/* Layout: fixed left rail + scrolling work area; dense, scannable cards; data in tabular figures. */
:root {
  --bg: #f3f5f4;
  --panel: #ffffff;
  --panel-2: #f8faf9;
  --ink: #14211f;
  --ink-2: #4b5b58;
  --mut: #7c8b88;
  --line: #e2e8e6;
  --line-2: #eef2f1;
  --accent: #0b7a6e;
  --accent-ink: #ffffff;
  --accent-soft: #dff1ee;
  --rail: #10201e;
  --rail-ink: #c9d6d3;
  --rail-hi: #ffffff;
  --hot: #d9472f;   --hot-soft: #fbe4df;
  --warm: #c98a12;  --warm-soft: #f8eed6;
  --cold: #55748f;  --cold-soft: #e3ebf2;
  --good: #1f8a4c;  --bad: #c2362b;
  --t-slate: #64748b; --t-sky: #0284c7; --t-indigo: #4f46e5; --t-teal: #0b7a6e; --t-green: #1f8a4c; --t-gold: #b7791f; --t-orange: #d9692f; --t-red: #c2362b;
  --shadow: 0 1px 2px rgba(16, 32, 30, .06), 0 4px 16px rgba(16, 32, 30, .05);
  --r: 10px;
  --f-display: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  --f-body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1716; --panel: #13201f; --panel-2: #172625; --ink: #e6efed; --ink-2: #b4c3c0; --mut: #85948f;
    --line: #24302f; --line-2: #1c2928; --accent: #2bb3a2; --accent-ink: #062320; --accent-soft: #123b36;
    --rail: #091211; --rail-ink: #9fb2ae; --rail-hi: #ffffff;
    --hot: #f26b52; --hot-soft: #3b1d18; --warm: #e5ac3d; --warm-soft: #3a2c12; --cold: #8eaecb; --cold-soft: #1c2b38;
    --good: #45c27a; --bad: #f07368;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1716; --panel: #13201f; --panel-2: #172625; --ink: #e6efed; --ink-2: #b4c3c0; --mut: #85948f;
  --line: #24302f; --line-2: #1c2928; --accent: #2bb3a2; --accent-ink: #062320; --accent-soft: #123b36;
  --rail: #091211; --rail-ink: #9fb2ae; --rail-hi: #ffffff;
  --hot: #f26b52; --hot-soft: #3b1d18; --warm: #e5ac3d; --warm-soft: #3a2c12; --cold: #8eaecb; --cold-soft: #1c2b38;
  --good: #45c27a; --bad: #f07368;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--f-body); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--f-display); letter-spacing: -.01em; text-wrap: balance; margin: 0; }
.num, td.n, .kpi .v { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100%; }
.rail { background: var(--rail); color: var(--rail-ink); display: flex; flex-direction: column; gap: 4px; padding: 18px 12px; padding-left: max(12px, env(safe-area-inset-left, 0px)); position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: var(--rail-hi); }
.brand .mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); font: 700 15px var(--f-display); }
.brand b { font: 700 17px var(--f-display); letter-spacing: -.02em; }
.brand small { display: block; color: var(--rail-ink); font-size: 11px; font-weight: 500; letter-spacing: .02em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button { all: unset; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--rail-ink); font-weight: 600; font-size: 13.5px; }
.nav button:hover { background: rgba(255,255,255,.06); color: var(--rail-hi); }
.nav button.on { background: rgba(255,255,255,.1); color: var(--rail-hi); }
.nav button .ic { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav .count { margin-left: auto; background: var(--hot); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 7px; line-height: 18px; }
.rail .foot { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; display: flex; flex-direction: column; gap: 6px; }
.rail .foot b { color: var(--rail-hi); font-weight: 600; }
.rail .foot button { all: unset; cursor: pointer; color: var(--rail-ink); text-decoration: underline; font-size: 12px; }

.work { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 12px 24px; padding-right: max(24px, env(safe-area-inset-right, 0px)); }
.top h1 { font-size: 20px; }
.top .sub { color: var(--mut); font-size: 12.5px; }
.top .grow { flex: 1; }
.gsearch { position: relative; width: min(320px, 40vw); }
.gsearch input { width: 100%; padding: 8px 12px 8px 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.gsearch svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--mut); }
.demo-pill { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; background: var(--warm-soft); color: var(--warm); padding: 4px 8px; border-radius: 6px; white-space: nowrap; }
.page { padding: 20px 24px 40px; padding-right: max(24px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 18px; }
.burger { display: none; }

/* ---------- primitives ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13px; white-space: nowrap; }
.btn:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.inp, select.inp, textarea.inp { width: 100%; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 10px; }
textarea.inp { min-height: 74px; resize: vertical; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.mut { color: var(--mut); }
.small { font-size: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card > .hd { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px 0; }
.card > .hd h3 { font-size: 14.5px; }
.card > .bd { padding: 12px 16px 16px; min-width: 0; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.seg button { all: unset; cursor: pointer; padding: 5px 10px; border-radius: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--accent-soft); color: var(--accent); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.chip i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st { color: var(--tone); background: color-mix(in srgb, var(--tone) 13%, transparent); }
.t-slate { --tone: var(--t-slate); } .t-sky { --tone: var(--t-sky); } .t-indigo { --tone: var(--t-indigo); } .t-teal { --tone: var(--t-teal); }
.t-green { --tone: var(--t-green); } .t-gold { --tone: var(--t-gold); } .t-orange { --tone: var(--t-orange); } .t-red { --tone: var(--t-red); }
.score { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-variant-numeric: tabular-nums; }
.score b { min-width: 30px; text-align: center; padding: 2px 6px; border-radius: 6px; font-size: 12.5px; }
.score.hot b { background: var(--hot-soft); color: var(--hot); } .score.warm b { background: var(--warm-soft); color: var(--warm); } .score.cold b { background: var(--cold-soft); color: var(--cold); }
.score span { font-size: 11.5px; color: var(--mut); font-weight: 600; }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 800; flex: none; }
.empty { padding: 30px; text-align: center; color: var(--mut); }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 200; box-shadow: var(--shadow); font-weight: 600; }
.toast.bad { background: var(--bad); color: #fff; }

/* ---------- dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi .l { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--mut); font-weight: 700; }
.kpi .v { font: 700 26px/1.1 var(--f-display); }
.kpi .d { font-size: 12px; color: var(--ink-2); }
.kpi .d .up { color: var(--good); font-weight: 700; } .kpi .d .down { color: var(--bad); font-weight: 700; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.chart { width: 100%; display: block; }
.chart text { fill: var(--mut); font: 11px var(--f-body); }
.chart .gl { stroke: var(--line-2); }
.funnel { display: flex; flex-direction: column; gap: 7px; }
.funnel .fr { display: grid; grid-template-columns: 120px minmax(0, 1fr) 92px; align-items: center; gap: 10px; font-size: 13px; }
.funnel .bar { height: 26px; border-radius: 6px; background: var(--line-2); position: relative; overflow: hidden; }
.funnel .bar span { position: absolute; inset: 0 auto 0 0; background: var(--tone); border-radius: 6px; display: flex; align-items: center; padding-left: 8px; color: #fff; font-weight: 700; font-size: 12px; min-width: 28px; }
.funnel .pct { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.hbars { display: flex; flex-direction: column; gap: 8px; }
.hb { display: grid; grid-template-columns: minmax(80px, 140px) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 12.5px; }
.hb .lb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb .tr { height: 10px; background: var(--line-2); border-radius: 99px; overflow: hidden; display: flex; }
.hb .tr i { display: block; height: 100%; }
.hb .n { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.heat { display: grid; grid-template-columns: 34px repeat(13, minmax(0, 1fr)); gap: 3px; font-size: 10.5px; color: var(--mut); }
.heat div { aspect-ratio: 1.6; border-radius: 4px; display: grid; place-items: center; }
.heat .c { background: color-mix(in srgb, var(--accent) calc(var(--a) * 100%), var(--line-2)); color: transparent; }
.heat .c:hover { color: var(--accent-ink); font-weight: 700; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--mut); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; font-weight: 700; background: var(--panel); position: sticky; top: 0; }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t td.n, table.t th.n { text-align: right; }
table.t tbody tr { cursor: pointer; }
table.t tbody tr:hover td { background: var(--panel-2); }
.tw { overflow-x: auto; }
.todo li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.todo { list-style: none; margin: 0; padding: 0; }
.todo li:last-child { border-bottom: 0; }
.todo .when { margin-left: auto; font-size: 12px; font-weight: 700; white-space: nowrap; }
.todo .when.late { color: var(--bad); }

/* ---------- pipeline ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column; min-height: 300px; max-height: calc(100vh - 190px); }
.col .ch { padding: 10px 12px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.col .ch b { font-size: 13px; }
.col .ch .c { margin-left: auto; font-size: 12px; color: var(--mut); font-variant-numeric: tabular-nums; }
.col .ch .bar { width: 4px; height: 16px; border-radius: 2px; background: var(--tone); }
.col .cb { padding: 8px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: 1; }
.col.drop { outline: 2px dashed var(--accent); outline-offset: -4px; }
.lc { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 6px; cursor: grab; box-shadow: 0 1px 1px rgba(0,0,0,.03); }
.lc:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.lc.dragging { opacity: .45; }
.lc .nm { font-weight: 700; display: flex; justify-content: space-between; gap: 8px; }
.lc .meta { font-size: 12px; color: var(--ink-2); display: flex; gap: 8px; flex-wrap: wrap; }
.lc .foot { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: var(--mut); }
.col .more { text-align: center; font-size: 12px; color: var(--mut); padding: 6px; }

/* ---------- leads ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters .inp { width: auto; min-width: 140px; }
.filters .q { min-width: 220px; flex: 1; }
.bulk { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 8px; padding: 8px 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 2px 0; font-size: 12.5px; color: var(--mut); }

/* ---------- drawer ---------- */
.ov { position: fixed; inset: 0; background: rgba(8, 18, 17, .38); z-index: 80; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100%); background: var(--panel); z-index: 90; overflow-y: auto; box-shadow: -12px 0 40px rgba(0,0,0,.18); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); padding-right: env(safe-area-inset-right, 0px); }
.dh { padding: 18px 20px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 14px; align-items: flex-start; }
.dh h2 { font-size: 20px; }
.ring { width: 64px; height: 64px; flex: none; position: relative; }
.ring svg { width: 64px; height: 64px; transform: rotate(-90deg); }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font: 700 18px var(--f-display); }
.ds { padding: 14px 20px; border-bottom: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 10px; }
.ds h4 { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--mut); }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.factors { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.factors li { display: flex; justify-content: space-between; }
.factors .p { font-weight: 700; font-variant-numeric: tabular-nums; } .factors .p.pos { color: var(--good); } .factors .p.neg { color: var(--bad); }
.tl { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.tl li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; padding-bottom: 12px; position: relative; }
.tl li::before { content: ""; position: absolute; left: 10px; top: 20px; bottom: 0; width: 2px; background: var(--line-2); }
.tl li:last-child::before { display: none; }
.tl .dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 11px; }
.tl .tx { font-size: 13px; }
.tl .tx small { display: block; color: var(--mut); font-size: 11.5px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.copy { cursor: pointer; border-bottom: 1px dashed var(--mut); }

/* ---------- agenda ---------- */
.agenda { display: grid; grid-template-columns: 48px repeat(7, minmax(110px, 1fr)); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--panel); min-width: 860px; }
.agenda .h { background: var(--panel-2); padding: 8px; font-size: 12px; font-weight: 700; border-bottom: 1px solid var(--line); text-align: center; }
.agenda .h.today { color: var(--accent); }
.agenda .tm { font-size: 11px; color: var(--mut); padding: 4px 6px; border-top: 1px solid var(--line-2); text-align: right; }
.agenda .slot { border-top: 1px solid var(--line-2); border-left: 1px solid var(--line-2); min-height: 46px; padding: 3px; display: flex; flex-direction: column; gap: 3px; }
.agenda .ev { background: color-mix(in srgb, var(--tone) 14%, var(--panel)); border-left: 3px solid var(--tone); border-radius: 5px; padding: 3px 6px; font-size: 11.5px; cursor: pointer; line-height: 1.25; }
.agenda .ev b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- settings ---------- */
.wrow { display: grid; grid-template-columns: minmax(0, 1fr) 160px 44px; gap: 10px; align-items: center; font-size: 13px; padding: 4px 0; }
.wrow input[type=range] { width: 100%; accent-color: var(--accent); }
.wrow output { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
code.u { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; display: block; word-break: break-all; font: 12px var(--f-mono); }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login form { width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; padding: 28px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 100; transform: translateX(-100%); transition: transform .2s; height: 100%; }
  .rail.open { transform: none; }
  .burger { display: inline-flex; }
  .top { padding: 10px 16px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); flex-wrap: wrap; }
  .gsearch { order: 5; width: 100%; }
  .page { padding: 14px 16px 30px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .funnel .fr { grid-template-columns: 90px minmax(0, 1fr) 70px; }
  .hb { grid-template-columns: 90px minmax(0, 1fr) auto; }
  .wrow { grid-template-columns: minmax(0, 1fr) 110px 40px; }
}

/* fixes */
[hidden] { display: none !important; }
.btn.burger { display: none; }
.burger svg { width: 18px; height: 18px; }
td.num { white-space: nowrap; }
@media (max-width: 860px) { .btn.burger { display: inline-flex; } }
