:root {
  --bg: #0b0d12;
  --panel: #12151c;
  --panel-2: #181c26;
  --line: #232837;
  --text: #e8eaf0;
  --muted: #8b93a7;
  --brand: #7c9cff;
  --brand-2: #5b7cff;
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --info: #60a5fa;
  --radius: 12px;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 1.5rem; margin: 0 0 0.25rem; letter-spacing: -0.02em; }
h2 { font-size: 1rem; margin: 0 0 0.75rem; }
h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 1.25rem 0 0.5rem; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }

/* ---- layout ---- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 1.1rem 0.8rem; display: flex; flex-direction: column; gap: 0.25rem; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 0.7rem; padding: 0.3rem 0.5rem 1.1rem; }
.brand img { height: 34px; }
.brand b { display: block; font-size: 0.95rem; }
.brand span { font-size: 0.72rem; color: var(--muted); }
.nav { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.7rem; border-radius: 9px; color: var(--muted); cursor: pointer; border: 0; background: none; font: inherit; text-align: left; width: 100%; }
.nav:hover { background: var(--panel-2); color: var(--text); }
.nav.on { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--text); }
.nav svg { width: 17px; height: 17px; flex: none; }
.side .grow { flex: 1; }
.main { padding: 1.6rem 2rem 3rem; max-width: 1280px; width: 100%; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.head p { margin: 0; color: var(--muted); }

/* ---- components ---- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; }
.grid { display: grid; gap: 0.9rem; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.kpi span { color: var(--muted); font-size: 0.78rem; }
.kpi strong { display: block; font-size: 1.65rem; letter-spacing: -0.02em; margin-top: 0.15rem; }
.kpi small { color: var(--muted); }
button, .btn { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 9px; padding: 0.5rem 0.9rem; display: inline-flex; align-items: center; gap: 0.4rem; }
button:hover { border-color: #343b52; }
button.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; font-weight: 600; }
button.primary:hover { filter: brightness(1.1); }
button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
button.sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 0.5rem 0.7rem; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-2); }
label.f { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.8rem; color: var(--muted); }
.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.row.sp { justify-content: space-between; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.form .full { grid-column: 1 / -1; }
.toolbar { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.toolbar input { max-width: 300px; }
.toolbar select { width: auto; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 0.65rem 0.7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
.tw { overflow-x: auto; }

.badge { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.73rem; font-weight: 600; background: var(--panel-2); border: 1px solid var(--line); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-active { color: var(--ok); } .b-pending { color: var(--info); } .b-suspended { color: var(--warn); } .b-expired { color: var(--muted); } .b-revoked { color: var(--bad); }
.chip { font-size: 0.72rem; padding: 0.1rem 0.5rem; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.key { font-family: ui-monospace, Consolas, monospace; letter-spacing: 0.04em; }
.copy { cursor: pointer; }
.pager { display: flex; justify-content: space-between; align-items: center; padding-top: 0.8rem; }

/* ---- drawer / modal ---- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); display: flex; justify-content: flex-end; z-index: 20; }
.overlay.center { justify-content: center; align-items: center; }
.drawer { width: min(640px, 100%); background: var(--panel); border-left: 1px solid var(--line); height: 100%; overflow-y: auto; padding: 1.3rem 1.5rem 3rem; }
.modal { width: min(560px, 94vw); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.3rem 1.5rem; max-height: 92vh; overflow-y: auto; }
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 0.45rem 1rem; margin: 0; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; word-break: break-word; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 1rem 0; }

/* ---- timeline ---- */
.tl { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); margin-left: 6px; }
.tl li { position: relative; padding: 0 0 0.9rem 1rem; }
.tl li::before { content: ""; position: absolute; left: -6px; top: 0.3rem; width: 10px; height: 10px; border-radius: 50%; background: var(--brand-2); border: 2px solid var(--panel); }
.tl li.bad::before { background: var(--bad); } .tl li.ok::before { background: var(--ok); } .tl li.warn::before { background: var(--warn); }
.tl b { font-weight: 600; } .tl small { color: var(--muted); display: block; }

/* ---- chart ---- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.bars div.c { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars .col { width: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 1px; flex: 1; }
.bars .seg { border-radius: 3px; min-height: 0; }
.bars .v { background: var(--brand-2); } .bars .a { background: var(--ok); } .bars .d { background: var(--bad); }
.bars small { font-size: 0.65rem; color: var(--muted); }
.legend { display: flex; gap: 1rem; margin-top: 0.6rem; font-size: 0.75rem; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

/* ---- login ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login .card { width: min(380px, 100%); padding: 2rem; }
.login img { height: 54px; display: block; margin: 0 auto 1rem; }
.login h1 { text-align: center; font-size: 1.2rem; }
.login .muted { text-align: center; margin: 0 0 1.2rem; }
.login form { display: grid; gap: 0.8rem; }
.err { color: var(--bad); font-size: 0.82rem; }

#toasts { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: 0.5rem; z-index: 50; }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--ok); padding: 0.65rem 0.9rem; border-radius: 9px; max-width: 380px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); }
.toast.bad { border-left-color: var(--bad); }
.secret { background: var(--bg); border: 1px dashed var(--brand-2); border-radius: 9px; padding: 0.7rem; word-break: break-all; margin: 0.6rem 0; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .brand { padding: 0.2rem 0.5rem; }
  .main { padding: 1rem; }
  .form { grid-template-columns: 1fr; }
}
