/*
 * StreamBot control panel — component kit. IBM Plex type, light/dark via [data-theme].
 * Flat depth: surface alternation + 1px hairlines (+ a soft shadow in light only).
 * Type-led hierarchy; uppercase IBM Plex Mono section labels.
 */
@import "/static/tokens.css";

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
body, .sidebar, .card, .tile, .topbar, .iconbtn, input, select, textarea, .btn, .nav a {
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.015em; margin: 0; }

*:focus { outline: none; }
:where(a, button, .btn, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-xs);
}

.ic { width: 18px; height: 18px; flex: 0 0 auto; }
.eyebrow {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted);
}

/* icon buttons */
.iconbtn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  background: transparent; border: 1px solid transparent; border-radius: var(--r-sm);
  color: var(--muted); cursor: pointer;
}
.iconbtn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--hairline); }
.theme-toggle .ic-moon { display: none; }
[data-theme="light"] .theme-toggle .ic-sun { display: none; }
[data-theme="light"] .theme-toggle .ic-moon { display: block; }
.theme-toggle.floating { position: fixed; top: var(--s-6); right: var(--s-6); z-index: 5; }

/* brand mark */
.brand-mark {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: 0 0 auto;
  background: var(--accent); color: var(--on-accent); border-radius: var(--r-sm);
  font-family: var(--font-mono); font-weight: 600; font-size: 14px; letter-spacing: -0.02em;
}
.brand-mark.lg { width: 52px; height: 52px; font-size: 20px; margin: 0 auto var(--s-4); }

/* ── shell ─────────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--surface-1); border-right: 1px solid var(--hairline);
  display: flex; flex-direction: column; padding: var(--s-6) var(--s-5);
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3) var(--s-7); }
.brand-name { display: flex; flex-direction: column; font-family: var(--font-display);
  font-weight: 600; font-size: 16px; letter-spacing: -0.01em; line-height: 1.1; }
.brand-name small { font-family: var(--font-mono); font-size: 9px; font-weight: 400;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }

.nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3); border-radius: var(--r-sm);
  color: var(--muted); font-size: 14px; font-weight: 500;
}
.nav a .ic { opacity: .85; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--ink); }
.nav a.on .ic { color: var(--accent); opacity: 1; }
.nav .group { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--slate); margin: var(--s-6) var(--s-3) var(--s-2); }

.userbox {
  border-top: 1px solid var(--hairline); margin-top: var(--s-5); padding: var(--s-4) var(--s-3) 0;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
}
.userbox .who { display: flex; flex-direction: column; min-width: 0; }
.userbox .who b { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 1px 7px; border-radius: var(--r-full); width: fit-content; margin-top: 3px; border: 1px solid; }
.tag-owner { color: var(--accent-bright); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.tag-mod { color: var(--muted); border-color: var(--hairline); }
.logout-form { margin: 0; }

/* ── content ───────────────────────────────────────────────────────────── */
.content { flex: 1; min-width: 0; }
.topbar { padding: var(--s-6) var(--s-9); border-bottom: 1px solid var(--hairline);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); }
.topbar-left { display: flex; align-items: center; gap: var(--s-4); }
.topbar-title { display: flex; flex-direction: column; gap: var(--s-1); }
.topbar-title h1 { font-size: 24px; }
.topbar-actions { display: flex; align-items: center; gap: var(--s-3); }
.nav-toggle { display: none; }
.scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 15; }
.page { padding: var(--s-9); max-width: var(--maxw); }
.section-label { display: block; margin: var(--s-9) 0 var(--s-4); }

/* ── KPI cards ─────────────────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s-4); }
.card { background: var(--surface-1); border: 1px solid var(--card-border);
  border-radius: var(--r-md); padding: var(--s-6); box-shadow: var(--shadow); }
.kpi { display: flex; align-items: center; gap: var(--s-4); }
.kpi-ic { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto;
  background: var(--accent-soft); color: var(--accent); border-radius: var(--r-sm); }
.kpi .num { font-family: var(--font-display); font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1; }
.kpi .lbl { color: var(--muted); font-size: 13px; margin-top: 3px; }

/* ── jump tiles ────────────────────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s-4); }
.tile { display: flex; flex-direction: column; gap: 2px; padding: var(--s-6);
  background: var(--surface-1); border: 1px solid var(--card-border); border-radius: var(--r-md);
  box-shadow: var(--shadow); }
.tile .ic { width: 22px; height: 22px; color: var(--accent); margin-bottom: var(--s-3); }
.tile b { font-size: 15px; font-weight: 600; }
.tile span { color: var(--muted); font-size: 13px; }
.tile:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--card-border)); }

/* ── tables ────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
  padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--hairline); }
.table td { padding: var(--s-4); border-bottom: 1px solid var(--hairline); font-size: 14px; }
.table tr:hover td { background: var(--surface-1); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.rank { color: var(--muted); font-variant-numeric: tabular-nums; width: 2.5rem; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }

/* two-column page layout (stacks on mobile) */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-8); align-items: start; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; gap: var(--s-7); } }
.mt { margin-top: var(--s-6); }

