:root {
  --bg: #0B0F14;
  --surface: #121821;
  --surface-2: #1A222E;
  --surface-3: #212B39;
  --border: #26313F;
  --border-soft: #1D2733;
  --text: #E7EDF3;
  --text-muted: #8A9AAE;
  --text-dim: #5C6B7E;
  --accent: #3FA9F5;
  --accent-dim: #1F4A66;
  --critical: #FF5C5C;
  --critical-dim: #3A1E1E;
  --warning: #FFB84D;
  --warning-dim: #3A2E14;
  --healthy: #3DD68C;
  --healthy-dim: #143A2A;
  --unknown: #8A9AAE;
  --font-ui: -apple-system, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "DejaVu Sans Mono", ui-monospace, monospace;
  --radius: 3px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--accent); }
::selection { background: var(--accent-dim); }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- Shell layout ---------- */
#app { display: flex; min-height: 100vh; }

.nav {
  width: 216px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 18px 0;
}
.nav-brand {
  padding: 0 18px 18px 18px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 10px;
}
.nav-brand .mark { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; color: var(--accent); }
.nav-brand .name { font-size: 14px; font-weight: 600; margin-top: 4px; }
.nav-brand .tag { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: var(--text-muted);
  cursor: pointer;
  border-left: 2px solid transparent;
  font-size: 13.5px;
}
.nav-item:hover { color: var(--text); background: var(--surface-2); }
.nav-item.active { color: var(--text); background: var(--surface-2); border-left-color: var(--accent); }
.nav-item .badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--text-muted);
}
.nav-item .badge.critical { background: var(--critical-dim); color: var(--critical); }
.nav-item .badge.warning { background: var(--warning-dim); color: var(--warning); }

.nav-foot { margin-top: auto; padding: 10px 18px 0 18px; border-top: 1px solid var(--border-soft); }
.nav-foot .lock-btn {
  width: 100%; text-align: left; background: none; border: none; color: var(--text-dim);
  padding: 8px 0; cursor: pointer; font-size: 12px;
}
.nav-foot .lock-btn:hover { color: var(--text-muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 52px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; border-bottom: 1px solid var(--border-soft);
  background: var(--bg);
}
.topbar h1 { font-size: 15px; font-weight: 600; margin: 0; }
.topbar .sub { color: var(--text-dim); font-size: 12px; margin-left: 10px; }

.content { flex: 1; overflow-y: auto; padding: 22px 24px 60px 24px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 7px 13px; font-size: 12.5px; cursor: pointer;
}
.btn:hover { background: var(--surface-3); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #04121C; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-critical { background: var(--critical); border-color: var(--critical); color: #2A0A0A; font-weight: 600; }
.btn-critical:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-sm { padding: 4px 9px; font-size: 11.5px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Panels / cards ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border-soft);
}
.panel-head h2 { font-size: 12.5px; font-weight: 600; margin: 0; letter-spacing: 0.02em; color: var(--text-muted); text-transform: uppercase; }
.panel-body { padding: 16px; }

.grid { display: grid; gap: 14px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) { .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .grid-3, .grid-4 { grid-template-columns: 1fr; } .nav { width: 64px; } .nav-item span.label, .nav-brand .name, .nav-brand .tag { display: none; } }

/* status summary strip */
.status-strip { display: flex; gap: 12px; margin-bottom: 18px; }
.status-chip {
  flex: 1; background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 14px 16px; border-left: 3px solid var(--border);
}
.status-chip .n { font-family: var(--font-mono); font-size: 26px; font-weight: 700; line-height: 1; }
.status-chip .l { font-size: 11px; color: var(--text-muted); margin-top: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.status-chip.critical { border-left-color: var(--critical); }
.status-chip.critical .n { color: var(--critical); }
.status-chip.warning { border-left-color: var(--warning); }
.status-chip.warning .n { color: var(--warning); }
.status-chip.healthy { border-left-color: var(--healthy); }
.status-chip.healthy .n { color: var(--healthy); }

/* provider / attention cards */
.pcard {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border-soft);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px; margin-bottom: 8px; cursor: pointer;
}
.pcard:hover { background: var(--surface-2); }
.pcard.critical { border-left-color: var(--critical); }
.pcard.warning { border-left-color: var(--warning); }
.pcard.healthy { border-left-color: var(--healthy); }
.pcard.unknown, .pcard.disabled { border-left-color: var(--text-dim); }
.pcard .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot.critical { background: var(--critical); box-shadow: 0 0 6px var(--critical); }
.dot.warning { background: var(--warning); }
.dot.healthy { background: var(--healthy); }
.dot.unknown, .dot.disabled, .dot.auth_failed, .dot.stale, .dot.degraded, .dot.rate_limited { background: var(--text-dim); }

.pcard .main-col { flex: 1; min-width: 0; }
.pcard .pname { font-weight: 600; font-size: 13.5px; }
.pcard .pmeta { color: var(--text-dim); font-size: 11.5px; margin-top: 2px; }
.pcard .stat { text-align: right; min-width: 92px; }
.pcard .stat .v { font-family: var(--font-mono); font-size: 15px; font-weight: 600; }
.pcard .stat .k { font-size: 10.5px; color: var(--text-dim); text-transform: uppercase; }

/* text tags */
.tag { display: inline-block; font-size: 10.5px; padding: 1px 7px; border-radius: 10px; border: 1px solid var(--border); color: var(--text-muted); }
.tag.critical { color: var(--critical); border-color: var(--critical-dim); background: var(--critical-dim); }
.tag.warning { color: var(--warning); border-color: var(--warning-dim); background: var(--warning-dim); }
.tag.healthy { color: var(--healthy); border-color: var(--healthy-dim); background: var(--healthy-dim); }

/* forms */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 11.5px; color: var(--text-muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.02em; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 10px; color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.field .hint { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* table */
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; color: var(--text-dim); font-weight: 500; font-size: 11px; text-transform: uppercase; padding: 8px 10px; border-bottom: 1px solid var(--border-soft); }
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--border-soft); }
table.data tr:hover td { background: var(--surface-2); }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(4,8,12,0.7); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border-soft); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 14.5px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border-soft); display: flex; justify-content: flex-end; gap: 8px; }
.close-x { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 18px; line-height: 1; }

/* empty state */
.empty { text-align: center; padding: 50px 20px; color: var(--text-dim); }
.empty .big { font-size: 30px; margin-bottom: 8px; }
.empty p { max-width: 380px; margin: 8px auto 16px auto; font-size: 13px; }

/* misc */
.divider { height: 1px; background: var(--border-soft); margin: 16px 0; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin: 24px 0 10px 0; }
.section-title:first-child { margin-top: 0; }
.toast-wrap { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--surface-3); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius); padding: 10px 14px; font-size: 12.5px; max-width: 320px; }
.toast.critical { border-left-color: var(--critical); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 0; }
.checkbox-row input { width: auto; }
.explain { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 10px 12px; font-size: 12px; color: var(--text-muted); margin-top: 10px; }
.kv { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--border-soft); font-size: 12.5px; }
.kv .k { color: var(--text-dim); }
.kv .v { font-family: var(--font-mono); }
