@import url("/static/css/fonts.css");

:root {
  --bg: #F3F7FC;
  --bg-elev: #E8F1FA;
  --paper: #FFFFFF;
  --paper-2: #F5F9FF;
  --ink: #0B1C33;
  --ink-soft: #2A3F5C;
  --muted: #5B7190;
  --line: #D7E4F2;
  --line-strong: #C5D6E8;
  --accent: #0077FF;
  --accent-hover: #0066DB;
  --accent-soft: #EAF3FF;
  --accent-ink: #FFFFFF;
  --ok: #047857;
  --ok-soft: #D1FAE5;
  --ok-ink: #065F46;
  --down: #B91C1C;
  --down-soft: #FEE2E2;
  --down-ink: #991B1B;
  --warn: #B45309;
  --warn-soft: #FEF3C7;
  --sidebar: #0B1C33;
  --sidebar-ink: #E8F1FA;
  --sidebar-muted: #8BA3C0;
  --sidebar-line: #163052;
  --sidebar-on: #153056;
  --sidebar-accent: #4DA3FF;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 18px 44px rgba(15, 23, 42, 0.12);
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 24px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Manrope", "Inter", system-ui, sans-serif;
  --sidebar-w: 264px;
  --topbar-h: 60px;
  --focus: 0 0 0 3px rgba(0, 119, 255, 0.28);
  --m-reach: #0077FF;
  --m-reach-sub: #2D5BFF;
  --m-viral: #00B2FF;
  --m-views: #00B2FF;
  --m-sub: #047857;
  --m-unsub: #DC2626;
  --m-likes: #2D5BFF;
  --m-comments: #5AC8FA;
  --m-shares: #0077FF;
  --chart-grid: #E2E8F0;
  --chart-tick: #64748B;
  --tooltip-bg: #0F172A;
  --tooltip-ink: #F8FAFC;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07111F;
  --bg-elev: #0C1A2E;
  --paper: #102038;
  --paper-2: #16304C;
  --ink: #F1F6FC;
  --ink-soft: #C5D6EC;
  --muted: #8BA3C0;
  --line: #1E3A5F;
  --line-strong: #2A4C75;
  --accent: #4DA3FF;
  --accent-hover: #6BB3FF;
  --accent-soft: #0E2A4A;
  --accent-ink: #FFFFFF;
  --ok: #34D399;
  --ok-soft: #0F2E24;
  --ok-ink: #A7F3D0;
  --down: #F87171;
  --down-soft: #3F1D1D;
  --down-ink: #FECACA;
  --warn: #FBBF24;
  --warn-soft: #3A2A0A;
  --sidebar: #06101C;
  --sidebar-ink: #E8F1FA;
  --sidebar-muted: #8BA3C0;
  --sidebar-line: #14304C;
  --sidebar-on: #122844;
  --sidebar-accent: #5AC8FA;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 28px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.5);
  --chart-grid: #1E3A5F;
  --chart-tick: #94A3B8;
  --tooltip-bg: #F8FAFC;
  --tooltip-ink: #0F172A;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { height: 100%; }
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, .logo__text, .kpi__value, .kpis__value, .plan-price {
  font-family: var(--font-display);
  letter-spacing: -0.03em;
  color: var(--ink);
  font-weight: 700;
}
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 0.35rem; font-weight: 800; }
h2 { font-size: 1.15rem; line-height: 1.3; margin: 0 0 0.6rem; }
h3 { font-size: 1rem; margin: 0 0 0.4rem; }
p { margin: 0 0 0.75rem; }
.lead, .note { color: var(--muted); }
.lead { font-size: 0.98rem; }
.note { font-size: 0.86rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
code { font-size: 0.86em; background: var(--bg-elev); padding: 0.1em 0.35em; border-radius: 4px; }

/* ---------- layout shells ---------- */
.shell-app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.shell-app .sidebar { position: sticky; top: 0; height: 100vh; max-height: 100dvh; overflow: hidden; }
.shell-app .app-col { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.shell-market { display: flex; flex-direction: column; min-height: 100vh; }
.shell-share { display: flex; flex-direction: column; min-height: 100vh; }
.shell-share .wrap { max-width: 980px; }
.share-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 1.4rem; }
.conclusions { margin: 0 0 1.4rem; padding-left: 1.2rem; max-width: 46rem; }
.conclusions li { margin: 0 0 0.55rem; line-height: 1.45; }

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 18px 14px 16px;
  border-right: 1px solid var(--sidebar-line);
  z-index: 40;
  overflow: hidden;
}
.sidebar__brand {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 6px 16px;
}
.sidebar__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-right: 2px;
}
.sidebar a { color: var(--sidebar-ink); text-decoration: none; }
.sidebar a:hover { text-decoration: none; color: #fff; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-family: var(--font-display); letter-spacing: -0.03em; color: inherit; }
.logo__mark {
  width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(145deg, #00B2FF, #0077FF);
  display: grid; place-items: center; color: #fff; flex: none; box-shadow: 0 4px 10px rgba(0,119,255,.35);
}
.logo__mark svg { width: 18px; height: 18px; }
.logo__text { font-size: 1.02rem; color: inherit; }
.logo__sub { display: block; font-size: 0.7rem; color: var(--sidebar-muted); font-weight: 500; letter-spacing: 0; font-family: var(--font); margin-top: -2px; }

.sidebar__switch { margin: 0 0 14px; padding: 0 4px; }
.group-pick {
  display: block;
  margin: 0 0 16px;
  padding: 10px 8px 8px;
  background: color-mix(in srgb, var(--sidebar-on) 70%, transparent);
  border: 1px solid var(--sidebar-line);
  border-radius: var(--r);
}
.group-pick__label {
  display: block;
  font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--sidebar-muted); font-weight: 600; margin: 0 8px 8px;
}
.sidebar .group-pick__list {
  display: block;
  list-style: none;
  margin: 0;
  padding: 0;
}
.sidebar .group-pick__list li {
  display: block;
  margin: 0 0 4px;
  padding: 0;
}
.sidebar a.group-pick__item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  column-gap: 10px;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
  padding: 8px;
  border-radius: 9px;
  color: var(--sidebar-muted);
  text-decoration: none;
}
.sidebar a.group-pick__item:hover { background: var(--sidebar-on); color: #fff; }
.sidebar a.group-pick__item.is-on {
  background: color-mix(in srgb, var(--sidebar-accent) 18%, var(--sidebar-on));
  color: #fff;
}
.group-avatar {
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--sidebar-line); color: #fff;
  font-weight: 800; font-size: 0.85rem; font-family: var(--font-display);
  line-height: 1;
}
.sidebar a.group-pick__item.is-on .group-avatar { background: var(--accent); }
.group-pick__text { min-width: 0; overflow: hidden; }
.group-pick__name,
.group-pick__meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.group-pick__name { font-weight: 650; font-size: 0.9rem; line-height: 1.25; }
.group-pick__meta { font-size: 0.72rem; color: var(--sidebar-muted); margin-top: 1px; }
.group-pick__empty { display: block; font-size: 0.82rem; color: var(--sidebar-muted); margin: 0 8px 8px; }
.sidebar a.group-pick__more {
  display: flex; align-items: center; gap: 8px;
  margin-top: 6px; padding: 8px;
  font-size: 0.82rem; font-weight: 650; color: var(--sidebar-accent);
  border-radius: 9px; text-decoration: none;
}
.sidebar a.group-pick__more:hover { background: var(--sidebar-on); color: #fff; }
.group-pick__more .ico { width: 16px; height: 16px; }
.group-switch select, select, input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"], input[type="search"], textarea {
  width: 100%;
  appearance: none;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 0.5rem 0.7rem;
  font: inherit;
  font-size: 0.92rem;
}
.sidebar__switch select {
  background: var(--sidebar-on);
  color: var(--sidebar-ink);
  border-color: var(--sidebar-line);
}
select:focus, input:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-color: var(--accent);
}
label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.consent { flex-direction: row; align-items: flex-start; gap: 0.55rem; font-weight: 500; color: var(--ink-soft); font-size: 0.88rem; }
.consent span { min-width: 0; flex: 1; font-weight: 500; }
.consent input { width: auto; margin-top: 0.2rem; }

