:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --ok: #059669;
  --ok-bg: #ecfdf5;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --bad: #dc2626;
  --bad-bg: #fef2f2;
  --off: #475569;
  --off-bg: #f1f5f9;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; background: #0f172a; color: #fff; }
.brand { color: #fff; font-weight: 800; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.brand small { font-weight: 500; color: #94a3b8; }
.brand:hover { text-decoration: none; }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--brand); }
.topbar nav { display: flex; flex-wrap: wrap; gap: 4px; }
.topbar nav a { color: #cbd5e1; padding: 6px 10px; border-radius: 8px; font-weight: 600; }
.topbar nav a.on, .topbar nav a:hover { background: #1e293b; color: #fff; text-decoration: none; }
.topbar nav a.logout { color: #fca5a5; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 20px 16px 40px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 0 16px 24px; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.stat .k { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 24px; font-weight: 800; margin-top: 4px; }
.stat.warn .v { color: var(--warn); }
.stat.bad .v { color: var(--bad); }
.stat.ok .v { color: var(--ok); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; }
tr:last-child td { border-bottom: 0; }
.sub { color: var(--muted); font-size: 12px; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.active { background: var(--ok-bg); color: var(--ok); }
.badge.expiring { background: var(--warn-bg); color: var(--warn); }
.badge.expired { background: var(--bad-bg); color: var(--bad); }
.badge.suspended { background: var(--off-bg); color: var(--off); }
.tokens { font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; }
.tokens.active { color: var(--ok); }
.tokens.expiring { color: var(--warn); }
.tokens.expired, .tokens.suspended { color: var(--bad); }

form .row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 12px; }
label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 9px 10px; border: 1px solid #cbd5e1; border-radius: 10px; font: inherit; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--brand); }
textarea { min-height: 90px; }
.btn { display: inline-block; border: 0; border-radius: 10px; padding: 9px 16px; font-weight: 700; cursor: pointer; background: var(--brand); color: #fff; font-size: 14px; }
.btn:hover { filter: brightness(.95); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid #cbd5e1; }
.btn.danger { background: var(--bad); }
.btn.ok { background: var(--ok); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline { display: inline; }

.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 600; }
.flash.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #a7f3d0; }
.flash.error { background: var(--bad-bg); color: var(--bad); border: 1px solid #fecaca; }

.key { font-family: ui-monospace, Consolas, monospace; background: var(--off-bg); padding: 6px 8px; border-radius: 8px; word-break: break-all; display: block; white-space: normal; }
.login { max-width: 380px; margin: 60px auto; }
.muted { color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.filters > div { min-width: 160px; }
