/* =========================================================================
   Hydra Server admin — design system
   =========================================================================
   Two layers of colour, kept apart on purpose:

   * UI chrome (violet) — navigation, buttons, focus. Identity, never data.
   * Data ink (the --series-* slots) — assigned to a category in fixed order
     so a category keeps its colour when it shrinks, and validated for
     colour-vision separation against both surfaces. Never recycled for
     chrome, never reordered by size.

   Status colours are a third, reserved set: they always ship with a label,
   never as colour alone.
   ====================================================================== */

:root {
  color-scheme: dark;

  --bg: #0b0b10;
  --surface-1: #14141b;
  --surface-2: #1b1b25;
  --surface-3: #23232f;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  --text: #f3f3f7;
  --text-2: #a6a6bb;
  --text-muted: #6f6f88;

  --accent: #8b7bff;
  --accent-hover: #9d90ff;
  --accent-ink: #ffffff;
  --accent-weak: rgba(139, 123, 255, 0.16);
  --accent-line: rgba(139, 123, 255, 0.42);

  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;

  /* Categorical data slots, dark-surface steps, in fixed assignment order.
     Validated as a set against this surface: lightness band, chroma floor,
     colour-vision separation of adjacent pairs, and 3:1 contrast. */
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;

  /* Sequential ramp (magnitude), stepped for a dark surface: away from the
     surface means more. */
  --heat-0: rgba(255, 255, 255, 0.05);
  --heat-1: #184f95;
  --heat-2: #256abf;
  --heat-3: #3987e5;
  --heat-4: #86b6ef;

  --grid: rgba(255, 255, 255, 0.07);
  --axis: rgba(255, 255, 255, 0.16);

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -16px rgba(0, 0, 0, 0.8);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 236px;
  --topbar-height: 60px;
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f5f5f8;
  --surface-1: #ffffff;
  --surface-2: #f4f4f8;
  --surface-3: #ebebf1;
  --border: rgba(14, 14, 24, 0.10);
  --border-strong: rgba(14, 14, 24, 0.20);

  --text: #14141c;
  --text-2: #4f4f63;
  --text-muted: #74748c;

  --accent: #5f4ae8;
  --accent-hover: #5238e3;
  --accent-ink: #ffffff;
  --accent-weak: rgba(95, 74, 232, 0.10);
  --accent-line: rgba(95, 74, 232, 0.35);

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;

  --heat-0: rgba(14, 14, 24, 0.06);
  --heat-1: #cde2fb;
  --heat-2: #86b6ef;
  --heat-3: #3987e5;
  --heat-4: #1c5cab;

  --grid: rgba(14, 14, 24, 0.08);
  --axis: rgba(14, 14, 24, 0.18);

  --shadow: 0 1px 2px rgba(14, 14, 24, 0.06), 0 12px 28px -18px rgba(14, 14, 24, 0.35);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--accent-weak); }

/* ---------------------------------------------------------------- layout */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 12px;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--accent), #4ac6e8);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  flex: none;
}

.brand-name { font-weight: 650; letter-spacing: -0.01em; }
.brand-sub { color: var(--text-muted); font-size: 11px; }

.nav { display: grid; gap: 2px; }

.nav-group-label {
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 14px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 13.5px;
  font-family: inherit;
  position: relative;
}

.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item .icon { color: var(--text-muted); flex: none; }
.nav-item[aria-current="page"] { background: var(--accent-weak); color: var(--text); }
.nav-item[aria-current="page"] .icon { color: var(--accent); }
.nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.nav-item .count {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 10px 0;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11.5px;
  display: grid;
  gap: 4px;
}

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar h1 { font-size: 16px; margin: 0; font-weight: 620; letter-spacing: -0.01em; }
.topbar .subtitle { color: var(--text-muted); font-size: 12px; }
.topbar .spacer { flex: 1; }

.content { padding: 24px; display: grid; gap: 20px; align-content: start; }

/* Narrow screens: the sidebar becomes a scrolling strip of icons above the
   content, so the same navigation works without a hamburger menu. */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 10px 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .brand { padding: 0 12px 0 4px; }
  /* Scoped to .sidebar so these beat the element's own display rule
     (.stack sets display:grid at the same specificity, later in the file). */
  .sidebar .brand-text,
  .sidebar .nav-group-label,
  .sidebar .sidebar-footer { display: none; }
  .nav { display: flex; flex-direction: row; gap: 4px; }
  .nav-item { width: auto; white-space: nowrap; }
  .nav-item[aria-current="page"]::before { display: none; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; height: auto; min-height: var(--topbar-height); flex-wrap: wrap; gap: 8px; }
  .topbar .subtitle { display: none; }
  .grid.cols-4, .grid.cols-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------- surfaces */

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  /* A head with a title, a subtitle and two buttons runs out of room on a
     phone; the actions drop to their own line rather than push the page
     sideways. */
  flex-wrap: wrap;
}

