:root {
  color-scheme: dark;
  --bg: #071012;
  --bg-soft: #0a1518;
  --panel: #0d1c20;
  --panel-strong: #112328;
  --line: #234047;
  --line-soft: #183138;
  --text: #e8f0ee;
  --muted: #8ea3a3;
  --teal: #39d6bd;
  --teal-deep: #0d7669;
  --amber: #e1bc54;
  --danger: #f36f77;
  --success: #64d98e;
  --radius: 7px;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: 0;
}

button, input, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
[hidden] { display: none !important; }

.shell { width: min(1040px, calc(100% - 40px)); margin-inline: auto; }
.shell-wide { width: min(1320px, calc(100% - 40px)); }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  position: relative;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(57, 214, 189, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(57, 214, 189, .045) 1px, transparent 1px);
  background-size: 40px 40px;
}

.login-panel {
  width: min(430px, 100%);
  padding: 40px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--teal);
  border-radius: var(--radius);
  background: rgba(13, 28, 32, .97);
  box-shadow: 0 22px 70px rgba(0, 0, 0, .35);
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  color: #06211d;
  background: var(--teal);
  border: 1px solid #76ead7;
  border-radius: 6px;
  font-size: 22px;
  font-weight: 900;
}

.brand-mark-small { width: 34px; height: 34px; font-size: 16px; flex: 0 0 34px; }
.eyebrow, .section-kicker { margin: 18px 0 6px; color: var(--amber); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.section-kicker { margin-top: 0; color: var(--teal); }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 30px; line-height: 1.2; }
h2 { margin-bottom: 6px; font-size: 19px; line-height: 1.3; }
.login-copy { color: var(--muted); margin-bottom: 28px; }

