:root {
  --bg: #f4f5fb; --surface: #fff; --surface-2: #f7f8fc; --surface-3: #eef0f7;
  --border: rgba(20, 24, 50, .09); --text: #171a2e; --muted: #646a88;
  --accent: #6d5dfc; --grad: linear-gradient(135deg, #8b7bff 0%, #5b8cff 100%);
  --good: #059669; --good-soft: rgba(5, 150, 105, .1); --warn: #d97706; --warn-soft: rgba(217, 119, 6, .1);
  --bad: #dc2626; --bad-soft: rgba(220, 38, 38, .09); --shadow: 0 10px 30px -14px rgba(30, 30, 80, .25);
  font-family: "Segoe UI", Inter, system-ui, -apple-system, sans-serif; font-size: 14px; color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(1000px 500px at 90% -10%, rgba(124, 108, 255, .1), transparent 60%), var(--bg); min-height: 100vh; }
a { color: #4f6cf7; text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.02em; }
h2 { font-size: 15px; margin: 0 0 14px; }
code { font-family: Consolas, "Cascadia Code", monospace; font-size: 12.5px; background: var(--surface-3); padding: 2px 6px; border-radius: 6px; }
code.wrap { word-break: break-all; }
.mono { font-family: Consolas, monospace; letter-spacing: .02em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }

.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); 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; font-size: 14px; }
.brand span { font-size: 12px; color: var(--muted); }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: var(--grad); position: relative; box-shadow: 0 6px 18px -6px rgba(109, 93, 252, .6); flex: none; margin: 0 auto 10px; }
.brand-mark::after { content: ""; position: absolute; left: 50%; top: 45%; width: 14px; height: 14px; background: #fff; border-radius: 50% 50% 50% 0; transform: translate(-50%, -50%) rotate(-45deg); }
.brand-mark.sm { width: 32px; height: 32px; margin: 0; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav a { padding: 9px 12px; border-radius: 9px; color: var(--muted); font-weight: 500; }
.side nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.side nav a.on { background: rgba(109, 93, 252, .1); color: var(--text); font-weight: 600; }
.main { padding: 28px 32px; max-width: 1280px; width: 100%; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.page-head.tight { margin-bottom: 10px; align-items: center; }
.page-head.tight h2 { margin: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; overflow-x: auto; }
.card.flush { padding: 0; }
.card.narrow { max-width: 720px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid2 > .card { margin-bottom: 0; }
.grid2 + .card, .grid2 + section { margin-top: 18px; }
.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 26px; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 12.5px; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table code { white-space: nowrap; }
.table tbody tr:hover { background: var(--surface-2); }
.table .empty { text-align: center; padding: 30px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--muted); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.active { color: var(--good); background: var(--good-soft); }
.pill.unused { color: #4f6cf7; background: rgba(79, 108, 247, .1); }
.pill.expired, .pill.suspended { color: var(--warn); background: var(--warn-soft); }
.pill.revoked { color: var(--bad); background: var(--bad-soft); }
.tag { display: inline-block; padding: 2px 9px; border-radius: 7px; background: var(--surface-3); font-size: 12px; font-weight: 600; }
.tag.plan-lifetime { background: rgba(109, 93, 252, .12); color: #5b4ae0; }
.tag.plan-yearly { background: rgba(79, 108, 247, .1); color: #3c5ae0; }
.tag.plan-trial { background: var(--warn-soft); color: var(--warn); }

.form { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-weight: 500; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; outline: none; width: 100%; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109, 93, 252, .15); }
input.sm { width: 110px; padding: 7px 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filters input { max-width: 340px; }
.filters select { width: auto; }
textarea.keys { font-family: Consolas, monospace; font-size: 14px; letter-spacing: .03em; margin-bottom: 12px; }

.btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn.primary { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 6px 18px -6px rgba(109, 93, 252, .7); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.warn { color: var(--warn); }
.btn.ok { color: var(--good); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.copy { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 14px; padding: 0 4px; }
.copy:hover { color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
form.inline { display: inline-flex; gap: 6px; align-items: center; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.pager { display: flex; gap: 8px; justify-content: center; }
.logout { margin-top: auto; }

/* Dashboard */
.head-actions { align-items: center; }
.head-search input { width: 280px; background: var(--surface); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { display: flex; align-items: center; gap: 14px; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); color: var(--text); transition: transform .12s, border-color .12s; }
.kpi:hover { text-decoration: none; transform: translateY(-1px); border-color: rgba(109, 93, 252, .35); }
.kpi-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.kpi-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.kpi-body { display: flex; flex-direction: column; min-width: 0; }
.kpi-body b { font-size: 26px; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-body span { font-size: 13px; font-weight: 600; }
.kpi-body em { font-style: normal; font-size: 12px; color: var(--muted); }
.k-good .kpi-icon { background: var(--good-soft); color: var(--good); }
.k-blue .kpi-icon { background: rgba(79, 108, 247, .1); color: #4f6cf7; }
.k-violet .kpi-icon { background: rgba(109, 93, 252, .1); color: var(--accent); }
.k-warn .kpi-icon { background: var(--warn-soft); color: var(--warn); }
.k-warn b { color: var(--warn); }
.k-muted .kpi-icon { background: var(--surface-3); color: var(--muted); }
.card-title { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.card-title h2 { margin: 0; }
.plan-rows, .status-rows { display: flex; flex-direction: column; }
.plan-row, .status-row { display: grid; align-items: center; gap: 12px; padding: 9px 8px; margin: 0 -8px; border-radius: 9px; color: var(--text); }
.plan-row:hover, .status-row:hover { background: var(--surface-2); text-decoration: none; }
.plan-row { grid-template-columns: 96px 1fr 56px; }
.pr-bar { display: block; width: 100%; height: 8px; }
.pr-bg { fill: var(--surface-3); }
.pr-fg { fill: var(--accent); }
.pr-fg.plan-free { fill: #10b981; }
.pr-fg.plan-trial { fill: var(--warn); }
.pr-fg.plan-monthly { fill: #8b7bff; }
.pr-fg.plan-yearly { fill: #4f6cf7; }
.pr-fg.plan-lifetime { fill: #5b4ae0; }
.tag.plan-free { background: var(--good-soft); color: var(--good); }
div.plan-row { cursor: default; }
.pr-note { margin: 10px 0 0; }
.pr-num, .sr-num { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.status-row { grid-template-columns: 1fr 56px 44px; }
.sr-label { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.active { background: var(--good); }
.dot.unused { background: #4f6cf7; }
.dot.expired, .dot.suspended { background: var(--warn); }
.dot.revoked { background: var(--bad); }
.sr-pct { text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; }
.pill.deactivated { color: var(--muted); }

.notice { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; }
.notice.ok { background: var(--good-soft); color: var(--good); }
.notice.err { background: var(--bad-soft); color: var(--bad); }

body.center { display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 32px; box-shadow: var(--shadow); text-align: center; }
.auth-card .form { text-align: left; margin-top: 18px; }
.auth-card p { margin: 0 0 6px; }
.steps { text-align: left; line-height: 1.9; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .grid2, .row2 { grid-template-columns: 1fr; }
  .stats, .kpis { grid-template-columns: repeat(2, 1fr); }
  .head-search input { width: 100%; }
  .main { padding: 18px 16px; }
}
.btn-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
