:root {
  --bg: #F5F6F3; --surface: #FFFFFF; --surface-2: #EEF0EC; --border: #DBDFD6;
  --text: #12161F; --text-muted: #5B6270; --accent: #0E9C90; --accent-contrast: #FFFFFF;
  --ok: #0F9D63; --pending: #B7791F; --danger: #DC2626;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B0E14; --surface: #12161F; --surface-2: #171C27; --border: #232838;
    --text: #E7EAF2; --text-muted: #7C8397; --accent: #3FD0C9; --accent-contrast: #05201E;
    --ok: #34D399; --pending: #FBBF24; --danger: #F87171;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text); min-height: 100vh;
  font-family: "IBM Plex Sans", -apple-system, "Helvetica Neue", Arial, sans-serif;
}
.mono { font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }

.mark { display: inline-flex; align-items: center; gap: 10px; font-family: "IBM Plex Mono", monospace; font-weight: 600; font-size: 14px; }
.mark .dots { display: inline-flex; gap: 4px; }
.mark .dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }

/* ---------- unlock screen ---------- */
.screen-unlock { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.unlock-card { width: 100%; max-width: 380px; text-align: center; }
.unlock-card .mark { justify-content: center; margin-bottom: 40px; }
.unlock-card h1 { font-size: 21px; font-weight: 600; margin: 0 0 6px; }
.unlock-card p.sub { margin: 0 0 32px; color: var(--text-muted); font-size: 13.5px; line-height: 1.5; }
.field { text-align: left; margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 11px 13px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 7px; color: var(--text); font-size: 14.5px; font-family: inherit;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.btn-primary {
  width: 100%; padding: 12px 14px; margin-top: 8px; background: var(--accent); color: var(--accent-contrast);
  border: none; border-radius: 7px; font-size: 14.5px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-primary:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.unlock-foot { margin-top: 28px; font-size: 11.5px; color: var(--text-muted); }
.form-msg { margin-top: 14px; font-size: 13px; min-height: 18px; }
.form-msg.error { color: var(--danger); }
.form-msg.ok { color: var(--ok); }

/* ---------- admin shell ---------- */
.admin-shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.rail { background: var(--surface); border-right: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; }
.rail .mark { padding: 4px 8px 22px; }
.rail-section-label { font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); padding: 0 8px 8px; }
.collection-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 7px; font-size: 13.5px; color: var(--text-muted); cursor: pointer; }
.collection-item.active { background: var(--surface-2); color: var(--text); font-weight: 500; }
.collection-item:hover:not(.active) { background: var(--surface-2); }
.collection-swatch { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; background: var(--accent); }
.collection-item .count { margin-left: auto; font-family: "IBM Plex Mono", monospace; font-size: 11.5px; }
.rail-new { margin-top: 4px; padding: 8px; font-size: 13px; color: var(--text-muted); cursor: pointer; border-radius: 7px; background: none; border: none; text-align: left; width: 100%; font-family: inherit; }
.rail-new:hover { background: var(--surface-2); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 22px 28px; border-bottom: 1px solid var(--border); }
.topbar h1 { font-size: 19px; font-weight: 600; margin: 0; }
.topbar .eyebrow { font-size: 12px; color: var(--text-muted); margin: 0 0 2px; }
.btn-issue { background: var(--accent); color: var(--accent-contrast); border: none; border-radius: 7px; font-size: 13px; font-weight: 600; font-family: inherit; padding: 9px 15px; cursor: pointer; }

.table-wrap { overflow-x: auto; padding: 6px 28px 28px; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
thead th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); padding: 14px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 14px 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
tbody tr:hover { background: var(--surface-2); cursor: pointer; }
.cfg-name { font-weight: 500; }
.cfg-email { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 3px 9px 3px 7px; border-radius: 100px; border: 1px solid var(--border); }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; }
.chip.st-active { color: var(--ok); } .chip.st-active .dot { background: var(--ok); }
.chip.st-issued { color: var(--pending); } .chip.st-issued .dot { background: var(--pending); }
.chip.st-revoked { color: var(--danger); } .chip.st-revoked .dot { background: var(--danger); }
.cell-muted { color: var(--text-muted); }

/* ---------- modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(5,7,12,.55); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 20; }
.modal-overlay.hidden { display: none; }
.modal-panel { width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.modal-head h2 { font-size: 17px; font-weight: 600; margin: 0; }
.modal-close, .icon-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 5px; border-radius: 6px; }
.modal-close:hover, .icon-btn:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 18px 20px 6px; }
.identity-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 20px; }
.identity-icon { width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: var(--surface-2); font-family: "IBM Plex Mono", monospace; font-weight: 600; color: var(--accent); flex-shrink: 0; }
.identity-name { font-weight: 600; font-size: 15px; }
.identity-meta { display: flex; gap: 14px; margin-top: 4px; font-size: 12px; color: var(--text-muted); }
.modal-section { margin-bottom: 20px; }
.modal-section h3 { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 10px; }
.kv-box { border: 1px solid var(--border); border-radius: 10px; padding: 6px 14px; }
.kv-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.kv-row:last-child { border-bottom: none; }
.kv-row .k-label { font-size: 11.5px; color: var(--text-muted); margin-bottom: 3px; }
.kv-row .k-value { font-size: 14px; }
.reveal-banner { display: flex; gap: 10px; background: color-mix(in srgb, var(--pending) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--pending) 40%, var(--border)); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; margin-bottom: 14px; }
.reveal-banner strong { color: var(--pending); }
.history-line { font-size: 13px; color: var(--text-muted); padding: 3px 0; }
.history-line b { color: var(--text); font-weight: 500; }
.modal-foot { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 6px; font-size: 12.5px; font-weight: 500; font-family: inherit; padding: 7px 11px; cursor: pointer; }
.btn-secondary:hover { border-color: var(--text-muted); }
.btn-secondary:disabled { opacity: .45; cursor: default; }
.log-list { list-style: none; margin: 0; padding: 0; max-height: 150px; overflow-y: auto; }
.log-list li { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.log-list li:last-child { border-bottom: none; }

.dialog-panel { max-width: 380px; }
.dialog-message { font-size: 14px; color: var(--text); line-height: 1.5; margin: 0 0 4px; }
.dialog-panel .modal-foot { justify-content: flex-end; gap: 10px; }
.dialog-panel .btn-secondary.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
