/* WhiteBox Key API — vibrant glass panel */
:root {
  --bg: #070512;
  --bg-2: #0b0820;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-2: rgba(255, 255, 255, 0.03);
  --stroke: rgba(255, 255, 255, 0.09);
  --stroke-2: rgba(255, 255, 255, 0.14);
  --text: #eae7ff;
  --muted: #9a94bd;
  --dim: #6f6894;
  --violet: #8b5cf6;
  --violet-2: #a78bfa;
  --cyan: #22d3ee;
  --pink: #f472b6;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #fb7185;
  --radius: 18px;
  --shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.85);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: radial-gradient(1200px 800px at 15% -10%, #1a1040 0%, transparent 60%),
              radial-gradient(1000px 700px at 110% 10%, #0d2b3a 0%, transparent 55%),
              linear-gradient(180deg, var(--bg), var(--bg-2));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.tiny { font-size: 11px; }
.small { font-size: 12px; }
.grad {
  background: linear-gradient(92deg, var(--violet-2), var(--cyan) 45%, var(--pink));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.spacer { flex: 1; }

/* ─────────────── aurora ─────────────── */
.aurora { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.blob {
  position: absolute; border-radius: 50%; filter: blur(90px); opacity: .42;
  animation: drift 26s ease-in-out infinite alternate;
}
.b1 { width: 520px; height: 520px; left: -140px; top: -120px; background: #6d28d9; }
.b2 { width: 440px; height: 440px; right: -100px; top: 40px; background: #0891b2; animation-delay: -6s; }
.b3 { width: 380px; height: 380px; left: 38%; bottom: -160px; background: #be185d; opacity: .3; animation-delay: -12s; }
.b4 { width: 300px; height: 300px; right: 22%; bottom: 10%; background: #0f766e; opacity: .28; animation-delay: -18s; }
.grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 72%);
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(40px, -40px, 0) scale(1.12); }
}

/* ─────────────── shell ─────────────── */
.shell { position: relative; z-index: 1; display: grid; grid-template-columns: 246px 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 22px 16px;
  display: flex; flex-direction: column; gap: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.015));
  border-right: 1px solid var(--stroke);
  backdrop-filter: blur(18px);
}
.logo { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  font-weight: 800; font-size: 16px; color: #0a0618;
  background: linear-gradient(135deg, var(--violet-2), var(--cyan) 60%, var(--green));
  box-shadow: 0 8px 24px -8px rgba(139, 92, 246, .9);
}
.logo-text { font-weight: 700; letter-spacing: .2px; line-height: 1.1; }
.logo-text em { display: block; font-style: normal; font-size: 10px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--muted); margin-top: 3px; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 12px;
  color: var(--muted); font-weight: 500; transition: .18s ease; border: 1px solid transparent;
}
.nav-item .ico { width: 18px; text-align: center; opacity: .9; font-size: 14px; }
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.045); }
.nav-item.active {
  color: #fff; background: linear-gradient(100deg, rgba(139,92,246,.26), rgba(34,211,238,.12));
  border-color: rgba(139,92,246,.45);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 10px 26px -18px var(--violet);
}

.side-card {
  margin-top: auto; padding: 14px; border-radius: 14px;
  background: var(--panel-2); border: 1px solid var(--stroke);
}
.side-card-title { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--dim); margin-bottom: 8px; }
.side-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ─────────────── main ─────────────── */
.main { padding: 26px 30px 60px; min-width: 0; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.topbar h2 { margin: 0 0 4px; font-size: 23px; letter-spacing: -.4px; }
.topbar p { margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.view { animation: rise .35s cubic-bezier(.2,.7,.3,1); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ─────────────── cards / grid ─────────────── */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.02));
  border: 1px solid var(--stroke); border-radius: var(--radius);
  box-shadow: var(--shadow); backdrop-filter: blur(14px); position: relative; overflow: hidden;
}
.card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent);
  opacity: .5;
}
.card.pad { padding: 18px 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: .1px; }
.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; margin-bottom: 18px; }
.grid-2 > .card { min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 18px; }
@media (max-width: 1080px) { .grid-2 { grid-template-columns: 1fr; } }