.card-head h2 { font-size: 13.5px; margin: 0; font-weight: 620; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px; }
.card-body.tight { padding: 10px 16px; }

.grid { display: grid; gap: 16px; }
/* Grid and flex children default to min-width:auto, which lets a wide table
   or heatmap push the whole page sideways instead of scrolling inside its
   own card. Every layout child opts out. */
.grid > *, .content > *, .main { min-width: 0; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
/* Side-by-side columns size to their own content: a short card next to a
   long one should not grow a field of empty space to match it. */
.grid.split { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1080px) { .grid.split { grid-template-columns: 1fr; } }

.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row .spacer { flex: 1; }
.stack { display: grid; gap: 4px; }

/* ------------------------------------------------------------ stat tiles */

.stat {
  padding: 14px 16px;
  display: grid;
  gap: 2px;
  align-content: start;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

.stat .label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat .value { font-size: 26px; font-weight: 640; letter-spacing: -0.02em; line-height: 1.2; }
.stat .value small { font-size: 14px; font-weight: 500; color: var(--text-2); }
.stat .sub { color: var(--text-muted); font-size: 12px; }
.stat.clickable { cursor: pointer; }
.stat.clickable:hover { border-color: var(--border-strong); }

/* --------------------------------------------------------------- controls */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 40%, transparent); }
.btn.danger:hover { background: color-mix(in srgb, var(--critical) 12%, transparent); }
.btn.ghost { background: none; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.icon-only { padding: 7px; }
.btn[aria-pressed="true"] { border-color: var(--accent); color: var(--text); background: var(--accent-weak); }

.input, .select {
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  min-width: 0;
}

.input::placeholder { color: var(--text-muted); }
.input:disabled, .select:disabled { opacity: 0.5; cursor: not-allowed; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label { color: var(--text-2); font-size: 12px; font-weight: 550; }
.field .hint { color: var(--text-muted); font-size: 11.5px; }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  min-width: 220px;
  flex: 1;
  max-width: 380px;
}

.search .icon { color: var(--text-muted); flex: none; }
.search input {
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 13px;
  padding: 7px 0;
  width: 100%;
  outline: none;
}

.kbd {
  font: inherit;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
  background: var(--surface-1);
  white-space: nowrap;
}

.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 2px; gap: 2px; }
.segmented button {
  border: none;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: 12.5px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--surface-1); color: var(--text); box-shadow: var(--shadow); }

/* ------------------------------------------------------------------ menus */
/* Small panel anchored under its button — the column chooser, for now.
   Right-aligned because these buttons live at the right end of a toolbar. */

.menu-anchor { position: relative; display: inline-flex; }

.menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 200px;
  display: grid;
  gap: 2px;
  padding: 6px;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.menu[hidden] { display: none; }

.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.menu-item:hover { background: var(--surface-2); }
.menu-item input { accent-color: var(--accent); width: 14px; height: 14px; }
.menu-item input:disabled { opacity: 0.5; }
.menu-item .muted { margin-left: auto; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ----------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }

table.data th {
  text-align: left;
  padding: 9px 14px;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface-1);
  position: sticky;
  top: 0;
  z-index: 1;
}

table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--text-2); }
table.data th .sort-arrow { opacity: 0.9; margin-left: 4px; }

table.data td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover td { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data td.actions .btn { margin-left: 4px; }

.subrow td { background: var(--surface-2); padding: 0; border-left: 3px solid var(--accent); }
table.sub { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.sub th { padding: 7px 14px; color: var(--text-muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; text-align: left; }
table.sub td { padding: 7px 14px; border-top: 1px solid var(--border); }

.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}

/* ------------------------------------------------------------ identities */

.identity { display: flex; align-items: center; gap: 10px; min-width: 0; }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-3);
  flex: none;
  display: grid;
  place-items: center;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
}

.avatar.lg { width: 56px; height: 56px; font-size: 18px; }

