:root {
  --bg: #0f1417;
  --surface: #1a2227;
  --surface-2: #222d33;
  --border: #2e3d45;
  --text: #e8eef1;
  --muted: #9aaab3;
  --accent: #14b8a6;
  --accent-dark: #0d9488;
  --danger: #ef4444;
  --gold: #f59e0b;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  line-height: 1.6;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: baseline; gap: 10px; }
.logo { font-size: 1.4rem; font-weight: 800; color: var(--accent); }
.brand-sub { color: var(--muted); font-size: 0.95rem; }

/* ---------- Layout ---------- */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card h2 { margin: 0 0 14px; font-size: 1.15rem; }
.card h3 { margin: 0 0 8px; font-size: 0.95rem; color: var(--muted); }

/* ---------- Login ---------- */
.login-card { max-width: 420px; margin: 48px auto 0; }
.login-card h1 { margin: 0 0 4px; font-size: 1.4rem; }
.login-card p { margin-top: 0; }

/* ---------- Stats ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--accent); }

/* ---------- Tables ---------- */
.tables-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 640px) { .tables-row { grid-template-columns: 1fr; } }

.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.table th, .table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: right;
}

.table th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.table tr:last-child td { border-bottom: none; }
.table code { font-size: 0.85rem; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}
.badge-paid { background: rgba(20, 184, 166, 0.18); color: var(--accent); }
.badge-gift { background: rgba(245, 158, 11, 0.18); color: var(--gold); }

/* ---------- Forms ---------- */
label { display: block; margin-bottom: 14px; font-size: 0.92rem; font-weight: 600; }

input, select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0 16px;
  align-items: end;
}

/* ---------- Buttons ---------- */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #042f2e; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); color: #fff; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.btn-block { width: 100%; }
.btn-small { padding: 5px 12px; font-size: 0.85rem; }

/* ---------- Messages ---------- */
.error { color: var(--danger); font-size: 0.9rem; margin: 8px 0; }
.success { color: var(--accent); font-size: 0.9rem; }
.error-banner {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid var(--danger);
  color: #fca5a5;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
}

/* ---------- Issued code ---------- */
.issued {
  margin-top: 16px;
  padding: 14px 16px;
  background: rgba(20, 184, 166, 0.1);
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.issued-label { font-weight: 700; }
.issued code {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 1px;
}
