/* Cloud Tycoon Live — core design system
   Fonts are loaded by pages:
   <link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
   <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@500;700;800&display=swap" rel="stylesheet">
*/

/* ---------- Tokens (light) ---------- */
:root {
  color-scheme: light;
  --scale: 1;

  --bg: #eef3f8;
  --bg-grad: radial-gradient(1200px 600px at 10% -10%, #dff3ee 0%, transparent 60%),
             radial-gradient(1000px 600px at 110% 0%, #dcebfb 0%, transparent 55%);
  --surface: #ffffff;
  --surface-2: #f5f8fb;
  --surface-3: #e8eef5;
  --ink: #0f1b2d;
  --ink-2: #3b4a5f;
  --ink-3: #5f6e82;          /* AA on surface & surface-2 */
  --line: #d9e2ec;
  --line-2: #c3cfdc;

  --accent: #00806b;         /* #009C82 darkened for AA text/button contrast */
  --accent-brand: #009C82;
  --accent-hover: #006b5a;
  --accent-ink: #ffffff;
  --accent-bg: #dcf4ef;
  --accent-line: #9fdccf;

  --sky: #2f7fd8;
  --sky-2: #5aa9f0;
  --sky-bg: #e1eefc;

  --good: #137a3f;   --good-bg: #e0f5e8;
  --bad:  #c0281c;   --bad-bg:  #fde6e3;
  --warn: #8f5a00;   --warn-bg: #fff1d6;
  --info: #1f65b8;   --info-bg: #e1eefc;

  --cat-ramp: #c0281c;
  --cat-security: #7b3fc4;
  --cat-vraag: #1f6fd1;
  --cat-geld: #b07a00;

  --radius: 16px;
  --radius-sm: 12px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(15, 27, 45, .06), 0 1px 1px rgba(15, 27, 45, .04);
  --shadow: 0 1px 2px rgba(15, 27, 45, .05), 0 4px 10px rgba(15, 27, 45, .06), 0 12px 28px -8px rgba(15, 27, 45, .10);
  --shadow-lg: 0 2px 4px rgba(15, 27, 45, .06), 0 12px 24px rgba(15, 27, 45, .10), 0 32px 64px -16px rgba(15, 27, 45, .22);
  --ring: 0 0 0 3px var(--surface), 0 0 0 5.5px var(--sky);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --gutter: 16px;
}

/* ---------- Tokens (dark) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a1220;
    --bg-grad: radial-gradient(1200px 600px at 10% -10%, rgba(63, 209, 180, .10) 0%, transparent 60%),
               radial-gradient(1000px 600px at 110% 0%, rgba(90, 169, 240, .12) 0%, transparent 55%);
    --surface: #121c2e;
    --surface-2: #17233a;
    --surface-3: #1f2d47;
    --ink: #eaf1fa;
    --ink-2: #bccadb;
    --ink-3: #8fa1b8;
    --line: #26354f;
    --line-2: #34466a;
    --accent: #3fd1b4;
    --accent-brand: #3fd1b4;
    --accent-hover: #66e0c7;
    --accent-ink: #04201a;
    --accent-bg: rgba(63, 209, 180, .14);
    --accent-line: rgba(63, 209, 180, .45);
    --sky: #6db6ff;
    --sky-2: #8ec7ff;
    --sky-bg: rgba(109, 182, 255, .14);
    --good: #4ade80;   --good-bg: rgba(74, 222, 128, .13);
    --bad:  #ff7a6e;   --bad-bg:  rgba(255, 122, 110, .14);
    --warn: #fbbf4b;   --warn-bg: rgba(251, 191, 75, .14);
    --info: #7cb8ff;   --info-bg: rgba(124, 184, 255, .14);
    --cat-ramp: #ff7a6e;
    --cat-security: #c49bff;
    --cat-vraag: #7cb8ff;
    --cat-geld: #f5c451;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 16px rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 255, 255, .03);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, .35), 0 24px 56px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .04);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a1220;
  --bg-grad: radial-gradient(1200px 600px at 10% -10%, rgba(63, 209, 180, .10) 0%, transparent 60%),
             radial-gradient(1000px 600px at 110% 0%, rgba(90, 169, 240, .12) 0%, transparent 55%);
  --surface: #121c2e;
  --surface-2: #17233a;
  --surface-3: #1f2d47;
  --ink: #eaf1fa;
  --ink-2: #bccadb;
  --ink-3: #8fa1b8;
  --line: #26354f;
  --line-2: #34466a;
  --accent: #3fd1b4;
  --accent-brand: #3fd1b4;
  --accent-hover: #66e0c7;
  --accent-ink: #04201a;
  --accent-bg: rgba(63, 209, 180, .14);
  --accent-line: rgba(63, 209, 180, .45);
  --sky: #6db6ff;
  --sky-2: #8ec7ff;
  --sky-bg: rgba(109, 182, 255, .14);
  --good: #4ade80;   --good-bg: rgba(74, 222, 128, .13);
  --bad:  #ff7a6e;   --bad-bg:  rgba(255, 122, 110, .14);
  --warn: #fbbf4b;   --warn-bg: rgba(251, 191, 75, .14);
  --info: #7cb8ff;   --info-bg: rgba(124, 184, 255, .14);
  --cat-ramp: #ff7a6e;
  --cat-security: #c49bff;
  --cat-vraag: #7cb8ff;
  --cat-geld: #f5c451;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 16px rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 255, 255, .03);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, .35), 0 24px 56px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .04);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: calc(16px * var(--scale));
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}
img, svg, video, canvas { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; letter-spacing: -.02em; color: var(--ink); }
h1 { font-size: clamp(1.75em, 4vw + 1em, 2.75em); font-weight: 850; letter-spacing: -.035em; }
h2 { font-size: 1.5em; font-weight: 800; }
h3 { font-size: 1.15em; font-weight: 750; }
h4 { font-size: 1em; font-weight: 700; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
a:hover { color: var(--accent-hover); }
hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }
::selection { background: var(--accent-bg); color: var(--ink); }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 10px; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 var(--gutter); }
@media (min-width: 768px) { :root { --gutter: 24px; } }

/* ---------- Utilities ---------- */
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack.sm, .stack-sm { gap: 8px; }
.stack.lg, .stack-lg { gap: 28px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.row.sm { gap: 6px; }
.row.between { justify-content: space-between; }
.row.nowrap { flex-wrap: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid-auto { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--min, 240px)), 1fr)); }
.muted { color: var(--ink-3); }
.small { font-size: .875em; }
.tiny { font-size: .75em; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.num { font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.center.row, .row.center { justify-content: center; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.eyebrow { font-size: .75em; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.show-sm { display: none !important; }
@media (max-width: 640px) {
  .hide-sm { display: none !important; }
  .show-sm { display: revert !important; }
}

/* ---------- Topbar / brand ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  min-height: 60px; padding: 8px var(--gutter);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar .spacer { flex: 1; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 850; font-size: 1.05em; letter-spacing: -.02em; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand-mark, .brand .logo {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; font-size: 20px; line-height: 1;
  background: linear-gradient(135deg, var(--accent-brand), var(--sky));
  box-shadow: 0 4px 12px -2px color-mix(in srgb, var(--accent-brand) 50%, transparent), inset 0 1px 0 rgba(255,255,255,.35);
}
.brand > span:not(.brand-mark):not(.logo) { display: inline; }
.brand b, .brand em { color: var(--accent); font-style: normal; }

/* ---------- Buttons ---------- */
.btn {
  --b-bg: var(--surface); --b-ink: var(--ink); --b-line: var(--line-2);
  appearance: none; -webkit-appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px;
  font: inherit; font-weight: 650; font-size: .95em; line-height: 1.2; letter-spacing: -.005em;
  color: var(--b-ink); background: var(--b-bg);
  border: 1px solid var(--b-line); border-radius: 12px;
  box-shadow: var(--shadow-sm);
  cursor: pointer; text-decoration: none; white-space: nowrap; user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s var(--ease), background-color .15s, border-color .15s, box-shadow .15s, color .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); color: var(--b-ink); }
.btn:active { transform: scale(.97); }
.btn:focus-visible { box-shadow: var(--ring); border-radius: 12px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn .ico { font-size: 1.15em; line-height: 1; }

.btn.primary {
  --b-ink: var(--accent-ink);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff) 0%, var(--accent) 100%);
  border-color: color-mix(in srgb, var(--accent) 80%, #000);
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 -2px 0 rgba(0,0,0,.12) inset, 0 6px 16px -6px color-mix(in srgb, var(--accent) 70%, transparent);
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn.primary:active { box-shadow: 0 2px 0 rgba(0,0,0,.12) inset; }
.btn.primary:focus-visible { box-shadow: var(--ring); }

.btn.ghost { --b-bg: transparent; --b-line: transparent; box-shadow: none; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--ink); }

.btn.danger { --b-bg: var(--bad); --b-ink: #fff; --b-line: color-mix(in srgb, var(--bad) 80%, #000); }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 88%, #000); border-color: color-mix(in srgb, var(--bad) 80%, #000); color: #fff; }
:root[data-theme="dark"] .btn.danger { --b-ink: #2a0703; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.danger { --b-ink: #2a0703; } }
:root[data-theme="dark"] .btn.danger:hover { color: #2a0703; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.danger:hover { color: #2a0703; } }

.btn.big {
  min-height: 60px; padding: 14px 28px; font-size: 1.15em; font-weight: 800; border-radius: 16px; letter-spacing: -.01em;
}
.btn.primary.big {
  box-shadow: 0 1px 0 rgba(255,255,255,.3) inset, 0 -4px 0 rgba(0,0,0,.16) inset, 0 10px 24px -8px color-mix(in srgb, var(--accent) 75%, transparent);
}
.btn.primary.big:active { transform: scale(.97) translateY(1px); box-shadow: 0 3px 0 rgba(0,0,0,.14) inset; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: .85em; border-radius: 10px; }
.btn.block { display: flex; width: 100%; }
.btn.icon { width: 44px; padding: 0; }
.btn.icon.sm { width: 36px; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after {
  content: ""; position: absolute; width: 1.1em; height: 1.1em; border-radius: 50%;
  border: 2.5px solid var(--b-ink); border-right-color: transparent; animation: ct-spin .7s linear infinite;
}
.btn.primary.loading::after { border-color: var(--accent-ink); border-right-color: transparent; }

/* ---------- Card ---------- */
.card {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
}
@media (min-width: 768px) { .card { padding: 24px; } }
.card.flat { box-shadow: none; }
.card.tight { padding: 14px; }
.card.accent { border-color: var(--accent-line); background: linear-gradient(180deg, var(--accent-bg), var(--surface) 70%); }
.card.hero { position: relative; overflow: hidden; }
.card.hero::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--accent-brand), var(--sky), var(--sky-2));
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card.interactive { cursor: pointer; transition: transform .15s var(--ease), box-shadow .15s, border-color .15s; }
.card.interactive:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--line-2); }
.card.interactive:active { transform: scale(.99); }

/* ---------- Pill / badge ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; min-height: 28px;
  font-size: .85em; font-weight: 650; line-height: 1.2;
  color: var(--ink-2); background: var(--surface-3);
  border: 1px solid transparent; border-radius: var(--radius-pill); white-space: nowrap;
}
.pill.accent { color: var(--accent); background: var(--accent-bg); }
.pill.good { color: var(--good); background: var(--good-bg); }
.pill.bad { color: var(--bad); background: var(--bad-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.info { color: var(--info); background: var(--info-bg); }
.pill.outline { background: transparent; border-color: var(--line-2); }
.pill .dot, .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }
.dot.live { animation: ct-pulse 1.6s ease-out infinite; box-shadow: 0 0 0 0 currentColor; }

.badge {
  display: inline-grid; place-items: center;
  min-width: 22px; height: 22px; padding: 0 7px;
  font-size: .72em; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums;
  color: var(--accent-ink); background: var(--accent);
  border-radius: var(--radius-pill);
}
.badge.good { background: var(--good); color: var(--surface); }
.badge.bad { background: var(--bad); color: var(--surface); }
.badge.warn { background: var(--warn); color: var(--surface); }
.badge.info { background: var(--info); color: var(--surface); }
.badge.muted { background: var(--surface-3); color: var(--ink-2); }

/* category tag: <span class="pill cat" style="--c:var(--cat-ramp)"> */
.pill.cat, .cat-tag { color: var(--c, var(--ink-2)); background: color-mix(in srgb, var(--c, var(--ink-3)) 14%, transparent); }

/* ---------- Chip (toggle) ---------- */
.chip {
  appearance: none; -webkit-appearance: none;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 8px 16px;
  font: inherit; font-size: .92em; font-weight: 600; color: var(--ink-2);
  background: var(--surface); border: 1.5px solid var(--line-2); border-radius: var(--radius-pill);
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: transform .12s var(--ease), background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}
.chip::before {
  content: ""; flex: none; width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid var(--line-2); background: var(--surface);
  transition: all .18s var(--spring);
}
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip:active { transform: scale(.97); }
.chip:focus-visible { box-shadow: var(--ring); border-radius: var(--radius-pill); }
.chip[aria-pressed="true"] {
  color: var(--accent); background: var(--accent-bg); border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.chip[aria-pressed="true"]::before {
  border-color: var(--accent);
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/12px no-repeat;
}
:root[data-theme="dark"] .chip[aria-pressed="true"]::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%2304201a' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip[aria-pressed="true"]::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%2304201a' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); } }
.chip.nocheck::before { display: none; }
.chip[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Segmented control ---------- */
.seg {
  display: inline-flex; gap: 4px; padding: 4px; max-width: 100%;
  background: var(--surface-3); border-radius: 14px;
  box-shadow: inset 0 1px 2px rgba(15, 27, 45, .08);
  overflow-x: auto; scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg.block { display: flex; width: 100%; }
.seg.block > button { flex: 1 1 0; }
.seg > button {
  appearance: none; -webkit-appearance: none;
  flex: 0 0 auto; min-height: 40px; padding: 8px 16px;
  font: inherit; font-size: .92em; font-weight: 650; color: var(--ink-2);
  background: transparent; border: 0; border-radius: 10px; cursor: pointer; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .18s var(--ease), color .15s, box-shadow .18s, transform .12s var(--ease);
}
.seg > button:hover { color: var(--ink); background: color-mix(in srgb, var(--surface) 50%, transparent); }
.seg > button:active { transform: scale(.97); }
.seg > button:focus-visible { box-shadow: var(--ring); }
.seg > button[aria-pressed="true"] {
  color: var(--ink); background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 27, 45, .12), 0 2px 6px rgba(15, 27, 45, .08);
}
.seg.accent > button[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent); }
.seg > button[disabled] { opacity: .45; cursor: not-allowed; }

/* ---------- Note / callout ---------- */
.note {
  --n: var(--info); --n-bg: var(--info-bg);
  position: relative; display: block;
  padding: 12px 14px 12px 42px; border-radius: 14px;
  color: var(--ink); background: var(--n-bg);
  border: 1px solid color-mix(in srgb, var(--n) 25%, transparent);
  border-left: 4px solid var(--n);
  font-size: .95em; line-height: 1.45;
}
.note::before { position: absolute; left: 12px; top: 12px; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: 12px; line-height: 1; font-weight: 900; color: var(--surface); background: var(--n); content: "i"; font-family: var(--mono); }
.note.good { --n: var(--good); --n-bg: var(--good-bg); }
.note.good::before { content: "✓"; font-family: var(--font); }
.note.bad { --n: var(--bad); --n-bg: var(--bad-bg); }
.note.bad::before { content: "✕"; font-family: var(--font); }
.note.warn { --n: var(--warn); --n-bg: var(--warn-bg); }
.note.warn::before { content: "!"; }
.note.noicon { padding-left: 14px; }
.note.noicon::before { display: none; }
.note b, .note strong { color: var(--ink); }

/* ---------- Form fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: .85em; font-weight: 700; color: var(--ink-2); }
.input, input.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  font: inherit; font-size: 1em; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line-2); border-radius: 12px;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--ink-3); opacity: .85; }
.input:hover { border-color: var(--ink-3); }
.input:focus { border-color: var(--sky); box-shadow: 0 0 0 4px color-mix(in srgb, var(--sky) 22%, transparent); outline: none; }
.input.code { font-family: var(--mono); font-weight: 800; font-size: 1.6em; letter-spacing: .3em; text-transform: uppercase; text-align: center; padding-left: calc(14px + .3em); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.field .hint { font-size: .8em; color: var(--ink-3); }
.field .err { font-size: .82em; color: var(--bad); font-weight: 600; }

/* ---------- KPI ---------- */
.kpi { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi > .label, .kpi .kpi-label {
  font-size: .75em; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3);
}
.kpi > .value, .kpi .kpi-value {
  font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 800;
  font-size: clamp(1.35em, 1em + 2.2vw, 1.75em); line-height: 1.1; letter-spacing: -.03em; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi > .sub, .kpi .kpi-sub { font-size: .8em; color: var(--ink-3); font-weight: 600; }
.kpi.big > .value, .kpi.big .kpi-value { font-size: clamp(1.9em, 1.2em + 3vw, 2.6em); }
.kpi.good > .value { color: var(--good); }
.kpi.bad > .value { color: var(--bad); }
.kpi.accent > .value { color: var(--accent); }
.kpi.boxed { padding: 14px 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; }

/* ---------- Progress ---------- */
.progress {
  position: relative; height: 10px; width: 100%; overflow: hidden;
  background: var(--surface-3); border-radius: var(--radius-pill);
  box-shadow: inset 0 1px 2px rgba(15, 27, 45, .08);
}
.progress > i {
  display: block; height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-brand), var(--sky));
  transition: width .5s var(--ease);
}
.progress.good > i { background: var(--good); }
.progress.bad > i { background: var(--bad); }
.progress.warn > i { background: var(--warn); }
.progress.sm { height: 6px; }
.progress.lg { height: 16px; }
.progress.striped > i {
  background-image: linear-gradient(45deg, rgba(255,255,255,.22) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.22) 50%, rgba(255,255,255,.22) 75%, transparent 75%), linear-gradient(90deg, var(--accent-brand), var(--sky));
  background-size: 20px 20px, 100% 100%;
  animation: ct-stripes 1s linear infinite;
}

