/* Aurovia design system — shared by every page. Feature pages add page-specific CSS in their own <style> block
   or static/css/<area>.css, and should reuse these tokens/classes instead of inventing new ones. */
:root {
  --bg: #0b0d12;
  --bg-2: #11141b;
  --panel: #151922;
  --panel-2: #1b202b;
  --line: #262c39;
  --text: #e8eaf0;
  --muted: #8b93a7;
  --faint: #5b6378;
  --gold: #d4af37;
  --gold-2: #f0d67a;
  --gold-dim: rgba(212, 175, 55, .14);
  --up: #22c55e;
  --up-dim: rgba(34, 197, 94, .14);
  --down: #ef4444;
  --down-dim: rgba(239, 68, 68, .14);
  --info: #60a5fa;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.35);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, ui-monospace, monospace;
  --sidebar: 232px;
}
[data-theme="light"] {
  --bg: #f5f6f8; --bg-2: #eceef2; --panel: #ffffff; --panel-2: #f7f8fa; --line: #e1e4ea;
  --text: #141821; --muted: #5d6578; --faint: #9aa1b2; --gold: #a8841a; --gold-2: #8a6c12;
  --gold-dim: rgba(168,132,26,.12); --up: #15803d; --down: #dc2626;
  --shadow: 0 1px 2px rgba(0,0,0,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-2); }
h1, h2, h3 { margin: 0 0 .5rem; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh;
  background: linear-gradient(90deg, var(--bg-2) calc(var(--sidebar) - 1px), var(--line) calc(var(--sidebar) - 1px), var(--line) var(--sidebar), transparent var(--sidebar)); }
.sidebar { background: var(--bg-2); border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; align-self: start; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 700; letter-spacing: .14em; font-size: .95rem; color: var(--text); }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--gold-2), var(--gold) 55%, #8a6c12); display: grid; place-items: center; color: #111; font-weight: 800; font-size: .85rem; letter-spacing: 0; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.active { background: var(--gold-dim); color: var(--gold-2); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav-more summary { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 500; cursor: pointer; list-style: none; }
.nav-more summary::-webkit-details-marker { display: none; }
.nav-more summary::after { content: "▾"; margin-left: auto; font-size: .75rem; transition: transform .15s; }
.nav-more[open] summary::after { transform: rotate(180deg); }
.nav-more summary:hover { background: var(--panel); color: var(--text); }
.nav-more a { padding-left: 18px; }
.sidebar-foot { margin-top: auto; padding: 10px; font-size: .8rem; color: var(--faint); display: grid; gap: 6px; }
.main { padding: 24px 28px 48px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Building blocks ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; }
.stack { display: grid; gap: 16px; }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; }
.stat .value { font-family: var(--mono); font-size: 1.45rem; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: .8rem; color: var(--muted); margin-top: 2px; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; }
.btn:hover { border-color: var(--faint); color: var(--text); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #111; }
.btn-gold:hover { background: var(--gold-2); color: #111; }
.btn-danger { color: var(--down); }
.btn-sm { padding: 5px 10px; font-size: .85rem; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.badge.gold { background: var(--gold-dim); color: var(--gold-2); border-color: transparent; }
.badge.up { background: var(--up-dim); color: var(--up); border-color: transparent; }
.badge.down { background: var(--down-dim); color: var(--down); border-color: transparent; }

table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; }
.table-wrap { overflow-x: auto; }

form .field { display: grid; gap: 5px; margin-bottom: 12px; }
label { font-size: .8rem; color: var(--muted); font-weight: 500; }
input, select, textarea { width: 100%; padding: 9px 11px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--bg-2); color: var(--text); font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold-dim); border-color: var(--gold); }
input[type=checkbox], input[type=radio] { width: auto; padding: 0; flex: none; accent-color: var(--gold); }
/* two-or-three choice pill (radio buttons that look like one control) */
.choice { display: flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-2); }
.choice label { flex: 1; justify-content: center; display: flex; align-items: center; padding: 9px 14px; cursor: pointer; color: var(--muted); white-space: nowrap; font-size: .9rem; }
.choice label + label { border-left: 1px solid var(--line); }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice label:has(input:checked) { background: var(--gold-dim); color: var(--gold-2); font-weight: 600; }
.choice label:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: -2px; }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.flash { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; border: 1px solid var(--line); background: var(--panel); }
.flash.error { border-color: var(--down); color: var(--down); background: var(--down-dim); }
.flash.ok { border-color: var(--up); color: var(--up); background: var(--up-dim); }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty h3 { color: var(--text); }
.chart-box { position: relative; height: 300px; }
.chart-box.sm { height: 180px; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--up); box-shadow: 0 0 0 0 rgba(34,197,94,.6); animation: pulse 2s infinite; }
.live-dot.off { background: var(--faint); animation: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }
.disclaimer { font-size: .75rem; color: var(--faint); margin-top: 28px; border-top: 1px solid var(--line); padding-top: 12px; }