.identity .name { font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.identity .sub { color: var(--text-muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cover {
  width: 64px;
  height: 30px;
  border-radius: 5px;
  object-fit: cover;
  background: var(--surface-3);
  flex: none;
}

.cover.lg { width: 116px; height: 54px; }

/* A reported souvenir: big enough to judge at a glance, full size a click
   away. */
.report-shot {
  display: block;
  width: 72px;
  height: 40px;
  border-radius: 5px;
  object-fit: cover;
  background: var(--surface-3);
}
.report-shot.lg { width: 320px; height: 180px; }
.report-shot.missing {
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 12px;
}
.report-detail {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  padding: 6px 4px 10px;
}
.report-entry {
  display: grid;
  gap: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.report-entry:last-child { border-bottom: 0; }
.report-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text-2);
}
@media (max-width: 720px) {
  .report-detail { grid-template-columns: 1fr; }
  .report-shot.lg { width: 100%; height: auto; aspect-ratio: 16 / 9; }
}

/* -------------------------------------------------------------- indicators */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 550;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--text-2);
}

.pill.good { background: color-mix(in srgb, var(--good) 16%, transparent); color: color-mix(in srgb, var(--good) 88%, var(--text)); }
.pill.warning { background: color-mix(in srgb, var(--warning) 18%, transparent); color: color-mix(in srgb, var(--warning) 82%, var(--text)); }
.pill.serious { background: color-mix(in srgb, var(--serious) 18%, transparent); color: color-mix(in srgb, var(--serious) 85%, var(--text)); }
.pill.critical { background: color-mix(in srgb, var(--critical) 16%, transparent); color: color-mix(in srgb, var(--critical) 90%, var(--text)); }
.pill.accent { background: var(--accent-weak); color: var(--accent); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.meter { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; min-width: 60px; }
.meter > span { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.meter.warning > span { background: var(--warning); }
.meter.critical > span { background: var(--critical); }

.alert {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  align-items: flex-start;
}

.alert .icon { flex: none; margin-top: 1px; }
.alert.warning { border-color: color-mix(in srgb, var(--warning) 40%, transparent); }
.alert.warning .icon { color: var(--warning); }
.alert.critical { border-color: color-mix(in srgb, var(--critical) 45%, transparent); }
.alert.critical .icon { color: var(--critical); }
.alert.info .icon { color: var(--accent); }
.alert .title { font-weight: 570; font-size: 13px; }
.alert .detail { color: var(--text-2); font-size: 12.5px; }

.empty { display: grid; gap: 8px; justify-items: center; padding: 36px 16px; color: var(--text-muted); text-align: center; }
.empty .icon { color: var(--text-muted); opacity: 0.6; }
.empty .title { color: var(--text-2); font-weight: 550; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
  border-radius: 6px;
  height: 12px;
}

@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

.muted { color: var(--text-muted); }
.text-2 { color: var(--text-2); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.right { text-align: right; }

/* ----------------------------------------------------------------- charts */

.chart { width: 100%; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.chart text { fill: var(--text-muted); font-size: 10.5px; }
.chart .area { opacity: 0.16; }
.chart .line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart .dot { r: 3.5; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.legend .item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; min-width: 0; }
.legend .swatch { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.legend .value { color: var(--text-2); font-variant-numeric: tabular-nums; margin-left: auto; }

.stackbar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--surface-3); gap: 2px; }
.stackbar > span { display: block; height: 100%; }

.barlist { display: grid; gap: 10px; }
.barlist .item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.barlist .track { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.barlist .track > span { display: block; height: 100%; border-radius: 3px; background: var(--series-1); }

.heatmap { display: flex; flex-direction: column; gap: 8px; overflow-x: auto; }
.heatmap-chart { display: flex; gap: 4px; min-width: 620px; }
.heatmap-weekdays { display: flex; flex-direction: column; gap: 3px; padding-top: 15px; }
.heatmap-weekday { flex: 1; display: flex; align-items: center; min-width: 28px; color: var(--text-muted); font-size: 10px; }
.heatmap-weeks { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.heatmap-months { display: flex; gap: 3px; height: 12px; }
.heatmap-month { flex: 1; min-width: 6px; overflow: visible; white-space: nowrap; color: var(--text-muted); font-size: 10px; line-height: 12px; }
.heatmap-grid { display: flex; gap: 3px; }
.heatmap-week { flex: 1; min-width: 6px; display: flex; flex-direction: column; gap: 3px; }
.heatmap-cell { width: 100%; aspect-ratio: 1; border-radius: 2px; background: var(--heat-0); }
.heatmap-cell.l1 { background: var(--heat-1); }
.heatmap-cell.l2 { background: var(--heat-2); }
.heatmap-cell.l3 { background: var(--heat-3); }
.heatmap-cell.l4 { background: var(--heat-4); }
.heatmap-cell.future { background: transparent; }
.heatmap-cell:not(.future):hover { outline: 1px solid var(--border-strong); outline-offset: -1px; }
.heatmap-legend { display: flex; align-items: center; justify-content: flex-end; gap: 3px; color: var(--text-muted); font-size: 10.5px; }
.heatmap-legend .heatmap-cell { flex: none; width: 10px; height: 10px; }

.tooltip {
  position: fixed;
  z-index: 90;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 8px 10px;
  font-size: 12px;
  max-width: 260px;
  display: grid;
  gap: 2px;
}

.tooltip .title { font-weight: 600; }
.tooltip .row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }

/* ------------------------------------------------------------------ tabs */

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button {
  border: none;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count { color: var(--text-muted); font-size: 11.5px; margin-left: 5px; }

/* --------------------------------------------------------------- overlays */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(4, 4, 8, 0.55);
  z-index: 60;
  display: grid;
  overflow: auto;
  animation: fade 0.12s ease-out;
}

@keyframes fade { from { opacity: 0; } }

.modal {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: min(460px, calc(100vw - 32px));
  margin: auto;
  padding: 20px;
  display: grid;
  gap: 14px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
}

.modal h2 { margin: 0; font-size: 15px; }
.modal .body {
  color: var(--text-2);
  font-size: 13px;
  display: grid;
  gap: 10px;
  align-content: start;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
  margin: -4px;
  padding: 4px;
}
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; }

.drawer {
  background: var(--surface-1);
  border-left: 1px solid var(--border);
  width: min(640px, 100vw);
  margin-left: auto;
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  animation: slide-in 0.16s ease-out;
}

@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .drawer, .scrim { animation: none; }
}

.drawer-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.drawer-body { padding: 18px; overflow-y: auto; display: grid; gap: 16px; align-content: start; }

.palette {
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: min(560px, calc(100vw - 32px));
  margin: 12vh auto auto;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: 62vh;
}

.palette-input { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.palette-input input { border: none; background: none; color: inherit; font: inherit; font-size: 15px; width: 100%; outline: none; }
.palette-results { overflow-y: auto; padding: 6px; }
.palette-group { color: var(--text-muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em; padding: 8px 10px 4px; font-weight: 650; }
.palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
}
.palette-item .icon { color: var(--text-muted); }
.palette-item .sub { color: var(--text-muted); font-size: 12px; margin-left: auto; }
.palette-item[data-active="true"] { background: var(--accent-weak); }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; justify-items: end; }

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  font-size: 13px;
  max-width: 380px;
  animation: toast-in 0.16s ease-out;
}

@keyframes toast-in { from { transform: translateY(6px); opacity: 0; } }
.toast.good .icon { color: var(--good); }
.toast.critical .icon { color: var(--critical); }
.toast .icon { flex: none; margin-top: 1px; }

/* ----------------------------------------------------------------- login */

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }

