:root {
  color-scheme: dark;
  --bg: #05070e;
  --surface: rgba(14, 18, 30, 0.88);
  --surface-strong: #0d111c;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(214, 197, 161, 0.32);
  --text: #f8fafc;
  --muted: rgba(226, 232, 240, 0.54);
  --gold: #d6c5a1;
  --gold-bright: #f1dfb7;
  --green: #86efac;
  --red: #fca5a5;
  --violet: #a5b4fc;
  --radius: 20px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -10%, rgba(99, 102, 241, 0.16), transparent 34rem),
    radial-gradient(circle at 8% 72%, rgba(214, 197, 161, 0.07), transparent 30rem),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    radial-gradient(circle at 14% 21%, rgba(248, 250, 252, 0.42) 0 1px, transparent 1.5px),
    radial-gradient(circle at 72% 16%, rgba(214, 197, 161, 0.3) 0 1px, transparent 1.5px),
    radial-gradient(circle at 84% 64%, rgba(165, 180, 252, 0.28) 0 1px, transparent 1.5px),
    radial-gradient(circle at 32% 78%, rgba(248, 250, 252, 0.22) 0 1px, transparent 1.5px);
  background-size: 340px 290px, 470px 390px, 520px 430px, 410px 360px;
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand strong { display: block; font-size: 14px; letter-spacing: 0.16em; }
.brand small { display: block; margin-top: 3px; color: var(--muted); font: 9px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.2em; }

.brand-mark {
  position: relative;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(214, 197, 161, 0.42);
  border-radius: 50%;
  box-shadow: 0 0 24px rgba(214, 197, 161, 0.16);
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}

.brand-mark::before { width: 18px; height: 18px; background: #f8fafc; }
.brand-mark::after { width: 18px; height: 18px; left: 22px; background: #0b0e18; border-left: 1px solid rgba(214, 197, 161, 0.7); }
.brand-mark span { width: 1px; height: 24px; background: linear-gradient(transparent, var(--gold), transparent); opacity: 0.7; }

main { flex: 1; padding: 42px 0 56px; }

.login-view { min-height: calc(100vh - 210px); display: grid; place-items: center; padding: 24px 0; }
.login-card {
  width: min(460px, 100%);
  padding: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(19, 23, 37, 0.96), rgba(8, 11, 19, 0.96));
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.48), inset 0 1px rgba(255, 255, 255, 0.04);
}

.login-card h1 { margin: 10px 0 10px; font-size: clamp(25px, 4vw, 34px); font-weight: 400; letter-spacing: 0.06em; }
.login-card > p { margin: 0 0 28px; color: var(--muted); font-size: 13px; line-height: 1.8; }

.eyebrow { color: var(--gold); font: 10px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.22em; }
.success-colour { color: var(--green); }

.stack-form { display: grid; gap: 10px; }
.stack-form label, .form-grid label { color: rgba(248, 250, 252, 0.72); font-size: 12px; letter-spacing: 0.05em; }
.inline-field { display: flex; gap: 10px; }
.inline-field input { flex: 1; min-width: 0; }
.field-hint { margin: 6px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }

input, select {
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  padding: 10px 13px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  background: rgba(4, 7, 13, 0.78);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input::placeholder { color: rgba(255, 255, 255, 0.26); }
input:focus, select:focus { border-color: rgba(214, 197, 161, 0.72); box-shadow: 0 0 0 3px rgba(214, 197, 161, 0.1); background: rgba(7, 10, 18, 0.94); }

.primary-button, .secondary-button, .ghost-button, .text-button {
  min-height: 42px;
  padding: 9px 16px;
  border-radius: 11px;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, opacity 150ms ease;
}

.primary-button { color: #0b0d12; border: 1px solid var(--gold-bright); background: linear-gradient(135deg, #f2e3c0, #c8b486); font-weight: 700; }
.secondary-button { color: var(--gold-bright); border: 1px solid rgba(214, 197, 161, 0.4); background: rgba(214, 197, 161, 0.08); }
.ghost-button { color: rgba(248, 250, 252, 0.7); border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); }
.text-button { min-height: auto; padding: 4px 0; color: var(--gold); border: 0; background: transparent; font-size: 12px; }
.primary-button:hover, .secondary-button:hover, .ghost-button:hover { transform: translateY(-1px); border-color: rgba(214, 197, 161, 0.6); }
.primary-button:disabled, .secondary-button:disabled, .ghost-button:disabled { cursor: wait; opacity: 0.5; transform: none; }

.page-heading, .section-heading-row, .panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.page-heading { margin-bottom: 28px; }
.page-heading h1 { margin: 7px 0 6px; font-size: clamp(26px, 4vw, 38px); font-weight: 400; letter-spacing: 0.05em; }
.page-heading p, .panel-description { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }

.control-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.panel {
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.035), 0 16px 48px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(18px);
}

