/* ---------- design tokens ---------- */
:root {
  --bg: #f3f5fa; --surface: #ffffff; --surface-2: #f8f9fc; --ink: #0c1322; --muted: #5d687d; --faint: #8a94a8; --line: #e5e9f1;
  --brand: #0a6cff; --brand-ink: #ffffff; --brand-soft: #e8f1ff;
  --good: #0f9b57; --bad: #e0393e; --warn: #c97800; --violet: #6a4df0;
  --good-soft: #e5f6ed; --bad-soft: #fdebec; --warn-soft: #fdf2dc; --violet-soft: #eeeaff; --idle-soft: #eef0f5;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px -12px rgba(16, 24, 40, .12);
  --radius: 16px;
  --splash: #fcfcfc; /* same as the intro GIF's background, so it blends in */
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --logo-filter: none;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #080c14; --surface: #101725; --surface-2: #0c1220; --ink: #e9eefa; --muted: #93a0b8; --faint: #66738c; --line: #1c2740;
    --brand: #4d8dff; --brand-ink: #06101f; --brand-soft: #14264a;
    --good: #3ccf86; --bad: #ff6b70; --warn: #f0b04f; --violet: #a28dff;
    --good-soft: #10291d; --bad-soft: #36161a; --warn-soft: #30240d; --violet-soft: #231d45; --idle-soft: #172033;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 28px -14px rgba(0, 0, 0, .6);
    --splash: #0a0a0a;
    --logo-filter: invert(1) hue-rotate(180deg);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14.5px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 13.5px; font-weight: 650; }
p { margin: 0 0 8px; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.small { font-size: 12.5px; } .mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--good); } .neg { color: var(--bad); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 8px; }

/* ---------- splash (load animation) ---------- */
#splash { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--splash);
  transition: opacity .5s ease, visibility .5s; }
#splash.done { opacity: 0; visibility: hidden; }
.splash-gif { width: min(768px, 94vw); height: auto; display: block; }
#splash .splash-fallback { display: none; }
#splash.fallback .splash-fallback { display: grid; }
#splash.fallback .splash-gif { display: none; }
.splash-inner { display: grid; justify-items: center; gap: 18px; }
/* the logo is two layers: the black 8 draws itself outward, then the blue arrow sweeps up and to the right and keeps floating */
.logo-stack { position: relative; height: 150px; aspect-ratio: 438 / 520; filter: var(--logo-filter); }
.logo-stack img { position: absolute; inset: 0; width: 100%; height: 100%; }
.l8 { animation: draw8 1.5s cubic-bezier(.5, 0, .2, 1) both; }
.larrow { animation: sweep 1.2s .95s cubic-bezier(.3, .7, .2, 1) both, bob 2.4s 2.3s ease-in-out infinite alternate; }
@keyframes draw8 { from { clip-path: circle(0% at 50% 50%); opacity: .2; } to { clip-path: circle(75% at 50% 50%); opacity: 1; } }
@keyframes sweep { from { clip-path: polygon(0 100%, 0 100%, 0 100%); } to { clip-path: polygon(0 100%, 230% 100%, 0 -130%); } }
@keyframes bob { from { transform: translate(0, 0); } to { transform: translate(5px, -5px); } }
.splash-name { font-weight: 700; font-size: 20px; letter-spacing: .02em; animation: fade-up .8s 1.6s ease both; }
.splash-name span { color: var(--brand); }
.splash-sub { color: var(--muted); font-size: 12.5px; letter-spacing: .14em; text-transform: uppercase; margin-top: -10px; animation: fade-up .8s 1.8s ease both; }
.splash-bar { width: 168px; height: 3px; border-radius: 99px; background: var(--line); overflow: hidden; animation: fade-up .6s 1.5s ease both; }
.splash-bar i { display: block; height: 100%; width: 40%; border-radius: 99px; background: var(--brand); animation: slide 1.1s ease-in-out infinite; }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes slide { from { transform: translateX(-110%); } to { transform: translateX(350%); } }
/* the opening intro always plays (Windows turns "reduce motion" on in remote sessions and power saving); page transitions respect it */
@media (prefers-reduced-motion: reduce) { .tab, .live.good .dot { animation: none !important; } }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; padding: 20px 14px;
  background: var(--surface); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; }
.brand img { height: 42px; width: auto; filter: var(--logo-filter); }
.brand b { display: block; font-size: 15px; letter-spacing: -.01em; line-height: 1.2; }
.brand span { font-size: 11.5px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .09em; color: var(--faint); padding: 14px 12px 6px; }
.nav button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border: 0; border-radius: 10px; background: none;
  color: var(--muted); font-weight: 550; text-align: left; transition: background .15s, color .15s; }
