/* Sahel CRM — design tokens */
:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f2f4f7; --surface-3: #e9edf2; --text: #101828; --text-2: #344054; --muted: #667085; --line: #e4e7ec; --line-2: #eef0f3;
  --primary: #0e6b78; --primary-hover: #0b5965; --primary-ink: #ffffff; --primary-soft: #e3f1f3; --accent: #b8823a; --accent-soft: #f7eddf;
  --ok: #067647; --ok-soft: #e7f6ee; --warn: #b54708; --warn-soft: #fef4e6; --bad: #c01f1a; --bad-soft: #fdecea; --info: #175cd3; --info-soft: #eaf2fe;
  --wa: #128c4b; --call: #b8823a;
  --side: #ffffff; --side-ink: #344054; --side-on: #e3f1f3; --side-on-ink: #0e6b78;
  /* chart series (validated categorical slots 1–3) */
  --s-form: #257de0; --s-wa: #00b894; --s-other: #f47230; --s-call: #8e5cd9;
  --o0: #84b9f3; --o1: #6aabf1; --o2: #519ced; --o3: #338ced; --o4: #257de0; --o5: #2370cd; --o6: #1b64be; --o7: #1757ac;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.05);
  --shadow-md: 0 4px 16px -4px rgba(16,24,40,.08), 0 2px 4px -2px rgba(16,24,40,.04);
  --font: "IBM Plex Sans Arabic", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0e13; --surface: #11171f; --surface-2: #161d27; --surface-3: #1d2632; --text: #e9edf2; --text-2: #c8d0db; --muted: #8d99aa; --line: #222c39; --line-2: #1a222d;
    --primary: #3cb4c2; --primary-hover: #5cc4d0; --primary-ink: #04171b; --primary-soft: #0f2b31; --accent: #e0aa62; --accent-soft: #33261a;
    --ok: #47cd89; --ok-soft: #0f2a1d; --warn: #f5b25b; --warn-soft: #33240f; --bad: #f97066; --bad-soft: #3a1714; --info: #6ea8fe; --info-soft: #14243d;
    --wa: #25b862; --call: #d09a52;
    --side: #0d1219; --side-ink: #b4bfcd; --side-on: #16262d; --side-on-ink: #5cc4d0;
    --s-form: #338ced; --s-wa: #00a888; --s-other: #e76624; --s-call: #a57bf0;
    --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-md: 0 8px 24px -8px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0e13; --surface: #11171f; --surface-2: #161d27; --surface-3: #1d2632; --text: #e9edf2; --text-2: #c8d0db; --muted: #8d99aa; --line: #222c39; --line-2: #1a222d;
  --primary: #3cb4c2; --primary-hover: #5cc4d0; --primary-ink: #04171b; --primary-soft: #0f2b31; --accent: #e0aa62; --accent-soft: #33261a;
  --ok: #47cd89; --ok-soft: #0f2a1d; --warn: #f5b25b; --warn-soft: #33240f; --bad: #f97066; --bad-soft: #3a1714; --info: #6ea8fe; --info-soft: #14243d;
  --wa: #25b862; --call: #d09a52;
  --side: #0d1219; --side-ink: #b4bfcd; --side-on: #16262d; --side-on-ink: #5cc4d0;
  --s-form: #338ced; --s-wa: #00a888; --s-other: #e76624; --s-call: #a57bf0;
  --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-md: 0 8px 24px -8px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14.5px/1.6 var(--font); -webkit-font-smoothing: antialiased; padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
