:root {
  --bg: #f5f7fa; --surface: #ffffff; --surface-2: #f0f3f6; --ink: #111c26; --muted: #5a6876;
  --line: #dfe5eb; --brand: #0f6e6a; --brand-2: #0b5653; --brand-ink: #ffffff; --brand-soft: #e3f2f1;
  --danger: #b42318; --danger-soft: #fdecea; --warn: #8a5a00; --warn-soft: #fff4dc; --ok: #146c43; --ok-soft: #e6f4ec;
  --focus: #f2b705; --radius: 12px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e141a; --surface: #161f28; --surface-2: #1c2732; --ink: #e8edf2; --muted: #9aa7b4; --line: #293542;
    --brand: #3fb3a9; --brand-2: #57c4ba; --brand-ink: #062320; --brand-soft: #143533;
    --danger: #ff8a7a; --danger-soft: #3a1c19; --warn: #f3c46b; --warn-soft: #3a2d12; --ok: #7ad3a3; --ok-soft: #15322a;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.noscript { max-width: 720px; margin: 40px auto; padding: 0 16px; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-inner { max-width: 1080px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 16px; justify-content: space-between; }
.logo { display: flex; align-items: center; gap: 10px; font-size: 16px; letter-spacing: -.01em; }
.logo-mark { width: 22px; height: 22px; border-radius: 7px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.topbar-right { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; min-width: 0; }
.topbar-right .email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }

main { max-width: 1080px; margin: 0 auto; padding: 24px 16px 64px; outline: none; }
h1 { font-size: 24px; line-height: 1.25; margin: 0; letter-spacing: -.015em; }
h2 { font-size: 17px; margin: 0; }
h3 { font-size: 16px; margin: 0; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.loading { color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.link { border: 0; background: none; padding: 0; min-height: 0; color: var(--brand); }
.btn.block { display: flex; width: 100%; }
.btn.link.block { min-height: 32px; }

.auth { max-width: 420px; margin: 48px auto 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.stack > * + * { margin-top: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.field .hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=datetime-local], textarea, select {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; }
textarea { min-height: 84px; resize: vertical; }
input[type=file] { font: inherit; width: 100%; }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { width: 18px; height: 18px; margin-top: 2px; flex: none; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.error { background: var(--danger-soft); color: var(--danger); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.note { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.otp { font-size: 22px; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.qr-enrol { display: block; width: 200px; height: 200px; margin: 0 auto; background: #fff; border-radius: 8px; padding: 8px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; word-break: break-all; }

.page-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.page-head .row select { width: auto; min-width: 220px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab { border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); padding: 10px 12px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab[aria-selected=true] { color: var(--ink); border-color: var(--brand); }

.list { display: grid; gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card.archived { opacity: .7; }
.card-head { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; }
.card-title { display: grid; gap: 4px; min-width: 0; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.meta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.card-title { flex: 1 1 320px; }
.links { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 10px; }
.link-row { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; }
.link-row .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) { .link-row { grid-template-columns: 1fr; } .link-row .actions { justify-content: flex-start; } }

.empty { text-align: center; padding: 40px 16px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.empty h2 { color: var(--ink); margin-bottom: 6px; }

.events { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.events th, .events td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
.events th { background: var(--surface-2); font-size: 13px; color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }

dialog { border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(10, 16, 22, .45); }
.dialog-body { padding: 22px; }
.dialog-body h2 { margin-bottom: 4px; }
progress { width: 100%; height: 10px; accent-color: var(--brand); }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 20; max-width: calc(100vw - 32px); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
