/*
 * Planets OS — temporary neutral design system.
 * Every colour, radius and spacing value is a token so the brand can be
 * swapped in later (once visual references arrive) without touching markup.
 */
:root {
  color-scheme: light;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --page: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f9f9f7;
  --surface-sunken: #efeee9;
  --border: rgba(11, 11, 11, 0.09);
  --border-strong: rgba(11, 11, 11, 0.16);
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-muted: #85837d;
  --accent: #2a78d6;
  --accent-soft: #e6f0fc;
  --focus: #2a78d6;

  --grid: #e8e7e1;
  --axis: #c3c2b7;

  /* categorical (fixed order) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  /* sequential blue ramp (ordinal steps) */
  --seq-250: #86b6ef;
  --seq-350: #5598e7;
  --seq-450: #2a78d6;
  --seq-550: #1c5cab;
  --seq-650: #104281;

  /* status — reserved, always paired with an icon + label */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-text: #006300;
  --critical-text: #b32c2c;
  --good-soft: #e5f5e5;
  --warning-soft: #fdf3dc;
  --serious-soft: #fcebe3;
  --critical-soft: #fae6e6;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 1px 1px rgba(11, 11, 11, 0.02);
  --sidebar-w: 236px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #20201f;
    --surface-sunken: #141413;
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-muted: #898781;
    --accent: #3987e5;
    --accent-soft: #1b2a3d;
    --focus: #5598e7;
    --grid: #2c2c2a;
    --axis: #383835;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --seq-250: #184f95;
    --seq-350: #1c5cab;
    --seq-450: #2a78d6;
    --seq-550: #5598e7;
    --seq-650: #86b6ef;
    --good-text: #0ca30c;
    --critical-text: #e66767;
    --good-soft: #14281a;
    --warning-soft: #2e2612;
    --serious-soft: #2f1d15;
    --critical-soft: #331818;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #20201f;
  --surface-sunken: #141413;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f0efec;
  --text-2: #c3c2b7;
  --text-muted: #898781;
  --accent: #3987e5;
  --accent-soft: #1b2a3d;
  --focus: #5598e7;
  --grid: #2c2c2a;
  --axis: #383835;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --seq-250: #184f95;
  --seq-350: #1c5cab;
  --seq-450: #2a78d6;
  --seq-550: #5598e7;
  --seq-650: #86b6ef;
  --good-text: #0ca30c;
  --critical-text: #e66767;
  --good-soft: #14281a;
  --warning-soft: #2e2612;
  --serious-soft: #2f1d15;
  --critical-soft: #331818;
  --shadow: none;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text);
  font: 14px/1.45 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--text-muted); }
.text-2 { color: var(--text-2); }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-weight: 650; font-size: 15px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--text); color: var(--surface); font-size: 13px; font-weight: 700;
}
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); padding: 6px 10px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500;
}
.nav-link svg { width: 16px; height: 16px; flex: none; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.sidebar-foot { margin-top: auto; padding: 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--surface-sunken); color: var(--text-2); font-size: 12px; font-weight: 600;
}

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 28px; background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; }
.topbar .sub { color: var(--text-muted); font-size: 12.5px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.content { padding: 22px 28px 48px; display: flex; flex-direction: column; gap: 20px; }
.menu-btn { display: none; }

/* --------------------------------------------------------------- controls */
.btn, .select, .input {
  height: 34px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px;
}
.btn { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 500; }
.btn:hover { background: var(--surface-2); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-icon { width: 34px; padding: 0; justify-content: center; }
.btn svg { width: 16px; height: 16px; }
.input:focus, .select:focus { outline: 2px solid var(--focus); outline-offset: -1px; }
.segmented { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--radius-sm); background: var(--surface-sunken); }
.segmented a { padding: 5px 10px; border-radius: 5px; font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.segmented a[aria-current="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.banner {
  display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: var(--radius);
  background: var(--warning-soft); border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent); font-size: 13px;
}

/* ------------------------------------------------------------------ cards */
.grid { display: grid; gap: 16px; }
.grid-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); min-width: 0; display: flex; flex-direction: column;
}
.card-head { display: flex; align-items: flex-start; gap: 10px; padding: 16px 18px 0; }
.card-head h2 { font-size: 14px; }
.card-head .hint { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-body { padding: 14px 18px 18px; flex: 1; min-width: 0; }
.card-link { font-size: 12.5px; color: var(--accent); font-weight: 500; white-space: nowrap; }
.empty { color: var(--text-muted); font-size: 13px; padding: 18px 0; text-align: center; }

.section-title { display: flex; align-items: baseline; gap: 10px; margin-top: 6px; }
.section-title h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; }

/* ------------------------------------------------------------- hero strip */
.hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 2fr); gap: 16px; }
.hero-figure { padding: 20px 22px; display: flex; flex-direction: column; gap: 6px; }
.hero-figure .label { color: var(--text-2); font-weight: 500; }
.hero-figure .value { font-size: 48px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.05; }
.hero-figure .compare { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--text-2); font-size: 13px; }
.hero-figure .compare strong { color: var(--text); font-weight: 600; }

