/* Rally "Control Room" dashboard system, shared by /dashboard and /internal. */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* Control Room: dark navy is the default look. An explicit light
   choice (rally-theme = light, shared with the landing page) swaps
   the same tokens, so nothing below hardcodes a surface color. */
:root {
  --bg: #060833; --panel: #0C1046; --panel-2: #11165A; --raise: rgba(255,255,255,.035);
  --line: rgba(160,168,255,.13); --line-strong: rgba(160,168,255,.24);
  --text: #EEF0FF; --muted: #8F95C9; --faint: #5E64A0;
  --gold: #FCD400; --gold-ink: #060833; --blue: #7C86FF; --prev: #5B62B8;
  --good: #4ADE80; --bad: #FF7A6E; --warn: #FDBA4D;
  --good-bg: rgba(74,222,128,.1); --bad-bg: rgba(255,122,110,.1); --warn-bg: rgba(253,186,77,.1); --blue-bg: rgba(124,134,255,.12);
  --header: rgba(6,8,51,.82); --glow-a: rgba(124,134,255,.18); --glow-b: rgba(252,212,0,.06);
  --invert: #EEF0FF; --invert-ink: #060833;
  --shadow: 0 20px 40px -24px rgba(0,0,0,.6);
}
:root[data-theme="light"] {
  --bg: #F3F4FB; --panel: #FFFFFF; --panel-2: #FFFFFF; --raise: #F6F7FD;
  --line: #E3E5F2; --line-strong: #CFD3EA;
  --text: #0B0F3A; --muted: #62668C; --faint: #9A9EC0;
  --gold: #E0B800; --gold-ink: #0B0F3A; --blue: #3B43C4; --prev: #A9AEE0;
  --good: #15803D; --bad: #C0392B; --warn: #B45309;
  --good-bg: #E7F5EC; --bad-bg: #FBEAE8; --warn-bg: #FEF3E2; --blue-bg: #EEF0FB;
  --header: rgba(243,244,251,.85); --glow-a: rgba(59,67,196,.08); --glow-b: rgba(224,184,0,.07);
  --invert: #0B0F3A; --invert-ink: #FFFFFF;
  --shadow: 0 16px 32px -24px rgba(11,15,58,.25);
}
html { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
body {
  font-family: 'Schibsted Grotesk', system-ui, sans-serif; background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; font-size: 14px; min-height: 100vh;
  background-image: radial-gradient(900px 520px at 88% -12%, var(--glow-a), transparent 60%), radial-gradient(700px 420px at -10% 110%, var(--glow-b), transparent 60%);
  background-attachment: fixed;
}
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Login ---------- */
#login-view { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { position: relative; overflow: hidden; padding: 44px; display: flex; flex-direction: column; justify-content: space-between; border-right: 1px solid var(--line); }
.login-art .rings { position: absolute; right: -300px; top: 50%; transform: translateY(-50%); width: 600px; height: 600px; opacity: .9; }
.login-art h2 { font-size: 44px; font-weight: 700; letter-spacing: -1.4px; line-height: 1.05; max-width: 440px; position: relative; }
.login-art h2 em { font-style: normal; color: var(--gold); }
.login-art p { color: var(--muted); max-width: 380px; margin-top: 14px; line-height: 1.55; position: relative; }
.login-art .foot { color: var(--faint); font-size: 12.5px; position: relative; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.login-card .sub { color: var(--muted); margin: 6px 0 28px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 7px; }
.field input {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--raise); color: var(--text); font: inherit; font-size: 15px; caret-color: var(--gold);
}
.field input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(252,212,0,.15); }
.btn-primary {
  width: 100%; border: 0; border-radius: 12px; padding: 13px; font-weight: 700; font-size: 15px; cursor: pointer;
  background: var(--gold); color: var(--gold-ink); margin-top: 6px; transition: transform .12s, filter .12s;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary[disabled] { opacity: .6; cursor: default; }
#login-error { color: var(--bad); font-size: 13px; margin-top: 12px; min-height: 18px; }
.login-card .hint { color: var(--faint); font-size: 12.5px; margin-top: 22px; line-height: 1.5; }
@media (max-width: 880px) { #login-view { grid-template-columns: 1fr; } .login-art { display: none; } }

/* ---------- Header ---------- */
header.top {
  display: flex; align-items: center; gap: 22px; padding: 14px 32px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20; background: var(--header); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; letter-spacing: -.3px; flex-shrink: 0; }
.brand .mk { width: 28px; height: 28px; border-radius: 8px; background: var(--gold); color: var(--gold-ink); display: grid; place-items: center; font-size: 15px; }
.org-chip { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; font-weight: 600; max-width: 220px; flex-shrink: 0; }
.org-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--good); flex-shrink: 0; }
nav.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
nav.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 8px 13px; border-radius: 9px; color: var(--muted); font-weight: 500; font-size: 13.5px; cursor: pointer; white-space: nowrap; border: 0; background: none; display: flex; align-items: center; gap: 6px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line); }
.tab .ct { background: var(--gold); color: var(--gold-ink); font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 99px; }
.hdr-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: none; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); }
.icon-btn svg { width: 17px; height: 17px; }
.me { position: relative; }
.me-btn { display: flex; align-items: center; gap: 10px; background: none; border: 0; cursor: pointer; padding: 3px; border-radius: 99px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--gold); color: var(--gold-ink); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.me-menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: 240px; background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 14px; padding: 8px; box-shadow: var(--shadow);
}
.me-menu .who { padding: 10px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.me-menu .who b { display: block; font-weight: 600; }
.me-menu .who small { color: var(--muted); font-size: 12px; }
.me-menu button { width: 100%; text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 9px; cursor: pointer; font-size: 13.5px; }
.me-menu button:hover { background: var(--raise); }
@media (max-width: 1100px) { .org-chip { display: none; } }
@media (max-width: 760px) {
  header.top { flex-wrap: wrap; padding: 12px 16px; gap: 10px; }
  nav.tabs { order: 3; width: 100%; }
}

/* ---------- Page ---------- */
main.page { padding: 26px 32px 64px; max-width: 1480px; margin: 0 auto; }
@media (max-width: 760px) { main.page { padding: 18px 16px 48px; } }
.title-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.title-row h1 { font-size: 28px; font-weight: 700; letter-spacing: -.6px; line-height: 1.15; }
.title-row p { color: var(--muted); margin-top: 5px; }
.live-pill { display: inline-flex; align-items: center; gap: 7px; font-family: 'JetBrains Mono', monospace; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; padding: 5px 10px; border-radius: 99px; margin-bottom: 12px; color: var(--muted); border: 1px solid var(--line); }
.live-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.live-pill.on { color: var(--good); border-color: rgba(74,222,128,.3); background: var(--good-bg); }
.live-pill.on i { background: var(--good); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(74,222,128,.55); } 100% { box-shadow: 0 0 0 9px rgba(74,222,128,0); } }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: var(--raise); }
.seg button { background: none; border: 0; color: var(--muted); font-size: 12.5px; padding: 6px 12px; border-radius: 7px; cursor: pointer; }
.seg button.on { background: var(--invert); color: var(--invert-ink); font-weight: 600; }

