/* =============================================
   TRUFASPAY — DESIGN SYSTEM
   ============================================= */

:root {
  --primary:        #7C3AED;
  --primary-dark:   #5B21B6;
  --primary-darker: #4C1D95;
  --primary-light:  #EDE9FE;
  --primary-mid:    #DDD6FE;

  --amber:          #D97706;
  --amber-light:    #FFFBEB;
  --amber-mid:      #FDE68A;

  --green:          #059669;
  --green-light:    #ECFDF5;
  --green-mid:      #A7F3D0;

  --red:            #DC2626;
  --red-light:      #FEF2F2;
  --red-mid:        #FECACA;

  --blue:           #2563EB;
  --blue-light:     #EFF6FF;
  --blue-mid:       #BFDBFE;

  --gray-50:        #F9FAFB;
  --gray-100:       #F3F4F6;
  --gray-200:       #E5E7EB;
  --gray-300:       #D1D5DB;
  --gray-400:       #9CA3AF;
  --gray-500:       #6B7280;
  --gray-700:       #374151;
  --gray-800:       #1F2937;
  --gray-900:       #111827;

  --bg-page:        #F5F3FF;
  --bg-card:        #FFFFFF;
  --text-main:      #1F2937;
  --text-sub:       #6B7280;
  --border:         #E5E7EB;

  --shadow-sm:      0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg:      0 10px 30px rgba(0,0,0,0.12);
  --shadow-purple:  0 4px 20px rgba(124,58,237,0.3);

  --radius-sm:      8px;
  --radius-md:      12px;
  --radius-lg:      16px;
  --radius-xl:      20px;
  --radius-full:    9999px;

  --header-h:       56px;
  --nav-h:          64px;
  --content-pad:    16px;

  --transition:     0.2s ease;
}

/* =============================================
   RESET & BASE
   ============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  overscroll-behavior: none;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; }
img, svg { display: block; }

/* =============================================
   LAYOUT
   ============================================= */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

/* Header */
#app-header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--header-h);
  background: linear-gradient(135deg, var(--primary-darker) 0%, var(--primary) 100%);
  display: flex;
  align-items: center;
  padding: 0 8px;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(92,33,182,0.4);
}

.header-back {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: rgba(255,255,255,0.9);
  transition: background var(--transition);
  flex-shrink: 0;
}
.header-back:hover { background: rgba(255,255,255,0.15); }
.header-back.hidden { visibility: hidden; pointer-events: none; }

.header-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.header-logo-icon {
  width: 28px;
  height: 28px;
  background: rgba(255,255,255,0.15);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

#header-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.header-right {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Desktop top navigation (hidden on mobile, shown via media query) */
.desktop-nav {
  display: none;
  align-items: center;
  gap: 8px;
}
.desktop-nav .nav-item {
  flex-direction: row;
  height: auto;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  color: rgba(255,255,255,0.75);
  transition: background var(--transition), color var(--transition);
}
.desktop-nav .nav-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.desktop-nav .nav-item.active { background: rgba(255,255,255,0.18); color: #fff; }
.desktop-nav .nav-item.active svg { transform: none; }
.desktop-nav .btn-primary {
  background: #fff;
  color: var(--primary-dark);
  box-shadow: none;
}
.desktop-nav .btn-primary:hover { background: var(--primary-light); box-shadow: none; }

/* Main Content */
#main-content {
  margin-top: var(--header-h);
  margin-bottom: var(--nav-h);
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Pages */
.page {
  display: none;
  min-height: calc(100vh - var(--header-h) - var(--nav-h));
  padding: var(--content-pad);
  padding-bottom: calc(var(--content-pad) + 8px);
  animation: pageIn 0.2s ease;
}
.page.active { display: block; }

@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Bottom Navigation */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-h);
  background: #fff;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 72px 1fr;
  align-items: center;
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 100%;
  color: var(--gray-400);
  font-size: 11px;
  font-weight: 500;
  transition: color var(--transition);
  padding: 0 4px;
}
.nav-item svg { transition: transform var(--transition); }
.nav-item.active { color: var(--primary); }
.nav-item.active svg { transform: scale(1.1); }
.nav-spacer { height: 100%; }

/* FAB */
#fab {
  position: fixed;
  bottom: calc(var(--nav-h) - 28px);
  left: 50%;
  transform: translateX(-50%);
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-purple);
  z-index: 101;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#fab:hover { transform: translateX(-50%) scale(1.05); }
#fab:active { transform: translateX(-50%) scale(0.95); }

/* =============================================
   DASHBOARD
   ============================================= */
