/* =============================================================
   Zappify — Design System
   Fonte: DM Sans (display) + DM Mono (code)
   Tema: Dark profissional com accent verde-esmeralda
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

/* --- Reset & Variables --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f172a;
  --bg2:       #1e293b;
  --bg3:       #334155;
  --surface:   #1e293b;
  --border:    rgba(255,255,255,.08);
  --border2:   rgba(255,255,255,.14);
  --text:      #f1f5f9;
  --text2:     #94a3b8;
  --text3:     #64748b;
  --accent:    #10b981;
  --accent2:   #059669;
  --accent-bg: rgba(16,185,129,.12);
  --danger:    #ef4444;
  --warn:      #f59e0b;
  --info:      #3b82f6;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
  --font:      'DM Sans', system-ui, sans-serif;
  --mono:      'DM Mono', monospace;
  --nav-h:     60px;
  --sidebar-w: 240px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 3px; }

/* =============================================================
   AUTH PAGES
   ============================================================= */
.auth-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}

.auth-logo-mark {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 600; color: #fff;
}

.auth-logo-text { font-size: 20px; font-weight: 600; color: var(--text); }

.auth-title    { font-size: 22px; font-weight: 600; margin-bottom: 6px; }
.auth-subtitle { font-size: 14px; color: var(--text2); margin-bottom: 28px; }

/* =============================================================
   LAYOUT
   ============================================================= */
#app { display: flex; min-height: 100dvh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo-mark {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 600; color: #fff;
  flex-shrink: 0;
}

.sidebar-logo-text { font-size: 17px; font-weight: 600; }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }

.nav-section { font-size: 10px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .08em; padding: 12px 10px 4px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px; font-weight: 400;
  color: var(--text2);
  transition: background .15s, color .15s;
  position: relative;
  text-decoration: none;
  margin-bottom: 1px;
}

.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent-bg); color: var(--accent); font-weight: 500; }

.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px; font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
}

.sidebar-user:hover { background: var(--bg3); }

.avatar {
  width: 32px; height: 32px;
  background: var(--accent-bg);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: var(--accent);
  flex-shrink: 0;
}

.sidebar-user-info { overflow: hidden; }
.sidebar-user-name  { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role  { font-size: 11px; color: var(--text3); }

/* Overlay mobile */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}

/* Main */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* Top bar */
.topbar {
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 50;
}

.topbar-title { font-size: 16px; font-weight: 600; flex: 1; }

.topbar-menu-btn {
  display: none;
  background: none; border: none; cursor: pointer;
  color: var(--text2); padding: 4px;
}

/* Content */
.content { flex: 1; padding: 24px 20px; max-width: 1200px; width: 100%; }

/* =============================================================
   COMPONENTS
   ============================================================= */

/* Onboarding banner */
.onboarding-banner {
  background: linear-gradient(135deg, rgba(16,185,129,.15), rgba(16,185,129,.05));
  border: 1px solid rgba(16,185,129,.3);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 24px;
}

.onboarding-banner svg { color: var(--accent); flex-shrink: 0; }
.onboarding-banner-text { flex: 1; font-size: 14px; }
.onboarding-banner-text strong { display: block; font-size: 15px; margin-bottom: 2px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}

.card-title { font-size: 15px; font-weight: 600; }
.card-subtitle { font-size: 13px; color: var(--text2); margin-top: 2px; }

/* Metric cards */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.metric-label { font-size: 12px; color: var(--text2); font-weight: 500; margin-bottom: 6px; }
.metric-value { font-size: 28px; font-weight: 600; line-height: 1; }
.metric-sub   { font-size: 12px; color: var(--text3); margin-top: 4px; }
.metric-card.accent { border-color: rgba(16,185,129,.3); background: var(--accent-bg); }
.metric-card.accent .metric-value { color: var(--accent); }

/* Progress bar */
.progress-wrap { margin-top: 6px; }
.progress-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text2); margin-bottom: 4px; }
.progress-bar   { height: 4px; background: var(--bg3); border-radius: 2px; overflow: hidden; }
.progress-fill  { height: 100%; background: var(--accent); border-radius: 2px; transition: width .4s; }
.progress-fill.warn { background: var(--warn); }
.progress-fill.danger { background: var(--danger); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 14px; font-weight: 500; font-family: var(--font);
  cursor: pointer; border: none; text-decoration: none;
  transition: background .15s, opacity .15s, transform .1s;
}

.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-secondary { background: var(--bg3); color: var(--text); }
.btn-secondary:hover { background: #475569; }
.btn-outline { background: transparent; border: 1px solid var(--border2); color: var(--text2); }
.btn-outline:hover { background: var(--bg3); color: var(--text); }
.btn-danger { background: rgba(239,68,68,.15); color: var(--danger); border: 1px solid rgba(239,68,68,.3); }
.btn-danger:hover { background: rgba(239,68,68,.25); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon { padding: 8px; border-radius: var(--radius); }
.btn-full { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text2); margin-bottom: 6px; }
.form-label span { color: var(--danger); margin-left: 2px; }

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px; font-family: var(--font);
  color: var(--text);
  transition: border-color .15s;
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(16,185,129,.15);
}

.form-input::placeholder, .form-textarea::placeholder { color: var(--text3); }
.form-textarea { resize: vertical; min-height: 100px; }
.form-select { appearance: none; cursor: pointer; }
.form-select option { background: var(--bg2); }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.form-hint  { font-size: 12px; color: var(--text3); margin-top: 4px; }

/* Toggle */
.toggle-wrap { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle-input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 40px; height: 22px;
  background: var(--bg3);
  border-radius: 11px;
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}
.toggle-input:checked + .toggle-track { background: var(--accent); }
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.toggle-input:checked + .toggle-track::after { transform: translateX(18px); }
.toggle-label { font-size: 14px; color: var(--text); }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .05em; padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover td { background: rgba(255,255,255,.02); }
tbody tr:last-child td { border-bottom: none; }

