/* ============================================================
   Madium Key System — design tokens
   Subject: license-key vault for a Roblox script. The accent is a
   brass/gold "key metal" tone against a deep vault-navy background;
   everything else stays quiet so the gold only shows up where a
   status or action actually matters.
   ============================================================ */
:root {
  --bg: #0b0d11;
  --bg-elev: #12151b;
  --bg-elev-2: #171b22;
  --bg-input: #0e1116;
  --border: #232830;
  --border-strong: #2e343f;

  --text: #eef1f4;
  --text-dim: #939cab;
  --text-faint: #5c6472;

  --accent: #cd9a4d;
  --accent-strong: #e3b568;
  --accent-ink: #221a0b;
  --accent-bg: rgba(205, 154, 77, .12);

  --success: #34b573;
  --success-bg: rgba(52, 181, 115, .13);
  --danger: #ef5350;
  --danger-bg: rgba(239, 83, 80, .13);
  --info: #5b8def;
  --info-bg: rgba(91, 141, 239, .13);
  --warn: #e0a83e;
  --warn-bg: rgba(224, 168, 62, .13);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-pill: 999px;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-2: 0 24px 60px rgba(0, 0, 0, .55);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Consolas, monospace;

  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(560px 320px at 12% -10%, rgba(205, 154, 77, .07), transparent 60%),
    radial-gradient(480px 320px at 100% 0%, rgba(91, 141, 239, .05), transparent 55%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; font-weight: 700; }
p { margin: 0; }
::selection { background: var(--accent); color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
  border-radius: 4px;
}

::-webkit-scrollbar { height: 10px; width: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }

.mono { font-family: var(--mono); }
.hide-sm { display: inline; }
.hint { color: var(--text-dim); font-size: 13px; }
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; padding: 3px 9px; border-radius: var(--r-pill);
  background: var(--bg-elev-2); color: var(--text-dim); border: 1px solid var(--border);
  white-space: nowrap;
}

.ic { flex-shrink: 0; }

/* ---------------------------------------------------------
   Buttons
--------------------------------------------------------- */
.btn {
  --h: 42px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h);
  padding: 0 16px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: filter .12s ease, transform .06s ease, background-color .12s ease, border-color .12s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none !important; transform: none; }
.btn-block { width: 100%; }
.btn-sm { --h: 32px; padding: 0 12px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn-xs { --h: 28px; padding: 0 10px; font-size: 12px; border-radius: var(--r-sm); }

.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }

.btn-secondary { background: var(--bg-elev-2); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: #1d222b; }

.btn-outline { background: transparent; color: var(--text-dim); border-color: var(--border-strong); }
.btn-outline:hover:not(:disabled) { color: var(--text); border-color: var(--text-dim); }

.btn-danger { background: var(--danger-bg); color: #ff9d9a; border-color: rgba(239, 83, 80, .35); }
.btn-danger:hover:not(:disabled) { background: rgba(239, 83, 80, .22); }

.btn-ghost { background: transparent; color: var(--text-dim); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--bg-elev-2); }

.icon-btn {
  width: 32px; height: 32px; padding: 0; border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-elev-2); border: 1px solid var(--border-strong); color: var(--text-dim);
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); }
.icon-btn.copied { color: var(--success); border-color: rgba(52, 181, 115, .4); }

