/* Plain CSS, no build step. Light and dark follow the device setting. */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --text: #1d2430; --muted: #5d6675; --border: #d9dee6;
  --primary: #0b6bcb; --primary-text: #ffffff; --danger: #b42318; --ok-bg: #e7f6ec; --ok: #16683a;
  --err-bg: #fdecea; --info-bg: #e8f1fb; --warn: #9a6700; --focus: #f5a623;
  --radius: 8px; font-size: 16px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12161c; --surface: #1b2129; --text: #e6e9ee; --muted: #a2abb8; --border: #2e3640;
    --primary: #4d9bf0; --primary-text: #0b1420; --danger: #ff8a80; --ok-bg: #12301f; --ok: #7bd99c;
    --err-bg: #3a1714; --info-bg: #13263b; --warn: #f2c14e; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9em; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 1rem; top: 1rem; background: var(--surface); padding: .5rem; z-index: 10; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .hint { color: var(--muted); font-size: .9rem; margin: -.25rem 0 0; }

.topbar { display: flex; align-items: center; gap: 1rem; padding: .75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar.platform { border-bottom: 3px solid var(--warn); }
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.who { margin-left: auto; display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.nav-toggle { display: none; }
.shell { display: flex; min-height: calc(100vh - 56px); }
.sidenav { width: 220px; flex: none; background: var(--surface); border-right: 1px solid var(--border); padding: 1rem 0; }
.sidenav ul { list-style: none; margin: 0; padding: 0; }
.sidenav a { display: block; padding: .45rem 1.25rem; text-decoration: none; color: var(--text); }
.sidenav a:hover { background: var(--bg); }
.sidenav .group { padding: 1rem 1.25rem .25rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.content { flex: 1; padding: 1.5rem; min-width: 0; max-width: 1100px; }
.content.wide { max-width: 1200px; margin: 0 auto; }
@media (max-width: 760px) {
  .nav-toggle { display: inline-block; }
  .sidenav { display: none; position: absolute; top: 56px; left: 0; right: 0; z-index: 5; border-right: 0; border-bottom: 1px solid var(--border); width: auto; }
  .nav-open .sidenav { display: block; }
  .content { padding: 1rem; }
}

.card-page { display: flex; justify-content: center; padding: 3rem 1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 460px; }
.card .org { color: var(--muted); margin: 0 0 .25rem; font-weight: 600; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin: 0 0 1.25rem; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.panel { padding: 1.25rem; }
legend { font-weight: 700; padding: 0; margin-bottom: .75rem; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.stack > fieldset { display: flex; flex-direction: column; gap: .75rem; }
label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; font-size: .95rem; }
label.check { flex-direction: row; align-items: flex-start; gap: .5rem; font-weight: 400; }
input, select, textarea { font: inherit; padding: .55rem .65rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); width: 100%; }
input[type=checkbox] { width: auto; margin-top: .3rem; }
input.short { max-width: 10rem; }
input.copy { font-family: ui-monospace, monospace; font-size: .85rem; }
button, .button { display: inline-block; font: inherit; font-weight: 600; padding: .55rem 1rem; border-radius: 6px; border: 1px solid var(--primary); background: var(--primary); color: var(--primary-text); cursor: pointer; text-decoration: none; text-align: center; }
button.secondary, .button.secondary { background: transparent; color: var(--primary); }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.link { background: none; border: 0; color: var(--primary); padding: 0; font-weight: 400; text-decoration: underline; }
form.inline { display: inline; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.field-error { color: var(--danger); margin: -.4rem 0 0; font-size: .9rem; }
.alert { padding: .75rem 1rem; border-radius: 6px; margin: 0 0 1rem; }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.error { background: var(--err-bg); color: var(--danger); }
.alert.info { background: var(--info-bg); }
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: 1rem; }
.filters label { min-width: 10rem; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1rem; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
table.audit td.changes { font-size: .85rem; max-width: 420px; word-break: break-word; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; background: var(--bg); border: 1px solid var(--border); }
.badge.active { color: var(--ok); } .badge.disabled, .badge.suspended { color: var(--danger); } .badge.invited, .badge.onboarding { color: var(--warn); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0 0 1rem; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.tile { display: flex; flex-direction: column; gap: .25rem; padding: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); }
.tile span { color: var(--muted); font-size: .9rem; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.stat.warn { border-color: var(--warn); }
.perm-group { border-top: 1px solid var(--border); padding-top: .75rem; }
.perm-row { display: flex; gap: .75rem; align-items: center; justify-content: space-between; padding: .25rem 0; flex-wrap: wrap; }
.perm-row label { flex: 1 1 320px; }
.perm-row select { width: auto; }
.qr img { background: #fff; padding: 8px; border-radius: 6px; margin: .5rem 0; }
.secret { word-break: normal; overflow-wrap: normal; letter-spacing: .02em; }
.codes { columns: 2; list-style: none; padding: 0; font-size: 1.1rem; }
.steps li { margin-bottom: .75rem; }
.checklist { list-style: none; padding: 0; } .checklist .ok { color: var(--ok); } .checklist .bad { color: var(--danger); }
.progress { display: flex; gap: 1rem; flex-wrap: wrap; padding-left: 1.2rem; } .progress .current { font-weight: 700; } .progress .done { color: var(--muted); text-decoration: line-through; }
.pager { display: flex; gap: 1rem; }