/* --------------------------------------------------------------- stat tile */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 4px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  min-width: 0;
}
a.tile:hover { border-color: var(--border-strong); color: inherit; }
.tile .label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.tile .value { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
.tile .foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); min-height: 18px; }
.tile .spark { position: absolute; right: 14px; top: 14px; width: 72px; height: 26px; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; font-size: 12px; }
.delta.good { color: var(--good-text); }
.delta.bad { color: var(--critical-text); }
.delta.flat { color: var(--text-muted); }

/* ------------------------------------------------------------ attention */
.attention { display: flex; flex-direction: column; }
.attention a {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 10px 4px; border-top: 1px solid var(--border);
}
.attention a:first-child { border-top: 0; }
.attention .title { font-weight: 600; font-size: 13px; }
.attention .detail { font-size: 12px; color: var(--text-muted); }
.sev { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.sev svg { width: 16px; height: 16px; }
.sev-critical { background: var(--critical-soft); color: var(--critical); }
.sev-serious { background: var(--serious-soft); color: var(--serious); }
.sev-warning { background: var(--warning-soft); color: #b07700; }
.sev-good { background: var(--good-soft); color: var(--good); }

/* -------------------------------------------------------------- hbar list */
.hbars { display: flex; flex-direction: column; gap: 12px; }
.hbar-row { display: grid; grid-template-columns: minmax(90px, 140px) minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.hbar-row .name { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-row .val { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; min-width: 64px; }
.hbar-row .val small { display: block; font-weight: 400; color: var(--text-muted); font-size: 11.5px; }
.hbar-track { height: 12px; position: relative; }
.hbar { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; background: var(--series-1); min-width: 2px; }
.hbar.weighted { background: var(--seq-650); opacity: 0.9; height: 4px; top: auto; bottom: -6px; border-radius: 0 2px 2px 0; }

/* stacked meter (health / aging) */
.meter { display: flex; gap: 2px; height: 12px; border-radius: 4px; overflow: hidden; background: var(--surface-sunken); }
.meter span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--text-2); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend i.line { height: 2px; border-radius: 1px; vertical-align: 3px; width: 14px; }

/* --------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; margin: 0 -18px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-weight: 500; font-size: 12px; color: var(--text-muted); padding: 8px 18px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 10px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data .primary { font-weight: 550; color: var(--text); }
table.data .secondary { font-size: 12px; color: var(--text-muted); }

.progress { height: 6px; border-radius: 3px; background: var(--surface-sunken); min-width: 70px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--series-1); border-radius: 3px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--surface-sunken); color: var(--text-2);
}
.pill svg { width: 12px; height: 12px; }
.pill-good { background: var(--good-soft); color: var(--good-text); }
.pill-warning { background: var(--warning-soft); color: #8a5d00; }
.pill-serious { background: var(--serious-soft); color: #a8481f; }
.pill-critical { background: var(--critical-soft); color: var(--critical-text); }
.pill-info { background: var(--accent-soft); color: var(--accent); }
:root[data-theme="dark"] .pill-warning { color: var(--warning); }
:root[data-theme="dark"] .pill-serious { color: var(--serious); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pill-warning { color: var(--warning); }
  :root:not([data-theme="light"]) .pill-serious { color: var(--serious); }
}

.chart-box { position: relative; height: 280px; }
.chart-table { display: none; }
.card.show-table .chart-box, .card.show-table .chart-visual { display: none; }
.card.show-table .chart-table { display: block; }

.feed { display: flex; flex-direction: column; }
.feed li { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); font-size: 13px; }
.feed li:first-child { border-top: 0; }
.feed .when { font-size: 11.5px; color: var(--text-muted); }
ul.plain { list-style: none; margin: 0; padding: 0; }

.tooltip {
  position: fixed; z-index: 100; pointer-events: none; padding: 8px 10px; border-radius: 8px;
  background: var(--text); color: var(--surface); font-size: 12px; line-height: 1.4; max-width: 260px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18); opacity: 0; transition: opacity .08s;
}
.tooltip.show { opacity: 1; }

/* ---------------------------------------------------------------- login */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; padding: 28px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field .input { height: 40px; }
.error { color: var(--critical-text); font-size: 12.5px; }
.btn-primary { background: var(--text); color: var(--surface); border-color: var(--text); height: 40px; justify-content: center; width: 100%; }
.btn-primary:hover { background: var(--text); opacity: .9; }

.pagination { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding-top: 12px; font-size: 13px; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1200px) {
  .span-3, .span-4, .span-5 { grid-column: span 6; }
  .span-7, .span-8 { grid-column: span 12; }
  .hero { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .menu-btn { display: inline-flex; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .grid-12 > * { grid-column: span 12; }
  .hero-figure .value { font-size: 40px; }
  .hbar-row { grid-template-columns: 90px minmax(0, 1fr) auto; }
}
@media print {
  .sidebar, .topbar-actions, .menu-btn { display: none !important; }
  .shell { display: block; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