.side-nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 16px; }
.side-nav__label {
  font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--sidebar-muted); padding: 8px 10px 4px; font-weight: 600;
}
.side-nav a, .side-nav button.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 9px;
  color: var(--sidebar-muted); font-weight: 550; font-size: 0.92rem;
  background: none; border: 0; width: 100%; text-align: left; cursor: pointer; font-family: inherit;
}
.side-nav a:hover, .side-nav button.nav-link:hover { background: var(--sidebar-on); color: #fff; }
.side-nav a.is-on { background: var(--sidebar-on); color: #fff; box-shadow: inset 3px 0 0 var(--sidebar-accent); }
.side-nav .ico { width: 18px; height: 18px; flex: none; opacity: 0.9; }
.sidebar__foot {
  flex: 0 0 auto;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--sidebar-line);
}
.user-chip { font-size: 0.78rem; color: var(--sidebar-muted); padding: 0 10px; word-break: break-all; }

.topbar, .market-top, .share-top {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--topbar-h);
  padding: 10px 22px;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar__title { font-family: var(--font-display); font-weight: 700; font-size: 0.98rem; margin-right: auto; color: var(--ink-soft); }
.topbar .tz, .market-top .tz { color: var(--muted); font-size: 0.78rem; margin-right: auto; }
.market-top { justify-content: flex-start; }
.market-top .logo { color: var(--ink); }
.market-top nav { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn, .theme-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  cursor: pointer; padding: 0;
}
.theme-btn { width: auto; padding: 0 10px; font-size: 0.8rem; color: var(--ink-soft); font-weight: 600; font-family: inherit; }
.theme-btn svg, .icon-btn svg { width: 18px; height: 18px; }
.menu-btn { display: none; }
.backdrop { display: none; }

.wrap { width: min(1160px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 48px; flex: 1; }
.shell-market .wrap { width: min(1120px, calc(100% - 40px)); }
.foot {
  width: min(1160px, calc(100% - 40px));
  margin: 0 auto;
  padding: 8px 0 28px;
  color: var(--muted);
  font-size: 0.8rem;
}
.foot__links { display: flex; gap: 1rem; flex-wrap: wrap; }
.foot a { color: var(--ink-soft); }
.foot__time { opacity: 0.8; }

/* ---------- buttons / pills ---------- */
.btn, button.btn, a.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0.5rem 0.95rem;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
  font: inherit; font-weight: 600; font-size: 0.9rem;
  cursor: pointer; text-decoration: none;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.btn:hover, a.btn:hover { text-decoration: none; background: var(--paper-2); }
.btn--primary, .top .btn--primary, .topbar .btn--primary, .sidebar .btn--primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
}
.btn--primary:hover { background: var(--accent-hover); color: var(--accent-ink); }
.btn--ghost { background: transparent; box-shadow: none; }
.btn--sm { padding: 0.35rem 0.7rem; font-size: 0.82rem; }
.pill, a.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--ink-soft);
  font-size: 0.8rem; font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--line);
}
a.pill:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.pill--dark { background: var(--ink); color: #fff; border-color: transparent; }
html[data-theme="dark"] .pill--dark { background: var(--paper-2); color: var(--ink); }

/* ---------- page chrome ---------- */
.page-head { display: flex; justify-content: space-between; gap: 12px 24px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head > h1,
.page-head > .lead { flex: 1 1 100%; }
.page-head > h1 { margin-bottom: 0; }
.page-head > .lead { margin: 0; max-width: 46rem; }
.filters-row, .filters, form.filters, .period {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 1.1rem;
}
.filters { padding: 12px 14px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); }
.filters label { min-width: 120px; }
.filters--scope { background: transparent; border: 0; box-shadow: none; padding: 0; }

.flash { padding: 0.75rem 1rem; border-radius: var(--r); margin-bottom: 1rem; font-size: 0.92rem; }
.flash--ok { background: var(--ok-soft); color: var(--ok-ink); }
.flash--err { background: var(--down-soft); color: var(--down-ink); }
.alerts { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line)); border-radius: var(--r); padding: 14px 16px; margin-bottom: 1.1rem; }
.alerts--warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, var(--line)); }
.alerts h2 { margin-bottom: 0.4rem; }
.alerts ul { margin: 0; padding-left: 1.1rem; }
.empty, .chart-empty {
  background: var(--paper);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r);
  padding: 28px 20px;
  text-align: center;
  color: var(--muted);
  margin: 0 0 1rem;
}
.card, .chart-card, article.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
  min-width: 0;
  overflow: hidden;
}
.cards, .report-cards, .plan-grid, .kpis {
  display: grid;
  gap: 14px;
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
}
.cards, .report-cards, .plan-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ---------- KPI cards ---------- */
.kpis { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.kpis > li, .kpi {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 14px 16px 10px;
  display: flex; flex-direction: column; gap: 4px;
  min-height: 118px;
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--kpi-color, var(--accent));
}
.kpi--reach_all { --kpi-color: var(--m-reach); }
.kpi--reach_subscribers { --kpi-color: var(--m-reach-sub); }
.kpi--reach_viral { --kpi-color: var(--m-viral); }
.kpi--views_all { --kpi-color: var(--m-views); }
.kpi--subscribe_action { --kpi-color: var(--m-sub); }
.kpi--unsubscribe_action { --kpi-color: var(--m-unsub); }
.kpi--likes { --kpi-color: var(--m-likes); }
.kpi--comments { --kpi-color: var(--m-comments); }
.kpi--shares { --kpi-color: var(--m-shares); }
.kpi__head, .kpis__label { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.kpi__label, .kpis__label { font-size: 0.78rem; font-weight: 600; color: var(--muted); letter-spacing: 0.01em; }
.kpi__value, .kpis__value { font-size: 1.55rem; font-weight: 800; line-height: 1.15; letter-spacing: -0.03em; }
.kpi__sub, .kpis__sub { font-size: 0.78rem; color: var(--muted); }
.kpi__note { font-size: 0.75rem; color: var(--muted); margin: 0; }
.delta {
  font-size: 0.72rem; font-weight: 700; border-radius: 999px;
  padding: 0.1rem 0.45rem; white-space: nowrap;
  background: var(--bg-elev); color: var(--ink-soft);
}
.delta--up { background: var(--ok-soft); color: var(--ok-ink); }
.delta--down { background: var(--down-soft); color: var(--down-ink); }
.delta--flat { background: var(--bg-elev); color: var(--muted); }
.spark { width: 100%; height: 28px; margin-top: auto; color: var(--kpi-color, var(--accent)); }
.spark polyline { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.spark-fill { fill: color-mix(in srgb, currentColor 16%, transparent); stroke: none; }

/* ---------- charts / tables ---------- */
.charts { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 900px) {
  .charts { grid-template-columns: 1fr 1fr; }
  .charts .chart-card:first-child { grid-column: 1 / -1; }
}
.chart-card h2 { font-size: 0.98rem; }
.chart-card .chart-wrap { height: 280px; position: relative; }
.table-wrap {
  overflow: auto;
  max-height: min(72vh, 820px);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.4rem;
}
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.88rem; }
table.data th, table.data td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data th {
  position: sticky; top: 0; z-index: 1;
  background: var(--paper-2);
  font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; white-space: nowrap;
}
table.data th a { color: inherit; }
table.data tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 55%, var(--paper)); }
table.data tbody tr.lifetime-pick { cursor: pointer; }
table.data tbody tr.lifetime-pick.is-curve-on {
  background: color-mix(in srgb, var(--accent-soft) 80%, var(--paper));
}
table.data tbody tr.lifetime-pick.is-curve-on:hover {
  background: color-mix(in srgb, var(--accent-soft) 92%, var(--paper));
}
table.data .num, table.data td:nth-child(n+5) { font-variant-numeric: tabular-nums; }
table.data .text-col { max-width: 280px; color: var(--ink-soft); }
.vk-ext {
  display: inline-block;
  margin-left: 0.4em;
  padding: 0 0.38em;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.5;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  text-decoration: none;
  vertical-align: 0.12em;
  white-space: nowrap;
}
.vk-ext:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.media-cell { display: flex; align-items: center; gap: 10px; min-width: 140px; }
.thumb {
  width: 48px; height: 48px; border-radius: 8px; object-fit: cover;
  background: var(--bg-elev); border: 1px solid var(--line); flex: none;
}
.thumb--ph {
  display: grid; place-items: center; color: var(--muted);
}
.thumb--ph svg { width: 22px; height: 22px; }
.item-hero { display: flex; gap: 16px; align-items: flex-start; }
.item-hero__thumb {
  width: 96px; height: 96px; border-radius: 12px; object-fit: cover;
  background: var(--bg-elev); border: 1px solid var(--line); flex: none;
}
.cmp--down { color: var(--down); }
.cmp--up { color: var(--ok); }
.cmp--flat { color: var(--muted); }
article.card + article.card { margin-top: 14px; }
article.card > h2 { font-size: 1.05rem; margin: 0 0 0.55rem; }
ul.plain { margin: 0.35rem 0 0; padding-left: 1.15rem; }
.kind-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--ink-soft);
}
.sort-on { color: var(--accent); }

