/* ---- colors: light by default, dark from the system or the toggle ---- */

:root {
  --bg: #fafafa; --side: #f5f5f5; --panel: #ffffff; --panel2: #fafafa;
  --border: #e5e5e5; --soft: #efefef; --grid: #e5e5e5;
  --text: #171717; --muted: #525252; --faint: #6b6b6b;
  --hover: #f7f7f7; --sel: #ebebeb;
  --s1: #2563eb; --s2: #93b4f4; --bar: rgba(37, 99, 235, 0.07);
  --good: #15803d; --bad: #dc2626; --warn: #b45309;
  --shadow: rgba(0, 0, 0, 0.08); --overlay: rgba(0, 0, 0, 0.32);
  --invert-bg: #171717; --invert-text: #fafafa;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0a; --side: #0a0a0a; --panel: #111111; --panel2: #161616;
    --border: #262626; --soft: #1c1c1c; --grid: #262626;
    --text: #ededed; --muted: #a3a3a3; --faint: #8f8f8f;
    --hover: #171717; --sel: #1f1f1f;
    --s1: #4b8df8; --s2: #a3c4ff; --bar: rgba(75, 141, 248, 0.09);
    --good: #3fb950; --bad: #f2555a; --warn: #e3a33b;
    --shadow: rgba(0, 0, 0, 0.5); --overlay: rgba(0, 0, 0, 0.6);
    --invert-bg: #ededed; --invert-text: #0a0a0a;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0a0a0a; --side: #0a0a0a; --panel: #111111; --panel2: #161616;
  --border: #262626; --soft: #1c1c1c; --grid: #262626;
  --text: #ededed; --muted: #a3a3a3; --faint: #8f8f8f;
  --hover: #171717; --sel: #1f1f1f;
  --s1: #4b8df8; --s2: #a3c4ff; --bar: rgba(75, 141, 248, 0.09);
  --good: #3fb950; --bad: #f2555a; --warn: #e3a33b;
  --shadow: rgba(0, 0, 0, 0.5); --overlay: rgba(0, 0, 0, 0.6);
  --invert-bg: #ededed; --invert-text: #0a0a0a;
  color-scheme: dark;
}