/* key-value rows (activity cards) */
.kv { display: flex; justify-content: space-between; gap: var(--s-4); align-items: center;
  padding: var(--s-3) 0; border-bottom: 1px solid var(--hairline); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv > span:first-child { color: var(--muted); flex: 0 0 auto; }
.kv > b { text-align: right; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* live indicator */
.live-line { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); font-size: 15px; }
.live-dot { width: 9px; height: 9px; border-radius: var(--r-full); background: var(--muted); flex: 0 0 auto; }
.live-dot.on { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 28%, transparent); }

/* ── pills / filters ───────────────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-4);
  border-radius: var(--r-full); font-size: 12px; border: 1px solid var(--hairline); color: var(--muted); }
.pill .ic { width: 14px; height: 14px; }
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
.pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.filters { display: flex; gap: var(--s-3); flex-wrap: wrap; }
.filters a { padding: 6px 16px; border-radius: var(--r-pill); border: 1px solid var(--hairline);
  color: var(--muted); font-size: 13px; }
.filters a.on { border-color: var(--accent); color: var(--ink); }

/* ── buttons ───────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-body); font-size: 14px; font-weight: 600; padding: 10px 20px;
  border-radius: var(--r-sm); border: 1px solid transparent; cursor: pointer; }
.btn .ic { width: 18px; height: 18px; }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { opacity: .9; }
.btn-accent { background: var(--accent-btn); color: var(--on-accent); }
.btn-accent:hover { background: var(--accent-btn-hover); }
.btn-outline { background: transparent; border-color: var(--hairline); color: var(--ink); }
.btn-outline:hover { border-color: var(--ink); }

/* ── forms ─────────────────────────────────────────────────────────────── */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input, select, textarea { width: 100%; background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--hairline); border-radius: var(--r-sm); padding: 10px 12px; font: inherit; font-size: 14px; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft); }
.field { margin-bottom: var(--s-5); }
.help { color: var(--slate); font-size: 12px; margin-top: 4px; }

/* ── empty state ───────────────────────────────────────────────────────── */
.empty { text-align: center; padding: var(--s-12) var(--s-6); color: var(--muted);
  border: 1px dashed var(--hairline); border-radius: var(--r-md); background: var(--surface-1); }
.empty-ic { display: inline-grid; place-items: center; width: 56px; height: 56px;
  background: var(--accent-soft); color: var(--accent); border-radius: var(--r-md); margin-bottom: var(--s-5); }
.empty-ic .ic { width: 26px; height: 26px; }
.empty h2 { color: var(--ink); margin-bottom: var(--s-3); font-size: 20px; }

/* ── login ─────────────────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: var(--s-6); }
.login-card { background: var(--surface-1); border: 1px solid var(--card-border); border-radius: var(--r-md);
  padding: var(--s-10) var(--s-9); width: 380px; text-align: center; box-shadow: var(--shadow); }
.login-title { font-size: 24px; margin-bottom: 2px; }
.btn-discord { width: 100%; margin-top: var(--s-7); background: var(--accent-btn); color: var(--on-accent); }
.btn-discord:hover { background: var(--accent-btn-hover); }
.error { background: color-mix(in srgb, var(--bad) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--bad) 45%, transparent); color: var(--bad-text);
  padding: 10px 12px; border-radius: var(--r-sm); margin: var(--s-5) 0; font-size: 13px; text-align: left; }

.muted { color: var(--muted); }
code { font-family: var(--font-mono); background: var(--surface-2); padding: 1px 6px; border-radius: var(--r-xs); }

@media (max-width: 820px) {
  .sidebar { position: fixed; transform: translateX(-100%); z-index: 20; transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .scrim.show { display: block; }
  .nav-toggle { display: inline-grid; }
  .page, .topbar { padding-left: var(--s-5); padding-right: var(--s-5); }
}
