:root {
  color-scheme: dark;
  --bg: #070b14;
  --surface: rgba(15, 21, 35, .92);
  --surface-2: #111a2a;
  --surface-3: #172236;
  --border: rgba(151, 171, 205, .14);
  --border-strong: rgba(100, 149, 255, .35);
  --text: #f4f7ff;
  --muted: #8f9db5;
  --primary: #4d7cff;
  --primary-2: #3260ec;
  --success: #3ddc97;
  --warning: #ffbc5c;
  --danger: #ff6f7d;
  --shadow: 0 22px 65px rgba(0, 0, 0, .34);
  --radius: 20px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; overflow-x: hidden; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.ambient { position: fixed; width: 520px; height: 520px; border-radius: 50%; filter: blur(110px); opacity: .17; pointer-events: none; z-index: -1; }
.ambient-a { top: -240px; right: 2%; background: #315cff; }
.ambient-b { bottom: -280px; left: -120px; background: #00a98f; }
.auth-gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(440px, 100%); padding: 38px; border: 1px solid var(--border); border-radius: 28px; background: linear-gradient(145deg, rgba(18, 26, 43, .97), rgba(8, 13, 24, .97)); box-shadow: var(--shadow); }
.brand-mark { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 18px; background: linear-gradient(135deg, var(--primary), #805dff); box-shadow: 0 15px 35px rgba(77, 124, 255, .35); font-weight: 900; font-size: 25px; }
.brand-mark.small { width: 44px; height: 44px; border-radius: 14px; font-size: 20px; flex: 0 0 auto; }
.eyebrow { margin: 0 0 8px; font-size: 11px; letter-spacing: .16em; font-weight: 800; color: #6e8bff; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin: 20px 0 10px; font-size: 34px; letter-spacing: -.04em; }
h2 { margin: 2px 0 0; font-size: 25px; letter-spacing: -.03em; }
h3 { margin: 2px 0 0; font-size: 25px; letter-spacing: -.03em; }
h4 { margin: 2px 0 0; font-size: 19px; }
.auth-copy, .panel-copy { color: var(--muted); line-height: 1.65; }
.field-label, label > span { display: block; margin-bottom: 8px; color: #bac4d6; font-size: 13px; font-weight: 700; }
.input-shell { display: flex; align-items: center; border: 1px solid var(--border); background: #0a1020; border-radius: 14px; transition: border-color .2s, box-shadow .2s; }
.input-shell:focus-within { border-color: var(--border-strong); box-shadow: 0 0 0 4px rgba(77, 124, 255, .1); }
.input-shell input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); padding: 14px 16px; }
.icon-btn { width: 46px; height: 46px; border: 0; background: transparent; color: var(--muted); }
.primary-btn, .secondary-btn, .danger-btn, .ghost-btn { border: 1px solid transparent; border-radius: 12px; min-height: 42px; padding: 0 16px; color: white; font-weight: 800; transition: transform .16s, filter .16s, border-color .16s; }
.primary-btn { background: linear-gradient(135deg, var(--primary), var(--primary-2)); box-shadow: 0 10px 28px rgba(77, 124, 255, .24); }
.secondary-btn { background: #151e30; border-color: var(--border); color: #dfe7f6; }
.danger-btn { background: rgba(255, 86, 104, .16); border-color: rgba(255, 111, 125, .34); color: #ff9aa5; }
.ghost-btn { width: 100%; background: transparent; border-color: var(--border); color: var(--muted); }
.primary-btn:hover, .secondary-btn:hover, .danger-btn:hover, .ghost-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.auth-submit { width: 100%; margin-top: 18px; }
.form-error { margin: 14px 0 0; color: #ff8c98; font-size: 13px; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 264px minmax(0, 1fr); }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 264px; display: flex; flex-direction: column; padding: 22px 16px; border-right: 1px solid var(--border); background: rgba(7, 11, 20, .88); backdrop-filter: blur(24px); z-index: 20; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 26px; }
.sidebar-brand strong { display: block; font-size: 14px; }
.sidebar-brand span { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); }
.nav-list { display: grid; gap: 7px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 14px; border: 1px solid transparent; border-radius: 13px; color: #93a1b9; background: transparent; text-align: left; font-weight: 750; }
.nav-item span { width: 22px; color: #6f83a5; font-size: 18px; }
.nav-item:hover { background: rgba(255,255,255,.035); color: #dce5f5; }
.nav-item.active { color: white; border-color: rgba(77, 124, 255, .24); background: linear-gradient(135deg, rgba(77, 124, 255, .17), rgba(77, 124, 255, .08)); }
.nav-item.active span { color: #7d9dff; }
.sidebar-foot { margin-top: auto; display: grid; gap: 14px; }
.api-state { display: flex; align-items: center; gap: 9px; padding: 12px 13px; border: 1px solid var(--border); border-radius: 13px; color: #9faec4; font-size: 12px; }
.api-state i, .live-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px rgba(61, 220, 151, .1); }
.main-content { grid-column: 2; width: 100%; min-width: 0; padding: 0 34px 70px; }
.topbar { position: sticky; top: 0; z-index: 15; display: flex; align-items: center; justify-content: space-between; min-height: 92px; margin: 0 -34px 26px; padding: 0 34px; border-bottom: 1px solid var(--border); background: rgba(7, 11, 20, .78); backdrop-filter: blur(22px); }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.last-refresh { color: var(--muted); font-size: 12px; }
.mobile-menu { display: none; border: 0; background: transparent; color: white; font-size: 24px; }
.page-section { scroll-margin-top: 112px; margin-bottom: 38px; }
.section-heading, .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.section-heading { margin-bottom: 18px; }
.live-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid rgba(61, 220, 151, .24); border-radius: 999px; background: rgba(61, 220, 151, .08); color: #87edbd; font-size: 11px; font-weight: 900; letter-spacing: .09em; }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.stat-card, .panel { border: 1px solid var(--border); background: linear-gradient(145deg, rgba(18, 25, 41, .92), rgba(11, 16, 28, .94)); box-shadow: 0 12px 42px rgba(0,0,0,.15); }
.stat-card { position: relative; overflow: hidden; min-height: 150px; padding: 22px; border-radius: 18px; }
.stat-card::after { content: ""; position: absolute; width: 110px; height: 110px; right: -50px; top: -50px; border-radius: 50%; background: rgba(77, 124, 255, .12); filter: blur(12px); }
.stat-card span { display: block; color: #a8b4c8; font-size: 13px; font-weight: 700; }
.stat-card strong { display: block; margin: 13px 0 9px; font-size: 35px; letter-spacing: -.04em; }
.stat-card small { color: #6f7d94; }
.split-grid { display: grid; grid-template-columns: 1.3fr .7fr; gap: 14px; }
.overview-panels { margin-top: 14px; }
.panel { border-radius: var(--radius); padding: 22px; }
.text-btn { border: 0; background: transparent; color: #86a2ff; font-weight: 800; }
.duration-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.duration-preview span { padding: 8px 12px; border: 1px solid var(--border); border-radius: 999px; background: rgba(255,255,255,.025); color: #bcc7d9; font-size: 12px; }
.big-metric { display: flex; align-items: baseline; gap: 10px; margin: 20px 0 10px; }
.big-metric strong { font-size: 42px; }
.big-metric span { color: var(--muted); }
.create-panel { padding: 26px; }
.duration-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.duration-option { min-height: 92px; display: grid; place-content: center; gap: 5px; border: 1px solid var(--border); border-radius: 16px; background: #0d1423; color: var(--muted); transition: border-color .18s, background .18s, transform .18s; }
.duration-option strong { font-size: 21px; color: #e9effa; }
.duration-option span { font-size: 12px; }
.duration-option:hover { transform: translateY(-2px); border-color: rgba(100, 149, 255, .28); }
.duration-option.active { border-color: rgba(94, 138, 255, .66); background: linear-gradient(145deg, rgba(77,124,255,.22), rgba(77,124,255,.07)); box-shadow: inset 0 0 0 1px rgba(93,137,255,.12), 0 12px 25px rgba(41, 77, 177, .13); }
.duration-option.active strong { color: #8fa9ff; }
.form-grid { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 14px; margin-top: 20px; }
.form-grid input, .table-toolbar input, .table-toolbar select, select { width: 100%; min-height: 45px; border: 1px solid var(--border); border-radius: 12px; outline: none; background: #0a1020; color: var(--text); padding: 0 14px; }
.form-grid input:focus, .table-toolbar input:focus, select:focus { border-color: var(--border-strong); box-shadow: 0 0 0 4px rgba(77,124,255,.08); }
.create-summary { display: grid; grid-template-columns: 1.3fr .7fr auto; align-items: end; gap: 16px; margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--border); }
.create-summary span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 12px; }
.create-summary strong { display: block; overflow: hidden; text-overflow: ellipsis; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.result-panel { margin-top: 14px; border-color: rgba(61, 220, 151, .24); }
.created-key-list { display: grid; gap: 9px; margin-top: 16px; }
.created-key-row { display: flex; align-items: center; gap: 10px; padding: 12px 13px; border: 1px solid var(--border); border-radius: 13px; background: #0b1220; }
.created-key-row code { min-width: 0; flex: 1; overflow-wrap: anywhere; color: #a9bfff; }
.table-panel { padding: 0; overflow: hidden; }
.table-toolbar { display: flex; justify-content: space-between; gap: 12px; padding: 18px; border-bottom: 1px solid var(--border); }
.search-box { flex: 1; max-width: 520px; display: flex; align-items: center; border: 1px solid var(--border); border-radius: 12px; background: #0a1020; }
.search-box span { padding-left: 14px; color: var(--muted); }
.search-box input { border: 0; background: transparent; }
.table-toolbar select { width: 190px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 940px; }
th, td { padding: 14px 16px; border-bottom: 1px solid rgba(151, 171, 205, .09); text-align: left; vertical-align: middle; }
th { color: #77869d; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
td { color: #cbd5e5; font-size: 13px; }
tbody tr:hover { background: rgba(255,255,255,.018); }
.key-cell { max-width: 300px; }
.key-cell code { display: block; color: #9fb4ff; overflow-wrap: anywhere; }
.key-cell small, .device-cell small { display: block; margin-top: 5px; color: #68758b; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; border: 1px solid; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.status-unused { color: #aeb9ca; border-color: rgba(174,185,202,.2); background: rgba(174,185,202,.07); }
.status-active { color: #72e7b0; border-color: rgba(61,220,151,.25); background: rgba(61,220,151,.08); }
.status-expired { color: #ffc57b; border-color: rgba(255,188,92,.25); background: rgba(255,188,92,.08); }
.status-revoked { color: #ff929e; border-color: rgba(255,111,125,.25); background: rgba(255,111,125,.08); }
.online-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(61,220,151,.08); }
.actions { display: flex; justify-content: flex-end; gap: 6px; }
.action-btn { min-width: 34px; min-height: 34px; border: 1px solid var(--border); border-radius: 9px; background: #121b2b; color: #aebcd1; }
.action-btn:hover { color: white; border-color: rgba(112,145,215,.36); }
.empty-state { padding: 44px 20px; text-align: center; color: var(--muted); }
.event-chip { display: inline-flex; padding: 6px 9px; border-radius: 8px; background: #151f31; color: #b7c4d8; font-size: 11px; font-weight: 800; }
.modal-backdrop { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; background: rgba(3,6,12,.72); backdrop-filter: blur(8px); }
.modal-card { width: min(430px, 100%); padding: 25px; border: 1px solid var(--border); border-radius: 20px; background: #101827; box-shadow: var(--shadow); }
.modal-card p:not(.eyebrow) { color: var(--muted); line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.toast-host { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 10px; width: min(360px, calc(100vw - 40px)); }
.toast { padding: 13px 15px; border: 1px solid var(--border); border-radius: 13px; background: #121b2b; box-shadow: 0 14px 40px rgba(0,0,0,.32); color: #dce5f3; animation: toastIn .22s ease-out; }
.toast.error { border-color: rgba(255,111,125,.32); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .duration-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .create-summary { grid-template-columns: 1fr 1fr; }
  .create-summary .primary-btn { grid-column: 1 / -1; }
}
@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { transform: translateX(-105%); transition: transform .22s ease; box-shadow: 20px 0 50px rgba(0,0,0,.35); }
  .sidebar.open { transform: translateX(0); }
  .main-content { padding: 0 18px 60px; }
  .topbar { margin: 0 -18px 24px; padding: 0 18px; }
  .mobile-menu { display: block; margin-right: 12px; }
  .topbar > div:nth-child(2) { flex: 1; }
  .last-refresh { display: none; }
  .split-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .auth-card { padding: 28px 22px; }
  h2 { font-size: 19px; }
  h3 { font-size: 22px; }
  .topbar { min-height: 78px; }
  .topbar .eyebrow { display: none; }
  .topbar-actions .secondary-btn { padding: 0 11px; font-size: 12px; }
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { min-height: 132px; }
  .duration-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .create-summary { grid-template-columns: 1fr; }
  .table-toolbar { flex-direction: column; }
  .search-box, .table-toolbar select { width: 100%; max-width: none; }
  .created-key-row { align-items: flex-start; flex-wrap: wrap; }
}