/* ---------- nav bits used in reports ---------- */
.reports-nav, .subnav { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 1.2rem; }
.reports-nav a, .subnav a {
  padding: 0.4rem 0.75rem; border-radius: 999px;
  background: var(--paper); border: 1px solid var(--line); color: var(--ink-soft);
  font-size: 0.85rem; font-weight: 600; text-decoration: none;
}
.reports-nav a.is-on, .reports-nav a:hover,
.subnav a.is-on, .subnav a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.heatmap-wrap { overflow: auto; }
table.heatmap {
  width: max-content;
  min-width: 100%;
  font-size: 0.72rem;
}
table.heatmap th, table.heatmap td {
  padding: 0.28rem 0.22rem;
  text-align: center;
  white-space: nowrap;
  min-width: 2.4rem;
}
table.heatmap td.hm span { display: block; font-weight: 700; line-height: 1.15; }
table.heatmap td.hm small { display: block; color: var(--muted); font-size: 0.62rem; }
.kv { list-style: none; padding: 0; margin: 0 0 1rem; }
.kv li { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 0.4rem 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.kv span { color: var(--muted); flex: 1 1 auto; max-width: 68%; }
.kv b { flex: 0 1 auto; text-align: right; font-weight: 650; overflow-wrap: anywhere; min-width: 0; }
.kpis__value--text { overflow-wrap: anywhere; }
.add-form, form.add-form, .auth-card form { display: flex; flex-direction: column; gap: 12px; max-width: 460px; }
.auth-shell { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: start; }
@media (min-width: 880px) {
  .auth-shell { grid-template-columns: 1fr 420px; padding-top: 12px; }
}
.auth-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg); padding: 28px 26px;
}
.auth-card .add-form { max-width: none; }
.auth-card hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.auth-links { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 12px 0 0; }
.auth-links a { font-weight: 650; }
.plan-card { position: relative; display: flex; flex-direction: column; gap: 6px; }
.plan-card.is-featured { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: var(--shadow), 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent); }
.plan-badge { position: absolute; top: 14px; right: 14px; }
.plan-price { font-size: 1.6rem; font-weight: 800; margin: 0; }
.plan-year { color: var(--muted); font-size: 0.85rem; margin: 0; }

