:root {
  --bg: #04060c;
  --glass: rgba(14, 20, 36, 0.55);
  --border: rgba(255, 255, 255, 0.10);
  --text: #e8ecf6;
  --muted: #8a94ad;
  --brand: #0059ff;
  --accent: #5c96ff;
  --red: #ff5468;
  --green: #3dd18c;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  font: 14px/1.5 "Segoe UI", Inter, system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 10% 10%, rgba(0, 89, 255, 0.22), transparent 60%),
    radial-gradient(700px 400px at 95% 90%, rgba(0, 130, 255, 0.14), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

main { max-width: 1040px; margin: 0 auto; padding: 24px 16px 48px; }
.center { min-height: 100vh; display: grid; place-items: center; }

.glass {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.card { padding: 20px; margin-bottom: 16px; }
.login-card { width: min(360px, 100%); display: grid; gap: 10px; text-align: center; }
.login-card label { text-align: left; color: var(--muted); font-size: 12px; }

.brand { margin: 0; font-size: 34px; letter-spacing: 0.5px; font-weight: 800; }
.brand span { color: var(--brand); }
.brand.small { font-size: 20px; }
.brand em { font-style: normal; font-weight: 500; color: var(--muted); font-size: 14px; margin-left: 6px; }
h2 { margin: 0 0 4px; font-size: 16px; }
.muted { color: var(--muted); margin: 0 0 12px; }
.error { color: var(--red); min-height: 1.5em; margin: 0; font-size: 13px; }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
textarea { font-family: Consolas, "Cascadia Mono", monospace; resize: vertical; margin: 12px 0 8px; }

button {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  white-space: nowrap;
}
button.primary { background: var(--brand); color: #fff; border-color: rgba(255, 255, 255, 0.2); font-weight: 600; }
button.primary:hover { filter: brightness(1.15); }
button.ghost { background: rgba(255, 255, 255, 0.05); border-color: var(--border); }
button.ghost:hover { border-color: var(--accent); }
button.danger { background: transparent; border-color: rgba(255, 84, 104, 0.4); color: var(--red); padding: 5px 10px; font-size: 12px; }
button.small { padding: 5px 10px; font-size: 12px; }
button:disabled { opacity: 0.5; cursor: default; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); }

a.button {
  display: block; text-decoration: none; text-align: center;
  border-radius: 8px; padding: 11px 16px; font-weight: 600; margin-top: 6px;
}
a.discord { background: #5865f2; color: #fff; border: 1px solid rgba(255, 255, 255, 0.2); }
a.discord:hover { filter: brightness(1.1); }
/* segmented filter (Unused / Used / Revoked / All) */
.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border); flex-wrap: wrap; }
.seg button { background: transparent; color: var(--muted); padding: 6px 14px; font-size: 13px; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--brand); color: #fff; font-weight: 600; }

/* Updates tab */
.drop {
  display: grid; place-items: center; gap: 4px; text-align: center; cursor: pointer;
  padding: 34px 16px; border: 2px dashed rgba(92, 150, 255, 0.35); border-radius: 12px;
  background: rgba(0, 89, 255, 0.05); transition: background 0.15s, border-color 0.15s;
}
.drop:hover, .drop:focus-visible, .drop.over { border-color: var(--accent); background: rgba(0, 89, 255, 0.14); outline: none; }
.drop b { font-size: 15px; }
.drop span { color: var(--muted); font-size: 13px; }
.file-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 16px 0 8px; }
.file-info > div { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; min-width: 0; }
.file-info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted-label { color: var(--muted); font-size: 12px; }
label.stack { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
label.stack textarea { font-family: inherit; margin: 0; color: var(--text); }
label.check { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0; cursor: pointer; color: var(--muted); }
label.check input { width: auto; margin-top: 3px; accent-color: var(--brand); }
label.check b { color: var(--text); font-weight: 600; }
.progress { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.07); overflow: hidden; margin: 4px 0 14px; }
.progress div { height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--accent)); transition: width 0.2s; }
select option { background: #0e1424; color: var(--text); }

.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.row label input { width: 110px; }
.row .grow { flex: 1; min-width: 180px; }
.row .grow input { width: 100%; }
.row select, .row input[type="search"] { max-width: 260px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { padding: 14px 16px; }
.stat b { display: block; font-size: 24px; }
.stat span { color: var(--muted); font-size: 12px; }

.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tab { background: transparent; border-color: var(--border); color: var(--muted); }
.tab.active { background: rgba(0, 89, 255, 0.18); border-color: var(--brand); color: var(--text); }

.table-wrap { overflow-x: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px; border-bottom: 1px solid var(--border); }
td { padding: 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); vertical-align: middle; }
td code { font-family: Consolas, "Cascadia Mono", monospace; white-space: nowrap; }
td.actions { text-align: right; white-space: nowrap; }
td.actions button + button { margin-left: 6px; }
.empty { color: var(--muted); text-align: center; padding: 20px; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; }
.pill.ok { background: rgba(61, 209, 140, 0.15); color: var(--green); }
.pill.bad { background: rgba(255, 84, 104, 0.15); color: var(--red); }
.pill.dim { background: rgba(255, 255, 255, 0.06); color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: rgba(10, 14, 26, 0.92); border: 1px solid var(--border);
  padding: 10px 18px; border-radius: 99px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}
.toast.bad { border-color: rgba(255, 84, 104, 0.5); }

@media (max-width: 600px) {
  .brand { font-size: 28px; }
  .row label input { width: 100%; }
  .row label { flex: 1; }
}

a.button-link {
  display: inline-block; margin-left: 6px; padding: 5px 10px; font-size: 12px; border-radius: 8px;
  color: var(--text); text-decoration: none; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border);
}
a.button-link:hover { border-color: var(--accent); }
td.actions > * + * { margin-left: 6px; }
.pill.tag { margin-left: 8px; }
td.nowrap { white-space: nowrap; }
.notes { color: var(--muted); font-size: 12px; margin-top: 2px; max-width: 320px; white-space: pre-wrap; }

