/* MarketUnlock Analytics — visual system
   Neutral, bordered, monochrome-first (shadcn "new-york" look, Geist type).
   Colour is reserved for money (amber), deltas (green / red) and status. */

:root {
  color-scheme: light;
  --bg: #fafafa;
  --panel: #ffffff;
  --panel-2: #f4f4f5;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #09090b;
  --muted: #71717a;
  --faint: #a1a1aa;
  --fg: #18181b;
  --fg-contrast: #fafafa;
  --accent: #18181b;
  --accent-soft: rgba(24, 24, 27, 0.06);
  --good: #059669;
  --good-soft: rgba(5, 150, 105, 0.10);
  --revenue: #d97706;
  --revenue-soft: rgba(217, 119, 6, 0.12);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.10);
  --chart-1: #3f3f46;
  --chart-rev: #d97706;
  --ring: rgba(24, 24, 27, 0.18);
  --shadow: 0 1px 2px rgba(9, 9, 11, 0.04);
  --shadow-pop: 0 10px 30px rgba(9, 9, 11, 0.12), 0 1px 3px rgba(9, 9, 11, 0.08);
  --radius: 10px;
  --radius-sm: 8px;
  --sidebar-w: 240px;
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09090b;
  --panel: #111113;
  --panel-2: #1c1c1f;
  --border: #27272a;
  --border-strong: #3f3f46;
  --text: #fafafa;
  --muted: #a1a1aa;
  --faint: #71717a;
  --fg: #fafafa;
  --fg-contrast: #09090b;
  --accent: #e4e4e7;
  --accent-soft: rgba(250, 250, 250, 0.08);
  --good: #34d399;
  --good-soft: rgba(52, 211, 153, 0.14);
  --revenue: #fbbf24;
  --revenue-soft: rgba(251, 191, 36, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --chart-1: #a1a1aa;
  --chart-rev: #fafafa;
  --ring: rgba(250, 250, 250, 0.22);
  --shadow: none;
  --shadow-pop: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--border);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* lock the page horizontally — content scrolls inside .tbl-wrap etc., never the page */
html, body { max-width: 100%; overflow-x: hidden; overscroll-behavior-x: none; }
body {
  margin: 0;
  font-family: "Geist", "Geist Fallback", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
.hidden { display: none !important; }
h1, h2, h3, h4 { letter-spacing: -0.01em; }
small { color: var(--muted); font-weight: 400; }

/* ---------- Login ---------- */
.login {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: var(--bg);
  background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: center;
}
.login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-pop);
  padding: 36px 36px 24px; width: 400px; display: flex; flex-direction: column; gap: 14px;
}
.login-mark {
  width: 44px; height: 44px; margin: 0 auto; border-radius: 12px; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  background: var(--fg); color: var(--fg-contrast);
}
.login-card h1 { margin: 4px 0 0; font-size: 20px; font-weight: 600; text-align: center; }
.login-sub { margin: -8px 0 6px; text-align: center; color: var(--muted); font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 2px; }
.field span { font-size: 13px; font-weight: 500; color: var(--text); }
.field input { width: 100%; padding: 9px 12px; font-size: 14px; border-radius: var(--radius-sm); }
.field input:focus { outline: none; border-color: var(--border-strong); box-shadow: 0 0 0 3px var(--ring); }
.totp-input { text-align: center; font-size: 22px !important; letter-spacing: 10px; font-variant-numeric: tabular-nums; }
.login-btn { width: 100%; padding: 10px; font-size: 14px; font-weight: 500; border-radius: var(--radius-sm); margin-top: 4px; }
.login-foot { margin: 10px 0 0; text-align: center; color: var(--faint); font-size: 12px; }

/* Kill the browser-autofill yellow */
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--panel) inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  transition: background-color 9999s ease-in-out 0s;
}
.error { color: var(--danger); min-height: 1em; margin: 0; text-align: center; font-size: 13px; }

/* ---------- App shell: sidebar on the page ground, main column as an inset card ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--bg);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 0 12px 12px;
}
.sidebar-top { padding: 0 4px 6px; display: flex; flex-direction: column; gap: 10px; }
.brand {
  display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 8px;
  font-size: 14px; font-weight: 500;
}
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--fg); color: var(--fg-contrast);
}
.brand-mark svg { width: 13px; height: 13px; }
.site-select { width: 100%; font-weight: 500; font-size: 13.5px; }
.realtime { color: var(--muted); font-size: 12.5px; white-space: nowrap; cursor: pointer; text-decoration: none; padding: 0 8px; }
.realtime:hover { color: var(--text); }
.realtime::before { content: "●"; color: var(--good); margin-right: 7px; font-size: 8px; animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

.side-nav { display: flex; flex-direction: column; gap: 1px; flex: 1; overflow-y: auto; padding: 0 4px; scrollbar-width: thin; }
.nav-group { color: var(--muted); font-size: 12px; font-weight: 400; padding: 14px 8px 6px; }
.side-nav button {
  display: flex; align-items: center; gap: 10px;
  background: none; border: none; text-align: left; color: var(--text);
  padding: 6px 8px; font-size: 13.5px; font-weight: 450; border-radius: var(--radius-sm); cursor: pointer;
  line-height: 1.2; min-height: 32px;
}
.side-nav button svg { width: 16px; height: 16px; flex: none; color: var(--text); }
.side-nav button:hover { background: var(--panel-2); }
.side-nav button.active { background: var(--panel-2); font-weight: 500; }
.sidebar-bottom { display: flex; flex-direction: column; gap: 1px; padding: 10px 4px 0; border-top: 1px solid var(--border); }
.foot-link {
  display: flex; align-items: center; gap: 8px; background: none; border: none; text-align: left;
  color: var(--muted); font-size: 12.5px; font-weight: 400; padding: 6px 8px; min-height: 0; border-radius: 6px;
}
.foot-link:hover { background: var(--panel-2); color: var(--text); }
.foot-link svg { width: 14px; height: 14px; flex: none; }
#theme-toggle .ico-sun { display: none; }
[data-theme="dark"] #theme-toggle .ico-sun { display: inline; }
[data-theme="dark"] #theme-toggle .ico-moon { display: none; }

.main-col {
  flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; margin: 8px 8px 8px 0; min-height: calc(100vh - 16px);
}
header { background: var(--panel); position: sticky; top: 8px; z-index: 10; border-bottom: 1px solid var(--border); border-radius: 12px 12px 0 0; }
.header-inner { height: 56px; padding: 0 16px 0 12px; display: flex; align-items: center; gap: 12px; }
.nav-collapse { border: none; background: none; padding: 6px; min-width: 0; min-height: 0; color: var(--text); border-radius: 6px; }
.nav-collapse:hover { background: var(--panel-2); }
.nav-collapse svg { width: 16px; height: 16px; display: block; }
.header-sep { width: 1px; height: 16px; background: var(--border); flex: none; }
.crumb { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; font-weight: 500; letter-spacing: 0; }
.crumb-icon { display: inline-flex; }
.crumb-icon svg { width: 14px; height: 14px; }
.crumb-icon:empty { display: none; }
.header-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

main { padding: 24px 24px 32px; }

/* Desktop: pin the sidebar so it never scrolls away. `overflow-x: hidden` on
   <body> (needed to lock horizontal scroll) silently breaks position:sticky, so
   use fixed + offset the main column by the sidebar width. */
