:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1c2030;
  --muted: #61677a;
  --border: #d9dce5;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --accent-soft: #eef0ff;
  --danger: #c0262d;
  --ok: #1a7f4b;
  --ok-soft: #e4f5ec;
  --warn: #9a6200;
  --warn-soft: #fdf1d8;
  --danger-soft: #fdeaea;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141b;
    --surface: #1b1e28;
    --text: #e8eaf1;
    --muted: #9aa1b5;
    --border: #2f3445;
    --accent: #8b87ff;
    --accent-text: #12141b;
    --accent-soft: #262a45;
    --danger: #ff7b7f;
    --ok: #5fd39a;
    --ok-soft: #173326;
    --warn: #f0b955;
    --warn-soft: #3a2e12;
    --danger-soft: #3d1c1e;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.top {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; color: var(--text); }
.brand:hover { text-decoration: none; }
.mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), #22b8cf);
}
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.logout { display: flex; align-items: center; gap: 12px; margin: 0; }
.who { color: var(--muted); }

main { max-width: 920px; margin: 0 auto; padding: 24px 16px 64px; }

body.card .top { justify-content: center; background: transparent; border: 0; padding-top: 48px; }
body.card main { max-width: 420px; padding-top: 8px; }

h1 { font-size: 24px; line-height: 1.25; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.heading h1 { margin: 0; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  overflow-x: auto;
}
.panel.highlight { border-color: var(--accent); background: var(--accent-soft); }
.panel > :last-child { margin-bottom: 0; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
code { font: 13px ui-monospace, "Cascadia Mono", Consolas, monospace; overflow-wrap: anywhere; }

.stack { display: flex; flex-direction: column; gap: 14px; margin: 0; }
.stack.narrow, form.narrow { max-width: 420px; }
label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; }
label small, fieldset small, form > small { font-weight: 400; color: var(--muted); font-size: 13px; }
label.check { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 400; }
label.check small { flex-basis: 100%; padding-left: 24px; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
legend { font-weight: 600; padding: 0 6px; }

input[type="text"], input[type="email"], input[type="password"], input[type="url"], select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  width: 100%;
}
textarea { font: 13px ui-monospace, "Cascadia Mono", Consolas, monospace; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input:disabled { color: var(--muted); background: var(--bg); }
input.copy { font: 13px ui-monospace, "Cascadia Mono", Consolas, monospace; }

button, .button {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  display: inline-block;
  text-align: center;
}
.button:hover { text-decoration: none; }
button.primary, .button.primary { background: var(--accent); color: var(--accent-text); }
button.secondary, .button.secondary { background: transparent; border-color: var(--border); color: var(--text); }
button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
button:hover:not(:disabled), .button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 400; }
button.link.danger { color: var(--danger); }
button.link:hover { text-decoration: underline; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.actions form { margin: 0; }

.alert { padding: 10px 14px; border-radius: 8px; margin: 0 0 14px; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.info { background: var(--accent-soft); color: var(--accent); }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.off { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
tr.inactive td { color: var(--muted); }
td form { margin: 0; }
table + form { margin-top: 14px; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; margin: 0 0 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.apps { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.apps a { display: block; padding: 10px 16px; border: 1px solid var(--border); border-radius: 8px; font-weight: 600; }
.apps a:hover { border-color: var(--accent); text-decoration: none; }

.steps { padding-left: 20px; margin: 0 0 16px; }
.steps li { margin-bottom: 10px; }
.qr { background: #ffffff; padding: 8px; border-radius: 8px; display: block; }
.codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, max-content); gap: 8px 32px; }
.codes code { font-size: 15px; }

@media (max-width: 640px) {
  .top { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: 8px; }
}
