:root {
  --bg: #f5f7fa; --surface: #fff; --text: #1f2933; --muted: #616e7c; --border: #d9e2ec;
  --primary: #2251cc; --primary-text: #fff; --danger: #c62828; --success-bg: #e3f6ea; --success: #1e6b3a;
  --error-bg: #fdecea; --notice-bg: #fff6e0; --code-bg: #eef2f7;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --surface: #1b2026; --text: #e4e7eb; --muted: #9aa5b1; --border: #323a45;
    --primary: #5b8def; --primary-text: #0b1020; --danger: #ef6b6b; --success-bg: #173322; --success: #8fd9a8;
    --error-bg: #3a1c1c; --notice-bg: #3a3019; --code-bg: #262d36;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
main.narrow { max-width: 440px; margin: 8vh auto; padding: 0 16px; }
main.wide { max-width: 1100px; margin: 24px auto 64px; padding: 0 16px; }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
a { color: var(--primary); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
.muted, small { color: var(--muted); }
small { display: block; font-size: .85rem; font-weight: normal; }
.card, .panel { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 24px; }
.panel { margin: 20px 0; }
.stack { display: grid; gap: 10px; margin: 16px 0; }
input, select, textarea { font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; width: 100%; }
textarea { resize: vertical; }
input[type=checkbox] { width: auto; margin-right: 6px; }
button, .button { font: inherit; display: inline-block; padding: 8px 16px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; }
button.primary, .button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 600; }
button.danger { color: var(--danger); border-color: var(--danger); }
button.small, .button.small { padding: 4px 10px; font-size: .875rem; }
button.link { border: 0; background: none; color: var(--primary); padding: 4px 0; text-decoration: underline; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.check { display: flex; align-items: center; gap: 4px; }
.code { font: 600 1.75rem ui-monospace, monospace; letter-spacing: .3em; text-align: center; background: var(--code-bg); border-radius: 8px; padding: 12px; }
.error, .notice, .success { padding: 10px 14px; border-radius: 6px; }
.error { background: var(--error-bg); color: var(--danger); }
.notice { background: var(--notice-bg); }
.success { background: var(--success-bg); color: var(--success); }
.topbar { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar .brand { font-weight: 700; color: var(--text); text-decoration: none; }
.topbar .brand span { color: var(--muted); font-weight: 400; }
.topbar nav { display: flex; gap: 16px; flex: 1; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; }
.heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.crumbs { margin: 0; color: var(--muted); }
table { border-collapse: collapse; width: 100%; }
.list th, .list td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.list th { font-size: .85rem; color: var(--muted); font-weight: 600; }
.kv th { text-align: left; width: 220px; padding: 6px 10px 6px 0; color: var(--muted); font-weight: 500; vertical-align: top; }
.kv td { padding: 6px 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 16px 0 28px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; text-decoration: none; color: var(--text); display: flex; flex-direction: column; }
.tile strong { font-size: 1.75rem; }
.tile span { color: var(--muted); }
.grid-form fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin: 0 0 16px; display: grid; gap: 14px; background: var(--surface); }
.grid-form legend { font-weight: 600; padding: 0 6px; }
.grid-form label { display: grid; gap: 4px; font-weight: 500; }
.grid-form label.check { display: flex; flex-wrap: wrap; font-weight: 400; }
.grid-form label.check small { flex-basis: 100%; margin-left: 24px; }
.field { display: grid; gap: 2px; }
.field > span { font-weight: 500; }
.duration { display: flex; gap: 8px; max-width: 360px; }
.duration input { flex: 1; }
.duration select { width: auto; }
.row-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.row-form input:not([type=checkbox]), .row-form select { width: auto; flex: 1 1 140px; }
.row-form.compact { margin: 0; }
.row-form .type { color: var(--muted); font-size: .85rem; min-width: 56px; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
form.inline { display: inline-flex; gap: 8px; align-items: center; margin: 0; }
.badge { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 10px; background: var(--code-bg); }
.badge.off { color: var(--danger); }
.danger-zone { border-color: var(--danger); }
.secret { display: inline-block; margin: 6px 0; }
details summary { cursor: pointer; color: var(--primary); }
@media (max-width: 640px) {
  .list thead { display: none; }
  .list td { display: block; border: 0; padding: 4px 0; }
  .list tr { display: block; border-bottom: 1px solid var(--border); padding: 8px 0; }
  .kv th { width: auto; display: block; }
  .kv td { display: block; }
  .row-actions { justify-content: flex-start; }
}
.grid-form input[type=number] { max-width: 200px; }
