:root {
  --bg: #f4f6f9; --card: #fff; --text: #1b2430; --muted: #5d6b7c; --line: #dde3ea;
  --primary: #1565c0; --primary-text: #fff; --danger: #c62828; --ok: #2e7d32; --warn: #a15c00; --info: #1565c0;
  --ok-bg: #e8f5e9; --err-bg: #fdecea; --warn-bg: #fff4e0; --info-bg: #e3effc; --muted-bg: #eef1f4;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11161c; --card: #1a2129; --text: #e3e8ee; --muted: #93a1b0; --line: #2c3540;
    --primary: #5aa0f0; --primary-text: #0b1220; --danger: #ef6f6c; --ok: #6cc070; --warn: #f0b04a; --info: #5aa0f0;
    --ok-bg: #18301b; --err-bg: #3a1c1c; --warn-bg: #3a2c12; --info-bg: #15283f; --muted-bg: #242c35; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
a { color: var(--primary); }
h1 { font-size: 1.6rem; margin: 1.4rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .8rem; }
h3 { font-size: 1rem; margin: .2rem 0 .5rem; }
code { font: .9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
pre { background: var(--muted-bg); padding: 12px; border-radius: 6px; overflow-x: auto; font-size: .85rem; }

.top { background: var(--card); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 18px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); font-size: 1.1rem; }
.brand span { color: var(--muted); font-weight: 400; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 6px; }
nav a:hover { background: var(--muted-bg); }
nav a.on { color: var(--text); background: var(--muted-bg); font-weight: 600; }
.logout { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.who { color: var(--muted); font-size: .9rem; }
.sim { background: var(--warn-bg); color: var(--warn); text-align: center; padding: 6px 16px; font-size: .9rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin: 0 0 18px; overflow-x: auto; }
.card.narrow { max-width: 440px; margin: 48px auto; }
details.card > summary { cursor: pointer; font-weight: 600; }
.center { text-align: center; }
.small { font-size: .875rem; }
.muted { color: var(--muted); }
.foot { color: var(--muted); font-size: .8rem; padding: 24px 16px 40px; }

label { display: block; margin: 0 0 12px; font-weight: 600; font-size: .9rem; }
label.check { font-weight: 400; display: flex; gap: 8px; align-items: center; margin: 4px 0; }
fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 0 0 12px; padding: 8px 12px; }
legend { font-weight: 600; font-size: .9rem; padding: 0 4px; }
input, select { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; font: inherit; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 6px; }
input[type=checkbox] { display: inline; width: auto; margin: 0; }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; align-items: end; }
.grid3 button { margin-bottom: 12px; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }

button, .btn { display: inline-block; font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--muted-bg); color: var(--text); text-decoration: none; }
button.primary, .btn.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.small, .btn.small { padding: 5px 10px; font-size: .85rem; }
button.link { background: none; border: 0; padding: 0; color: var(--primary); font-weight: 400; text-decoration: underline; }
button:disabled { opacity: .6; cursor: wait; }
.card.narrow button.primary { width: 100%; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
td.actions { white-space: nowrap; text-align: right; }
td.actions form { display: inline; margin-left: 6px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.muted { background: var(--muted-bg); color: var(--muted); }
.tag { display: inline-block; background: var(--muted-bg); border-radius: 4px; padding: 1px 6px; margin: 1px 2px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.dot.on { background: var(--ok); }

.flash { padding: 10px 14px; border-radius: 6px; margin: 0 0 16px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--err-bg); color: var(--danger); }
.flash ul { margin: 0; padding-left: 18px; }
main > .flash { margin-top: 16px; }

svg.qr { width: 240px; max-width: 100%; height: auto; border-radius: 6px; }
.secret { word-break: break-all; }

@media (max-width: 640px) {
  .logout { margin-left: 0; width: 100%; justify-content: space-between; padding-bottom: 8px; }
  .card { padding: 14px; }
  .card.narrow { margin: 20px auto; }
  table:not(.keep), table:not(.keep) tbody, table:not(.keep) tr, table:not(.keep) td { display: block; width: 100%; }
  table:not(.keep) thead { display: none; }
  table:not(.keep) tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  table:not(.keep) td { border: 0; padding: 3px 0; }
  table:not(.keep) td:empty { display: none; }
  td.actions { white-space: normal; text-align: left; padding-top: 8px; }
  td.actions form:first-child, td.actions .btn:first-child { margin-left: 0; }
}

.row.between { justify-content: space-between; align-items: center; margin-bottom: 8px; }
.row.between h1, .row.between h2 { margin-bottom: 0; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 16px; }
td.detail { word-break: break-word; max-width: 420px; }
textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 6px; resize: vertical; }
.guide { white-space: pre-line; background: var(--muted-bg); border-radius: 6px; padding: 12px 14px; margin: 0 0 12px; }
.flash.warn { background: var(--warn-bg); color: var(--warn); }
.flash.warn a { color: inherit; }
.service h2 { margin-bottom: 4px; }
