:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1c2330;
  --muted: #5f6b7a;
  --line: #e2e6ec;
  --accent: #2f5bd3;
  --accent-text: #ffffff;
  --danger: #c23a31;
  --ok: #1f7a4d;
  --warn: #9a6200;
  --info: #2f5bd3;
  --focus: #7aa2ff;
  --radius: 8px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --panel: #1a1f27;
    --text: #e6e9ee;
    --muted: #9aa5b4;
    --line: #2b323d;
    --accent: #6d8ff0;
    --accent-text: #0d1117;
    --danger: #f0776e;
    --ok: #5cc28f;
    --warn: #e0b04a;
    --info: #86a4f5;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.1rem; }
a { color: var(--accent); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.boot { padding: 2rem; color: var(--muted); }
[hidden] { display: none !important; }

/* Layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 1.25rem 1rem; display: flex; flex-direction: column; gap: 1.5rem; }
.brand { font-weight: 650; }
.brand small { display: block; color: var(--muted); font-weight: 400; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: var(--text); text-decoration: none; padding: 0.45rem 0.7rem; border-radius: 6px; }
.nav a:hover { background: var(--bg); }
.nav a[aria-current="page"] { background: var(--bg); font-weight: 600; }
.who { margin-top: auto; font-size: 0.85rem; color: var(--muted); display: flex; flex-direction: column; gap: 0.5rem; }
.who strong { color: var(--text); word-break: break-all; }
.main { padding: 2rem clamp(1rem, 3vw, 2.5rem); max-width: 1100px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: end; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.muted { color: var(--muted); }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav { flex-direction: row; }
  .who { margin-top: 0; margin-left: auto; flex-direction: row; align-items: center; }
}

/* Sign-in and the other standalone pages */
.center { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1.75rem; }
.card h1 { margin-bottom: 0.25rem; }
.card .lead { color: var(--muted); margin: 0 0 1.25rem; }

/* Forms */
label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 550; font-size: 0.9rem; }
label.check { flex-direction: row; align-items: center; gap: 0.5rem; font-weight: 400; }
.hint { font-weight: 400; color: var(--muted); font-size: 0.82rem; }
input[type="email"], input[type="password"], input[type="search"], input[type="text"], select {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  min-width: 0;
}
fieldset { border: 1px solid var(--line); border-radius: 6px; padding: 0.75rem; margin: 0; display: flex; flex-direction: column; gap: 0.4rem; }
legend { font-weight: 550; font-size: 0.9rem; padding: 0 0.25rem; }
.form-error { color: var(--danger); margin: 0; }
.notice { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 0.6rem 0.8rem; margin: 0; }
.notice-error { border-color: var(--danger); color: var(--danger); }

.button {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 6px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}
.button:hover { border-color: var(--muted); }
.button:disabled { opacity: 0.55; cursor: default; }
.button-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.button-danger { color: var(--danger); border-color: var(--danger); }
.button-small { padding: 0.2rem 0.55rem; font-size: 0.85rem; }
.button-link { background: none; border: 0; color: var(--accent); padding: 0; cursor: pointer; font: inherit; }
.actions { display: flex; gap: 0.5rem; justify-content: flex-end; flex-wrap: wrap; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.actions-cell { text-align: right; }
td.actions-cell .button { margin-left: 0.25rem; }
.empty { padding: 2rem; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 0.75rem; color: var(--muted); }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1.25rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.badge { display: inline-block; font-size: 0.78rem; padding: 0.1rem 0.5rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge-ok { color: var(--ok); border-color: currentColor; }
.badge-warn { color: var(--warn); border-color: currentColor; }
.badge-danger { color: var(--danger); border-color: currentColor; }
.badge-info { color: var(--info); border-color: currentColor; }
.badge-muted { color: var(--muted); }

/* Dialogs and toasts */
.dialog { border: 1px solid var(--line); border-radius: 12px; padding: 1.5rem; width: min(460px, calc(100vw - 2rem)); background: var(--panel); color: var(--text); }
.dialog::backdrop { background: rgb(0 0 0 / 0.35); }
.secret { display: flex; gap: 0.5rem; align-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 0.5rem 0.75rem; }
.secret code { flex: 1; font-size: 1.05rem; letter-spacing: 0.03em; word-break: break-all; }
.toasts { position: fixed; bottom: 1rem; right: 1rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 10; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 6px; padding: 0.6rem 0.9rem; max-width: 360px; box-shadow: 0 4px 16px rgb(0 0 0 / 0.12); }
.toast-error { border-left-color: var(--danger); }