/* ---------- landing ---------- */
.hero {
  display: grid; gap: 28px; align-items: center;
  padding: 28px 0 20px;
}
@media (min-width: 880px) {
  .hero { grid-template-columns: 1.15fr 0.85fr; padding: 42px 0 28px; }
}
.hero h1 { font-size: clamp(2rem, 4.2vw, 3.1rem); margin-bottom: 0.7rem; }
.hero .lead { font-size: 1.08rem; max-width: 36em; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 8px; }
.hero-art {
  background: radial-gradient(120% 120% at 10% 0%, #EAF3FF 0%, var(--paper) 55%);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  padding: 22px;
  min-height: 280px;
}
html[data-theme="dark"] .hero-art {
  background: radial-gradient(120% 120% at 10% 0%, #0E2A4A 0%, var(--paper) 60%);
}
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin: 8px 0 36px; }
.feature {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px; box-shadow: var(--shadow-sm);
}
.feature .ico { width: 28px; height: 28px; color: var(--accent); margin-bottom: 10px; }
.feature h3 { margin-bottom: 0.3rem; }
.feature p { color: var(--muted); font-size: 0.9rem; margin: 0; }
.section-title { margin: 8px 0 16px; }
.section-title p { color: var(--muted); margin: 0; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 0 0 40px; counter-reset: step; }
.step { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 18px 18px 56px; position: relative; }
.step::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 16px; top: 16px;
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent); font-weight: 800;
  display: grid; place-items: center; font-family: var(--font-display);
}

