:root {
  --bg: #14171c;
  --panel: #1b1f26;
  --panel-raised: #20242c;
  --border: #2a2f38;
  --text: #e8eaed;
  --muted: #8b93a1;
  --muted-2: #5f6673;
  --accent: #5b8def;
  --accent-soft: rgba(91, 141, 239, 0.14);
  --good: #2fbf9f;
  --good-soft: rgba(47, 191, 159, 0.14);
  --bad: #e2574c;
  --bad-soft: rgba(226, 87, 76, 0.14);
  --warn: #e0a940;
  --warn-soft: rgba(224, 169, 64, 0.14);
  --radius: 6px;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; }

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

/* ---------- Sidebar ---------- */
.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 22px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent), #2fbf9f);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #0d0f13; letter-spacing: 0.5px;
}
.brand-title { font-weight: 600; font-size: 14.5px; }
.brand-sub { font-size: 11.5px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-group-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted-2); margin: 16px 8px 6px; font-weight: 600;
}
.nav-group-label:first-child { margin-top: 4px; }

.nav-item {
  text-align: left; background: transparent; border: none; color: var(--muted);
  padding: 9px 12px; border-radius: var(--radius); cursor: pointer;
  font-size: 13.5px; font-weight: 500; transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--panel-raised); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }

.sidebar-foot {
  display: flex; align-items: center; gap: 8px; padding: 10px 8px 2px;
  border-top: 1px solid var(--border); margin-top: 10px; font-size: 12px; color: var(--muted);
}
.health-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); }
.health-dot.ok { background: var(--good); }
.health-dot.bad { background: var(--bad); }

/* ---------- Content ---------- */
.content { flex: 1; min-width: 0; padding: 28px 36px 60px; max-width: 1280px; }
.content-header { margin-bottom: 22px; }
#pageTitle { font-size: 21px; font-weight: 600; margin: 0 0 4px; }
.page-sub { color: var(--muted); font-size: 13px; margin: 0; }

.page-body { display: flex; flex-direction: column; gap: 20px; }

/* ---------- Panels / cards ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px;
}
.panel-title { font-size: 14px; font-weight: 600; margin: 0 0 12px; }
.panel-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-row .filters { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 10px; border-bottom: 1px solid var(--border);
}
tbody td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: var(--panel-raised); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.table-wrap { overflow-x: auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel-raised); color: var(--text); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: var(--radius); cursor: pointer; font-weight: 500; font-size: 13px;
  transition: border-color .12s, background .12s;
}
.btn:hover { border-color: var(--muted-2); }
.btn-primary { background: var(--accent); color: #0d1220; border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: #6f9bf2; }
.btn-good { background: var(--good); color: #08211b; border-color: var(--good); font-weight: 600; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--panel-raised); }

/* ---------- Forms ---------- */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
input[type=text], input[type=number], input[type=date], input[type=search], select, textarea {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 8px 10px; border-radius: var(--radius); width: 100%; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.field { margin-bottom: 12px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
textarea { resize: vertical; min-height: 70px; }

input[type=range] {
  width: 100%; accent-color: var(--accent);
}
.slider-field { margin-bottom: 18px; }
.slider-label-row { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 6px; }
.slider-value { font-family: var(--mono); color: var(--accent); font-weight: 600; }

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 100px;
  font-size: 11.5px; font-weight: 600;
}
.pill-good { background: var(--good-soft); color: var(--good); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-muted { background: rgba(255,255,255,0.06); color: var(--muted); }

/* ---------- Modal ---------- */
.modal-root:empty { display: none; }
.modal-overlay {
  position: fixed; inset: 0; background: rgba(8,10,14,0.66); display: flex;
  align-items: flex-start; justify-content: center; padding: 5vh 20px; z-index: 100; overflow-y: auto;
}
.modal-box {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  width: 100%; max-width: 640px; padding: 22px 24px; margin-bottom: 40px;
}
.modal-box.wide { max-width: 820px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 16px; }

/* ---------- Toast ---------- */
.toast-root { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: var(--panel-raised); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  padding: 10px 16px; border-radius: var(--radius); font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.toast.err { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--good); }

/* ---------- Misc ---------- */
.empty-state { color: var(--muted); padding: 30px 10px; text-align: center; font-size: 13px; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 14px; }
.metric-box { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.metric-box .k { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.metric-box .v { font-family: var(--mono); font-size: 15px; font-weight: 600; }
.reason-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.reason-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius); background: var(--bg); border: 1px solid var(--border);
  font-size: 12.5px;
}
.reason-row .rp { color: var(--muted); }
.reason-row .rv { font-family: var(--mono); }
.summary-strip { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.summary-chip { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 16px; min-width: 120px; }
.summary-chip .k { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.summary-chip .v { font-size: 19px; font-weight: 700; font-family: var(--mono); }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 12.5px; font-weight: 500; }
.link-btn:hover { text-decoration: underline; }
.hint { color: var(--muted-2); font-size: 11.5px; margin-top: 4px; }
.tag { font-family: var(--mono); font-size: 11.5px; background: var(--panel-raised); padding: 2px 6px; border-radius: 4px; color: var(--muted); }
.glossary { font-size: 12px; color: var(--muted); margin-bottom: 14px; line-height: 1.9; }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
