:root {
  --bg: #f4f4f5;
  --card: #ffffff;
  --text: #18181b;
  --muted: #71717a;
  --line: #e4e4e7;
  --accent: #2563eb;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #09090b;
    --card: #18181b;
    --text: #fafafa;
    --muted: #a1a1aa;
    --line: #27272a;
    --accent: #60a5fa;
    --ok: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 8px 0 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 15px; margin: 0 0 12px; }
main { max-width: 1280px; margin: 0 auto; padding: 16px; }

.top {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--text); }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; }
.top nav a { padding: 6px 10px; border-radius: 6px; color: var(--muted); }
.top nav a.on { background: var(--bg); color: var(--text); font-weight: 600; }
.logout { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px; margin-bottom: 16px;
}
.card canvas { height: 260px !important; width: 100% !important; }
.scroll { overflow-x: auto; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.cols > .card { margin-bottom: 0; }
.cols { margin-bottom: 16px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px;
  color: var(--text); display: flex; flex-direction: column; gap: 4px;
}
a.tile:hover { text-decoration: none; border-color: var(--accent); }
.tile b { font-size: 22px; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: 12px; }

table { width: 100%; border-collapse: collapse; }
td, th { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
table.list td { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.faded { opacity: .5; }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--line); color: var(--muted);
}
.badge.ok { color: var(--ok); border-color: currentColor; }
.badge.warn { color: var(--warn); border-color: currentColor; }
.badge.bad { color: var(--bad); border-color: currentColor; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.dot.off { background: var(--bad); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid currentColor; }
.flash.ok { color: var(--ok); }
.flash.bad { color: var(--bad); }

input, select, button, textarea {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.danger { color: var(--bad); }
button.danger:hover { border-color: var(--bad); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; }
input.short { width: 90px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input[type=search] { min-width: 240px; flex: 1 1 240px; max-width: 360px; }
.pager { display: flex; gap: 16px; justify-content: center; align-items: center; margin: 8px 0 24px; }

.actions form { margin-bottom: 12px; }
.actions .row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.actions .row form { margin: 0; }
.actions label { margin-right: 8px; }
details summary { cursor: pointer; color: var(--bad); }

.props { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.props dt { color: var(--muted); }
.props dd { margin: 0; word-break: break-all; }

.push-form { display: flex; flex-direction: column; gap: 10px; max-width: 560px; }
.push-form label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
.push-form textarea { min-height: 80px; resize: vertical; font: inherit; }

.login { max-width: 360px; margin: 10vh auto; display: flex; flex-direction: column; gap: 12px; }
.login label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }

@media (max-width: 640px) {
  .logout { margin-left: 0; }
  .props { grid-template-columns: 1fr; }
  .props dt { margin-top: 6px; }
}
