:root {
    --navy: #0b1b3a;
    --navy-2: #102447;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e6ebf2;
    --bg: #eef3f9;
    --blue: #2563eb;
    --green: #16a34a;
    --amber: #f5b400;
    --red: #ef4444;
    --slate: #475569;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", Inter, ui-sans-serif, system-ui, sans-serif; color: var(--ink); background: var(--bg); }
a { color: inherit; }
button, input, select { font: inherit; }
.topbar { height: 64px; background: linear-gradient(90deg, #071428, #12305f); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; position: sticky; top: 0; z-index: 20; box-shadow: 0 8px 24px rgba(7, 20, 40, 0.25); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: 0.01em; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; background: linear-gradient(180deg, #ffd15a, #f5b400); color: #111; display: grid; place-items: center; font-size: 13px; }
.top-links { display: flex; gap: 18px; color: #dbe7ff; font-size: 14px; }
.top-links a { text-decoration: none; }
.who { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #1d4ed8; display: grid; place-items: center; }
.shell { display: flex; min-height: calc(100vh - 64px); }
.sidebar { width: 248px; background: var(--navy-2); color: #d6e2f5; padding: 18px 12px; }
.sidebar a { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 11px 12px; border-radius: 12px; margin-bottom: 4px; color: #d6e2f5; }
.sidebar a strong { width: 28px; height: 28px; border-radius: 8px; background: rgba(255,255,255,.08); display: grid; place-items: center; font-size: 12px; }
.sidebar a.active, .sidebar a:hover { background: #1d4ed8; color: #fff; }
.sidebar a.active strong { background: rgba(255,255,255,.18); }
.logout-form { margin-top: 18px; }
.logout-form button { width: 100%; text-align: left; background: transparent; color: #d6e2f5; border: 0; padding: 11px 12px; border-radius: 12px; cursor: pointer; }
.logout-form button:hover { background: #7f1d1d; color: #fff; }
.content { flex: 1; padding: 26px 28px 48px; }
.crumb { text-align: right; color: var(--blue); font-size: 13px; margin-bottom: 10px; }
h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
h2 { margin: 0 0 12px; font-size: 18px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; }
.page-head p { margin: 6px 0 0; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 8px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; gap: 12px; align-items: center; text-decoration: none; box-shadow: var(--shadow); min-height: 84px; transition: transform .15s ease, box-shadow .15s ease; }
.kpi:hover { transform: translateY(-2px); box-shadow: 0 16px 32px rgba(15, 23, 42, 0.1); }
.kpi.static { cursor: default; }
.kpi b { display: block; font-size: 14px; }
.kpi small { color: var(--muted); }
.ico { min-width: 52px; height: 52px; padding: 0 8px; border-radius: 14px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px; }
.ico.blue { background: linear-gradient(180deg, #3b82f6, #1d4ed8); }
.ico.green { background: linear-gradient(180deg, #22c55e, #15803d); }
.ico.amber { background: linear-gradient(180deg, #fbbf24, #d97706); color: #111; }
.ico.red { background: linear-gradient(180deg, #f87171, #dc2626); }
.ico.slate { background: linear-gradient(180deg, #94a3b8, #475569); }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.filters label { min-width: 150px; }
.filter-actions { display: flex; gap: 8px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; letter-spacing: .03em; text-transform: uppercase; color: #475569; padding: 10px 8px; border-bottom: 1px solid var(--line); }
td { padding: 12px 8px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tr:hover td { background: #f8fafc; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.valid, .badge.active { background: #dcfce7; color: #166534; }
.badge.used { background: #e2e8f0; color: #334155; }
.badge.expired, .badge.disabled { background: #fee2e2; color: #991b1b; }
.btn { border: 0; border-radius: 10px; padding: 9px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; font-weight: 650; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.ghost { background: #e2e8f0; color: #0f172a; }
.flash { background: #ecfdf3; color: #166534; border: 1px solid #bbf7d0; padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }
.errors { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }
.form-grid { display: grid; gap: 12px; max-width: 520px; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
input, select { border: 1px solid #d7dee8; border-radius: 10px; padding: 9px 10px; background: #fff; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at top, #1d4ed8, #0b1b3a 55%); }
.login-card { width: min(400px, calc(100% - 32px)); background: #fff; border-radius: 18px; padding: 28px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 24px; margin-bottom: 8px; }
.muted { color: var(--muted); font-size: 13px; font-weight: 500; }
code { font-size: 12px; background: #f1f5f9; padding: 2px 6px; border-radius: 6px; }
.empty { text-align: center; color: var(--muted); padding: 28px 8px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.pager-links { display: flex; gap: 6px; }
.pager-links a, .pager-links span { min-width: 36px; height: 36px; padding: 0 10px; border-radius: 10px; display: grid; place-items: center; text-decoration: none; background: #f1f5f9; color: #0f172a; }
.pager-links a.on { background: var(--blue); color: #fff; }
.pager-links span.off { color: #94a3b8; }
.license-pill { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; box-shadow: var(--shadow); display: grid; min-width: 160px; }
.license-pill span { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.license-pill strong { font-size: 28px; }
@media (max-width: 1100px) {
    .cards { grid-template-columns: 1fr 1fr; }
    .shell { display: block; }
    .sidebar { width: auto; display: flex; gap: 6px; overflow-x: auto; }
    .sidebar a { white-space: nowrap; }
    .logout-form { margin: 0; }
}
@media (max-width: 640px) {
    .cards { grid-template-columns: 1fr; }
    .content { padding: 18px 14px 32px; }
}
