:root {
    --bg: #f4f6f9;
    --panel: #ffffff;
    --side: #14213d;
    --side-text: #c9d3e6;
    --text: #1d2433;
    --muted: #6b7486;
    --line: #e3e7ee;
    --primary: #1f6feb;
    --primary-ink: #ffffff;
    --ok: #1a7f37;
    --ok-bg: #e6f4ea;
    --warn: #9a6700;
    --warn-bg: #fff4d6;
    --bad: #c62828;
    --bad-bg: #fde8e8;
    --info-bg: #e8f0fe;
    --radius: 8px;
    color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 4px 0; display: flex; align-items: center; gap: 10px; }
h2 { font-size: 15px; margin: 0 0 10px; }
h3 { font-size: 16px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; }
.big { font-size: 16px; font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── shell ── */
.shell { display: flex; min-height: 100vh; }
.side {
    width: 220px; flex: none; background: var(--side); color: var(--side-text);
    display: flex; flex-direction: column; padding: 16px 12px; position: sticky; top: 0; height: 100vh;
}
.brand { color: #fff; font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 10px; margin: 0 6px 20px; }
.brand:hover { text-decoration: none; }
.logo, .auth-logo {
    background: var(--primary); color: #fff; border-radius: 8px; width: 34px; height: 34px;
    display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px;
}
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav a { color: var(--side-text); padding: 8px 10px; border-radius: 6px; }
.side nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.side nav a.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.me { border-top: 1px solid rgba(255,255,255,.12); padding: 12px 8px 0; display: flex; justify-content: space-between; align-items: center; }
.me-name { color: #fff; font-weight: 600; }
.me .link { color: var(--side-text); }
.content { flex: 1; padding: 24px 28px 60px; min-width: 0; }

/* ── page bits ── */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 12px; }
.section-head p { margin: 0; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
td.actions { white-space: nowrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; }
.narrow { max-width: 460px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 .card { margin: 0; }
.span2 { grid-column: span 2; }
.empty { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; color: var(--text); }
a.stat:hover { border-color: var(--primary); text-decoration: none; }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 14px; color: var(--muted); font-weight: 500; }
.stat-sub { font-size: 12px; color: var(--muted); }
.stat-attn { border-color: var(--primary); background: var(--info-bg); }
.stat-warn { border-color: #e9c46a; background: var(--warn-bg); }
.stat-value.ok { color: var(--ok); } .stat-value.warn { color: var(--warn); } .stat-value.bad { color: var(--bad); }

/* ── tables ── */
.tbl { width: 100%; border-collapse: collapse; }
table.card { padding: 0; overflow: hidden; display: table; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: #f6f9ff; }
.tbl tr.dim td { opacity: .55; }
.tbl tr.total td { font-weight: 700; border-top: 2px solid var(--line); }
.tbl-inner { margin-top: 10px; border: 1px solid var(--line); border-radius: 6px; }

/* ── badges ── */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: capitalize; background: #eef0f4; color: var(--muted); white-space: nowrap; vertical-align: middle; }
.badge-active, .badge-online, .badge-completed { background: var(--ok-bg); color: var(--ok); }
.badge-pending, .badge-stale, .badge-expiring { background: var(--warn-bg); color: var(--warn); }
.badge-suspended, .badge-revoked, .badge-expired, .badge-rejected, .badge-offline, .badge-cancelled { background: var(--bad-bg); color: var(--bad); }
.tag { font-family: Consolas, monospace; font-size: 12px; background: #eef0f4; padding: 1px 6px; border-radius: 4px; }

/* ── forms ── */
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
label.check { flex-direction: row; align-items: center; gap: 6px; font-weight: 500; color: var(--text); font-size: 13px; margin: 0; }
label.inline { flex-direction: row; align-items: center; gap: 6px; margin: 0; }
input, select, textarea {
    font: inherit; color: var(--text); background: #fff; border: 1px solid #cdd3dd; border-radius: 6px; padding: 7px 9px; font-weight: 400;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31,111,235,.25); border-color: var(--primary); }
input[type=checkbox] { width: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.filters .grow { flex: 1; min-width: 220px; }
.quick { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 8px; flex-wrap: wrap; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600;
    padding: 7px 14px; border-radius: 6px; border: 1px solid #cdd3dd; background: #fff; color: var(--text); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f3f5f8; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-sm { padding: 3px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: #1a5fd0; }
.btn-danger { color: var(--bad); border-color: #f0b4b4; }
.btn-danger:hover { background: var(--bad-bg); }
.btn-warn { color: var(--warn); border-color: #e9c46a; }
.btn-warn:hover { background: var(--warn-bg); }
.link { background: none; border: 0; padding: 0; color: var(--primary); cursor: pointer; font: inherit; }

/* ── tabs ── */
.tabs { display: flex; gap: 4px; background: #e9edf3; padding: 3px; border-radius: 8px; }
.tabs button { border: 0; background: none; padding: 6px 14px; border-radius: 6px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button.on { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tabs-page { display: inline-flex; margin-bottom: 14px; }
.count { background: rgba(0,0,0,.08); border-radius: 999px; padding: 0 7px; font-size: 11px; margin-left: 4px; }

/* ── licences ── */
.lic-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.lic-head > div:first-child { display: flex; gap: 10px; align-items: center; }
.kv { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 8px; color: var(--muted); font-size: 13px; }
.kv strong { color: var(--text); margin-left: 4px; }

/* ── flash, modal, code ── */
.flash { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 6px; margin-bottom: 14px; font-size: 13px; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-err { background: var(--bad-bg); color: var(--bad); }
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 50; }
.modal {
    position: fixed; z-index: 51; top: 8vh; left: 50%; transform: translateX(-50%); width: min(520px, calc(100vw - 32px));
    max-height: 84vh; display: flex; flex-direction: column; background: #fff; border-radius: 10px; box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.modal-wide { width: min(780px, calc(100vw - 32px)); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
pre.code { background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 6px; overflow: auto; font-size: 12.5px; white-space: pre; }
pre.json { max-height: 60vh; }

/* ── auth pages ── */
.bare { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--side); }
.auth-card { background: #fff; border-radius: 12px; padding: 28px; width: min(380px, 100%); box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.auth-card h1 { margin-top: 12px; }
.auth-card form { margin-top: 16px; }

#blazor-error-ui { background: #fff4d6; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none; left: 0; padding: .6rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }

@media (max-width: 900px) {
    .shell { flex-direction: column; }
    .side { width: auto; height: auto; position: static; }
    .side nav { flex-direction: row; flex-wrap: wrap; }
    .grid2, .form-grid { grid-template-columns: 1fr; }
    .span2 { grid-column: auto; }
    .content { padding: 16px; }
    table.card { display: block; overflow-x: auto; }
}