html[lang="en"] body { font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: inherit; }
h1 { font-size: 1.5rem; line-height: 1.3; margin: 0; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.02rem; margin: 0 0 10px; font-weight: 650; }
h3 { font-size: .95rem; margin: 0 0 8px; font-weight: 650; }
p { margin: 0; }
.muted { color: var(--muted); } .small { font-size: .84rem; } .nowrap { white-space: nowrap; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.ico { flex: none; }
[dir="rtl"] .flip { transform: scaleX(-1); }
.mobile-only { display: flex; }

/* ---------- App shell ---------- */
.app { min-height: 100vh; }
.sidebar { display: none; }
.shell { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 60%, #0b2530)); }
.brand .logo { color: #fff; font-weight: 700; font-size: 1.05rem; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.brand b { font-size: 1.05rem; }
.brand small { display: block; font-size: .7rem; color: var(--muted); letter-spacing: .12em; font-weight: 600; line-height: 1; }
.topbar .brand.mobile-only .logo { width: 30px; height: 30px; }
.tsearch { display: none; align-items: center; gap: 8px; flex: 1; max-width: 420px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 0 14px; color: var(--muted); }
.tsearch input { border: 0; background: transparent; min-height: 38px; padding: 0; box-shadow: none; }
.tsearch input:focus { outline: none; }
.tsearch:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.tright { margin-inline-start: auto; display: flex; align-items: center; gap: 6px; }
.tright form { margin: 0; }
.tbtn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); display: grid; place-items: center; cursor: pointer; font: inherit; font-weight: 700; font-size: .85rem; }
.tbtn:hover { background: var(--surface-2); }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; } :root[data-theme="dark"] .i-moon { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .i-sun { display: block; } :root:not([data-theme="light"]) .i-moon { display: none; } }

.avatar { width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .8rem; text-decoration: none; background: var(--primary-soft); color: var(--primary); text-transform: uppercase; }
.avatar.sm { width: 34px; height: 34px; }
.avatar.xs { width: 24px; height: 24px; font-size: .66rem; }
.avatar.lg { width: 52px; height: 52px; font-size: 1.1rem; }