/* ---------- Avatar ---------- */
.avatar {
  --tc: var(--accent);
  --size: 44px;
  flex: none; position: relative;
  display: inline-grid; place-items: center;
  width: var(--size); height: var(--size); border-radius: 50%;
  font-size: calc(var(--size) * .52); line-height: 1;
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--tc) 30%, var(--surface)), color-mix(in srgb, var(--tc) 18%, var(--surface)) 70%);
  box-shadow: 0 0 0 2.5px var(--tc), 0 4px 10px -3px color-mix(in srgb, var(--tc) 60%, transparent);
}
.avatar.sm { --size: 32px; box-shadow: 0 0 0 2px var(--tc); }
.avatar.lg { --size: 64px; box-shadow: 0 0 0 3px var(--tc), 0 6px 16px -4px color-mix(in srgb, var(--tc) 60%, transparent); }
.avatar.xl { --size: 96px; box-shadow: 0 0 0 4px var(--tc), 0 10px 24px -6px color-mix(in srgb, var(--tc) 60%, transparent); }
.avatar .badge { position: absolute; right: -6px; bottom: -4px; min-width: 20px; height: 20px; box-shadow: 0 0 0 2px var(--surface); }

/* ---------- Table ---------- */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .95em; }
.table th { text-align: left; font-size: .75em; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); padding: 8px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .r, .table td.num, .table th.num { text-align: right; white-space: nowrap; font-family: var(--mono); font-variant-numeric: tabular-nums; }
@media (max-width: 480px) { .table th, .table td { padding: 8px 6px; } .table th:first-child, .table td:first-child { padding-left: 2px; } }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

