/* Themes: dark is the default; light applies when the OS prefers it (and no choice is saved) or when
   theme.js sets <html data-theme="light">. Every color below comes from these tokens. */
:root {
  color-scheme: dark;
  --bg: #0d0f0c; --panel: #161a14; --panel-2: #1b2018; --sidebar: #111410; --line: #262c22; --hover: rgba(255, 255, 255, 0.05);
  --fg: #eef2e8; --muted: #9aa392;
  --accent: #c6ff3d; --on-accent: #111; --accent-soft: rgba(198, 255, 61, 0.12);
  --warn: #ffb547; --bad: #ff6b6b; --good: #7ee08a;
  --c-signup: #6cb6ff; --c-trial: #c6ff3d; --c-purchase: #ffb547; --c-revenue: #b79cff; --c-active: #3ddcc0; --c-muted: #4a5245;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  font: 14px/1.45 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f5f6f2; --panel: #fff; --panel-2: #f9faf7; --sidebar: #fbfbf8; --line: #e2e5dc; --hover: rgba(0, 0, 0, 0.04);
    --fg: #161a14; --muted: #5f6858;
    --accent: #4d7c00; --on-accent: #fff; --accent-soft: rgba(77, 124, 0, 0.1);
    --warn: #a86300; --bad: #c43535; --good: #2b8a3e;
    --c-signup: #2f74c0; --c-trial: #5b9100; --c-purchase: #d07400; --c-revenue: #7c4dcc; --c-active: #0f8f7a; --c-muted: #c9cec2;
    --shadow: 0 10px 30px rgba(20, 30, 10, 0.14);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6f2; --panel: #fff; --panel-2: #f9faf7; --sidebar: #fbfbf8; --line: #e2e5dc; --hover: rgba(0, 0, 0, 0.04);
  --fg: #161a14; --muted: #5f6858;
  --accent: #4d7c00; --on-accent: #fff; --accent-soft: rgba(77, 124, 0, 0.1);
  --warn: #a86300; --bad: #c43535; --good: #2b8a3e;
  --c-signup: #2f74c0; --c-trial: #5b9100; --c-purchase: #d07400; --c-revenue: #7c4dcc; --c-active: #0f8f7a; --c-muted: #c9cec2;
  --shadow: 0 10px 30px rgba(20, 30, 10, 0.14);
}

/* Series colors: an element with one of these classes draws in var(--c). */
.c-signup { --c: var(--c-signup); } .c-trial { --c: var(--c-trial); } .c-purchase { --c: var(--c-purchase); }
.c-revenue { --c: var(--c-revenue); } .c-active { --c: var(--c-active); } .c-muted { --c: var(--c-muted); }
.c-bad { --c: var(--bad); } .c-good { --c: var(--good); } .c-warn { --c: var(--warn); }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); }
body.no-scroll { overflow: hidden; }
h1 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
h1 span { color: var(--muted); font-weight: 400; }
h2 { font-size: 15px; margin: 0; }
h3 { font-size: 12px; font-weight: 600; color: var(--muted); margin: 14px 0 6px; text-transform: uppercase; letter-spacing: 0.04em; }
h3:first-child { margin-top: 0; }
code { font-size: 12px; }
a { color: inherit; }
label { color: var(--muted); font-size: 12px; }
select, input, button { font: inherit; color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 7px 11px; }
input::placeholder { color: var(--muted); }
button { cursor: pointer; background: var(--accent); color: var(--on-accent); border-color: transparent; font-weight: 600; }
button:disabled { cursor: default; opacity: 0.7; }
button.ghost, a.button.ghost { display: inline-flex; align-items: center; justify-content: center; gap: 7px; background: transparent; color: var(--fg); border: 1px solid var(--line); font-weight: 500; text-decoration: none; }
button.ghost:hover, a.button.ghost:hover { background: var(--hover); }
button.danger { background: var(--bad); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ic, .nav svg, .menu svg, .theme-pick svg, button.ghost svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; padding: 8px 12px; background: var(--accent); color: var(--on-accent); border-radius: 8px; }
.skip:focus { top: 12px; }
.meta { color: var(--muted); font-size: 12px; margin: 2px 0 0; }
.meta:empty { display: none; }
.empty { color: var(--muted); padding: 14px 0; margin: 0; }
.link { color: var(--accent); font-size: 12px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.link:hover { text-decoration: underline; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; background: transparent; color: var(--fg); border: 1px solid var(--line); border-radius: 10px; }
.icon-btn:hover { background: var(--hover); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }

/* ---------- Shell: sidebar + content ---------- */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: 14px; padding: 18px 14px calc(16px + env(safe-area-inset-bottom)); background: var(--sidebar); border-right: 1px solid var(--line); overflow-y: auto; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 0 0 10px; min-height: 36px; }
.brand { font-size: 17px; font-weight: 700; text-decoration: none; }
.brand span { color: var(--muted); font-weight: 400; }
.nav { display: grid; gap: 2px; }
.nav-label { margin: 14px 10px 4px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.nav-label:first-child { margin-top: 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--hover); color: var(--fg); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--fg); }
.nav a[aria-current="page"] svg { color: var(--accent); }
.nav .count { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.signout { margin-top: auto; }
.signout button { width: 100%; justify-content: flex-start; padding: 9px 10px; color: var(--muted); }
.signout button:hover { color: var(--bad); }
.drawer-only, .menu-btn { display: none; }
.scrim { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, 0.45); }