@media (min-width: 861px) {
  .sidebar { position: fixed; top: 0; left: 0; width: var(--sidebar-w); height: 100vh; z-index: 20; }
  .main-col { margin-left: var(--sidebar-w); }
  .app-shell.nav-collapsed .sidebar { display: none; }
  .app-shell.nav-collapsed .main-col { margin-left: 8px; }
}

/* ---------- Mobile layout: hamburger drawer ---------- */
.menu-toggle { display: none; }

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 30;
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
    gap: 8px; padding: 10px 12px; background: var(--panel);
    border-bottom: 1px solid var(--border);
  }
  .sidebar-top { display: contents; }
  .sidebar-top .brand { display: none; }
  .menu-toggle { display: flex; align-items: center; justify-content: center; grid-row: 1; grid-column: 1; font-size: 17px; padding: 8px 12px; }
  .site-select { min-width: 0; width: 100%; grid-row: 1; grid-column: 2; }
  /* live badge collapses to its pulsing dot (still tappable -> Realtime) */
  .realtime { font-size: 0; padding: 8px 8px; grid-row: 1; grid-column: 3; }
  .realtime::before { font-size: 11px; margin: 0; }

  /* drawer: hidden until the hamburger opens it */
  .side-nav { display: none; }
  .sidebar.open .side-nav {
    display: flex; flex-direction: column; gap: 1px;
    grid-column: 1 / -1; grid-row: 2;
    padding: 6px 0 2px; border-top: 1px solid var(--border); margin-top: 8px;
  }
  .sidebar.open .side-nav button { padding: 11px 12px; font-size: 15px; }
  .sidebar.open .nav-group { display: block; padding: 12px 12px 4px; }
  .sidebar-bottom { display: none; }
  .sidebar.open .sidebar-bottom {
    display: flex; grid-column: 1 / -1; grid-row: 3;
    padding: 10px 8px 2px; border-top: 1px solid var(--border); margin-top: 6px;
  }
  .sidebar.open .foot-link { padding: 10px 12px; font-size: 14px; }
  .main-col { margin: 0; border: none; border-radius: 0; min-height: 0; background: var(--bg); }
  header { position: static; border-radius: 0; background: var(--bg); }
  .header-inner { height: auto; }
  .nav-collapse, .header-sep { display: none; }
}

/* ---------- Inputs ---------- */
input, select, button, textarea { font: inherit; color: var(--text); }
input:not([type]),
input[type=text], input[type=password], input[type=email], input[type=date], input[type=number],
input[type=tel], input[type=time], input[type=search], input[type=url],
select, textarea {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 12px;
  min-height: 36px; color: var(--text);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--border-strong); box-shadow: 0 0 0 3px var(--ring); }
select { appearance: none; -webkit-appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; }
button {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 14px;
  cursor: pointer; font-weight: 500; font-size: 13.5px; min-height: 36px; line-height: 1.2;
  transition: background .12s, border-color .12s, color .12s;
}
button:hover { background: var(--panel-2); }
button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
button.primary, .upload-btn.primary { background: var(--fg); border-color: var(--fg); color: var(--fg-contrast); font-weight: 500; }
button.primary:hover, .upload-btn.primary:hover { opacity: 0.9; }
button.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
button.ghost:hover { background: var(--panel-2); }
/* anchor-styled actions (CSV export / download links) — match ghost buttons
   instead of the browser's default blue underlined link */
a.ghost { display: inline-flex; align-items: center; background: transparent; border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); padding: 7px 14px; font-size: 13.5px; font-weight: 500; text-decoration: none; cursor: pointer; line-height: 1.2; min-height: 36px; }
a.ghost:hover { background: var(--panel-2); }
.icon-btn { padding: 7px 10px; color: var(--muted); min-width: 36px; font-size: 15px; }
.icon-btn:hover { color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; vertical-align: -3px; }
#theme-toggle .ico-sun { display: none; }
[data-theme="dark"] #theme-toggle .ico-sun { display: inline; }
[data-theme="dark"] #theme-toggle .ico-moon { display: none; }
.upload-btn { display: inline-flex; align-items: center; border-radius: var(--radius-sm); padding: 8px 14px; cursor: pointer; font-weight: 500; font-size: 13.5px; min-height: 36px; border: 1px solid var(--border); }

