:root {
  --bg: #ffffff;
  --bg-subtle: #f7f7f8;
  --border: #e5e7eb;
  --text: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --status-good: #16a34a;       --status-good-bg: #f0fdf4;
  --status-watch: #ca8a04;      --status-watch-bg: #fefce8;
  --status-bad: #dc2626;        --status-bad-bg: #fef2f2;
  --status-stale: #6b7280;      --status-stale-bg: #f3f4f6;
  --status-info: #2563eb;       --status-info-bg: #eff6ff;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px; line-height: 1.5; }
body { font-variant-numeric: tabular-nums; }
.num, td.num, .value, .delta { font-variant-numeric: tabular-nums; }

header.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg); border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex; flex-direction: column; gap: 8px;
}
header.top .title { font-size: 18px; font-weight: 600; }
header.top .headline { color: var(--text-secondary); font-size: 13px; }

nav.tabs {
  display: flex; gap: 0; overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 58px; z-index: 9;
}
nav.tabs a {
  padding: 10px 16px; color: var(--text-secondary); text-decoration: none;
  border-bottom: 2px solid transparent; white-space: nowrap; font-size: 13px;
}
nav.tabs a.active { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }
nav.tabs a:hover { color: var(--text); }

main { padding: 16px 20px 60px; max-width: 1280px; margin: 0 auto; }

.section { margin-bottom: 24px; }
.section h2 { font-size: 13px; font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 8px; }

.card { background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 12px; }
.card.subtle { background: var(--bg-subtle); }
.card .title { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.card .meta { color: var(--text-secondary); font-size: 12px; }
.card .value { font-size: 22px; font-weight: 600; }
.card .delta { font-size: 12px; color: var(--text-secondary); }

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

.pill { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.pill.good   { color: var(--status-good);   background: var(--status-good-bg); }
.pill.watch  { color: var(--status-watch);  background: var(--status-watch-bg); }
.pill.bad    { color: var(--status-bad);    background: var(--status-bad-bg); }
.pill.stale  { color: var(--status-stale);  background: var(--status-stale-bg); }
.pill.info   { color: var(--status-info);   background: var(--status-info-bg); }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--text-secondary); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
td.num, th.num { text-align: right; }

button { font: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--bg);
  color: var(--text); padding: 6px 12px; border-radius: 4px; font-size: 12px; }
button:hover { background: var(--bg-subtle); }
button.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
button.primary:hover { opacity: 0.9; }
button.danger { color: var(--status-bad); border-color: var(--status-bad); }

input, select, textarea { font: inherit; border: 1px solid var(--border); padding: 6px 10px;
  border-radius: 4px; background: var(--bg); color: var(--text); width: 100%; }
label { font-size: 12px; color: var(--text-secondary); display: block; margin-bottom: 4px; }
.field { margin-bottom: 10px; }

.banner { padding: 10px 12px; border-radius: 6px; background: var(--status-info-bg);
  color: var(--status-info); margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.banner button { color: var(--status-info); border-color: var(--status-info); }

.sparkline-host { height: 40px; margin-top: 6px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--bg); border-radius: 8px; padding: 20px; max-width: 500px; width: 100%;
  max-height: 90vh; overflow-y: auto; }
.modal h3 { margin: 0 0 12px; font-size: 16px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

.empty { color: var(--text-muted); font-style: italic; font-size: 13px; padding: 12px; }
.divider { border-top: 1px solid var(--border); margin: 16px 0; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: none; }
.row .desc { flex: 1; min-width: 0; }
.row .desc .name { font-weight: 500; }
.row .desc .meta { color: var(--text-secondary); font-size: 12px; }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 4px 12px; font-size: 13px; }
.kv .k { color: var(--text-secondary); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 6px;
  font-size: 13px; z-index: 200; opacity: 0; transition: opacity 0.2s; }
.toast.show { opacity: 1; }
.toast.error { background: var(--status-bad); }