.content { min-width: 0; container: content / inline-size; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "menu title actions" "filters filters filters";
  align-items: center; gap: 12px 16px;
  padding: 14px clamp(14px, 2.2vw, 36px);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.menu-btn { grid-area: menu; }
.title { grid-area: title; min-width: 0; }
.title h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.badge { display: inline-block; padding: 0 7px; border-radius: 999px; background: var(--warn); color: #111; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.filters { grid-area: filters; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.actions { grid-area: actions; display: flex; align-items: center; gap: 8px; }
.topbar:not(:has(.filters)) { grid-template-areas: "menu title actions"; }
@container content (min-width: 1100px) {
  .topbar { grid-template-columns: auto minmax(180px, 1fr) auto auto; grid-template-areas: "menu title filters actions"; }
  .filters { flex-wrap: nowrap; justify-content: flex-end; }
}

/* Segmented controls (radio groups) */
.seg { position: relative; display: inline-flex; margin: 0; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); min-width: 0; }
.seg legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.seg label { position: relative; display: block; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; padding: 5px 10px; border-radius: 8px; color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.seg label:hover span { color: var(--fg); }
.seg input:checked + span { background: var(--accent-soft); color: var(--fg); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.search { position: relative; display: flex; align-items: center; flex: 1 1 220px; max-width: 340px; min-width: 0; }
.search .ic { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search input { width: 100%; padding-left: 32px; border-radius: 10px; }
#refresh.spinning .ic { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Theme menu + avatar */
.menu-wrap { position: relative; }
.theme-btn .ic { display: none; }
:root:not([data-theme-pref]) .theme-btn .i-system, [data-theme-pref="system"] .theme-btn .i-system,
[data-theme-pref="light"] .theme-btn .i-light, [data-theme-pref="dark"] .theme-btn .i-dark { display: block; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 200px; padding: 5px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.menu button { display: grid; grid-template-columns: 18px 1fr; align-items: center; column-gap: 10px; width: 100%; padding: 8px 10px; background: transparent; color: var(--fg); border: 0; border-radius: 8px; font-weight: 500; text-align: left; }
.menu button small { grid-column: 2; color: var(--muted); font-size: 11px; font-weight: 400; }
.menu button:hover, .menu button:focus-visible { background: var(--hover); outline: none; }
.menu button[aria-checked="true"] { color: var(--accent); }
.avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); font-weight: 700; text-decoration: none; flex: none; }
.avatar:hover { background: var(--accent); color: var(--on-accent); }
.avatar.big { width: 56px; height: 56px; font-size: 22px; }

main { padding: clamp(14px, 2.2vw, 36px); padding-bottom: 64px; container: main / inline-size; outline: none; }
main > section > :first-child { margin-top: 0; }

/* Below 1024px the sidebar slides in over the page. */
@media (max-width: 1023.98px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(300px, 86vw); transform: translateX(-102%); transition: transform 0.22s ease; box-shadow: var(--shadow); }
  .shell[data-drawer-open] .sidebar { transform: none; }
  .drawer-only, .menu-btn { display: inline-grid; }
}
@media (min-width: 1800px) {
  .shell { grid-template-columns: 264px minmax(0, 1fr); }
}
/* Phones: the filters stay on one line that scrolls sideways, so the sticky top bar stays short. */
@media (max-width: 720px) {
  .topbar { gap: 10px; padding-top: 10px; padding-bottom: 10px; }
  .filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * clamp(14px, 2.2vw, 36px)); padding: 0 clamp(14px, 2.2vw, 36px) 2px; }
  .filters::-webkit-scrollbar { display: none; }
  .filters > * { flex: none; }
  .search { flex: 0 0 210px; }
  .seg span { padding: 5px 9px; }
}