/* ─────────────── kpis ─────────────── */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
@media (max-width: 1080px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi {
  position: relative; padding: 16px 16px 14px; border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.02));
  border: 1px solid var(--stroke); overflow: hidden; min-height: 108px;
}
.kpi::after {
  content: ""; position: absolute; right: -40px; top: -50px; width: 130px; height: 130px;
  border-radius: 50%; filter: blur(34px); opacity: .5; background: var(--k-color, var(--violet));
}
.kpi .k-label { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.kpi .k-value { font-size: 30px; font-weight: 700; letter-spacing: -1px; margin: 8px 0 2px; }
.kpi .k-value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.kpi .k-foot { font-size: 11px; color: var(--dim); display: flex; align-items: center; gap: 6px; }
.kpi .spark { position: absolute; right: 12px; bottom: 10px; width: 74px; height: 30px; opacity: .85; }

/* ─────────────── charts ─────────────── */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding-top: 6px; }
.bars .bar {
  flex: 1; min-height: 3px; border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, var(--cyan), var(--violet) 85%);
  opacity: .78; transition: .25s ease; position: relative;
}
.bars .bar:hover { opacity: 1; transform: translateY(-2px); }
.bars .bar.zero { background: rgba(255,255,255,.08); }
.axis { display: flex; justify-content: space-between; color: var(--dim); font-size: 10px; margin-top: 8px; letter-spacing: .06em; }

