:root {
  --bg: #0e1116;
  --surface: #161a20;
  --surface-2: #1d222a;
  --border: #2a303a;
  --ink: #e8e6e1;
  --muted: #98a1ab;
  --accent: #d8b25a;
  --accent-ink: #1a1405;
  --ok: #5cb87a;
  --warn: #e0a33c;
  --danger: #d9534f;
  --info: #5b9bd5;
  --radius: 10px;
  --side: 220px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100dvh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.92em; color: #f0e6c8; }
h1 { font-size: 24px; margin: 0; font-weight: 600; }
h2 { font-size: 17px; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 15px; margin: 18px 0 8px; font-weight: 600; color: var(--muted); }
p { margin: 0 0 12px; }
small { font-size: 12.5px; }
.muted { color: var(--muted); }
.warn { color: var(--warn); }

body.app { display: grid; grid-template-columns: var(--side) 1fr; }
.side { position: sticky; top: 0; height: 100dvh; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 18px 14px; }
.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; padding: 4px 8px 18px; }
.brand small { color: var(--muted); font-weight: 400; }
.brand.big { font-size: 20px; padding-bottom: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { padding: 9px 12px; border-radius: 8px; color: var(--ink); }
.side nav a:hover { background: var(--surface-2); text-decoration: none; }
.side nav a.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.side-foot { margin-top: auto; padding: 8px 12px; display: flex; justify-content: space-between; align-items: center; color: var(--muted); }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

.main { padding: 26px 30px 60px; max-width: 1400px; width: 100%; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; min-width: 0; }
.card.narrow { max-width: 720px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 18px; }
.cols > .card { margin-bottom: 0; }
.cols { margin-bottom: 18px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; color: var(--ink); }
.tile:hover { text-decoration: none; border-color: var(--accent); }
.tile b { font-size: 26px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: 13px; }
.tile.accent { border-color: var(--accent); }
.tile.accent b { color: var(--accent); }

.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 500; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl.keys code.key { font-size: 15px; letter-spacing: .04em; }
.nowrap { white-space: nowrap; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink); white-space: nowrap; }
.st-active, .r-ok, .st-ok { background: rgba(92,184,122,.15); border-color: rgba(92,184,122,.5); color: #8fd6a6; }
.st-issued { background: rgba(91,155,213,.15); border-color: rgba(91,155,213,.5); color: #9cc4ea; }
.st-paused, .st-suspended, .st-degraded, .r-device_mismatch, .r-lease_conflict, .r-hwid_changed, .r-many_devices { background: rgba(224,163,60,.15); border-color: rgba(224,163,60,.5); color: #f0c46f; }
.st-expired, .st-void { background: rgba(152,161,171,.15); color: var(--muted); }
.st-revoked, .st-refunded, .st-chargeback, .st-broken, .r-revoked, .r-refunded, .r-unknown_key { background: rgba(217,83,79,.15); border-color: rgba(217,83,79,.5); color: #f19794; }
.chip { display: inline-block; padding: 0 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; margin-right: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; min-height: 38px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.warn { border-color: var(--warn); color: #f0c46f; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger.ghost { background: transparent; color: #f19794; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

.form label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.form label.inline { display: inline; margin: 0; }
.form label.check { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); margin: 6px 14px 6px 0; font-size: 14px; }
.form label.check.top { margin-top: 30px; }
input, select, textarea { width: 100%; background: var(--bg); color: var(--ink); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: inherit; min-height: 38px; }
input[type=checkbox] { width: 16px; height: 16px; min-height: 0; accent-color: var(--accent); }
input[type=file] { padding: 6px; }
input.short { width: 140px; }
select.small { width: auto; min-height: 30px; padding: 3px 8px; font-size: 13px; }
textarea.mono { font-family: ui-monospace, Consolas, monospace; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px 10px; margin: 12px 0; }
legend { color: var(--muted); font-size: 13px; padding: 0 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.row { display: flex; align-items: center; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row input.short { width: 140px; }
form.inline { display: inline-flex; align-items: center; gap: 6px; }
form.inline input { width: 180px; min-height: 30px; padding: 3px 8px; font-size: 13px; }

.filters { display: grid; grid-template-columns: 1fr 200px auto; gap: 10px; margin-bottom: 14px; }
.pager { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 14px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.flash.ok { background: rgba(92,184,122,.12); border-color: rgba(92,184,122,.5); }
.flash.err { background: rgba(217,83,79,.12); border-color: rgba(217,83,79,.5); }

body.bare .main { max-width: none; padding: 0; }
.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; }
.login h1 { font-size: 18px; margin: 4px 0 8px; }
.login .btn { margin-top: 18px; }

@media (max-width: 860px) {
  body.app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 6px; padding: 10px 12px; }
  .brand { padding: 0 8px 0 0; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { margin: 0 0 0 auto; padding: 0 4px; gap: 10px; }
  .main { padding: 16px; }
  .grid2, .filters { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dt { margin-top: 8px; }
  .card { overflow-x: auto; }
}