/* ---- base ---- */

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
a { color: var(--s1); }
:focus-visible { outline: 2px solid var(--s1); outline-offset: 2px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.hidden { display: none !important; }

/* ---- layout ---- */

.layout { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side {
  flex: 1 1 232px;
  background: var(--side);
  border-right: 1px solid var(--border);
  padding: 24px 14px;
  display: flex; flex-direction: column; gap: 28px;
}
.main {
  flex: 999 1 640px; min-width: 0;
  padding: 36px 40px 56px;
  display: flex; flex-direction: column; gap: 28px;
}
@media (max-width: 900px) {
  .side { border-right: 0; border-bottom: 1px solid var(--border); padding: 16px 12px; gap: 16px; }
  .side .spacer { display: none; }
  .main { padding: 24px 16px 48px; }
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px; font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 0 10px 8px; font-size: 11px; font-weight: 500; color: var(--faint); text-transform: uppercase; letter-spacing: 0.08em; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; min-height: 36px; padding: 0 10px;
  border: 0; border-radius: 6px; background: transparent;
  color: var(--muted); font-size: 13.5px; text-align: left;
}
.nav-item:hover { background: var(--hover); }
.nav-item[aria-current="page"] { background: var(--sel); color: var(--text); font-weight: 500; }
.nav-count { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.nav-add { justify-content: flex-start; margin-top: 6px; }
.spacer { flex: 1 1 auto; }

.account { display: flex; align-items: center; gap: 10px; padding: 14px 10px 0; border-top: 1px solid var(--border); }
.avatar {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%;
  background: var(--sel); color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
}
.account-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.account-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-role { font-size: 12px; color: var(--faint); }

/* ---- header and toolbar ---- */

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.page-title { font-size: 24px; font-weight: 500; letter-spacing: -0.02em; }
.page-sub { margin-top: 6px; font-size: 13px; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-top: -8px; }
.toolbar-right { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.tabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel); }
.tab {
  min-height: 32px; padding: 0 14px;
  border: 1px solid transparent; border-radius: 6px; background: transparent;
  color: var(--muted); font-size: 13px; font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { border-color: var(--border); background: var(--sel); color: var(--text); }

/* ---- controls ---- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 36px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel); color: var(--text);
  font-size: 13px; font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--invert-bg); border-color: var(--invert-bg); color: var(--invert-text); }
.btn-primary:hover { background: var(--invert-bg); opacity: 0.88; }
.btn-danger { color: var(--bad); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-small { min-height: 30px; padding: 0 10px; font-size: 12.5px; }
.icon-btn { width: 36px; padding: 0; }

.select { position: relative; display: inline-flex; align-items: center; }
.select select {
  appearance: none; -webkit-appearance: none;
  min-height: 36px; padding: 0 34px 0 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel); color: var(--text); font-size: 13px; font-weight: 500;
}
.select::after {
  content: ""; position: absolute; right: 13px; top: 50%;
  width: 6px; height: 6px;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}

.field { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--muted); }
.input {
  min-height: 38px; padding: 0 12px; width: 100%;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel2); color: var(--text); font-size: 14px;
}
.input.mono { font-size: 12.5px; }
.input:focus { border-color: var(--s1); outline: none; box-shadow: 0 0 0 3px var(--bar); }
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1 1 auto; min-width: 0; }

/* ---- cards and tables ---- */

.stack { display: flex; flex-direction: column; gap: 20px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; min-width: 0; }
.card-head {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px;
  min-height: 52px; padding: 10px 20px; border-bottom: 1px solid var(--soft);
}
.card-title { font-size: 15px; font-weight: 500; }
.card-note { font-size: 12px; color: var(--faint); }
.card-body { padding: 20px; }
.card-body > p { font-size: 13px; color: var(--muted); max-width: 640px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
@media (max-width: 420px) { .kpi { padding: 14px 16px 16px; } .kpi-value { font-size: 24px; } }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px 20px; min-width: 0; }
.kpi-label { font-size: 13px; color: var(--muted); }
.kpi-value { margin-top: 8px; font-size: 28px; font-weight: 500; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-note { margin-top: 4px; font-size: 12px; color: var(--faint); }

.table-wrap { overflow-x: auto; }
.table { min-width: 1000px; padding-bottom: 6px; }
.t-row {
  display: grid; gap: 14px; align-items: center;
  grid-template-columns: 76px minmax(0, 1.6fr) 72px 56px 64px minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1fr) 64px;
  padding: 10px 20px; border-bottom: 1px solid var(--soft); font-size: 13px;
}
.table.with-site .t-row { grid-template-columns: 76px 100px minmax(0, 1.6fr) 72px 56px 64px minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1fr) 64px; }
.t-row:hover:not(.t-head) { background: var(--hover); }
.t-head { font-size: 12px; color: var(--faint); }
.t-row > span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-right { text-align: right; }
.t-bot { color: var(--faint); }
.status-ok { color: var(--muted); }
.status-warn { color: var(--warn); }
.status-bad { color: var(--bad); }

.empty { padding: 48px 20px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.empty-title { font-size: 15px; font-weight: 500; color: var(--text); }

/* ---- settings ---- */

.settings { max-width: 920px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 18px 20px; }

.setting-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--soft); }
.setting-row:last-child { border-bottom: 0; }
.setting-text { display: flex; flex-direction: column; gap: 4px; max-width: 560px; }
.setting-name { font-size: 14px; }
.setting-desc { font-size: 13px; color: var(--muted); }

.code {
  margin: 14px 0 0; padding: 16px 18px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--panel2);
  font: 12.5px/1.7 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  overflow-x: auto; white-space: pre;
}

/* ---- dialog ---- */

dialog {
  width: min(520px, calc(100vw - 32px)); padding: 0;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--panel); color: var(--text);
  box-shadow: 0 24px 64px var(--shadow);
}
dialog::backdrop { background: var(--overlay); }
.dialog-head { padding: 18px 22px 0; font-size: 16px; font-weight: 500; }
.dialog-body { padding: 16px 22px; display: flex; flex-direction: column; gap: 16px; }
.dialog-body > p { font-size: 13px; color: var(--muted); }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 22px 20px; }

/* ---- login ---- */

.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login {
  width: min(380px, 100%); padding: 36px 32px 32px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center;
}
.login h1 { font-size: 22px; font-weight: 500; letter-spacing: -0.02em; }
.login p { font-size: 13px; color: var(--muted); }
.login .btn { width: 100%; min-height: 42px; font-size: 14px; }
.login-error { min-height: 18px; font-size: 13px; color: var(--bad); }

