:root {
  color-scheme: dark;
  --bg: #080d18;
  --panel: rgba(17, 27, 46, 0.88);
  --panel-strong: #121d31;
  --panel-soft: rgba(13, 23, 40, 0.72);
  --line: rgba(148, 163, 184, 0.18);
  --line-strong: rgba(148, 163, 184, 0.3);
  --text: #eef4ff;
  --muted: #97a6bd;
  --accent: #4f8cff;
  --accent-2: #66e0c2;
  --danger: #ff6b7a;
  --warning: #ffcb6b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 10%, rgba(79, 140, 255, 0.2), transparent 34rem),
    radial-gradient(circle at 90% 35%, rgba(102, 224, 194, 0.12), transparent 30rem),
    var(--bg);
}
button, input, select, textarea { font: inherit; }
button {
  border: 0;
  border-radius: 11px;
  padding: 0.78rem 1.1rem;
  color: white;
  background: linear-gradient(135deg, var(--accent), #6b5cff);
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 10px 28px rgba(79, 140, 255, 0.22);
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button:disabled { cursor: wait; opacity: 0.6; }
button.secondary { background: #24324a; box-shadow: none; }
button.danger { background: rgba(255, 107, 122, 0.18); color: #ff9daa; box-shadow: none; }
button.compact-danger { border: 1px solid rgba(255, 107, 122, 0.3); border-radius: 8px; padding: 0.42rem 0.68rem; color: #ff9daa; background: rgba(255, 107, 122, 0.12); box-shadow: none; font-size: 0.75rem; white-space: nowrap; }
button.compact-danger:disabled { cursor: not-allowed; opacity: 0.48; filter: none; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0.78rem 0.9rem;
  color: var(--text);
  background: rgba(4, 10, 21, 0.72);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: rgba(79, 140, 255, 0.75); box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.12); }
select option { color: var(--text); background: #101a2d; }
textarea { resize: vertical; line-height: 1.55; }
label { display: grid; gap: 0.45rem; color: #c8d4e6; font-size: 0.92rem; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0.65rem; font-size: clamp(1.8rem, 4vw, 2.7rem); letter-spacing: -0.045em; }
h2 { margin-bottom: 0; font-size: 1.2rem; }
.muted { color: var(--muted); }
.small { font-size: 0.84rem; }
.eyebrow { margin-bottom: 0.45rem; color: var(--accent-2); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.18em; }
.message { min-height: 1.4rem; margin: 0.9rem 0 0; color: var(--accent-2); }
.message.error { color: #ff9daa; }
.warning { color: var(--warning); }
.stack-form { display: grid; gap: 0.85rem; }
.button-row { display: flex; flex-wrap: wrap; gap: 0.7rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem; }
.check-row { display: flex; align-items: center; gap: 0.65rem; }
.check-row input { width: auto; }
.public-page { display: grid; place-items: center; padding: 2rem 1rem; }
.redeem-shell { width: min(100%, 680px); display: grid; gap: 1rem; }
.hero-card, .result-card, .login-card, .panel-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: clamp(1.25rem, 4vw, 2rem);
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(18px);
}
.brand-mark { display: grid; place-items: center; width: 3rem; height: 3rem; margin-bottom: 1.4rem; border-radius: 14px; background: linear-gradient(135deg, var(--accent), #6757ff); font-size: 1.45rem; font-weight: 900; }
.section-heading, .admin-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; }
.pill { border: 1px solid rgba(102, 224, 194, 0.28); border-radius: 999px; padding: 0.35rem 0.7rem; color: var(--accent-2); background: rgba(102, 224, 194, 0.08); font-size: 0.82rem; white-space: nowrap; }
.security-note { color: #6f8099; text-align: center; font-size: 0.78rem; }
.admin-shell { width: min(1440px, calc(100% - 2rem)); margin: 0 auto; padding: 1.5rem 0 4rem; }
.login-card { width: min(100%, 470px); margin: 9vh auto 0; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.stats-grid article { position: relative; display: grid; gap: 0.35rem; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; padding: 1rem 1.05rem; background: linear-gradient(150deg, rgba(25, 39, 65, 0.92), rgba(12, 22, 39, 0.9)); }
.stats-grid article::before { position: absolute; inset: 0 auto 0 0; width: 3px; background: linear-gradient(var(--accent), var(--accent-2)); content: ""; }
.stats-grid strong { font-size: 1.7rem; letter-spacing: -0.04em; }
.stats-grid span { color: var(--muted); font-size: 0.82rem; }
.table-card { margin-top: 1rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { border-bottom: 1px solid var(--line); padding: 0.78rem 0.65rem; text-align: left; font-size: 0.84rem; vertical-align: top; }
th { color: #8292aa; font-weight: 700; }
td { color: #d8e1ef; max-width: 330px; overflow-wrap: anywhere; }
.task-progress { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.progress-track { height: 9px; overflow: hidden; border-radius: 999px; background: #0a1221; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.25s ease; }

.admin-shell .panel-card { padding: 1.35rem; border-radius: 18px; box-shadow: 0 18px 60px rgba(0, 0, 0, 0.25); }
.admin-header { margin-bottom: 1rem; padding: 0.35rem 0; }
.admin-header h1 { margin-bottom: 0.35rem; }
.header-summary, .section-description, .helper-text { margin-bottom: 0; color: var(--muted); }
.header-summary { font-size: 0.92rem; }
.header-actions { display: flex; align-items: center; gap: 0.65rem; }
.status-badge { display: inline-flex; align-items: center; gap: 0.45rem; border: 1px solid rgba(102, 224, 194, 0.2); border-radius: 999px; padding: 0.55rem 0.75rem; color: #9cebd8; background: rgba(102, 224, 194, 0.08); font-size: 0.78rem; font-weight: 700; }
.status-badge span { width: 0.48rem; height: 0.48rem; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 0 4px rgba(102, 224, 194, 0.12); }
.workspace-grid { display: grid; grid-template-columns: minmax(280px, 0.72fr) minmax(0, 2.28fr); align-items: start; gap: 1rem; }
.operations-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr); align-items: start; gap: 1rem; }
.category-panel { position: sticky; top: 1rem; }
.compact-heading { margin-bottom: 0.65rem; }
.compact-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.65rem; margin-top: 1rem; }
.compact-form button { min-width: 5rem; }
.category-list { display: grid; gap: 0.65rem; margin-top: 0.35rem; }
.category-item { border: 1px solid var(--line); border-radius: 14px; padding: 0.9rem; background: var(--panel-soft); }
.category-item-header { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.75rem; }
.category-item h3 { margin: 0; font-size: 0.98rem; }
.category-total { color: var(--accent-2); font-size: 0.75rem; font-weight: 800; }
.category-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.45rem; }
.category-metrics div { display: grid; gap: 0.12rem; border-radius: 10px; padding: 0.5rem; background: rgba(4, 10, 21, 0.48); }
.category-metrics strong { font-size: 0.95rem; }
.category-metrics span { color: var(--muted); font-size: 0.68rem; }
.category-actions { display: flex; justify-content: flex-end; margin-top: 0.7rem; border-top: 1px solid var(--line); padding-top: 0.65rem; }
.action-cell { width: 1%; white-space: nowrap; }
.step-badge { display: grid; place-items: center; width: 2rem; height: 2rem; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: rgba(4, 10, 21, 0.45); font-size: 0.72rem; font-weight: 800; }
.operation-card { min-width: 0; }
.primary-action { width: 100%; }
.upload-row { display: grid; gap: 0.35rem; }
.file-label input { padding: 0.55rem; }
.helper-text { font-size: 0.76rem; }
.generated-box { display: grid; gap: 0.75rem; margin-top: 0.85rem; border-top: 1px solid var(--line); padding-top: 0.85rem; }
.generated-box[hidden] { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.records-panel { margin-top: 1rem; }
.records-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.record-tabs { display: flex; gap: 0.35rem; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; padding: 0.3rem; background: rgba(4, 10, 21, 0.42); }
.tab-button { flex: 0 0 auto; border-radius: 9px; padding: 0.55rem 0.75rem; color: var(--muted); background: transparent; box-shadow: none; font-size: 0.8rem; }
.tab-button.active { color: white; background: rgba(79, 140, 255, 0.2); box-shadow: inset 0 0 0 1px rgba(79, 140, 255, 0.3); }
.record-view[hidden] { display: none; }
.empty-row td { padding: 2rem 1rem; color: var(--muted); text-align: center; }
.status-text { display: inline-flex; border-radius: 999px; padding: 0.2rem 0.5rem; color: #b8c8df; background: rgba(148, 163, 184, 0.1); font-size: 0.75rem; }

@media (max-width: 1180px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .category-panel { position: static; }
  .category-list { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
}
@media (max-width: 860px) {
  .operations-grid { grid-template-columns: 1fr; }
  .records-heading { align-items: flex-start; flex-direction: column; }
  .record-tabs { width: 100%; }
}
@media (max-width: 620px) {
  .admin-header, .section-heading { align-items: flex-start; flex-direction: column; }
  .header-actions { width: 100%; flex-wrap: wrap; }
  .header-actions .status-badge { margin-right: auto; }
  .stats-grid, .form-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid article:last-child:nth-child(odd) { grid-column: span 2; }
  .compact-form { grid-template-columns: 1fr; }
  .compact-form button { width: 100%; }
  .category-metrics { grid-template-columns: repeat(2, 1fr); }
  .hero-card, .result-card, .login-card, .panel-card { border-radius: 16px; }
}
@media (max-width: 420px) {
  .admin-shell { width: min(100% - 1rem, 1440px); padding-top: 0.8rem; }
  .form-grid { grid-template-columns: 1fr; }
  .admin-shell .panel-card { padding: 1rem; }
}