/* ---------- misc pages ---------- */
.health-grid, .admin-grid { display: grid; gap: 14px; }
.sync-form { display: inline-flex; margin: 0; }
.sidebar .sync-form, .sidebar .btn { width: 100%; }
.group-list { display: grid; gap: 12px; }
.legal { max-width: 760px; font-size: 0.98rem; line-height: 1.65; }
.legal h2 { margin: 1.6rem 0 0.55rem; font-size: 1.12rem; }
.legal p, .legal li { color: var(--ink-soft); }
.legal p { margin: 0 0 0.85rem; }
.legal ul { margin: 0 0 1rem; padding-left: 1.2rem; }
.legal a { text-decoration: underline; text-underline-offset: 2px; }
.legal-req {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px 8px;
  margin: 0 0 1.4rem;
}
.legal-req > p { margin: 0 0 0.6rem; color: var(--ink); }
.legal-req .kv { margin: 0; }
.legal-req .kv b { text-align: right; }

@media (max-width: 860px) {
  /* Block layout so the off-canvas sidebar does not consume a 100vh grid row. */
  .shell-app { display: block; grid-template-columns: unset; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(86vw, var(--sidebar-w));
    height: 100vh; max-height: 100dvh; overflow: hidden;
    transform: translateX(-105%);
    transition: transform 0.2s ease; box-shadow: var(--shadow-lg);
  }
  .shell-app .app-col { min-height: 100vh; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 30; }
  body.sidebar-open .backdrop { display: block; }
  .menu-btn { display: inline-flex; }
  .wrap { width: calc(100% - 28px); padding: 18px 0 36px; }
  .foot { width: calc(100% - 28px); }
  .topbar, .market-top, .share-top { padding: 8px 12px; }
  .hero { padding-top: 12px; }
  h1 { font-size: 1.45rem; }
  .kpi__value, .kpis__value, .plan-price { font-size: 1.35rem; }
  .topbar .tz { display: none; }
  table.data .text-col { max-width: 180px; }
}

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