.donut-wrap { display: flex; align-items: center; justify-content: center; position: relative; padding: 6px 0 10px; }
.donut { width: 170px; height: 170px; transform: rotate(-90deg); }
.donut circle { fill: none; stroke-width: 11; stroke-linecap: round; }
.donut-bg { stroke: rgba(255,255,255,.07); }
.donut-fg {
  stroke: url(#g); stroke: var(--green);
  stroke-dasharray: 0 289; transition: stroke-dasharray .7s ease;
  filter: drop-shadow(0 0 10px rgba(52,211,153,.55));
}
.donut-label { position: absolute; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.donut-label b { font-size: 30px; letter-spacing: -1px; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; border-top: 1px solid var(--stroke); padding-top: 12px; }
.mini-stats div { text-align: center; }
.mini-stats b { display: block; font-size: 17px; }
.mini-stats b small { font-size: 10px; color: var(--muted); margin-left: 2px; }
.mini-stats span { font-size: 10px; color: var(--dim); letter-spacing: .04em; }

/* ─────────────── lists ─────────────── */
.top-users, .recent { display: flex; flex-direction: column; gap: 10px; }
.tu-row { display: grid; grid-template-columns: 26px 1fr 90px 44px; align-items: center; gap: 10px; }
.tu-bar { height: 7px; border-radius: 6px; background: rgba(255,255,255,.07); overflow: hidden; }
.tu-bar i { display: block; height: 100%; border-radius: 6px;
  background: linear-gradient(90deg, var(--violet), var(--pink)); }
.recent-item { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed rgba(255,255,255,.06); }
.recent-item:last-child { border-bottom: 0; }

.avatar {
  width: 26px; height: 26px; border-radius: 9px; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #0b0618;
  background: linear-gradient(135deg, var(--violet-2), var(--cyan));
}

/* ─────────────── pills / chips / buttons ─────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px;
  border-radius: 999px; font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,.05); border: 1px solid var(--stroke);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); box-shadow: 0 0 10px currentColor; }
.pill.ok { color: #b8f7dd; border-color: rgba(52,211,153,.45); background: rgba(52,211,153,.12); }
.pill.ok .dot { background: var(--green); }
.pill.warn { color: #ffe8b0; border-color: rgba(251,191,36,.45); background: rgba(251,191,36,.12); }
.pill.warn .dot { background: var(--amber); }
.pill.bad { color: #ffd0d8; border-color: rgba(251,113,133,.45); background: rgba(251,113,133,.12); }
.pill.bad .dot { background: var(--red); }
.pill.mock { color: #d9d0ff; border-color: rgba(139,92,246,.5); background: rgba(139,92,246,.16); }
.pill.mock .dot { background: var(--violet-2); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 9px;
  font-size: 11px; color: var(--muted); background: rgba(255,255,255,.045);
  border: 1px solid var(--stroke);
}
.chips { display: flex; gap: 8px; }
.chip-btn {
  padding: 7px 12px; border-radius: 10px; font-size: 12px; cursor: pointer;
  color: var(--muted); background: rgba(255,255,255,.04); border: 1px solid var(--stroke);
  transition: .18s;
}
.chip-btn:hover { color: var(--text); }
.chip-btn.active { color: #fff; background: rgba(139,92,246,.22); border-color: rgba(139,92,246,.5); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 14px; border-radius: 11px; font-size: 13px; font-weight: 600;
  color: var(--text); background: rgba(255,255,255,.06); border: 1px solid var(--stroke-2);
  cursor: pointer; transition: .18s ease; font-family: inherit;
}
.btn:hover { background: rgba(255,255,255,.1); transform: translateY(-1px); }
.btn:active { transform: none; }
.btn.primary {
  background: linear-gradient(120deg, var(--violet), #6d28d9 55%, var(--cyan));
  border-color: transparent; color: #fff;
  box-shadow: 0 14px 30px -16px rgba(139,92,246,.95);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 5px 9px; font-size: 11px; border-radius: 8px; }
.btn.danger { color: #ffd0d8; border-color: rgba(251,113,133,.4); background: rgba(251,113,133,.1); }
.btn.wide { width: 100%; padding: 11px 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ─────────────── forms ─────────────── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px; }
.field > span { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.input, .field input, .field select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 11px; color: var(--text);
  background: rgba(8,6,20,.55); border: 1px solid var(--stroke); outline: none;
  font-size: 13px; font-family: inherit; transition: .18s;
}
.field input:focus, .field select:focus, .input:focus {
  border-color: rgba(139,92,246,.7); box-shadow: 0 0 0 3px rgba(139,92,246,.16);
}
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.toolbar .input { max-width: 360px; }

/* ─────────────── tables ─────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 10px; letter-spacing: .13em; text-transform: uppercase;
  color: var(--dim); font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--stroke);
  white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,.05); vertical-align: middle; }
.table tbody tr { transition: .15s; }
.table tbody tr:hover { background: rgba(255,255,255,.035); }
.table tbody tr:last-child td { border-bottom: 0; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell b { display: block; font-size: 13px; }
.keycell { display: flex; align-items: center; gap: 6px; }
.mono-cell { font-family: var(--mono); font-size: 11.5px; color: #cfc8ff; }
.trunc { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }
.copy {
  border: 1px solid var(--stroke); background: rgba(255,255,255,.05); color: var(--muted);
  border-radius: 7px; padding: 2px 6px; font-size: 10px; cursor: pointer; transition: .15s;
}
.copy:hover { color: #fff; border-color: var(--violet-2); background: rgba(139,92,246,.2); }
.empty { padding: 34px; text-align: center; color: var(--dim); font-size: 13px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.kidkey { display: flex; flex-direction: column; gap: 2px; }
.kidkey span:first-child { color: var(--cyan); }

/* ─────────────── misc blocks ─────────────── */
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; margin: 0; font-size: 12px; }
.kv dt { color: var(--dim); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 11.5px; word-break: break-all; }
.code {
  font-family: var(--mono); font-size: 11.5px; line-height: 1.55; color: #cfc8ff;
  background: rgba(6,4,16,.7); border: 1px solid var(--stroke); border-radius: 12px;
  padding: 12px; overflow: auto; margin: 10px 0 0; white-space: pre-wrap; word-break: break-word;
}
.hint { font-size: 12px; color: var(--dim); text-align: center; margin: 14px 0 0; }
.hint code { color: var(--violet-2); font-family: var(--mono); }
.link { color: var(--cyan); transition: .15s; }
.link:hover { color: #a5f3fc; text-decoration: underline; }

/* ─────────────── login ─────────────── */
.login-wrap { position: relative; z-index: 2; min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; padding: 32px 28px 26px; text-align: left; }
.login-card .logo.big { justify-content: center; margin-bottom: 14px; }
.login-card .logo-mark { width: 46px; height: 46px; border-radius: 14px; font-size: 21px; }
.login-card h1 { margin: 0 0 6px; font-size: 22px; text-align: center; letter-spacing: -.4px; }
.login-card > p { text-align: center; margin: 0 0 22px; font-size: 12px; }

/* ─────────────── toasts / modal ─────────────── */
.toasts { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 60; }
.toast {
  min-width: 240px; max-width: 380px; padding: 12px 14px; border-radius: 12px; font-size: 12.5px;
  background: rgba(20,16,40,.94); border: 1px solid var(--stroke-2);
  box-shadow: 0 18px 40px -20px #000; backdrop-filter: blur(12px);
  animation: slideIn .25s ease; display: flex; gap: 9px; align-items: flex-start;
}
.toast.ok { border-color: rgba(52,211,153,.5); }
.toast.err { border-color: rgba(251,113,133,.55); }
.toast .t-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; background: var(--violet-2); flex: 0 0 auto; }
.toast.ok .t-dot { background: var(--green); }
.toast.err .t-dot { background: var(--red); }
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

.modal-back { position: fixed; inset: 0; background: rgba(4,2,12,.66); backdrop-filter: blur(6px);
  display: grid; place-items: center; z-index: 50; padding: 20px; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { width: 100%; max-width: 560px; padding: 22px; }
.modal h3 { margin: 0 0 4px; font-size: 17px; }
.modal .sub { margin: 0 0 18px; font-size: 12px; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* per-user stats modal */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stat-grid div { padding: 10px 8px; border-radius: 11px; background: rgba(255,255,255,.045);
  border: 1px solid var(--stroke); text-align: center; }
.stat-grid b { display: block; font-size: 19px; letter-spacing: -.5px; }
.stat-grid span { font-size: 10px; color: var(--dim); }
.mini-bars { display: flex; align-items: flex-end; gap: 2px; height: 46px; }
.mini-bars i { flex: 1; min-height: 3px; border-radius: 2px;
  background: linear-gradient(180deg, var(--cyan), var(--violet)); opacity: .82; }
.uk-list { display: flex; flex-direction: column; gap: 6px; max-height: 250px; overflow: auto; }
.uk-row { display: grid; grid-template-columns: 1.4fr 1fr 54px 60px 34px; align-items: center;
  gap: 8px; padding: 7px 9px; border-radius: 10px; background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.05); }
.uk-row:hover { background: rgba(255,255,255,.055); }

/* srollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* engine banner */
.banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 0 18px; padding: 12px 16px;
  border-radius: 14px; border: 1px solid var(--stroke-2);
  background: var(--panel); font-size: 13px;
}
.banner strong { font-weight: 650; letter-spacing: .2px; }
.banner span { color: var(--muted); }
.banner.warn {
  border-color: rgba(251,191,36,.45);
  background: linear-gradient(90deg, rgba(251,191,36,.14), rgba(251,191,36,.05));
}
.banner.warn strong { color: var(--amber); }
.banner.bad {
  border-color: rgba(251,113,133,.45);
  background: linear-gradient(90deg, rgba(251,113,133,.16), rgba(251,113,133,.05));
}
.banner.bad strong { color: var(--red); }

/* key cache: several kid:key pairs per row */
.kidkey-list { display: flex; flex-direction: column; gap: 8px; }
.kidkey-list .kidkey { display: grid; grid-template-columns: 1fr auto; gap: 0 6px; align-items: center; }
.kidkey-list .kidkey span:first-child { grid-column: 1; color: var(--cyan); }
.kidkey-list .kidkey span:nth-child(2) { grid-column: 1; color: var(--text-dim); }
.kidkey-list .kidkey .copy { grid-column: 2; grid-row: 1 / span 2; }