/* ---------- Overview: KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
@container main (min-width: 640px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; } }
@container main (min-width: 1700px) { .kpis { grid-template-columns: repeat(8, minmax(0, 1fr)); } }
.kpi { position: relative; display: flex; flex-direction: column; min-width: 0; padding: 14px 16px 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.kpi-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; }
.kpi-value { margin: 4px 0 2px; font-size: clamp(20px, 2.4cqi, 28px); font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { color: var(--muted); font-size: 11px; padding-bottom: 12px; min-height: 2.6em; }
.kpi .spark { display: block; width: calc(100% + 32px); height: 34px; margin: auto -16px 0; }
.spark .line { fill: none; stroke: var(--c); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.spark .area { fill: var(--c); opacity: 0.14; }
.delta { flex: none; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--hover); color: var(--muted); }
.delta.up { color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }
.delta.down { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }

/* ---------- Overview: widgets grid (columns follow the space, up to 6 on ultra-wide screens) ---------- */
.dash { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; grid-auto-flow: row dense; align-items: stretch; }
.wfull { grid-column: 1 / -1; }
/* Wide widgets span 2 or 3 columns so every column count (2–6) fills its rows. */
@container main (min-width: 720px) { .dash { grid-template-columns: repeat(2, minmax(0, 1fr)); } .wwide { grid-column: span 2; } }
@container main (min-width: 1080px) { .dash { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@container main (min-width: 1700px) { .dash { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; } .wwide { grid-column: span 3; } }
@container main (min-width: 2400px) { .dash { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@container main (min-width: 3000px) { .dash { grid-template-columns: repeat(6, minmax(0, 1fr)); } .wwide { grid-column: span 2; } }
.widget { display: flex; flex-direction: column; min-width: 0; padding: 16px 18px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.w-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.w-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.w-body:has(> .donut-wrap) { justify-content: center; }
.w-body > * { min-width: 0; }

.key { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.inline-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 8px; padding: 0; list-style: none; color: var(--muted); font-size: 12px; }
.inline-legend li { display: flex; align-items: center; gap: 7px; }
.inline-legend b { color: var(--fg); }

.chart-box { position: relative; min-width: 0; }
.line-chart { display: block; overflow: visible; touch-action: pan-y; }
.line-chart text { fill: var(--muted); font-size: 11px; }
.line-chart .grid { stroke: var(--line); stroke-dasharray: 3 4; }
.line-chart .line { fill: none; stroke: var(--c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line-chart .area { fill: var(--c); opacity: 0.14; }
.line-chart .guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; }
.line-chart .dot { fill: var(--panel); stroke: var(--c); stroke-width: 2; }
.tip { position: absolute; top: 4px; z-index: 5; display: grid; gap: 3px; padding: 8px 10px; min-width: 140px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); font-size: 12px; pointer-events: none; white-space: nowrap; }
.tip span { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.tip strong { color: var(--fg); margin-left: auto; padding-left: 10px; }

.bars, .funnel, .ending, .feed, .legend-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 11px; }
.bar-row { display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: 13px; }
.bar-row .bar-label, .bar-row > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row b { font-variant-numeric: tabular-nums; }
.bar-row b.warn { color: var(--warn); }
.bar-row small, .ending small { color: var(--muted); font-size: 11px; white-space: nowrap; }
.ending small { display: block; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; }
.track { height: 6px; margin-top: 5px; border-radius: 99px; background: var(--hover); overflow: hidden; }
.track.tall { height: 12px; border-radius: 6px; }
.fill { display: block; height: 100%; min-width: 3px; border-radius: inherit; background: var(--c); }

.stack { display: flex; height: 12px; gap: 2px; border-radius: 6px; overflow: hidden; background: var(--hover); margin-bottom: 12px; }
.stack i { display: block; height: 100%; background: var(--c); }
.stacks .legend-list { margin-bottom: 4px; }
.legend-list { gap: 7px; }
.legend-list li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 44px; align-items: center; gap: 8px; font-size: 12px; }
.legend-list span { color: var(--muted); min-width: 0; overflow-wrap: anywhere; }
.legend-list b { font-variant-numeric: tabular-nums; }
.legend-list small { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.donut-wrap { display: grid; grid-template-columns: minmax(110px, 150px) minmax(0, 1fr); align-items: center; gap: 18px; }
.donut { width: 100%; height: auto; }
.donut .track { fill: none; stroke: var(--hover); stroke-width: 14; }
.donut .seg { fill: none; stroke: var(--c); stroke-width: 14; }
.donut .big { fill: var(--fg); font-size: 22px; font-weight: 700; }
.donut .small { fill: var(--muted); font-size: 10px; }
@container main (max-width: 400px) { .donut-wrap { grid-template-columns: 1fr; justify-items: center; } .donut { max-width: 160px; } .donut-wrap .legend-list { width: 100%; } }

.figures { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-bottom: 14px; }
.figures div { display: grid; }
.figures small { color: var(--muted); font-size: 11px; }
.figures b { font-size: 18px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.figures.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.figures.tiles div { padding: 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.figures.tiles b { font-size: 22px; }

.feed { gap: 0; }
.feed li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed .key { border-radius: 50%; }
.feed-text { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed small { display: block; color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed time { color: var(--muted); font-size: 11px; white-space: nowrap; }

.heat { display: grid; grid-template-columns: auto repeat(24, minmax(0, 1fr)); gap: 3px; align-items: center; font-size: 10px; color: var(--muted); }
.heat .hour { text-align: left; min-height: 12px; }
.heat .wd { padding-right: 6px; }
.heat i { display: block; height: 20px; border-radius: 3px; background: var(--hover); }
@container main (max-width: 560px) { .heat { gap: 2px; } .heat i { height: 13px; border-radius: 2px; } }
.heat i.on { background: color-mix(in srgb, var(--c-trial) calc(var(--a) * 100%), var(--hover)); }

/* Loading placeholders */
.skeleton { min-height: 120px; gap: 10px; }
.skeleton i { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--hover), color-mix(in srgb, var(--fg) 10%, transparent), var(--hover)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
.skeleton i:nth-child(1) { width: 45%; } .skeleton i:nth-child(2) { width: 70%; height: 22px; } .skeleton i:nth-child(3) { width: 55%; }
.widget.skeleton { min-height: 220px; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton i, #refresh.spinning .ic { animation: none; } .sidebar { transition: none; } }

/* ---------- Table views ---------- */
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: baseline; gap: 5px; padding: 4px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.chip b { color: var(--fg); font-variant-numeric: tabular-nums; }
.chip.active b { color: var(--c-active); } .chip.bought b { color: var(--good); } .chip.refunded b { color: var(--bad); } .chip.ended b { color: var(--muted); }
.chip.search-chip { border-style: dashed; }
.split { display: grid; gap: 16px; align-items: start; }
@container main (min-width: 1500px) { .split { grid-template-columns: minmax(0, 1fr) 400px; } .split .help { position: sticky; top: 96px; } }
.table-wrap { overflow: auto; max-height: max(420px, calc(100dvh - 210px)); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: top; }
th { position: sticky; top: 0; z-index: 1; color: var(--muted); font-weight: 500; font-size: 12px; background: var(--panel); }
tbody tr:hover td { background: var(--hover); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td small { display: block; color: var(--muted); font-size: 11px; white-space: normal; max-width: 420px; }
td.empty { padding: 18px 14px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; border: 1px solid var(--line); white-space: nowrap; }
.pill.active { color: var(--accent); border-color: var(--accent); }
.pill.ended { color: var(--muted); }
.pill.bought { color: var(--good); border-color: var(--good); }
.pill.refunded { color: var(--bad); border-color: var(--bad); }
.pill.email, .pill.app, .pill.license { color: var(--good); }
.pill.network { color: var(--warn); }
.pill.none { color: var(--muted); }
.help { color: var(--muted); }
.help summary { cursor: pointer; color: var(--fg); font-weight: 600; }
.help ul { padding-left: 18px; margin: 10px 0 0; }
.help li { margin: 8px 0; }

/* Narrow screens: each table row becomes a card that names its fields. */
@container main (max-width: 719px) {
  .table-wrap { max-height: none; overflow: visible; background: none; border: 0; border-radius: 0; }
  table, tbody, tr, td { display: block; }
  thead { display: none; }
  tbody { display: grid; gap: 10px; }
  tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
  tbody tr:hover td { background: none; }
  td { padding: 0; border: 0; white-space: normal; overflow-wrap: anywhere; min-width: 0; }
  td.num { text-align: left; }
  td::before { content: attr(data-label); display: block; margin-bottom: 2px; color: var(--muted); font-size: 11px; }
  td[data-label="Email"], td[data-label="Source"], td[data-label="Source / medium"], td[data-label="Trial"] { grid-column: 1 / -1; }
  td[data-label="Source / medium"] { font-weight: 600; }
  tr.empty-row { display: block; }
  td.empty::before { content: none; }
}

/* ---------- Profile ---------- */
.profile { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.profile .card { container-type: inline-size; }
.profile h2 { margin-bottom: 2px; }
.account { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 16px; }
.account h2 { overflow-wrap: anywhere; font-size: 17px; }
.facts { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin: 4px 0 0; }
.facts div { padding: 12px 14px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.facts dt { color: var(--muted); font-size: 11px; }
.facts dd { margin: 2px 0 0; font-weight: 600; }
@container main (min-width: 900px) {
  .profile { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account { grid-column: 1 / -1; grid-template-columns: auto minmax(0, 1fr) minmax(0, 2fr); }
  .facts { grid-column: auto; margin: 0; }
  #password { grid-row: span 2; }
}
@container main (min-width: 1700px) {
  .profile { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #password { grid-row: auto; }
}
.form-grid { display: grid; gap: 12px; margin-top: 14px; }
.form-grid label, .login label { display: grid; gap: 5px; font-size: 13px; }
.profile input:not([type="radio"]), .login input { width: 100%; padding: 9px 12px; background: var(--bg); }
.pair { display: grid; gap: 12px; }
@container (min-width: 520px) { .pair { grid-template-columns: 1fr 1fr; } }
.notice { margin: 12px 0 0; padding: 9px 12px; border-radius: 10px; font-size: 13px; }
.notice.success { background: color-mix(in srgb, var(--good) 12%, transparent); }
.notice.error { background: color-mix(in srgb, var(--bad) 12%, transparent); }
.theme-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.theme-pick button { display: grid; justify-items: center; gap: 4px; padding: 14px 8px; background: var(--panel-2); color: var(--fg); border: 1px solid var(--line); border-radius: 12px; font-weight: 600; }
.theme-pick button small { color: var(--muted); font-size: 11px; font-weight: 400; }
.theme-pick button:hover { background: var(--hover); }
.theme-pick button[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.theme-pick svg { width: 22px; height: 22px; }
.ticks { margin: 12px 0 0; padding-left: 18px; color: var(--muted); }
.ticks li { margin: 7px 0; }

/* ---------- Sign-out confirmation ---------- */
.dialog { width: min(400px, calc(100vw - 32px)); padding: 0; color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(2px); }
.dialog form { display: grid; justify-items: start; gap: 8px; padding: 22px; }
.dialog h2 { font-size: 17px; }
.dialog p { margin: 0; color: var(--muted); }
.dialog-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }
.dialog-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; width: 100%; margin-top: 12px; }
.dialog-actions button { padding: 8px 16px; }
@media (max-width: 420px) { .dialog-actions button { flex: 1; } }

/* ---------- Small pages (sign-in, forgot, reset) ---------- */
.bar { display: flex; align-items: center; padding: 14px clamp(16px, 3vw, 32px); border-bottom: 1px solid var(--line); }
.login { width: min(400px, calc(100% - 32px)); margin: clamp(24px, 12vh, 140px) auto 48px; display: grid; gap: 12px; padding: clamp(20px, 4vw, 28px); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
.login h2 { margin: 0; }
.login p { margin: 0; color: var(--muted); font-size: 12px; }
.login button[type="submit"] { padding: 10px 12px; }
.login code { font-size: 11px; }
.back { color: var(--muted); font-size: 12px; }
.error { color: var(--bad) !important; }
.success { color: var(--good) !important; }
