:root {
  --bg: #f5f3fa;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --card-hover: #fbfaff;
  --text: #1b1724;
  --muted: #6c667a;
  --faint: #9a94a8;
  --line: #e8e4f0;
  --line-strong: #d9d3e6;
  --brand: #64007d;
  --brand-2: #937cd8;
  --brand-3: #e65aa8;
  --brand-tint: #f1ebfb;
  --brand-ink: #64007d;
  --good: #16794a;
  --good-tint: #e3f4ea;
  --warn: #9a5a00;
  --warn-tint: #fdf0da;
  --bad: #b3261e;
  --bad-tint: #fbe6e4;
  --sidebar: #fbfaff;
  --shadow: 0 1px 2px rgba(40, 20, 70, .04), 0 4px 16px rgba(40, 20, 70, .05);
  --shadow-lg: 0 24px 64px rgba(40, 10, 70, .22);
  --radius: 14px;
  --radius-sm: 10px;
  --chart-grid: #eeeaf5;
  --dot-1: #9b7bf0;
  --dot-2: #f06bb5;
  --dot-3: #f7a531;
  --dot-4: #3fcf7e;
  --heat-0: #ece8f3;
  --heat-1: #d9cdf3;
  --heat-2: #b39fe6;
  --heat-3: #8a62d4;
  --heat-4: #64007d;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f0c16;
  --bg-elev: #17131f;
  --card: #1a1623;
  --card-hover: #211c2c;
  --text: #f1edf8;
  --muted: #a49cb5;
  --faint: #776f88;
  --line: #2a2436;
  --line-strong: #3a3249;
  --brand: #b48cff;
  --brand-2: #8f6ce0;
  --brand-3: #ff7ac0;
  --brand-tint: #2a1f3d;
  --brand-ink: #d9c6ff;
  --good: #5fd39a;
  --good-tint: #15301f;
  --warn: #f0b05c;
  --warn-tint: #33260f;
  --bad: #ff8a80;
  --bad-tint: #3a1715;
  --sidebar: #130f1a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --chart-grid: #2a2436;
  --heat-0: #251f30;
  --heat-1: #3d2d5c;
  --heat-2: #5b3f91;
  --heat-3: #8a62d4;
  --heat-4: #c9a6ff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
.booting body { visibility: hidden; }
html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display { font-family: "Plus Jakarta Sans", Inter, system-ui, sans-serif; letter-spacing: -.01em; }
a { color: inherit; }
button { font: inherit; cursor: pointer; color: inherit; }
input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Shell */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 14px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; text-decoration: none; }
.sidebar-brand img { height: 24px; }
:root[data-theme="dark"] .sidebar-brand img { filter: brightness(0) invert(1); opacity: .92; }
.sidebar-brand span { font: 600 12px/1 Inter, sans-serif; text-transform: uppercase; letter-spacing: .12em; color: var(--brand-ink); background: var(--brand-tint); padding: 4px 7px; border-radius: 6px; }
.search-trigger {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; margin-bottom: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--muted); text-align: left;
}
.search-trigger:hover { border-color: var(--line-strong); }
.search-trigger kbd, .kbd { margin-left: auto; font: 500 11px/1 Inter, sans-serif; color: var(--faint); border: 1px solid var(--line); border-radius: 5px; padding: 3px 5px; background: var(--bg); }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--brand-tint); color: var(--text); }
.nav a.active { background: var(--brand-tint); color: var(--brand-ink); }
.nav a.active .icon { color: var(--brand); }
.nav .count { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--brand-ink); background: var(--brand-tint); padding: 1px 7px; border-radius: 999px; }
.nav a.active .count { background: var(--card); }
.nav-toggle { display: flex; align-items: center; gap: 6px; width: 100%; border: 0; background: none; text-align: left; cursor: pointer; }
.nav-toggle:hover { color: var(--muted); }
.nav-toggle .icon { width: 12px; height: 12px; transform: rotate(90deg); transition: transform .15s; }
.nav-group.folded .nav-toggle .icon { transform: none; }
.nav-group.folded .nav { display: none; }
.new-dot { width: 8px; height: 8px; margin-left: auto; border-radius: 50%; background: var(--brand); }
.sidebar-version { display: block; padding: 6px 10px 0; font-size: 11px; color: var(--faint); text-decoration: none; }
.sidebar-version:hover { color: var(--muted); }
.changelog { display: grid; gap: 14px; max-width: 820px; }
.changelog-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.changelog-head h2 { margin: 0; }
.changelog-version { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.changelog-latest { font-size: 11px; font-weight: 600; color: var(--good); background: var(--good-tint); padding: 1px 8px; border-radius: 999px; }
.changelog-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.changelog-list li { display: grid; grid-template-columns: 80px 1fr; gap: 12px; font-size: 14px; line-height: 1.45; }
.changelog-area { font-size: 12px; font-weight: 600; color: var(--muted); padding-top: 1px; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.avatar { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-3)); }
.who { min-width: 0; flex: 1; font-size: 12px; }
.who b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; color: var(--muted); }
.icon-btn:hover { background: var(--brand-tint); color: var(--text); }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 4; display: flex; align-items: center; gap: 16px; padding: 14px 32px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 20px; margin: 0; }
.topbar .sub { color: var(--muted); font-size: 13px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
/* Page actions (e.g. the Insights tabs) shrink before the title does; the title keeps room for its subtitle. */
#page-actions-slot, #page-actions { display: flex; min-width: 0; }
.topbar > div:not(.topbar-actions) { min-width: 220px; }
.menu-btn { display: none; }
.content { max-width: 1320px; margin: 0 auto; padding: 24px 32px 48px; }

/* Components */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card h2 { font-size: 15px; margin: 0; }
.card-link { font-size: 13px; color: var(--brand-ink); text-decoration: none; font-weight: 500; }
.card-link:hover { text-decoration: underline; }
.grid { display: grid; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; align-items: start; }
.grid-2.even { grid-template-columns: 1fr 1fr; }
.state { padding: 48px; text-align: center; color: var(--muted); }
.state.error { color: var(--bad); }
.empty { color: var(--muted); padding: 12px 4px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); color: var(--text); background: var(--card); border-radius: var(--radius-sm); padding: 7px 14px; font-weight: 500; text-decoration: none; transition: border-color .15s, background .15s, transform .1s; }
.btn:hover { border-color: var(--brand-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--brand), #7d2fb0); color: #fff; border-color: transparent; }
:root[data-theme="dark"] .btn.primary { background: linear-gradient(135deg, #7c4dd9, #b14ba8); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); background: var(--bad-tint); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.link { background: none; border: 0; color: var(--brand-ink); padding: 4px 8px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; }
.input { width: 100%; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--bg-elev); outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-2) 25%, transparent); }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .input { flex: 0 1 320px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips-label { align-self: center; margin: 0 4px 0 10px; font-size: 12px; color: var(--muted); }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; color: var(--muted); }
.chip:hover { border-color: var(--line-strong); }
.chip.active { border-color: var(--brand-2); color: var(--brand-ink); background: var(--brand-tint); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.active, .badge.good { background: var(--good-tint); color: var(--good); }
.badge.quiet, .badge.warn { background: var(--warn-tint); color: var(--warn); }
.badge.dormant, .badge.neutral { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

.table-card { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 16px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 600; background: var(--bg-elev); position: sticky; top: 0; }
th[data-sort] { cursor: pointer; user-select: none; }
th.sorted::after { content: " ↓"; }
th.sorted.asc::after { content: " ↑"; }
tbody tr.clickable { cursor: pointer; }
tbody tr:hover { background: var(--card-hover); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { position: relative; overflow: hidden; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi-value { font: 700 30px/1.15 "Plus Jakarta Sans", Inter, sans-serif; margin: 6px 0; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .spark { position: absolute; right: 14px; top: 14px; opacity: .9; }
.kpi:has(.spark) .kpi-label { padding-right: 64px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.delta { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.delta.up { background: var(--good-tint); color: var(--good); }
.delta.down { background: var(--bad-tint); color: var(--bad); }
.delta.flat { background: var(--bg); color: var(--muted); }
.kpi-prev { color: var(--muted); font-size: 12px; margin-left: 6px; }
.change.up { color: var(--good); }
.change.down { color: var(--bad); }

/* Hero (home) */
.hero {
  position: relative; overflow: hidden;
  border-radius: 20px; padding: 28px 32px; margin-bottom: 20px; color: #fff;
  background: radial-gradient(120% 140% at 0% 0%, #8b2fc9 0%, #64007d 42%, #2b0a3d 100%);
  box-shadow: 0 18px 48px rgba(100, 0, 125, .28);
}
.hero h2 { font-size: 28px; margin: 0 0 6px; }
.hero p { margin: 0; opacity: .85; max-width: 560px; }
.hero .orb { position: absolute; border-radius: 50%; filter: blur(.5px); pointer-events: none; }
.hero-stats { display: flex; gap: 28px; margin-top: 22px; flex-wrap: wrap; position: relative; }
.hero-stat b { display: block; font: 700 26px/1.1 "Plus Jakarta Sans", sans-serif; }
.hero-stat span { font-size: 12px; opacity: .8; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tile { display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); text-decoration: none; box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.tile:hover { transform: translateY(-2px); border-color: var(--brand-2); }
.tile .tile-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: var(--brand-tint); color: var(--brand); }
.tile b { font-size: 14px; }
.tile span { color: var(--muted); font-size: 13px; }
.tiles.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tiles.compact .tile { display: grid; grid-template-columns: 36px 1fr; column-gap: 12px; row-gap: 0; align-items: center; padding: 12px; box-shadow: none; }
.tiles.compact .tile-icon { grid-row: span 2; }
.tiles.compact .tile b, .tiles.compact .tile span:not(.tile-icon) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Orbs: floating Cosmo Dots */
.orb { border-radius: 50%; pointer-events: none; }
@keyframes float { 0%, 100% { transform: translate3d(0, 0, 0); } 50% { transform: translate3d(0, -14px, 0); } }
@media (prefers-reduced-motion: no-preference) { .orb.float { animation: float 7s ease-in-out infinite; } }

/* Loader: Cosmo logo with bouncing Dots, used while a page or tab fetches data */
.loader { display: grid; justify-items: center; gap: 18px; padding: 72px 24px; min-height: 320px; align-content: center; text-align: center; }
.loader-logo { height: 34px; }
:root[data-theme="dark"] .loader-logo { filter: brightness(0) invert(1); opacity: .92; }
.loader-dots { display: flex; gap: 12px; height: 40px; align-items: flex-end; }
.loader-dots span { width: 18px; height: 18px; border-radius: 50%; background: var(--dot); box-shadow: 0 0 18px color-mix(in srgb, var(--dot) 55%, transparent); }
.loader-dots span:nth-child(1) { --dot: var(--dot-1); }
.loader-dots span:nth-child(2) { --dot: var(--dot-2); }
.loader-dots span:nth-child(3) { --dot: var(--dot-3); }
.loader-dots span:nth-child(4) { --dot: var(--dot-4); }
.loader-text { margin: 0; font-weight: 600; color: var(--text); }
.loader-hint { margin: -10px 0 0; font-size: 13px; color: var(--muted); }
.loader.error .loader-dots { display: none; }
.loader.error .loader-text { color: var(--bad); }
@keyframes dot-bounce { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-22px); } 60% { transform: translateY(-22px) scale(1.05); } }
@keyframes logo-breathe { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@media (prefers-reduced-motion: no-preference) {
  .loader:not(.error) .loader-dots span { animation: dot-bounce 1.2s cubic-bezier(.45, 0, .55, 1) infinite; }
  .loader-dots span:nth-child(2) { animation-delay: .12s; }
  .loader-dots span:nth-child(3) { animation-delay: .24s; }
  .loader-dots span:nth-child(4) { animation-delay: .36s; }
  .loader:not(.error) .loader-logo { animation: logo-breathe 2.4s ease-in-out infinite; }
}

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-bottom: 1px solid var(--line); border-radius: 8px; }
.list li:last-child { border-bottom: 0; }
.list li.clickable { cursor: pointer; }
.list li.clickable:hover { background: var(--card-hover); }
.list .grow { flex: 1; min-width: 0; }
.list .grow div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.from-to { font-variant-numeric: tabular-nums; white-space: nowrap; }

.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 160px 1fr 64px; align-items: center; gap: 10px; font-size: 13px; }
.bar-track { background: var(--bg); border-radius: 6px; height: 10px; overflow: hidden; }
.bar-fill { background: linear-gradient(90deg, var(--brand-2), var(--brand)); height: 100%; border-radius: 6px; }
.bar-row.dim { opacity: .4; }
.model-list { font-size: 12px; margin: -2px 0 6px 170px; }
.bar-row.with-sessions, .bar-row.with-share { grid-template-columns: 160px 1fr 64px 64px; }
.bar-row.regions { grid-template-columns: 160px 1fr 64px 52px 64px 64px; }
.bar-head { color: var(--muted); font-size: 12px; }
.kpis.suite-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.suite-kpi { border-top: 3px solid var(--suite); }
.suite-meta { color: var(--muted); font-size: 13px; margin-top: 8px; }
.suite-meta b { color: var(--text); font-weight: 600; }
.group-row td { background: var(--bg-elev); font-weight: 600; }
.suite-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; }
.explain { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 14px 0 0; max-width: 90ch; }
.explain b { color: var(--text); font-weight: 600; }
.kpi-explain { margin: -6px 0 18px; }
.version-share { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 10px; margin-bottom: 16px; }
.version-share .input { width: auto; padding: 6px 10px; }
.version-share .kpi-value { margin: 0 0 0 6px; }
.chart { position: relative; height: 280px; }
.chart.short { height: 240px; }
.spark { display: block; }

/* Translations */
.lang-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.lang-card { display: flex; align-items: center; gap: 14px; padding: 16px; text-decoration: none; transition: transform .15s, border-color .15s; }
.lang-card:hover { transform: translateY(-2px); border-color: var(--brand-2); }
.ring { --p: 0; width: 56px; height: 56px; flex: none; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--heat-0) 0); }
.ring::before { content: ""; grid-area: 1 / 1; width: 44px; height: 44px; border-radius: 50%; background: var(--card); }
.ring b { grid-area: 1 / 1; z-index: 1; font-size: 12px; }
.lang-card .flag { width: 20px; height: 15px; border-radius: 3px; object-fit: cover; box-shadow: 0 0 0 1px var(--line); }
.lang-card h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; margin: 0 0 2px; }

/* Stories */
.story-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.story { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.story .cover { aspect-ratio: 4 / 3; background: var(--bg) center / cover no-repeat; display: block; position: relative; }
.story .cover span { position: absolute; left: 10px; bottom: 10px; background: rgba(15, 10, 25, .7); color: #fff; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; backdrop-filter: blur(4px); }
.story .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.story h3 { font-size: 15px; margin: 0; }
.story select { width: 100%; }

/* Drawer, modal, palette, toast */
.overlay { position: fixed; inset: 0; z-index: 20; }
.backdrop { position: absolute; inset: 0; background: rgba(15, 8, 25, .45); backdrop-filter: blur(2px); animation: fade .15s ease; }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(720px, 100%); background: var(--card); overflow-y: auto; padding: 24px; box-shadow: var(--shadow-lg); animation: slide .2s ease; }
.drawer-close { position: absolute; top: 12px; right: 16px; }
.drawer-panel h2 { margin: 0 40px 4px 0; font-size: 20px; word-break: break-all; }
.drawer-panel .meta { color: var(--muted); margin-bottom: 16px; }
.drawer-panel h3 { font-size: 14px; margin: 22px 0 10px; }
.mini-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 8px; }
.mini-kpis .kpi-value { font-size: 22px; }
.modal-panel { position: relative; margin: 12vh auto 0; width: min(440px, calc(100% - 32px)); background: var(--card); border-radius: 18px; padding: 24px; box-shadow: var(--shadow-lg); animation: pop .18s ease; }
.modal-panel h2 { margin: 0 0 4px; font-size: 18px; }
.modal-panel form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.form-error { color: var(--bad); font-size: 13px; min-height: 18px; }

.palette { position: relative; margin: 10vh auto 0; width: min(620px, calc(100% - 32px)); background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .15s ease; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.palette-input input { flex: 1; border: 0; outline: none; background: none; font-size: 16px; }
.palette-list { max-height: 52vh; overflow-y: auto; padding: 6px; }
.palette-group { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 10px 10px 4px; }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; cursor: pointer; }
.palette-item .hint { margin-left: auto; color: var(--faint); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 45%; }
.palette-item.selected { background: var(--brand-tint); color: var(--brand-ink); }
.palette-foot { display: flex; gap: 14px; padding: 9px 14px; border-top: 1px solid var(--line); color: var(--faint); font-size: 12px; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 30; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13px; animation: pop .18s ease; }
.toast.error { background: var(--bad); color: #fff; }

@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
@keyframes pop { from { transform: translateY(6px) scale(.98); opacity: 0; } }

/* Heatmap */
.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 10px); grid-auto-columns: 10px; gap: 2px; overflow-x: auto; padding-bottom: 4px; }
.heatmap i { display: block; width: 10px; height: 10px; border-radius: 2px; background: var(--heat-0); }
.heatmap i.l1 { background: var(--heat-1); }
.heatmap i.l2 { background: var(--heat-2); }
.heatmap i.l3 { background: var(--heat-3); }
.heatmap i.l4 { background: var(--heat-4); }
.heatmap i.pad { background: transparent; }