/* ---- 1.4: timed keys, user dashboard, changelog, dialogs ---- */
:root { --amber: #ffb547; }
.pill.warn { background: rgba(255, 181, 71, 0.15); color: var(--amber); }
.row.between { justify-content: space-between; align-items: center; }
.row label select { width: auto; min-width: 120px; }
.inline { display: flex; gap: 6px; }
.inline input { width: 80px; }
.inline select { width: auto; }
.small-note { font-size: 12px; margin: 10px 0 0; }

.stat.bad b { color: var(--red); }
.stat.warn b { color: var(--amber); }

tr.clickable { cursor: pointer; }
tr.clickable:hover td, tr.clickable:focus-visible td { background: rgba(0, 89, 255, 0.08); }
tr.clickable:focus-visible { outline: none; }
td.uname { font-weight: 600; white-space: nowrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 8px; box-shadow: 0 0 8px var(--green); vertical-align: middle; }
a.user-link { color: var(--accent); text-decoration: none; font-weight: 600; }
a.user-link:hover { text-decoration: underline; }
.used { white-space: nowrap; }
td.detail { color: var(--muted); font-size: 12px; min-width: 160px; }

/* user dashboard */
.user-head { margin-bottom: 16px; align-items: flex-end; }
.uv-name { font-size: 24px; margin: 10px 0 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.uv-name .pill { font-size: 12px; font-weight: 500; }
#uv-pills { display: inline-flex; gap: 6px; }
.uv-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.uv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.uv-grid > .card { margin-bottom: 16px; min-width: 0; }
#uv-stats .stat b { font-size: 20px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 12px 0 0; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
#uv-note { font-family: inherit; margin: 0 0 8px; }

/* changelog */
.stack-form { display: grid; gap: 12px; }
.stack-form textarea { margin: 0; font-family: inherit; }
.cl-entry h2 { margin: 0; }
.cl-entry ul { margin: 10px 0 0; padding-left: 20px; color: var(--text); }
.cl-entry li { margin: 2px 0; }
.cl-tools { display: flex; gap: 6px; }
.cl-tools button + button { margin-left: 0; }

/* dialogs */
dialog {
  color: var(--text); padding: 22px; width: min(440px, calc(100vw - 32px));
  background: rgba(12, 17, 30, 0.97); border: 1px solid var(--border); border-radius: var(--radius);
}
dialog::backdrop { background: rgba(2, 4, 10, 0.7); backdrop-filter: blur(4px); }
dialog form { display: grid; gap: 12px; }
dialog h2 { margin: 0; }
dialog .muted { margin: 0; }
.big-code {
  display: block; text-align: center; font: 600 20px/1.4 Consolas, "Cascadia Mono", monospace; letter-spacing: 1px;
  padding: 14px; border-radius: 10px; background: rgba(0, 89, 255, 0.12); border: 1px solid rgba(92, 150, 255, 0.35);
  user-select: all; overflow-wrap: anywhere;
}

@media (max-width: 600px) {
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dd { margin-bottom: 8px; }
  .uv-grid { grid-template-columns: 1fr; }
  .row.between { align-items: stretch; }
}
td .pill { white-space: nowrap; }

/* Website tab */
.st-bar { align-items: center; margin-top: 14px; }
.st-bar .seg { flex: 1; min-width: 0; flex-wrap: wrap; }
.st-open { padding: 8px 12px; border-radius: 8px; text-decoration: none; }
.st-card { display: grid; gap: 18px; }
.st-item { display: grid; gap: 6px; }
.st-head { display: flex; align-items: center; gap: 10px; }
.st-head label { flex: 1; color: var(--text); font-size: 13px; font-weight: 600; }
.st-state { font-size: 12px; color: var(--muted); }
.st-state.unsaved { color: #ffab3d; }
.st-item textarea { margin: 0; font-family: inherit; }
.st-item input, .st-item textarea { width: 100%; }

/* Orders tab: bot status */
.debug { display: grid; grid-template-columns: 140px 1fr; gap: 6px 16px; margin: 12px 0 0; font-family: Consolas, "Cascadia Mono", monospace; font-size: 12.5px; }
.debug dt { color: var(--muted); }
.debug dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.debug dd.ok { color: #3ddc97; }
.debug dd.bad { color: #ff5468; }
.debug dd.warn { color: var(--amber); }
.debug dd.dim { color: var(--muted); }
.debug code { font-size: 12px; }
button.tiny { padding: 1px 8px; font-size: 11px; margin-left: 6px; }


/* ---- Sign-in screens (admin page and Records) ---- */
@font-face { font-family: Jersey; src: url("/admin/assets/jersey-25.woff2") format("woff2"); font-weight: 400; font-display: swap; }
.signin { position: relative; isolation: isolate; overflow: hidden; max-width: none; min-height: 100vh; margin: 0; padding: 24px 16px; display: grid; place-items: center; }
.signin::before { content: ""; position: absolute; z-index: -2; inset: -6%; background: linear-gradient(#050b1a8c, #03050ad9), url("/admin/assets/space-background.jpg") center / cover no-repeat; animation: signin-drift 40s ease-in-out infinite alternate; }
.signin::after { content: ""; position: absolute; z-index: -1; left: 50%; top: 50%; width: min(820px, 130vw); aspect-ratio: 3 / 1; translate: -50% -56%; rotate: -14deg; border: 1px solid #4d86ff4d; border-radius: 50%; box-shadow: 0 0 44px #1255e526, inset 0 0 34px #0e4ade1f; pointer-events: none; }
.signin-card { width: min(410px, 100%); padding: 36px 30px 26px; display: grid; gap: 12px; justify-items: center; text-align: center; border: 1px solid #6f98e045; border-radius: 22px; background: linear-gradient(160deg, #17243dde, #0a1220eb); backdrop-filter: blur(16px); box-shadow: inset 0 1px #ffffff1c, 0 34px 90px -34px #000, 0 0 0 1px #0206118c; animation: signin-arrive .42s cubic-bezier(.2, .76, .25, 1) backwards; }
.signin-emblem { width: 76px; height: auto; filter: drop-shadow(0 6px 20px #2a6cff8c); animation: signin-float 6s ease-in-out infinite; }
.signin-card .brand { font: 400 48px/1 Jersey, "Segoe UI", sans-serif; letter-spacing: .01em; }
.signin-card .brand span { color: #3d7dff; text-shadow: 0 0 24px #0653fc59; }
.signin-kicker { margin: 0; padding: 3px 13px; border: 1px solid #7fa6e852; border-radius: 99px; background: #0f1d36; color: #a9c8ff; font: 600 11px/1.7 ui-monospace, Consolas, monospace; letter-spacing: .15em; text-transform: uppercase; }
.signin-copy { margin: 4px 0 8px; max-width: 310px; color: #b6c5dc; font-size: 14px; line-height: 1.55; }
.signin-card a.button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 48px; padding: 12px 18px; border-radius: 12px; font-size: 15px; font-weight: 600; text-decoration: none; transition: translate .16s ease, filter .16s ease, box-shadow .16s ease; }
.signin-card a.discord { color: #fff; background: linear-gradient(#6b77ff, #4854df); border: 1px solid #ffffff3d; box-shadow: inset 0 1px #ffffff45, 0 4px #2a339c, 0 14px 30px -12px #5865f2b3; }
.signin-card a.signin-open { color: #fff; background: linear-gradient(#2876ff, #054be5); border: 1px solid #739bff5c; box-shadow: inset 0 1px #ffffff38, 0 4px #002c95, 0 14px 30px -12px #0653fcb3; }
.signin-card a.button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.signin-card a.button:hover { translate: 0 -2px; filter: brightness(1.08); }
.signin-card a.button:active { translate: 0 2px; box-shadow: inset 0 1px #ffffff45, 0 1px #2a339c; }
.signin-card a.button:focus-visible, .signin-card button:focus-visible { outline: 2px solid #8de5ff; outline-offset: 3px; }
.signin-card .error { width: 100%; min-height: 0; }
.signin-card .error:not(:empty) { padding: 10px 12px; border: 1px solid #ff54685c; border-radius: 10px; background: #ff54681c; color: #ffb6bf; text-align: left; }
.signin-note { margin: 4px 0 0; color: #8494b0; font-size: 12px; line-height: 1.5; }
.signin-note a { color: #a7ceff; }
@keyframes signin-drift { from { transform: translate3d(-1%, 0, 0) scale(1.02); } to { transform: translate3d(1.5%, 1.5%, 0) scale(1.06); } }
@keyframes signin-arrive { from { opacity: 0; translate: 0 14px; } }
@keyframes signin-float { 50% { translate: 0 -6px; } }
@media (prefers-reduced-motion: reduce) { .signin::before, .signin-card, .signin-emblem { animation: none; } .signin-card a.button { transition: none; } }