/* ---- toast ---- */

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 10;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  padding: 10px 16px; border-radius: 8px;
  background: var(--invert-bg); color: var(--invert-text); font-size: 13px;
  transition: opacity 0.18s, transform 0.18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- series colors ---- */

:root { --cat1: #2563eb; --cat2: #0f9f8a; --cat3: #7c5ce6; --cat4: #c9861a; --cat5: #db2777; --cat6: #525252; --gray: #a3a3a3; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --cat1: #4b8df8; --cat2: #36b3a0; --cat3: #a78bfa; --cat4: #e3a33b; --cat5: #f472b6; --cat6: #a3a3a3; --gray: #8f8f8f; }
}
:root[data-theme="dark"] { --cat1: #4b8df8; --cat2: #36b3a0; --cat3: #a78bfa; --cat4: #e3a33b; --cat5: #f472b6; --cat6: #a3a3a3; --gray: #8f8f8f; }

[hidden] { display: none !important; }

/* ---- number cards ---- */

.kpi { display: flex; flex-direction: column; padding: 0; overflow: hidden; text-align: left; color: var(--text); }
.kpi-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 18px 20px 0; }
.kpi .kpi-value { margin: 0; padding: 8px 20px 0; }
.kpi-btn { font: inherit; cursor: pointer; }
.kpi-btn:hover { border-color: var(--faint); }
.kpi-btn[aria-pressed="true"] { border-color: var(--s1); }
.spark { display: block; width: 100%; height: 40px; margin-top: 14px; }
.delta { font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }
@media (max-width: 420px) { .kpi-top { padding: 14px 16px 0; } .kpi .kpi-value { padding: 6px 16px 0; } }

/* ---- charts ---- */