/* ---------- Panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: none; padding: 20px 24px; margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px 16px; margin-bottom: 14px; flex-wrap: wrap; }
/* card header: title + description in its own band, divided from the body by a full-width rule */
.panel > .panel-head:first-child { margin: -20px -24px 16px; padding: 16px 24px 14px; border-bottom: 1px solid var(--border); }
.panel > .panel-head:first-child > .hint { margin-top: 0; }
.panel-head h3 { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.3; }
.panel-head h3 + .hint { display: block; margin-top: 4px; }
.panel-head > .hint { flex-basis: 100%; order: 10; margin-top: -4px; }
.panel-head > .hint:first-child { flex-basis: auto; order: 0; margin-top: 0; }
.panel-tabs { display: inline-flex; gap: 2px; flex-wrap: wrap; background: var(--panel-2); padding: 3px; border-radius: var(--radius-sm); }
.panel-tabs button { background: none; border: none; color: var(--muted); padding: 4px 10px; font-size: 12.5px; font-weight: 500; border-radius: 6px; min-height: 0; line-height: 1.4; }
.panel-tabs button.active { color: var(--text); background: var(--panel); box-shadow: 0 1px 2px rgba(9, 9, 11, 0.10), 0 0 0 1px var(--border); }
.panel-tabs button:hover { color: var(--text); }
[data-theme="dark"] .panel-tabs button.active { box-shadow: 0 0 0 1px var(--border-strong); }

/* ---------- Stat grid: one bordered box, hairline-divided cells (compact) ----------
   Each cell draws the 1px line to its left and above (box-shadow into the 1px
   gap), so a partially filled last row stays clean panel colour. */
.metric-bar {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  margin-bottom: 16px;
}
.metric {
  position: relative; background: var(--panel); border: none; border-radius: 0;
  box-shadow: -1px -1px 0 0 var(--border);
  padding: 12px 16px 14px; text-align: left; cursor: pointer; min-height: 0; line-height: 1.3;
  display: flex; flex-direction: column; gap: 4px; font-weight: 400;
  transition: background .12s;
}
.metric:hover { background: var(--panel-2); }
.metric[disabled] { cursor: default; }
.metric[disabled]:hover { background: var(--panel); }
/* cell = 2-col grid: row 1 label | delta, row 2 value. .m-value is display:contents so
   its text node and the delta become grid items; text styling still inherits. */
.metric { display: grid; grid-template-columns: minmax(0, 1fr); grid-auto-columns: auto; column-gap: 8px; row-gap: 4px; align-items: baseline; align-content: start; }
.metric .m-label { grid-column: 1; grid-row: 1; color: var(--muted); font-size: 12.5px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.metric .m-value { display: contents; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; font-variant-numeric: tabular-nums; line-height: 1.15; color: var(--text); }
.metric .m-value small { grid-column: 1; font-size: 12px; font-weight: 400; color: var(--muted); letter-spacing: 0; margin-top: -2px; }
.metric.active { box-shadow: -1px -1px 0 0 var(--border), inset 0 2px 0 var(--fg); }
.metric.active .m-label { color: var(--text); }
.metric.m-revenue .m-value { color: var(--revenue); }
/* a value that wraps an input (month goal) stays one flex row */
.metric .m-value:has(input) { display: flex; align-items: center; gap: 4px; grid-column: 1; grid-row: 2; }
/* delta sits in the label row, right-aligned, only as wide as its text */
.delta { grid-column: 2; grid-row: 1; justify-self: end; white-space: nowrap; font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.3; letter-spacing: 0; }
.delta.up { color: var(--good); }
.delta.down { color: var(--danger); }
.delta.flat { color: var(--faint); }
.metric .hint, .metric .m-sub { grid-column: 1; display: block; color: var(--muted); font-size: 12px; white-space: nowrap; margin-top: -1px; }
main > section > .metric-bar { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.panel .metric-bar .metric { background: var(--panel); }

/* view-level toolbar: quiet actions row above the stats, no card */
.view-toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin: -8px 0 12px; }
.view-toolbar .hint { margin-right: auto; }
.view-toolbar .ghost, .view-toolbar .upload-btn { min-height: 32px; padding: 5px 12px; font-size: 13px; color: var(--muted); }
.view-toolbar .ghost:hover, .view-toolbar .upload-btn:hover { color: var(--text); }
#revenue-cards { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.sub-head + .metric-bar { margin-bottom: 18px; }
.metric-bar:last-child { margin-bottom: 0; }
.adj-details { margin-bottom: 8px; }
.adj-details summary { cursor: pointer; color: var(--muted); font-size: 13px; list-style: none; display: inline-flex; align-items: center; gap: 6px; }
.adj-details summary::-webkit-details-marker { display: none; }
.adj-details summary::before { content: "+"; font-weight: 600; }
.adj-details[open] summary::before { content: "\2013"; }
.adj-details summary:hover { color: var(--text); }
.adj-details .row { margin: 12px 0 4px; }

/* Chart cards */
.chart-card { padding: 20px 24px; }
.chart-card > .chart-wrap { margin-top: 4px; }
.chart-wrap { position: relative; height: 290px; }

/* Realtime toolbar */
.rt-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.rt-toolbar .metric-bar { margin-bottom: 0; flex: 1; min-width: 280px; }
.rt-window { align-self: center; }
.rt-window button { white-space: nowrap; }
/* dimmed "(15 min ago)" beside the absolute time in the live clicks feed */
.rt-ago { color: var(--faint); font-size: 12px; white-space: nowrap; }

/* ---------- Bar lists ---------- */
.list-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; font-weight: 500; padding: 0 10px 8px; margin-bottom: 4px; }
.bar-row { display: flex; align-items: center; gap: 8px; padding: 0 10px; position: relative; border-radius: 6px; min-height: 44px; margin-bottom: 4px; }
.bar-row .bar[style="width:0.0%"] { display: none; }
.bar-row .bar { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, var(--accent-soft), var(--panel-2)); border-right: 1px solid var(--border-strong); border-radius: 4px; z-index: 0; }
.bar-row .favicon { width: 16px; height: 16px; border-radius: 3px; z-index: 1; flex: none; }
.bar-row .letter { width: 16px; height: 16px; border-radius: 50%; z-index: 1; flex: none; background: var(--fg); color: var(--fg-contrast); font-size: 10px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.bar-row .key { flex: 1; z-index: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .pct { z-index: 1; color: var(--faint); font-size: 12px; min-width: 38px; text-align: right; font-variant-numeric: tabular-nums; }
.bar-row .num { z-index: 1; min-width: 48px; text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: left; color: var(--muted); font-size: 13px; font-weight: 500; padding: 10px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th.r, td.r { text-align: right; }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); }
td.r { color: var(--muted); }
td.r.rev, td.r b, tfoot td.r { color: inherit; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--panel-2); }
td.rev { color: var(--revenue); font-weight: 600; }
/* totals row (tfoot) — bold, separated, doesn't hover-highlight */
tfoot .tbl-total td { font-weight: 600; border-top: 1px solid var(--border-strong); border-bottom: none; background: var(--panel-2); }