/* ---------------------------------------------------------
   Inputs
--------------------------------------------------------- */
.field { text-align: left; margin-bottom: 16px; }
.field label {
  display: block; font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin-bottom: 7px;
}
.input-wrap {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 0 13px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.input-wrap .ic { color: var(--text-faint); }
.input-wrap input, .input-wrap select {
  flex: 1; min-width: 0;
  background: transparent; border: none; outline: none;
  color: var(--text); font: inherit; font-size: 14.5px;
  height: 44px;
}
.input-wrap input::placeholder { color: var(--text-faint); }
.input-wrap .toggle-pass {
  background: none; border: none; color: var(--text-faint); cursor: pointer;
  display: flex; align-items: center; padding: 4px;
}
.input-wrap .toggle-pass:hover { color: var(--text-dim); }

select, input[type=text], input[type=number], input[type=datetime-local], input[type=password] {
  font: inherit;
}

/* compact inputs used inline in admin tables/dialogs */
.field-sm label { font-size: 11px; margin-bottom: 5px; }
.input-sm {
  background: var(--bg-input); border: 1px solid var(--border-strong); color: var(--text);
  border-radius: var(--r-sm); padding: 8px 10px; font-size: 13px; height: 36px;
}
.input-sm:focus-visible { border-color: var(--accent); }

/* ---------------------------------------------------------
   Messages
--------------------------------------------------------- */
.msg {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--r-md);
  font-size: 13.5px; margin-bottom: 18px; text-align: left;
  border: 1px solid transparent;
}
.msg .ic { margin-top: 1px; }
.msg-error { background: var(--danger-bg); border-color: rgba(239, 83, 80, .3); color: #ff9d9a; }
.msg-success { background: var(--success-bg); border-color: rgba(52, 181, 115, .3); color: #8fe3b5; }
.msg-warn { background: var(--warn-bg); border-color: rgba(224, 168, 62, .3); color: #f0c46f; }

/* ---------------------------------------------------------
   Auth pages
--------------------------------------------------------- */
.wrap-center {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
}
.auth-card { width: 100%; max-width: 384px; }
.auth-card.text-center { text-align: center; }

.brand-tile {
  width: 46px; height: 46px; border-radius: 13px;
  background: linear-gradient(155deg, var(--accent-strong), var(--accent) 65%, #a87735);
  color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px;
  margin: 0 auto 20px;
  box-shadow: 0 10px 24px rgba(205, 154, 77, .22);
}

.auth-card h1 { font-size: 21px; margin-bottom: 6px; }
.auth-card p.sub { color: var(--text-dim); font-size: 13.5px; margin-bottom: 26px; }

.auth-form { text-align: left; }
.row-2 { display: flex; gap: 10px; margin-top: 14px; }
.row-2 .btn { flex: 1; }
.auth-switch { margin-top: 22px; font-size: 13.5px; color: var(--text-dim); }
.auth-switch a { color: var(--accent-strong); font-weight: 600; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

/* ---------------------------------------------------------
   Member page shell
--------------------------------------------------------- */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 20px 90px;
}
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 22px; gap: 12px;
}
.topbar h2 { font-size: 21px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.link-quiet {
  color: var(--text-dim); font-size: 13px; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.link-quiet:hover { color: var(--text); }
.link-quiet.accent { color: var(--accent-strong); font-weight: 600; }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-1);
}
.card-flush { padding: 0; overflow: hidden; }
.card-label { font-size: 11.5px; font-weight: 600; letter-spacing: .03em; color: var(--text-faint); text-transform: uppercase; }

.row-between { display: flex; justify-content: space-between; align-items: center; gap: 14px; }

/* balance hero */
.balance-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; }
.balance-value { font-size: 34px; font-weight: 800; letter-spacing: -0.015em; margin: 8px 0 2px; font-family: var(--mono); }
.badge-stack { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: .01em;
  padding: 4px 10px; border-radius: var(--r-pill);
}
.badge-empty   { background: var(--warn-bg); color: var(--warn); }
.badge-active  { background: var(--success-bg); color: var(--success); }
.badge-banned  { background: var(--danger-bg); color: var(--danger); }
.badge-freeze  { background: var(--info-bg); color: var(--info); }
.badge-free    { background: var(--bg-elev-2); color: var(--text-dim); border: 1px solid var(--border-strong); }
.badge-prem    { background: var(--accent-bg); color: var(--accent-strong); }

.divider { height: 1px; background: var(--border); margin: 16px 0; }

.kv-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 11px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px;
}
.kv-row:last-child { border-bottom: none; }
.kv-row .k { color: var(--text-dim); }
.kv-row .v { font-family: var(--mono); text-align: right; }

.key-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 13.5px;
  background: var(--bg-input); border: 1px solid var(--border-strong);
  padding: 6px 6px 6px 12px; border-radius: var(--r-sm);
}

.section-title { font-weight: 700; font-size: 15px; margin-bottom: 3px; }
.section-desc { color: var(--text-dim); font-size: 13px; margin-bottom: 16px; }

/* quest / earn box */
.quest-box {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px;
}
.quest-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.quest-icon {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-bg); color: var(--accent-strong);
}
.quest-name { font-weight: 700; font-size: 14.5px; }
.quest-desc { color: var(--text-dim); font-size: 12.5px; }

