/* queen — a clean, light operational dashboard. Black-on-white typography, a
   fixed left sidebar, calm indigo accent, and status colour reserved for badges.
   No external fonts or assets: system font stack, self-contained. */

:root {
  --bg: #ffffff;
  --surface: #f8f9fb;
  --surface-2: #f2f4f7;
  --border: #e6e8ec;
  --border-strong: #d5d9e0;

  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;

  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --accent-border: #c7d2fe;

  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --idle: #9ca3af;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 1px 3px rgba(16, 24, 40, 0.10), 0 1px 2px rgba(16, 24, 40, 0.06);
  --mono: "SFMono-Regular", ui-monospace, Menlo, Consolas, "DejaVu Sans Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

b { font-weight: 600; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* ---- Shell ------------------------------------------------------------- */

.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

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

.brand {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--text);
  padding: 4px 10px 12px;
  border-bottom: 1px solid var(--border);
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  text-decoration: none;
  font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }

.sidebar-foot {
  margin-top: auto;
  padding: 12px 10px 4px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 5;
}
.page-title { margin: 0; font-size: 18px; font-weight: 650; }

.status { display: flex; align-items: center; gap: 14px; font-size: 12.5px; }
.status-meta { color: var(--muted); }
.status-meta b { color: var(--text-2); }

.content { padding: 24px 28px 40px; }

/* ---- Cards & layout ---------------------------------------------------- */

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 20px;
}
.card:last-child { margin-bottom: 0; }
.card > h2 {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.card.empty { color: var(--muted); }
.card.empty p { margin: 0; }

.row {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 20px;
}
.row > .card { margin-bottom: 0; }

/* KPI tiles */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat .k {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat .v { font-size: 30px; font-weight: 680; line-height: 1; letter-spacing: -0.01em; }
.stat .v.mono { font-size: 18px; font-weight: 600; }
.stat .v.ok { color: var(--ok); }
.stat .v.warn { color: var(--warn); }
.stat .v.bad { color: var(--bad); }
.stat .v.idle { color: var(--idle); }
.stat .v.none { color: var(--muted); }
.stat .spark { margin-top: 2px; }

/* ---- Charts ------------------------------------------------------------ */

.spark { display: block; width: 100%; height: 30px; color: var(--accent); }
.spark-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.spark-area { fill: currentColor; opacity: 0.08; stroke: none; }
.spark-dot { fill: currentColor; stroke: var(--bg); stroke-width: 1.5; }

.segbar {
  display: flex;
  gap: 2px;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-2);
}
.segbar .seg { display: block; min-width: 2px; }
.segbar .seg.ok { background: var(--ok); }
.segbar .seg.warn { background: var(--warn); }
.segbar .seg.bad { background: var(--bad); }
.segbar .seg.idle { background: var(--idle); }

.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 14px; font-size: 12.5px; }
.legend .item { display: inline-flex; align-items: center; gap: 7px; color: var(--text-2); }
.legend .item b { color: var(--text); }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; }
.legend .swatch.ok { background: var(--ok); }
.legend .swatch.warn { background: var(--warn); }
.legend .swatch.bad { background: var(--bad); }
.legend .swatch.idle { background: var(--idle); }

/* ---- Badges & dots ----------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}
.badge.ok { background: #ecfdf3; color: #067647; }
.badge.warn { background: #fffaeb; color: #b54708; }
.badge.bad { background: #fef3f2; color: #b42318; }
.badge.idle { background: var(--surface-2); color: var(--text-2); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.neutral { background: var(--surface-2); color: var(--muted); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--idle); }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.dot.idle { background: var(--idle); }
.dot.none { background: transparent; border: 1px solid var(--border-strong); }

/* status text helpers (kept for inline values) */
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }
.idle { color: var(--idle); }
.none, .dim { color: var(--muted); }

/* ---- Tables ------------------------------------------------------------ */

.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-strong);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface); }
td .badge { vertical-align: middle; }

/* ---- Warnings ---------------------------------------------------------- */

.warnings { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.warnings li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: #fffaeb;
  border: 1px solid #fde8b8;
  border-radius: var(--radius-sm);
  color: #93600a;
}
.allclear { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); margin: 0; }

/* ---- Responsive -------------------------------------------------------- */

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; align-items: center;
    flex-wrap: wrap; gap: 8px 14px;
  }
  .brand { border-bottom: none; padding: 4px 6px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { display: none; }
  .row { grid-template-columns: 1fr; }
  .topbar { padding: 14px 18px; flex-wrap: wrap; }
  .content { padding: 18px; }
}
