/* neuromancer_eyes dashboard styles.
   Colour tokens follow the reference data-viz palette. Light values sit on bare
   :root; dark values are redefined under both the OS media query and the explicit
   [data-theme="dark"] scope so the toggle wins in both directions. */

:root {
  color-scheme: light;

  --surface-1:      #fcfcfb;  /* card / chart surface */
  --surface-2:      #f3f3f0;  /* sidebar, inset panels */
  --page:           #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11, 11, 11, 0.10);
  --shadow:         0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 12px rgba(11, 11, 11, 0.04);
  --hover:          rgba(11, 11, 11, 0.04);

  /* Categorical slots, fixed order. Never cycled past slot 8. */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
  --series-other: #898781;

  /* Sequential blue ramp, used for the core-load map. */
  --seq-100: #cde2fb; --seq-250: #86b6ef; --seq-400: #3987e5;
  --seq-500: #256abf; --seq-600: #184f95; --seq-700: #0d366b;

  /* Status palette: reserved for state, never for a series. */
  --status-good:     #0ca30c;
  --status-warning:  #fab219;
  --status-serious:  #ec835a;
  --status-critical: #d03b3b;

  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-w: 216px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --surface-2: #141413;
    --page:      #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border:   rgba(255, 255, 255, 0.10);
    --shadow:   none;
    --hover:    rgba(255, 255, 255, 0.06);

    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --surface-2: #141413;
  --page:      #0d0d0d;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border:   rgba(255, 255, 255, 0.10);
  --shadow:   none;
  --hover:    rgba(255, 255, 255, 0.06);

  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
}

* { box-sizing: border-box; }

/* The UA's `[hidden] { display: none }` is beaten by any author `display`
   declaration, and several elements toggled via the hidden attribute here are
   flex/grid containers. Without this a full-viewport overlay silently eats clicks. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--page);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; font-weight: 600; }
p { margin: 0; }

/* Stroke icons inherit colour from their container. */
.icon {
  width: 18px; height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.icon--sm { width: 15px; height: 15px; }
.icon--brand { width: 24px; height: 24px; stroke: var(--series-1); }

.app { display: flex; min-height: 100vh; }

/* --------------------------------------------------------------- sidebar */

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand-text { display: flex; flex-direction: column; min-width: 0; }
.sidebar-brand-text strong { font-size: 14px; letter-spacing: -0.01em; }
.sidebar-brand-text span {
  font-size: 11px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.nav { display: flex; flex-direction: column; gap: 2px; padding: 10px 8px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  position: relative;
}
.nav-item:hover { background: var(--hover); color: var(--text-primary); }
.nav-item.is-active { background: var(--series-1); color: #fff; font-weight: 500; }
.nav-item.is-active .icon { stroke: #fff; }
.nav-item:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }

.nav-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--status-good);
  margin-left: auto;
}
.nav-item.is-active .nav-dot { background: #fff; }

.sidebar-foot {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}

.live {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-secondary);
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 999px;
  min-width: 0;
}
.live span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); flex: none; }
.live[data-state="ok"]    .live-dot { background: var(--status-good); }
.live[data-state="stale"] .live-dot { background: var(--status-warning); }
.live[data-state="error"] .live-dot { background: var(--status-critical); }

/* ------------------------------------------------------------------ main */

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

.topbar {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 16px 24px 12px;
  background: var(--page);
}
.topbar h1 { font-size: 20px; letter-spacing: -0.02em; }
.topbar-sub { font-size: 12px; color: var(--text-muted); }
.sidebar-toggle { display: none; align-self: center; }

/* --------------------------------------------------------------- filters */

.filterbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 18px;
  padding: 12px 24px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--page);
  position: sticky;
  top: 0;
  z-index: 30;
}
.filter-group { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.filter-group--switch { flex-direction: row; align-items: center; gap: 10px; padding-top: 20px; }
.filter-group--custom { flex-basis: 100%; }
.custom-inputs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.filter-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); font-weight: 600;
}
.hint { font-size: 11px; color: var(--text-muted); }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.segmented button {
  background: transparent; border: 0; border-right: 1px solid var(--border);
  color: var(--text-secondary); padding: 6px 11px;
  font: inherit; font-size: 13px; cursor: pointer; min-height: 32px;
}
.segmented button:last-child { border-right: 0; }
.segmented button:hover { color: var(--text-primary); background: var(--hover); }
.segmented button.is-active { background: var(--series-1); color: #fff; font-weight: 500; }
.segmented--sm button { padding: 4px 10px; font-size: 12px; min-height: 28px; }

select, .input {
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px 10px; font: inherit; font-size: 13px; min-height: 32px;
}
select:focus-visible, .input:focus-visible, button:focus-visible {
  outline: 2px solid var(--series-1); outline-offset: 1px;
}
.input--date { font-size: 12px; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .icon { position: absolute; left: 9px; stroke: var(--text-muted); }
.input-wrap .input { padding-left: 30px; min-width: 220px; }

.switch { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.switch input { accent-color: var(--series-1); width: 15px; height: 15px; }
.switch--sm { font-size: 12px; }

.btn {
  background: var(--surface-1); border: 1px solid var(--border); color: var(--text-secondary);
  border-radius: var(--radius-sm); padding: 6px 12px;
  font: inherit; font-size: 13px; cursor: pointer; min-height: 32px;
}
.btn:hover { color: var(--text-primary); border-color: var(--baseline); }
.btn--ghost { font-size: 12px; padding: 4px 10px; min-height: 28px; }
.btn--icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; padding: 0; }
.btn--primary { background: var(--series-1); border-color: var(--series-1); color: #fff; }
.btn--primary:hover { color: #fff; }
.btn.is-active { background: var(--series-1); color: #fff; border-color: var(--series-1); }

.icon-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-secondary);
  border-radius: var(--radius-sm); width: 30px; height: 30px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.icon-btn:hover { color: var(--text-primary); border-color: var(--baseline); }

/* -------------------------------------------------------------- dropdown */

.dropdown { position: relative; }
.dropdown-btn {
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
  min-width: 180px; min-height: 32px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-primary); padding: 6px 10px; font: inherit; font-size: 13px; cursor: pointer;
}
.dropdown-btn:hover { border-color: var(--baseline); }
.dropdown-panel {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 40;
  width: 262px;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  display: flex; flex-direction: column; overflow: hidden;
}
.dropdown-search { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border-bottom: 1px solid var(--border); }
.dropdown-search .icon { stroke: var(--text-muted); }
.dropdown-search input {
  border: 0; background: transparent; color: var(--text-primary);
  font: inherit; font-size: 13px; width: 100%; outline: none;
}
.dropdown-list { max-height: 260px; overflow-y: auto; padding: 4px; }
.dropdown-option {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 9px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px; color: var(--text-secondary);
}
.dropdown-option:hover { background: var(--hover); color: var(--text-primary); }
.dropdown-option input { accent-color: var(--series-1); width: 14px; height: 14px; }
.dropdown-option .chip { margin-left: auto; }
.dropdown-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-top: 1px solid var(--border);
}

.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; max-width: 300px; }
.chip-tag {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 5px 2px 8px; font-size: 11px; color: var(--text-secondary);
}
.chip-tag button {
  background: transparent; border: 0; cursor: pointer; color: var(--text-muted);
  display: inline-flex; padding: 1px; border-radius: 50%;
}
.chip-tag button:hover { color: var(--status-critical); background: var(--hover); }
.chip-tag .icon { width: 12px; height: 12px; }

/* ----------------------------------------------------------------- views */

main {
  padding: 18px 24px 40px;
  display: flex; flex-direction: column; gap: 16px;
  max-width: 1900px; width: 100%;
}
.view { display: none; flex-direction: column; gap: 16px; }
.view.is-active { display: flex; }

.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px 18px;
  box-shadow: var(--shadow); min-width: 0;
}
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 12px;
}
.card h2 { font-size: 14px; letter-spacing: -0.005em; }
.card-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chart-note { font-size: 11px; color: var(--text-muted); margin-top: 8px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); gap: 16px; }

/* Containers include the x-axis band, so nothing gets a nested scrollbar. */
.chart { width: 100%; height: 330px; }
.chart--tall { height: 420px; }
.is-refetching { opacity: 0.55; transition: opacity 120ms ease; }

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

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 12px; }
.tiles--compact { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.tile {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0;
}
.tile-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); font-weight: 600;
}
/* Proportional figures on display numbers; never tabular-nums here. */
.tile-value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; line-height: 1.15; }
.tile-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.meter { margin-top: 10px; height: 5px; border-radius: 999px; background: var(--gridline); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 999px; background: var(--series-1); width: 0%; transition: width 300ms ease; }
.meter-fill[data-status="good"]     { background: var(--status-good); }
.meter-fill[data-status="warning"]  { background: var(--status-warning); }
.meter-fill[data-status="serious"]  { background: var(--status-serious); }
.meter-fill[data-status="critical"] { background: var(--status-critical); }

/* -------------------------------------------------------------- core map */

.coregrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(26px, 1fr));
  gap: 3px;
}
.corecell {
  aspect-ratio: 1;
  border-radius: 3px;
  background: var(--gridline);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  cursor: default;
  transition: background 250ms ease;
}
.corecell[data-hot="1"] { color: #fff; }
.coregrid-legend { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.ramp {
  flex: 1; height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, var(--seq-100), var(--seq-250), var(--seq-400), var(--seq-500), var(--seq-600), var(--seq-700));
}

/* ----------------------------------------------------------- filesystems */

.fs-list { display: flex; flex-direction: column; gap: 10px; }
.fs-row { display: grid; grid-template-columns: minmax(110px, 190px) 1fr auto; gap: 14px; align-items: center; }
.fs-mount { font-size: 13px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fs-bar { height: 7px; border-radius: 999px; background: var(--gridline); overflow: hidden; }
.fs-bar > span { display: block; height: 100%; border-radius: 999px; }
.fs-figures { font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Status never rides on colour alone: each row carries an icon and a word. */
.fs-state { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; margin-left: 8px; }
.fs-state[data-status="good"]     { color: var(--status-good); }
.fs-state[data-status="critical"] { color: var(--status-critical); }
.fs-state[data-status="warning"], .fs-state[data-status="serious"] { color: var(--text-secondary); }

/* --------------------------------------------------------------- sensors */

.sensor-group { margin-bottom: 18px; }
.sensor-group:last-child { margin-bottom: 0; }
.sensor-group h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); font-weight: 600; margin: 0 0 8px;
}
.sensor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 8px; }
.sensor {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 11px; display: flex; flex-direction: column; gap: 3px;
}
.sensor-label { font-size: 11px; color: var(--text-muted); font-family: var(--mono); }
.sensor-value { font-size: 17px; font-weight: 600; }
.sensor-bar { height: 4px; border-radius: 999px; background: var(--gridline); overflow: hidden; margin-top: 3px; }
.sensor-bar > span { display: block; height: 100%; border-radius: 999px; }

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

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  text-align: left; padding: 8px 12px 8px 0;
  border-bottom: 1px solid var(--gridline); white-space: nowrap;
}
.data-table th {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); font-weight: 600; border-bottom-color: var(--baseline);
}
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; padding-right: 16px; }
.data-table tbody tr:hover { background: var(--hover); }
.data-table .cmd {
  font-family: var(--mono); font-size: 12px; color: var(--text-secondary);
  max-width: 440px; overflow: hidden; text-overflow: ellipsis;
}
.table-foot { font-size: 12px; color: var(--text-muted); margin-top: 10px; display: flex; align-items: center; gap: 10px; }

/* A colour chip beside a name carries identity; the text keeps its ink token. */
.user-cell { display: inline-flex; align-items: center; gap: 7px; }
.chip { width: 9px; height: 9px; border-radius: 2px; flex: none; }

.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-secondary); }
.pill[data-state="running"] { color: var(--status-good); border-color: color-mix(in srgb, var(--status-good) 40%, transparent); }

.table-view { overflow-x: auto; }
.table-view table { width: 100%; border-collapse: collapse; font-size: 12px; }
.table-view th, .table-view td {
  padding: 6px 12px 6px 0; border-bottom: 1px solid var(--gridline);
  text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.table-view th:first-child, .table-view td:first-child { text-align: left; }
.table-view th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; }

/* ---------------------------------------------------------------- footer */

.footer {
  padding: 18px 24px 30px; border-top: 1px solid var(--border);
  color: var(--text-muted); font-size: 12px;
  display: flex; flex-direction: column; gap: 4px; margin-top: auto;
}
.footer strong { color: var(--text-secondary); font-weight: 600; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--status-critical); color: #fff; padding: 9px 16px;
  border-radius: var(--radius-sm); font-size: 13px; z-index: 60;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.empty { color: var(--text-muted); font-size: 13px; padding: 24px 0; text-align: center; }

.auth-overlay {
  position: fixed; inset: 0; background: var(--page);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.auth-box {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 32px; width: min(360px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow);
}
.auth-box h2 { font-size: 16px; }
.auth-box p { font-size: 13px; color: var(--text-secondary); }
.auth-error { color: var(--status-critical) !important; font-size: 12px; }

/* ----------------------------------------------------------- responsive */

@media (max-width: 1000px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 50;
    transform: translateX(-100%); transition: transform 180ms ease;
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-toggle { display: inline-flex; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar, .filterbar, main, .footer { padding-left: 14px; padding-right: 14px; }
  .filterbar { position: static; }
  .chart, .chart--tall { height: 290px; }
  .input-wrap .input { min-width: 150px; }
}