.chart-body { padding: 20px 24px 18px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-bottom: 20px; font-size: 13px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 8px; }
.legend-item b { color: var(--text); font-weight: 500; }
.swatch { display: inline-block; flex-shrink: 0; width: 8px; height: 8px; border-radius: 2px; }
.plot { position: relative; margin-left: 56px; }
.tick { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--grid); }
.tick-zero { border-top-style: solid; }
.tick span { position: absolute; right: calc(100% + 12px); top: -8px; font-size: 11px; color: var(--faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.plot-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.line { fill: none; stroke-width: 1.75px; stroke-linejoin: round; stroke-linecap: round; }
.area { fill-opacity: 0.1; stroke: none; }
.hover-line { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--faint); opacity: 0.6; pointer-events: none; }
.hover-dot { position: absolute; width: 8px; height: 8px; margin: 0 0 -4px -4px; border-radius: 50%; box-shadow: 0 0 0 2px var(--panel); pointer-events: none; }
.tip {
  position: absolute; top: 0; z-index: 2; min-width: 190px; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px var(--shadow);
  display: flex; flex-direction: column; gap: 6px; pointer-events: none;
}
.tip-title { font-size: 12px; color: var(--muted); white-space: nowrap; }
.tip-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; font-size: 13px; white-space: nowrap; }
.tip-row > span { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.tip-row b { font-weight: 500; }
.overlay { position: absolute; inset: 0; cursor: crosshair; touch-action: pan-y; }
.xaxis { position: relative; height: 18px; margin: 12px 0 0 56px; }
.xaxis span { position: absolute; top: 0; font-size: 11px; color: var(--faint); white-space: nowrap; }
@media (max-width: 600px) { .chart-body { padding: 16px 16px 14px; } .plot, .xaxis { margin-left: 44px; } }

/* ---- grids and ranked tables ---- */

.grid-wide { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(440px, 100%), 1fr)); gap: 20px; }
.grid-small { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 20px; }
.grid-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(460px, 100%), 1fr)); gap: 20px; }
.dt { padding-bottom: 6px; overflow-x: auto; }
.dt-row {
  position: relative; display: grid; grid-template-columns: var(--cols); gap: 12px; align-items: center;
  min-width: var(--min); padding: 10px 20px; border-bottom: 1px solid var(--soft); font-size: 13px;
}
.dt-row:last-child { border-bottom: 0; }
.dt-row:not(.dt-head):hover { background: var(--hover); }
.dt-head { font-size: 12px; color: var(--faint); }
.dt-bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--bar); pointer-events: none; }
.dt-row > span:not(.dt-bar) { position: relative; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc { display: inline-block; width: 22px; margin-right: 8px; font: 11px ui-monospace, "SF Mono", Menlo, monospace; color: var(--faint); }
.method { display: inline-block; width: 42px; font: 11px ui-monospace, "SF Mono", Menlo, monospace; color: var(--faint); }
.small-text { font-size: 12px; }
.empty.small { padding: 28px 20px; font-size: 13px; }

/* ---- header extras ---- */

.live { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.live b { color: var(--text); font-weight: 500; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.select-icon svg { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.select-icon select { padding-left: 34px; }
.select-small select { min-height: 32px; font-weight: 400; }
.inline-field { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.is-loading { opacity: 0.55; transition: opacity 0.15s; }
.kpis-5 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.line-open { stroke-dasharray: 4 4; opacity: 0.7; }
.kpi-top { flex-wrap: wrap; row-gap: 2px; }

/* ---- paths ---- */

.kpis-3 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.kpi-plain { padding: 18px 20px 20px; gap: 8px; }
.kpi-plain .kpi-value { padding: 0; }
.entry-pick { display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.entry-list { display: flex; flex-wrap: wrap; gap: 8px; }
.entry {
  display: inline-flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--panel); font-size: 13px;
}
.entry:hover { background: var(--hover); }
.entry[aria-pressed="true"] { border-color: var(--s1); }
.flow-wrap { overflow-x: auto; }
.flow { display: grid; grid-template-columns: repeat(4, minmax(200px, 1fr)); gap: 20px; min-width: 880px; padding: 20px 24px 24px; }
.flow-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.flow-head { display: flex; justify-content: space-between; gap: 8px; padding-bottom: 4px; font-size: 12px; font-weight: 500; color: var(--muted); }
.flow-head .num { font-weight: 400; color: var(--faint); }
.flow-node { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel2); min-width: 0; }
.flow-node-muted { color: var(--muted); }
.flow-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; min-width: 0; }
.flow-top > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flow-top b { font-weight: 500; font-size: 13px; }
.flow-bar { display: block; height: 3px; border-radius: 2px; background: var(--soft); overflow: hidden; }
.flow-bar > span { display: block; height: 100%; background: var(--s1); }
.flow-node-muted .flow-bar > span { background: var(--gray); }
.flow-sub { font-size: 12px; color: var(--faint); }
.flow-exit { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px dashed var(--border); border-radius: 8px; font-size: 13px; color: var(--muted); }
.scroll { display: inline-flex; align-items: center; justify-content: flex-end; gap: 8px; }
.scroll-bar { display: inline-block; width: 44px; height: 3px; border-radius: 2px; background: var(--soft); overflow: hidden; }
.scroll-bar > span { display: block; height: 100%; background: var(--s1); }
.visit { display: flex; flex-direction: column; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--soft); }
.visit:last-child { border-bottom: 0; }
.visit-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: 12px; color: var(--faint); }
.visit-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; }
.step { display: inline-flex; align-items: baseline; gap: 8px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel2); }
.step .mono { font-size: 12px; }
.chevron { color: var(--faint); flex-shrink: 0; }

/* ---- account ---- */

.person { display: inline-flex; align-items: center; gap: 10px; }
.person .avatar { width: 28px; height: 28px; font-size: 10.5px; }
.dt-row > .row-actions { display: flex; justify-content: flex-end; overflow: visible; }
.fieldset { margin: 0; padding: 0; border: 0; gap: 10px; }
.fieldset legend { padding: 0; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.fieldset[disabled] { opacity: 0.6; }
.choice { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 14px; cursor: pointer; }
.choice > span { display: flex; flex-direction: column; gap: 2px; }
.choice b { font-weight: 500; }
.choice .muted { font-size: 13px; }
.choice input { margin: 3px 0 0; accent-color: var(--s1); }
.choice-inline { padding: 8px 12px; }
.choice:has(input:checked) { border-color: var(--s1); }

/* ---- consent ---- */

.consent-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; border-bottom: 1px solid var(--soft); }
.consent-stat { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; border-right: 1px solid var(--soft); min-width: 0; }
.consent-stat:last-child { border-right: 0; }
.consent-stat .kpi-label { display: inline-flex; align-items: center; gap: 8px; }
.consent-stat .kpi-value { margin: 0; padding: 0; }
.consent-num { font-size: 18px; }
.consent-num b { font-weight: 500; }
.consent-num .faint { font-size: 13px; }

/* ---- the sidebar stays in place while the page scrolls ---- */

