/* ---------- tokens ---------- */
/* Flat, neutral surfaces with hairline borders; green is reserved for status, trends and positive deltas.
   Light is the default; dark follows the OS unless <html data-theme> pins one (see sml.theme in app.js). */
:root {
  --bg: #f6f7f8; --bg-solid: #ffffff; --surface: #ffffff; --surface-2: #f2f3f5; --surface-3: #e9ebee;
  --border: #e6e8eb; --border-strong: #d3d7dc;
  --text: #111418; --text-2: #3f454d; --muted: #6b7280;
  --accent: #159957; --accent-2: #0f7a45; --accent-bg: rgba(21, 153, 87, .1); --accent-bg-2: rgba(21, 153, 87, .22);
  --good: #16a34a; --good-bg: rgba(22, 163, 74, .1); --bad: #dc2626; --bad-bg: rgba(220, 38, 38, .09);
  --primary: #111418; --primary-text: #ffffff;
  --radius: 10px; --radius-s: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-pop: 0 12px 32px -12px rgba(16, 24, 40, .25), 0 1px 2px rgba(16, 24, 40, .06);
  --ring: 0 0 0 3px rgba(21, 153, 87, .2);
  --grad: linear-gradient(135deg, #1fb46a, #0f7a45);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1012; --bg-solid: #131518; --surface: #16181b; --surface-2: #1e2125; --surface-3: #262a2f;
    --border: #25282d; --border-strong: #363a41;
    --text: #e9ebee; --text-2: #b7bcc4; --muted: #7f868f;
    --accent: #34d386; --accent-2: #6ee7a8; --accent-bg: rgba(52, 211, 134, .12); --accent-bg-2: rgba(52, 211, 134, .26);
    --good: #4ade80; --good-bg: rgba(74, 222, 128, .12); --bad: #f87171; --bad-bg: rgba(248, 113, 113, .12);
    --primary: #e9ebee; --primary-text: #111418;
    --shadow: none;
    --shadow-pop: 0 16px 40px -12px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .04);
    --ring: 0 0 0 3px rgba(52, 211, 134, .25);
    --grad: linear-gradient(135deg, #34d386, #1a9a5e);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1012; --bg-solid: #131518; --surface: #16181b; --surface-2: #1e2125; --surface-3: #262a2f;
  --border: #25282d; --border-strong: #363a41;
  --text: #e9ebee; --text-2: #b7bcc4; --muted: #7f868f;
  --accent: #34d386; --accent-2: #6ee7a8; --accent-bg: rgba(52, 211, 134, .12); --accent-bg-2: rgba(52, 211, 134, .26);
  --good: #4ade80; --good-bg: rgba(74, 222, 128, .12); --bad: #f87171; --bad-bg: rgba(248, 113, 113, .12);
  --primary: #e9ebee; --primary-text: #111418;
  --shadow: none;
  --shadow-pop: 0 16px 40px -12px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .04);
  --ring: 0 0 0 3px rgba(52, 211, 134, .25);
  --grad: linear-gradient(135deg, #34d386, #1a9a5e);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 13px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; font-feature-settings: "cv11", "ss01"; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1 { font-size: 16px; font-weight: 600; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 13.5px; font-weight: 600; margin: 0; }
h3 { font-size: 11px; font-weight: 600; margin: 0 0 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
h4 { font-size: 13px; font-weight: 600; margin: 0; }
p { margin: 0 0 10px; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 11.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
pre { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; line-height: 1.55; background: var(--bg-solid); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 12px 14px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; margin: 0 0 12px; }
pre.key { font-size: 14px; letter-spacing: .06em; color: var(--accent-2); }
.muted { color: var(--muted); } .small { font-size: 12px; } .error { color: var(--bad); }
.big { font-size: 26px; font-weight: 600; letter-spacing: -.02em; margin: 10px 0 0; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; font-size: 10px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; border-radius: 4px; padding: 2px 6px; vertical-align: middle; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); line-height: 1.3; white-space: nowrap; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.url { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; word-break: break-all; }
::selection { background: var(--accent-bg-2); }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.topbar { display: none; }
.side-backdrop { display: none; }
.side { width: 228px; flex: none; background: var(--surface); border-right: 1px solid var(--border); padding: 12px 10px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; font-size: 13.5px; letter-spacing: -.01em; padding: 4px 6px 12px; line-height: 1.2; }
.brand:hover { text-decoration: none; }
.brand .mark { width: 26px; height: 26px; border-radius: 7px; background: var(--primary); color: var(--primary-text); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text small { font-size: 11px; font-weight: 400; color: var(--muted); }
.side nav { display: flex; flex-direction: column; gap: 1px; flex: 1; overflow-y: auto; }
.side .section { font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 16px 8px 5px; }
.nav { display: flex; align-items: center; gap: 9px; color: var(--text-2); padding: 6px 8px; border-radius: var(--radius-s); font-weight: 500; min-width: 0; }
.nav > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav svg { width: 15px; height: 15px; flex: none; opacity: .8; }
.nav:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav.active { background: var(--surface-3); color: var(--text); }
.nav.active svg { opacity: 1; }
.nav .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); flex: none; margin: 0 4px; }
.nav .dot.on { background: var(--good); }
.nav.add { color: var(--muted); font-weight: 400; }
.nav.add svg { width: 13px; height: 13px; }
.usage { border: 1px solid var(--border); border-radius: var(--radius-s); padding: 9px 10px; margin: 6px 0 4px; background: var(--bg); }
.usage-row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-2); }
.usage-row code { background: transparent; border: 0; padding: 0; color: var(--text); font-weight: 600; }
.usage-bar { height: 4px; border-radius: 2px; background: var(--surface-3); margin: 8px 0 6px; overflow: hidden; }
.usage-bar i { display: block; height: 100%; background: var(--primary); border-radius: 2px; }
.usage-sub { font-size: 11px; }
.side-foot { border-top: 1px solid var(--border); padding-top: 10px; display: 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: 11px; color: var(--text-2); text-transform: uppercase; flex: none; }
.side-foot .who { min-width: 0; flex: 1; font-size: 12px; line-height: 1.3; }
.side-foot .who span, .side-foot .who small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .who span { font-weight: 500; color: var(--text); }
.side-foot .who small { font-size: 11px; }
.side-foot form { display: contents; }
button.icon { padding: 5px; border: 0; background: transparent; color: var(--muted); border-radius: var(--radius-s); display: grid; place-items: center; line-height: 0; box-shadow: none; }
button.icon:hover { background: var(--surface-2); color: var(--text); }
button.icon svg { width: 15px; height: 15px; }
button.icon .moon { display: none; } button.icon .sun { display: block; }
:root[data-theme="dark"] button.icon .moon { display: block; } :root[data-theme="dark"] button.icon .sun { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) button.icon .moon { display: block; } :root:not([data-theme="light"]) button.icon .sun { display: none; } }
.main { flex: 1; padding: 20px 24px 48px; width: 100%; min-width: 0; }
.center { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }

