:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --border: #e3e6ef;
  --text: #171a2b;
  --muted: #6b7189;
  --accent: #4f46e5;
  --pos: #0f9d58;
  --neg: #d93025;
  --section: #eef0fb;
  --mtd: #fff8e6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(23, 26, 43, .06), 0 4px 16px rgba(23, 26, 43, .05);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---- top bar ---- */
.topbar {
  height: 56px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--text); color: #fff; font-weight: 700; font-size: 14px;
}
.brand-mark.big { width: 48px; height: 48px; border-radius: 12px; font-size: 22px; margin: 0 auto 16px; }
.topnav { display: flex; align-items: center; gap: 16px; }
.navlink { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; }
.navlink:hover { color: var(--text); }
.who { display: inline-flex; align-items: center; gap: 8px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border);
  display: grid; place-items: center; font-weight: 600; font-size: 12px;
}
.flashes { padding: 12px 20px 0; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; background: #e8f5ee; color: #0b6b3c; }
.flash.error { background: #fdecea; color: #a52714; }

/* ---- home ---- */
.home { max-width: 1120px; margin: 0 auto; padding: 32px 20px 64px; }
.home-head { margin-bottom: 24px; }
.home-head p { margin: 6px 0 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.tile {
  display: flex; flex-direction: column; gap: 6px; padding: 20px; min-height: 180px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.tile:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.tile-icon {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; margin-bottom: 10px;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, white);
}
.tile-icon.small { width: 28px; height: 28px; border-radius: 8px; margin: 0; }
.tile-name { font-weight: 600; font-size: 16px; }
.tile-desc { color: var(--muted); font-size: 13px; flex: 1; }
.tile-meta { color: var(--muted); font-size: 12px; }

.empty {
  text-align: center; padding: 64px 20px; color: var(--muted);
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty h2 { color: var(--text); margin: 12px 0 6px; }

/* ---- report layout ---- */
.report { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100vh - 56px); }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px;
  position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto;
}
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; margin: 0 8px 16px; }
.back:hover { color: var(--text); }
.sidebar-title { display: flex; align-items: center; gap: 10px; font-weight: 600; margin: 0 8px 12px; }
.pages { display: flex; flex-direction: column; gap: 2px; }
.pagelink {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px; color: var(--text); font-weight: 500;
}
.pagelink:hover { background: var(--surface-2); }
.pagelink.active { background: color-mix(in srgb, var(--accent) 12%, white); color: var(--accent); }
.pagelink.soon { color: var(--muted); font-weight: 400; }
.badge { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; padding: 2px 6px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.content { padding: 24px; min-width: 0; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 4px 0 0; }
.controls { display: flex; align-items: flex-end; gap: 8px; }
.select { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
select, input[type=email], input[name=name], input[type=text] {
  font: inherit; color: var(--text); padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); min-width: 200px;
}
.btn {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 500; cursor: pointer;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.danger { color: var(--neg); }
.btn.wide { width: 100%; justify-content: center; padding: 11px; }
.alert { padding: 12px 14px; border-radius: 8px; background: #fdecea; color: #a52714; margin: 12px 0; }
.alert.warn { background: #fff4e0; color: #8a5300; }

/* ---- the grid ---- */
.table-wrap {
  overflow: auto; max-height: calc(100vh - 200px); width: fit-content; max-width: 100%; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
table.grid { border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; font-size: 13px; }
.grid th, .grid td { padding: 6px 12px; white-space: nowrap; border-bottom: 1px solid var(--border); }
.grid thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); font-weight: 600;
  text-align: right; font-size: 12px; color: var(--muted);
}
.grid td { text-align: right; }
.grid .rowhead {
  position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left;
  font-weight: 500; min-width: 220px; border-right: 1px solid var(--border);
}
.grid thead .rowhead { z-index: 3; background: var(--surface-2); color: var(--text); }
.grid tr.total .rowhead, .grid tr.total td { font-weight: 700; }
.grid tr.sub .rowhead { padding-left: 26px; color: var(--muted); font-weight: 400; }
.grid tr.section .rowhead, .grid tr.section td {
  background: var(--section); font-weight: 700; color: var(--accent); text-transform: uppercase;
  font-size: 11px; letter-spacing: .05em; padding-top: 10px;
}
.grid tbody tr:hover td, .grid tbody tr:hover .rowhead { background: #f7f8ff; }
.grid .col-mtd { background: var(--mtd); }
.grid thead .col-mtd { background: #fdefc6; color: var(--text); }
.grid .col-rr, .grid .col-lmtd, .grid .col-growth { background: #fafbfd; }
.grid thead .col-rr, .grid thead .col-lmtd, .grid thead .col-growth { background: #e9ecf5; color: var(--text); }
.grid td.col-rr { border-left: 2px solid var(--border); }
.grid td.pos { color: var(--pos); font-weight: 600; }
.grid td.neg { color: var(--neg); font-weight: 600; }
.footnote { font-size: 12px; margin-top: 12px; max-width: 900px; }

/* ---- admin ---- */
.admin { max-width: 1200px; margin: 0 auto; padding: 24px 20px 64px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab { padding: 10px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--accent); border-color: var(--accent); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.stack { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.row-form { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.inline { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 99px;
  border: 1px solid var(--border); font-size: 12px; cursor: pointer; background: var(--surface);
}
.chip:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, white); color: var(--accent); }
.chip input { margin: 0; }
.admin-chip:has(input:checked) { border-color: var(--text); background: var(--text); color: #fff; }
.check { display: inline-flex; gap: 6px; align-items: center; }
.table-scroll { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 8px; border-bottom: 1px solid var(--border); }
.list td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.list .actions { display: flex; gap: 6px; }
.list .actions form { margin: 0; }
.matrix th:not(:first-child), .matrix td:not(:first-child) { text-align: center; }
.matrix + .btn, form > .btn.primary { margin-top: 14px; }

/* ---- login ---- */
.login { min-height: calc(100vh - 56px); display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 380px; text-align: center; background: var(--surface); padding: 36px 28px;
  border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
}
.login-card p { margin: 8px 0 24px; }
.gsi-wrap { display: flex; justify-content: center; min-height: 44px; }

@media (max-width: 760px) {
  .report { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .pages { flex-direction: row; overflow-x: auto; }
  .pagelink { white-space: nowrap; }
  .content { padding: 16px; }
  .who-text { display: none; }
  .grid .rowhead { min-width: 160px; }
}

/* ---- dashboard (Cadence › Overall Monthly) ---- */
:root { --ink: #2f2e2b; --repeat: #d6d4cd; --good: #006300; --bad: #c5221f; }
.viewtabs { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.viewtab { font: inherit; font-weight: 500; border: 0; background: transparent; color: var(--muted); padding: 6px 14px; border-radius: 8px; cursor: pointer; }
.viewtab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(23, 26, 43, .08); }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 20px; }
.filters select { min-width: 180px; }

.dash { display: flex; flex-direction: column; gap: 16px; }
.dash-row { display: grid; gap: 16px; }
.dash-row.headline { grid-template-columns: minmax(280px, 1fr) minmax(0, 2.6fr); }
.dash-row.two-one { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); }
.dash-row.halves { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dash-row.thirds { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dash .card { margin: 0; padding: 18px 20px; }
.card-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card-head p { margin: 2px 0 0; font-size: 12px; }
.section-title { font-size: 14px; margin: 8px 0 12px; }

/* hero */
.hero { display: flex; flex-direction: column; gap: 6px; }
.hero-value { font-size: 44px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; margin-top: 4px; }
.hero-delta { display: flex; align-items: center; gap: 6px; font-size: 12px; flex-wrap: wrap; }
.hero-pace { font-size: 13px; color: var(--muted); }
.split { margin-top: 10px; }
.split-bar { height: 8px; border-radius: 99px; background: var(--repeat); overflow: hidden; }
.split-bar span { display: block; height: 100%; background: var(--ink); border-right: 2px solid var(--surface); }
.split-legend { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.split-legend b { color: var(--text); font-weight: 600; }
.hero-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: auto 0 0; padding-top: 14px; border-top: 1px solid var(--border); }
.hero-facts dt { font-size: 12px; color: var(--muted); }
.hero-facts dd { margin: 2px 0 0; font-weight: 600; font-size: 16px; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { display: flex; flex-direction: column; gap: 4px; min-height: 118px; }
.kpi-value { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.kpi-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; margin-top: auto; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 99px; white-space: nowrap; }
.delta.up { color: var(--good); background: #e7f4e7; }
.delta.down { color: var(--bad); background: #fcebea; }
.delta.flat { color: var(--muted); background: var(--surface-2); }
.spark { width: 96px; height: 28px; flex: none; }
.spark-line { fill: none; stroke: #b9b7b0; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* legends & keys (text stays in text colours; the key carries identity) */
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.card > .legend { margin: -4px 0 8px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--k); flex: none; }
.key.line { height: 2px; width: 14px; border-radius: 2px; }

/* charts: fixed height includes the axis band */
.chart { position: relative; height: 260px; }
.chart.tall { height: 300px; }
.chart.short { height: 200px; }

/* service mix */
.mix { display: flex; flex-direction: column; gap: 14px; }
.mix-top { display: grid; grid-template-columns: 1fr auto 48px; gap: 8px; align-items: baseline; font-size: 13px; }
.mix-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.mix-val { color: var(--muted); }
.mix-share { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.meter { height: 6px; border-radius: 99px; background: var(--surface-2); margin-top: 6px; overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 99px; }

/* funnel */
.funnel { display: flex; align-items: stretch; gap: 0; }
.funnel-step { flex: 1; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; padding: 14px 16px; background: var(--surface-2); border-radius: 10px; }
.funnel-value { font-size: 22px; font-weight: 700; }
.funnel-link { flex: 0 0 150px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 2px; padding: 0 8px; font-size: 12px; color: var(--muted); }
.funnel-link .arrow { font-size: 18px; color: var(--axis, #c3c2b7); line-height: 1; }

/* service cards */
.services { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.svc { display: flex; flex-direction: column; gap: 10px; }
.svc-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.svc-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.svc-main { display: flex; align-items: center; gap: 10px; }
.svc-value { font-size: 22px; font-weight: 700; }
.svc-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; padding-top: 10px; border-top: 1px solid var(--border); }
.svc-facts dt { font-size: 11px; color: var(--muted); }
.svc-facts dd { margin: 2px 0 0; font-weight: 600; }

@media (max-width: 1280px) {
  .dash-row.headline { grid-template-columns: 1fr; }
  .dash-row.thirds { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .services { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .dash-row.two-one, .dash-row.halves, .dash-row.thirds, .services { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .funnel { flex-direction: column; }
  .funnel-link { flex-basis: auto; flex-direction: row; padding: 8px 0; }
  .funnel-link .arrow { transform: rotate(90deg); }
}

/* trend range switch + momentum */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.segmented button { font: inherit; font-size: 13px; font-weight: 500; border: 0; background: transparent; color: var(--muted);
  padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(23, 26, 43, .1); }
.range-note { margin: -4px 0 0; font-size: 12px; }
table.momentum { width: 100%; border-collapse: collapse; font-size: 13px; }
.momentum th, .momentum td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.momentum thead th { font-size: 12px; font-weight: 600; color: var(--text); vertical-align: bottom; }
.momentum thead th:first-child { color: var(--muted); font-weight: 500; }
.momentum tbody th { font-weight: 500; }
.momentum tbody tr:last-child th, .momentum tbody tr:last-child td { border-bottom: 0; }
.momentum tbody tr:hover { background: #f7f8ff; }
.mcell { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 150px; }
.mval { font-weight: 600; font-variant-numeric: tabular-nums; }

/* headline mini chart */
.hero-chart { margin-top: 12px; }
.hero-chart-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.hero-chart-cmp { display: inline-flex; align-items: center; gap: 4px; }
.chart.mini { height: 130px; margin-top: 6px; }
/* KPI tiles grow with the headline card: the sparkline box takes the extra room */
.kpi .kpi-foot { flex: 1; flex-direction: column; align-items: stretch; justify-content: space-between; gap: 10px; }
.kpi .delta { align-self: flex-start; }
.spark-box { flex: 1; min-height: 32px; max-height: 120px; }
.spark-box .spark { display: block; width: 100%; height: 100%; }

/* comparison control */
.slider { min-width: 230px; }
.slider input[type=range] { width: 100%; accent-color: var(--ink); margin: 6px 0 2px; }
.slider #cmp-n-label { color: var(--text); font-weight: 600; }
.ticks { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.ticks .on { color: var(--text); font-weight: 600; }
.select select:disabled { opacity: .5; }
.cmp-summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 18px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; font-size: 13px; }
.cmp-summary b { font-weight: 600; }

/* SQL editor (Data team) */
.sql-link { margin-top: 14px; border-top: 1px solid var(--border); border-radius: 0 0 8px 8px; padding-top: 12px; gap: 8px; justify-content: flex-start; }
.sql-link .badge { margin-left: auto; }
.sql-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; align-items: start; }
.sql-status { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.badge.edited { background: #fff4e0; color: #8a5300; }
.sql-input { width: 100%; min-height: 420px; font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text); background: #fbfbfa; border: 1px solid var(--border); border-radius: 8px; padding: 12px; resize: vertical; tab-size: 2; }
.sql-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.sql-actions .note { flex: 1; min-width: 200px; font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.sql-result { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px; }
.sql-result h3 { margin: 0 0 8px; font-size: 14px; }
.sql-result h4 { margin: 16px 0 6px; font-size: 13px; }
.result-table { max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.result-table table { font-size: 12px; font-variant-numeric: tabular-nums; }
.result-table th, .result-table td { white-space: nowrap; padding: 6px 10px; }
.sql-history h3 { margin: 0 0 10px; font-size: 14px; }
.sql-history ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.sql-history li { padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.sql-history li:last-child { border-bottom: 0; }
.sql-history form { margin-top: 6px; }
code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
@media (max-width: 1100px) { .sql-layout { grid-template-columns: 1fr; } }

/* Data team: SQL buttons + panel */
.sql-btn { font: 600 10.5px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 6px; cursor: pointer; white-space: nowrap; }
.sql-btn:hover { color: var(--accent); border-color: var(--accent); }
.card.has-sql { position: relative; }
.card.has-sql > .sql-btn { position: absolute; top: 12px; right: 12px; }
.grid .rowhead .sql-btn { margin-left: 8px; padding: 2px 5px; font-size: 9.5px; opacity: 0; }
.grid tr:hover .rowhead .sql-btn { opacity: 1; }
.sql-panel { width: min(760px, 94vw); max-height: 86vh; border: 1px solid var(--border); border-radius: 14px; padding: 0;
  box-shadow: 0 20px 60px rgba(23, 26, 43, .25); }
.sql-panel::backdrop { background: rgba(23, 26, 43, .35); }
.sql-panel > header { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; background: var(--surface); border-bottom: 1px solid var(--border); }
.sql-panel h3 { margin: 0; font-size: 15px; }
#sql-panel-body { padding: 6px 18px 18px; }
.sql-sec h4 { margin: 16px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sql-metric { padding: 6px 0; border-bottom: 1px solid var(--border); }
.sql-metric-name { font-weight: 600; font-size: 13px; }
.sql-item { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; overflow: hidden; }
.sql-item-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; background: var(--surface-2); }
.sql-item-name { font-weight: 600; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.sql-code { margin: 0; padding: 10px 12px; font: 11.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap;
  word-break: break-word; background: #fbfbfa; max-height: 220px; overflow: auto; }

.sql-layout.three { grid-template-columns: 260px minmax(0, 1fr) 260px; }
.sql-list { padding: 12px; max-height: calc(100vh - 160px); overflow: auto; position: sticky; top: 72px; }
.sql-list input { width: 100%; font: inherit; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; }
.sql-group-name { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 10px 4px 4px; }
.sql-entry { display: flex; justify-content: space-between; gap: 6px; padding: 6px 8px; border-radius: 6px; font-size: 13px; }
.sql-entry:hover { background: var(--surface-2); }
.sql-entry.active { background: color-mix(in srgb, var(--accent) 12%, white); color: var(--accent); font-weight: 500; }
.sql-title { font-size: 16px; margin: 0 0 6px; }
.sql-input.short { min-height: 160px; white-space: pre-wrap; }
@media (max-width: 1280px) { .sql-layout.three { grid-template-columns: 220px minmax(0, 1fr); } .sql-layout.three .sql-history { grid-column: 2; } }
@media (max-width: 900px) { .sql-layout.three { grid-template-columns: 1fr; } .sql-layout.three .sql-history { grid-column: auto; } .sql-list { position: static; max-height: 260px; } }

/* ======================================================================
   Theme: clinic MIS. Paper + lagoon ink, marigold for "now", grotesque figures.
   Overrides the earlier base tokens; one bold surface (the GMV panel).
   ====================================================================== */
:root {
  --bg: #F6F8F7;
  --surface: #FFFFFF;
  --surface-2: #EEF3F1;
  --border: #DCE3E1;
  --text: #132625;
  --muted: #5C6B6A;
  --accent: #0E6E6B;
  --ink: #123B3A;
  --marigold: #E9A23B;
  --good: #1F7A3F;
  --bad: #B4372F;
  --repeat: #D6DEDB;
  --section: #EEF3F1;
  --mtd: #FDF4E4;
  --radius: 10px;
  --shadow: none;
  --display: "Bricolage Grotesque", "Instrument Sans", system-ui, sans-serif;
}
body { font-family: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 14px; }
h1 { font-family: var(--display); font-size: 28px; font-weight: 650; letter-spacing: -0.02em; }
.icon { flex: none; vertical-align: -0.15em; }
.ic { display: inline-flex; line-height: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* top bar + brand */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { font-family: var(--display); font-size: 16px; letter-spacing: -0.01em; }
.brand-mark { background: var(--ink); border-radius: 7px; font-family: var(--display); }
.navlink { gap: 6px; }

/* sidebar: icon + label rows, marigold rule marks the open page */
.sidebar { background: var(--surface); }
.pagelink { justify-content: flex-start; gap: 10px; padding: 8px 10px; color: var(--text); position: relative; }
.pagelink .icon { color: var(--muted); }
.pagelink .badge { margin-left: auto; }
.pagelink.active { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.pagelink.active .icon { color: var(--ink); }
.pagelink.active::before { content: ""; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--marigold); }
.pagelink.soon { color: var(--muted); }
.badge { text-transform: none; letter-spacing: 0; font-size: 11px; background: var(--surface-2); color: var(--muted); }
.sidebar-title { font-family: var(--display); font-size: 15px; }
.tile-icon { color: var(--ink); background: var(--surface-2); }

/* cards: flat, hairline, no shadow; hierarchy comes from type, not boxes */
.card, .tile, .table-wrap, .empty, .login-card { box-shadow: none; border-color: var(--border); border-radius: var(--radius); }
.card-head h3 { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-size: 15.5px; font-weight: 600; letter-spacing: -0.01em; }
.card-head h3 .icon { color: var(--accent); }
.section-title { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-size: 18px; font-weight: 600; margin: 14px 0 12px; }
.section-title .icon { color: var(--accent); }
.select > span { display: inline-flex; align-items: center; gap: 5px; }
.select .icon { color: var(--muted); }
.btn { border-radius: 8px; }
.btn.primary { background: var(--ink); border-color: var(--ink); }
.btn .icon { color: inherit; }
.tile:hover { border-color: var(--accent); transform: none; }
.tile-name, .funnel-value, .svc-value { font-family: var(--display); letter-spacing: -0.015em; }

/* comparison bar + controls */
.cmp-summary { background: transparent; border: 0; border-left: 3px solid var(--marigold); border-radius: 0; padding: 4px 12px; }
.segmented button.active { color: var(--ink); }
.slider input[type=range] { accent-color: var(--ink); }
.viewtab.active { color: var(--ink); }

/* the one bold surface: GMV headline panel */
.card.hero { background: var(--ink); border-color: var(--ink); color: #fff; }
.hero .card-label, .hero .muted, .hero .hero-pace, .hero .hero-facts dt, .hero .split-legend { color: rgba(255,255,255,0.72); }
.hero .hero-value { font-family: var(--display); font-size: 52px; font-weight: 700; letter-spacing: -0.03em; color: #fff; }
.hero .hero-facts { border-top-color: rgba(255,255,255,0.16); }
.hero .hero-facts dd, .hero .split-legend b { color: #fff; }
.hero .split-bar { background: rgba(255,255,255,0.18); }
.hero .split-bar span { background: var(--marigold); border-right-color: var(--ink); }
.hero .key { background: var(--k); }
.hero .delta.up { color: #BFF0CF; background: rgba(31,122,63,0.35); }
.hero .delta.down { color: #FFD3CF; background: rgba(180,55,47,0.38); }
.hero .delta.flat { color: rgba(255,255,255,0.8); background: rgba(255,255,255,0.12); }
.hero .sql-btn { background: transparent; color: rgba(255,255,255,0.75); border-color: rgba(255,255,255,0.28); }
.hero .sql-btn:hover { color: #fff; border-color: #fff; }

/* KPI tiles */
.kpi .card-label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.kpi .card-label .ic { color: var(--accent); }
.kpi .kpi-value { font-family: var(--display); font-size: 28px; font-weight: 650; letter-spacing: -0.02em; color: var(--text); }
.spark-line { stroke: #9FB0AD; }

/* change chips with trend icons */
.delta { gap: 4px; padding: 3px 8px; font-size: 12px; }
.delta .icon { width: 13px; height: 13px; }
.delta.up { color: var(--good); background: #E6F2EA; }
.delta.down { color: var(--bad); background: #F8E7E5; }

/* service cards: colour lives in the icon badge, not the text */
.svc-icon { width: 26px; height: 26px; border-radius: 7px; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--k) 14%, white); color: color-mix(in srgb, var(--k) 70%, black); }
.svc-icon .icon { width: 15px; height: 15px; }
.svc-name { gap: 10px; font-family: var(--display); font-weight: 600; }

/* funnel */
.funnel-step { background: var(--surface-2); }
.funnel-link .arrow { color: var(--marigold); }

/* metrics table */
.grid thead th, .grid thead .rowhead { background: var(--surface-2); }
.grid tr.section .rowhead, .grid tr.section td { text-transform: none; letter-spacing: 0; font-size: 12.5px; color: var(--ink); background: var(--section); }
.grid .col-mtd { background: var(--mtd); }
.grid thead .col-mtd { background: #FBE7C2; }
.grid td { font-variant-numeric: tabular-nums; }

/* SQL bits: sentence case, quieter */
.sql-btn { display: inline-flex; align-items: center; gap: 4px; font-family: "Instrument Sans", system-ui, sans-serif; font-size: 11.5px; font-weight: 600; }
.sql-btn .icon { width: 13px; height: 13px; }
.sql-group-name, .sql-sec h4 { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 600; color: var(--muted); }
.sql-link { color: var(--ink); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Brand: Hoola Health purple (from the logo), marigold stays the "now" highlight */
:root {
  --bg: #F7F6FA;
  --surface-2: #F0EEF6;
  --border: #E2DFEC;
  --text: #1E1A2E;
  --muted: #635E75;
  --accent: #5E4B9C;
  --ink: #33265F;
  --repeat: #DCD8E6;
  --section: #F0EEF6;
}
.brand-word { font-family: "Baloo 2", var(--display); font-weight: 800; font-size: 21px; letter-spacing: -0.01em; color: var(--accent); line-height: 1; }
.brand-word small { font-size: 15px; font-weight: 700; margin-left: 2px; }
.brand-sep { width: 1px; height: 20px; background: var(--border); }
.brand-app { font-family: var(--display); font-weight: 600; font-size: 15px; color: var(--text); }
.login-word { font-size: 34px; display: block; margin-bottom: 14px; }
.spark-line { stroke: #B3ADC6; }
.hero .split-bar span { border-right-color: var(--ink); }
.delta.up { background: #E6F2EA; }

/* Type: one family, Plus Jakarta Sans (friendly, clear numerals); weight and size carry hierarchy */
:root { --display: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif; }
body, .sql-btn, button, input, select, textarea:not(.sql-input) { font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif; }
h1 { font-weight: 700; letter-spacing: -0.02em; }
.hero .hero-value { font-weight: 800; letter-spacing: -0.035em; }
.kpi .kpi-value, .funnel-value, .svc-value { font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.card-head h3, .section-title, .svc-name, .sidebar-title, .tile-name, .brand-app { font-weight: 700; letter-spacing: -0.01em; }
.card-label, .muted { letter-spacing: 0; }

/* comparison value next to every change chip */
.cmp { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cmp-was { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.hero .cmp-was { color: rgba(255,255,255,0.72); }
.hero-delta { gap: 8px; }
.kpi .kpi-foot .cmp { align-self: flex-start; }

/* funnel: narrowing stages on the left, labels + rates beside them, costs on the right */
.funnel { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(220px, 1fr); gap: 28px; align-items: center; flex-direction: initial; }
.fn { display: grid; grid-template-columns: minmax(180px, 1.1fr) minmax(0, 1fr); gap: 0 20px; }
.fn-shape { display: grid; grid-template-rows: repeat(3, 76px); gap: 4px; }
.fn-seg { display: flex; align-items: center; justify-content: center; }
.fn-val { color: #fff; font-weight: 700; font-size: 19px; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.fn-rows { display: grid; grid-template-rows: repeat(3, 76px); gap: 4px; }
.fn-row { display: flex; flex-direction: column; justify-content: center; gap: 4px; border-bottom: 1px dashed var(--border); }
.fn-row:last-child { border-bottom: 0; }
.fn-label { font-weight: 700; font-size: 14px; }
.fn-rate { font-size: 12.5px; color: var(--text); }
.fn-rate b { color: var(--accent); }
.fn-costs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-left: 24px; border-left: 1px solid var(--border); }
.fn-cost { display: flex; flex-direction: column; gap: 4px; }
.fn-cost-val { font-size: 20px; font-weight: 700; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }

/* momentum: value, comparison value, change; the slider's column is highlighted */
.mvals { display: flex; flex-direction: column; gap: 1px; }
.mwas { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.momentum th.on, .momentum td.on { background: #FBF3E3; }
.momentum thead th.on { box-shadow: inset 0 3px 0 var(--marigold); }

@media (max-width: 1100px) {
  .funnel { grid-template-columns: 1fr; }
  .fn-costs { padding-left: 0; border-left: 0; border-top: 1px solid var(--border); padding-top: 16px; grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 640px) {
  .fn { grid-template-columns: 1fr 1fr; }
  .fn-costs { grid-template-columns: 1fr 1fr; }
}

/* brand logo: top bar shows the "hoola health" lettering (top 61% of the artwork); sign-in shows all of it */
.brand-logo { display: block; width: 116px; aspect-ratio: 1280 / 236; overflow: hidden; }
.brand-logo img { display: block; width: 100%; height: auto; }
.login-logo { display: block; width: 220px; height: auto; margin: 0 auto 18px; }

/* mini bar charts on cards (periods on screen) */
.minibars { display: block; width: 100%; height: 100%; overflow: visible; }
.minibars .mb-val { font-size: 9.5px; font-weight: 600; fill: var(--muted); }
.minibars .mb-val.on { fill: var(--text); }
.minibars .mb-lab { font-size: 9.5px; fill: var(--muted); }
.minibars rect { cursor: default; }
.svc-bars { height: 52px; }
.momentum th, .momentum td { min-width: 130px; }

.spark-box { min-height: 64px; }

/* combo charts carry value labels: give them room */
.chart { height: 300px; }
.chart.tall { height: 340px; }
.chart.short { height: 260px; }

.hero .hero-facts.four { grid-template-columns: 1fr 1fr; row-gap: 12px; margin-top: 14px; }
.hero .hero-facts dd { font-size: 17px; }
.hero { overflow: hidden; }

.sheet-refresh { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.sheet-refresh .btn { gap: 6px; }

/* eight service lines: four across */
.services { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1280px) { .services { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .services { grid-template-columns: 1fr; } }