/* ---------- Engine: update banner, freshness, toast ---------- */
.update-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 7px 10px 7px 14px; margin: -8px 0 16px;
  border: 1px solid var(--gold); border-radius: var(--radius-sm); background: var(--gold-dim); color: var(--gold-2); font-size: .85rem; font-weight: 500; }
.update-banner[hidden] { display: none; }
.update-banner svg { width: 16px; height: 16px; flex: none; }
.update-banner .update-text { flex: 1 1 220px; min-width: 0; }
.freshness { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .78rem; line-height: 1.3; }
.freshness .fresh-next { display: inline-block; white-space: nowrap; }
.freshness .live-dot { width: 7px; height: 7px; flex: none; }
.toast { position: fixed; z-index: 50; right: 20px; bottom: 20px; padding: 9px 14px; border-radius: var(--radius-sm); background: var(--panel-2);
  border: 1px solid var(--line); border-left: 3px solid var(--gold); color: var(--text); font-size: .85rem; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: none; }
@media (max-width: 820px) { .toast { left: 16px; right: 16px; bottom: 16px; } .update-banner { margin-top: 0; } }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(212,175,55,.12), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { justify-content: center; padding-bottom: 8px; }

/* ---------- Responsive ---------- */
.btn.mobile-nav-toggle { display: none; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; background: none; }
  .sidebar { position: fixed; z-index: 20; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .btn.mobile-nav-toggle { display: inline-flex; }
  .main { padding: 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: auto; }
}

/* "Enter the Island" button (Dashboard) and the portal it opens before /island loads */
.island-portal-btn { position: relative; display: inline-flex; align-items: center; gap: 8px; border-color: var(--gold);
  background: linear-gradient(120deg, rgba(212, 175, 55, .18), rgba(138, 92, 255, .22)); }
.island-portal-btn .ip-ring { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--gold);
  box-shadow: 0 0 8px var(--gold), inset 0 0 6px #8a5cff; animation: ipSpin 2.4s linear infinite; }
@keyframes ipSpin { 0% { transform: rotate(0) scale(1); } 50% { transform: rotate(180deg) scale(1.15); } 100% { transform: rotate(360deg) scale(1); } }
.portal-go { position: fixed; inset: 0; z-index: 9999; pointer-events: none; display: grid; place-items: center; }
.portal-go::before { content: ""; width: 40px; height: 40px; border-radius: 50%;
  background: radial-gradient(circle, #fff 0, rgba(212, 175, 55, .95) 25%, rgba(138, 92, 255, .9) 50%, #0b0d12 72%);
  box-shadow: 0 0 60px 20px rgba(138, 92, 255, .6); animation: portalGo .9s ease-in forwards; }
@keyframes portalGo { 0% { transform: scale(.2) rotate(0); } 100% { transform: scale(80) rotate(540deg); } }
@media (prefers-reduced-motion: reduce) { .island-portal-btn .ip-ring, .portal-go::before { animation: none; } }