/* Coming back (cohort retention) */
.retention-headline { font: 700 22px/1.35 "Plus Jakarta Sans", Inter, sans-serif; letter-spacing: -.01em; margin: 4px 0 0; max-width: 60ch; }
.retention-table td.heat { font-variant-numeric: tabular-nums; font-weight: 600; }
.retention-table td.heat.l0 { background: var(--heat-0); }
.retention-table td.heat.l1 { background: var(--heat-1); }
.retention-table td.heat.l2 { background: var(--heat-2); }
.retention-table td.heat.l3 { background: var(--heat-3); color: #fff; }
.retention-table td.heat.l4 { background: var(--heat-4); color: #fff; }
:root[data-theme="dark"] .retention-table td.heat.l4 { color: var(--bg); }

/* What's new tips */
.tip { position: absolute; z-index: 5; width: min(340px, calc(100vw - 32px)); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-lg); text-align: left; animation: pop .18s ease; }
.tip-arrow { position: absolute; top: -6px; left: var(--arrow-x, 50%); width: 10px; height: 10px; margin-left: -5px; background: var(--card); border-left: 1px solid var(--line); border-top: 1px solid var(--line); transform: rotate(45deg); }
.tip-title { margin: 0 0 4px; font-weight: 600; }
.tip-badge { display: inline-block; margin-right: 4px; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; color: var(--brand-ink); background: var(--brand-tint); }
.tip-body { margin: 0; color: var(--muted); font-size: 13px; }
.tip-more { margin: 10px 0 0; max-height: 45vh; overflow-y: auto; }
.tip-actions { display: flex; gap: 8px; margin-top: 12px; }
.sessions td { padding: 7px 8px; font-size: 13px; }

/* Insights specifics */
.account-cell .email { font-weight: 500; }
.account-cell .school { color: var(--muted); font-size: 12px; }
.report-panel { position: absolute; inset: 24px; max-width: 1040px; margin: 0 auto; display: flex; flex-direction: column; background: var(--card); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow-lg); animation: pop .18s ease; }
.report-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.report-bar .grow { flex: 1; min-width: 180px; }
.report-bar .title { font-weight: 600; overflow-wrap: anywhere; }
.report-bar .input { width: auto; padding: 6px 10px; }
.report-bar .changed { color: var(--brand-ink); font-weight: 600; }
.report-body { position: relative; flex: 1; background: #fff; }
.report-body iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.report-body .state { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--card); }
@media (max-width: 640px) { .report-panel { inset: 0; border-radius: 0; } }
.reseller-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.reseller-card h3 { margin: 0 0 4px; font-size: 15px; }
.stack { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--bg); margin: 14px 0 8px; }
.stack span { display: block; height: 100%; }
.stack .s-active { background: var(--good); }
.stack .s-quiet { background: #e8a33d; }
.stack .s-dormant { background: var(--line-strong); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend b { color: var(--text); }
.translations-card { margin-bottom: 16px; }
.translations-card .legend { margin-top: 10px; }
.legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.legend .dot.s-active { background: var(--good); }
.legend .dot.s-quiet { background: #e8a33d; }
.legend .dot.s-dormant { background: var(--line-strong); }
.tr-bar-col { width: 40%; min-width: 120px; }
.stack.tr-bar { margin: 0; }
.actions { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
/* Tabs stay on one line; when they don't fit, the bar scrolls sideways (every tab is also in the side menu). */
.tabs { display: flex; gap: 4px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px; padding: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tab { flex: none; white-space: nowrap; background: none; border: 0; padding: 6px 14px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--brand-tint); color: var(--brand-ink); }

/* Sign-in */
.auth { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.auth-art { position: relative; overflow: hidden; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; background: radial-gradient(120% 120% at 10% 0%, #8b2fc9 0%, #64007d 40%, #1d0629 100%); }
.auth-art img { height: 30px; filter: brightness(0) invert(1); align-self: flex-start; }
.auth-art h1 { font-size: 40px; line-height: 1.1; margin: 0 0 12px; max-width: 460px; }
.auth-art p { opacity: .82; max-width: 420px; margin: 0; }
.auth-form { display: grid; place-items: center; padding: 32px; background: var(--bg); }
.auth-form form { width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px; }
.auth-form h2 { margin: 0; font-size: 26px; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2, .grid-2.even { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 15; left: 0; width: 264px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .app.nav-open .sidebar { transform: none; }
  .menu-btn { display: grid; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { min-height: 240px; padding: 28px; }
  .auth-art h1 { font-size: 28px; }
}

@media (max-width: 560px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-value { font-size: 24px; }
  .kpi .spark { display: none; }
  .bar-row { grid-template-columns: 110px 1fr 52px; }
  .bar-row.with-sessions, .bar-row.with-share { grid-template-columns: 110px 1fr 52px 52px; }
  .model-list { margin-left: 120px; }
  .bar-row.regions { grid-template-columns: 90px 1fr 52px 40px 52px 52px; }
  .kpis.suite-kpis { grid-template-columns: 1fr; }
  .mini-kpis { grid-template-columns: 1fr 1fr; }
  .tiles.compact { grid-template-columns: 1fr; }
  .topbar .sub { display: none; }
  .topbar > div:not(.topbar-actions) { min-width: 0; flex: none; }
  .hero { padding: 22px; }
  .hero h2 { font-size: 22px; }
}

/* Insights: period picker under the header, and the App Store downloads table inside a card. */
.period-bar { margin-bottom: 18px; }
.table-scroll { overflow-x: auto; margin: 0 -16px; }
.session-long { color: var(--muted); font-style: italic; }
