/* Stringfellow admin (backlog/gtm/90) — operator surface, not a product one.
   Tokens mirror site/src/styles/global.css so it reads as ours, but nothing
   here is brand work: no logo, no marketing type, no hero art. Dark only —
   it's one operator on one machine, so a light mode is a mode to maintain for
   nobody. */

:root {
  --bg: #121213;
  --topbar: #0a0a0c;
  --surface: #1b1b1d;
  --panel: #232326;
  --panel-edge: #35353b;
  --inset: #161618;
  --hairline: #2a2a2e;
  --ink: #f6f0e6;
  --ink-soft: #9a968f;
  --ink-faint: #6b6862;

  /* One data hue. Every chart here plots a single measure, so there is no
     categorical palette to get wrong — magnitude is length, and color is
     constant. */
  --data: #ff5a1f;
  --data-track: #33241d;

  /* Status. Always shipped with a word next to it, never color alone. */
  --warn: #e5c07b;
  --bad: #ff6b6b;
  --good: #7cc4a4;

  --radius: 12px;

  /* Narrow-screen header height. One variable because it sizes the header AND
     positions the drawer under it — a hard-coded pair drifts, and when it does
     the drawer covers the button that opens it. */
  --topbar-h: 56px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--ink);
}

/* ------------------------------------------------------------------ chrome */

/* Sidebar + content. A side menu rather than tabs across the top because the
   screen list is expected to grow, and a vertical list grows without
   rebalancing anything. */
.shell {
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
}

aside.side {
  position: sticky;
  top: 0;
  flex: 0 0 208px;
  width: 208px;
  height: 100vh;
  overflow-y: auto;
  padding: 18px 12px 24px;
  background: var(--topbar);
  border-right: 1px solid var(--hairline);
}

aside.side .brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 10px 20px;
}

aside.side .brand strong {
  font-weight: 700;
  letter-spacing: -0.01em;
}

.tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
}

aside.side nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Group labels, so the list stays scannable past a handful of items. */
.nav-section {
  margin: 14px 0 4px;
  padding: 0 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-faint);
}

.nav-section:first-child {
  margin-top: 0;
}

aside.side nav a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--ink-soft);
  text-decoration: none;
  /* The current-page marker rides the left edge, so it reads as a position in
     a list rather than a pressed button. */
  border-left: 2px solid transparent;
}

aside.side nav a:hover {
  color: var(--ink);
  background: #ffffff08;
}

aside.side nav a[aria-current="page"] {
  color: var(--ink);
  background: #ff5a1f14;
  border-left-color: var(--data);
  font-weight: 600;
}

.content {
  flex: 1 1 auto;
  min-width: 0; /* or a wide table stretches the flex item and the page pans */
}

main {
  max-width: 1100px;
  padding: 26px 26px 80px;
}

/* The narrow-screen top bar. Hidden on desktop, where the sidebar is the
   chrome and a second header would just repeat it. */
header.bar {
  display: none;
}

.scrim {
  display: none;
}

@media (max-width: 860px) {
  header.bar {
    position: sticky;
    top: 0;
    /* Above the scrim, deliberately. The scrim covering the toggle meant the
       button that opened the drawer couldn't close it — and reaching for the
       same button is the first thing anyone does. */
    z-index: 45;
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--topbar-h);
    padding: 0 16px;
    background: var(--topbar);
    border-bottom: 1px solid var(--hairline);
  }

  header.bar strong {
    font-weight: 700;
  }

  .menu-toggle {
    background: transparent;
    border: 1px solid var(--panel-edge);
    color: var(--ink);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
  }

  aside.side {
    position: fixed;
    z-index: 50;
    /* Under the header, not over it: the toggle has to stay reachable to close
       what it opened. */
    top: var(--topbar-h);
    left: 0;
    height: calc(100vh - var(--topbar-h));
    transform: translateX(-100%);
    transition: transform 0.16s ease-out;
  }

  body.nav-open aside.side {
    transform: none;
  }

  body.nav-open .scrim {
    display: block;
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    z-index: 35;
    background: #000000a8;
  }

  main {
    padding: 18px 16px 60px;
  }

  /* The header already carries the brand at this width; the drawer repeating
     it directly underneath just reads as a mistake. */
  aside.side .brand {
    display: none;
  }

  aside.side {
    padding-top: 12px;
  }

  /* A five-column ledger does not fit a phone. Let the panel scroll sideways
     rather than the page — a body that pans horizontally makes every vertical
     scroll feel broken, and it's the one thing this layout must never do.
     Narrow screens only: on desktop this would put a scrollbar under the
     chart panel for the sake of a few overhanging pixels. */
  .panel {
    overflow-x: auto;
  }
}