/* ---------- Skeleton ---------- */
.skeleton {
  display: block; min-height: 1em; border-radius: 10px; color: transparent !important;
  background: linear-gradient(90deg, var(--surface-3) 0%, color-mix(in srgb, var(--surface-3) 40%, var(--surface)) 50%, var(--surface-3) 100%);
  background-size: 200% 100%;
  animation: ct-shimmer 1.4s ease-in-out infinite;
}
.skeleton > * { visibility: hidden; }
.skeleton.line { height: 14px; }
.skeleton.title { height: 26px; width: 60%; }
.skeleton.circle { border-radius: 50%; width: 44px; height: 44px; }
.skeleton.block { height: 120px; }

/* ---------- Toasts ---------- */
.toast-wrap {
  position: fixed; z-index: 100; pointer-events: none;
  left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  width: min(calc(100vw - 32px), 420px);
  display: flex; flex-direction: column-reverse; gap: 8px; align-items: stretch;
}
@media (min-width: 768px) {
  .toast-wrap { left: auto; right: 24px; top: 24px; bottom: auto; transform: none; width: 380px; flex-direction: column; }
}
.toast {
  --t: var(--info);
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px 12px 12px;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-lg);
  font-size: .94em; font-weight: 550; line-height: 1.4;
  animation: ct-toast-in .32s var(--spring) both;
  position: relative; overflow: hidden;
}
.toast::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--t); }
.toast .t-ico {
  flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  font-size: 13px; font-weight: 900; color: var(--surface); background: var(--t);
}
.toast .t-msg { flex: 1; min-width: 0; padding-top: 1px; overflow-wrap: anywhere; }
.toast .t-x {
  flex: none; appearance: none; border: 0; background: transparent; color: var(--ink-3);
  width: 28px; height: 28px; margin: -3px -4px -3px 0; border-radius: 8px; cursor: pointer; font-size: 18px; line-height: 1;
}
.toast .t-x:hover { background: var(--surface-3); color: var(--ink); }
.toast.good { --t: var(--good); }
.toast.bad { --t: var(--bad); }
.toast.warn { --t: var(--warn); }
.toast.out { animation: ct-toast-out .22s var(--ease) both; }

