/* FUA One — design system (from the "FUA One" Claude Design project).
   Token-driven, light + dark. Manrope (Aeonik fallback) UI, JetBrains Mono
   for figures, plus a brand gradient. */

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e6e8f0;
  --border-2: #d5d8e6;
  --text: #0f172a;
  --text-2: #555d72;
  /* AA: #8b91a5 was ~3.0:1 on the near-white bg (below the 4.5:1 floor for
     body text); #6b7280 is ~4.6:1 and still clearly muted vs --text-2. */
  --text-3: #6b7280;
  --pos: #059669;
  --neg: oklch(.55 .17 25);
  --warn: #F59E0B;
  --accent: #6366F1;
  --brand-2: #8B5CF6;
  --brand-3: #0D8CFF;
  --brand-4: #22D3EE;
  --brand-grad: linear-gradient(120deg, #8B5CF6, #6366F1 42%, #0D8CFF 74%, #22D3EE);
  --accent-fg: #fff;
  --grid: #ecedf3;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 32px -8px rgba(15, 23, 42, .16), 0 2px 6px rgba(15, 23, 42, .06);
}

html[data-theme="dark"] {
  --bg: #07080d;
  --surface: #0e1016;
  --surface-2: #14161f;
  --border: #1f2331;
  --border-2: #2c3142;
  --text: #f2f3f7;
  --text-2: #98a0b4;
  /* AA: #666e82 was ~3.9:1 on the dark surface; #8b93a8 is ~6.4:1. */
  --text-3: #8b93a8;
  --pos: #10B981;
  --neg: oklch(.68 .16 25);
  --warn: #F59E0B;
  --accent: #818CF8;
  --brand-2: #A78BFA;
  --brand-3: #38A3FF;
  --brand-4: #22D3EE;
  --brand-grad: linear-gradient(120deg, #A78BFA, #7C86F8 42%, #3B9BFF 74%, #22D3EE);
  --grid: #191d28;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-lg: 0 16px 40px -10px rgba(0, 0, 0, .75), 0 2px 8px rgba(0, 0, 0, .45);
}

:root {
  --accent-soft: color-mix(in oklab, var(--accent) 13%, transparent);
  --accent-line: color-mix(in oklab, var(--accent) 30%, transparent);
  --pos-soft: color-mix(in oklab, var(--pos) 14%, transparent);
  --neg-soft: color-mix(in oklab, var(--neg) 14%, transparent);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Aeonik, Manrope, system-ui, -apple-system, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: translateY(-4px) scale(.985); } to { opacity: 1; transform: none; } }

.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.muted { color: var(--text-2); }
.muted-3 { color: var(--text-3); }

/* ------- App shell ------- */
.app { height: 100vh; display: flex; overflow: hidden; background: var(--bg); }

.sidebar {
  flex: none; width: 236px;
  transition: width .24s cubic-bezier(.4, 0, .2, 1);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden; z-index: 20;
}
.app[data-nav="collapsed"] .sidebar { width: 60px; }
.app[data-nav="collapsed"] .nav-label,
.app[data-nav="collapsed"] .nav-chevron { opacity: 0; pointer-events: none; }
.app[data-nav="collapsed"] .nav-splits { display: none; }
/* Collapsed shows only the rail logo (which is the expand affordance);
   expanded shows the hamburger + full lockup + pin. */
.app[data-nav="collapsed"] .only-expanded { display: none !important; }
.app[data-nav="expanded"] .only-collapsed { display: none !important; }

.side-head {
  height: 61px; flex: none; display: flex; align-items: center; gap: 9px;
  padding: 0 13px; border-bottom: 1px solid var(--border);
}
/* Brand: full lockup (mark + wordmark) when expanded; a centered mark
   ("rail") when collapsed, which doubles as the expand button. */
.brand-lockup { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; cursor: pointer; background: transparent; border: 0; padding: 0; }
.rail-logo { flex: 1; height: 34px; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 9px; background: transparent; cursor: pointer; transition: background .14s; }
.rail-logo:hover { background: var(--surface-2); }
.brand-mark-img { height: 18px; width: auto; flex: none; }
.rail-logo .brand-mark-img { height: 20px; }
.brand-word-img { height: 11.5px; width: auto; flex: none; }
/* Theme-swapped logo variants (dark-theme asset vs light-theme asset). */
.logo-dark { display: none; }
.logo-light { display: block; }
html[data-theme="dark"] .logo-dark { display: block; }
html[data-theme="dark"] .logo-light { display: none; }
/* Marks blend into the surface — screen on dark, multiply on light. */
.brand-mark-img.logo-dark { mix-blend-mode: screen; }
.brand-mark-img.logo-light { mix-blend-mode: multiply; }