.sidebar .btn, .sidebar .btn--ghost {
  color: var(--sidebar-ink);
  background: var(--sidebar-on);
  border-color: var(--sidebar-line);
  box-shadow: none;
}
.sidebar .btn--primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.sidebar .theme-btn {
  width: 100%; justify-content: flex-start;
  background: transparent; color: var(--sidebar-muted);
  border-color: var(--sidebar-line);
}
.sidebar .theme-btn:hover { color: #fff; }

a.btn.btn--primary, button.btn.btn--primary, .btn.btn--primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
}
a.btn.btn--primary:hover, button.btn.btn--primary:hover {
  background: var(--accent-hover);
  color: var(--accent-ink);
  text-decoration: none;
}
.ico, svg.ico { width: 18px; height: 18px; flex: none; display: block; }
.sidebar .btn .ico { width: 18px; height: 18px; }
.sidebar .sync-form .btn--ghost { justify-content: flex-start; gap: 8px; height: 40px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pill.is-on, a.pill.is-on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.muted { color: var(--muted); font-size: 0.82rem; align-self: center; }
.filters .pills { margin-right: 8px; }

@media (max-width: 860px) {
  body.shell-app {
    display: block;
  }
  body.shell-app .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(86vw, var(--sidebar-w));
    height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
  body.shell-app .app-col {
    width: 100%;
    min-height: 100vh;
  }
}

@media (max-width: 860px) {
  .market-top { flex-wrap: nowrap; gap: 6px; }
  .market-top .tz { display: none !important; }
  .market-top .logo__text { font-size: 0.9rem; white-space: nowrap; }
  .market-top nav { margin-left: auto; flex: none; }
  .market-top .theme-btn [data-theme-label] { display: none; }
  .market-top .theme-btn { width: 38px; min-width: 38px; padding: 0; }
  .market-top .btn { padding: 0.4rem 0.7rem; font-size: 0.82rem; }
}

/* KPI grid: 6-up on a wide desk, 3×2, 2 columns on a phone — never a single tall stack. */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.kpis.kpis--6 {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
.kpis.kpis--status {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.kpis__value--text, .kpi__muted {
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.kpi__muted { color: var(--muted); font-weight: 600; font-size: 0.92rem; }
@media (max-width: 1280px) {
  .kpis.kpis--6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .kpis, .kpis.kpis--6, .kpis.kpis--status {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; margin-left: 4px; vertical-align: middle;
  border-radius: 50%; border: 1px solid var(--line-strong);
  background: var(--paper-2); color: var(--muted);
  font-size: 10px; font-weight: 800; font-family: var(--font);
  cursor: help; position: relative; line-height: 1;
}
.tip__mark { font-style: normal; }
.tip:hover, .tip:focus { color: var(--accent); border-color: var(--accent); outline: none; }
.tip:hover::after, .tip:focus::after, .tip:focus-visible::after {
  content: attr(title);
  position: absolute;
  left: 50%; top: calc(100% + 8px);
  transform: translateX(-30%);
  width: min(260px, 70vw);
  background: var(--tooltip-bg);
  color: var(--tooltip-ink);
  font-size: 0.72rem; font-weight: 500; line-height: 1.4; letter-spacing: 0;
  font-family: var(--font);
  padding: 8px 10px; border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 5; text-transform: none;
  white-space: normal;
  pointer-events: none;
}

/* Period + type as one compact bar, especially on a phone. */
.filters-row {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  padding: 12px 14px;
  margin-bottom: 1.1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.filters-row .filters, .filters-row form.filters, .filters-row .filters--scope {
  background: transparent; border: 0; box-shadow: none; padding: 0; margin: 0;
  width: 100%;
}
.note--block {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
  color: var(--ink-soft);
}
.note--block h2 { font-size: 1rem; margin: 0 0 0.5rem; color: var(--ink); }

.verdict {
  font-size: 1.08rem;
  font-weight: 650;
  margin: -0.4rem 0 1.2rem;
  max-width: 40em;
}
.brief-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 1.6rem; }
.compare-dates {
  display: flex; flex-wrap: wrap; gap: 8px 1.5rem;
  color: var(--muted); margin: 0 0 0.5rem; font-size: 0.9rem;
}
.how {
  margin: 1.2rem 0 0;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--paper);
  padding: 0 14px;
  box-shadow: var(--shadow-sm);
}
.how summary {
  cursor: pointer;
  font-weight: 650;
  padding: 12px 0;
  list-style: none;
}
.how summary::-webkit-details-marker { display: none; }
.how summary::before { content: "▸ "; color: var(--muted); }
.how[open] summary::before { content: "▾ "; }
.how__body { padding: 0 0 14px; color: var(--ink-soft); }
.how__body .filters { margin-top: 8px; }
table.data tr.row--sub td:first-child { padding-left: 1.6rem; color: var(--muted); }
table.data tr.is-worse { background: var(--warn-soft); }
.examples { font-size: 0.8rem; color: var(--muted); margin: 0 0 0.25rem; }
.ok { color: var(--ok-ink); }
.err { color: var(--down-ink); }
table.data th.period {
  white-space: normal;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.78rem;
  min-width: 8.5rem;
  line-height: 1.35;
}
@media (max-width: 860px) {
  form.filters--bar, .filters-row form.filters--bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 10px;
    align-items: end;
  }
  form.filters--bar .pills,
  form.filters--bar .muted,
  form.filters--bar > button {
    grid-column: 1 / -1;
  }
  form.filters--bar label { min-width: 0; }
  .cab-plan { align-items: flex-start; }
  .cab-inline { display: grid; grid-template-columns: 1fr; }
  .cab-inline label { min-width: 0; max-width: none; }
}

.cab-plan {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow); padding: 18px 20px; margin: 0 0 0.5rem;
}
.cab-plan__kicker { margin: 0; font-size: 0.75rem; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.cab-plan__name { margin: 2px 0 8px; font-size: 1.45rem; font-weight: 800; font-family: var(--font-display); letter-spacing: -0.03em; }
.cab-plan__meta { margin: 0 0 4px; color: var(--muted); font-size: 0.9rem; }
.cab-plan__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.status-pill {
  display: inline-flex; align-items: center;
  padding: 0.12rem 0.5rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700;
  background: var(--bg-elev); color: var(--ink-soft);
}
.status-pill.is-ok { background: var(--ok-soft); color: var(--ok-ink); }
.status-pill.is-warn { background: var(--warn-soft); color: var(--warn); }
.status-pill.is-off { background: var(--down-soft); color: var(--down-ink); }
.section-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin: 1.5rem 0 0.75rem;
}
.section-head h2 { margin: 0; }
.cab-groups {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px; margin: 0 0 1.25rem;
}
a.cab-group {
  display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; align-items: center;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); padding: 14px 16px; color: inherit; text-decoration: none;
}
a.cab-group:hover { border-color: var(--accent); text-decoration: none; }
a.cab-group .group-avatar {
  width: 40px; height: 40px;
  background: var(--accent-soft); color: var(--accent);
}
.cab-group__text { min-width: 0; }
.cab-group__name, .cab-group__meta {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cab-group__name { font-weight: 700; }
.cab-group__meta { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.cab-inline {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: end;
  margin: 0 0 1rem;
}
.cab-inline label { min-width: 180px; flex: 1; }
.cab-share-url { white-space: nowrap; }
.cab-share-url a {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}
table.data tr.is-muted td { color: var(--muted); }