.dashboard-greeting {
  margin-bottom: 20px;
}
.dashboard-greeting h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}
.dashboard-greeting p {
  font-size: 13px;
  color: var(--text-sub);
  margin-top: 2px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-card.highlight {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-color: transparent;
  box-shadow: var(--shadow-purple);
}

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 4px;
}

.stat-card.highlight .stat-icon { background: rgba(255,255,255,0.2); }
.stat-icon.green { background: var(--green-light); }
.stat-icon.red   { background: var(--red-light); }
.stat-icon.blue  { background: var(--blue-light); }
.stat-icon.amber { background: var(--amber-light); }

.stat-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1;
}
.stat-card.highlight .stat-value { color: #fff; }

.stat-label {
  font-size: 12px;
  color: var(--text-sub);
  font-weight: 500;
}
.stat-card.highlight .stat-label { color: rgba(255,255,255,0.8); }

.stat-value.value-green  { color: var(--green); }
.stat-value.value-red    { color: var(--red); }
.stat-value.value-blue   { color: var(--blue); }
.stat-value.value-amber  { color: var(--amber); }

.dashboard-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}

.dashboard-action-btn { flex: 1; }

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-title a {
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
}

/* =============================================
   SALE CARDS
   ============================================= */
.sale-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border);
  margin-bottom: 12px;
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-sm);
}
.sale-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.sale-card.overdue {
  border-left: 3px solid var(--red);
}

.card-top {
  display: flex;
  align-items: flex-start;
  padding: 14px 14px 0;
  gap: 10px;
}

.card-checkbox {
  margin-top: 2px;
  flex-shrink: 0;
}
.card-checkbox input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--primary);
  border-radius: 4px;
}

.card-main {
  flex: 1;
  min-width: 0;
}

.card-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.client-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-pendente { background: var(--blue-light);  color: var(--blue);  }
.badge-atrasado { background: var(--red-light);   color: var(--red);   }
.badge-cobrado  { background: var(--amber-light);  color: var(--amber); }
.badge-pago     { background: var(--green-light); color: var(--green); }

.card-phone {
  font-size: 13px;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-delete {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  border-radius: var(--radius-full);
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.card-delete:hover { background: var(--red-light); color: var(--red); }

.card-body {
  padding: 10px 14px 0;
}

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

.product-info {
  font-size: 13px;
  color: var(--text-sub);
}
.product-info strong { color: var(--gray-800); }

.product-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--amber);
}

.card-due {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-sub);
  margin-bottom: 4px;
}
.card-due.overdue { color: var(--red); font-weight: 600; }

.card-obs {
  font-size: 12px;
  color: var(--text-sub);
  font-style: italic;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  margin-bottom: 4px;
}

.card-dates-meta {
  font-size: 11px;
  color: var(--gray-400);
  margin-bottom: 4px;
}

.card-actions {
  display: flex;
  gap: 6px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--gray-100);
  margin-top: 10px;
  flex-wrap: wrap;
}

/* Mini card for dashboard recent list */
.sale-card-mini {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: box-shadow var(--transition);
}
.sale-card-mini:hover { box-shadow: var(--shadow-md); }

.mini-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}

.mini-info { flex: 1; min-width: 0; }
.mini-name { font-size: 14px; font-weight: 600; color: var(--gray-900); }
.mini-product { font-size: 12px; color: var(--text-sub); }

.mini-right { text-align: right; flex-shrink: 0; }
.mini-value { font-size: 15px; font-weight: 700; color: var(--amber); }
.mini-date  { font-size: 11px; color: var(--text-sub); }

/* =============================================
   FILTER BAR
   ============================================= */
.filter-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 0 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }

.filter-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text-sub);
  transition: all var(--transition);
  flex-shrink: 0;
}
.filter-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.filter-btn .f-count {
  background: rgba(0,0,0,0.12);
  color: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
}
.filter-btn.active .f-count { background: rgba(255,255,255,0.25); }

/* Selection Quick Bar */
.quick-select-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

/* Bulk Actions Bar */
.bulk-actions-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--primary-dark);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-purple);
  transition: all 0.3s ease;
}
.bulk-actions-bar.hidden { display: none; }
.bulk-label {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
}
.bulk-btns { display: flex; gap: 6px; }

/* =============================================
   FORM
   ============================================= */