/* ---------- Offline banner ---------- */
.offline-banner {
  position: fixed; z-index: 90; left: 50%; top: 12px; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 10px;
  max-width: calc(100vw - 32px);
  padding: 10px 18px; border-radius: var(--radius-pill);
  font-size: .9em; font-weight: 700;
  color: var(--warn); background: color-mix(in srgb, var(--warn-bg) 92%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  animation: ct-drop-in .3s var(--spring) both;
}
.offline-banner::before {
  content: ""; flex: none; width: 14px; height: 14px; border-radius: 50%;
  border: 2.5px solid currentColor; border-right-color: transparent;
  animation: ct-spin .9s linear infinite;
}
.offline-banner.static { position: static; transform: none; animation: none; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: rgba(8, 15, 28, .45);
  -webkit-backdrop-filter: blur(8px) saturate(1.2); backdrop-filter: blur(8px) saturate(1.2);
  animation: ct-fade-in .2s ease both;
  overflow-y: auto;
}
@media (min-width: 640px) { .modal-backdrop { align-items: center; } }
.modal {
  position: relative;
  width: 100%; max-width: 520px; max-height: calc(100dvh - 32px); overflow: auto;
  padding: 24px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: ct-modal-in .32s var(--spring) both;
}
.modal.wide { max-width: 760px; }
.modal h2, .modal h3 { margin-bottom: 8px; }
.modal .modal-x {
  position: absolute; top: 12px; right: 12px; width: 40px; height: 40px;
  appearance: none; border: 0; border-radius: 12px; background: transparent; color: var(--ink-3);
  font-size: 22px; line-height: 1; cursor: pointer;
}
.modal .modal-x:hover { background: var(--surface-3); color: var(--ink); }
.modal .modal-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 20px; }
@media (max-width: 480px) { .modal .modal-actions > .btn { flex: 1 1 auto; } }

