/* Tene dashboard.
 *
 * One stylesheet, no framework, no build step. Light and dark both styled
 * from the same custom properties, so the page follows the operating system
 * rather than committing to one look.
 *
 * The grid is `.tiles`. Everything that looks like a card uses it. A previous
 * dashboard invented a `.cards` class that did not exist, silently fell back
 * to a 380px form container, and rendered four enormous stacked boxes.
 */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #16191d;
  --muted: #697280;
  --line: #e2e5ea;
  --accent: #1f6feb;
  --ok: #18794e;
  --ok-bg: #e8f5ee;
  --warn: #9a6700;
  --warn-bg: #fff6e0;
  --bad: #b42318;
  --bad-bg: #fdeceb;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --panel: #171b21;
    --ink: #e7eaee;
    --muted: #8b95a3;
    --line: #262c35;
    --accent: #589bff;
    --ok: #4ec38a;
    --ok-bg: #11291f;
    --warn: #e3b341;
    --warn-bg: #2a2212;
    --bad: #ff7b72;
    --bad-bg: #2d1715;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--accent); }

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 650;
  font-size: 17px;
  text-decoration: none;
  color: var(--ink);
}

.topbar nav { display: flex; gap: 18px; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; color: var(--muted); font-weight: 500; }
.topbar nav a:hover { color: var(--ink); }

.who { margin-left: auto; display: flex; align-items: center; gap: 12px; }

button.link {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
}

/* ----------------------------------------------------------------- tiles */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin: 0 0 24px;
}

.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.tile .n { font-size: 26px; font-weight: 650; line-height: 1.2; }
.tile .k { color: var(--muted); font-size: 13px; }
.tile.ok .n { color: var(--ok); }
.tile.warn .n { color: var(--warn); }
.tile.bad .n { color: var(--bad); }

/* ---------------------------------------------------------------- panels */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 0 0 20px;
}

.panel > h2 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 620;
}

.panel > h2 + .sub { margin: 0 0 14px; color: var(--muted); font-size: 13px; }

h1 { font-size: 22px; margin: 0 0 4px; }
.lede { color: var(--muted); margin: 0 0 20px; }

/* ---------------------------------------------------------------- tables */

.scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 560; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.muted { color: var(--muted); }

/* ----------------------------------------------------------------- pills */

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 560;
  white-space: nowrap;
}

.pill.ok    { background: var(--ok-bg);   color: var(--ok); }
.pill.warn  { background: var(--warn-bg); color: var(--warn); }
.pill.bad   { background: var(--bad-bg);  color: var(--bad); }
.pill.muted { background: var(--line);    color: var(--muted); }

/* ---------------------------------------------------------------- charts */

.chart { margin: 0 0 18px; }
.chart svg { width: 100%; height: 160px; display: block; }
.chart figcaption {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.chart-axis  { stroke: var(--line); stroke-width: 1; }
.chart-bar   { fill: var(--accent); opacity: .85; }
.chart-line  { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.chart-point { fill: var(--accent); }
.chart-peak  { fill: var(--muted); font-size: 11px; }
.chart-empty { padding: 20px 0; }

/* ----------------------------------------------------------------- forms */

form.inline { display: inline-flex; gap: 8px; align-items: center; }

input[type=text], input[type=email], input[type=password], select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}

button.btn {
  padding: 8px 14px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
}

button.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.btn.danger  { background: var(--bad-bg); border-color: var(--bad-bg); color: var(--bad); }
button.btn:hover { filter: brightness(1.05); }

/* ------------------------------------------------------------- login box */

.card {
  max-width: 380px;
  margin: 72px auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
}

.card h1 { margin-bottom: 18px; }
.card label { display: block; margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
.card input { width: 100%; }
.card button { width: 100%; margin-top: 18px; }

.error {
  background: var(--bad-bg);
  color: var(--bad);
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 14px;
  margin-bottom: 8px;
}

.notice {
  background: var(--warn-bg);
  color: var(--warn);
  padding: 12px 14px;
  border-radius: 7px;
  margin-bottom: 16px;
}

footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px 32px;
  font-size: 13px;
}

/* ------------------------------------------------------------ small kv */

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 20px; }
.kv .k { color: var(--muted); font-size: 12.5px; }
.kv .v { font-weight: 550; }
