:root {
  --primary: #6d28d9; --primary-600: #5b21b6; --primary-50: #f5f3ff; --primary-100: #ede9fe;
  --indigo: #4f46e5; --indigo-50: #eef2ff;
  --teal: #0d9488; --teal-50: #f0fdfa;
  --red: #dc2626; --red-50: #fef2f2; --amber: #b45309; --amber-50: #fffbeb;
  --ink: #111827; --ink-2: #374151; --muted: #6b7280; --line: #e5e7eb; --bg: #f8f7fc; --card: #fff;
  --radius: 12px; --shadow: 0 1px 2px rgba(17,24,39,.04), 0 1px 3px rgba(17,24,39,.06);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; line-height: 1.25; margin: 0 0 4px; font-weight: 650; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h1.mono { font-size: 19px; }
h2 { font-size: 14px; margin: 0 0 12px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; } .right { text-align: right; }
.trunc { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* shell */
.shell { display: flex; min-height: 100vh; background: linear-gradient(to right, #fff 235px, var(--line) 235px, var(--line) 236px, transparent 236px); }
@media (max-width: 1000px) { .shell { background: linear-gradient(to right, #fff 199px, var(--line) 199px, var(--line) 200px, transparent 200px); } }
.side { width: 236px; flex: none; background: #fff; border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); padding: 4px 8px; }
.brand:hover { text-decoration: none; }
.brand b { display: block; font-size: 15px; line-height: 1.1; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.brand.center { justify-content: center; margin-bottom: 18px; }
.logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 16px; background: linear-gradient(135deg, var(--primary), var(--indigo) 60%, var(--teal)); box-shadow: 0 4px 10px rgba(109,40,217,.25); }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a, .navbtn { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.side nav a:hover, .navbtn:hover { background: var(--primary-50); color: var(--primary); text-decoration: none; }
.side nav a.on { background: var(--primary-100); color: var(--primary-600); }
.side nav a.on .ic { fill: var(--primary); }
.ic { width: 18px; height: 18px; fill: #9ca3af; flex: none; }
.btn .ic { fill: currentColor; width: 16px; height: 16px; }
.logout { margin-top: auto; }
.navbtn { width: 100%; border: 0; background: none; font: inherit; cursor: pointer; }
.main { flex: 1; min-width: 0; padding: 28px 32px 48px; max-width: 1280px; }

/* page header */
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.crumb { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; }

/* cards & grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.card-h h2 { margin: 0; }
.card-h.pad { padding: 16px 20px 8px; margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid2 > .card, .grid3 > .card { margin-bottom: 0; }
.grid3 { align-items: start; } .grid2, .grid3 { margin-bottom: 16px; }
.span2 { grid-column: span 2; }
@media (max-width: 1000px) { .grid2, .grid3 { grid-template-columns: 1fr; } .span2 { grid-column: auto; } .side { width: 200px; } }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
@media (max-width: 1000px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); border-top: 3px solid var(--primary); }
.stat.teal { border-top-color: var(--teal); } .stat.indigo { border-top-color: var(--indigo); }
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.chart { width: 100%; height: 130px; display: block; }
.bar { fill: var(--primary); opacity: .85; } .bar0 { fill: var(--line); opacity: 1; }
.axis { font-size: 9px; fill: var(--muted); }
.kv { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 8px; }
.kv li { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: #fafafa; border-radius: 8px; }

/* tables */
.tablewrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 14px; background: #fafafa; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 14px; border-bottom: 1px solid #f1f1f4; vertical-align: middle; }
.card:not(.flush) .table th:first-child, .card:not(.flush) .table td:first-child { padding-left: 0; }
.card:not(.flush) .table th { background: none; }
.table tr:last-child td { border-bottom: 0; }
.rowlink { cursor: pointer; }
.rowlink:hover td { background: var(--primary-50); }
tr.dim td { opacity: .55; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* badges & chips */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; text-transform: capitalize; line-height: 1.6; }
.badge-active, .badge-wh-processed { background: var(--teal-50); color: var(--teal); box-shadow: inset 0 0 0 1px #99f6e4; }
.badge-revoked, .badge-wh-error { background: var(--red-50); color: var(--red); box-shadow: inset 0 0 0 1px #fecaca; }
.badge-expired, .badge-wh-ignored, .badge-wh-received { background: #f3f4f6; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
h1 .badge { font-size: 12px; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--indigo-50); color: var(--indigo); font-size: 11.5px; font-weight: 600; }
.chip-arch { background: var(--primary-100); color: var(--primary-600); }

/* forms */
label { display: block; font-weight: 550; font-size: 13px; color: var(--ink-2); margin-bottom: 14px; }
label > input, label > select, label > textarea { display: block; margin-top: 6px; }
label .muted { font-weight: 400; }
input, select, textarea { font: inherit; font-weight: 400; color: var(--ink); padding: 9px 11px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; width: 100%; transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(109,40,217,.15); }
.form.narrow { max-width: 640px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.actions { display: flex; gap: 8px; margin-top: 6px; }
.inline { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 6px; }
.inline label { flex: 1; margin-bottom: 0; }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px; }
.filters select { width: auto; } .filters .grow { flex: 1; min-width: 260px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid #d1d5db; background: #fff; color: var(--ink-2); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { background: #f9fafb; text-decoration: none; border-color: #c4c8cf; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(109,40,217,.25); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(109,40,217,.3); }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn-teal { background: var(--teal); border-color: var(--teal); color: #fff; } .btn-teal:hover { background: #0f766e; }
.btn-danger { background: #fff; color: var(--red); border-color: #fecaca; } .btn-danger:hover { background: var(--red-50); border-color: #fca5a5; }
.btn-ghost { border-color: transparent; background: transparent; } .btn-ghost:hover { background: var(--primary-50); color: var(--primary); }
.btn-ghost-danger { border-color: transparent; background: transparent; color: var(--red); } .btn-ghost-danger:hover { background: var(--red-50); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; padding: 10px; }

/* misc */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.flash-ok { background: var(--teal-50); color: #115e59; border: 1px solid #99f6e4; }
.flash-err { background: var(--red-50); color: #991b1b; border: 1px solid #fecaca; }
.warn { color: var(--amber); }
p.warn { background: var(--amber-50); border: 1px solid #fde68a; padding: 10px 14px; border-radius: 8px; }
.dl { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; } .dl dd { margin: 0; word-break: break-all; }
.keybox { display: flex; gap: 12px; align-items: center; background: var(--primary-50); border: 1px dashed #c4b5fd; border-radius: 10px; padding: 16px 18px; margin: 14px 0 16px; }
.keybox code { flex: 1; font-family: var(--mono); font-size: 22px; font-weight: 600; letter-spacing: .04em; color: var(--primary-600); word-break: break-all; }
.reveal { max-width: 760px; }
.code { background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: 16px; font-family: var(--mono); font-size: 12.5px; max-height: 620px; overflow: auto; margin: 0; white-space: pre; }
.latest { display: flex; gap: 40px; padding: 12px 0 16px; border-bottom: 1px solid var(--line); margin-bottom: 4px; flex-wrap: wrap; }
.ver { font-size: 22px; font-weight: 700; color: var(--primary); }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 10% -10%, #ede9fe 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #ccfbf1 0%, transparent 55%), var(--bg); }
.login { width: 360px; padding: 32px 30px; margin: 0; }