.bento { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: 18px;
  padding: 20px; position: relative; min-width: 0;
}
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; } .span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; } .span-3 { grid-column: span 3; }
@media (max-width: 1180px) { .span-3 { grid-column: span 6; } .span-4 { grid-column: span 6; } }
@media (max-width: 1000px) { .span-8, .span-7, .span-6, .span-5 { grid-column: span 12; } }
@media (max-width: 640px) { .span-3, .span-4 { grid-column: span 12; } }
.lbl { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.1px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.lbl .aside { text-transform: none; letter-spacing: 0; font-weight: 500; }
.lbl a, .link { color: var(--gold); text-transform: none; letter-spacing: 0; font-weight: 600; font-size: 12.5px; cursor: pointer; background: none; border: 0; }
:root[data-theme="light"] .lbl a, :root[data-theme="light"] .link { color: var(--blue); }
.card-title { font-size: 16px; font-weight: 700; letter-spacing: -.2px; }

/* stat cards */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stats.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1180px) { .stats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .stats, .stats.three { grid-template-columns: 1fr; } }
.stat b { display: block; font-size: 34px; font-weight: 700; letter-spacing: -1.2px; margin: 12px 0 4px; line-height: 1.05; }
.stat .s { font-size: 12.5px; color: var(--muted); }
.up { color: var(--good); font-weight: 600; } .dn { color: var(--bad); font-weight: 600; }

