/* Admin console — denser layout than the landing page, monospace-friendly. */

* { box-sizing: border-box; margin: 0; padding: 0; }

body.admin {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #fafafa;
  color: #1a1a1a;
  line-height: 1.5;
  font-size: 14px;
  min-height: 100vh;
}

body.admin a { color: #0b6bcb; text-decoration: none; }
body.admin a:hover { text-decoration: underline; }

#admin-header {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 0.65rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-header-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.admin-logo {
  font-weight: 700;
  font-size: 1.05rem;
  color: #1a1a1a !important;
  letter-spacing: -0.01em;
  text-decoration: none !important;
}
.admin-logo span { color: #999; font-weight: 500; font-size: 0.85rem; }

.admin-nav {
  display: flex;
  gap: 0.4rem;
}

.nav-link {
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  color: #444 !important;
  text-decoration: none !important;
  font-size: 0.9rem;
}
.nav-link:hover { background: #f1f1f1; }
.nav-link.active { background: #111; color: #fff !important; }

.admin-header-spacer { flex: 1; }

.admin-env {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.env-pill {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid;
}
.env-prod { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.env-local { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }

.admin-user { font-size: 0.85rem; color: #666; font-family: 'SF Mono', Menlo, Consolas, monospace; }

.link-button {
  background: none;
  border: none;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  color: #0b6bcb;
  font-size: 0.85rem;
  text-decoration: underline;
  font-family: inherit;
}
.link-button:hover { color: #0a5aab; }

main.admin-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 1rem;
}

h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.5rem 0 0.6rem;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 1rem 0 0.5rem;
  color: #333;
}

p.muted, .muted { color: #888; }
.small { font-size: 0.85rem; }

code, .mono {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
}

/* ── Cards ─────────────────────────────────────────────────────────────── */

.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.card-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-start;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 100px;
}
.stat-label { font-size: 0.75rem; color: #999; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 1.4rem; font-weight: 600; font-family: 'SF Mono', Menlo, Consolas, monospace; }
.stat-value.positive { color: #166534; }
.stat-value.negative { color: #991b1b; }

/* ── Forms ─────────────────────────────────────────────────────────────── */

.form-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}

.field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 200px; flex: 1; }
.field label { font-size: 0.75rem; color: #555; font-weight: 500; }
.field.checkbox { flex-direction: row; align-items: center; min-width: 0; }
.field.checkbox label { font-size: 0.85rem; color: #1a1a1a; }

input[type="text"], input[type="email"], input[type="number"], input[type="search"], input[type="date"], select, textarea {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #1a1a1a;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #0b6bcb;
  box-shadow: 0 0 0 3px rgba(11, 107, 203, 0.15);
}

textarea { font-family: inherit; min-height: 4em; resize: vertical; }

button.btn, .btn {
  display: inline-block;
  background: #111;
  color: #fff;
  border: 1px solid #111;
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none !important;
}
button.btn:hover, .btn:hover { background: #333; }
button.btn:disabled { background: #ccc; border-color: #ccc; cursor: not-allowed; }

button.btn-secondary, .btn-secondary {
  background: #fff;
  color: #1a1a1a;
  border: 1px solid #d1d5db;
}
button.btn-secondary:hover, .btn-secondary:hover { background: #f5f5f5; }

button.btn-danger, .btn-danger {
  background: #b91c1c;
  border-color: #b91c1c;
}
button.btn-danger:hover, .btn-danger:hover { background: #991b1b; }

button.btn-sm, .btn-sm {
  padding: 0.25rem 0.55rem;
  font-size: 0.8rem;
}

/* ── Tables ────────────────────────────────────────────────────────────── */

.table-wrap {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem;
}

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

table.data th, table.data td {
  padding: 0.55rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: top;
}

table.data th {
  background: #f9fafb;
  font-weight: 600;
  color: #444;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  user-select: none;
}

table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { background: #f1f1f1; }
table.data th .sort-arrow { color: #999; margin-left: 0.25rem; }

table.data tbody tr:hover { background: #f9fafb; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tr.empty td { text-align: center; color: #888; padding: 1.5rem; }

table.data td.right, table.data th.right { text-align: right; }
table.data td.mono { font-family: 'SF Mono', Menlo, Consolas, monospace; font-size: 0.8rem; }
table.data td.delta-pos { color: #166534; font-weight: 600; }
table.data td.delta-neg { color: #991b1b; font-weight: 600; }

/* ── Badges ────────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #e5e7eb;
  color: #374151;
}
.badge-admin { background: #fef3c7; color: #92400e; }
.badge-adjust { background: #dbeafe; color: #1e40af; }
.badge-set { background: #ede9fe; color: #5b21b6; }
.badge-quest { background: #d1fae5; color: #065f46; }
.badge-signup { background: #fce7f3; color: #9d174d; }
.badge-refund { background: #fef9c3; color: #854d0e; }
.badge-sent { background: #d1fae5; color: #065f46; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-failed { background: #fee2e2; color: #991b1b; }

/* ── Pagination ────────────────────────────────────────────────────────── */

.pagination {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
  font-size: 0.85rem;
  color: #666;
  margin-top: 0.75rem;
}

.pagination .pg-info { margin-right: 0.5rem; }

/* ── Login screen ──────────────────────────────────────────────────────── */

.login-box {
  max-width: 380px;
  margin: 4rem auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 2rem;
  text-align: center;
}
.login-box h1 { margin-bottom: 0.4rem; }
.login-box .tagline { color: #666; margin-bottom: 1.4rem; font-size: 0.9rem; }

.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: #fff;
  color: #1a1a1a;
  border: 1px solid #d1d5db;
  padding: 0.65rem 1.1rem;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.google-btn:hover { background: #f5f5f5; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.dashboard-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1.1rem 1.25rem;
  text-decoration: none !important;
  color: inherit !important;
  display: block;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.dashboard-card:hover { border-color: #0b6bcb; transform: translateY(-1px); }
.dashboard-card h3 { color: #111; margin: 0 0 0.35rem; }
.dashboard-card p { color: #666; font-size: 0.85rem; }

/* ── Chart (simple CSS bars) ───────────────────────────────────────────── */

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 120px;
  padding: 0.5rem 0;
  border-bottom: 1px solid #e5e7eb;
}
.bar {
  flex: 1;
  min-width: 4px;
  background: #0b6bcb;
  border-radius: 2px 2px 0 0;
  position: relative;
  min-height: 1px;
  cursor: pointer;
}
.bar:hover { background: #075aac; }
.bar.empty { background: #f1f1f1; }
.bar-axis {
  display: flex;
  font-size: 0.7rem;
  color: #999;
  gap: 2px;
  margin-top: 0.25rem;
}
.bar-axis span { flex: 1; text-align: center; white-space: nowrap; overflow: hidden; }

/* ── Toast ─────────────────────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.7rem 1rem;
  border-radius: 6px;
  background: #1f2937;
  color: #fff;
  font-size: 0.85rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  max-width: 360px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: auto;
}
.toast.toast-visible { opacity: 1; transform: translateY(0); }
.toast.toast-success { background: #065f46; }
.toast.toast-warning { background: #92400e; }
.toast.toast-error { background: #991b1b; }

/* ── Modal / drawer ────────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 100;
  padding: 4rem 1rem 1rem;
}

.modal {
  background: #fff;
  border-radius: 10px;
  max-width: 520px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.modal h2 { margin-top: 0; }
.modal .modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

/* ── Misc ──────────────────────────────────────────────────────────────── */

details.danger {
  margin-top: 2rem;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fef2f2;
  padding: 0.6rem 1rem;
}
details.danger summary {
  cursor: pointer;
  font-weight: 600;
  color: #991b1b;
}
details.danger[open] { padding-bottom: 1rem; }

.notice {
  padding: 0.75rem 1rem;
  background: #fef9e7;
  border: 1px solid #fde68a;
  border-radius: 6px;
  color: #92400e;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.notice.info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.notice.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

.spinner {
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  border: 2px solid #ccc;
  border-top-color: #111;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.hidden { display: none !important; }

.tag {
  display: inline-block;
  background: #f1f1f1;
  border: 1px solid #e5e7eb;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.75rem;
  margin-right: 0.25rem;
  color: #444;
}

.email-cell { font-family: 'SF Mono', Menlo, Consolas, monospace; font-size: 0.8rem; }

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: #888;
  font-size: 0.9rem;
}
