/* nQuorate Admin — dark theme, palette per validated dataviz reference */
:root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #222221;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --good: #0ca30c;
  --critical: #d03b3b;
  /* categorical slots (dark-stepped) */
  --s-blue: #3987e5;
  --s-aqua: #199e70;
  --s-yellow: #c98500;
  --s-green: #008300;
  --s-violet: #9085e9;
  --s-red: #e66767;
  --s-magenta: #d55181;
  --s-orange: #d95926;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
}
button, input, select { font-family: inherit; font-size: 14px; color: inherit; }
a { color: var(--s-blue); text-decoration: none; }

#app { max-width: 1180px; margin: 0 auto; padding: 0 20px 60px; }

/* ---------- top bar ---------- */
#topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 14px 0; margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand span { color: var(--text-muted); font-weight: 500; }
#tabs { display: flex; gap: 4px; }
.tab {
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary); padding: 7px 12px; border-radius: 8px;
}
.tab:hover { background: var(--surface-1); }
.tab.active { background: var(--surface-2); color: var(--text-primary); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
select, input[type="text"], input[type="password"] {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; outline: none;
}
select:focus, input:focus { border-color: var(--s-blue); }
button.primary {
  background: var(--s-blue); border: none; color: #fff; font-weight: 600;
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
}
button.primary:hover { filter: brightness(1.1); }
button.ghost {
  background: none; border: 1px solid var(--border); color: var(--text-secondary);
  padding: 7px 12px; border-radius: 8px; cursor: pointer;
}
button.ghost:hover { background: var(--surface-1); color: var(--text-primary); }
button.danger { border-color: transparent; color: var(--critical); background: none; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
button.danger:hover { background: rgba(208, 59, 59, 0.12); }

/* ---------- layout blocks ---------- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.card h3 {
  margin: 0 0 12px; font-size: 13px; font-weight: 600;
  color: var(--text-secondary); letter-spacing: 0.01em;
}
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-6 { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 1100px) {
  .grid.cols-6 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .grid.cols-6 { grid-template-columns: repeat(2, 1fr); }
}
.grid.cols-6 .tile .value { font-size: 21px; }
@media (max-width: 600px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}
.section { margin-bottom: 18px; }
.page-title { display: flex; align-items: baseline; gap: 12px; margin: 4px 0 16px; }
.page-title h2 { margin: 0; font-size: 20px; }
.page-title .sub { color: var(--text-muted); }
.back { color: var(--text-secondary); cursor: pointer; background: none; border: none; padding: 0; font-size: 14px; }
.back:hover { color: var(--text-primary); }

/* ---------- stat tiles ---------- */
.tile .label { color: var(--text-muted); font-size: 12.5px; margin-bottom: 4px; }
.tile .value { font-size: 26px; font-weight: 650; letter-spacing: -0.01em; }
.tile .sub { color: var(--text-secondary); font-size: 12.5px; margin-top: 3px; }
.live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--good); margin-right: 6px;
  box-shadow: 0 0 0 3px rgba(12, 163, 12, 0.18);
}

/* ---------- site cards ---------- */
.site-card { cursor: pointer; transition: border-color 0.12s; }
.site-card:hover { border-color: var(--s-blue); }
.site-card .head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 2px; }
.site-card .name { font-weight: 650; font-size: 15px; }
.site-card .domain { color: var(--text-muted); font-size: 12.5px; }
.site-card .nums { display: flex; gap: 18px; margin: 10px 0 4px; }
.site-card .nums .n { font-size: 20px; font-weight: 650; }
.site-card .nums .l { color: var(--text-muted); font-size: 11.5px; }
.site-card svg { display: block; width: 100%; }

/* ---------- charts ---------- */
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; }
.legend { display: flex; gap: 16px; margin-bottom: 8px; flex-wrap: wrap; }
.legend .item { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: 12.5px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; }
.tooltip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 11px; font-size: 12.5px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  max-width: 280px;
}
.tooltip .t-title { color: var(--text-muted); margin-bottom: 4px; }
.tooltip .t-row { display: flex; align-items: center; gap: 7px; justify-content: space-between; }
.tooltip .t-row .k { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.tooltip .t-row .v { font-variant-numeric: tabular-nums; font-weight: 600; }
.tooltip .swatch { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

/* ---------- bar lists ---------- */
.barlist .row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 5px 8px; margin: 0 -8px; border-radius: 6px; position: relative;
}
.barlist .row .fill {
  position: absolute; left: 0; top: 2px; bottom: 2px; border-radius: 5px;
  background: var(--s-blue); opacity: 0.14;
}
.barlist .row .lbl {
  position: relative; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text-secondary); max-width: 75%;
}
.barlist .row .val { position: relative; font-variant-numeric: tabular-nums; color: var(--text-primary); font-weight: 600; }
.barlist .empty { color: var(--text-muted); padding: 8px 0; }

/* ---------- tables ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th {
  text-align: left; color: var(--text-muted); font-weight: 500;
  padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 6px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data th.num { text-align: right; }
.scroll-x { overflow-x: auto; }

/* ---------- settings ---------- */
.snippet {
  background: var(--page); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; color: var(--text-secondary); overflow-x: auto; white-space: pre;
  margin: 8px 0;
}
.copy-btn { font-size: 12px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.inline-form input { flex: 1; min-width: 140px; }
.muted { color: var(--text-muted); font-size: 12.5px; }
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px;
  background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--border);
}
.pill.ok { color: var(--good); }
.pill.err { color: var(--critical); }
.kv { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

/* ---------- login ---------- */
.login-wrap { display: flex; justify-content: center; padding-top: 14vh; }
.login-card { width: 340px; text-align: center; }
.login-card h1 { font-size: 18px; margin: 0 0 4px; }
.login-card p { color: var(--text-muted); margin: 0 0 18px; }
.login-card input { width: 100%; margin-bottom: 10px; }
.login-card button { width: 100%; }
.login-err { color: var(--critical); font-size: 12.5px; min-height: 18px; margin-top: 8px; }

.empty-state { text-align: center; color: var(--text-muted); padding: 40px 0; }
.empty-state .big { font-size: 15px; color: var(--text-secondary); margin-bottom: 6px; }