/* now card */
.now { display: flex; flex-direction: column; }
.gauge { position: relative; width: 236px; height: 236px; margin: 16px auto 6px; }
.gauge svg { width: 100%; height: 100%; }
.gauge .arc { transition: stroke-dashoffset 1s cubic-bezier(.2,.8,.2,1); }
.gauge .c { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.gauge .c b { font-size: 60px; font-weight: 800; letter-spacing: -2.5px; line-height: 1; }
.gauge .c small { color: var(--muted); font-family: 'JetBrains Mono', monospace; font-size: 11.5px; margin-top: 6px; }
.now h2 { font-size: 20px; font-weight: 700; margin-top: 8px; letter-spacing: -.3px; }
.now .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.also { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.also button { border: 1px solid var(--line); background: var(--raise); border-radius: 99px; padding: 5px 11px; font-size: 12px; cursor: pointer; color: var(--muted); }
.also button.on { border-color: var(--gold); color: var(--text); }
.feed { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.feed .row { display: flex; gap: 10px; align-items: center; font-size: 13px; min-width: 0; animation: slidein .35s ease both; }
@keyframes slidein { from { opacity: 0; transform: translateY(-4px); } }
.feed .t { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--muted); width: 44px; flex-shrink: 0; }
.feed .d { width: 6px; height: 6px; border-radius: 50%; background: var(--good); flex-shrink: 0; }
.feed .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed .br { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; padding-left: 8px; }

/* charts */
.chart { position: relative; margin-top: 14px; }
.chart svg { width: 100%; display: block; overflow: visible; }
.chart .tip {
  position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 8px 10px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%); box-shadow: var(--shadow); opacity: 0; transition: opacity .12s;
}
.chart .tip b { font-family: 'JetBrains Mono', monospace; font-size: 13px; }
.chart .tip small { color: var(--muted); display: block; }
.key { display: inline-flex; align-items: center; gap: 6px; }
.key i { display: inline-block; width: 12px; height: 2px; border-radius: 2px; }

/* branch rings */
.rank-row { display: flex; align-items: center; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.rank-row:last-child { border-bottom: 0; }
.rank-row.click { cursor: pointer; border-radius: 10px; }
.rank-row.click:hover { background: var(--raise); }
.rank-row .rk { font-family: 'JetBrains Mono', monospace; color: var(--faint); font-size: 12px; width: 20px; flex-shrink: 0; }
.rank-row .n { flex: 1; font-weight: 600; min-width: 0; }
.rank-row .n small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.rank-row .v { font-family: 'JetBrains Mono', monospace; font-weight: 600; min-width: 52px; text-align: right; }
.ring { width: 40px; height: 40px; flex-shrink: 0; }

/* queue */
.queue { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--raise); border: 1px solid var(--line); margin-top: 10px; cursor: pointer; text-align: left; width: 100%; }
.queue:hover { border-color: var(--line-strong); }
.queue .n { font-size: 22px; font-weight: 800; min-width: 40px; text-align: center; }
.queue b { font-weight: 600; display: block; }
.queue small { display: block; color: var(--muted); font-size: 12px; }
.queue .go { margin-left: auto; color: var(--gold); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
:root[data-theme="light"] .queue .go { color: var(--blue); }
.all-clear { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 28px 10px; color: var(--muted); }
.all-clear .ok { width: 44px; height: 44px; border-radius: 50%; background: var(--good-bg); color: var(--good); display: grid; place-items: center; font-size: 20px; }

/* people list */
.person { display: flex; align-items: center; gap: 11px; padding: 9px 0; min-width: 0; }
.pa { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; flex-shrink: 0; color: #fff; }
.person b { font-weight: 600; font-size: 13.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .pc { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }

/* podium */
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 14px; align-items: end; margin-bottom: 14px; }
.pod { text-align: center; padding: 22px 16px 18px; }
.pod .pa { width: 56px; height: 56px; font-size: 17px; margin: 0 auto 12px; }
.pod .place { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--muted); letter-spacing: 1px; }
.pod b { display: block; font-size: 16px; font-weight: 700; margin: 4px 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod .rate { font-size: 30px; font-weight: 800; letter-spacing: -1px; }
.pod.first { border-color: rgba(252,212,0,.5); padding-top: 34px; }
.pod.first .pa { box-shadow: 0 0 0 3px var(--gold); }
@media (max-width: 640px) { .podium { grid-template-columns: 1fr; } }

/* tables */
.table-wrap { overflow-x: auto; margin: 6px -20px -8px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; }
th:first-child, td:first-child { padding-left: 0; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--raise); }
td.num, th.num { text-align: right; font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }
td .strong { font-weight: 600; }
.nil { color: var(--faint); }
.bar { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; min-width: 80px; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--gold); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; text-transform: capitalize; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.info { background: var(--blue-bg); color: var(--blue); }
.badge.neutral { background: var(--raise); color: var(--muted); }

/* toolbar / sub tabs */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.search { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--raise); min-width: 240px; flex: 0 1 320px; }
.search svg { width: 15px; height: 15px; color: var(--muted); flex-shrink: 0; }
.search input { border: 0; background: none; outline: none; color: var(--text); font: inherit; font-size: 13.5px; width: 100%; caret-color: var(--gold); }
.subtabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); margin: 4px 0 6px; overflow-x: auto; }
.subtabs button { background: none; border: 0; padding: 10px 0; color: var(--muted); cursor: pointer; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.subtabs button.on { color: var(--text); border-bottom-color: var(--gold); }
.subtabs .ct { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--faint); }