/* ---------- Timer ring helper (optional) ---------- */
.ring { --p: 0; --c: var(--accent); --size: 64px; width: var(--size); height: var(--size); border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-3) 0); position: relative; }
.ring::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--surface); }
.ring > * { position: relative; font-family: var(--mono); font-weight: 800; }

/* ---------- Divider label / kbd ---------- */
kbd, .kbd { font-family: var(--mono); font-size: .82em; padding: 2px 6px; border-radius: 6px; background: var(--surface-3); border: 1px solid var(--line-2); border-bottom-width: 2px; }

/* ---------- Animations ---------- */
@keyframes ct-spin { to { transform: rotate(360deg); } }
@keyframes ct-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes ct-stripes { to { background-position: 20px 0, 0 0; } }
@keyframes ct-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 60%, transparent); } 100% { box-shadow: 0 0 0 8px transparent; } }
@keyframes ct-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes ct-modal-in { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes ct-toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes ct-toast-out { to { opacity: 0; transform: translateY(6px) scale(.97); } }
@keyframes ct-drop-in { from { opacity: 0; transform: translate(-50%, -16px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes ct-pop { 0% { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
@keyframes ct-bump { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.12); } }
@keyframes ct-shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.pop-in { animation: ct-pop .45s var(--spring) both; }
.bump { animation: ct-bump .4s var(--spring); }
.shake { animation: ct-shake .4s ease; }
.fade-in { animation: ct-fade-in .3s ease both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
  .skeleton { animation: none; }
  .btn:active, .chip:active, .seg > button:active { transform: none; }
}