.hint { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.rev-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 4px 0 4px; }
.code { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; overflow-x: auto; font-size: 12.5px; line-height: 1.55; cursor: copy; font-family: ui-monospace, "Geist Mono", SFMono-Regular, Menlo, monospace; }
code { background: var(--panel-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 5px; font-size: 12px; font-family: ui-monospace, "Geist Mono", SFMono-Regular, Menlo, monospace; }
.empty { color: var(--faint); text-align: center; padding: 28px 0; font-size: 13px; }

/* Date-range dropdown (with compare built in) */
.dd { position: relative; }
.dd-btn { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 12px; font-size: 13.5px; font-weight: 500; white-space: nowrap; }
/* "Real traffic" segment toggle — off looks like the range button; on fills with the foreground. */
.seg-toggle { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 12px; font-size: 13.5px; font-weight: 500; color: var(--muted); white-space: nowrap; cursor: pointer; }
.seg-toggle svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 6px; }
.seg-toggle:hover { color: var(--text); background: var(--panel-2); }
.seg-toggle.active { background: var(--fg); border-color: var(--fg); color: var(--fg-contrast); }
.seg-toggle.active:hover { opacity: 0.9; }
.dd-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-pop); min-width: 240px; padding: 6px;
}
.dd-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: none; padding: 8px 10px; border-radius: 6px; font-size: 13.5px; font-weight: 400; color: var(--text); cursor: pointer; min-height: 0; }
.dd-item:hover { background: var(--panel-2); }
.dd-item .check { width: 16px; flex: none; color: var(--text); font-weight: 600; }
.dd-sep { border-top: 1px solid var(--border); margin: 6px -6px; }
.dd-head { color: var(--muted); font-size: 12px; font-weight: 500; padding: 6px 10px 2px; }
@media (max-width: 760px) {
  .dd { width: 100%; }
  .dd-btn { width: 100%; }
  .seg-toggle { width: 100%; }
  .dd-menu { left: 0; right: 0; }
}

/* Filter chips */
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 2px 4px 2px 9px; font-size: 12.5px; font-weight: 500; }
.chip b { font-weight: 600; }
.chip button { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0 4px; font-size: 13px; line-height: 1; min-height: 0; }
.chip button:hover { color: var(--text); background: none; }
.chip-clear { background: none; border: none; color: var(--muted); font-size: 12px; cursor: pointer; padding: 3px 6px; min-height: 0; }
.chip-clear:hover { color: var(--text); background: none; }
.src-cell { display: inline-flex; align-items: center; gap: 7px; }
.src-cell .favicon, .src-cell .letter { width: 15px; height: 15px; }
.bar-row[data-dim] { cursor: pointer; }
.bar-row[data-dim]:hover { background: var(--panel-2); }

/* Funnel */
.funnel-stage { display: flex; align-items: center; gap: 14px; padding: 8px 0; }
.funnel-stage .f-label { width: 150px; color: var(--muted); font-size: 13px; text-align: right; flex: none; }
.funnel-stage .f-bar-wrap { flex: 1; background: var(--panel-2); border-radius: 6px; height: 28px; overflow: hidden; }
.funnel-stage .f-bar { height: 100%; border-radius: 6px; background: var(--fg); opacity: 0.85; min-width: 3px; }
.funnel-stage.f-money .f-bar { background: var(--revenue); opacity: 1; }
.funnel-stage .f-value { width: 170px; flex: none; font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
.funnel-stage.f-money .f-value { color: var(--revenue); }
.funnel-stage .f-rate { width: 120px; flex: none; color: var(--faint); font-size: 12px; }
@media (max-width: 760px) {
  .funnel-stage .f-label { width: 105px; font-size: 12px; }
  .funnel-stage .f-value { width: 120px; font-size: 13.5px; }
  .funnel-stage .f-rate { display: none; }
}

/* Markdown report */
.report-pre { max-height: 420px; overflow: auto; white-space: pre; }

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--muted); }
th.sorted::after { content: " ↓"; color: var(--muted); }
.badge { display: inline-block; font-size: 11.5px; font-weight: 500; padding: 1px 8px; border-radius: 6px; background: var(--panel); border: 1px solid var(--border); color: var(--text); white-space: nowrap; line-height: 1.5; }

