/* CRM shell. Existing forms and module-specific layout rules remain in style.css. */
:root {
  --green: #087653;
  --green2: #153f35;
  --bg: #f7f7f2;
  --line: #dce6e1;
  --text: #172b25;
  --gold: #d3a763;
}
#crmApp { min-height: 100vh; }
.crmChrome {
  position: sticky;
  top: 0;
  z-index: 15;
  background: var(--green2);
  box-shadow: 0 3px 12px #153f3525;
}
.crmTopbar {
  min-height: 68px;
  padding: 10px clamp(14px, 3vw, 38px);
  flex-direction: row;
  align-items: center;
  background: var(--green2);
  color: #fff;
}
.crmBrand { display: flex; gap: 12px; align-items: center; min-width: 0; }
.crmBrandIcon {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  color: var(--green2);
  background: var(--gold);
  border-radius: 13px;
  font-size: 22px;
  font-weight: 800;
}
.crmBrand h1 { color: #fff; font-size: 20px; font-weight: 800; letter-spacing: -.035em; line-height: 1.12; }
.crmBrand h1 span { color: #f3cc8e; font-size: .8em; }
.crmBrand small { display: block; color: #dcebe3; opacity: 1; margin-top: 3px; font-size: 13px; }
.crmTopActions { align-items: center; justify-content: flex-end; }
#newLead { background: var(--gold); color: #153f35; }
#newLead:hover { background: #efc98c; }
.crmAccountBlock { display: grid; justify-items: end; gap: 4px; min-width: 0; }
.crmAccountBlock .onlineBadge {
  position: static;
  padding: 3px 8px;
  background: #174e3f;
  color: #fff;
  font: 600 12px/1.4 system-ui, sans-serif;
  white-space: nowrap;
}
.crmAccount { position: relative; }
.crmAccount summary { padding: 8px 10px; border: 1px solid #739a8a; border-radius: 10px; cursor: pointer; color: #fff; }
.crmAccount .userBadge { background: transparent; border: 0; color: #fff; padding: 0; font-size: 14px; }
.crmAccountActions {
  position: absolute;
  inset-inline-end: 0;
  z-index: 2;
  top: calc(100% + 8px);
  width: min(220px, 85vw);
  display: grid;
  gap: 5px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 32px #193b2e1c;
}
.crmAccountActions > :is(button, label) { text-align: left; margin: 0; }
#backupStatus:empty { display: none; }
#crmNav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px clamp(14px, 3vw, 38px);
  overflow: visible;
  border: 0;
  border-top: 1px solid #477363;
  background: #205646;
}
.crmNavGroup { position: relative; }
.crmNavGroup:not(:has(button:not([hidden]),a:not([hidden]))) { display: none; }
.crmNavGroup > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 750;
  cursor: pointer;
  list-style: none;
}
.crmNavGroup > summary::-webkit-details-marker { display: none; }
.crmNavGroup > summary::after {
  content: '';
  width: 6px;
  height: 6px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: translateY(-2px) rotate(45deg);
}
.crmNavGroup[open] > summary::after { transform: translateY(2px) rotate(225deg); }
.crmNavGroup > summary:hover,
.crmNavGroup[open] > summary { background: #32745f; }
.crmNavGroup:has([aria-current="page"]) > summary { background: var(--gold); color: #153f35; }
.crmNavItems {
  position: absolute;
  inset-inline-start: 0;
  top: calc(100% + 5px);
  z-index: 1;
  width: min(240px, calc(100vw - 28px));
  padding: 6px;
  border: 1px solid #b7cbbf;
  border-top: 3px solid var(--gold);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 26px #153f3530;
}
#crmNav :is(button,a) {
  display: block;
  width: 100%;
  min-height: 38px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #29483d;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 650;
  text-align: left;
  text-decoration: none;
  white-space: normal;
}
#crmNav :is(button,a):hover { background: #eef4f1; }
#crmNav :is(button,a)[aria-current="page"] {
  background: #e2f2e8;
  border-color: #bddfcb;
  color: #153f35;
  box-shadow: inset 3px 0 var(--green);
  font-weight: 800;
}
#crmApp :is(button,a,summary,input,select,textarea):focus-visible { outline: 2px solid #087653; outline-offset: 2px; }
.crmChrome :is(summary,#newLead):focus-visible { outline-color: #f3cc8e !important; }
#crmApp > main {
  width: 100%;
  min-width: 0;
  max-width: 1550px;
  margin: 0 auto;
  padding: clamp(16px, 2.6vw, 38px);
}
#crmApp > main[data-module-open] > .view { display: none; }
#crmApp .view > h2, .crmModuleHeader h2 { margin: 0 0 12px; letter-spacing: -.035em; }
.crmDashboardHeading {
  padding: clamp(20px, 3vw, 36px);
  border: 1px solid #225646;
  border-left: 5px solid var(--gold);
  border-radius: 18px;
  background: linear-gradient(112deg, #153f35, #17614a);
  color: #fff;
}
.crmDashboardHeading p, .crmModuleLabel { color: #296754; font-size: 11px; font-weight: 800; letter-spacing: .12em; margin: 0 0 5px; }
.crmDashboardHeading h2 { margin: 0 0 4px; font-size: clamp(24px, 3vw, 36px); line-height: 1.2; letter-spacing: -.045em; }
.crmDashboardHeading p { color: #f3cc8e; }
.crmDashboardHeading span { color: #ebf4ed; }
#crmApp .cards { gap: 12px; margin: 16px 0 24px; }
#crmApp :is(.card,.panel,.tableWrap,.column) { border-radius: 14px; }
#crmApp .card { border-top: 3px solid var(--green); box-shadow: 0 3px 10px #183f2f09; }
#crmApp .card:nth-child(even) { border-top-color: var(--gold); }
#crmApp .card b { font-size: clamp(24px, 2.5vw, 34px); color: var(--green2); }
#crmApp .tableWrap th { background: #f1f6f3; color: #365c4e; }
#crmApp dialog { border-radius: 16px; }
.crmModuleHeader { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 12px; }
.crmModuleHeader h2, .crmModuleHeader .actions { margin: 0; }
#crmModuleStatus { margin: 0 0 10px; color: #496357; }
#crmModuleFrames iframe {
  display: block;
  width: 100%;
  height: max(520px, calc(100dvh - 230px));
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
@media (max-width: 680px) {
  .crmTopbar { min-height: 54px; }
  #crmNav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
  .crmNavGroup:nth-child(even) > .crmNavItems { inset-inline-start: auto; inset-inline-end: 0; }
  .crmNavGroup > summary { min-height: 36px; font-size: 13px; }
}
@media (max-width: 540px) {
  .crmBrandIcon { width: 30px; height: 30px; flex-basis: 30px; border-radius: 8px; font-size: 17px; }
  .crmBrand small { display: none; }
  .crmBrand { gap: 6px; }
  .crmBrand h1 { font-size: 16px; }
  #newLead, .crmAccount summary { font-size: 13px; padding: 7px; }
  .crmAccount .userBadge { display: inline-block; max-width: 80px; vertical-align: middle; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
  #crmModuleFrames iframe { height: max(520px, calc(100dvh - 235px)); }
}

.kanbanToolbar {
  position: sticky;
  top: var(--kanban-controls-top, 122px);
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  background: var(--bg);
}
.kanbanToolbar h2 { margin: 0 0 3px; }
.kanbanToolbar p { margin: 0; }
.kanbanActions { display: flex; flex: 0 0 auto; gap: 7px; }
.kanbanActions button {
  min-width: 44px;
  min-height: 44px;
  padding: 5px;
  border: 1px solid #24634f;
  border-radius: 9px;
  background: linear-gradient(155deg, #297358, #153f35);
  color: #fff;
  font-size: 20px;
  box-shadow: 0 3px 0 #12382e, 0 5px 9px #153f3525;
}
.kanbanActions button:disabled {
  background: #e2ece5;
  border-color: #c3d4c8;
  color: #536b60;
  box-shadow: none;
}
#kanban { padding: 2px 3px 16px; gap: 12px; cursor: grab; }
#kanban:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
#kanban .column {
  background: linear-gradient(155deg, #edf5ef, #dce8e1);
  border: 1px solid #cbdad0;
  border-top: 3px solid #257456;
  box-shadow: 0 3px 8px #153f3516;
}
#kanban .column h3 { margin: 0 0 10px; color: #153f35; }
#kanban .leadCard {
  background: linear-gradient(160deg, #fff 65%, #f5faf6);
  border-left-color: #df8b45;
  box-shadow: 0 2px 0 #c5d8cc, 0 4px 9px #153f3518;
}
#kanban .leadCard:hover { box-shadow: 0 2px 0 #91b3a0, 0 6px 12px #153f3528; }

#dashboard :is(button,a).card {
  color: var(--text);
  text-align: left;
  text-decoration: none;
}
#dashboard :is(button,a).card:focus-visible {
  outline: 2px solid var(--green2);
  outline-offset: 2px;
}
#owner-dashboard {
  margin-bottom: 16px;
}


#crmApp:has(main[data-module-open]) #newLead,
main[data-module-open] .crmModuleLabel { display: none; }
#crmModuleFrames iframe {
  border: 0;
  border-radius: 0;
  background: transparent;
}

#kanban .lead-overdue { color: #a62d24; font-weight: 700; }
#follow-up-form { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin-top: 12px; }
#kanban .leadCard { color: #153f35; overflow-wrap: anywhere; }
#kanban .lead-card-header { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 10px; border-bottom: 1px solid #dce6e1; padding-bottom: 6px; margin-bottom: 7px; }
#kanban .lead-card-temperature { color: #53665c; }
#kanban .lead-card-name, #kanban .lead-card-contact { display: flex; align-items: flex-start; gap: 5px; margin-top: 5px; }
#kanban .lead-card-name { font-size: 15px; }
#kanban .lead-card-contact, #kanban .leadCard small { font-size: 12px; }
#kanban .leadCard svg { flex: 0 0 14px; width: 14px; height: 14px; color: #087653; margin-top: 2px; }
#kanban .lead-card-contact a { color: #14684f; min-width: 0; }
#kanban .lead-wa { font-size: 10px; }
#kanban .lead-card-more { display: block; margin: 8px auto; padding: 4px 7px; font-size: 11px; }
#kanban .lead-card-stats { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px 4px; margin: 0; border-block: 1px solid #dce6e1; padding: 7px 0; }
#kanban .lead-card-stats dt { font-size: 9px; color: #50635b; }
#kanban .lead-card-stats dd { font-size: 11px; font-weight: 700; margin: 1px 0 0; }