label { display: block; margin: 0 0 7px; color: #b8c9c7; font-size: 12px; font-weight: 700; }
input, textarea {
  width: 100%;
  color: var(--text);
  background: #061114;
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input { height: 43px; padding: 0 12px; }
textarea { padding: 12px; resize: vertical; line-height: 1.55; }
input:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(57, 214, 189, .1); }
input::placeholder, textarea::placeholder { color: #587075; }

.login-form { display: grid; gap: 10px; }
.form-error { min-height: 20px; margin: 0; color: var(--danger); font-size: 12px; }
.login-support { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line-soft); display: flex; justify-content: space-between; color: var(--muted); }
.login-support strong { color: var(--text); }
.admin-entry { position: absolute; right: 24px; bottom: 20px; color: #62787a; font-size: 12px; text-decoration: none; }
.admin-entry:hover, .back-link:hover { color: var(--teal); }
.back-link { display: block; margin-top: 18px; color: var(--muted); text-align: center; text-decoration: none; font-size: 12px; }

.button {
  min-height: 40px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 750;
  transition: background .15s, border-color .15s, opacity .15s;
}
.button:disabled { cursor: not-allowed; opacity: .42; }
.button-primary { background: var(--teal); border-color: var(--teal); color: #04211d; }
.button-primary:hover:not(:disabled) { background: #6ce3cf; }
.button-secondary { background: #102328; border-color: var(--line); color: var(--text); }
.button-secondary:hover:not(:disabled) { border-color: #3f6268; background: #153036; }
.button-danger { background: var(--danger); border-color: var(--danger); color: #2b070a; }
.button-block { width: 100%; justify-content: space-between; margin-top: 4px; }

.site-header { height: 66px; border-bottom: 1px solid var(--line-soft); background: rgba(7, 16, 18, .96); position: sticky; top: 0; z-index: 10; }
.header-inner { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; min-width: 0; }
.brand > span:last-child { display: grid; min-width: 0; }
.brand strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand small { color: #6f8587; font-size: 9px; font-weight: 700; }
.header-actions { display: flex; align-items: center; gap: 16px; }
.service-status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.service-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(100, 217, 142, .08); }
.icon-command, .text-command { padding: 5px 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; text-decoration: none; }
.icon-command:hover, .text-command:hover { color: var(--text); }

.page-main { padding-block: 48px 72px; }
.account-hero { display: flex; justify-content: space-between; align-items: end; gap: 30px; padding: 0 0 26px; }
.account-hero h1 { font-size: 29px; }
.account-hero p { color: var(--muted); margin-bottom: 0; }
.account-hero .eyebrow { color: var(--amber); margin-bottom: 8px; }
.card-identity { text-align: right; }
.card-identity span { display: block; color: var(--muted); font-size: 11px; }
.card-identity strong { font-family: Consolas, monospace; font-size: 13px; }

.stats-band, .admin-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-left: 3px solid var(--teal);
  border-radius: var(--radius);
  background: var(--panel);
}
.stats-band > div, .admin-stats > div { min-height: 86px; padding: 18px 22px; display: grid; align-content: center; gap: 4px; border-right: 1px solid var(--line-soft); }
.stats-band > div:last-child, .admin-stats > div:last-child { border-right: 0; }
.stats-band span, .admin-stats span { color: var(--muted); font-size: 11px; }
.stats-band strong, .admin-stats strong { font-size: 22px; }

.notice { margin: 14px 0 0; padding: 11px 14px; border: 1px solid; border-radius: 5px; font-size: 12px; }
.notice-error { color: #ffc3c6; background: rgba(243, 111, 119, .08); border-color: rgba(243, 111, 119, .5); }

.tool-panel, .records-section, .data-section {
  margin-top: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.section-heading { display: flex; justify-content: space-between; align-items: start; gap: 24px; margin-bottom: 22px; }
.section-heading p { margin-bottom: 0; color: var(--muted); font-size: 12px; }
.section-heading-compact { align-items: center; margin-bottom: 18px; }
.status-pill { display: inline-flex; align-items: center; min-height: 26px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #0a171a; font-size: 11px; white-space: nowrap; }
.status-pill.success, .badge.success { color: var(--success); border-color: rgba(100, 217, 142, .35); }
.status-pill.warning, .badge.pending { color: var(--amber); border-color: rgba(225, 188, 84, .4); }
.status-pill.error, .badge.failed { color: var(--danger); border-color: rgba(243, 111, 119, .4); }
.badge.redeemed { color: #ff9ca2; border-color: rgba(243, 111, 119, .65); background: rgba(243, 111, 119, .1); }
.badge.retryable { color: var(--amber); border-color: rgba(225, 188, 84, .4); }
.badge.uncertain { color: #ffc3c6; border-color: rgba(243, 111, 119, .65); }
.refund-tool textarea { min-height: 122px; font-family: Consolas, monospace; font-size: 12px; }
.token-foot { min-height: 32px; display: flex; justify-content: space-between; align-items: center; gap: 12px; color: #647c7f; font-size: 11px; }

.account-preview { display: grid; grid-template-columns: 1.5fr repeat(3, 1fr); margin: 12px 0 18px; border: 1px solid var(--line-soft); border-radius: 5px; background: #091619; }
.account-preview > div { padding: 13px 14px; min-width: 0; border-right: 1px solid var(--line-soft); }
.account-preview > div:last-child { border-right: 0; }
.account-preview span { display: block; color: var(--muted); font-size: 10px; }
.account-preview strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.action-row { display: flex; justify-content: flex-end; gap: 10px; }
.work-message { min-height: 21px; margin: 12px 0 0; color: var(--muted); font-size: 12px; }
.work-message.success { color: var(--success); }
.work-message.error { color: var(--danger); }

.support-band { margin-top: 18px; min-height: 250px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 48px; padding: 30px 44px; border-block: 1px solid var(--line); background: #0a171a; }
.support-band h2 { font-size: 24px; }
.support-band p { color: var(--muted); }
.support-band img, .qr-preview img { display: block; background: white; border-radius: 6px; }
.group-number { margin-top: 24px; color: var(--muted); }
.group-number strong { margin-left: 8px; color: var(--amber); font-size: 18px; }

.records-section { margin-top: 18px; }
.table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--line-soft); border-radius: 5px; }
table { width: 100%; border-collapse: collapse; min-width: 700px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
th { color: #70878a; background: #091619; font-size: 10px; font-weight: 800; text-transform: uppercase; }
td { color: #b9cac8; font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(57, 214, 189, .025); }
.empty-state { padding: 34px; color: #688083; text-align: center; font-size: 12px; }
.badge { display: inline-flex; padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 10px; }
.table-action { padding: 4px 8px; border: 1px solid var(--line); border-radius: 4px; background: transparent; color: var(--text); cursor: pointer; font-size: 11px; }
.table-action:hover { border-color: var(--teal); }
.site-footer { padding: 20px 0; border-top: 1px solid var(--line-soft); color: #5e7476; font-size: 11px; }

.confirm-dialog { width: min(420px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); background: var(--panel-strong); }
.confirm-dialog::backdrop { background: rgba(0, 0, 0, .72); }
.confirm-dialog form { padding: 28px; text-align: center; }
.confirm-dialog p { color: var(--muted); }
.dialog-icon { width: 42px; height: 42px; margin: 0 auto 14px; display: grid; place-items: center; border: 1px solid var(--danger); border-radius: 50%; color: var(--danger); font-weight: 900; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
.toast { position: fixed; left: 50%; bottom: 26px; z-index: 50; transform: translate(-50%, 20px); max-width: min(420px, calc(100% - 32px)); padding: 10px 15px; border: 1px solid var(--line); border-radius: 5px; color: var(--text); background: #122329; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; box-shadow: 0 12px 30px rgba(0, 0, 0, .3); }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

.admin-main { padding-block: 38px 70px; }
.admin-title-row { display: flex; justify-content: space-between; align-items: end; gap: 30px; margin-bottom: 24px; }
.admin-title-row h1 { margin-bottom: 4px; }
.admin-title-row p { margin-bottom: 0; color: var(--muted); }
.admin-stats { grid-template-columns: repeat(5, 1fr); }
.admin-stats > div { min-height: 82px; }

.tab-list { display: flex; gap: 2px; margin-top: 24px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab-button { min-width: 110px; padding: 12px 16px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); cursor: pointer; font-weight: 700; }
.tab-button.active { color: var(--text); border-bottom-color: var(--teal); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(340px, .9fr); gap: 18px; }
.admin-grid:not(.has-results) .create-card-tool { grid-column: 1 / -1; }
.create-card-tool, .generated-panel { margin-top: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 18px; }
.form-grid-two { margin: 14px 0; }
.field-button { display: grid; align-content: end; }
.generated-panel { padding: 24px; border: 1px solid rgba(225, 188, 84, .4); border-radius: var(--radius); background: rgba(225, 188, 84, .05); }
.generated-panel h2 { margin-bottom: 3px; }
.generated-panel p { color: var(--muted); font-size: 12px; }
.generated-panel textarea { margin: 12px 0; font-family: Consolas, monospace; color: #f6d87f; }
.search-input { width: min(280px, 100%); }
.inventory-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; width: min(470px, 100%); }
.inventory-actions .search-input { flex: 1 1 220px; }
.row-checkbox { width: 16px; height: 16px; margin: 0; accent-color: var(--teal); box-shadow: none; cursor: pointer; }
.checkbox-cell { width: 42px; text-align: center; }
.checkbox-cell .row-checkbox { display: inline-block; vertical-align: middle; }
.data-section { margin-top: 18px; padding: 22px; }
.vendor-summary { display: grid; grid-template-columns: repeat(5, 1fr); margin-bottom: 16px; border-block: 1px solid var(--line-soft); }
.vendor-summary > div { min-height: 68px; padding: 12px 16px; display: grid; align-content: center; border-right: 1px solid var(--line-soft); }
.vendor-summary > div:last-child { border-right: 0; }
.vendor-summary span { color: var(--muted); font-size: 10px; }
.vendor-summary strong { font-size: 18px; }
.vendor-table { min-width: 1280px; }
.mono-cell { font-family: Consolas, monospace; white-space: nowrap; }
.settings-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.settings-tool { display: grid; gap: 10px; align-content: start; }
.settings-tool .section-heading { margin-bottom: 8px; }
.settings-tool textarea { font-family: Consolas, monospace; font-size: 12px; }
.settings-tool > .button { justify-self: start; margin-top: 5px; }
.field-note { margin: -3px 0 4px; color: var(--muted); font-size: 11px; }
.qr-preview { display: flex; align-items: center; gap: 16px; padding: 12px; border: 1px solid var(--line-soft); background: #091619; }
.qr-preview span { color: var(--muted); font-size: 11px; }

@media (max-width: 820px) {
  .shell, .shell-wide { width: min(100% - 24px, 1040px); }
  .page-main, .admin-main { padding-top: 28px; }
  .account-hero, .admin-title-row { align-items: start; }
  .account-hero { flex-direction: column; gap: 14px; }
  .card-identity { text-align: left; }
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
  .admin-stats > div:nth-child(2n) { border-right: 0; }
  .admin-grid, .settings-layout { grid-template-columns: 1fr; }
  .admin-grid .create-card-tool { grid-column: auto; }
  .support-band { padding: 26px; gap: 24px; }
  .support-band img { width: 180px; height: 180px; }
  .vendor-summary { grid-template-columns: repeat(2, 1fr); }
  .vendor-summary > div:nth-child(2n) { border-right: 0; }
}

@media (max-width: 600px) {
  .login-panel { padding: 28px 22px; }
  .header-actions .service-status, .header-actions > a { display: none; }
  .stats-band { grid-template-columns: 1fr 1fr; }
  .stats-band > div { min-height: 74px; padding: 14px; }
  .stats-band > div:nth-child(2) { border-right: 0; }
  .stats-band > div:last-child { grid-column: 1 / -1; border-top: 1px solid var(--line-soft); }
  .tool-panel, .records-section, .data-section { padding: 18px 14px; }
  .section-heading { gap: 12px; }
  .account-preview { grid-template-columns: 1fr 1fr; }
  .account-preview > div:nth-child(2) { border-right: 0; }
  .account-preview > div:nth-child(-n+2) { border-bottom: 1px solid var(--line-soft); }
  .action-row { display: grid; grid-template-columns: 1fr 1fr; }
  .support-band { grid-template-columns: 1fr; text-align: center; }
  .support-band img { width: min(220px, 100%); height: auto; margin-inline: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .inventory-actions { align-items: stretch; flex-direction: column; }
  .inventory-actions .search-input { flex-basis: auto; }
  .admin-title-row { display: grid; }
  .admin-stats > div { padding: 14px; }
  .qr-preview { align-items: start; }
}
