:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2330;
  --muted: #5d6778;
  --line: #e2e6ec;
  --accent: #2f5bd3;
  --accent-text: #ffffff;
  --danger: #b4232c;
  --error-bg: #fdecec;
  --reveal-bg: #fff8e1;
  --reveal-line: #f0d98a;
  --radius: 8px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1a1f27;
    --text: #e6e9ee;
    --muted: #9aa4b4;
    --line: #2b323d;
    --accent: #6f94ff;
    --accent-text: #0d1220;
    --danger: #ff7a80;
    --error-bg: #3a1c1f;
    --reveal-bg: #2e2812;
    --reveal-line: #6b5a1d;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

[hidden] { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; margin-right: auto; }
.who { color: var(--muted); font-size: 14px; }

main { max-width: 880px; margin: 32px auto; padding: 0 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.card.narrow { max-width: 400px; margin: 48px auto; }

h2 { font-size: 17px; margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
code { font: 13px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; }

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

.balance { text-align: right; }
.balance .label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.balance .value { font-size: 26px; font-weight: 700; }

label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 14px; }
input:not([type=checkbox]):not([type=radio]) {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 9px 11px;
  font: inherit;
  font-weight: 400;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button {
  font: inherit;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.link { border: none; background: none; padding: 4px 0; color: var(--accent); font-weight: 500; }
button.danger { color: var(--danger); }

.tabs { display: flex; gap: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.tabs button { border: none; background: none; padding: 8px 0; border-radius: 0; color: var(--muted); }
.tabs button[aria-selected=true] { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }

.notice.error {
  background: var(--error-bg);
  color: var(--danger);
  padding: 12px 16px;
  border-radius: var(--radius);
}

fieldset { border: none; padding: 0; margin: 0 0 14px; }
legend { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
label.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin: 0 18px 0 0; }

.create-key { padding: 16px 0; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.create-key label { max-width: 360px; }

.reveal {
  background: var(--reveal-bg);
  border: 1px solid var(--reveal-line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
}
.reveal p { margin: 0 0 10px; }
.reveal .key { flex: 1; min-width: 0; overflow-wrap: anywhere; padding: 8px 10px; background: var(--surface); border-radius: 6px; }

table.keys { width: 100%; border-collapse: collapse; font-size: 14px; }
.keys th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 10px 8px; }
.keys td { padding: 10px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.keys tr.inactive td { color: var(--muted); }
.keys td.actions { text-align: right; }
.badge { font-size: 12px; text-transform: capitalize; }

.packs { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0 16px; }
.pack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  min-width: 140px;
}
.pack input { position: absolute; opacity: 0; }
.pack:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.pack-credits { font-weight: 700; }
.pack-price { font-weight: 400; color: var(--muted); }

@media (max-width: 640px) {
  .keys th:nth-child(4), .keys td:nth-child(4), .keys th:nth-child(5), .keys td:nth-child(5) { display: none; }
}