/* ---------- Mobile fine-tuning ---------- */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.panel > .tbl-wrap, .panel > .panel-body > .tbl-wrap { margin: 0 -24px -20px; }
.panel > .tbl-wrap th:first-child, .panel > .tbl-wrap td:first-child, .panel > .panel-body > .tbl-wrap th:first-child, .panel > .panel-body > .tbl-wrap td:first-child { padding-left: 24px; }
.panel > .tbl-wrap th:last-child, .panel > .tbl-wrap td:last-child, .panel > .panel-body > .tbl-wrap th:last-child, .panel > .panel-body > .tbl-wrap td:last-child { padding-right: 24px; }
.panel > .tbl-wrap tr:last-child td, .panel > .panel-body > .tbl-wrap tr:last-child td { border-bottom: none; }

@media (max-width: 760px) {
  main { padding: 12px 12px 20px; }
  .panel { padding: 16px 14px; margin-bottom: 12px; }
  .panel > .panel-head:first-child { margin: -16px -14px 14px; padding: 14px 14px 12px; }
  .panel > .tbl-wrap, .panel > .panel-body > .tbl-wrap { margin: 0 -14px -16px; }
  .bar-row { min-height: 40px; }
  .chart-card { padding: 16px 14px; }
  .grid { gap: 12px; }

  /* header: title row, then controls full width */
  .header-inner { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  #view-title { font-size: 15px; flex: 1 1 100%; }
  .header-right { margin-left: 0; flex: 1 1 100%; flex-wrap: wrap; }
  .header-right select { flex: 1; min-width: 0; }
  .filter-chips { flex-basis: 100%; }

  .metric-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  main > section > .metric-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { padding: 10px 12px 12px; }
  .metric .m-value { font-size: 19px; }
  .chart-wrap { height: 210px; }

  /* tables scroll inside panels instead of breaking the page */
  .tbl-wrap table { min-width: 560px; }
  .tbl-wrap td, .tbl-wrap th { white-space: nowrap; }
  td { padding: 10px 8px; }

  /* forms stack */
  .row { gap: 8px; }
  .row input[type=text], .row input[type=password], .row input[type=email], .row select { flex: 1 1 100%; min-width: 0; }
  .rev-actions { flex-wrap: wrap; }
  .code { font-size: 11.5px; }
  .report-pre { max-height: 320px; }

  /* iOS zooms the page when focused inputs are <16px — keep them at 16 */
  input, select { font-size: 16px; }
  .panel-tabs button { padding: 6px 10px; }
  .rt-toolbar { gap: 8px; }
  .rt-window { align-self: stretch; overflow-x: auto; scrollbar-width: none; }
  .rt-window::-webkit-scrollbar { display: none; }
  .bar-row { min-height: 34px; }

  .login-card { width: min(400px, 92vw); padding: 28px 20px 20px; }
}

/* annotation bar under the dashboard chart */
.anno-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 14px 0 0; }
.anno-bar input, .anno-bar select { padding: 5px 8px; min-height: 32px; }
/* status pills on the Health view */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 500; border: 1px solid transparent; line-height: 1.5; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--good-soft); color: var(--good); }
.pill.quiet { background: var(--revenue-soft); color: var(--revenue); }
.pill.silent { background: var(--danger-soft); color: var(--danger); }
.pill.idle { background: var(--panel-2); color: var(--muted); border-color: var(--border); }
.journey { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.journey .seq { color: var(--muted); word-break: break-word; }
.journey .seq b { color: var(--text); }

/* Accounting "Paid" input — clearly editable, themes correctly */
.acct-paid {
  width: 116px; text-align: right; padding: 6px 10px; font: inherit; min-height: 32px;
  background: var(--panel); border: 1px solid var(--border); color: var(--text); border-radius: 6px;
}
.acct-paid::placeholder { color: var(--faint); }
.acct-paid:focus { outline: none; border-color: var(--border-strong); box-shadow: 0 0 0 3px var(--ring); }

/* Settings sub-tabs (de-cluttered Setup view) */
.settings-tabs { display: flex; gap: 2px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.settings-tabs button { background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted); padding: 9px 14px; font-size: 13.5px; font-weight: 500; cursor: pointer; border-radius: 0; margin-bottom: -1px; min-height: 0; }
.settings-tabs button:hover { color: var(--text); background: none; }
.settings-tabs button.active { color: var(--text); border-bottom-color: var(--fg); }

/* Settings: stacked labeled fields, not inline wrap-soup */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px 16px;
}
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: 1 / -1; }
@media (max-width: 720px) {
  .form-grid .span-2, .form-grid .span-3 { grid-column: 1 / -1; }
}
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; min-width: 0; }
.field > span { font-size: 12px; font-weight: 500; color: var(--muted); line-height: 1.3; }
.field input, .field select, .field textarea { width: 100%; }
.form-section { margin: 0 0 8px; padding: 0 0 20px; border-bottom: 1px solid var(--border); }
.form-section:last-of-type { border-bottom: none; padding-bottom: 8px; }
.form-section h5 {
  margin: 0 0 12px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
}
.form-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 4px; }
.phone-site { margin: 0; padding: 4px 0 8px; border: none; }
.phone-site + .phone-site { margin-top: 8px; padding-top: 24px; border-top: 1px solid var(--border); }
.phone-site-head { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin-bottom: 18px; }
.phone-site-head h4 { margin: 0; font-size: 16px; font-weight: 600; }
.phone-site-head .hint { margin: 0; }
.check-inline { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.check-inline input { width: auto; min-height: 0; }
.dow { display: flex; gap: 4px; flex-wrap: wrap; }
.dow label {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; min-height: 32px; padding: 0 8px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 12px; font-weight: 500; color: var(--muted); cursor: pointer;
  background: var(--panel-2);
}
.dow label:has(input:checked) { color: var(--text); border-color: var(--border-strong); background: var(--accent-soft); }
.dow input { position: absolute; opacity: 0; pointer-events: none; }
.available-numbers { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.available-numbers:empty { display: none; }

.site-picker { display: flex; flex-direction: column; gap: 6px; margin: 0 0 20px; max-width: 36rem; }
.site-picker-item {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--panel-2); color: var(--text); cursor: pointer;
}
.site-picker-item:hover { border-color: var(--border-strong); }
.site-picker-item.active { border-color: var(--border-strong); background: var(--accent-soft); }
.site-picker-item b { font-size: 13px; }
.phone-site-one { border-top: 1px solid var(--border); padding-top: 16px; }
.site-tabs { display: flex; gap: 2px; flex-wrap: wrap; margin: 0 0 16px; border-bottom: 1px solid var(--border); }
.site-tabs button {
  background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0;
  color: var(--muted); padding: 8px 12px; font-size: 13px; font-weight: 500;
}
.site-tabs button:hover { color: var(--text); }
.site-tabs button.active { color: var(--text); border-bottom-color: var(--fg); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
body.tenant-mode .nav-group,
body.tenant-mode .side-nav button[data-view="portfolio"],
body.tenant-mode .side-nav button[data-view="rentroll"],
body.tenant-mode .side-nav button[data-view="numbers"],
body.tenant-mode .side-nav button[data-view="funnel"],
body.tenant-mode .side-nav button[data-view="opportunities"],
body.tenant-mode .side-nav button[data-view="revenue"],
body.tenant-mode .side-nav button[data-view="briefs"],
body.tenant-mode .side-nav button[data-view="health"],
body.tenant-mode .side-nav button[data-view="settings"],
body.tenant-mode .side-nav button[data-view="silos"],
body.tenant-mode .side-nav button[data-view="search"],
body.tenant-mode .side-nav button[data-view="content"],
body.tenant-mode .side-nav button[data-view="trends"],
body.tenant-mode .side-nav button[data-view="realtime"],
body.tenant-mode #site-select,
body.tenant-mode .site-picker { display: none !important; }

/* Core Web Vitals rating colors (Google's good / needs-improvement / poor) */
.cwv-good { color: var(--good); font-weight: 600; }
.cwv-mid  { color: var(--revenue); font-weight: 600; }
.cwv-poor { color: var(--danger); font-weight: 600; }

/* In-table links to the real page: quiet until hovered */
.page-link { color: var(--text); text-decoration: none; font-family: ui-monospace, "Geist Mono", SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; }
.page-link:hover { border-color: var(--border-strong); }

/* YouTube channel header */
.yt-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px 20px; }
.yt-id { min-width: 0; flex: 1; }
.yt-id h3 { margin: 0 0 2px; font-size: 16px; font-weight: 600; line-height: 1.25; }
.yt-id .hint { margin: 0; }
#yt-cards { width: 100%; margin-top: 12px; }
#yt-range-note { margin: 4px 0 8px; }
a.yt-title { display: inline-block; max-width: 36rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; color: var(--text); }
a.yt-title:hover { text-decoration: underline; }
#panel-forecast .metric-bar { margin-bottom: 0; }

/* Schools → Widget ranking "Pin to slot" input */
.rank-cell { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.rank-pin {
  width: 64px; text-align: right; padding: 5px 8px; font: inherit; min-height: 30px;
  background: var(--panel); border: 1px solid var(--border); color: var(--text); border-radius: 6px;
  -moz-appearance: textfield; appearance: textfield;
}
.rank-pin::-webkit-outer-spin-button, .rank-pin::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.rank-pin::placeholder { color: var(--faint); }
.rank-pin:focus { outline: none; border-color: var(--border-strong); box-shadow: 0 0 0 3px var(--ring); }
.rank-unpin { padding: 4px 9px; line-height: 1; min-height: 30px; }

/* Silos view */
.silo-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.silo-crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; font-size: 15px; font-weight: 600; }
.silo-crumbs a { color: var(--muted); text-decoration: none; padding: 2px 4px; border-radius: 5px; }
.silo-crumbs a:hover { background: var(--panel-2); color: var(--text); }
.silo-crumbs .sep { color: var(--faint); font-weight: 400; }
.silo-crumbs .cur { padding: 2px 4px; }
.silo-jump { display: flex; gap: 6px; }
.silo-jump input { width: 220px; }
.silo-folder { color: var(--text); cursor: pointer; text-decoration: none; font-weight: 500; }
.silo-folder:hover { text-decoration: underline; }
.silo-kind { color: var(--faint); font-size: 11px; margin-right: 6px; }
.badge.new { background: var(--good-soft); color: var(--good); border-color: transparent; font-weight: 500; margin-left: 6px; }

/* Lead-quality breakdowns (Revenue → Scrubbed leads) */
.scrub-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-bottom: 14px; }
.scrub-grid h4, .sub-head { margin: 0 0 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
/* Pacing target input */
.target-input { width: 110px; text-align: right; padding: 4px 8px; font: inherit; font-size: 15px; font-weight: 600; min-height: 32px;
  background: var(--panel); border: 1px solid var(--border); color: var(--text); border-radius: 6px; }
.target-input::placeholder { color: var(--faint); font-weight: 400; }
.target-input:focus { outline: none; border-color: var(--border-strong); box-shadow: 0 0 0 3px var(--ring); }
/* Cohort heat cells */
.cohort-cell { display: block; padding: 4px 6px; border-radius: 5px; text-align: right; font-variant-numeric: tabular-nums; }
.cohort-cell.empty { color: var(--faint); }
.cohort-sub { display: block; font-size: 10.5px; color: var(--faint); }

/* ---------- A/B experiments ---------- */
.exp-panel { padding-top: 18px; }
.exp-top { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.exp-title { margin: 0; font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.exp-question { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; max-width: 72ch; }
.exp-facts { display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.exp-state { font-size: 11.5px; font-weight: 500; padding: 2px 9px; border-radius: 6px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); }
.exp-state.running, .exp-state.leaning { background: var(--panel); color: var(--text); }
.exp-state.winner { background: var(--good-soft); color: var(--good); border-color: transparent; }
.exp-state.loser { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.exp-state.inconclusive { background: var(--revenue-soft); color: var(--revenue); border-color: transparent; }
.exp-kpis { margin: 14px 0 6px; }
.exp-kpis .metric .hint { display: block; font-size: 12px; margin-top: 1px; white-space: nowrap; }
.exp-verdict { margin: 8px 0 8px; padding: 10px 12px; border: 1px solid var(--border); border-left: 3px solid var(--fg); background: var(--panel-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 13.5px; }
.exp-verdict.winner { border-left-color: var(--good); }
.exp-verdict.loser { border-left-color: var(--danger); }
.exp-verdict.inconclusive { border-left-color: var(--revenue); }
.exp-verdict.collecting { border-left-color: var(--faint); }
.progress-line { margin: 0 0 14px; }
.exp-progress-bar { height: 4px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.exp-progress-bar span { display: block; height: 100%; background: var(--fg); }
.exp-table td { vertical-align: middle; }
.exp-table tr.exp-ctl td { color: var(--muted); }
.exp-table tr.exp-ctl td b { color: var(--text); }
.exp-vname { display: flex; align-items: center; gap: 8px; }
.exp-swatch { width: 10px; height: 10px; border-radius: 2px; background: var(--fg); flex: none; }
.exp-swatch.ctl { background: var(--faint); }
.exp-primary-cell b { font-size: 15px; }
.exp-ci-cell { min-width: 150px; }
.ci-bar { position: relative; height: 18px; }
.ci-track { position: absolute; left: 0; right: 0; top: 8px; height: 2px; background: var(--border); }
.ci-range { position: absolute; top: 5px; height: 8px; border-radius: 4px; background: var(--accent-soft); border: 1px solid var(--fg); }
.ci-range.ctl { background: var(--panel-2); border-color: var(--faint); }
.ci-point { position: absolute; top: 4px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: var(--fg); }
.ci-point.ctl { background: var(--faint); }
.exp-chart-wrap { margin-top: 14px; }
.exp-chart { position: relative; height: 200px; }
.exp-about { margin-top: 12px; }
.exp-about summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.exp-about ul { margin: 8px 0 4px; padding-left: 18px; font-size: 13.5px; }
.exp-about p { margin: 6px 0 0; max-width: 100ch; }


/* ---------- Landlord → Clients ---------- */
.clients-toolbar { margin: 0 0 12px; }
.clients-toolbar input[type=search], .clients-toolbar select { padding: 7px 10px; font-size: 13px; border-radius: var(--radius-sm); }
#clients-table tbody tr { cursor: pointer; }
#clients-table tbody tr:hover td { background: var(--panel-2); }
.pill.warn { background: var(--revenue-soft); color: var(--revenue); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.muted { background: var(--panel-2); color: var(--muted); border-color: var(--border); }
.client-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.client-head h2 { margin: 0; font-size: 20px; letter-spacing: -0.01em; }
.client-head .spacer { flex: 1; }
.client-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; align-items: start; }
.client-grid .panel { margin: 0; }
.client-grid .panel.wide { grid-column: 1 / -1; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); align-items: start; font-size: 13.5px; }
.timeline li:last-child { border-bottom: none; }
.timeline .tl-kind { font-size: 15px; line-height: 1.3; text-align: center; }
.timeline .tl-body { min-width: 0; white-space: pre-wrap; word-break: break-word; }
.timeline .tl-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.timeline li.done .tl-body { text-decoration: line-through; color: var(--muted); }
.timeline li.overdue .tl-meta { color: var(--danger); }
.timeline .tl-act { display: flex; gap: 6px; align-items: center; }
.timeline .tl-act button { min-height: 0; padding: 2px 8px; font-size: 12px; }
.weekbars { display: flex; align-items: flex-end; gap: 4px; height: 64px; margin: 8px 0 4px; }
.weekbars .wb { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; min-width: 0; }
.weekbars .wb i { display: block; background: var(--chart-1); border-radius: 3px 3px 0 0; min-height: 2px; }

/* ---------- Form leads ---------- */
.lead-list { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.lead-row { display: grid; grid-template-columns: 7.2rem minmax(0, 1fr) auto auto; gap: 8px 16px; align-items: center; width: 100%; padding: 12px 14px; background: transparent; border: 0; border-bottom: 1px solid var(--border); text-align: left; cursor: pointer; color: inherit; font: inherit; }
.lead-row:last-child { border-bottom: 0; }
.lead-row:hover { background: var(--panel-2); }
.lead-when { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; line-height: 1.35; }
.lead-main { min-width: 0; }
.lead-main b { display: block; font-size: 14.5px; font-weight: 600; }
.lead-job { display: block; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-call { font-weight: 600; font-variant-numeric: tabular-nums; text-decoration: none; color: var(--text); white-space: nowrap; }
.lead-call:hover { text-decoration: underline; }
.lead-act { display: flex; flex-wrap: wrap; gap: 6px; }
.lead-act button { min-height: 32px; padding: 4px 10px; font-size: 12.5px; }
.lead-dl { display: grid; grid-template-columns: 7.2rem 1fr; gap: 8px 16px; font-size: 13.5px; margin: 0; }
.lead-dl dt { color: var(--muted); }
.lead-dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.lead-msg { white-space: pre-wrap; }
.lead-phone-lg { font-size: 18px; font-weight: 650; letter-spacing: -0.02em; }
@media (max-width: 720px) {
  .lead-row { grid-template-columns: 1fr auto; }
  .lead-when { grid-column: 1 / -1; }
}
details.lead-snippet { padding-top: 8px; }
details.lead-snippet > summary.panel-head { cursor: pointer; list-style: none; }
details.lead-snippet > summary.panel-head::-webkit-details-marker { display: none; }
details.lead-snippet > summary.panel-head h3::after { content: " ▸"; color: var(--muted); font-weight: 500; }
details.lead-snippet[open] > summary.panel-head h3::after { content: " ▾"; }
.lead-modal { position: fixed; inset: 0; z-index: 40; background: rgba(9, 9, 11, 0.45); display: flex; align-items: center; justify-content: center; padding: 24px; }
.lead-modal.hidden { display: none !important; }
.lead-modal-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-pop); max-width: 42rem; width: 100%; max-height: min(80vh, 640px); overflow: auto; padding: 8px 20px 20px; }
.lead-modal-card .panel-head { margin: 0 -20px 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); align-items: center; }
.lead-modal-card .report-pre { white-space: pre-wrap; font-size: 13px; }
.weekbars .wb b { display: block; background: var(--good); border-radius: 3px 3px 0 0; }
.weekbars-labels { display: flex; gap: 4px; }
.weekbars-labels span { flex: 1; font-size: 10px; color: var(--faint); text-align: center; white-space: nowrap; overflow: hidden; }
.client-form textarea, .client-form input, .client-form select { width: 100%; padding: 8px 10px; font-size: 13.5px; border-radius: var(--radius-sm); }
.client-form.form-grid { grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.client-form .form-actions { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.client-grid { align-items: start; }
.client-grid .panel { align-self: start; }
.client-grid .empty { padding: 10px 0; text-align: left; }
.act-form { display: flex; flex-direction: column; gap: 8px; }
.act-form-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.act-form-row select { min-width: 7.5rem; padding: 7px 10px; font-size: 13px; border-radius: var(--radius-sm); }
.act-form textarea { width: 100%; min-height: 72px; padding: 8px 10px; font-size: 13.5px; border-radius: var(--radius-sm); resize: vertical; }
.act-form-row .primary { min-height: 34px; padding: 6px 14px; }
.client-timeline { margin-top: 12px; }
.site-rows { display: flex; flex-direction: column; }
.site-row {
  display: grid;
  grid-template-columns: minmax(12rem, 1.3fr) 10.5rem minmax(16rem, 1.5fr) auto;
  gap: 12px 20px;
  align-items: start;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.site-row:first-child { padding-top: 0; }
.site-row:last-child { border-bottom: 0; padding-bottom: 0; }
.site-row-id b { display: block; font-size: 14px; }
.site-row-flags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.site-row-rent { min-width: 0; }
.field-label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
.rent-edit { display: flex; gap: 6px; align-items: center; }
.rent-edit .site-weekly {
  width: 88px; min-height: 32px; padding: 5px 8px; font-size: 13px; text-align: right;
  border-radius: var(--radius-sm);
}
.rent-edit .site-weekly-save { min-height: 32px; padding: 5px 10px; font-size: 12.5px; }
.site-row-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; min-width: 0; }
.site-row-stats .hint { display: block; margin-bottom: 2px; }
.site-row-stats > div { min-width: 0; overflow-wrap: anywhere; }
.site-row .site-detach, .site-row .site-invite { min-height: 32px; padding: 5px 10px; font-size: 12.5px; }
.site-attach { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.site-attach select { min-width: 16rem; padding: 7px 10px; font-size: 13px; border-radius: var(--radius-sm); }
.weekbars-caption { margin: 6px 0 0; }
.client-leads, .client-pays { margin-top: 14px; }
.pay-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 12px 12px;
  align-items: end;
}
.pay-form .form-actions { display: flex; align-items: center; gap: 12px; grid-column: 1 / -1; }
.pay-form .field input, .pay-form .field select { width: 100%; padding: 7px 10px; font-size: 13px; border-radius: var(--radius-sm); }
.client-leads .tbl-wrap { margin: 0; }
.client-pays .tbl-wrap { margin: 0; }
@media (max-width: 960px) {
  .site-row { grid-template-columns: 1fr 10.5rem; }
  .site-row-stats { grid-column: 1 / -1; }
  .site-row .site-detach { justify-self: start; }
}
@media (max-width: 640px) {
  .client-form.form-grid { grid-template-columns: 1fr; }
  .site-row { grid-template-columns: 1fr; }
  .site-row-stats { grid-template-columns: 1fr 1fr; }
}
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.inline-form input, .inline-form select, .inline-form textarea { padding: 7px 10px; font-size: 13px; border-radius: var(--radius-sm); }
.inline-form textarea { flex: 1 1 100%; min-height: 56px; }
