:root {
  --fg: #1b1f24;
  --muted: #6a737d;
  --bg: #ffffff;
  --line: #d8dde3;
  --soft: #f4f6f8;
  --link: #0b5cad;
  --red: #b3261e;
  --red-bg: #fdecea;
  --amber: #8a5a00;
  --amber-bg: #fff4d6;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--fg);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
a { color: var(--link); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }

header {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem;
  padding: 0.6rem 1rem; border-bottom: 1px solid var(--line); background: var(--soft);
}
header .sep { color: var(--muted); }
header .role { color: var(--muted); }
header .logout { margin-left: auto; }

nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; padding: 0.5rem 1rem; border-bottom: 1px solid var(--line); }
nav a { text-decoration: none; padding: 0.15rem 0; }
nav a.active { font-weight: 600; border-bottom: 2px solid var(--link); }

main { max-width: 1200px; margin: 0 auto; padding: 1rem; }
h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 0.5rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.5rem; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin-bottom: 1rem; }
.muted { color: var(--muted); }
.error { color: var(--red); }

button, .button, input, select {
  font: inherit; padding: 0.3rem 0.6rem; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); color: var(--fg);
}
button, .button { cursor: pointer; text-decoration: none; display: inline-block; }
button:disabled { cursor: not-allowed; color: var(--muted); background: var(--soft); }
button.danger:not(:disabled) { color: var(--red); border-color: var(--red); }

.block { border: 1px solid var(--line); border-radius: 6px; padding: 0.75rem 1rem; margin-bottom: 1rem; }
.block.red { border-left: 4px solid var(--red); }
.block.amber { border-left: 4px solid var(--amber); }
.block ul { margin: 0; padding-left: 1.2rem; }

.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 0.3rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; background: var(--soft); white-space: nowrap; }
td.num { text-align: right; }
td.detail { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; word-break: break-all; min-width: 16rem; }
tr.dead td { background: var(--red-bg); color: var(--red); }
tr.dead a { color: var(--red); font-weight: 600; }
tr.selected td { border-bottom: 2px solid var(--link); }
tr.denied td { color: var(--red); }
td.amber { background: var(--amber-bg); color: var(--amber); }

section.detail { margin-top: 1.5rem; border-top: 2px solid var(--line); padding-top: 1rem; }
dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 1rem; margin: 0 0 1rem; }
dl.meta dt { color: var(--muted); }
dl.meta dd { margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; }
.forms form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.75rem; background: var(--soft); border-radius: 6px; }
.status { color: var(--red); }

.reveal dl.meta { margin-bottom: 0; }
pre.secret { margin: 0 0 0.3rem; padding: 0.2rem 0.4rem; background: var(--soft); border-radius: 4px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.85em; }
.reveal .actions { align-items: center; margin-bottom: 0.4rem; }
form.stack.editor { max-width: 60rem; }
textarea { font: 0.85em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; width: 100%; padding: 0.4rem; border: 1px solid var(--line); border-radius: 4px; }
td.row-actions { white-space: nowrap; }
td.row-actions button { margin-right: 0.3rem; }
tr.revoked td { color: var(--muted); background: var(--soft); }
input.secret-once { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; flex: 1 1 28rem; min-width: 0; }
.scope-row { margin-bottom: 0.4rem; }

details.menu { position: relative; }
details.menu summary { list-style: none; }
details.menu summary::-webkit-details-marker { display: none; }
details.menu > div {
  position: absolute; z-index: 1; margin-top: 0.25rem; display: flex; flex-direction: column; min-width: 10rem;
  background: var(--bg); border: 1px solid var(--line); border-radius: 4px;
}
details.menu > div a { padding: 0.4rem 0.75rem; text-decoration: none; }
details.menu > div a:hover { background: var(--soft); }

form.stack { display: flex; flex-direction: column; gap: 0.6rem; max-width: 32rem; }
form.stack label { display: flex; flex-direction: column; gap: 0.3rem; }
form.stack label.inline { flex-direction: row; align-items: center; gap: 0.4rem; display: inline-flex; margin-right: 1rem; }
form.stack > button { align-self: flex-start; }
form.stack fieldset { border: 1px solid var(--line); border-radius: 4px; }
.wizard ol { padding-left: 1.2rem; }
.code-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.user-code { font-size: 2rem; font-weight: 600; letter-spacing: 0.12em; padding: 0.2rem 0.6rem; background: var(--soft); border-radius: 4px; }
.countdown { font-variant-numeric: tabular-nums; }

.login { max-width: 24rem; margin: 3rem auto; }
.login h1 { margin-bottom: 1rem; }
.login form { display: flex; flex-direction: column; gap: 0.6rem; }
.login label { display: flex; flex-direction: column; gap: 0.3rem; }

@media (max-width: 600px) {
  main { padding: 0.75rem; }
  dl.meta { grid-template-columns: 1fr; }
  dl.meta dd { margin-bottom: 0.4rem; }
}

/* Audit, session groups, admin tabs */
form.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem 0.75rem; margin-bottom: 1rem; }
form.filters label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.9em; }
form.filters label span { color: var(--muted); }
form.filters .actions { margin-bottom: 0; }
tr.denied td { background: var(--red-bg); }
tr.anomaly td { background: var(--amber-bg); color: var(--amber); font-weight: 600; }
pre.json { margin: 0.3rem 0 0; padding: 0.3rem 0.5rem; background: var(--soft); border-radius: 4px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.85em; max-width: 36rem; }
details > summary { cursor: pointer; color: var(--link); }
details.raw { margin-top: 0.75rem; }
.small { font-size: 0.85em; font-weight: normal; }
tr.open td:last-child { font-weight: 600; }
.tabs { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line); }
.tabs a { text-decoration: none; padding: 0.3rem 0; }
.tabs a.active { font-weight: 600; border-bottom: 2px solid var(--link); }
table.matrix th[scope="row"] { background: var(--bg); font-weight: normal; white-space: normal; }
table.matrix select.none { color: var(--muted); }