.panel-heading { margin-bottom: 22px; align-items: center; }
.panel-heading > div:first-child { display: flex; align-items: center; gap: 11px; }
.panel-heading h2, .section-heading-row h2 { margin: 0; font-size: 17px; font-weight: 500; letter-spacing: 0.05em; }
.step-number { display: inline-grid; width: 27px; height: 27px; place-items: center; border: 1px solid rgba(214, 197, 161, 0.26); border-radius: 50%; color: var(--gold); font: 10px ui-monospace, monospace; }
.panel-note { color: rgba(248, 250, 252, 0.36); font: 10px ui-monospace, monospace; letter-spacing: 0.06em; text-align: right; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.span-two { grid-column: span 2; }
.label-optional { color: rgba(248, 250, 252, 0.3); font-size: 10px; }

.generated-panel { margin-top: 18px; border-color: rgba(134, 239, 172, 0.24); }
.generated-heading { align-items: flex-start; }
.generated-heading > div:first-child { display: block; }
.generated-heading h2 { margin: 5px 0 7px; }
.button-row { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.warning-note { margin-bottom: 16px; padding: 11px 13px; color: #fde68a; border: 1px solid rgba(253, 230, 138, 0.2); border-radius: 10px; background: rgba(253, 230, 138, 0.055); font-size: 11px; line-height: 1.6; }
.code-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; max-height: 290px; overflow: auto; padding-right: 4px; }
.code-chip { padding: 10px 12px; color: #fff7dd; border: 1px solid rgba(214, 197, 161, 0.2); border-radius: 9px; background: rgba(214, 197, 161, 0.06); font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.04em; }

.summary-section { margin: 30px 0 18px; }
.section-heading-row { align-items: flex-end; margin-bottom: 14px; }
.section-heading-row h2 { margin-top: 5px; }
.summary-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.stat-card { min-width: 0; padding: 17px; border: 1px solid var(--line); border-radius: 14px; background: rgba(12, 16, 27, 0.78); }
.stat-card span { display: block; color: var(--muted); font-size: 11px; }
.stat-card strong { display: block; margin-top: 7px; font: 25px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.stat-unused strong { color: var(--gold-bright); }
.stat-used strong { color: var(--green); }
.stat-expired strong { color: #fcd34d; }
.stat-revoked strong { color: var(--red); }

.table-panel { padding-bottom: 16px; }
.table-heading-tools { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 12px; }
.table-heading-tools .ghost-button { min-height: 32px; padding: 5px 11px; font-size: 11px; }
.code-availability-note { margin: -8px 0 16px; color: rgba(248, 250, 252, 0.42); font-size: 11px; line-height: 1.7; }
.filter-toolbar { display: grid; gap: 10px; margin: 0 0 14px; }
.filter-group { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.filter-label { min-width: 34px; color: var(--muted); font: 10px ui-monospace, monospace; letter-spacing: 0.08em; }
.filter-chip {
  min-height: 32px;
  padding: 5px 11px;
  color: rgba(248, 250, 252, 0.62);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
  font-size: 11px;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}
.filter-chip:hover { color: var(--text); border-color: rgba(214, 197, 161, 0.4); }
.filter-chip.is-active { color: #101116; border-color: var(--gold-bright); background: var(--gold-bright); font-weight: 700; }
.table-scroll { width: 100%; overflow-x: auto; border: 1px solid rgba(255, 255, 255, 0.06); border-radius: 12px; }
table { width: 100%; min-width: 1080px; border-collapse: collapse; }
th, td { padding: 13px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.055); text-align: left; vertical-align: top; font-size: 11px; }
th { color: rgba(248, 250, 252, 0.42); background: rgba(255, 255, 255, 0.022); font-weight: 500; letter-spacing: 0.06em; white-space: nowrap; }
td { color: rgba(248, 250, 252, 0.74); }
tbody tr:last-child td { border-bottom: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--muted); }
.token-code-row { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.token-code { color: var(--gold-bright); font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.04em; white-space: nowrap; }
.copy-code-button { min-height: 25px; padding: 2px 7px; color: rgba(248, 250, 252, 0.62); border: 1px solid var(--line); border-radius: 7px; background: rgba(255, 255, 255, 0.035); font-size: 9px; }
.copy-code-button:hover { color: var(--gold-bright); border-color: rgba(214, 197, 161, 0.5); }
.code-cell-meta { display: block; margin-top: 5px; color: rgba(226, 232, 240, 0.3); font: 9px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.code-unavailable { color: rgba(248, 250, 252, 0.42); font-size: 10px; }
.status-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 10px; white-space: nowrap; }
.status-chip::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status-unused { color: var(--gold-bright); border-color: rgba(214, 197, 161, 0.24); background: rgba(214, 197, 161, 0.07); }
.status-used { color: var(--green); border-color: rgba(134, 239, 172, 0.2); background: rgba(134, 239, 172, 0.06); }
.status-expired { color: #fcd34d; border-color: rgba(252, 211, 77, 0.2); background: rgba(252, 211, 77, 0.06); }
.status-revoked { color: var(--red); border-color: rgba(252, 165, 165, 0.2); background: rgba(252, 165, 165, 0.06); }
.empty-state { padding: 42px 20px; color: var(--muted); text-align: center; font-size: 12px; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 13px; padding-top: 15px; color: var(--muted); font-size: 11px; }

footer { padding: 22px 0 30px; color: rgba(248, 250, 252, 0.24); border-top: 1px solid rgba(255, 255, 255, 0.05); font: 10px ui-monospace, monospace; letter-spacing: 0.1em; text-align: center; }

.toast { position: fixed; z-index: 20; right: 20px; bottom: 20px; max-width: min(420px, calc(100vw - 40px)); padding: 13px 16px; border: 1px solid var(--line); border-radius: 12px; background: #111624; box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45); font-size: 12px; line-height: 1.6; }
.toast.error { color: #fecaca; border-color: rgba(252, 165, 165, 0.3); }
.toast.success { color: #bbf7d0; border-color: rgba(134, 239, 172, 0.3); }

button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

@media (max-width: 820px) {
  .page-shell { width: min(100% - 24px, 680px); }
  .topbar { padding: 18px 0; }
  main { padding: 30px 0 42px; }
  .control-grid { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .login-card { padding: 26px 20px; }
}

@media (max-width: 560px) {
  .brand small { display: none; }
  .page-heading, .panel-heading, .generated-heading { flex-direction: column; align-items: stretch; }
  .page-heading > button { width: 100%; }
  .button-row { justify-content: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .span-two { grid-column: auto; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card:first-child { grid-column: span 2; }
  .inline-field { flex-direction: column; }
  .inline-field button { width: 100%; }
  .panel { padding: 18px; }
  .filter-label { width: 100%; }
  .table-heading-tools { justify-content: space-between; }
  .pagination { justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
