:root {
  --primary: #0d9488;
  --primary-soft: #14b8a6;
  --primary-deep: #134e4a;
  --primary-faint: #ccfbf1;
  --canvas: #f8faf9;
  --surface: #ffffff;
  --surface-muted: #f1f4f2;
  --text: #0f172a;
  --text-secondary: #64748b;
  --border: rgba(13, 148, 136, 0.18);
  --shadow: 0 8px 24px rgba(19, 78, 74, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
}

.hidden { display: none !important; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--primary-deep), var(--primary));
  color: #fff;
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { font-size: 22px; }
.brand-title { font-weight: 800; letter-spacing: -0.01em; font-size: 17px; }

.actions { display: flex; align-items: center; gap: 14px; }
.who { font-size: 13px; opacity: 0.9; }

.env-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

/* Status banner */
.status {
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 999px; flex: none; }
.status-connecting { background: #fef3c7; color: #92400e; }
.status-connecting::before { background: #f59e0b; animation: pulse 1.2s ease-in-out infinite; }
.status-ok { background: var(--primary-faint); color: var(--primary-deep); }
.status-ok::before { background: var(--primary); }
.status-empty { background: #fef3c7; color: #92400e; }
.status-empty::before { background: #f59e0b; }
.status-error { background: #fee2e2; color: #991b1b; }
.status-error::before { background: #ef4444; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Project line + toggle */
.project-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}
.project-line code {
  background: var(--surface-muted);
  padding: 2px 8px;
  border-radius: 5px;
  color: var(--text);
}
.ghost-link {
  background: transparent;
  color: var(--primary);
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid var(--border);
}
.ghost-link:hover { background: var(--primary-faint); }

.raw {
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 10px;
  font-size: 12px;
  overflow: auto;
  max-height: 320px;
  margin: 0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

button {
  border-radius: 10px;
  border: 0;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  padding: 9px 16px;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
button:active { transform: scale(0.97); }

button.primary {
  background: linear-gradient(135deg, var(--primary-soft), var(--primary));
  color: #fff;
}

button.ghost {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

/* Layout */
main {
  max-width: 1100px;
  margin: 32px auto;
  padding: 0 24px;
}

.card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 22px;
  overflow: hidden;
}

/* Auth */
.auth-card {
  max-width: 380px;
  margin: 60px auto;
}

.auth-card h2 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.hint {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 0 0 16px;
}
.hint code {
  background: var(--surface-muted);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

form label {
  display: block;
  margin-bottom: 14px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
}

input[type=email], input[type=password], input[type=search], select {
  width: 100%;
  padding: 11px 13px;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  background: var(--surface);
  color: var(--text);
  text-transform: none;
}
input:focus, select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 0;
}

button[type=submit] { width: 100%; padding: 12px; }
.error { color: #b91c1c; margin: 12px 0 0; font-size: 13px; min-height: 1em; }

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary-deep);
}
.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.toolbar input, .toolbar select {
  flex: 1 1 200px;
  margin: 0;
}
.checkbox {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  font-size: 13px !important;
  text-transform: none !important;
  font-weight: 500 !important;
  color: var(--text) !important;
  margin: 0 !important;
}

/* Table */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
}
th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  background: var(--surface-muted);
}
tbody tr:hover { background: var(--surface-muted); }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.badge.on { background: var(--primary-faint); color: var(--primary-deep); }
.badge.off { background: #f1f5f9; color: var(--text-secondary); }
.badge.search-yes { background: var(--primary); color: #fff; }
.badge.search-no { background: #f1f5f9; color: var(--text); }
.badge.search-unknown { background: #fef3c7; color: #92400e; }
.badge.soft { background: #f1f5f9; color: #334155; margin-left: 6px; }

/* Pre-launch promo helper text + lifetime-winner result card. */
.promo-help {
  margin: -6px 0 14px; padding: 12px 14px;
  background: rgba(13,148,136,0.06);
  border: 1px dashed rgba(13,148,136,0.35);
  border-radius: 12px; color: #134E4A; font-size: 0.9rem; line-height: 1.5;
}
.promo-help code {
  display: inline-block; margin: 0 2px; padding: 1px 6px; border-radius: 6px;
  background: #0D9488; color: #fff; font-weight: 700; letter-spacing: 0.04em; font-size: 0.82rem;
}
.winner-card {
  margin-top: 16px; padding: 18px 20px; border-radius: 14px;
  background: linear-gradient(135deg, #CCFBF1, #ffffff);
  border: 1px solid rgba(13,148,136,0.35);
  box-shadow: 0 8px 20px rgba(15,23,42,0.06);
}
.winner-card.hidden { display: none; }
.winner-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.winner-card-head h3 { margin: 0; font-size: 1.05rem; color: #134E4A; }
.winner-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 0; border-top: 1px dashed rgba(13,148,136,0.25);
}
.winner-row:first-of-type { border-top: 0; }
.winner-label {
  font-size: 0.8rem; color: #475569; text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 700; min-width: 50px;
}
.winner-value {
  flex: 1; padding: 8px 12px; background: #0F172A; color: #fff;
  border-radius: 8px; font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.06em; font-weight: 600; word-break: break-all;
}
.winner-note {
  margin: 12px 0 0; font-size: 0.85rem; color: #475569; line-height: 1.5;
}
.winner-note code {
  padding: 1px 6px; border-radius: 5px; background: #F1F4F2; color: #134E4A;
  font-size: 0.85rem;
}
.copy-btn { padding: 6px 12px; font-size: 0.82rem; }

/* ============================================================
   Winner section
   ============================================================ */
#winner-section { margin-bottom: 28px; }
#winner-section .section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; gap: 12px;
}
#winner-section h2 { margin: 0; font-size: 1.15rem; }

.winner-status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; font-size: 0.82rem; font-weight: 600;
  background: #f1f5f9; color: #475569;
}
.winner-status.pending { background: #fef3c7; color: #92400e; }
.winner-status.claimed { background: var(--primary-faint); color: var(--primary-deep); }
.winner-status.off     { background: #f1f5f9; color: #64748B; }

.winner-form {
  display: flex; flex-direction: column; gap: 14px;
}
.winner-field {
  display: flex; flex-direction: column; gap: 6px;
}
.winner-field-label {
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: #475569;
}
.winner-field input {
  padding: 11px 14px; border-radius: 10px; border: 1px solid var(--border, #E2E8E5);
  background: #fff; font-size: 0.98rem; color: var(--text, #0F172A);
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.winner-field input:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,148,136,0.18);
}
.winner-input-row {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.winner-input-row input { flex: 1; min-width: 220px; }
.winner-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 4px;
}
.winner-actions .primary {
  padding: 10px 18px; border-radius: 10px; border: 0;
  background: var(--primary); color: #fff; font-weight: 600; font-size: 0.95rem;
  cursor: pointer;
}
.winner-actions .primary:hover { background: var(--primary-deep); }
.winner-actions .primary:disabled { opacity: 0.6; cursor: progress; }

.winner-feedback { font-size: 0.85rem; color: #475569; }
.winner-feedback.ok    { color: var(--primary-deep); }
.winner-feedback.error { color: #b91c1c; }

/* ============================================================
   Appeals section
   ============================================================ */
#appeals-section { margin-bottom: 28px; }
#appeals-section .section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; gap: 12px;
}
#appeals-section h2 { margin: 0; font-size: 1.15rem; }

#appeals-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
#appeals-table th, #appeals-table td {
  padding: 12px 10px; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--border, #E2E8E5);
  font-size: 0.92rem;
}
#appeals-table th {
  text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.7rem;
  color: var(--text-soft, #475569); font-weight: 700; background: #FAFCFB;
}
#appeals-table tr:last-child td { border-bottom: 0; }
#appeals-table td:nth-child(3) { width: 38%; }

.appeal-message {
  white-space: pre-wrap; word-break: break-word;
  background: #F1F4F2; padding: 8px 10px; border-radius: 8px;
  color: var(--text, #0F172A); font-size: 0.88rem; line-height: 1.45;
  max-height: 140px; overflow: auto;
}
.appeal-status {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700;
}
.appeal-status.pending  { background: #fef3c7; color: #92400e; }
.appeal-status.accepted { background: var(--primary-faint); color: var(--primary-deep); }
.appeal-status.denied   { background: #fee2e2; color: #991b1b; }

.appeal-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.appeal-actions .primary {
  padding: 6px 12px; border-radius: 8px; border: 0;
  background: var(--primary); color: #fff; font-size: 0.82rem; font-weight: 600;
  cursor: pointer;
}
.appeal-actions .primary:hover { background: var(--primary-deep); }
.appeal-actions .ghost-link { font-size: 0.82rem; padding: 6px 10px; }

.muted-note { color: #94A3B8; font-size: 0.72rem; }

/* ============================================================
   Push broadcasts
   ============================================================ */
#push-section { margin-bottom: 28px; }
#push-section .section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; gap: 12px;
}
#push-section h2 { margin: 0; font-size: 1.15rem; }
.subsection-heading {
  margin: 24px 0 10px; font-size: 0.95rem; font-weight: 700;
  color: var(--text-soft, #475569); text-transform: uppercase; letter-spacing: 0.06em;
}

.push-form {
  display: flex; flex-direction: column; gap: 14px;
}
.push-form select,
.push-form textarea,
.push-form input[type="text"],
.push-form input[type="email"] {
  padding: 11px 14px; border-radius: 10px; border: 1px solid var(--border, #E2E8E5);
  background: #fff; font-size: 0.98rem; color: var(--text, #0F172A);
  font-family: inherit;
  width: 100%;
}
.push-form select:focus,
.push-form textarea:focus,
.push-form input:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,148,136,0.18);
}
.push-form textarea { resize: vertical; min-height: 70px; line-height: 1.45; }

#push-history-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
#push-history-table th, #push-history-table td {
  padding: 12px 10px; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--border, #E2E8E5); font-size: 0.92rem;
}
#push-history-table th {
  text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.7rem;
  color: var(--text-soft, #475569); font-weight: 700; background: #FAFCFB;
}
#push-history-table td:nth-child(4) { width: 36%; }
#push-history-table tr:last-child td { border-bottom: 0; }

.empty {
  padding: 40px 0;
  text-align: center;
  color: var(--text-secondary);
}

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Waitlist section ---- */
#waitlist-section { margin-bottom: 28px; }
#waitlist-section .section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin: 18px 0 12px;
}
#waitlist-section h2 { margin: 0; font-size: 1.15rem; }
.waitlist-actions {
  display: flex; align-items: center; gap: 14px;
}
.stat-inline { color: var(--text-secondary, #64748B); font-size: 0.92rem; }
.stat-inline strong { color: inherit; font-weight: 700; }
#waitlist-table { width: 100%; border-collapse: collapse; }
#waitlist-table th, #waitlist-table td {
  text-align: left; padding: 10px 12px; border-bottom: 1px solid #E2E8E5;
  font-size: 0.95rem;
}
#waitlist-table th {
  font-weight: 600; color: var(--text-secondary, #64748B);
  font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em;
}
#waitlist-table tr:last-child td { border-bottom: 0; }

/* ---- Plan + warning badges ---- */
.badge.plan-reporter  { background: #E2E8F0; color: #334155; }
.badge.plan-supporter { background: #FEF3C7; color: #92400E; }
.badge.warn-ok        { background: #DCFCE7; color: #166534; }
.badge.warn-soft      { background: #FEF9C3; color: #854D0E; }
.badge.warn-final     { background: #FED7AA; color: #9A3412; }
.badge.warn-suspended { background: #FECACA; color: #991B1B; font-weight: 700; }

/* ---- Last report cell ---- */
#users-table .never { color: #94A3B8; font-style: italic; }
#users-table .stale { color: #B91C1C; font-weight: 600; }

/* ---- Action buttons ---- */
.action-btn {
  font: inherit; cursor: pointer;
  padding: 6px 12px; border-radius: 8px;
  border: 1px solid transparent; font-size: 0.82rem; font-weight: 600;
  transition: filter .15s ease, transform .1s ease;
}
.action-btn:hover { filter: brightness(0.95); }
.action-btn:active { transform: scale(0.97); }
.action-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.action-warn    { background: #FEF3C7; color: #92400E; border-color: #FCD34D; }
.action-danger  { background: #FED7AA; color: #9A3412; border-color: #FB923C; }
.action-restore { background: #DCFCE7; color: #166534; border-color: #86EFAC; }
.action-disabled { color: #94A3B8; }