/* ---------- controls ---------- */
button { font: inherit; font-weight: 500; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-s); padding: 6px 12px; cursor: pointer; line-height: 1.3; transition: background .12s, border-color .12s, box-shadow .12s; box-shadow: var(--shadow); }
button:hover { background: var(--surface-2); }
button:focus-visible { outline: none; box-shadow: var(--ring); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
button.primary:hover { opacity: .9; }
button.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
button.danger:hover { background: var(--bad-bg); }
button.link { background: none; border: none; padding: 0; color: var(--accent-2); font-weight: 500; box-shadow: none; }
button.link:hover { text-decoration: underline; background: none; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg-solid); border: 1px solid var(--border-strong); border-radius: var(--radius-s); padding: 7px 10px; width: 100%; transition: border-color .12s, box-shadow .12s; }
input::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input[type=number] { width: 90px; } input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
label { display: block; margin-bottom: 14px; color: var(--text-2); font-size: 12.5px; font-weight: 500; } label input, label select { margin-top: 6px; }
label .muted { font-weight: 400; }
label.row, .row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; } .row.wrap label { flex: 1 1 200px; }
.periods { display: inline-flex; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-s); padding: 2px; gap: 1px; max-width: 100%; overflow-x: auto; }
.periods button { background: transparent; border: none; padding: 4px 10px; color: var(--muted); border-radius: 4px; font-size: 12.5px; white-space: nowrap; box-shadow: none; }
.periods button:hover { color: var(--text); background: transparent; }
.periods button.on { background: var(--surface-3); color: var(--text); }
select.pill { width: auto; padding: 6px 28px 6px 12px; font-weight: 500; background-color: var(--surface); appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; background-size: 14px; }
.search-box { display: flex; align-items: center; gap: 6px; margin: 0; padding: 0 8px 0 10px; background: var(--bg-solid); border: 1px solid var(--border-strong); border-radius: var(--radius-s); width: 220px; }
.search-box:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.search-box .ico { display: grid; place-items: center; color: var(--muted); line-height: 0; } .search-box .ico svg { width: 14px; height: 14px; }
.search-box input { border: 0; padding: 6px 0; margin: 0; background: transparent; box-shadow: none !important; }
.search-box kbd { font: 11px ui-monospace, Consolas, monospace; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; line-height: 1.5; background: var(--surface-2); }