.icon-btn {
  flex: none; width: 32px; height: 32px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: transparent; color: var(--text-2);
  cursor: pointer; transition: background .14s, color .14s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.pin-btn { width: 26px; height: 26px; border-radius: 7px; transition: opacity .18s, background .14s; }
.pin-btn.is-pinned { background: var(--accent-soft); color: var(--accent); }

.nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 9px 8px; display: flex; flex-direction: column; gap: 1px; }
.side-foot { flex: none; padding: 8px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 1px; }

.nav-group__btn {
  width: 100%; display: flex; align-items: center; gap: 11px; padding: 7px 9px;
  border: 0; border-radius: 8px; cursor: pointer; text-align: left;
  font-size: 13px; font-weight: 450; letter-spacing: -.005em;
  background: transparent; color: var(--text-2); transition: background .14s, color .14s;
}
.nav-group__btn:hover { background: var(--surface-2); }
.nav-group__btn.is-active { color: var(--text); font-weight: 600; }
.nav-group__btn.is-active-closed { background: var(--accent-soft); }
.nav-group__btn svg { flex: none; }
.nav-label { flex: 1; white-space: nowrap; overflow: hidden; transition: opacity .18s; }
.nav-chevron { flex: none; color: var(--text-3); transition: transform .2s, opacity .18s; }
.nav-chevron.is-open { transform: rotate(90deg); }

.nav-splits { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 7px 19px; padding-left: 11px; border-left: 1px solid var(--border); animation: fadeUp .2s ease both; }
.side-foot .nav-splits { margin: 0 0 6px 19px; }
.nav-split {
  display: block; width: 100%; text-align: left; padding: 6px 9px; border: 0; border-radius: 7px;
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 12.5px; font-weight: 450; background: transparent; color: var(--text-2);
  transition: background .14s, color .14s;
}
.nav-split:hover { background: var(--surface-2); }
.nav-split.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ------- Main column ------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  flex: none; height: 61px; display: flex; align-items: center; gap: 14px;
  padding: 0 20px 0 22px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: relative; z-index: 15;
}
.crumb { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex: 1 1 auto; overflow: hidden; }
.crumb__parent { font-size: 13px; color: var(--text-3); white-space: nowrap; flex: none; }
.crumb__sep { font-size: 13px; color: var(--border-2); flex: none; }
.crumb__page { font-size: 14.5px; font-weight: 600; letter-spacing: -.015em; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

.range-chips { display: flex; flex: none; align-items: center; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); }
.chip { padding: 5px 10px; border: 0; border-radius: 7px; cursor: pointer; white-space: nowrap; font-size: 12px; font-weight: 450; background: transparent; color: var(--text-2); transition: background .14s, color .14s; }
.chip.is-active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

.pill {
  display: flex; flex: none; align-items: center; gap: 7px; padding: 5px 10px 5px 11px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface);
  font-size: 12px; color: var(--text-2); white-space: nowrap; cursor: pointer; transition: background .14s;
}
.pill:hover { background: var(--surface-2); }
/* Fixed-width date label so switching ranges doesn't resize the pill and
   shove the range chips left/right. */
#dateLabel { display: inline-block; min-width: 148px; text-align: left; }
.divider { width: 1px; height: 22px; background: var(--border); flex: none; }

/* Date-range picker dropdown */
.date-panel { position: absolute; top: 44px; right: 0; width: 300px; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); animation: popIn .16s ease both; z-index: 40; }
.date-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 8px; }
.date-preset { padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-2); font-size: 12px; cursor: pointer; text-align: left; transition: background .14s; }
.date-preset:hover { background: var(--surface-2); }
.date-preset.is-active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); font-weight: 600; }
.date-custom { display: flex; align-items: center; gap: 6px; padding: 8px 4px 4px; border-top: 1px solid var(--border); }
.date-custom input { flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); color: var(--text); font-size: 12px; font-family: inherit; }

