/* ==========================================================================
   SpiderWebSB Lead Center (started as the Buffing Bros demo)
   The "gold" tokens are the business's own color: app.js sets them from the
   tenant's brand.accent, adjusted per theme for contrast. Dark by default,
   light theme for reading outdoors in the sun.
   Chart series colors validated (dataviz validator) on both surfaces:
   blue / orange / aqua / violet / magenta in this fixed order.
   ========================================================================== */

:root {
  color-scheme: dark;
  --page: #0b0b0c;
  --surface: #16161a;
  --surface-2: #1c1c21;
  --surface-3: #25252b;
  --hover: rgba(255, 255, 255, .045);
  --line: rgba(255, 255, 255, .08);
  --line-2: rgba(255, 255, 255, .15);
  --text: #f4f0e8;
  --text-2: #c9c3b8;
  --muted: #918b81;
  --gold: #f4c430;
  --gold-hi: #ffe28a;
  --gold-ink: #17120a;
  --gold-text: #f4c430;
  --gold-wash: rgba(244, 196, 48, .12);
  --gold-line: rgba(244, 196, 48, .38);
  --mark: #f4c430;
  --grid: #26262c;
  --axis: #3b3b42;
  --s-gads: #3987e5;
  --s-meta: #d95926;
  --s-gbp: #199e70;
  --s-search: #9085e9;
  --s-social: #d55181;
  --good: #4ade80;
  --bad: #f87171;
  --warn: #fab219;
  --good-fill: #0ca30c;
  --crit-fill: #d03b3b;
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, .85);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Archivo", "Inter", system-ui, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --side: 240px;
}
:root[data-theme="light"] {
  color-scheme: light;
  --page: #f3f1ec;
  --surface: #ffffff;
  --surface-2: #f8f7f3;
  --surface-3: #efede7;
  --hover: rgba(20, 18, 14, .04);
  --line: rgba(20, 18, 14, .09);
  --line-2: rgba(20, 18, 14, .17);
  --text: #16140f;
  --text-2: #4b463e;
  --muted: #746e64;
  --gold-text: #8a6400;
  --gold-wash: rgba(224, 168, 0, .14);
  --gold-line: rgba(170, 125, 0, .42);
  --mark: #e3a90b;
  --grid: #ebe9e3;
  --axis: #cfccc3;
  --s-gads: #2a78d6;
  --s-meta: #eb6834;
  --s-gbp: #1baf7a;
  --s-search: #6250d6;
  --s-social: #e87ba4;
  --good: #0b7a2f;
  --bad: #c0362f;
  --warn: #a86b00;
  --shadow: 0 18px 44px -22px rgba(40, 30, 10, .35);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--text);
  font: 400 14.5px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico-sm { width: 14px; height: 14px; }
.ico-lg { width: 22px; height: 22px; }
.muted { color: var(--muted); }
.t2 { color: var(--text-2); }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px;
  padding: 18px 14px; border-right: 1px solid var(--line); background: var(--page);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px 6px; text-decoration: none; }
.brand-logo { width: 42px; height: 42px; border-radius: 50%; background: #0b0b0c; padding: 2px; flex: none; box-shadow: 0 0 0 1px var(--gold-line); overflow: hidden; }
.brand-logo img { width: 100%; height: 100%; display: block; border-radius: 50%; object-fit: cover; }
.brand-name { font: 800 1.02rem/1.05 var(--font-display); font-stretch: 112%; letter-spacing: .01em; }
.brand-sub { font-size: .74rem; color: var(--gold-text); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  text-decoration: none; color: var(--text-2); font-weight: 500; transition: background-color .15s, color .15s;
}
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a[aria-current="page"] { background: var(--gold-wash); color: var(--text); }
.nav a[aria-current="page"] .ico { color: var(--gold-text); }
.nav .count { margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--gold); color: var(--gold-ink); font-size: .72rem; font-weight: 700; display: grid; place-items: center; }
.side-foot { margin-top: auto; display: grid; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; border: 1px solid var(--line); }
.me .avatar { width: 34px; height: 34px; font-size: .8rem; }
.me b { display: block; font-size: .9rem; }
.me small { color: var(--muted); font-size: .76rem; }
.me .icon-btn.push { margin-left: auto; }
.me .icon-btn { width: 34px; height: 34px; }
.me-who { min-width: 0; overflow: hidden; }
.me-who b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { min-width: 0; padding: 0 28px 56px; }
.topbar { display: none; }
.tabbar { display: none; }

