:root {
  --bg: #07080c;
  --sidebar: #0b0d14;
  --surface: #11131c;
  --surface2: #161926;
  --border: #22263a;
  --border-bright: #3a4066;
  --text: #e8eaf3;
  --muted: #868ca8;
  --accent: #00e0b8;
  --accent2: #00b3ff;
  --accent-dim: #0a3f3a;
  --ok: #3ddc84;
  --bad: #ff5570;
  --radius: 16px;
}

:root[data-theme="light"] {
  --bg: #f4f6fb;
  --sidebar: #ffffff;
  --surface: #ffffff;
  --surface2: #eef1f8;
  --border: #dde1ee;
  --border-bright: #b9c0da;
  --text: #171a26;
  --muted: #666d87;
  --accent-dim: #c9f5ea;
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  cursor: none;
  transition: background .25s, color .25s;
}
.sidebar, .content, .stat-tile, .tile, .card, input, button, .button {
  transition: background .25s, color .25s, border-color .25s, box-shadow .25s, transform .15s;
}

@media (hover: none), (pointer: coarse) {
  body { cursor: auto; }
  .cursor-dot, .cursor-ring { display: none !important; }
}

a { color: var(--accent2); }

/* ---- custom cursor ---------------------------------------------------- */
.cursor-dot, .cursor-ring {
  position: fixed; top: 0; left: 0; pointer-events: none;
  border-radius: 50%; z-index: 9999; transform: translate(-50%, -50%); will-change: transform;
}
.cursor-dot {
  width: 5px; height: 5px; background: var(--accent);
  box-shadow: 0 0 10px 2px rgba(0, 224, 184, .7);
  transition: opacity .2s, background .15s;
}
.cursor-ring {
  width: 30px; height: 30px; border: 1px solid rgba(0, 224, 184, .4);
  transition: width .18s ease, height .18s ease, border-color .18s ease, opacity .2s, background .18s ease;
}
body.cursor-hover .cursor-ring { width: 50px; height: 50px; border-color: var(--accent); background: rgba(0, 224, 184, .08); }
body.cursor-hover .cursor-dot { background: #fff; }
body.cursor-down .cursor-ring { width: 22px; height: 22px; }
.cursor-dot.hide, .cursor-ring.hide { opacity: 0; }

/* ---- app shell: fixed sidebar + content ------------------------------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex: 0 0 240px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 22px 16px;
  position: sticky; top: 0; height: 100vh;
}
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
main {
  width: 100%; max-width: 980px; margin: 0 auto; padding: 36px 28px 64px; flex: 1;
  position: relative;
}
.content {
  background-image: linear-gradient(rgba(255, 255, 255, .025) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .025) 1px, transparent 1px);
  background-size: 34px 34px;
  background-position: 0 0;
  animation: gridshift 60s linear infinite;
}
@keyframes gridshift { to { background-position: 340px 340px; } }
@media (prefers-reduced-motion: reduce) { .content { animation: none; } }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 16px; border-top: 1px solid var(--border); }

.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); font-weight: 800; letter-spacing: .06em; font-size: 18px;
  text-decoration: none; padding: 0 8px 20px;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #04221d; font-weight: 900;
  box-shadow: 0 0 18px rgba(0, 224, 184, .45);
}

.sidenav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.sidenav a {
  color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600;
  padding: 10px 12px; border-radius: 10px; display: flex; align-items: center; gap: 10px;
  transition: background .15s, color .15s;
}
.sidenav a::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--border-bright);
  transition: background .15s, box-shadow .15s;
}
.sidenav a:hover { background: var(--surface); color: var(--text); }
.sidenav a:hover::before { background: var(--accent); box-shadow: 0 0 8px rgba(0, 224, 184, .6); }
.sidenav a.active { background: var(--surface2); color: var(--text); }
.sidenav a.active::before { background: var(--accent); box-shadow: 0 0 8px rgba(0, 224, 184, .6); }

.side-user {
  margin-top: auto; display: flex; align-items: center; gap: 10px;
  padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border);
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent2), var(--accent)); color: #04221d; font-weight: 800;
  flex: none;
}
.side-user-info { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.side-user-info strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.side-user-info .muted { font-size: 11px; }
.side-logout { margin-top: 8px; }
.side-logout button { width: 100%; text-align: left; color: var(--muted); background: none; border: none; padding: 8px 12px; font-size: 13px; }
.side-logout button:hover { color: var(--bad); }

/* theme toggle */
.theme-toggle {
  display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 10px;
  background: none; border: none; padding: 8px 12px; color: var(--muted); font-size: 13px;
}
.theme-toggle:hover { color: var(--text); border-color: transparent; transform: none; }
.theme-toggle-track {
  width: 34px; height: 18px; border-radius: 999px; background: var(--surface2); border: 1px solid var(--border);
  position: relative; flex: none;
}
.theme-toggle-thumb {
  position: absolute; top: 1px; left: 1px; width: 14px; height: 14px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  transition: transform .2s ease;
}
:root[data-theme="light"] .theme-toggle-thumb { transform: translateX(16px); }

/* account detail list */
.detail-list { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.detail-list > div { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; border-bottom: 1px dashed var(--border); padding-bottom: 8px; }
.detail-list > div:last-child { border-bottom: none; padding-bottom: 0; }
.detail-list dt { color: var(--muted); margin: 0; }
.detail-list dd { margin: 0; font-weight: 600; text-align: right; }

/* bar chart */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 32px; align-items: center; gap: 10px; font-size: 13px; }
.bar-label { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; border-radius: 999px; background: var(--surface2); border: 1px solid var(--border); overflow: hidden; }
.bar-fill {
  height: 100%; width: var(--pct, 0%); border-radius: 999px;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  animation: growIn .7s cubic-bezier(.2, .8, .2, 1) both;
}
.bar-count { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- page header / stats ----------------------------------------------- */
.pagehead { margin-bottom: 26px; animation: fadeUp .5s ease both; }
.pagehead h1 { font-size: 28px; margin: 0 0 6px; letter-spacing: -.01em; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 36px; }
.stat-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 4px;
  opacity: 0; transform: translateY(12px); animation: fadeUp .5s cubic-bezier(.2, .8, .2, 1) forwards;
  transition: border-color .2s, transform .2s;
}
.stat-row .stat-tile:nth-child(1) { animation-delay: .02s; }
.stat-row .stat-tile:nth-child(2) { animation-delay: .09s; }
.stat-row .stat-tile:nth-child(3) { animation-delay: .16s; }
.stat-tile:hover { border-color: var(--border-bright); transform: translateY(-2px); }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.stat-value { font-size: 24px; font-weight: 700; }
.stat-value.ok { color: var(--ok); }
.stat-value.bad { color: var(--bad); }
.stat-sub { font-size: 12px; color: var(--muted); }

/* ---- sections / tiles --------------------------------------------------- */
.panel-section { margin-bottom: 40px; scroll-margin-top: 24px; }
.section-title {
  font-size: 13px; text-transform: uppercase; letter-spacing: .12em; color: var(--accent);
  margin: 0 0 14px; display: flex; align-items: center; gap: 10px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.tiles-single { grid-template-columns: 1fr; }
.tile {
  background: linear-gradient(165deg, var(--surface2), var(--surface));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 22px;
  position: relative; overflow: hidden;
  opacity: 0; transform: translateY(14px); animation: fadeUp .55s cubic-bezier(.2, .8, .2, 1) forwards;
  transition: border-color .25s, transform .25s, box-shadow .25s;
}
.tiles .tile:nth-child(1) { animation-delay: .03s; }
.tiles .tile:nth-child(2) { animation-delay: .11s; }
.tile::before {
  content: ""; position: absolute; inset: -1px; border-radius: inherit;
  background: radial-gradient(180px 120px at var(--mx, 50%) var(--my, 0%), rgba(0, 224, 184, .14), transparent 70%);
  opacity: 0; transition: opacity .25s; pointer-events: none;
}
.tile:hover { border-color: var(--border-bright); transform: translateY(-2px); box-shadow: 0 16px 34px -18px rgba(0, 224, 184, .35); }
.tile:hover::before { opacity: 1; }
.tile h3 { margin: 0 0 12px; font-size: 15px; color: var(--text); }

.tile-download { display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap; }
.tile-download-info { max-width: 520px; }

/* progress bar (subscription) */
.progress {
  height: 8px; border-radius: 999px; background: #0a0b12; border: 1px solid var(--border);
  margin: 10px 0 4px; overflow: hidden;
}
.progress-fill {
  height: 100%; width: var(--pct, 0%); border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  box-shadow: 0 0 10px rgba(0, 224, 184, .5);
  animation: growIn 1s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes growIn { from { width: 0; } }
.progress-caption { font-size: 11px; margin: 0; }

/* copy-to-clipboard */
.copy-row { display: inline-flex; align-items: center; gap: 8px; }
.copy-btn {
  border: 1px solid var(--border); background: var(--surface2); color: var(--muted);
  width: 24px; height: 24px; line-height: 1; border-radius: 6px; font-size: 13px;
  padding: 0; display: inline-grid; place-items: center; cursor: none;
}
@media (hover: none), (pointer: coarse) { .copy-btn { cursor: pointer; } }
.copy-btn:hover { color: var(--accent); border-color: var(--border-bright); }
.copy-btn.copied { color: var(--accent); border-color: var(--accent); }

/* toasts */
.toast-stack {
  position: fixed; right: 20px; bottom: 20px; z-index: 10000;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
}
.toast {
  background: var(--surface2); border: 1px solid var(--border-bright); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .6);
  animation: toastIn .25s ease both;
}
.toast.leaving { animation: toastOut .2s ease both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.97); } }