h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
}

h2 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0 0 12px;
  color: var(--ink);
}

.sub {
  color: var(--ink-soft);
  font-size: 13px;
  margin: 0 0 22px;
}

/* Filters in one row above the charts. */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 0 0 22px;
}

select,
input[type="text"],
input[type="number"] {
  background: var(--inset);
  color: var(--ink);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
}

input[type="text"] {
  min-width: 260px;
}

button {
  background: var(--data);
  color: #1a0d06;
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

button.ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--panel-edge);
  font-weight: 400;
}

button:hover {
  filter: brightness(1.08);
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}

.grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  margin-bottom: 18px;
}

.grid .panel {
  margin: 0;
}

.tiles {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 18px;
}

.tile {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.tile .label {
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.tile .value {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.tile .note {
  font-size: 11px;
  color: var(--ink-faint);
  margin-top: 4px;
}

/* Exactly one per view. Proportional figures — tabular-nums makes a display
   number look loose. */
.hero .value {
  font-size: 48px;
  line-height: 1.05;
  font-weight: 600;
}

.status-good {
  color: var(--good);
}
.status-warn {
  color: var(--warn);
}
.status-bad {
  color: var(--bad);
}

/* --------------------------------------------------------------- the chart */

.chart {
  position: relative;
  height: 200px;
  margin: 8px 0 0;
}

.chart .plot {
  position: absolute;
  inset: 0 0 22px 58px;
  display: flex;
  align-items: flex-end;
  /* The 2px surface gap between adjacent bars — separation by negative space,
     never a stroke around the mark. */
  gap: 2px;
}

/* The slot takes its share of the width; the mark inside is capped and
   centred, so the band's leftover becomes air rather than a fatter bar. */
.chart .col {
  position: relative;
  flex: 1 1 0;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  cursor: default;
}

.chart .fill {
  width: 100%;
  max-width: 24px;
  min-height: 1px;
  background: var(--data);
  /* Rounded data-end, square at the baseline. */
  border-radius: 4px 4px 0 0;
}

.chart .col:hover .fill {
  filter: brightness(1.25);
}

.chart .col.empty .fill {
  background: var(--data-track);
}

/* Hairline, solid, recessive — one step off the surface. */
.chart .gridline {
  position: absolute;
  left: 58px;
  right: 0;
  border-top: 1px solid var(--hairline);
  color: var(--ink-faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart .gridline span {
  position: absolute;
  right: calc(100% + 8px);
  top: -0.6em;
  white-space: nowrap;
}

.chart .xaxis {
  position: absolute;
  left: 58px;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ink-faint);
}

/* The value on the tallest cap only — labels work because they're sparing.
   Positioned inside its own column (which is why .col is relative), so it
   tracks the bar without any global coordinate arithmetic to get wrong. */
.chart .peak {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--ink-soft);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.tooltip {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  background: var(--topbar);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.08s;
}

.tooltip.on {
  opacity: 1;
}

.tooltip .k {
  color: var(--ink-soft);
  margin-right: 8px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  font-weight: 600;
  padding: 0 10px 8px 0;
  border-bottom: 1px solid var(--hairline);
}

td {
  padding: 9px 10px 9px 0;
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: 0;
}

td.num,
th.num {
  text-align: right;
  padding-right: 0;
  font-variant-numeric: tabular-nums;
}

tbody tr.pick {
  cursor: pointer;
}

tbody tr.pick:hover {
  background: #ffffff08;
}

tbody tr.on {
  background: #ff5a1f14;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--ink-soft);
}

/* Magnitude inside a table cell: same single hue, length carries the value. */
.meter {
  position: relative;
  height: 6px;
  min-width: 60px;
  background: var(--data-track);
  border-radius: 3px;
  overflow: hidden;
}

.meter i {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--data);
  border-radius: 3px;
}

details.astable {
  margin-top: 14px;
}

details.astable summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-soft);
}

details.astable[open] summary {
  margin-bottom: 10px;
}

/* --------------------------------------------------------------- messages */

.banner {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 18px;
  font-size: 13px;
  border: 1px solid;
}

.banner.warn {
  background: #2a2317;
  border-color: #5c4a22;
  color: var(--warn);
}

.banner.bad {
  background: #2a1a1a;
  border-color: #5c2626;
  color: var(--bad);
}

.banner code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.empty {
  color: var(--ink-faint);
  font-size: 13px;
  padding: 10px 0;
}

.loading {
  color: var(--ink-faint);
  font-size: 13px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.spacer {
  flex: 1;
}

dl.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 0;
  font-size: 14px;
}

dl.kv dt {
  color: var(--ink-soft);
  font-size: 13px;
}

dl.kv dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}