@media (min-width: 901px) {
  .side { position: sticky; top: 0; align-self: flex-start; height: 100vh; overflow-y: auto; }
}

/* ---- (i) explanations ---- */

.info {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; margin-left: 6px; vertical-align: -3px;
  border-radius: 50%; color: var(--faint); cursor: help;
}
.info:hover, .info:focus-visible { color: var(--text); }
.info-tip {
  position: fixed; z-index: 50; max-width: min(300px, calc(100vw - 24px));
  padding: 10px 12px; border-radius: 8px;
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  box-shadow: 0 8px 24px var(--shadow);
  font-size: 12.5px; line-height: 1.5; font-weight: 400; letter-spacing: 0; text-transform: none;
  pointer-events: none;
}
.kpi-label .info, .card-title .info, .flow-head .info { margin-left: 4px; }

/* ---- sections, heatmap ---- */

.section-title { margin: 12px 0 -4px; font-size: 13px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.heat-wrap { overflow-x: auto; padding: 20px 24px 22px; }
.heat { display: grid; grid-template-columns: 32px repeat(24, minmax(18px, 1fr)); gap: 3px; min-width: 640px; }
.heat-label { font-size: 11px; color: var(--faint); display: flex; align-items: center; }
.heat-hour { font-size: 10.5px; color: var(--faint); text-align: center; }
.heat-cell { aspect-ratio: 1.6; min-height: 16px; border-radius: 3px; background: var(--soft); position: relative; overflow: hidden; }
.heat-cell > span { position: absolute; inset: 0; background: var(--s1); }
.heat-scale { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 12px; font-size: 11px; color: var(--faint); }
.heat-scale span.bar { width: 80px; height: 8px; border-radius: 3px; background: linear-gradient(to right, var(--soft), var(--s1)); }
.entry-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.toggle input { width: 16px; height: 16px; margin: 0; accent-color: var(--s1); cursor: pointer; }

/* ---- clickable rows, tabs inside cards, filter bar ---- */

.dt-click { cursor: pointer; }
.dt-click:focus-visible { outline: 2px solid var(--s1); outline-offset: -2px; }
.card-tabs { gap: 8px; }
.mini-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.mini-tab {
  min-height: 30px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent;
  color: var(--muted); font-size: 13px; font-weight: 500;
}
.mini-tab:hover { color: var(--text); }
.mini-tab[aria-selected="true"] { background: var(--sel); color: var(--text); }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: -12px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 6px 0 12px;
  border: 1px solid var(--s1); border-radius: 999px; background: var(--bar); font-size: 13px;
}
.chip b { font-weight: 500; }
.chip button { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); }
.chip button:hover { background: var(--sel); color: var(--text); }
.kpis-7 { grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); }

/* ---- goals, funnels, live ---- */

.icon-x { width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent; color: var(--faint); font-size: 16px; }
.icon-x:hover { background: var(--sel); color: var(--bad); }
.funnel { display: flex; flex-direction: column; gap: 14px; padding: 18px 20px 20px; }
.funnel-step { display: flex; flex-direction: column; gap: 6px; }
.funnel-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 13px; }
.funnel-top b { font-weight: 500; }
.funnel-bar { height: 10px; border-radius: 5px; background: var(--soft); overflow: hidden; }
.funnel-bar > span { display: block; height: 100%; background: var(--s1); border-radius: 5px; }
.funnel-lost { font-size: 12px; color: var(--faint); }
.steps { display: flex; flex-direction: column; gap: 8px; }
.step-row { display: grid; grid-template-columns: 22px 110px minmax(0, 1fr); gap: 8px; align-items: center; }
.step-row .select select { width: 100%; }
.feed { overflow-x: auto; padding-bottom: 4px; }
.feed-row {
  display: grid; grid-template-columns: 70px minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 0.8fr);
  gap: 14px; align-items: center; min-width: 760px; padding: 10px 20px; border-bottom: 1px solid var(--soft); font-size: 13px;
}
.feed-row:last-child { border-bottom: 0; }
.feed-row > span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-label .live-dot { display: inline-block; margin-right: 6px; vertical-align: 1px; }

/* ---- card tools: expand, ⋮ menu, tab menus ---- */

