:root {
  --bg:          #080b14;
  --card:        rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.08);
  --accent:      #00d4ff;
  --text:        #e8eaf6;
  --text-muted:  #6b7280;
  --error:       #ff4466;
  --success:     #22c55e;
  --warning:     #f59e0b;
  --radius:      14px;
  --radius-sm:   10px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 800;
}
.header-brand { display: flex; align-items: center; gap: 10px; }
.header-brand img { border-radius: 50%; }
.app-header h1 { font-size: 18px; font-weight: 700; }
.btn-logoff {
  background: transparent;
  border: 1px solid #fb923c;
  color: #fb923c;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-logoff:hover { background: rgba(251, 146, 60, 0.1); }

/* ── Screens ── */
.screen {
  display: none;
  flex-direction: column;
  padding: 16px 16px 90px;
  min-height: calc(100vh - 65px);
}
.screen.active { display: flex; }

/* ── Inputs ── */
.input {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--text-muted); }
.input-date { width: 140px; }

/* ── Buttons ── */
.btn-primary {
  background: linear-gradient(135deg, #00b8d9, #0088cc);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  white-space: nowrap;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.btn-secondary:hover { border-color: rgba(255, 255, 255, 0.2); }
.btn-chip {
  background: var(--card);
  color: var(--text-muted);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-chip:hover { border-color: rgba(255, 255, 255, 0.2); color: var(--text); }
.btn-chip.active {
  background: rgba(0, 212, 255, 0.12);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Filter Bar ── */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  align-items: center;
}
.filter-bar-dates { margin-bottom: 16px; }
.filter-search { flex: 1; min-width: 140px; }
.filter-select { min-width: 130px; }
.dates-row { display: flex; align-items: center; gap: 8px; }
.date-sep { font-size: 13px; color: var(--text-muted); }
.quick-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-novo { display: flex; align-items: center; gap: 6px; }
.btn-novo svg { width: 16px; height: 16px; }
.btn-filtrar { margin-left: auto; }
.list-counter {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color 0.2s;
}
.card:hover { border-color: rgba(255, 255, 255, 0.15); }

/* ── Cupom Card ── */
.cupom-card { display: flex; flex-direction: column; gap: 12px; }
.cupom-card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cupom-codigo {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--accent);
  font-family: 'Courier New', monospace;
}
.btn-copy {
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.25);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
.btn-copy:hover { background: rgba(0, 212, 255, 0.2); }
.cupom-card-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.cupom-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cupom-stat-value { font-size: 18px; font-weight: 700; }
.cupom-stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }

/* ── Indicado Card ── */
.indicado-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
}
.indicado-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.indicado-nome { font-size: 15px; font-weight: 600; }
.indicado-email { font-size: 13px; color: var(--text-muted); word-break: break-all; }
.indicado-cupom {
  font-size: 12px;
  color: var(--accent);
  font-family: 'Courier New', monospace;
  opacity: 0.8;
}
.indicado-card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.indicado-data { font-size: 12px; color: var(--text-muted); }
.indicado-valor { font-size: 13px; font-weight: 600; color: var(--success); }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-cadastro { background: rgba(107, 114, 128, 0.15); color: var(--text-muted); }
.badge-compra  { background: rgba(0, 212, 255, 0.12); color: var(--accent); }
.badge-pago    { background: rgba(34, 197, 94, 0.15); color: var(--success); }

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; opacity: 0.35; }
.empty-state p { font-size: 16px; font-weight: 600; color: var(--text); opacity: 0.6; }
.empty-state span { font-size: 13px; }

/* ── Lists ── */
.cupons-list,
.usuarios-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Loading ── */
.skeleton-card {
  height: 100px;
  background: linear-gradient(90deg, var(--card) 25%, rgba(255, 255, 255, 0.08) 50%, var(--card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ── Stats Filter ── */
.stats-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
}

/* ── Stats Cards ── */
.stats-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-value { font-size: 24px; font-weight: 700; }
.stat-money { color: var(--success); }

/* ── Stats Tables ── */
.stats-section { margin-bottom: 24px; }
.stats-section-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-left: 2px;
}
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.stats-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  font-size: 14px;
}
.stats-table th {
  text-align: left;
  padding: 12px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--card-border);
}
.stats-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--card-border);
}
.stats-table tbody tr:last-child td { border-bottom: none; }
.stats-table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.table-empty td {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 14px;
}

/* ── Modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-backdrop.open {
  display: flex;
}
.modal-backdrop.open .modal-dialog {
  transform: scale(1);
  opacity: 1;
}
.modal-dialog {
  background: #0f1420;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  opacity: 0;
  transition: transform 0.2s, opacity 0.2s;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--card-border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.modal-body { padding: 20px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--card-border);
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}
.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}
.modal-body .input { width: 100%; }

/* ── Detalhe Indicado Modal ── */
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--card-border);
  font-size: 14px;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text-muted); }
.detail-value { font-weight: 600; text-align: right; }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a1f2e;
  color: var(--text);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 2000;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Bottom Nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: #0a0f1a;
  border-top: 1px solid var(--card-border);
  padding: 8px 0;
  padding-bottom: env(safe-area-inset-bottom, 8px);
  z-index: 900;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  transition: color 0.2s;
}
.nav-btn.active { color: var(--accent); }
.nav-btn svg { width: 22px; height: 22px; }

/* ── Responsivo ── */
@media (min-width: 768px) {
  .cupons-list   { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .usuarios-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .stats-cards   { grid-template-columns: repeat(3, 1fr); }
  .modal-dialog  { max-width: 500px; }
}
@media (min-width: 1024px) {
  .cupons-list   { grid-template-columns: repeat(3, 1fr); }
  .usuarios-list { grid-template-columns: repeat(3, 1fr); }
  .stats-cards   { grid-template-columns: repeat(5, 1fr); }
  .screen        { padding: 20px 24px 90px; }
}