/* Badges */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 12px; font-weight: 500;
}
.badge-green  { background: rgba(16,185,129,.15); color: #10b981; }
.badge-yellow { background: rgba(245,158,11,.15);  color: #f59e0b; }
.badge-red    { background: rgba(239,68,68,.15);   color: #ef4444; }
.badge-blue   { background: rgba(59,130,246,.15);  color: #3b82f6; }
.badge-gray   { background: rgba(100,116,139,.15); color: #94a3b8; }

/* Alert */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 14px; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.alert svg { flex-shrink: 0; margin-top: 1px; }
.alert-success { background: rgba(16,185,129,.1);  border: 1px solid rgba(16,185,129,.25); color: #6ee7b7; }
.alert-error   { background: rgba(239,68,68,.1);   border: 1px solid rgba(239,68,68,.25);  color: #fca5a5; }
.alert-warn    { background: rgba(245,158,11,.1);  border: 1px solid rgba(245,158,11,.25); color: #fde68a; }
.alert-info    { background: rgba(59,130,246,.1);  border: 1px solid rgba(59,130,246,.25); color: #93c5fd; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
  animation: fadeIn .15s;
}

@media (min-width: 640px) {
  .modal-overlay { align-items: center; padding: 24px; }
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%; max-width: 540px;
  max-height: 92dvh;
  overflow-y: auto;
  animation: slideUp .2s cubic-bezier(.4,0,.2,1);
}

@media (min-width: 640px) {
  .modal { border-radius: var(--radius-lg); animation: scaleIn .18s; }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-title  { font-size: 16px; font-weight: 600; }
.modal-body   { padding: 20px 24px; }
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* Voucher display */
.voucher-card {
  background: var(--bg);
  border: 2px dashed var(--border2);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
}

.voucher-code {
  font-family: var(--mono);
  font-size: 28px; font-weight: 500;
  letter-spacing: .15em;
  color: var(--accent);
  margin: 12px 0;
}

.voucher-status-valid    { color: var(--accent); }
.voucher-status-redeemed { color: var(--text3); }
.voucher-status-expired  { color: var(--danger); }

/* Toast */
.toast-container {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column-reverse; gap: 8px;
  z-index: 999;
}

.toast {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  min-width: 260px; max-width: 360px;
  animation: slideInRight .2s;
  display: flex; gap: 10px; align-items: center;
}

.toast-success { border-color: rgba(16,185,129,.4); }
.toast-error   { border-color: rgba(239,68,68,.4); }

/* Setup steps */
.setup-steps { display: flex; flex-direction: column; gap: 12px; }
.setup-step {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s;
}
.setup-step:hover { border-color: var(--border2); }
.setup-step.done  { border-color: rgba(16,185,129,.3); }
.setup-step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  flex-shrink: 0;
}
.setup-step.done .setup-step-num { background: var(--accent-bg); color: var(--accent); }
.setup-step-info { flex: 1; }
.setup-step-title { font-size: 14px; font-weight: 500; }
.setup-step-desc  { font-size: 12px; color: var(--text2); margin-top: 2px; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text3);
}
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 16px; opacity: .4; }
.empty-state h3  { font-size: 16px; color: var(--text2); margin-bottom: 6px; }
.empty-state p   { font-size: 14px; }

/* Tenant selector */
.tenant-grid { display: flex; flex-direction: column; gap: 10px; }
.tenant-btn {
  display: flex; align-items: center; gap: 14px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-align: left; width: 100%;
  font-family: var(--font);
  transition: border-color .15s, background .15s;
}
.tenant-btn:hover { border-color: var(--accent); background: var(--accent-bg); }
.tenant-icon {
  width: 40px; height: 40px;
  background: var(--accent-bg);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 600; color: var(--accent);
  flex-shrink: 0;
}

/* =============================================================
   ANIMATIONS
   ============================================================= */
@keyframes fadeIn     { from { opacity: 0 }         to { opacity: 1 } }
@keyframes slideUp    { from { transform: translateY(40px); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes scaleIn    { from { transform: scale(.95); opacity: 0 }       to { transform: none; opacity: 1 } }
@keyframes slideInRight { from { transform: translateX(20px); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes spin       { to { transform: rotate(360deg) } }

.spin { animation: spin .8s linear infinite; }
.fade-in { animation: fadeIn .2s; }

/* =============================================================
   RESPONSIVE
   ============================================================= */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: none;
  }
  .sidebar-overlay.open {
    display: block;
  }
  .main {
    margin-left: 0;
  }
  .topbar-menu-btn {
    display: flex;
  }
  .content {
    padding: 16px;
  }
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .modal-footer {
    flex-direction: column;
  }
  .modal-footer .btn {
    width: 100%;
  }
  .toast-container {
    left: 12px; right: 12px; bottom: 12px;
  }
  .toast { min-width: unset; width: 100%; }
}

@media (max-width: 480px) {
  .metrics-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-value { font-size: 22px; }
  .auth-card { padding: 28px 20px; }
}

/* =============================================================
   UTILITY
   ============================================================= */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-muted { color: var(--text2); }
.text-faint { color: var(--text3); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-mono { font-family: var(--mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.page-title { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.page-subtitle { font-size: 14px; color: var(--text2); margin-bottom: 24px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.col-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 480px) { .col-2 { grid-template-columns: 1fr; } }

/* --- Google OAuth button --- */
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 10px 18px;
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
}
.btn-google:hover {
  background: #f8f9fa;
  box-shadow: 0 1px 6px rgba(0,0,0,.2);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text3);
  font-size: 12px;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