/* demo notice */
.demo-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 0 -28px 0; padding: 9px 28px; border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, var(--gold-wash), transparent 70%); font-size: .84rem; color: var(--text-2);
}
.demo-bar .tag { background: var(--gold); color: var(--gold-ink); font-weight: 700; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; padding: 3px 8px; border-radius: 6px; }
.demo-bar .grow { flex: 1 1 260px; min-width: 0; }
.demo-bar .btn { min-height: 32px; font-size: .8rem; }

/* page header */
.page-h { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 26px 0 18px; }
.page-h h1 { font: 800 1.7rem/1.1 var(--font-display); font-stretch: 108%; letter-spacing: -.005em; }
.page-h p { color: var(--text-2); margin-top: 6px; }
.page-h .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.section-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 12px; }
.section-h h2 { font-size: .8rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: .86rem; white-space: nowrap; text-decoration: none;
  transition: background-color .15s, border-color .15s, transform .15s var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--line-2); }
.btn:active { transform: scale(.98); }
.btn--gold { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn--gold:hover { background: var(--gold-hi); border-color: var(--gold-hi); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--hover); color: var(--text); }
.btn--sm { min-height: 32px; padding: 0 10px; font-size: .8rem; border-radius: 8px; }
.btn--block { width: 100%; }
.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px; color: var(--text-2); position: relative; transition: background-color .15s, color .15s; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn .badge { position: absolute; top: 4px; right: 3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--gold); color: var(--gold-ink); font-size: .66rem; font-weight: 800; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--page); }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: var(--surface); border: 1px solid var(--line); }
.seg button { min-height: 32px; padding: 0 13px; border-radius: 8px; color: var(--text-2); font-weight: 600; font-size: .84rem; transition: background-color .15s, color .15s; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 0 rgba(0,0,0,.2); }

.field { display: grid; gap: 6px; }
.field > span { font-size: .76rem; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--surface-2); color: var(--text); font-size: .9rem; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--gold-line); box-shadow: 0 0 0 3px var(--gold-wash); }
.textarea { min-height: 76px; resize: vertical; }
.select { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.search { position: relative; flex: 1 1 240px; max-width: 360px; }
.search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 38px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .select { width: auto; min-width: 150px; }
.toolbar .spacer { flex: 1; }

/* ---------- cards & grid ---------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; } .span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.card-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.card-h h3 { font-size: 1rem; font-weight: 700; letter-spacing: -.005em; }
.card-h p { color: var(--muted); font-size: .82rem; margin-top: 2px; }
.card-b { padding: 16px 20px 20px; }
.card-b.flush { padding: 8px 0 8px; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { padding: 15px 16px 13px; display: grid; gap: 8px; align-content: start; position: relative; overflow: hidden; }
.kpi .label { font-size: .8rem; color: var(--text-2); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .mid { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.kpi .value { font-size: 1.8rem; font-weight: 650; letter-spacing: -.02em; line-height: 1.05; white-space: nowrap; }
.kpi .value small { font-size: .9rem; font-weight: 600; color: var(--text-2); margin-left: 3px; letter-spacing: 0; }
.kpi .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 26px; }
.delta { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 0 4px; font-size: .76rem; font-weight: 600; color: var(--text-2); }
.delta .ico { width: 13px; height: 13px; stroke-width: 2.5; }
.delta.good { color: var(--good); } .delta.bad { color: var(--bad); }
.delta .vs { color: var(--muted); font-weight: 500; }
.spark { width: 72px; height: 24px; flex: none; overflow: visible; }
.spark polyline { fill: none; stroke: var(--muted); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; opacity: .7; }
.spark circle { fill: var(--mark); stroke: var(--surface); stroke-width: 2; }

/* ---------- greeting + attention ---------- */
.hello h1 { font: 800 1.85rem/1.1 var(--font-display); font-stretch: 108%; }
.hello p { margin-top: 8px; color: var(--text-2); font-size: .98rem; }
.hello p b { color: var(--text); font-weight: 650; }
.attn { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 26px; }
.attn-card { padding: 14px 14px 12px; display: grid; gap: 8px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); position: relative; cursor: pointer; transition: border-color .15s, transform .2s var(--ease); }
.attn-card:hover { border-color: var(--line-2); transform: translateY(-1px); }
.attn-card.hot { border-color: var(--gold-line); background: linear-gradient(180deg, var(--gold-wash), var(--surface) 70%); }
.attn-card .why { display: flex; align-items: center; gap: 6px; font-size: .76rem; font-weight: 700; color: var(--gold-text); }
.attn-card .why.late { color: var(--bad); }
.attn-card b { font-size: .98rem; }
.attn-card .sub { font-size: .82rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attn-card .row { display: flex; gap: 6px; margin-top: 2px; }
.attn-card .row .btn { flex: 1; }
.allclear { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px; border: 1px dashed var(--line-2); color: var(--text-2); margin-bottom: 26px; }
.allclear .ico { color: var(--good); }

/* ---------- source dots, pills, chips ---------- */
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.c-gads { --c: var(--s-gads); } .c-meta { --c: var(--s-meta); } .c-gbp { --c: var(--s-gbp); }
.c-search { --c: var(--s-search); } .c-social { --c: var(--s-social); }
.dot[class*="c-"] { background: var(--c); }
.src { display: inline-flex; align-items: center; gap: 7px; font-size: .8rem; color: var(--text-2); white-space: nowrap; }
.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: .72rem;
  font-weight: 700; letter-spacing: .02em; border: 1px solid var(--line-2); color: var(--text-2); white-space: nowrap; background: var(--surface-2);
}
.pill .ico { width: 12px; height: 12px; stroke-width: 2.6; }
.pill.st-new { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.pill.st-paid { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, transparent); background: color-mix(in srgb, var(--good) 10%, transparent); }
.pill.st-lost { color: var(--muted); }
.pill.st-booked { color: var(--text); border-color: var(--line-2); }
.pill.warn { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: color-mix(in srgb, var(--bad) 9%, transparent); }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--line-2); font-size: .8rem; font-weight: 600; color: var(--text-2); transition: background-color .15s, border-color .15s, color .15s; }
.chip:hover { color: var(--text); background: var(--hover); }
.chip[aria-pressed="true"] { background: var(--gold-wash); border-color: var(--gold-line); color: var(--text); }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .86rem; flex: none; background: var(--surface-3); color: var(--text); border: 1px solid var(--line-2); }

