/*
 * Base layer: reset, design tokens, page shell, typography.
 * Dark theme with a blue accent, per the operator UI brief.
 */

/*
 * Palette notes. The previous tokens were a blue-tinted navy set whose
 * surfaces sat 1.06:1 apart, so panels did not read as panels against the page
 * - the whole UI looked like one flat wash - and muted text fell below WCAG AA
 * (4.02:1 on panels, 3.75:1 on raised panels). These are a near-neutral slate
 * set instead: the greys carry only a slight cool cast so the blue accent
 * stands apart from them rather than blending in, surfaces step ~1.15:1 apart
 * so cards have edges, and every text/background pair below clears 4.5:1.
 * If you change one, re-check it - contrast ratios compress badly at this end
 * of the scale, so a small hex tweak can quietly drop text under AA.
 */
:root {
  --bg-0: #0a0c0f;       /* page background */
  --bg-1: #181c24;       /* panel background   - 1.15:1 vs bg-0 */
  --bg-2: #212632;       /* raised / hover     - 1.13:1 vs bg-1 */
  --bg-3: #2a3140;       /* input background */
  --border: #333b49;
  --border-soft: #262c37;
  --text-0: #eef1f6;     /* primary text   - 17.3:1 on bg-0 */
  --text-1: #b8c2d0;     /* secondary text -  9.5:1 on bg-1 */
  --text-2: #959fb1;     /* muted          -  6.4:1 on bg-1, 4.9:1 on bg-3 */
  --accent: #5aa2ff;     /* blue accent    -  6.5:1 on bg-1 */
  --accent-soft: #17304d;
  --accent-strong: #8fc0ff;
  --good: #3ecf8e;
  --good-soft: #102b21;
  --bad: #ff6b78;
  --bad-soft: #38151d;
  --warn: #f0c256;
  --warn-soft: #33290f;
  --mono: "SF Mono", "JetBrains Mono", Consolas, Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* This UI is dark-only by design (operator tool, not themed to the OS),
   but keep the color-scheme hint so form controls / scrollbars match. */
:root {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg-0);
  color: var(--text-0);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

code, pre, .mono {
  font-family: var(--mono);
}

h1, h2, h3, h4 {
  margin: 0 0 0.5em 0;
  font-weight: 600;
  color: var(--text-0);
}
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-1); }

p { margin: 0 0 0.75em 0; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-2); }

/* ---------- App shell ---------- */

#app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 12px 8px;
  border-bottom: 1px solid var(--border-soft);
}
.brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  flex: none;
}
.brand-name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
}
.brand-sub {
  font-size: 11.5px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav a {
  color: var(--text-1);
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 9px;
}
.nav a:hover {
  background: var(--bg-2);
  color: var(--text-0);
  text-decoration: none;
}
.nav a.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.nav a .icon {
  width: 16px;
  text-align: center;
  opacity: 0.9;
}

.sidebar-footer {
  margin-top: auto;
  font-size: 12.5px;
  color: var(--text-2);
  padding: 8px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.live-indicator .led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-2);
  flex: none;
}
.live-indicator[data-state="connected"] .led {
  background: var(--good);
  box-shadow: 0 0 6px var(--good);
}
.live-indicator[data-state="polling"] .led {
  background: var(--warn);
  box-shadow: 0 0 6px var(--warn);
}
.live-indicator[data-state="down"] .led {
  background: var(--bad);
}

main#view {
  padding: 24px 28px 60px 28px;
  min-width: 0;
  /* Wider than the old 1400px cap and centred in the remaining space. Left
     unbounded the event timeline and XML panes get uncomfortably long to
     read; left at 1400 and un-centred, a 1920 display had 300px of dead
     gutter pinned to one side. */
  max-width: 1680px;
  margin-inline: auto;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-header p {
  color: var(--text-1);
  max-width: 720px;
}

@media (max-width: 900px) {
  #app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .sidebar-footer {
    margin-top: 0;
    border-top: none;
  }
  main#view {
    padding: 16px;
  }
}

.grid {
  display: grid;
  gap: 16px;
}
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1000px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

.hidden { display: none !important; }
.muted { color: var(--text-2); }
.text-1 { color: var(--text-1); }
.small { font-size: 13px; }
.scroll-x { overflow-x: auto; }