.nav button svg { width: 19px; height: 19px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav button:hover { background: var(--idle-soft); color: var(--ink); }
.nav button.active { background: var(--brand-soft); color: var(--brand); }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-weight: 700; flex: none; text-transform: uppercase; }
.me b { display: block; line-height: 1.2; overflow-wrap: anywhere; } .me span { font-size: 12px; color: var(--muted); }
.foot-actions { display: flex; gap: 8px; }
.foot-actions > * { flex: 1 1 0; min-width: 0; margin: 0; } .foot-actions button { width: 100%; white-space: nowrap; padding: 7px 6px; }

.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 14px; padding: 14px 28px;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 20px; font-weight: 700; }
.topbar .sub { color: var(--muted); font-size: 13px; }
.topbar .grow { flex: 1; }
.live { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.live.good .dot { background: var(--good); box-shadow: 0 0 0 0 var(--good); animation: pulse 2s infinite; }
.live.violet .dot { background: var(--violet); } .live.warn .dot { background: var(--warn); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 8px transparent; } }
.content { padding: 24px 28px 48px; max-width: 1360px; margin: 0 auto; }
.tab { display: none; } .tab.active { display: block; animation: view-in .35s ease both; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.banner { margin: 16px 28px 0; padding: 11px 16px; border-radius: 12px; background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- building blocks ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head .hint { color: var(--muted); font-size: 12.5px; }
.grid { display: grid; gap: 16px; } .gap { margin-top: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.cols { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } .cols-even { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.stack > * + * { margin-top: 16px; }
.kpi { position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--accent, var(--brand)); opacity: .9; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
.kpi .value { font-size: 30px; font-weight: 750; letter-spacing: -.02em; margin: 6px 0 4px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.chart { position: relative; height: 290px; } .chart.sm { height: 230px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 650; background: var(--idle-soft); color: var(--muted); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); } .badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); } .badge.accent { background: var(--brand-soft); color: var(--brand); }
.badge.violet { background: var(--violet-soft); color: var(--violet); }

button.primary, .primary { background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 10px; padding: 8px 16px; font-weight: 650; }
button.primary:hover { filter: brightness(1.07); } button.wide { width: 100%; padding: 11px; margin-top: 14px; }
.ghost { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; font-weight: 550; }
.ghost:hover { border-color: var(--brand); color: var(--brand); }
button.danger { background: none; color: var(--bad); border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; }
button.danger:hover { background: var(--bad-soft); }
button.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 4px; }
input, select { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; }
input:focus, select:focus { border-color: var(--brand); outline: 0; box-shadow: 0 0 0 3px var(--brand-soft); }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; margin-bottom: 16px; }
.toolbar label { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 550; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--idle-soft); border-radius: 12px; }
.chip { border: 0; background: none; border-radius: 9px; padding: 6px 13px; font-size: 13px; font-weight: 600; color: var(--muted); }
.chip.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(16, 24, 40, .12); }

.meter { height: 7px; border-radius: 99px; background: var(--idle-soft); overflow: hidden; margin-top: 5px; }
.meter > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand), color-mix(in srgb, var(--brand) 60%, var(--violet))); }
.meter.hot > span { background: var(--warn); }
.counter + .counter { margin-top: 13px; } .counter .row { display: flex; justify-content: space-between; font-size: 13.5px; }
.pillrow { display: flex; flex-wrap: wrap; gap: 6px; }

table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 650; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
tr:last-child td { border-bottom: 0; } tbody tr:hover td { background: var(--surface-2); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; margin: 0 -8px; padding: 0 8px; }

/* alerts */
.feed > * + * { border-top: 1px solid var(--line); }
.feed-item { display: flex; gap: 12px; padding: 12px 0; align-items: flex-start; }
.feed-item:first-child { padding-top: 0; } .feed-item:last-child { padding-bottom: 0; }
.ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--idle-soft); font-size: 16px; }
.feed-item b { display: block; line-height: 1.35; } .feed-item .when { color: var(--muted); font-size: 12.5px; }
.alert { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; box-shadow: var(--shadow); }
.alert > summary { list-style: none; cursor: pointer; padding: 14px 18px; display: flex; gap: 10px 12px; align-items: center; flex-wrap: wrap; }
.alert > summary::-webkit-details-marker { display: none; }
.alert .title { font-weight: 650; flex: 1; min-width: 220px; }
.alert .body { padding: 0 18px 16px; border-top: 1px solid var(--line); }
.msg { white-space: pre-wrap; word-break: break-word; margin-top: 14px; }
.msg pre { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); padding: 10px 12px; border-radius: 10px; overflow-x: auto; margin: 8px 0; white-space: pre; }
.odds { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }

