:root {
  --bg: #f5f6fb; --card: #fff; --ink: #17181c; --muted: #6b6f7b; --line: #e5e7ef;
  --brand: linear-gradient(135deg, #388fff, #4f45e6); --blue: #4a5cf0;
  --ok: #138a4b; --bad: #d23b3b; --warn-bg: #fff6e5; --warn: #8a5a00;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111216; --card: #1a1b20; --ink: #eef0f5; --muted: #9a9daa; --line: #2a2c33; --warn-bg: #2d2412; --warn: #f0c46b; --ok: #4ccf86; --bad: #ff7676; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif; }
h1 { font-size: 26px; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 18px 0 6px; }
p { margin: 4px 0; }
small { display: block; color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }
.mono, code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }

.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--card); 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; gap: 10px; align-items: center; padding: 0 6px; }
.brand b { display: block; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); box-shadow: 0 6px 14px -6px #4f45e6; }
nav { display: grid; gap: 2px; }
nav a { padding: 8px 10px; border-radius: 9px; color: var(--ink); text-decoration: none; }
nav a:hover { background: var(--bg); }
nav a.on { background: var(--bg); font-weight: 600; color: var(--blue); }
.who { margin-top: auto; font-size: 12px; color: var(--muted); padding: 0 6px; word-break: break-all; }
main { padding: 28px clamp(16px, 4vw, 40px); max-width: 1100px; width: 100%; }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  nav { grid-auto-flow: column; overflow-x: auto; }
  .who { margin: 0; }
}

.head { margin-bottom: 18px; }
.head p { color: var(--muted); }
.row { display: flex; justify-content: space-between; align-items: end; gap: 12px; }
.gap { gap: 10px; justify-content: flex-start; align-items: center; margin: 8px 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow-x: auto; }
.grid2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.stat b { font-size: 24px; letter-spacing: -.02em; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; }
.bar i { width: 100%; max-width: 26px; border-radius: 6px 6px 3px 3px; background: var(--brand); }
.bar .n { font-size: 11px; color: var(--muted); min-height: 14px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list li:last-child { border-bottom: 0; }
.list .right { text-align: right; }

.toolbar { display: flex; gap: 10px; margin-bottom: 12px; }
.toolbar input { flex: 1; }
input, select, textarea { font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%; }
select { width: auto; }
textarea { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #4a5cf055; border-color: var(--blue); }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--bg); }
.table tr:last-child td { border-bottom: 0; }
.empty { color: var(--muted); text-align: center; padding: 30px !important; }
.pager { display: flex; gap: 8px; justify-content: flex-end; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.active { background: #e2f6ea; color: var(--ok); }
.pill.revoked { background: #fde6e6; color: var(--bad); }
@media (prefers-color-scheme: dark) { .pill.active { background: #15301f; } .pill.revoked { background: #3a1818; } }

.btn, .ghost, .bad, .btnlike { font: inherit; font-weight: 600; border-radius: 10px; padding: 9px 14px; cursor: pointer; border: 1px solid transparent; text-decoration: none; display: inline-block; }
.btn { background: var(--brand); color: #fff; box-shadow: 0 8px 18px -10px #4f45e6; }
.ghost, .btnlike { background: var(--card); color: var(--ink); border-color: var(--line); }
.bad { background: var(--bad); color: #fff; }
.small { padding: 6px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }

.form { display: grid; gap: 12px; max-width: 560px; }
.form label { display: grid; gap: 5px; font-weight: 600; font-size: 13px; }
.form label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.form label.check input { width: auto; }
.form .btn { justify-self: start; }
.error, .badtext { color: var(--bad); }
.oktext, .ok { color: var(--ok); }
.warn { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 8px 12px; }
.result { max-width: 760px; }
.key { display: block; padding: 12px; border-radius: 10px; background: var(--bg); word-break: break-all; margin: 8px 0; user-select: all; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 12px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; word-break: break-word; }
.note { color: var(--muted); font-size: 12px; }
.block { display: grid; gap: 5px; font-weight: 600; font-size: 13px; margin-top: 14px; }

.drawer { position: fixed; inset: 0; background: #0006; display: flex; justify-content: flex-end; z-index: 10; }
.drawer[hidden] { display: none; }
.drawer-panel { background: var(--card); width: min(520px, 100%); height: 100%; overflow-y: auto; padding: 26px; position: relative; box-shadow: -20px 0 60px -30px #000; }
.close { position: absolute; top: 14px; right: 16px; font-size: 24px; border: 0; background: none; color: var(--muted); cursor: pointer; }
.danger { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 4px; display: grid; gap: 8px; }
.danger .bad, .danger .btn { justify-self: start; }
.history { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.history li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.signin { max-width: 520px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #17181c; color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 600; z-index: 20; box-shadow: 0 10px 30px -10px #000; }
.toast.bad { background: var(--bad); }
.toast[hidden] { display: none; }
[hidden] { display: none !important; }

.signin-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; max-width: none; width: 100%; }
.signin { width: min(420px, 100%); display: grid; gap: 12px; }
.signin .form { max-width: none; }
.signin .brand { padding: 0; margin-bottom: 6px; }
.who a { color: var(--blue); }
