:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-hover: #243044;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --text-muted: #8b9cb3;
  --accent: #3d8bfd;
  --accent-dim: #2a6fd6;
  --danger: #f4717a;
  --success: #3dd68c;
  --radius: 10px;
  --font: "DM Sans", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(61, 139, 253, 0.22), transparent),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 2rem 2rem 1.75rem;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
}

.login-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.login-card h1 i {
  color: var(--accent);
}

.login-card .subtitle {
  margin: 0 0 1.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.form-group {
  margin-bottom: 1.1rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.form-group input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61, 139, 253, 0.2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-dim);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.alert {
  margin-top: 1rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  display: none;
}

.alert.show {
  display: block;
}

.alert-error {
  background: rgba(244, 113, 122, 0.12);
  border: 1px solid rgba(244, 113, 122, 0.35);
  color: #ffb3b9;
}

/* Dashboard */
.dashboard {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar h1 i {
  color: var(--accent);
  font-size: 1.05rem;
}

.topbar-user {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  background: rgba(61, 214, 140, 0.15);
  color: var(--success);
  border: 1px solid rgba(61, 214, 140, 0.3);
}

.btn-ghost {
  width: auto;
  padding: 0.45rem 0.9rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 0.875rem;
  font-weight: 500;
}

.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.dashboard-main {
  flex: 1;
  padding: 1.25rem 1.5rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  padding: 0.25rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: fit-content;
}

.tabs button {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.tabs button:hover {
  color: var(--text);
}

.tabs button.active {
  background: var(--accent);
  color: #fff;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

/* ── Toolbar card (light tone) ──────────────────────────────────────────── */
.toolbar-card {
  background: #ffffff;
  border: 1px solid #d4dde8;
  border-radius: calc(var(--radius) + 2px);
  padding: 0.85rem 1.1rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.toolbar-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.toolbar-row-top {
  gap: 0.75rem;
}

/* Search box */
.search-box {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 0.85rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.6rem 0.85rem 0.6rem 2.25rem;
  border: 1.5px solid #d4dde8;
  border-radius: 8px;
  background: #f8fafc;
  color: #1e293b;
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input::placeholder {
  color: #94a3b8;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(61, 139, 253, 0.15);
}

/* Refresh button */
.btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s;
}

.btn-refresh:hover  { background: var(--accent-dim); }
.btn-refresh:active { transform: scale(0.97); }

/* Page size select */
.page-size-field {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: #475569;
  font-weight: 500;
  white-space: nowrap;
}

.select-ctrl {
  padding: 0.38rem 0.6rem;
  border: 1.5px solid #d4dde8;
  border-radius: 7px;
  background: #f8fafc;
  color: #1e293b;
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.select-ctrl:focus {
  outline: none;
  border-color: var(--accent);
}

/* Pager */
.pager {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
  flex-wrap: wrap;
}

.pager-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.38rem 0.8rem;
  border: 1.5px solid #d4dde8;
  border-radius: 7px;
  background: #f8fafc;
  color: #334155;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.pager-btn:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.pager-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pager-info {
  font-size: 0.82rem;
  color: #475569;
  font-weight: 500;
  padding: 0 0.35rem;
  white-space: nowrap;
}

/* Legacy compat */
.btn-ghost:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { width: auto; padding: 0.45rem 0.85rem; font-size: 0.875rem; }

.status-loading i,
.status-empty i,
.status-error i {
  margin-right: 0.4rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

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

thead {
  background: linear-gradient(to bottom, #1e2d42, #1a2332);
  border-bottom: 2px solid var(--accent);
}

th,
td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  max-width: 240px;
  word-break: break-word;
}

th {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 0.9rem;
  padding-bottom: 0.9rem;
}

tbody tr:hover {
  background: rgba(61, 139, 253, 0.06);
}

tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.018);
}

tbody tr:nth-child(even):hover {
  background: rgba(61, 139, 253, 0.06);
}

/* Sort button */
.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
  transition: color 0.15s;
}
.sort-btn:hover {
  color: var(--text);
}
.sort-icon {
  font-size: 0.65rem;
  opacity: 0.4;
  transition: opacity 0.15s;
}
.sort-btn:hover .sort-icon {
  opacity: 1;
}

/* STT column */
.col-stt {
  width: 3rem;
  min-width: 3rem;
  text-align: center;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.status-loading,
.status-empty,
.status-error {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}

.status-error {
  color: var(--danger);
}

.mono {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.78rem;
}

@media (max-width: 640px) {
  th,
  td {
    max-width: 140px;
    font-size: 0.72rem;
  }
}

/* Sign-up method badge */

/* ── Payment status badges ───────────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25em 0.75em;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-completed { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.badge-failed    { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.badge-pending   { background: #fef9c3; color: #854d0e; border: 1px solid #fde68a; }
.badge-unknown   { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }

.method-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.method-google {
  background: rgba(61, 139, 253, 0.12);
  color: #3d8bfd;
  border: 1px solid rgba(61, 139, 253, 0.3);
}
.method-facebook {
  background: rgba(24, 119, 242, 0.12);
  color: #1877f2;
  border: 1px solid rgba(24, 119, 242, 0.3);
}
.method-email {
  background: rgba(251, 191, 36, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(251, 191, 36, 0.3);
}
.method-phone {
  background: rgba(61, 214, 140, 0.12);
  color: #3dd68c;
  border: 1px solid rgba(61, 214, 140, 0.3);
}
.method-other {
  background: rgba(139, 156, 179, 0.1);
  color: #8b9cb3;
  border: 1px solid rgba(139, 156, 179, 0.25);
}

/* ── Export button ──────────────────────────────────────────────────────────── */
.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.9rem;
  border: 1.5px solid #1d7a3e;
  border-radius: var(--radius);
  background: #f0fdf4;
  color: #166534;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, box-shadow 0.15s;
}
.btn-export:hover {
  background: #dcfce7;
  box-shadow: 0 2px 6px rgba(22, 101, 52, 0.15);
}

/* ── Modal overlay ──────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  backdrop-filter: blur(2px);
}
.modal-overlay[hidden] { display: none; }

.modal-box {
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  animation: modal-in 0.2s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(-18px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem 0.9rem;
  border-bottom: 1px solid #e5eaf0;
  background: #f8fafc;
}
.modal-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #166534;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.modal-close {
  border: none;
  background: transparent;
  color: #6b7280;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  transition: background 0.15s;
}
.modal-close:hover { background: #f1f5f9; color: #111; }

.modal-body {
  padding: 1.4rem 1.4rem 0.6rem;
}
.modal-desc {
  font-size: 0.88rem;
  color: #374151;
  margin: 0 0 1.1rem;
  font-weight: 500;
}

.date-range-row {
  display: flex;
  align-items: flex-end;
  gap: 0.7rem;
}
.date-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.date-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.date-input {
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  font-size: 0.9rem;
  color: #111827;
  background: #fff;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.date-input:focus {
  outline: none;
  border-color: #166534;
  box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.12);
}

.date-range-sep {
  color: #9ca3af;
  font-size: 0.9rem;
  padding-bottom: 0.55rem;
  flex-shrink: 0;
}

.modal-hint {
  margin: 0.9rem 0 0;
  font-size: 0.78rem;
  color: #6b7280;
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
}
.modal-hint i { margin-top: 2px; color: #3b82f6; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 0.9rem 1.4rem 1.1rem;
  border-top: 1px solid #e5eaf0;
  background: #f8fafc;
}
.btn { padding: 0.5rem 1.1rem; border-radius: 8px; font-size: 0.875rem; font-weight: 600; cursor: pointer; border: none; transition: background 0.15s, box-shadow 0.15s; }
.btn-ghost { background: #f1f5f9; color: #374151; border: 1.5px solid #d1d5db; }
.btn-ghost:hover { background: #e2e8f0; }
.btn-primary { background: #166534; color: #fff; display: inline-flex; align-items: center; gap: 0.4rem; }
.btn-primary:hover { background: #15803d; box-shadow: 0 4px 12px rgba(22, 101, 52, 0.25); }
.btn-primary:disabled { background: #9ca3af; cursor: not-allowed; box-shadow: none; }