/* ---------- live feed ---------- */
.live { display: inline-flex; align-items: center; gap: 7px; font-size: .76rem; font-weight: 700; color: var(--good); letter-spacing: .04em; text-transform: uppercase; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--good-fill); position: relative; }
.live i::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--good-fill); opacity: 0; animation: ping 2s var(--ease) infinite; }
@keyframes ping { 0% { transform: scale(.5); opacity: .8; } 80%, 100% { transform: scale(1.6); opacity: 0; } }
.feed li { border-top: 1px solid var(--line); }
.feed li:first-child { border-top: 0; }
.feed button { width: 100%; display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 20px; text-align: left; transition: background-color .15s; }
.feed button:hover { background: var(--hover); }
.feed .who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.feed .who b { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed .what { display: block; font-size: .82rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed .when { font-size: .76rem; color: var(--muted); text-align: right; display: grid; gap: 4px; justify-items: end; }
.feed .ch { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); position: relative; }
.feed .ch .dot { position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px; box-shadow: 0 0 0 2px var(--surface); }
.flash { animation: flash 2.4s var(--ease); }
@keyframes flash { 0% { background: var(--gold-wash); box-shadow: inset 3px 0 0 var(--gold); } 70% { background: var(--gold-wash); box-shadow: inset 3px 0 0 var(--gold); } 100% { background: transparent; box-shadow: inset 3px 0 0 transparent; } }
.feed-more { display: flex; justify-content: center; padding: 6px 20px 14px; }
.empty { padding: 28px 20px; text-align: center; color: var(--muted); display: grid; gap: 8px; justify-items: center; }
.empty .ico { width: 26px; height: 26px; color: var(--text-2); }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .seg-gads { fill: var(--s-gads); } .chart .seg-meta { fill: var(--s-meta); } .chart .seg-gbp { fill: var(--s-gbp); }
.chart .seg-search { fill: var(--s-search); } .chart .seg-social { fill: var(--s-social); } .chart .seg-mark { fill: var(--mark); }
.chart .col { transition: opacity .15s; }
.chart.is-hover .col { opacity: .38; }
.chart.is-hover .col.on { opacity: 1; }
.chart .hit { fill: transparent; cursor: default; outline: none; }
.chart .hit:focus-visible { stroke: var(--gold); stroke-width: 1.5; }
.chart .total-label { fill: var(--text-2); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0 20px; margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; font-size: .8rem; color: var(--text-2); }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.tip {
  position: fixed; z-index: 90; pointer-events: none; min-width: 170px; padding: 10px 12px; border-radius: 12px;
  background: var(--surface-3); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-size: .8rem;
  opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s;
}
.tip.on { opacity: 1; transform: none; }
.tip .t { font-weight: 700; margin-bottom: 6px; color: var(--text); }
.tip .r { display: grid; grid-template-columns: 12px auto 1fr; align-items: center; gap: 8px; padding: 2px 0; }
.tip .r .k { width: 12px; height: 3px; border-radius: 2px; background: var(--c); }
.tip .r b { font-variant-numeric: tabular-nums; }
.tip .r span { color: var(--text-2); }
.tip .sum { border-top: 1px solid var(--line-2); margin-top: 6px; padding-top: 6px; display: flex; justify-content: space-between; color: var(--text-2); }
.tip .sum b { color: var(--text); }

/* bar lists */
.bars { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.bar-row .name { display: flex; align-items: center; gap: 8px; font-size: .86rem; min-width: 0; }
.bar-row .name span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .val { font-size: .84rem; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }
.bar-row .val small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.bar-row .track { grid-column: 1 / -1; height: 8px; border-radius: 0 4px 4px 0; background: transparent; position: relative; }
.bar-row .fill { position: absolute; inset: 0 auto 0 0; border-radius: 0 4px 4px 0; background: var(--c, var(--mark)); min-width: 2px; transition: width .5s var(--ease); }

/* tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .86rem; }
.t th { text-align: left; font-size: .74rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t th.r, .t td.r { text-align: right; }
.t th button { display: inline-flex; align-items: center; gap: 4px; font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; }
.t th button:hover { color: var(--text); }
.t th button[aria-sort] .ico { width: 12px; height: 12px; }
.t td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t.compact th, .t.compact td { padding: 8px 12px; white-space: nowrap; }
.t tbody tr:last-child td { border-bottom: 0; }
.t tbody tr.click { cursor: pointer; transition: background-color .12s; }
.t tbody tr.click:hover { background: var(--hover); }
.t td .sub { display: block; font-size: .78rem; color: var(--muted); margin-top: 1px; }
.t .num, .t td.r { font-variant-numeric: tabular-nums; }
.t tfoot td { font-weight: 700; border-top: 1px solid var(--line-2); border-bottom: 0; }
.inline-bar { display: inline-block; height: 6px; border-radius: 0 3px 3px 0; background: var(--c); vertical-align: middle; margin-right: 8px; }

/* ---------- pipeline ---------- */
.pipe-sum { display: flex; gap: 22px; flex-wrap: wrap; color: var(--text-2); font-size: .86rem; }
.pipe-sum b { color: var(--text); font-size: 1.02rem; }
.kanban { display: grid; grid-template-columns: repeat(6, minmax(232px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; scroll-snap-type: x proximity; }
.lane { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; min-height: 240px; display: flex; flex-direction: column; scroll-snap-align: start; transition: border-color .15s, background-color .15s; }
.lane.drop { border-color: var(--gold-line); background: var(--gold-wash); }
.lane-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px 10px; position: sticky; top: 0; }
.lane-h h3 { font-size: .9rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.lane-h .n { font-size: .74rem; font-weight: 700; color: var(--text-2); background: var(--surface-3); border-radius: 999px; padding: 1px 8px; }
.lane-h small { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.lane-b { padding: 0 8px 8px; display: grid; gap: 8px; }
.lane-note { font-size: .74rem; color: var(--muted); padding: 0 14px 8px; margin-top: -4px; }
.lcard { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; display: grid; gap: 6px; cursor: grab; text-align: left; width: 100%; transition: border-color .15s, box-shadow .15s, transform .15s var(--ease); }
.lcard:hover { border-color: var(--line-2); box-shadow: 0 10px 24px -16px rgba(0,0,0,.6); }
.lcard:active { cursor: grabbing; }
.lcard.dragging { opacity: .45; }
.lcard .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .74rem; color: var(--muted); }
.lcard b { font-size: .92rem; font-weight: 650; }
.lcard .svc { font-size: .8rem; color: var(--text-2); }
.lcard .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .78rem; color: var(--text-2); }
.lcard .meta .money { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.lcard .when-due { font-size: .74rem; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; color: var(--gold-text); }
.lcard .when-due.late { color: var(--bad); }
.lcard .next { justify-self: start; margin-top: 2px; font-size: .74rem; font-weight: 700; color: var(--text-2); display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px 4px 6px; border-radius: 7px; border: 1px solid var(--line-2); }
.lcard .next:hover { color: var(--text); border-color: var(--gold-line); background: var(--gold-wash); }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(540px, 100%); z-index: 70; background: var(--surface);
  border-left: 1px solid var(--line-2); box-shadow: var(--shadow); transform: translateX(102%); transition: transform .28s var(--ease);
  display: flex; flex-direction: column;
}
.drawer.on { transform: none; }
.dr-h { display: flex; gap: 14px; align-items: center; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.dr-h .avatar { width: 46px; height: 46px; font-size: 1rem; }
.dr-h h2 { font-size: 1.2rem; font-weight: 700; line-height: 1.2; }
.dr-h .sub { font-size: .8rem; color: var(--muted); margin-top: 3px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dr-h .icon-btn { margin-left: auto; align-self: flex-start; }
.dr-b { overflow-y: auto; padding: 16px 20px 32px; display: grid; gap: 20px; align-content: start; overscroll-behavior: contain; }
.quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.quick .btn { min-height: 44px; }
.dr-sec h3 { font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; }
.stages { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.stages button { min-height: 34px; border-radius: 8px; font-size: .76rem; font-weight: 700; color: var(--text-2); transition: background-color .15s, color .15s; }
.stages button:hover { color: var(--text); background: var(--hover); }
.stages button[aria-pressed="true"] { background: var(--gold); color: var(--gold-ink); }
.stages button.done { color: var(--text); }
.kv { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 9px 14px; font-size: .86rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.msg { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font-size: .9rem; color: var(--text); position: relative; }
.msg::before { content: "\201C"; position: absolute; left: 10px; top: -8px; font: 800 2rem/1 var(--font-display); color: var(--gold-text); }
.msg p { padding-left: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.review-box { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--gold-line); background: var(--gold-wash); }
.review-box .ico { color: var(--gold-text); }
.review-box p { font-size: .84rem; color: var(--text-2); flex: 1; }
.review-box p b { color: var(--text); display: block; font-size: .9rem; }
.timeline { display: grid; gap: 0; }
.timeline li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; position: relative; padding-bottom: 14px; }
.timeline li::before { content: ""; position: absolute; left: 13.5px; top: 26px; bottom: 0; width: 1px; background: var(--line-2); }
.timeline li:last-child::before { display: none; }
.timeline .ti { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--text-2); }
.timeline .ti .ico { width: 14px; height: 14px; }
.timeline .ti.gold { background: var(--gold-wash); border-color: var(--gold-line); color: var(--gold-text); }
.timeline .ti.good { color: var(--good); }
.timeline p { font-size: .86rem; padding-top: 4px; }
.timeline small { color: var(--muted); font-size: .76rem; }
.timeline .note p { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-top: 4px; white-space: pre-wrap; }
.add-note { display: grid; gap: 8px; }
.add-note .row { display: flex; justify-content: flex-end; }

/* popover */
.pop { position: fixed; z-index: 80; width: min(360px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow); padding: 6px 0; display: none; }
.pop.on { display: block; }
.pop h4 { font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 10px 16px 6px; }
.pop .feed button { padding: 9px 16px; }

/* toasts */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 95; display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.drawer.on ~ .toasts { right: calc(min(540px, 100%) + 20px); }
.toast {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 12px 12px 14px;
  border-radius: 14px; background: var(--surface-3); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  animation: toast-in .35s var(--ease);
}
.toast.out { animation: toast-out .25s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-6px); } }
.toast .ti { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--gold); color: var(--gold-ink); }
.toast b { display: block; font-size: .9rem; }
.toast p { font-size: .8rem; color: var(--text-2); }
.toast.info .ti { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line-2); }

/* connections */
.conn { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.conn > div { padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); display: grid; gap: 8px; align-content: start; }
.conn b { font-size: .9rem; display: flex; align-items: center; gap: 8px; }
.conn p { font-size: .8rem; color: var(--text-2); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 700; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.ok { color: var(--good); } .status.wait { color: var(--gold-text); } .status.opt { color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 1360px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .attn { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .span-8, .span-7, .span-5, .span-4 { grid-column: span 12; }
  .conn { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .span-6 { grid-column: span 12; }
}
@media (max-width: 1023px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .main { padding: 0 16px calc(86px + env(safe-area-inset-bottom)); }
  .demo-bar { margin: 0 -16px; padding: 8px 16px; }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 40; margin: 0 -16px; padding: 10px 12px 10px 16px;
    background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
  }
  .topbar .brand { padding: 0; margin-right: auto; }
  .topbar .brand-logo { width: 34px; height: 34px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--page) 92%, transparent);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  }
  .tabbar a { display: grid; justify-items: center; gap: 3px; padding: 6px 0; font-size: .7rem; font-weight: 600; color: var(--muted); text-decoration: none; border-radius: 10px; position: relative; }
  .tabbar a[aria-current="page"] { color: var(--text); }
  .tabbar a[aria-current="page"] .ico { color: var(--gold-text); }
  .tabbar .count { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--gold); color: var(--gold-ink); font-size: .64rem; font-weight: 800; display: grid; place-items: center; }
  .kanban { grid-template-columns: repeat(6, 82vw); margin: 0 -16px; padding: 0 16px 12px; scroll-padding: 0 16px; }
}
@media (max-width: 720px) {
  body { font-size: 14px; }
  .page-h { padding: 18px 0 14px; }
  .page-h h1, .hello h1 { font-size: 1.45rem; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 13px 14px 12px; }
  .kpi .value { font-size: 1.5rem; }
  .spark { width: 56px; }
  .attn { grid-template-columns: minmax(0, 1fr); }
  .grid { gap: 12px; }
  .card-h { padding: 16px 16px 0; }
  .card-b { padding: 14px 16px 16px; }
  .feed button { padding: 11px 16px; }
  .legend { padding: 0 16px; }
  .conn { grid-template-columns: minmax(0, 1fr); }
  .seg { width: 100%; }
  .seg button { flex: 1; padding: 0 6px; }
  .demo-bar .grow { flex-basis: 100%; order: 3; }
  .toolbar .select { flex: 1 1 140px; min-width: 0; }
  .search { max-width: none; flex-basis: 100%; }
  .hide-sm { display: none !important; }
  .t th, .t td { padding: 10px 10px; }
  .kv { grid-template-columns: 104px minmax(0, 1fr); }
  .stages { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .toasts, .drawer.on ~ .toasts { left: 12px; right: 12px; top: 10px; bottom: auto; width: auto; }
  /* contacts table becomes a list */
  table.t.stack thead { display: none; }
  table.t.stack tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  table.t.stack td { border: 0; padding: 0; }
  table.t.stack td.c-name { grid-column: 1; }
  table.t.stack td.c-stage { grid-column: 2; grid-row: 1; justify-self: end; }
  table.t.stack td.c-svc { grid-column: 1; }
  table.t.stack td.c-when { grid-column: 2; grid-row: 2; justify-self: end; color: var(--muted); font-size: .78rem; }
  table.t.stack td.c-src, table.t.stack td.c-city, table.t.stack td.c-val { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- live version additions ---------- */
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.btn[disabled], .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.btn--danger:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); border-color: var(--bad); }
.form-err { color: var(--bad); font-size: .84rem; font-weight: 600; min-height: 1.2em; margin-top: 10px; }
.danger-zone p { font-size: .82rem; margin-bottom: 10px; }
.dr-b .field { margin-bottom: 12px; }
.dr-b .two .field { margin-bottom: 12px; }
.pipe-sum .btn { align-self: center; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 50% -10%, var(--gold-wash), transparent 70%), var(--page); }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 14px; padding: 28px 24px 22px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.login-card h1 { font: 800 1.6rem/1.1 var(--font-display); font-stretch: 112%; }
.login-card .muted { margin-top: -8px; }
.login-mark { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--gold-wash); color: var(--gold-text); border: 1px solid var(--gold-line); }
.login-card .btn { min-height: 46px; }
.login-card .form-err { margin-top: -4px; }
.login-card .fine { font-size: .78rem; color: var(--muted); text-align: center; }