.main { max-width: 1320px; margin: 0 auto; padding: 18px 16px 28px; }
.phead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.phead p { margin-top: 4px; font-size: .9rem; }
.phead-a { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumb { font-size: .82rem; color: var(--muted); text-decoration: none; margin-bottom: 8px; display: inline-flex; }
.crumb:hover { color: var(--primary); }

.bottomnav { position: fixed; bottom: 0; inset-inline: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 6px; text-decoration: none; color: var(--muted); font-size: .68rem; font-weight: 500; }
.bottomnav a.on { color: var(--primary); }

@media (max-width: 639px) { .hide-sm { display: none; } .btn.primary.sm:has(.ico) { padding: 0; width: 38px; height: 38px; } }
@media (min-width: 640px) { .tsearch { display: flex; } }
@media (min-width: 1000px) {
  body { padding-bottom: 0; }
  .mobile-only { display: none !important; }
  .bottomnav { display: none; }
  .app { display: grid; grid-template-columns: 256px minmax(0, 1fr); }
  .sidebar { display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; background: var(--side); border-inline-end: 1px solid var(--line); padding: 18px 14px; gap: 18px; }
  .sidebar .brand { padding: 2px 8px 10px; }
  .snav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
  .snav-h { font-size: .7rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; padding: 14px 12px 6px; }
  .snav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--side-ink); text-decoration: none; font-weight: 500; }
  .snav a:hover { background: var(--surface-2); color: var(--text); }
  .snav a.on { background: var(--side-on); color: var(--side-on-ink); font-weight: 600; }
  .snav a .ico { opacity: .85; }
  .sme-wrap { display: flex; gap: 8px; align-items: center; }
  .sme-wrap form { margin: 0; }
  .sme-wrap .tbtn:hover { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
  .sme { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; border: 1px solid var(--line); text-decoration: none; background: var(--surface); }
  .sme:hover, .sme.on { border-color: var(--primary); }
  .sme-t { min-width: 0; } .sme-t b { display: block; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .sme-t small { color: var(--muted); font-size: .76rem; }
  .topbar { padding: 12px 28px; }
  .main { padding: 26px 28px 40px; }
}

/* ---------- Generic UI ---------- */
.flash { display: flex; align-items: center; gap: 8px; margin: 0 0 16px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--ok-soft); color: var(--ok); font-weight: 500; }
.flash.bad { background: var(--bad-soft); color: var(--bad); }
.card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.panel { padding: 18px; }
.panel-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-h h2 { margin: 0; }
.panel-h p { margin-top: 2px; }
.link-more { font-size: .84rem; color: var(--primary); text-decoration: none; font-weight: 600; }
.grid { display: grid; gap: 14px; }
.grid.k4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 700px) { .grid.k4 { grid-template-columns: repeat(4, 1fr); } .grid.two { grid-template-columns: 1fr 1fr; } .grid.side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } }
.kpi { text-decoration: none; display: block; }
.kpi b { display: block; font-size: 1.8rem; line-height: 1.2; }
.kpi.alert b { color: var(--bad); }
.section { margin-top: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar select { width: auto; min-width: 170px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); padding: 8px 14px; border-radius: var(--radius-sm); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; min-height: 40px; box-shadow: var(--shadow); transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 11px; min-height: 34px; font-size: .86rem; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.wa { background: var(--wa); color: #fff; border-color: var(--wa); }
.btn.call { background: var(--call); color: #fff; border-color: var(--call); }
.btn.big { min-height: 52px; font-size: 1.02rem; flex: 1; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn[disabled] { opacity: .5; pointer-events: none; }

label { display: block; font-size: .82rem; color: var(--text-2); font-weight: 500; margin-bottom: 5px; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 11px; min-height: 40px; transition: border-color .12s, box-shadow .12s; }
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.btn:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; vertical-align: middle; accent-color: var(--primary); box-shadow: none; }
.field { margin-bottom: 14px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .93rem; margin: 6px 0; font-weight: 400; }
.form-grid { display: grid; gap: 0 14px; }
@media (min-width: 700px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.inp-ico { position: relative; display: flex; align-items: center; }
.inp-ico .ico { position: absolute; inset-inline-start: 12px; color: var(--muted); pointer-events: none; }
.inp-ico input { padding-inline-start: 36px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 500; background: var(--surface-2); color: var(--text-2); white-space: nowrap; border: 1px solid var(--line-2); }
.badge.wa { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.form { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.stage { background: var(--primary-soft); color: var(--primary); font-weight: 600; border-color: transparent; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: .76rem; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--text-2); }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.s-new { background: var(--info-soft); color: var(--info); }
.pill.s-contacted { background: var(--primary-soft); color: var(--primary); }
.pill.s-interested { background: color-mix(in srgb, #7a5af8 14%, transparent); color: #6941c6; }
.pill.s-viewing { background: var(--accent-soft); color: var(--accent); }
.pill.s-negotiation { background: var(--warn-soft); color: var(--warn); }
.pill.s-reserved, .pill.s-won { background: var(--ok-soft); color: var(--ok); }
:root[data-theme="dark"] .pill.s-interested { color: #b9a6ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pill.s-interested { color: #b9a6ff; } }

/* ---------- Customer rows ---------- */
.lrows { display: flex; flex-direction: column; }
.lrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name qa" "stage age"; gap: 8px 12px; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--line-2); }
.lrow:last-child { border-bottom: 0; }
.lrow.lhead { display: none; }
.lcell { min-width: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lname { grid-area: name; text-decoration: none; flex-wrap: nowrap; }
.lname-t { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.lname-t b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lname:hover b { color: var(--primary); }
.lproj, .lsrc, .lown { display: none; }
.lstage { grid-area: stage; }
.lage { grid-area: age; justify-content: flex-end; }
.lqa { grid-area: qa; justify-content: flex-end; }
.lproj, .lsrc { flex-direction: column; align-items: flex-start; gap: 2px; line-height: 1.35; }
@media (min-width: 1100px) {
  .lrow { grid-template-columns: minmax(180px, 1.6fr) minmax(120px, 1.2fr) 150px minmax(110px, 1fr) minmax(110px, 1fr) 110px 136px; grid-template-areas: none; padding: 11px 8px; }
  .lrow > * { grid-area: auto !important; }
  .lrow.lhead { display: grid; font-size: .74rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding-top: 4px; padding-bottom: 10px; }
  .lproj, .lsrc, .lown { display: flex; }
  .lage { justify-content: flex-start; }
  .lrow:not(.lhead):hover { background: var(--surface-2); border-radius: 10px; }
  .lrow.compact { grid-template-columns: minmax(0, 1fr) 160px 110px 136px; }
}
.panel .lrows { margin: 0 -8px; }
.qa { display: flex; gap: 6px; }
.qa form { margin: 0; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; text-decoration: none; color: #fff; cursor: pointer; }
.icon-btn.wa { background: var(--wa); } .icon-btn.call { background: var(--call); }
.icon-btn:hover { filter: brightness(1.08); }

.list { display: grid; gap: 8px; }
.lead { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; text-decoration: none; }

.filters { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; margin-bottom: 10px; padding-bottom: 14px; border-bottom: 1px solid var(--line-2); }
.filters .q { grid-column: 1 / -1; }
@media (min-width: 1000px) { .filters { grid-template-columns: minmax(220px, 2fr) repeat(5, minmax(0, 1fr)) auto; } .filters .q { grid-column: auto; } }
.pager { display: flex; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line-2); margin-top: 4px; }

table.t { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.t th, table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); text-align: start; vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t th { font-size: .75rem; color: var(--muted); font-weight: 600; background: var(--surface-2); text-transform: uppercase; letter-spacing: .03em; }
.scroll-x { overflow-x: auto; }

/* ---------- Customer card ---------- */
.lead-head { gap: 12px; }
.contact-bar { display: flex; gap: 10px; margin: 14px 0 0; }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.dl dt { color: var(--muted); font-size: .84rem; } .dl dd { margin: 0; font-weight: 500; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; position: relative; }
.timeline li { position: relative; padding: 8px 14px; padding-inline-start: 22px; border-radius: 10px; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: 6px; top: 16px; width: 8px; height: 8px; border-radius: 50%; background: var(--line); box-shadow: 0 0 0 3px var(--surface); }
.timeline li::after { content: ""; position: absolute; inset-inline-start: 9.5px; top: 26px; bottom: -10px; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li.note { background: var(--surface-2); }
.timeline li.note::before { background: var(--primary); }
.timeline li.contact::before { background: var(--wa); }
.timeline li.sys { color: var(--muted); font-size: .88rem; }
.timeline .who { font-size: .78rem; color: var(--muted); }
.timeline .body { white-space: pre-wrap; margin-top: 2px; }
.outcome { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.outcome .row .btn { flex: 1 1 auto; }

/* ---------- Pipeline ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x mandatory; }
.col { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 10px; scroll-snap-align: start; min-height: 160px; }
.col h3 { display: flex; justify-content: space-between; align-items: center; font-size: .86rem; padding: 2px 4px 8px; margin: 0; }
.col .card { padding: 12px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: grab; }
.col .card:hover { box-shadow: var(--shadow-md); }
.col .card a { text-decoration: none; }
.col.drop { outline: 2px dashed var(--primary); background: var(--primary-soft); }

.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 14px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; width: fit-content; max-width: 100%; }
.tabs a { padding: 6px 14px; border-radius: 9px; text-decoration: none; color: var(--muted); white-space: nowrap; font-weight: 500; font-size: .9rem; }
.tabs a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow); }
.seg a { padding: 5px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: .85rem; font-weight: 500; }
.seg a.on { background: var(--primary); color: var(--primary-ink); }
.perm-grid { display: grid; gap: 2px 12px; } @media (min-width: 700px) { .perm-grid { grid-template-columns: 1fr 1fr; } }
.more-list a { display: flex; padding: 15px 16px; border-bottom: 1px solid var(--line-2); text-decoration: none; font-weight: 500; }
.more-list a:last-child { border-bottom: 0; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); display: flex; gap: 8px; justify-content: center; align-items: center; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 1.3rem; letter-spacing: .1em; padding: 6px 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; display: inline-block; direction: ltr; }

/* ---------- Dashboard ---------- */
.alerts { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.alert-chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px; text-decoration: none; font-size: .88rem; font-weight: 500; border: 1px solid transparent; }
.alert-chip b { font-size: 1rem; }
.alert-chip.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 20%, transparent); }
.alert-chip.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 20%, transparent); }
.alert-chip:hover { filter: brightness(.97); }

.kpis { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 16px; }
@media (min-width: 1100px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi-top { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-weight: 500; font-size: .88rem; }
.kpi-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.kpi-ico.i1 { background: var(--info-soft); color: var(--info); }
.kpi-ico.i2 { background: var(--primary-soft); color: var(--primary); }
.kpi-ico.i3 { background: var(--accent-soft); color: var(--accent); }
.kpi-ico.i4 { background: var(--ok-soft); color: var(--ok); }
.kpi-v { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.kpi-v b { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-f { font-size: .78rem; }
.delta { font-size: .76rem; font-weight: 600; padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.delta.up { background: var(--ok-soft); color: var(--ok); }
.delta.down { background: var(--bad-soft); color: var(--bad); }
.delta.flat { background: var(--surface-2); color: var(--muted); }
.spark { width: 100%; height: 30px; display: block; }
[dir="rtl"] .spark { transform: scaleX(-1); }
.spark-l { fill: none; stroke: var(--s-form); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.spark-a { fill: color-mix(in srgb, var(--s-form) 12%, transparent); stroke: none; }
.meter { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin: 8px 0 6px; }
.meter i { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.meter.sm { width: 70px; height: 6px; margin: 0; }
.rate { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }

.dgrid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); grid-auto-flow: dense; }
@media (max-width: 1099px) { .p-wait { order: -1; } }
@media (min-width: 1100px) { .dgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .dgrid .span2 { grid-column: span 2; } }

.legend { list-style: none; margin: 0; padding: 0; display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--text-2); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend b { font-variant-numeric: tabular-nums; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.s-wa { background: var(--s-wa); } .s-form { background: var(--s-form); } .s-other { background: var(--s-other); }

.cols { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; height: 250px; }
.yaxis { display: flex; flex-direction: column; justify-content: space-between; font-size: .72rem; color: var(--muted); text-align: end; padding-bottom: 22px; font-variant-numeric: tabular-nums; }
.yaxis span { line-height: 0; }
.plot { position: relative; }
.grid-lines { position: absolute; inset: 0 0 22px 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.grid-lines i { display: block; height: 1px; background: var(--line-2); }
.grid-lines i:last-child { background: var(--line); }
.bars { position: absolute; inset: 0; display: flex; align-items: stretch; gap: 2px; }
.bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; position: relative; min-width: 0; padding-bottom: 22px; cursor: default; border-radius: 6px; }
.bar:hover, .bar:focus { background: color-mix(in srgb, var(--surface-3) 60%, transparent); outline: none; }
.stack { display: flex; flex-direction: column; gap: 2px; width: min(70%, 26px); margin: 0 auto; min-height: 0; }
.stack i { display: block; min-height: 3px; }
.stack i:first-child { border-radius: 4px 4px 0 0; }
.xl { position: absolute; bottom: 0; inset-inline: -20px; text-align: center; font-size: .68rem; color: var(--muted); white-space: nowrap; height: 18px; }

.funnel { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.funnel li { display: grid; grid-template-columns: 104px minmax(0, 1fr) 34px; align-items: center; gap: 10px; font-size: .85rem; border-radius: 6px; }
.funnel li:hover .f-bar i { filter: brightness(1.1); }
.f-l { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.f-bar { height: 14px; display: flex; }
.f-bar i { display: block; height: 100%; border-radius: 0 4px 4px 0; }
[dir="rtl"] .f-bar i { border-radius: 4px 0 0 4px; }
.f-n { text-align: end; font-variant-numeric: tabular-nums; }
.o0 { background: var(--o0); } .o1 { background: var(--o1); } .o2 { background: var(--o2); } .o3 { background: var(--o3); }
.o4 { background: var(--o4); } .o5 { background: var(--o5); } .o6 { background: var(--o6); } .o7 { background: var(--o7); }

.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.hb-t { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: 5px; gap: 8px; }
.hb-t .muted { font-variant-numeric: tabular-nums; }
.hb-track { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.hb-track i { display: block; height: 100%; background: var(--s-form); border-radius: 999px; }

table.mini { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.mini th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; text-align: start; padding: 0 8px 8px; border-bottom: 1px solid var(--line); }
table.mini td { padding: 10px 8px; border-bottom: 1px solid var(--line-2); }
table.mini tr:last-child td { border-bottom: 0; }
table.mini .num { text-align: end; font-variant-numeric: tabular-nums; }
.who { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }

.tasks, .feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.tasks li { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line-2); }
.tasks li:last-child { border-bottom: 0; }
.tasks form { margin: 0; }
.tick { width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--line); background: var(--surface); color: transparent; display: grid; place-items: center; cursor: pointer; padding: 0; }
.tick:hover { border-color: var(--ok); color: var(--ok); }
.task-t { flex: 1; min-width: 0; display: flex; flex-direction: column; text-decoration: none; line-height: 1.35; }
.task-t small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed li { display: flex; gap: 10px; padding: 7px 0; font-size: .87rem; line-height: 1.45; }
.feed a { color: var(--primary); text-decoration: none; font-weight: 500; }
.feed-ico { width: 26px; height: 26px; border-radius: 8px; flex: none; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }

.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--text); color: var(--bg); padding: 8px 10px; border-radius: 9px; font-size: .78rem; line-height: 1.5; box-shadow: var(--shadow-md); max-width: 240px; }
.tip b { display: block; margin-bottom: 2px; }

/* filters fold away on phones behind the icon in the search box */
.ff-toggle { display: none; }
.ff-btn { position: absolute; inset-inline-end: 6px; width: 30px; height: 30px; margin: 0; border-radius: 8px; display: grid; place-items: center; color: var(--muted); cursor: pointer; }
.ff-btn .ico { position: static; }
.ff-btn:hover { background: var(--surface-2); color: var(--primary); }
@media (max-width: 999px) {
  .ff-toggle:not(:checked) ~ select, .ff-toggle:not(:checked) ~ .row { display: none; }
  .ff-toggle:checked ~ select { display: block; }
}
@media (min-width: 1000px) { .ff-btn { display: none; } }
.logout-row { display: flex; width: 100%; padding: 15px 16px; border: 0; background: none; font: inherit; font-weight: 600; color: var(--bad); cursor: pointer; text-align: start; }
.more-list form { margin: 0; }
/* quick notes (list, dashboard, pipeline) */
.qn { position: relative; }
.qn > summary { list-style: none; }
.qn > summary::-webkit-details-marker { display: none; }
.qn-btn { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); cursor: pointer; }
.qn-btn:hover, .qn[open] > .qn-btn { color: var(--primary); }
.qn-panel { position: absolute; top: calc(100% + 6px); inset-inline-end: 0; width: 300px; max-width: 85vw; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-md); padding: 10px; z-index: 40; margin: 0; }
.qn-panel textarea { width: 100%; min-height: 0; }
.qn-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
@media (max-width: 640px) { .qn-panel { position: fixed; inset: auto 12px 12px 12px; top: auto; width: auto; max-width: none; } }
.lnote { display: block; font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.lrow.compact .lnote { display: none; }
.kc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.col .lnote { margin-top: 4px; }
/* returning customers */
.badge.ret { background: var(--info-soft); color: var(--info); border-color: transparent; font-weight: 600; }
.badge.ret.big { font-size: .82rem; padding: 3px 11px; }
.inq { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.inq li { padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 10px; display: flex; flex-direction: column; gap: 4px; }
.inq li.ret { border-color: color-mix(in srgb, var(--info) 35%, var(--line)); }
.inq-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.kpi-split { display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap; }
.kpi-split > a { text-decoration: none; color: inherit; padding-inline-start: 18px; border-inline-start: 1px solid var(--line-2); }
.kpi-split .kpi-v b { font-size: 1.6rem; }
.nr-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--surface-3); gap: 2px; margin: 6px 0 10px; }
.nr-bar i { display: block; height: 100%; min-width: 4px; }
.nr-new { background: var(--primary); }
.nr-ret { background: var(--accent); }
.nr-legend { margin-bottom: 10px; }
.badge.buyer { background: var(--ok-soft); color: var(--ok); border-color: transparent; font-weight: 600; }
.badge.buyer.big { font-size: .82rem; padding: 3px 11px; }
.inq li.deal { border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
/* reports */
.s-call { background: var(--s-call); }
.rep-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; padding: 12px; }
.rep-controls select { width: auto; min-width: 160px; }
.rep-date { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); }
.rep-date input { width: auto; min-height: 36px; padding: 4px 8px; }
.rtable th, .rtable td { white-space: nowrap; }
.rtable th:first-child, .rtable td:first-child { position: sticky; inset-inline-start: 0; background: var(--surface); z-index: 1; }
.rtable tfoot td { border-top: 1px solid var(--line); border-bottom: 0; }
.rtable td.num a { text-decoration: none; font-weight: 600; }
.dgrid .span3 { grid-column: 1 / -1; }
.chart-legend { margin-bottom: 12px; }
.rep-kpis .kpi-v b a { color: inherit; text-decoration: none; }
.rep-funnel li { grid-template-columns: 110px minmax(0, 1fr) 84px; }
.rep-funnel .f-n small { font-weight: 500; }