.org-btn { display: flex; align-items: center; gap: 8px; padding: 5px 9px 5px 6px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); cursor: pointer; transition: background .14s; }
.org-btn:hover { background: var(--surface-2); }
.avatar { width: 22px; height: 22px; flex: none; border-radius: 6px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 11px; font-weight: 600; }
.org-name { font-size: 12.5px; font-weight: 500; color: var(--text); white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }

.icon-btn.bordered { width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.icon-btn.bordered:hover { background: var(--surface-2); }
.bell-badge { position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--neg); color: #fff; font-family: 'JetBrains Mono', monospace; font-size: 9.5px; font-weight: 600; display: grid; place-items: center; border: 2px solid var(--surface); }
.profile-btn { display: flex; align-items: center; border: 0; background: transparent; cursor: pointer; padding: 0; }
.avatar-round { width: 30px; height: 30px; border-radius: 50%; background: var(--text); color: var(--bg); display: grid; place-items: center; font-size: 11.5px; font-weight: 600; }
.menu__row { padding: 7px 10px; border-radius: 8px; font-size: 12.5px; color: var(--text-2); cursor: pointer; transition: background .14s; }
.menu__row:hover { background: var(--surface-2); }
.alert-item { display: flex; gap: 9px; padding: 9px; border-radius: 8px; }
.alert-item:hover { background: var(--surface-2); }
/* Recent-alerts feed: bound the list so it can't stretch the Overview row.
   Header + "View all alerts" stay pinned; overflow scrolls inside. */
.alert-scroll { display: flex; flex-direction: column; gap: 2px; flex: 1 1 0; min-height: 0; overflow-y: auto; margin-right: -4px; padding-right: 4px; }
.alert-scroll::-webkit-scrollbar { width: 6px; }
.alert-scroll::-webkit-scrollbar-thumb { background: var(--border-2, var(--border)); border-radius: 3px; }
.alert-scroll::-webkit-scrollbar-track { background: transparent; }

.menu { position: absolute; top: 44px; right: 0; width: 264px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); animation: popIn .16s ease both; z-index: 40; }
.menu__label { padding: 7px 9px 6px; font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.menu__item { width: 100%; display: flex; align-items: center; gap: 9px; padding: 8px 9px; border: 0; border-radius: 8px; cursor: pointer; text-align: left; background: transparent; color: var(--text); transition: background .14s; }
.menu__item:hover { background: var(--surface-2); }

/* ------- View / cards ------- */
.view { flex: 1; overflow-y: auto; background: var(--bg); }
.view__inner { max-width: 1320px; margin: 0 auto; padding: 22px 24px 40px; display: flex; flex-direction: column; gap: 14px; }
.grid { display: grid; gap: 14px; }
@media (min-width: 1120px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .grid-215 { grid-template-columns: minmax(0, 2.15fr) minmax(0, 1fr); }
  .grid-19 { grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); }
}
/* Overview bottom row (channels / today) — let each take its natural height
   rather than stretching the short channels card into an empty void. The top
   row (grid-215) stays stretched so the trend + alerts cards match height; the
   alerts list fills via flex-grow + scroll (see .alert-scroll). */
