/* The admin panel. No external fonts or images; light and dark follow the system. */
:root {
  --bg: #f6f7f9;
  --fg: #1b1f24;
  --muted: #5d6673;
  --card: #ffffff;
  --line: #dde1e6;
  --accent: #1f6feb;
  --accent-fg: #ffffff;
  --ok-bg: #e6f4ea;
  --ok-fg: #1e6b34;
  --warn-bg: #fff4d6;
  --warn-fg: #7a5200;
  --bad-bg: #fde8e8;
  --bad-fg: #a0262b;
  --idle-bg: #eceef1;
  --idle-fg: #4b5360;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --fg: #e5e9ee;
    --muted: #9aa4b1;
    --card: #1a1f25;
    --line: #2c333c;
    --accent: #4c8ef7;
    --accent-fg: #0b0e12;
    --ok-bg: #173323;
    --ok-fg: #7fd69b;
    --warn-bg: #3a2e10;
    --warn-fg: #f0c661;
    --bad-bg: #3b1a1c;
    --bad-fg: #f19a9e;
    --idle-bg: #262c34;
    --idle-fg: #b3bcc8;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body.center { display: grid; min-height: 100vh; place-items: center; padding: 16px; }

main { max-width: 1200px; margin: 0 auto; padding: 16px; }

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

h1 { font-size: 1.5rem; margin: 0.4em 0; }
h1 small { color: var(--muted); font-weight: normal; font-size: 1rem; margin-left: 0.4em; }
h2 { font-size: 1.15rem; margin: 1.2em 0 0.5em; }
h3 { font-size: 1rem; margin: 1em 0 0.4em; }

.muted, .hint { color: var(--muted); }
.hint { display: block; font-size: 0.85em; font-weight: normal; }

/* top bar */
.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.top .brand { font-weight: 700; color: var(--fg); text-decoration: none; }
.top nav { display: flex; gap: 14px; flex: 1; }
.top nav a, .top .me a { text-decoration: none; color: var(--muted); }
.top a.on { color: var(--fg); font-weight: 600; }
.top .me { display: flex; align-items: center; gap: 12px; }
.top .who { font-weight: 600; }

.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }

/* cards and layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; }
main.card { margin-top: 16px; }
.narrow { max-width: 460px; width: 100%; }
section.card.narrow { margin-top: 24px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-top: 12px; }
.cols .card h2 { margin-top: 0.2em; }

/* forms and buttons */
form.inline { display: inline; margin: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; margin-bottom: 12px; }
.filters label { display: flex; flex-direction: column; gap: 2px; font-size: 0.85em; color: var(--muted); }

input, select, textarea {
  font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px;
}
input[readonly] { color: var(--muted); }
textarea { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.9em; }

button, .button {
  display: inline-block; font: inherit; font-size: 0.95em; cursor: pointer; text-decoration: none;
  color: var(--fg); background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px;
}
button:hover, .button:hover { border-color: var(--muted); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
button.danger { color: var(--bad-fg); border-color: var(--bad-fg); }
button.link { background: none; border: none; padding: 0; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }
td.actions { margin: 0; }
.htmx-request button, button.htmx-request { opacity: 0.6; cursor: progress; }

/* notices */
.notice { padding: 8px 12px; border-radius: 6px; margin: 8px 0; }
ul.notice { padding-left: 28px; }
.notice.ok { background: var(--ok-bg); color: var(--ok-fg); }
.notice.warn { background: var(--warn-bg); color: var(--warn-fg); }
.notice.error { background: var(--bad-bg); color: var(--bad-fg); }
.notice.secret { background: var(--warn-bg); color: var(--warn-fg); }
.notice.secret code { font-size: 1.2em; letter-spacing: 0.05em; user-select: all; }

/* tables */
table.grid { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); }
table.grid th, table.grid td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid th { font-size: 0.85em; color: var(--muted); font-weight: 600; }
table.grid.small { font-size: 0.9em; }
td.nowrap { white-space: nowrap; }
td.details { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.85em; word-break: break-all; }
tr.security td:first-child { box-shadow: inset 3px 0 var(--warn-fg); }
tr.operation td:first-child { box-shadow: inset 3px 0 var(--accent); }

@media (max-width: 760px) {
  table.grid { display: block; overflow-x: auto; }
}

/* key/value lists */
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }
.pre { white-space: pre-wrap; }
ul.plain { padding-left: 18px; margin: 4px 0; }

/* status pills */
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.85em; background: var(--idle-bg); color: var(--idle-fg); }
.pill.online, .pill.match { background: var(--ok-bg); color: var(--ok-fg); }
.pill.connecting, .pill.wait { background: var(--warn-bg); color: var(--warn-fg); }
.pill.mismatch { background: var(--bad-bg); color: var(--bad-fg); }

.pager { display: flex; gap: 16px; align-items: center; margin: 12px 0; }

/* guest access */
.stack label.check, label.check { flex-direction: row; align-items: center; gap: 6px; font-weight: normal; flex-wrap: wrap; }
label.check .hint { flex-basis: 100%; }
fieldset.scopes { border: 1px solid var(--line, #ccc); border-radius: 6px; padding: 8px 12px; margin: 0;
  display: flex; flex-direction: column; gap: 6px; }
fieldset.scopes legend { font-weight: 600; padding: 0 4px; }
/* Checkbox, scope name, description: a long description wraps in its own column. */
fieldset.scopes label.check { display: grid; grid-template-columns: auto 4.5em 1fr; align-items: baseline; }
.notice.handover p { margin: 4px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.notice.handover code { word-break: break-all; }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