.login-card {
  width: min(380px, 100%);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  display: grid;
  gap: 14px;
}

.login-card h1 { font-size: 17px; margin: 0; }
.login-card .input { width: 100%; padding: 10px 12px; font-size: 14px; }
.login-card .error { color: var(--critical); font-size: 12.5px; min-height: 17px; }

/* ------------------------------------------------------------ misc pieces */

.kv { display: grid; grid-template-columns: minmax(120px, auto) minmax(0, 1fr); gap: 8px 16px; font-size: 13px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; word-break: break-word; }

.danger-zone { border-color: color-mix(in srgb, var(--critical) 35%, var(--border)); }
.danger-zone .card-head h2 { color: var(--critical); }

.checkline { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 6px 0; }
.checkline input { accent-color: var(--accent); width: 15px; height: 15px; }

.hero-figure { font-size: 34px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; }

/* ----------------------------------------------------------------- portal */
/* The player's view has no sidebar — one centred column, the same cards. */
.portal-shell { max-width: 1080px; margin: 0 auto; padding: 0 16px 48px; }
.portal-shell .topbar { padding: 0; }
.portal-nav { display: flex; padding: 12px 0 0; overflow-x: auto; }
.portal-nav .nav-item { width: auto; white-space: nowrap; }
.portal-nav .nav-item[aria-current="page"] { background: var(--accent-weak); color: var(--text); }
.portal-nav .nav-item[aria-current="page"] .icon { color: var(--accent); }
.portal-nav .nav-item[aria-current="page"]::before { display: none; }
.portal-shell .content { padding: 20px 0 0; }