.grid-13 { align-items: start; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 16px 18px 14px; }
.card--flush { padding: 0; overflow: hidden; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card__title { font-size: 13px; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
.card__sub { font-size: 11.5px; color: var(--text-3); }

/* KPI tiles */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 14px 15px 12px; display: flex; flex-direction: column; gap: 11px; }
.kpi__label { font-size: 11px; font-weight: 600; letter-spacing: .055em; text-transform: uppercase; color: var(--text-3); }
.kpi__value { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 25px; font-weight: 600; letter-spacing: -.03em; color: var(--text); font-variant-numeric: tabular-nums; }
.kpi__value.accent { color: var(--accent); }
.kpi--accent { border-color: var(--accent-line); background: color-mix(in oklab, var(--accent-soft) 55%, var(--surface)); }
.ctype { padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border); background: var(--surface); font-size: 10.5px; color: var(--text-3); white-space: nowrap; text-transform: capitalize; }
.roas-badge { display: inline-block; min-width: 52px; text-align: center; padding: 3px 8px; border-radius: 6px; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi__foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.delta { display: inline-flex; align-items: center; gap: 3px; padding: 2px 6px; border-radius: 5px; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.pos { background: var(--pos-soft); color: var(--pos); }
.delta.neg { background: var(--neg-soft); color: var(--neg); }
.delta.flat { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.spark { flex: none; display: block; }

/* Screen header + sections */
.screen-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.screen-head h1 { margin: 0 0 5px; font-size: 20px; font-weight: 600; letter-spacing: -.02em; color: var(--text); }
.screen-head p { margin: 0; font-size: 12.5px; color: var(--text-2); }
.sec-title { margin: 0 0 3px; font-size: 14px; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
.sec-sub { margin: 0; font-size: 11.5px; color: var(--text-3); }

/* Channel bars */
.chbar__head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; font-size: 12.5px; color: var(--text); }
.chbar__val { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; font-variant-numeric: tabular-nums; }
.chbar__track { height: 7px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.chbar__fill { height: 100%; border-radius: 4px; background: var(--accent); }

/* Compact table (today vs avg, etc.) */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: right; padding: 8px 18px; font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl td { padding: 11px 18px; font-size: 12.5px; color: var(--text); border-bottom: 1px solid var(--border); }
.tbl td.num { text-align: right; font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.tbl tr:last-child td { border-bottom: 0; }

/* Cohort retention heatmap */
.rh-grid { display: grid; gap: 4px; align-items: center; }
.rh-head { font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); padding-bottom: 5px; }
.rh-head.rh-c { text-align: center; }
.rh-cohort { display: flex; align-items: center; font-size: 12px; font-weight: 500; color: var(--text); }
.rh-size { display: flex; align-items: center; justify-content: flex-end; font-size: 11.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.rh-cell { height: 34px; border-radius: 6px; display: grid; place-items: center; font-size: 11.5px; font-variant-numeric: tabular-nums; border: 1px solid var(--border); }
.rh-cell.rh-na { color: var(--text-3); background: transparent; border-style: dashed; }

/* Editable forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 16px 0 4px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field > span { font-size: 11.5px; font-weight: 600; letter-spacing: .01em; color: var(--text-2); }
.form-input { width: 100%; padding: 8px 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font-size: 13px; font-family: inherit; box-sizing: border-box; }
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 16%, transparent); }
.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.form-status { font-size: 12px; font-weight: 500; }

/* Revenue-trend chart axes + legend */
.legend { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-2); }
.legend__line { width: 14px; height: 2px; border-radius: 2px; }
.legend__dash { width: 14px; height: 0; border-top: 2px dashed var(--text-3); }
.trend-grid { display: grid; grid-template-columns: 46px 1fr; gap: 8px; margin-top: 6px; }
.trend-y { display: flex; flex-direction: column; justify-content: space-between; height: 250px; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 10px; color: var(--text-3); text-align: right; padding-top: 2px; }
.trend-x { display: flex; justify-content: space-between; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 10px; color: var(--text-3); padding-top: 8px; }
.pill-badge { padding: 2px 7px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 10.5px; color: var(--text-2); }

/* Interactive chart hover: crosshair + floating tooltip */
.chart-hoverable { cursor: crosshair; }
/* Clickable (drill-down) charts signal it with a pointer; defined after
   .chart-hoverable so it wins when both classes are present. */
.chart-selectable { cursor: pointer; }
.chart-hoverable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.chart-cross { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; opacity: .65; pointer-events: none; vector-effect: non-scaling-stroke; }
.chart-tip { position: fixed; z-index: 90; pointer-events: none; min-width: 132px; padding: 8px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 6px 22px rgba(15, 23, 42, .16); font-size: 11.5px; }
.chart-tip__d { font-weight: 650; color: var(--text); font-size: 11px; margin-bottom: 5px; }
.chart-tip__r { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 1px 0; }
.chart-tip__k { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.chart-tip__k i { width: 8px; height: 8px; border-radius: 2px; flex: none; display: inline-block; }
.chart-tip__v { font-family: 'JetBrains Mono', ui-monospace, monospace; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

@media (min-width: 1120px) {
  .grid-13 { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); }
}

/* Table */
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th { text-align: left; padding: 9px 12px; font-size: 11px; font-weight: 600; letter-spacing: .02em; color: var(--text-3); text-transform: uppercase; border-bottom: 1px solid var(--border); white-space: nowrap; cursor: pointer; user-select: none; }
.table th.right, .table td.right { text-align: right; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.badge.pos { background: var(--pos-soft); color: var(--pos); }
.badge.neg { background: var(--neg-soft); color: var(--neg); }
.badge.neutral { background: var(--surface-2); color: var(--text-2); }

.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; display: inline-block; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 12.5px; font-weight: 500; cursor: pointer; transition: background .14s, border-color .14s, box-shadow .14s, filter .14s; }
.btn:hover { background: var(--surface-2); }
/* Primary: brand gradient that stops at blue (no cyan/green edge). Hover
   DARKENS + lifts (visible on any background) rather than washing out. */
.btn--primary,
.btn--primary:hover { background: linear-gradient(118deg, var(--brand-2) 0%, var(--accent) 52%, var(--brand-3) 100%); border-color: transparent; color: #fff; }
.btn--primary { box-shadow: 0 1px 2px rgba(30, 27, 75, .22); }
.btn--primary:hover { filter: brightness(.94); box-shadow: 0 4px 12px rgba(60, 50, 170, .32); }
.btn--sm { padding: 6px 10px; font-size: 12px; }

/* Empty state */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; padding: 64px 24px; }
.empty__icon { width: 52px; height: 52px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.empty__title { font-size: 17px; font-weight: 600; letter-spacing: -.015em; }
.empty__text { font-size: 13px; color: var(--text-2); max-width: 420px; line-height: 1.55; }

/* Connection cards */
.conn-group-head { margin: 6px 0 -6px; }
.conn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.conn { display: flex; flex-direction: column; gap: 12px; }
.conn__top { display: flex; align-items: center; gap: 11px; }
.conn__logo { width: 40px; height: 40px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; font-weight: 700; color: var(--text-2); flex: none; }
.conn__name { font-size: 13.5px; font-weight: 600; }
.conn__status { font-size: 11.5px; display: flex; align-items: center; gap: 6px; color: var(--text-2); }

.loading { padding: 60px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ============================================================
   Accessibility
   ============================================================ */

/* Keyboard skip link — first focusable element, off-screen until focused. */
.skip-link {
  position: fixed; left: 10px; top: -56px; z-index: 100;
  padding: 9px 15px; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-lg); transition: top .16s ease;
}
.skip-link:focus { top: 10px; text-decoration: none; outline: 2px solid var(--surface); outline-offset: 2px; }

/* A single visible focus ring for keyboard users across every control.
   Mouse clicks don't trigger :focus-visible, so this doesn't add noise. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Text inputs already show an accent ring via box-shadow on :focus. */
.form-input:focus-visible, .date-custom input:focus-visible { outline: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   Responsive — the shell is desktop-first; below 860px the
   sidebar becomes an off-canvas drawer and the topbar tightens.
   ============================================================ */

/* Topbar hamburger + drawer backdrop exist only on mobile. */
.mobile-nav-btn { display: none; }
.nav-backdrop { display: none; }

@media (max-width: 860px) {
  .mobile-nav-btn {
    display: grid; place-items: center; flex: none; width: 34px; height: 34px;
    border: 1px solid var(--border); border-radius: 9px;
    background: var(--surface); color: var(--text-2); cursor: pointer;
  }
  .mobile-nav-btn:hover { background: var(--surface-2); }

  /* Off-canvas drawer. `visibility: hidden` (not just transform) keeps the
     hidden nav out of the tab order + accessibility tree. */
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; width: 264px !important;
    z-index: 60; visibility: hidden; transform: translateX(-100%);
    transition: transform .24s cubic-bezier(.4, 0, .2, 1), visibility .24s;
    box-shadow: var(--shadow-lg);
  }
  .app[data-mobile-nav="open"] .sidebar { visibility: visible; transform: none; }

  /* On mobile the drawer is always the FULL nav (never the collapsed rail),
     regardless of the desktop collapse state. */
  #drawerToggle, #pinToggle, #railToggle { display: none !important; }
  #brandHome { display: flex !important; }
  .nav-label, .nav-chevron { opacity: 1 !important; pointer-events: auto !important; }
  .nav-splits { display: flex !important; }

  .nav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(15, 23, 42, .42); opacity: 0; pointer-events: none;
    transition: opacity .2s ease;
  }
  .app[data-mobile-nav="open"] .nav-backdrop { opacity: 1; pointer-events: auto; }

  /* Tighten the topbar so its controls fit a phone width. */
  .topbar { padding: 0 12px; gap: 9px; }
  .divider { display: none; }
  #dateLabel { min-width: 0; }
  .org-name { display: none; }
  .crumb__parent, .crumb__sep { display: none; }

  .view__inner { padding: 16px 14px 32px; }
}

@media (max-width: 480px) {
  .screen-head h1 { font-size: 18px; }
  .kpi__value { font-size: 22px; }
  .view__inner { padding: 14px 11px 28px; }
}

/* ------- Modal (in-app dialogs) ------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center;
  padding: 20px; background: rgba(15, 23, 42, .45);
  animation: fadeUp .14s ease both;
}
.modal {
  width: min(94vw, 430px); background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-lg); padding: 22px 22px 18px;
  animation: popIn .16s ease both;
}
.modal__title { margin: 0 0 6px; font-size: 16px; font-weight: 650; letter-spacing: -.01em; color: var(--text); }
.modal__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ------- Connections (redesigned) ------- */
.conn-summary {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  box-shadow: var(--shadow);
}
.conn-card { display: flex; flex-direction: column; gap: 11px; padding: 14px 15px 13px; }
.conn-card--dashed { border-style: dashed; border-color: var(--border-2); box-shadow: none; }
.conn-head { display: flex; align-items: center; gap: 12px; }
.conn-logo {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center;
  border-radius: 11px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.05);
}
.conn__name { display: block; font-size: 14px; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
.conn__sub { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conn__desc { margin: 0; font-size: 12px; line-height: 1.55; color: var(--text-2); }
.conn-pill { display: inline-flex; align-items: center; gap: 5px; flex: none; padding: 3px 9px; border-radius: 7px; font-size: 11px; font-weight: 600; }
.conn-pill--ok { background: var(--pos-soft); color: var(--pos); }
.conn-pill--err { background: var(--neg-soft); color: var(--neg); }
.conn-pill--off { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-3); }
.conn-pill--warn { background: color-mix(in oklab, var(--warn) 16%, transparent); color: var(--warn); }
/* Account picker (post-consent) */
.acct-list { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; }
.acct-opt { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; cursor: pointer; transition: border-color .14s, background .14s; }
.acct-opt:hover { background: var(--surface-2); }
.acct-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.acct-opt input { accent-color: var(--accent); flex: none; }
.acct-opt__label { flex: 1; font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-opt__id { font-size: 11px; color: var(--text-3); flex: none; }
.conn-stats { display: flex; gap: 18px; padding: 11px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.conn-stat { display: flex; flex-direction: column; gap: 2px; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11px; color: var(--text-3); }
.conn-stat__v { font-size: 12px; }
.conn-note { padding: 11px 12px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); font-size: 11.5px; line-height: 1.5; color: var(--text-2); }
.conn-note--err { background: var(--neg-soft); border-color: color-mix(in oklab, var(--neg) 26%, transparent); color: var(--text); }
.conn-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: auto; }
/* Plain clickable text under the Connect button (no button chrome). */
.conn-manual-link { flex-basis: 100%; width: 100%; text-align: left; background: none; border: 0; padding: 0; margin: 2px 0 0; font: inherit; font-size: 11.5px; color: var(--accent); cursor: pointer; }
.conn-manual-link:hover { text-decoration: underline; }
.conn-manual-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.conn-danger { color: var(--neg); }
.conn-danger:hover { background: var(--neg-soft); }

/* ------- Get Started (redesigned) ------- */
.ob-cols { display: grid; gap: 14px; align-items: start; grid-template-columns: minmax(0, 1fr) 320px; }
@media (max-width: 940px) { .ob-cols { grid-template-columns: minmax(0, 1fr); } }
.ob-src {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 11px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2);
  color: var(--text); font-size: 12px; font-weight: 550; cursor: pointer; transition: background .14s, border-color .14s;
}
.ob-src:hover { background: var(--accent-soft); border-color: var(--accent-line); }