.form-page-content {
  max-width: 480px;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.form-label .required { color: var(--red); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 15px;
  color: var(--gray-900);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-control::placeholder { color: var(--gray-400); }
.form-control:disabled {
  background: var(--gray-50);
  color: var(--gray-500);
  cursor: not-allowed;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-control-textarea {
  min-height: 80px;
  resize: vertical;
}

.total-display {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-mid) 100%);
  border: 1.5px solid var(--primary-mid);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  margin-bottom: 8px;
}
.total-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.total-value {
  font-size: 28px;
  font-weight: 900;
  color: var(--primary-dark);
}

.form-hint {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 4px;
}

/* =============================================
   BUTTONS
   ============================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  white-space: nowrap;
  min-height: 44px;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(124,58,237,0.35);
}
.btn-primary:hover { box-shadow: 0 4px 16px rgba(124,58,237,0.45); }

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
}
.btn-secondary:hover { background: var(--gray-200); }

.btn-success {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(5,150,105,0.3);
}
.btn-success:hover { box-shadow: 0 4px 12px rgba(5,150,105,0.4); }

.btn-danger {
  background: var(--red-light);
  color: var(--red);
}
.btn-danger:hover { background: var(--red-mid); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }

.btn-whatsapp {
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,211,102,0.3);
}
.btn-whatsapp:hover { box-shadow: 0 4px 12px rgba(37,211,102,0.45); }

.btn-ghost {
  background: transparent;
  color: var(--primary);
  padding: 8px 12px;
  font-size: 13px;
}

.btn-text-danger {
  background: transparent;
  color: var(--red);
  font-size: 14px;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
  min-height: 36px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 15px 24px;
  font-size: 16px;
  border-radius: var(--radius-lg);
  min-height: 54px;
  width: 100%;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.85);
  transition: background var(--transition);
}
.btn-icon:hover { background: rgba(255,255,255,0.15); }

.btn-block { width: 100%; }

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* =============================================
   QUEUE MODAL
   ============================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  transition: opacity 0.3s ease;
}
.modal-overlay.hidden { display: none; }

.modal-sheet {
  background: #fff;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  max-height: 92vh;
  overflow-y: auto;
  animation: sheetUp 0.35s ease;
}

@keyframes sheetUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

.queue-handle {
  width: 40px;
  height: 4px;
  background: var(--gray-300);
  border-radius: var(--radius-full);
  margin: 12px auto 0;
}

.queue-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 8px;
}
.queue-title { font-size: 17px; font-weight: 700; color: var(--gray-900); }
.queue-progress-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.queue-progress-wrap {
  padding: 0 20px 16px;
}
.progress-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.queue-client-card {
  margin: 0 20px 16px;
  background: var(--primary-light);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.queue-avatar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.queue-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  flex-shrink: 0;
}

.queue-client-name { font-size: 18px; font-weight: 700; color: var(--gray-900); }
.queue-client-phone { font-size: 13px; color: var(--text-sub); }

.queue-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.queue-detail-item {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 10px;
}
.queue-detail-label { font-size: 11px; color: var(--text-sub); font-weight: 500; margin-bottom: 2px; }
.queue-detail-value { font-size: 15px; font-weight: 700; color: var(--gray-900); }
.queue-detail-value.value-big {
  font-size: 20px;
  color: var(--amber);
}

.queue-message-box {
  margin: 0 20px 16px;
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
}
.message-box-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.message-preview {
  font-size: 13px;
  color: var(--gray-700);
  line-height: 1.6;
  white-space: pre-line;
}

.queue-actions-wrap {
  padding: 0 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.queue-secondary-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* =============================================
   CONFIRM DIALOG
   ============================================= */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(3px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.confirm-overlay.hidden { display: none; }

.confirm-box {
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 24px;
  width: 100%;
  max-width: 340px;
  animation: popIn 0.2s ease;
}

@keyframes popIn {
  from { transform: scale(0.9); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.confirm-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin: 0 auto 16px;
  background: var(--red-light);
}
.confirm-icon.success { background: var(--green-light); }

.confirm-title {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  color: var(--gray-900);
  margin-bottom: 8px;
}
.confirm-message {
  font-size: 14px;
  color: var(--text-sub);
  text-align: center;
  line-height: 1.6;
  margin-bottom: 20px;
}
.confirm-btns {
  display: flex;
  gap: 10px;
}

/* =============================================
   TOAST NOTIFICATIONS
   ============================================= */
#toast-container {
  position: fixed;
  top: calc(var(--header-h) + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 448px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.toast {
  background: var(--gray-800);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateY(-8px);
  transition: all 0.3s ease;
  pointer-events: all;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.toast-success { background: var(--green); }
.toast.toast-error   { background: var(--red); }
.toast.toast-warning { background: var(--amber); }
.toast.toast-info    { background: var(--blue); }

/* =============================================
   EMPTY STATES
   ============================================= */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-sub);
}
.empty-icon {
  font-size: 56px;
  margin-bottom: 16px;
  line-height: 1;
}
.empty-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 8px;
}
.empty-text {
  font-size: 14px;
  color: var(--text-sub);
  margin-bottom: 24px;
  line-height: 1.6;
}

/* =============================================
   INSTALL BANNER
   ============================================= */
.install-banner {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  color: #fff;
}
.install-banner.hidden { display: none; }
.install-banner-text { flex: 1; font-size: 13px; }
.install-banner-text strong { display: block; font-size: 14px; }

/* =============================================
   IOS INSTALL BANNER
   ============================================= */
.ios-install-banner {
  position: fixed;
  bottom: var(--nav-h);
  left: 0;
  right: 0;
  background: linear-gradient(135deg, var(--primary-darker) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 9998;
  box-shadow: 0 -3px 16px rgba(0,0,0,0.22);
}
.ios-install-banner.hidden { display: none !important; }
.ios-install-text {
  flex: 1;
  font-size: 13px;
  line-height: 1.45;
}
.ios-install-close {
  flex-shrink: 0;
  background: rgba(255,255,255,0.18);
  border: 1.5px solid rgba(255,255,255,0.4);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* =============================================
   HELPERS
   ============================================= */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.gap-8  { gap: 8px; }

.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* =============================================
   SCROLLBAR (webkit)
   ============================================= */
#main-content::-webkit-scrollbar { width: 0; }

/* =============================================
   RESPONSIVE (wider screens)
   ============================================= */
@media (min-width: 480px) {
  #app-header, #bottom-nav, #fab { max-width: 480px; }

  .form-row { grid-template-columns: 1fr 1fr; }

  .modal-sheet { border-radius: var(--radius-xl); margin-bottom: 20px; max-height: 85vh; }
  .modal-overlay { align-items: center; }
}

@media (min-width: 768px) and (max-width: 1023px) {
  body { background: var(--primary-darker); }
  #app {
    box-shadow: var(--shadow-lg);
    min-height: 100vh;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* =============================================
   DESKTOP LAYOUT (1024px+)
   ============================================= */
@media (min-width: 1024px) {
  :root {
    --header-h: 72px;
    --nav-h: 0px;
    --content-pad: 32px;
  }

  body {
    background: #F3F4F6;
  }

  #app {
    max-width: 1280px;
    box-shadow: none;
  }

  /* Header stays purple — the only "full bleed" roxo element on desktop */
  #app-header {
    max-width: 1280px;
    padding: 0 var(--content-pad);
    justify-content: space-between;
  }

  .header-back,
  .header-right {
    display: none;
  }

  .header-center {
    flex: none;
    justify-content: flex-start;
    gap: 10px;
  }

  .header-logo-icon {
    width: 34px;
    height: 34px;
    font-size: 18px;
  }

  #header-title {
    font-size: 20px;
  }

  .desktop-nav {
    display: flex;
  }

  /* Hide mobile-only chrome */
  #bottom-nav,
  #fab,
  .ios-install-banner {
    display: none !important;
  }

  /* Main content becomes a white dashboard panel, separated from the
     purple header by the page's neutral background */
  #main-content {
    max-width: 1180px;
    margin: calc(var(--header-h) + 24px) auto 24px;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.08);
    min-height: calc(100vh - var(--header-h) - 48px);
  }

  /* Page content area: padding inside the white panel */
  .page {
    max-width: none;
    width: 100%;
    margin: 0;
    min-height: 0;
    padding: var(--content-pad);
    padding-bottom: var(--content-pad);
  }

  /* Dashboard stats: 4 across */
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
  }

  .stat-card {
    padding: 22px;
  }

  .stat-icon {
    width: 44px;
    height: 44px;
    font-size: 22px;
  }

  .stat-value {
    font-size: 26px;
  }

  /* Nova Venda / Cobrar Atrasados: aligned right, not stretched */
  .dashboard-actions {
    justify-content: flex-end;
  }

  .dashboard-action-btn {
    flex: none;
    min-width: 220px;
  }

  /* Empty states get more breathing room */
  .empty-state {
    padding: 64px 24px;
    max-width: 480px;
    margin: 0 auto;
  }

  /* List rows get a faint background so they read against the white panel */
  .sale-card,
  .sale-card-mini {
    background: var(--gray-50);
  }
  .sale-card.selected { background: #fff; }

  /* Forms stay readable width, centered */
  .form-page-content {
    max-width: 560px;
    margin: 0 auto;
  }
}