.card-tools { display: inline-flex; align-items: center; gap: 2px; margin-left: auto; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px;
  border: 0; border-radius: 6px; background: transparent; color: var(--faint);
}
.icon-btn:hover { background: var(--sel); color: var(--text); }
.mini-tab { display: inline-flex; align-items: center; gap: 5px; }
.mini-tab svg { opacity: 0.7; }
.row-icon { display: inline-flex; vertical-align: -2px; margin-right: 8px; color: var(--faint); }
.dt-label .row-icon svg { display: block; }
.menu {
  position: fixed; z-index: 50; min-width: 200px; max-width: min(320px, calc(100vw - 16px)); padding: 6px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
}
.menu-title { padding: 6px 8px 4px; font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--faint); }
.menu-search { margin-bottom: 2px; }
.menu-list { display: flex; flex-direction: column; max-height: 280px; overflow-y: auto; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 0 10px;
  border: 0; border-radius: 6px; background: transparent; color: var(--text); font-size: 13px; text-align: left;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); outline: none; }
.menu-item[aria-checked="true"] { background: var(--sel); }
.menu-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-check { color: var(--s1); }
.menu-empty { padding: 10px; font-size: 13px; color: var(--faint); }

/* ---- expanded list ---- */

dialog.dialog-wide { width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 48px); }
.expand-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 4px; }
.expand-search { padding: 8px 22px 12px; }
.expand-search .input { width: 100%; }
.expand-body { max-height: calc(100vh - 220px); overflow-y: auto; border-top: 1px solid var(--soft); }
.dt-row[hidden] { display: none; }

/* ---- funnel inside the overview card ---- */

.funnel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 16px 20px 0; font-size: 14px; font-weight: 500; }

/* ---- journey explorer ---- */

.explore { min-height: 200px; }
.explore.is-loading { opacity: 0.6; }
.ex-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; padding: 14px 20px 4px; }
.ex-title { font-size: 14px; font-weight: 500; }
.ex-tools { display: inline-flex; align-items: center; gap: 10px; }
.ex-cols { display: flex; gap: 12px; padding: 12px 20px 20px; overflow-x: auto; }
.ex-col {
  flex: 0 0 260px; display: flex; flex-direction: column; gap: 8px; padding: 10px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--panel2);
}
.ex-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 2px 4px; font-size: 12px; font-weight: 500; color: var(--muted); }
.ex-search { height: 30px; font-size: 12.5px; }
.ex-list { display: flex; flex-direction: column; gap: 2px; max-height: 340px; overflow-y: auto; }
.ex-row {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 32px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent;
  color: var(--text); font-size: 12.5px; text-align: left; overflow: hidden;
}
button.ex-row:hover:not(:disabled) { background: var(--hover); }
.ex-row[hidden] { display: none; }
.ex-row:disabled { cursor: default; }
.ex-row.is-chosen { box-shadow: inset 0 0 0 1px var(--s1); }
.ex-row.is-chosen .ex-bar { background: rgba(75, 141, 248, 0.22); }
.ex-bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--bar); border-radius: 6px; pointer-events: none; }
.ex-label { position: relative; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ex-row > .num { position: relative; flex: none; }
.ex-end { color: var(--muted); }
.menu-sep { height: 1px; margin: 4px 2px; background: var(--border); }
.menu-icon { display: inline-flex; color: var(--faint); }
.menu-sub { color: var(--faint); font-size: 15px; line-height: 1; }
.menu kbd {
  min-width: 22px; padding: 1px 6px; border: 1px solid var(--border); border-radius: 5px;
  font: 11px ui-monospace, "SF Mono", Menlo, monospace; color: var(--faint); text-align: center;
}

/* ---- toolbar: filter, period, more ---- */

.tool-btn { display: inline-flex; align-items: center; gap: 8px; }
.tool-btn svg { color: var(--muted); }
.chip-body { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.chip-body:hover b { text-decoration: underline; text-underline-offset: 3px; }
.chip .chip-body { width: auto; height: auto; border-radius: 0; }
.chip .chip-body:hover { background: transparent; }

/* ---- filter dialog, own period, segments ---- */

.filter-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px; }
.filter-row .select select { width: 100%; }
.suggest { display: flex; flex-direction: column; max-height: 280px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 4px; }
.range-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.segments { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 8px; }
.segment-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 28px; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--soft); }
.segment-row:last-child { border-bottom: 0; }
.segment-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.segment-text > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.segment-save { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 13px; font-weight: 500; }
@media (max-width: 520px) {
  .filter-row, .range-fields { grid-template-columns: 1fr; }
}