.story { border-left: 3px solid var(--line); padding: 4px 0 4px 14px; margin: 14px 0; }
.story.escalating { border-color: var(--bad); } .story.building { border-color: var(--warn); } .story.stable { border-color: var(--brand); } .story.easing { border-color: var(--good); }
.story ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 13.5px; }

/* performance */
.stat .value { font-size: 34px; }
.bar2 { display: grid; gap: 8px; margin-top: 12px; }
.bar2 .row { display: grid; grid-template-columns: 82px 1fr 44px; gap: 10px; align-items: center; font-size: 12.5px; color: var(--muted); }
.bar2 .track { height: 8px; border-radius: 99px; background: var(--idle-soft); overflow: hidden; } .bar2 .track i { display: block; height: 100%; border-radius: 99px; }
.empty { color: var(--muted); padding: 34px 16px; text-align: center; }
.empty b { display: block; color: var(--ink); margin-bottom: 4px; }
.note { color: var(--muted); font-size: 12.5px; margin-top: 12px; }

.logview { background: #0b1220; color: #d7e0f2; border-radius: var(--radius); padding: 16px; margin: 0; font: 12.5px/1.5 var(--mono); max-height: 70vh; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.logview .warn { color: #f5c26b; } .logview .err { color: #ff8b8b; }

dialog { border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--ink); width: min(430px, calc(100% - 32px)); padding: 24px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .45); }
dialog::backdrop { background: rgba(8, 12, 20, .55); backdrop-filter: blur(3px); }
dialog label { display: block; margin: 14px 0 5px; font-weight: 600; } dialog input:not([type=checkbox]) { width: 100%; }
dialog .check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; margin-top: 14px; }
dialog .check input { margin-top: 4px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.tempbox { margin: 14px 0 4px; padding: 14px; border-radius: 12px; background: var(--warn-soft); border: 1px dashed var(--warn); text-align: center; }
.tempbox code { display: block; font: 700 20px var(--mono); letter-spacing: .04em; margin: 6px 0 10px; user-select: all; }
.error { color: var(--bad); margin: 10px 0 0; font-weight: 550; } .hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.actions button { font-size: 12.5px; padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.actions button:hover { border-color: var(--brand); color: var(--brand); } .actions button.danger { color: var(--bad); }
.actions button.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; align-items: end; }
.form-grid label { display: grid; gap: 6px; color: var(--muted); font-weight: 600; font-size: 12.5px; } .form-grid input, .form-grid select { width: 100%; color: var(--ink); }
.check-inline { display: flex !important; grid-auto-flow: column; align-items: center; justify-content: start; gap: 8px; font-weight: 550 !important; color: var(--ink) !important; font-size: 13.5px !important; }

/* ---------- sign-in / set password ---------- */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(900px 500px at 15% -10%, color-mix(in srgb, var(--brand) 14%, transparent), transparent 60%),
              radial-gradient(800px 500px at 100% 110%, color-mix(in srgb, var(--violet) 12%, transparent), transparent 60%), var(--bg); }
.auth-card { width: min(410px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 34px 30px 28px; box-shadow: var(--shadow); animation: fade-up .6s .1s ease both; }
.auth-logo { height: 70px; width: auto; display: block; margin: 0 auto 14px; filter: var(--logo-filter); }
.auth-card h1 { text-align: center; font-size: 21px; } .auth-card > .muted { text-align: center; margin: 6px 0 18px; }
.auth-card label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 13px; }
.auth-card input { width: 100%; padding: 11px 13px; border-radius: 12px; }
.auth-alt { text-align: center; margin-top: 14px; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { scrollbar-width: none; position: sticky; z-index: 6; height: auto; flex-direction: row; align-items: center; gap: 10px; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .brand { padding: 0 6px 0 0; } .brand img { height: 34px; } .brand span, .nav-label, .me b, .me span { display: none; }
  .nav { flex-direction: row; gap: 2px; } .nav button { width: auto; padding: 8px 11px; white-space: nowrap; } .nav button span { display: none; }
  .nav button.active span { display: inline; }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; display: flex; align-items: center; gap: 8px; }
  .topbar { position: static; padding: 14px 16px; flex-wrap: wrap; } .content { padding: 16px 16px 40px; } .banner { margin: 12px 16px 0; }
  .cols { grid-template-columns: 1fr; } .cols-even { grid-template-columns: 1fr; } .chart { height: 240px; }
  .kpi .value { font-size: 26px; }
}
