:root {
  --bg: #f5f6f8; --surface: #fff; --text: #1c2330; --muted: #5d6778; --border: #dde1e8;
  --danger: #c62828; --ok: #1b7f3b; --warn-bg: #fff4d6; --warn-text: #6b4b00;
  --radius: 8px; --side: #19212e; --side-text: #cfd6e2;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11151c; --surface: #1a212c; --text: #e6eaf1; --muted: #98a2b3; --border: #2b3544;
    --warn-bg: #3a2f0f; --warn-text: #f3d98b; --side: #0c1017; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .6rem; }
.layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); padding: 1rem .75rem; }
.side .brand { font-weight: 700; font-size: 1.1rem; color: #fff; padding: .25rem .5rem 1rem; display: block; text-decoration: none; }
.side h3 { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; opacity: .6; margin: 1.1rem .5rem .3rem; font-weight: 600; }
.side a.nav { display: block; color: var(--side-text); text-decoration: none; padding: .45rem .6rem; border-radius: 6px; }
.side a.nav:hover { background: rgba(255,255,255,.08); }
.side a.nav.active { background: var(--brand); color: #fff; }
.main { display: flex; flex-direction: column; min-width: 0; }
.top { display: flex; justify-content: flex-end; align-items: center; gap: 1rem; padding: .6rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.top form { margin: 0; }
.content { padding: 1.5rem; max-width: 1100px; width: 100%; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: .55rem .8rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--bg); }
tr:last-child td { border-bottom: 0; }
.tablewrap { overflow-x: auto; }
.btn, button { display: inline-block; background: var(--brand); color: #fff; border: 0; border-radius: 6px; padding: .5rem .95rem; font: inherit; cursor: pointer; text-decoration: none; }
.btn.secondary, button.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.danger, button.danger { background: var(--danger); }
.btn.link, button.link { background: none; color: inherit; padding: 0; border: 0; }
.actions { display: flex; gap: .6rem; align-items: center; margin: 1rem 0; flex-wrap: wrap; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: .25rem; }
.field input[type=text], .field input[type=password], .field input[type=email], .field input[type=number], .field select, .field textarea, input.search {
  width: 100%; padding: .5rem .65rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font: inherit; }
.field input:focus, .field select:focus, .field textarea:focus, input.search:focus { outline: 2px solid var(--brand); outline-offset: 0; }
.field ul { list-style: none; margin: 0; padding: 0; }
.field ul li { padding: .15rem 0; }
.field ul label { font-weight: 400; display: inline; }
.help { color: var(--muted); font-size: .85rem; margin-top: .2rem; }
.errorlist { list-style: none; margin: .25rem 0 0; padding: 0; color: var(--danger); font-size: .9rem; }
.alert { padding: .7rem 1rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid var(--border); background: var(--surface); }
.alert.success { border-color: var(--ok); } .alert.error { border-color: var(--danger); color: var(--danger); }
.alert.warn { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }
.badge { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 99px; background: var(--border); color: var(--text); }
.badge.ok { background: var(--ok); color: #fff; } .badge.off { background: var(--danger); color: #fff; }
.muted { color: var(--muted); }
.authwrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.authcard { width: 100%; max-width: 440px; }
.authcard h1 { text-align: center; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; }
.rolebox { border: 1px solid var(--border); border-radius: 6px; padding: .6rem .8rem; margin-bottom: .6rem; }
.rolebox legend, .rolebox strong { font-weight: 600; }
.codes { font-family: ui-monospace, Consolas, monospace; font-size: 1.05rem; columns: 2; }
.qr svg { width: 200px; height: 200px; background: #fff; padding: 8px; border-radius: 6px; }
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .side { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; padding: .5rem; }
  .side h3 { display: none; } .side .brand { padding: .25rem .5rem; }
  .cols { grid-template-columns: 1fr; }
}
.comment { padding: .5rem 0; border-bottom: 1px solid var(--border); }
.comment:last-of-type { border-bottom: 0; }
.mention { color: var(--brand); font-weight: 600; }
.bell { text-decoration: none; }
details summary { cursor: pointer; }