/* ---------- page head ---------- */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; min-height: 32px; }
.page-head > div:first-child { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head > .row { flex-wrap: wrap; justify-content: flex-end; }
.page-head .count { color: var(--muted); background: transparent; border: 0; padding: 0; font-size: 12px; }
.page-head .tabs { display: flex; gap: 2px; margin-left: 4px; }
.page-head .tabs a { color: var(--muted); padding: 4px 9px; border-radius: var(--radius-s); font-weight: 500; font-size: 12.5px; }
.page-head .tabs a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.page-head .tabs a.active { color: var(--text); background: var(--surface-3); }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 12px; font-weight: 500; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px var(--good-bg); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 3px var(--good-bg); } 50% { box-shadow: 0 0 0 6px transparent; } }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: -6px 0 18px; }
.chip { border-radius: 99px; font-size: 12px; padding: 3px 10px; background: var(--accent-bg); border-color: transparent; color: var(--text); box-shadow: none; }
.chip b { font-weight: 600; margin-left: 4px; color: var(--accent-2); } .chip.clear { background: transparent; border-color: var(--border); color: var(--muted); }

/* ---------- cards & grid ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; min-width: 0; box-shadow: var(--shadow); overflow-wrap: anywhere; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: baseline; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card-head h2 { white-space: nowrap; flex: none; }
.card-head > :last-child:not(h2) { margin-left: auto; }
.card-head h2 + .muted { margin-left: 0; font-size: 12px; }
.card-head h2 + .muted + * { margin-left: auto; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--border); background: var(--bg); font-size: 12.5px; }
.card.site { color: var(--text); display: block; transition: border-color .12s; }
.card.site:hover { border-color: var(--border-strong); text-decoration: none; }
.card.danger { border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.card.plain { background: transparent; border-style: dashed; box-shadow: none; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.span2 { grid-column: span 2; }
.card-tabs { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; min-height: 26px; }
.card-tabs h3, .card-tabs h4 { margin: 0; }
.card-tabs nav { display: flex; gap: 1px; flex-wrap: wrap; align-items: center; background: var(--surface-2); border-radius: var(--radius-s); padding: 2px; }
.card-tabs nav button { background: transparent; border: none; color: var(--muted); padding: 3px 8px; font-size: 12px; border-radius: 4px; box-shadow: none; }
.card-tabs nav button:hover { color: var(--text); background: transparent; }
.card-tabs nav button.on { color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
.card-tabs nav span { padding: 0 6px; }
.empty { padding: 24px 16px; text-align: center; color: var(--muted); }

/* ---------- stat tiles ---------- */
/* One strip: every metric stays visible, each as a small segment with its change on the same line. */
.tiles { display: flex; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0; margin-bottom: 12px; overflow: hidden; }
.tile { flex: 1 1 auto; min-width: 118px; max-width: 210px; position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 3px; background: transparent; border: 0; border-radius: 0; padding: 10px 14px 11px; text-align: left; box-shadow: none; cursor: default; transition: background .12s; }
.tile + .tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 1px; background: var(--border); }
.tile:hover { background: var(--surface-2); }
.tile.on { background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--text); }
.tile-bottom { display: flex; justify-content: flex-start; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.tile-label { color: var(--muted); font-size: 11.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.on .tile-label { color: var(--text); }
.tile-value { font-size: 20px; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile-delta { font-size: 10.5px; font-weight: 600; padding: 1px 5px; border-radius: 4px; white-space: nowrap; }
.tile-delta.up { color: var(--good); background: var(--good-bg); } .tile-delta.down { color: var(--bad); background: var(--bad-bg); }
.tile-sub { font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.tile-sub.good { color: var(--good); } .tile-sub.bad { color: var(--bad); }
.tiles.ov { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tiles.ov .tile { max-width: none; min-width: 0; padding: 14px 18px 15px; }
.tiles.ov .tile-value { font-size: 24px; }
.tiles.ov .tile:hover { background: transparent; }

/* ---------- chart ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .area { fill: url(#chartFill); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart .tip { display: none; pointer-events: none; }
.chart .col:hover .tip { display: block; }
.chart .tip line { stroke: var(--border-strong); }
.chart .tip circle { fill: var(--accent); stroke: var(--surface); stroke-width: 2.5; }
.chart .tip rect { fill: var(--surface-2); stroke: var(--border-strong); }
.chart .tip text { fill: var(--muted); font-size: 11px; } .chart .tip text.strong { fill: var(--text); font-size: 13px; font-weight: 600; }

/* ---------- breakdown tables ---------- */
.bd { width: 100%; border-collapse: collapse; }
.bd th { text-align: left; font-weight: 600; color: var(--muted); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; padding: 0 8px 8px; border-bottom: 1px solid var(--border); }
.bd td { padding: 0 8px; height: 32px; }
.bd .n { text-align: right; width: 58px; font-variant-numeric: tabular-nums; font-weight: 500; }
.bd tbody tr { cursor: pointer; }
.bd tbody tr:hover td { background: var(--surface-2); }
.bd tbody tr:hover .k span { color: var(--text); }
.bd .k { position: relative; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 0; }
.bd .k span { position: relative; }
.bd .bar { position: absolute; inset: 6px auto 6px 0; background: var(--accent-bg); border-radius: 3px; transition: width .25s; }

/* ---------- map ---------- */
.map-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .map-wrap { grid-template-columns: 1fr; } }
.map { position: relative; } .map svg { width: 100%; height: auto; display: block; }
.map path { fill: var(--surface-2); stroke: var(--bg); stroke-width: .6; transition: fill-opacity .2s; }
.map path.has { fill: var(--accent); } .map path:hover { stroke: var(--text); }
.map-tip { display: none; position: absolute; pointer-events: none; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 7px; padding: 5px 9px; font-size: 12px; white-space: nowrap; z-index: 2; box-shadow: var(--shadow); }
.map-legend { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.map-legend li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: 7px; cursor: pointer; }
.map-legend li b { font-variant-numeric: tabular-nums; }
.map-legend li:hover { background: var(--surface-2); } .map-legend li.muted { cursor: default; }

/* ---------- funnels ---------- */
.funnels { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 28px; }
.funnel h4 { margin: 0 0 12px; } .funnel h4 .muted { font-weight: 400; font-size: 12px; }
.funnel ol { list-style: none; margin: 0; padding: 0; } .funnel li { margin-bottom: 12px; }
.funnel-row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.funnel-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.funnel-n { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; } .funnel-n .muted { font-weight: 400; margin-left: 4px; }
.funnel-bar { height: 10px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.funnel-bar div { height: 100%; background: var(--grad); border-radius: 6px; transition: width .3s; }
.funnel-drop { margin-top: 4px; }
.funnel-edit { border-top: 1px solid var(--border); padding: 16px 0 6px; }
.funnel-edit ol { padding-left: 22px; margin: 10px 0 0; } .funnel-edit li { margin-bottom: 8px; }
.funnel-edit li select { width: 200px; } .funnel-edit li input { width: 280px; }
.funnel-edit .row > input { max-width: 320px; }

/* ---------- short links ---------- */
.links { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); gap: 16px; }
.link-card { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 18px; color: var(--text); transition: border-color .12s; }
.link-card > div { min-width: 0; }
.link-card .url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-card .target { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-card:hover { border-color: var(--border-strong); text-decoration: none; }
.link-card img { width: 112px; height: 112px; border-radius: 10px; background: #fff; padding: 6px; }
.link-card h4 { margin: 0 0 4px; font-size: 15px; }
.link-stats { display: flex; gap: 20px; margin: 12px 0 0; flex-wrap: wrap; }
.link-stats b { display: block; font-size: 20px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; } .link-stats span { color: var(--muted); font-size: 11.5px; }
.qr { width: 180px; height: 180px; background: #fff; border-radius: 10px; padding: 8px; flex: none; }

/* ---------- login ---------- */
.login { width: 380px; padding: 32px; }
.login .brand { justify-content: center; padding: 0 0 22px; font-size: 16px; }
.login h2 { text-align: center; font-weight: 500; color: var(--text-2); font-size: 14px; margin-bottom: 22px; }
.login button { width: 100%; }
.login a.sso:hover { text-decoration: none; }
.login button.sso { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px; }
.login button.sso svg { width: 18px; height: 18px; }
.login .or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 18px 0; }
.login .or::before, .login .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.login .error { text-align: center; margin: -8px 0 14px; font-size: 12.5px; }

/* ---------- misc ---------- */
@media (max-width: 900px) {
  .shell { display: block; }
  .topbar { display: flex; align-items: center; gap: 6px; position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 12px; }
  .topbar .brand { padding: 4px 6px; }
  .burger { background: transparent; border: none; padding: 6px; color: var(--text-2); display: grid; place-items: center; box-shadow: none; }
  .burger svg { width: 22px; height: 22px; }
  .side { position: fixed; top: 0; left: 0; bottom: 0; height: 100dvh; z-index: 45; width: min(280px, 85vw); transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow-pop); }
  body.menu-open .side { transform: none; }
  body.menu-open .side-backdrop { display: block; }
  .side-backdrop { position: fixed; inset: 0; z-index: 44; background: rgba(10, 12, 16, .45); }
  .main { padding: 16px 14px 48px; }
  .grid { grid-template-columns: 1fr; } .span2 { grid-column: auto; }
  .tile { min-width: 33.33%; max-width: none; padding: 8px 10px 9px; } .tile-value { font-size: 18px; }
  .page-head { align-items: flex-start; flex-direction: column; margin-bottom: 14px; }
  .search-box { width: 100%; }
  .tiles.ov { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles.ov .tile + .tile::before { display: none; }
  .tiles.ov .tile { border-top: 1px solid var(--border); }
  .tiles.ov .tile:nth-child(-n+2) { border-top: 0; }
  .page-head > .row { width: 100%; justify-content: flex-start; }
  h1 { font-size: 16px; }
  .modal { padding: 16px; border-radius: 10px; } .overlay { padding: 12px; align-items: flex-start; padding-top: 24px; }
  .choices { grid-template-columns: 1fr; }
  .menu { width: calc(100vw - 28px); } .menu-cols { grid-template-columns: 1fr; }
  .daterange { flex-wrap: wrap; } .daterange input { width: 140px; }
  .seg-save { flex-wrap: wrap; } .seg-save input { width: 100%; }
  .err-detail .kv { grid-template-columns: 1fr; gap: 0 } .err-detail .kv span:nth-child(odd) { margin-top: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
  .funnel-edit li select, .funnel-edit li input, .funnel-edit .row > input { width: 100%; max-width: none; }
  .link-card { grid-template-columns: 84px minmax(0, 1fr); gap: 12px; } .link-card img { width: 84px; height: 84px; }
  .link-stats { gap: 14px; } .link-stats b { font-size: 17px; }
  .qr { width: 140px; height: 140px; }
  .bd-detail .toolbar { flex-wrap: wrap; } .bd-detail .toolbar input { flex: 1 1 100%; }
  .utm-builder .out { flex-direction: column; }
  .errs .n { width: 52px; } .errs td { padding: 8px 4px; }
  .ret { font-size: 11px; } .ret td { padding: 4px 4px; }
  table { display: block; max-width: 100%; overflow-x: auto; } table.bd, table.errs { display: table; }
}
@media (max-width: 480px) {
  .tile { min-width: 50%; }
  .page-head .live { display: none; }
  .link-stats > div { flex: 1 1 40%; }
}
#blazor-error-ui { display: none; position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--bad); color: #fff; padding: 10px 20px; border-radius: 10px; z-index: 1000; box-shadow: var(--shadow); }
#blazor-error-ui .dismiss { margin-left: 16px; cursor: pointer; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 12, 16, .5); display: grid; place-items: center; z-index: 50; padding: 24px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { width: 100%; max-width: 480px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow-pop); padding: 20px 22px; animation: rise .18s; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.modal-head h2 { font-size: 17px; letter-spacing: -.01em; }
.modal-head button { padding: 4px 8px; line-height: 1; border: none; background: transparent; color: var(--muted); font-size: 16px; box-shadow: none; }
.modal-head button:hover { color: var(--text); }
.modal > p.muted { margin-bottom: 18px; }
.modal-foot { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 8px; }
.modal-foot .error { margin-right: auto; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 16px; }
.choice { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; text-align: left; padding: 12px 14px; background: var(--bg-solid); border: 1px solid var(--border-strong); border-radius: 10px; }
.choice svg { width: 18px; height: 18px; color: var(--muted); margin-bottom: 4px; }
.choice b { font-weight: 600; } .choice span { color: var(--muted); font-size: 12px; line-height: 1.35; }
.choice.on { border-color: var(--accent); background: var(--accent-bg); } .choice.on svg { color: var(--accent-2); }
.empty-state { text-align: center; padding: 56px 24px; }
.empty-state h2 { margin-bottom: 6px; } .empty-state p { margin-bottom: 18px; }
.page-head .btn-row { display: flex; gap: 10px; }

/* ---------- filter bar & dropdown menus ---------- */
.filterbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: -4px 0 18px; }
.filterbar .chips { margin: 0; display: contents; }
.dd { position: relative; }
.dd > button svg { width: 15px; height: 15px; vertical-align: -3px; margin-right: 6px; }
.dd > button.on { border-color: var(--accent); }
.dd-backdrop { position: fixed; inset: 0; z-index: 40; }
.menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 41; width: 440px; max-width: calc(100vw - 48px); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow-pop); padding: 6px; animation: rise .15s; }
.menu.right { left: auto; right: 0; }
.menu-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
.menu-h { font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 10px 10px 4px; }
.menu-i { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; background: none; border: none; text-align: left; padding: 6px 10px; border-radius: 6px; color: var(--text); font-weight: 450; box-shadow: none; }
.menu-i:hover, .menu-i:focus-visible { background: var(--surface-2); box-shadow: none; }
.menu-i .muted { font-variant-numeric: tabular-nums; font-size: 12px; }
.menu-i span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-sec { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 4px; }
.menu-row { display: flex; align-items: center; }
.menu-row .menu-i { flex: 1; } .menu-row .x { color: var(--muted); padding: 4px 8px; box-shadow: none; }
.menu-row .x:hover { color: var(--bad); }
.menu-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 8px; font-weight: 600; }
.menu-head button { padding: 2px 8px; }
.menu input { margin: 0 0 6px; }
.menu-list { max-height: 320px; overflow: auto; }
.menu .empty { padding: 18px 0; }
.daterange { display: flex; align-items: center; gap: 8px; }
.daterange input { width: 150px; padding: 5px 9px; }
.seg-save { display: flex; gap: 6px; align-items: center; }
.seg-save input { width: 200px; padding: 5px 9px; }

.landing h2 { font-size: 18px; color: var(--text); font-weight: 600; letter-spacing: -.01em; margin-bottom: 8px; }
.landing .lock { display: grid; place-items: center; margin: -6px 0 14px; } .landing .lock svg { width: 34px; height: 34px; color: var(--muted); padding: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.landing > p.muted { text-align: center; margin-bottom: 22px; }
.landing.denied { border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.landing.denied .lock svg { color: var(--bad); background: var(--bad-bg); border-color: transparent; }

/* ---------- user flow ---------- */
.flow { width: 100%; height: auto; display: block; }
.flow .axis { fill: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.flow .link { fill: var(--accent); fill-opacity: .22; stroke: none; transition: fill-opacity .15s; }
.flow .link.exit { fill: var(--bad); fill-opacity: .13; }
.flow .link:hover { fill-opacity: .5; }
.flow .node rect { fill: var(--accent); fill-opacity: .9; stroke: var(--bg-solid); stroke-width: 1; }
.flow .node.other rect { fill: var(--border-strong); fill-opacity: 1; }
.flow .node.exit rect { fill: var(--bad); fill-opacity: .35; }
.flow .label { fill: #fff; font-size: 12px; font-weight: 600; pointer-events: none; }
.flow .label .n { font-weight: 400; font-size: 11px; fill: rgba(255, 255, 255, .8); }
.flow .node.exit .label { fill: var(--text); } .flow .node.exit .label .n { fill: var(--text-2); }
.flow .node.other .label { fill: var(--text); } .flow .node.other .label .n { fill: var(--text-2); }
.card.notice { margin-bottom: 16px; }

/* ---------- full breakdown list ---------- */
.bd-more { padding: 8px 8px 0; font-size: 12.5px; }
.modal.wide { max-width: 820px; }
.bd-detail .toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.bd-detail .toolbar input { flex: 1; }
.bd-detail .scroll { max-height: 60vh; overflow: auto; margin: 0 -8px; padding: 0 8px; }
.bd-detail th { cursor: pointer; user-select: none; white-space: nowrap; position: sticky; top: 0; background: var(--surface); }
.bd-detail th.on { color: var(--text); }
.bd-detail th .arrow { font-size: 9px; margin-left: 3px; }
.utm-builder .out { display: flex; gap: 8px; align-items: flex-start; }
.utm-builder .out pre { flex: 1; margin: 0; }

.chart .line.prev { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; opacity: .7; }
/* ---------- retention ---------- */
.ret { width: 100%; border-collapse: separate; border-spacing: 3px; font-variant-numeric: tabular-nums; }
.ret th { font-weight: 600; color: var(--muted); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; text-align: right; padding: 0 6px 4px; }
.ret th:first-child, .ret td:first-child { text-align: left; white-space: nowrap; }
.ret td { text-align: right; padding: 6px 8px; border-radius: 6px; font-size: 12.5px; }
.ret td.c { color: var(--text); background: color-mix(in srgb, var(--accent) calc(var(--p) * 1%), var(--surface-2)); }
.ret td.c.hi { color: #fff; }
.ret td.none { color: var(--muted); background: var(--surface-2); opacity: .4; }

/* ---------- errors ---------- */
.errs { width: 100%; border-collapse: collapse; }
.errs td { padding: 8px; vertical-align: top; border-top: 1px solid var(--border); }
.errs tr:first-child td { border-top: 0; }
.errs tbody tr { cursor: pointer; } .errs tbody tr:hover td { background: var(--surface-2); }
.errs .msg { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 0; }
.errs .meta { color: var(--muted); font-size: 12px; font-family: ui-monospace, Consolas, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.errs .n { text-align: right; width: 70px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.err-detail pre { max-height: 260px; overflow: auto; font-size: 11.5px; white-space: pre; }
.err-detail .kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; font-size: 13px; margin-bottom: 12px; }
.err-detail .kv span:nth-child(odd) { color: var(--muted); }
.badge.fatal { background: var(--bad-bg); color: var(--bad); border-color: transparent; }

.confirm .code { font-family: ui-monospace, Consolas, monospace; font-size: 18px; letter-spacing: .18em; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 6px; padding: 2px 10px; user-select: all; }
.confirm input { font-family: ui-monospace, Consolas, monospace; letter-spacing: .18em; font-size: 16px; margin-top: 6px; }

/* ---------- goals, campaigns, notes ---------- */
.goals .n, .camp .n { width: 1%; white-space: nowrap; padding-left: 14px; }
.goals tfoot td, .camp tfoot td { border-top: 1px solid var(--border); font-weight: 600; height: 38px; }
.goals tfoot .k span, .camp tfoot .k span { color: var(--muted); font-weight: 500; }
.camp { min-width: 760px; }
.camp .k { cursor: pointer; width: 220px; min-width: 220px; max-width: 220px; }
.camp th:first-child { white-space: nowrap; }
.camp tbody tr { cursor: default; }
.camp input.spend { width: 96px; padding: 4px 8px; text-align: right; font-variant-numeric: tabular-nums; }
.camp input.spend::placeholder { text-align: right; }
.scroll-x { overflow-x: auto; margin: 0 -8px; padding: 0 8px; }
.camp-sum { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; margin: -4px 0 12px; font-size: 12.5px; color: var(--muted); }
.camp-sum b { color: var(--text); font-weight: 600; }
.camp-sum a { margin-left: auto; }
.goal-edit { border-top: 1px solid var(--border); padding: 14px 0 6px; }
.goal-edit .row.wrap label { flex: 1 1 150px; margin-bottom: 10px; }
.goal-edit .row.wrap label input[type=number] { width: 100%; }
.notes { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.note { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; padding: 3px 6px 3px 10px; max-width: 100%; }
.note b { color: var(--accent-2); font-weight: 600; white-space: nowrap; }
.note .x { background: none; border: none; padding: 0 4px; color: var(--muted); font-size: 11px; line-height: 1; box-shadow: none; }
.note .x:hover { color: var(--bad); }
.notes button.link.small { font-size: 12px; }
.chart .ann line { stroke: var(--accent-2); stroke-dasharray: 2 3; pointer-events: none; opacity: .75; }
.chart .ann circle { fill: var(--surface); stroke: var(--accent-2); stroke-width: 2; cursor: help; }
.chart .ann:hover circle { fill: var(--accent-2); }
@media (max-width: 900px) {
  .camp-sum a { margin-left: 0; }
  table.goals { display: table; }
}

/* ---------- sticky toolbar: filters + period ---------- */
/* One row: the filter button and its chips on the left (wrapping only inside their own area), the period switch
   pinned to the right. Glass goes on a pseudo-element: a backdrop-filter on the bar itself would trap the
   filter menu's fixed backdrop inside it. */
.toolbar { position: sticky; top: 8px; z-index: 30; display: flex; align-items: flex-start; gap: 12px; padding: 4px 6px; margin: -2px 0 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
.toolbar-filters { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; flex: 1 1 auto; min-height: 32px; }
.toolbar-filters .dd > button { padding: 5px 11px; font-size: 12.5px; background: transparent; border-color: transparent; box-shadow: none; }
.toolbar-filters .dd > button:hover, .toolbar-filters .dd > button.on { background: var(--surface-2); border-color: var(--border-strong); }
.toolbar-filters .chip { padding: 3px 10px; font-size: 12px; }
.toolbar-period { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; flex: none; margin-left: auto; }
.toolbar .periods { border: 0; background: transparent; padding: 0; gap: 1px; }
.toolbar .periods button { padding: 5px 9px; }
.toolbar .periods button.on, .toolbar .card-tabs-nav button.on { background: var(--surface-3); color: var(--text); box-shadow: none; }
.toolbar .card-tabs-nav { display: flex; gap: 2px; flex-wrap: wrap; }
.toolbar .card-tabs-nav button { background: transparent; border: none; color: var(--muted); padding: 5px 11px; font-size: 12.5px; border-radius: 6px; box-shadow: none; }
.toolbar .card-tabs-nav button:hover { color: var(--text); }
.toolbar .daterange input { width: 132px; padding: 4px 8px; font-size: 12.5px; }
.toolbar .seg-save input { width: 150px; padding: 4px 8px; }
@media (max-width: 900px) { .toolbar { top: 50px; border-radius: 10px; margin: 0 0 14px; flex-wrap: wrap; } .toolbar-period { margin-left: 0; justify-content: flex-start; } }

/* ---------- user flow focus ---------- */
.flow .node.clickable { cursor: pointer; }
.flow .node.clickable:hover rect { fill-opacity: 1; stroke: var(--accent-2); stroke-width: 1.5; }
.flow .node.focused rect { stroke: var(--text); stroke-width: 2; fill-opacity: 1; }

/* ---------- campaign link builder ---------- */
.utm-out { margin-top: 4px; padding: 14px 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius-s); }
.utm-out .utm-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.utm-out pre { margin: 0 0 12px; }
.utm-out pre.muted { color: var(--muted); }

/* ---------- workspace overview (sites list) ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; padding: 8px 16px; border-bottom: 1px solid var(--border); background: var(--bg); white-space: nowrap; }
.tbl td { padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; width: 1%; padding-left: 28px; }
.tbl .trend { width: 140px; padding-left: 20px; } .tbl th.trend { text-align: left; }
.tbl .go { width: 32px; padding: 0 12px 0 0; color: var(--muted); line-height: 0; } .tbl .go svg { width: 14px; height: 14px; }
.tbl td.empty { padding: 24px 16px; }
.rowlink { cursor: pointer; }
.tbl tr.rowlink:hover td { background: var(--surface-2); }
.tbl .src { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ini { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); display: grid; place-items: center; font-size: 11px; font-weight: 600; color: var(--text-2); flex: none; letter-spacing: .02em; }
.src-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.src-name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.src-text .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spark { width: 100%; height: 28px; display: block; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.ov-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; align-items: center; gap: 12px; padding: 9px 16px; border-bottom: 1px solid var(--border); min-width: 0; }
.feed li:last-child { border-bottom: 0; }
.feed li.rowlink:hover { background: var(--surface-2); }
.feed code { background: transparent; border: 0; padding: 0; font-size: 12px; }
.feed .ago { color: var(--muted); width: 56px; flex: none; }
.feed .path, .feed .code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; font-weight: 500; }
.feed .path { flex: 1; }
.feed .code { flex: 0 1 auto; color: var(--text); }
.feed .where { margin-left: auto; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; text-align: right; }
.feed .n { font-variant-numeric: tabular-nums; flex: none; }
@media (max-width: 900px) {
  .ov-grid { grid-template-columns: 1fr; }
  table.tbl { display: table; }
  .tbl .trend, .tbl th.trend, .tbl .total, .tbl th.total, .tbl .go { display: none; }
  .tbl th, .tbl td { padding-left: 12px; padding-right: 12px; }
  .tbl .n { padding-left: 12px; }
  .card-head { flex-wrap: wrap; row-gap: 2px; }
  .card-foot { flex-wrap: wrap; }
  .feed li { gap: 8px; padding: 9px 12px; } .feed .ago { width: 44px; }
}