/* download button loading spinner */
.btn-spinner {
  display: none; width: 14px; height: 14px; margin-left: 8px;
  border: 2px solid rgba(4, 34, 29, .35); border-top-color: #04221d; border-radius: 50%;
  vertical-align: -2px;
}
.download-link.loading .btn-spinner { display: inline-block; animation: spin .7s linear infinite; }
.download-link.loading .btn-label { opacity: .85; }
@keyframes spin { to { transform: rotate(360deg); } }

/* product picker */
.product-intro { margin-top: -4px; margin-bottom: 16px; max-width: 640px; }
.tile-product { display: flex; flex-direction: column; gap: 6px; }
.tile-product .button { margin-top: 6px; align-self: flex-start; }
.tile-product.disabled { opacity: .6; }
.product-badge {
  align-self: flex-start; font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted);
  margin-bottom: 4px;
}
.tile-product:not(.disabled) .product-badge { color: var(--accent); border-color: var(--accent-dim); background: rgba(0, 224, 184, .08); }
.tile-redeem form { margin-top: 8px; }
.tile-redeem input { text-transform: uppercase; }
.auth-switch { margin-top: 16px; margin-bottom: 0; font-size: 13px; text-align: center; }

/* admin area */
.sidenav-admin { color: var(--accent); }
.admin-subnav { display: flex; gap: 6px; margin: -8px 0 24px; flex-wrap: wrap; }
.admin-subnav a {
  color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600;
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
}
.admin-subnav a:hover { color: var(--text); border-color: var(--border-bright); }
.admin-subnav a.active { color: #04221d; background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; }

.badge { display: inline-block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.badge-unused { color: var(--accent2); border-color: var(--accent2); }
.badge-redeemed { color: var(--ok); border-color: var(--ok); }
.badge-revoked { color: var(--bad); border-color: var(--bad); }
.badge-admin { color: var(--accent); border-color: var(--accent); margin-left: 6px; }

.filter-row { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-row select, .filter-row input[type="text"] { width: auto; margin-top: 0; }

.inline-form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
button.small, .button.small { padding: 6px 12px; font-size: 12px; }

.key-dump { background: #0a0b12; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-size: 13px; margin: 0 0 16px; white-space: pre-wrap; }

.admin-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.admin-actions form { margin: 0; }
.admin-actions button { width: 100%; }
.ban-form { display: flex; flex-direction: column; gap: 8px; }
.ban-form input[type="text"] { margin: 0; }

.sub-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--border); flex-wrap: wrap; }
.sub-row:last-child { border-bottom: none; }
.sub-row-actions { display: flex; gap: 8px; align-items: center; }
.sub-row-actions select { width: auto; margin: 0; padding: 7px 10px; font-size: 13px; }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; word-break: break-all; }
.big { font-size: 26px; font-weight: 700; margin: 0 0 8px; }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.big.ok::before { content: "● "; animation: pulse 1.6s ease-in-out infinite; display: inline-block; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
input {
  display: block; width: 100%; margin-top: 4px; padding: 11px 13px;
  background: #0a0b12; color: var(--text); border: 1px solid var(--border); border-radius: 10px; font-size: 15px;
  transition: border-color .2s, box-shadow .2s;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 224, 184, .18); }

button, .button {
  display: inline-block; padding: 11px 20px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text); font-size: 14px; cursor: none; text-decoration: none;
  transition: border-color .2s, transform .15s, box-shadow .2s, background .2s;
}
@media (hover: none), (pointer: coarse) { button, .button { cursor: pointer; } }
button:hover:not(:disabled), .button:hover { border-color: var(--border-bright); transform: translateY(-1px); }
button:active:not(:disabled), .button:active { transform: translateY(0); }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; color: #04221d; font-weight: 700;
  box-shadow: 0 8px 22px -8px rgba(0, 224, 184, .55);
}
.primary:hover:not(:disabled) { box-shadow: 0 12px 28px -8px rgba(0, 224, 184, .8); }
.danger { background: #2a0f18; border-color: #5c1c2c; color: #ff9ab0; }
.danger:hover:not(:disabled) { box-shadow: 0 10px 22px -10px rgba(255, 85, 112, .5); }
button.link { background: none; border: none; color: var(--accent2); padding: 0; }

.flash { padding: 11px 15px; border-radius: 10px; margin-bottom: 20px; border: 1px solid; animation: fadeUp .4s ease both; }
.flash.ok { background: #0b2a1e; border-color: #1c5c3f; color: #86f0bc; }
.flash.error { background: #2a0f18; border-color: #5c1c2c; color: #ff9ab0; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .06em; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: rgba(0, 224, 184, .06); }

/* ---- auth / login split screen ------------------------------------------ */
.auth-body { margin: 0; }
.auth-shell {
  min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr;
  background:
    radial-gradient(ellipse 60% 50% at 10% 0%, rgba(0, 224, 184, .14), transparent 60%),
    radial-gradient(ellipse 50% 40% at 100% 100%, rgba(0, 179, 255, .12), transparent 60%),
    var(--bg);
}
.auth-hero { padding: 64px; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.auth-hero .brand { padding: 0; margin-bottom: 8px; }
.auth-hero h1 { font-size: 38px; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
.hero-points { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 10px; color: var(--muted); font-size: 14px; }
.hero-points li { display: flex; align-items: baseline; gap: 10px; }
.hero-points li::before { content: "→"; color: var(--accent); font-weight: 700; }

.auth-form-wrap { display: flex; align-items: center; justify-content: center; padding: 40px; background: rgba(255, 255, 255, .02); border-left: 1px solid var(--border); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 30px; }
.auth-card .section-title { margin-bottom: 4px; }
.auth-card .muted { margin-top: 0; margin-bottom: 20px; font-size: 13px; }
.auth-card .primary { width: 100%; margin-top: 4px; }

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { padding: 40px 28px 10px; }
  .auth-form-wrap { border-left: none; padding: 28px; }
}

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { position: relative; height: auto; width: 100%; flex: none; flex-direction: row; align-items: center; gap: 16px; padding: 14px 16px; overflow-x: auto; }
  .brand { padding: 0; margin-right: 8px; }
  .sidenav { flex-direction: row; margin-top: 0; }
  .side-user, .side-logout { display: none; }
  main { padding: 24px 16px 48px; }
}