/* events */
.event-row { display: flex; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.event-row:last-child { border-bottom: 0; }
.event-row.click { cursor: pointer; }
.event-row.click:hover .ev-name { color: var(--gold); }
.date-block { width: 54px; flex-shrink: 0; border: 1px solid var(--line); border-radius: 12px; text-align: center; padding: 6px 0; background: var(--raise); }
.date-block small { display: block; font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--gold); text-transform: uppercase; letter-spacing: .8px; }
:root[data-theme="light"] .date-block small { color: var(--bad); }
.date-block b { font-size: 21px; font-weight: 800; line-height: 1.1; }
.ev-name { font-weight: 600; font-size: 14.5px; }
.ev-meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.event-row .right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

/* drawer */
.scrim { position: fixed; inset: 0; background: rgba(3,4,26,.55); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw); background: var(--bg); border-left: 1px solid var(--line-strong);
  z-index: 41; transform: translateX(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 24px 16px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 22px; font-weight: 700; letter-spacing: -.4px; }
.drawer-head p { color: var(--muted); margin-top: 4px; font-size: 13px; }
.drawer-body { padding: 20px 24px 40px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.drawer .stats { grid-template-columns: repeat(2, 1fr); }
.kv { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; font-family: 'JetBrains Mono', monospace; }

.empty { color: var(--muted); font-size: 13.5px; padding: 30px 10px; text-align: center; line-height: 1.5; }
.empty b { display: block; color: var(--text); font-size: 14.5px; margin-bottom: 4px; }
.note { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.skeleton { border-radius: 18px; background: linear-gradient(90deg, var(--panel) 0%, var(--panel-2) 50%, var(--panel) 100%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border: 1px solid var(--line); }
@keyframes shimmer { to { background-position: -200% 0; } }
.error-card { border-color: rgba(255,122,110,.35); color: var(--muted); }
.error-card b { color: var(--text); display: block; margin-bottom: 4px; }