.progress-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.progress-track { flex: 1; height: 5px; background: var(--border-strong); border-radius: 6px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); transition: width .35s ease; border-radius: 6px; }
.step-dot {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: var(--accent-ink);
  font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.step-dot.pending { background: var(--bg-elev); color: var(--text-faint); border: 1px solid var(--border-strong); }
.step-num { color: var(--text-faint); font-size: 12px; font-weight: 700; }

/* ---------------------------------------------------------
   Native <dialog> modal
--------------------------------------------------------- */
dialog.modal {
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--bg-elev);
  color: var(--text);
  padding: 0;
  width: 100%; max-width: 400px;
  box-shadow: var(--shadow-2);
  margin: auto;
}
dialog.modal[open] { animation: modal-in .16s ease; }
@keyframes modal-in { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
dialog.modal::backdrop { background: rgba(6, 7, 9, .65); backdrop-filter: blur(2px); }
dialog.modal .modal-inner { padding: 22px; }

.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 2px; }
.modal-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent-strong); }
.modal-title { font-size: 17px; font-weight: 700; margin: 6px 0 5px; }
.modal-desc { color: var(--text-dim); font-size: 13.5px; margin-bottom: 18px; }
.modal-close {
  background: none; border: none; color: var(--text-faint); cursor: pointer;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm); flex-shrink: 0;
}
.modal-close:hover { color: var(--text); background: var(--bg-elev-2); }

/* ---------------------------------------------------------
   Admin: top nav
--------------------------------------------------------- */
.topnav {
  position: sticky; top: 0; z-index: 40;
  background: rgba(11, 13, 17, .82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topnav-in {
  max-width: 1180px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 22px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; font-size: 14.5px; }
.brand small { color: var(--text-faint); font-weight: 600; font-size: 11px; margin-left: 4px; text-transform: uppercase; letter-spacing: .03em; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(155deg, var(--accent-strong), var(--accent) 65%, #a87735);
  color: var(--accent-ink); font-weight: 800; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px; border-radius: var(--r-sm);
  color: var(--text-dim); text-decoration: none; font-size: 13.5px; font-weight: 600;
  white-space: nowrap;
}
.nav a:hover { color: var(--text); background: var(--bg-elev-2); }
.nav a.active { color: var(--accent-ink); background: var(--accent); }
.nav-right { display: flex; align-items: center; gap: 8px; }

.admin { max-width: 1180px; margin: 0 auto; padding: 24px 20px 90px; }

/* ---------------------------------------------------------
   Admin: table
--------------------------------------------------------- */
.table-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-1); }
.table-scroll { overflow-x: auto; }
table.dtable { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 720px; }
table.dtable thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg-elev-2);
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  color: var(--text-faint);
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.dtable td {
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  vertical-align: middle; white-space: nowrap;
}
table.dtable tbody tr:last-child td { border-bottom: none; }
table.dtable tbody tr:hover { background: rgba(255, 255, 255, .015); }
table.dtable td:first-child, table.dtable th:first-child {
  position: sticky; left: 0; background: var(--bg-elev); z-index: 1;
}
table.dtable thead th:first-child { background: var(--bg-elev-2); z-index: 2; }
.cell-primary { font-weight: 600; }
.cell-muted { color: var(--text-faint); }
.cell-code { font-family: var(--mono); font-size: 12.5px; }

.table-toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.search-box { flex: 1; min-width: 220px; max-width: 340px; }
.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  padding: 7px 13px; border-radius: var(--r-pill); font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--border-strong); color: var(--text-dim); text-decoration: none; white-space: nowrap;
}
.pill.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pill:hover:not(.active) { color: var(--text); border-color: var(--text-dim); }

.empty-row td { text-align: center; padding: 48px 20px; color: var(--text-faint); }

/* generate key form */
.gen-form { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.gen-form .field-sm { min-width: 100px; }
.gen-form .field-sm.grow { min-width: 160px; flex: 1; }

/* ---------------------------------------------------------
   Responsive
--------------------------------------------------------- */
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .balance-value { font-size: 28px; }
  .topnav-in { gap: 14px; }
  .nav a span:not(.ic) { display: none; }
  .nav a { padding: 9px; }
  dialog.modal { max-width: calc(100vw - 32px); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
