@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800;900&display=swap');

/* iOS dynamic viewport fix variable (set via JS in mobile.js) */
:root {
  --vh: 1vh;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

:root {
  /* ──────────────────────────────────────────────
     Credlar Vacation Brand Colors
     Logo palette: Navy + Orange→Red gradient + White
     ──────────────────────────────────────────────
     Brand aliases (use these in new code) */
  --brand-navy:        #0C2340;  /* Logo "CREDLAR" / right side of diamond */
  --brand-navy-soft:   #1E3A5F;  /* Navy accent for UI */
  --brand-navy-pale:   #C7D2E0;  /* Pale navy tint */
  --brand-orange:      #F77F00;  /* Top of logo gradient */
  --brand-orange-soft: #FFA94D;  /* Light orange */
  --brand-red:         #D62828;  /* Bottom of logo gradient */
  --brand-white:       #FFFFFF;
  --brand-gradient:    linear-gradient(180deg, #F77F00 0%, #D62828 100%);
  --brand-gradient-h:  linear-gradient(90deg,  #D62828 0%, #F77F00 100%);

  /* Legacy aliases — names kept for compatibility, remapped to logo palette */
  --sky:         #1E3A5F;  /* navy soft */
  --sky-light:   #C7D2E0;  /* navy pale */
  --sky-dark:    #0C2340;  /* navy deep */
  --coral:       #F77F00;  /* orange */
  --coral-light: #FFE0B5;  /* orange pale */
  --coral-dark:  #D62828;  /* red */
  --sand:        #F77F00;  /* orange (merged) */
  --sand-light:  #FFF4E6;  /* orange tint */
  --green:       #1E3A5F;  /* navy (positive accent) */
  --green-light: #E8EDF3;  /* navy pale */

  /* Backgrounds */
  --bg-primary: #F4F6FA;
  --bg-secondary: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-sidebar: #FFFFFF;

  /* Text */
  --text-primary: #0C2340;
  --text-secondary: #475569;
  --text-muted: #94A3B8;

  /* Borders */
  --border: #E2E8F0;
  --border-sky: rgba(30,58,95, 0.25);
  --border-coral: rgba(247,127,0, 0.25);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(12, 35, 64, 0.08), 0 1px 2px rgba(12, 35, 64, 0.04);
  --shadow-md: 0 4px 16px rgba(12, 35, 64, 0.10), 0 2px 6px rgba(12, 35, 64, 0.05);
  --shadow-lg: 0 10px 40px rgba(12, 35, 64, 0.12), 0 4px 12px rgba(12, 35, 64, 0.06);
  --shadow-sky: 0 8px 30px rgba(30,58,95, 0.25);
  --shadow-coral: 0 8px 30px rgba(247,127,0, 0.25);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-2xl: 32px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Montserrat', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: clip;
  width: 100%;
}
/* Fallback para browsers sem `clip` (Safari < 16) */
@supports not (overflow-x: clip) {
  body { overflow-x: hidden; }
}

/* Defensive: nada deve estourar a viewport horizontalmente */
img, video, canvas, svg, iframe {
  max-width: 100%;
  height: auto;
}
/* Inputs/selects não devem forçar largura intrínseca */
input, select, textarea, button {
  max-width: 100%;
  min-width: 0;
}
/* Grid e flex items: por padrão devem poder encolher (sem min-width: auto) */
.app-layout, .main-content {
  max-width: 100%;
  min-width: 0;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #F1F5F9; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* ─── Typography ─── */
.gradient-text {
  background: linear-gradient(135deg, var(--brand-orange), var(--brand-red));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.display-font { font-family: 'Montserrat', sans-serif; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 11px 22px; border: none; border-radius: var(--radius-md);
  font-family: 'Montserrat', sans-serif; font-size: 14px; font-weight: 700;
  cursor: pointer; transition: var(--transition); text-decoration: none;
  letter-spacing: 0.2px; position: relative; overflow: hidden;
}
.btn::before {
  content: ''; position: absolute; inset: 0;
  background: rgba(255,255,255,0); transition: background 0.2s ease;
  border-radius: inherit;
}
.btn:active::before { background: rgba(255,255,255,0.15); }
.btn:active { transform: scale(0.97) !important; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand-orange), var(--brand-red));
  color: white; box-shadow: var(--shadow-coral);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 35px rgba(247,127,0,0.45); }
.btn-coral {
  background: linear-gradient(135deg, var(--coral), var(--coral-dark));
  color: white; box-shadow: var(--shadow-coral);
}
.btn-coral:hover { transform: translateY(-2px); box-shadow: 0 12px 35px rgba(247,127,0,0.4); }
.btn-secondary {
  background: white; color: var(--text-primary);
  border: 1.5px solid var(--border); box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { background: #F8FAFC; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-danger { background: linear-gradient(135deg, #D62828, #B91C1C); color: white; }
.btn-danger:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(214,40,40,0.35); }
.btn-success { background: linear-gradient(135deg, var(--green), #0C2340); color: white; }
.btn-success:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(30,58,95,0.35); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }

/* ─── Inputs ─── */
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-group label {
  font-size: 13px; font-weight: 700; color: var(--text-secondary); letter-spacing: 0.3px;
  transition: color 0.2s ease;
}
.input-group:focus-within label { color: var(--coral-dark); }
.input-field {
  background: #F8FAFC; border: 1.5px solid var(--border);
  border-radius: var(--radius-md); padding: 11px 16px;
  color: var(--text-primary); font-family: 'Montserrat', sans-serif;
  font-size: 14px; font-weight: 600; transition: var(--transition);
  outline: none; width: 100%;
}
.input-field:focus { border-color: var(--brand-orange); background: white; box-shadow: 0 0 0 3px rgba(247,127,0,0.18); transform: translateY(-1px); }
.input-field::placeholder { color: var(--text-muted); font-weight: 500; }
.input-field.shake { animation: shake 0.4s cubic-bezier(.36,.07,.19,.97); }

/* ─── Select ─── */
select.input-field { cursor: pointer; }

/* ─── Password toggle ─── */
.pass-wrapper { position: relative; }
.pass-wrapper .input-field { padding-right: 44px; box-sizing: border-box; }
.toggle-pass {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; padding: 4px;
  color: var(--text-muted); font-size: 17px; line-height: 1; user-select: none;
}
.toggle-pass:hover { color: var(--brand-orange); }

/* ─── Badge ─── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 11px; border-radius: 100px; font-size: 12px; font-weight: 700;
}
.badge-sky { background: #E8EDF3; color: var(--sky-dark); border: 1px solid rgba(30,58,95,0.2); }
.badge-coral { background: #FFF4E6; color: var(--coral-dark); border: 1px solid rgba(247,127,0,0.2); }
.badge-sand { background: #FFFAF0; color: #9A1D1D; border: 1px solid rgba(247,127,0,0.2); }
.badge-green { background: #F4F6FA; color: #0C2340; border: 1px solid rgba(30,58,95,0.2); }
.badge-blue { background: #E8EDF3; color: var(--sky-dark); border: 1px solid rgba(30,58,95,0.2); }
.badge-gold { background: #FFFAF0; color: #9A1D1D; border: 1px solid rgba(247,127,0,0.2); }

/* ─── Avatar ─── */
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-orange), var(--brand-red));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; color: white; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(247,127,0,0.25);
}
.avatar-lg { width: 52px; height: 52px; font-size: 18px; }

/* ─── App Layout ─── */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 264px;
  background: white;
  border-right: 1.5px solid var(--border);
  display: flex; flex-direction: column; padding: 24px 16px;
  position: fixed; height: 100vh; overflow-y: auto; z-index: 100;
  box-shadow: 4px 0 24px rgba(12, 35, 64, 0.05);
}

.main-content { flex: 1; margin-left: 264px; padding: 32px; min-height: 100vh; }

.sidebar-logo {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 8px 24px; border-bottom: 1.5px solid var(--border); margin-bottom: 20px;
  animation: fadeInDown 0.5s ease-out;
}
.sidebar-logo-icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; transition: transform 0.3s ease;
}
.sidebar-logo-icon:hover { transform: scale(1.1) rotate(-5deg); }
.sidebar-logo-icon img {
  width: 42px; height: 42px; object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(176,127,31,0.45));
  animation: logo-pulse 3s ease-in-out infinite;
}
.sidebar-logo-text h2 { font-size: 16px; font-weight: 800; color: var(--text-primary); }
.sidebar-logo-text p { font-size: 11px; color: var(--text-muted); font-weight: 600; letter-spacing: 0.5px; }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: var(--radius-md); color: var(--text-secondary); text-decoration: none;
  font-size: 14px; font-weight: 700; transition: var(--transition);
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
  position: relative; overflow: hidden;
}
.nav-item::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 0; background: linear-gradient(90deg, rgba(247,127,0,0.12), transparent);
  transition: width 0.3s ease; border-radius: inherit;
}
.nav-item:hover::after { width: 100%; }
.nav-item:hover { background: #FFF4E6; color: var(--coral-dark); transform: translateX(3px); }
.nav-item.active {
  background: linear-gradient(135deg, var(--brand-orange), var(--brand-red));
  color: white; border: 1.5px solid transparent;
  box-shadow: 0 4px 14px rgba(247,127,0,0.35);
}
.nav-item.active::after { display: none; }
.nav-item .nav-icon { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }

.sidebar-footer { padding-top: 16px; border-top: 1.5px solid var(--border); }

/* ─── Sub-nav ─── */
.nav-parent-btn {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: var(--radius-md); color: var(--text-secondary);
  font-size: 14px; font-weight: 700; transition: var(--transition);
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
  font-family: 'Montserrat', sans-serif;
}
.nav-parent-btn:hover { background: #FFF4E6; color: var(--coral-dark); }
.nav-parent-btn.active {
  background: linear-gradient(135deg, var(--brand-orange), var(--brand-red));
  color: white; border: 1.5px solid transparent;
  box-shadow: 0 4px 14px rgba(247,127,0,0.35);
}
.nav-parent-btn.active .nav-chevron { color: white; }
.nav-parent-btn .nav-icon { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
.nav-parent-label { flex: 1; }
.nav-chevron {
  font-size: 10px; color: var(--sky-dark); transition: transform 0.3s ease;
  flex-shrink: 0;
}
.nav-chevron.rotated { transform: rotate(180deg); }

.nav-sub {
  display: flex; flex-direction: column; gap: 2px;
  padding-left: 32px; overflow: hidden;
  max-height: 0; transition: max-height 0.35s ease;
}
.nav-sub.open { max-height: 300px; }
.nav-sub-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: var(--radius-md);
  font-size: 12px; font-weight: 700; color: var(--text-secondary);
  cursor: pointer; border: none; background: none; text-decoration: none;
  font-family: 'Montserrat', sans-serif; text-align: left; width: 100%;
  transition: var(--transition);
}
.nav-sub-item:hover { background: #FFF4E6; color: var(--coral-dark); }
.nav-sub-item.active { color: var(--coral-dark); background: rgba(247,127,0,0.12); font-weight: 800; }
.nav-sub-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; opacity: 0.5; }
.nav-sub-badge {
  margin-left: auto; background: #FFF4E6; color: #9A1D1D;
  font-size: 10px; font-weight: 800; padding: 1px 7px;
  border-radius: 20px;
}

/* ─── Page Header ─── */
.page-header { margin-bottom: 28px; max-width: 100%; min-width: 0; }
.page-header h1 { font-size: 26px; font-weight: 800; margin-bottom: 4px; color: var(--text-primary); word-wrap: break-word; overflow-wrap: break-word; }
.page-header p { color: var(--text-secondary); font-size: 14px; font-weight: 600; word-wrap: break-word; overflow-wrap: break-word; }

/* ─── Cards ─── */
.card {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.3s ease, transform 0.3s ease, border-color 0.3s ease;
  animation: fadeInUp 0.5s ease-out both;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: rgba(247,127,0,0.25); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.card-title { font-size: 15px; font-weight: 800; color: var(--text-primary); }

/* ─── Transactions ─── */
.transaction-list { display: flex; flex-direction: column; gap: 8px; max-width: 100%; min-width: 0; }
.transaction-item {
  display: flex; align-items: center; gap: 14px; padding: 13px 16px;
  background: #FAFBFC; border: 1.5px solid var(--border);
  border-radius: var(--radius-lg); transition: var(--transition);
  animation: fadeInLeft 0.4s ease-out both;
  max-width: 100%; min-width: 0;
}
.transaction-item:hover { border-color: var(--border-coral); background: #FFF4E6; box-shadow: var(--shadow-sm); transform: translateX(4px); }
.transaction-icon {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.transaction-icon.credito { background: #FFF4E6; }
.transaction-icon.debito { background: #FAD0D0; }
.transaction-info { flex: 1; min-width: 0; }
.transaction-info h4 { font-size: 13px; font-weight: 700; margin-bottom: 2px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.transaction-info p { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.transaction-amount { font-size: 15px; font-weight: 800; white-space: nowrap; }
.transaction-amount.credito { color: var(--brand-orange); }
.transaction-amount.debito { color: #D62828; }

/* ─── Alerts ─── */
.alert { padding: 12px 16px; border-radius: var(--radius-md); font-size: 13px; font-weight: 600; margin-bottom: 12px; display: none; }
.alert.show { display: block; animation: fadeInUp 0.3s ease; }
.alert-error { background: #FDEAEA; border: 1.5px solid rgba(214,40,40,0.2); color: #B91C1C; }
.alert-success { background: #F4F6FA; border: 1.5px solid rgba(30,58,95,0.2); color: #0C2340; }

/* ─── Section titles ─── */
.section-title { font-size: 15px; font-weight: 800; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; color: var(--text-primary); }
.section-title span { font-size: 18px; }

/* ═══════════════════════════════════════════════════
   MOBILE HAMBURGER MENU
   ═══════════════════════════════════════════════════ */

/* Mobile top bar — hidden on desktop */
.mobile-topbar {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; z-index: 150;
  height: 60px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1.5px solid var(--border);
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 16px rgba(12,35,64,0.06);
}

.mobile-topbar-logo {
  display: flex; align-items: center; gap: 10px;
}
.mobile-topbar-logo .sidebar-logo-icon {
  width: 36px; height: 36px; border-radius: 50%; font-size: 18px; overflow: visible;
}
.mobile-topbar-logo .sidebar-logo-icon img {
  width: 36px; height: 36px;
}
.mobile-topbar-logo h2 {
  font-size: 15px; font-weight: 800; color: var(--text-primary);
}
.mobile-topbar-logo p {
  font-size: 10px; color: var(--text-muted); font-weight: 600; letter-spacing: 0.5px;
}

/* Hamburger button */
.hamburger-btn {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  border-radius: var(--radius-md);
  transition: var(--transition);
  position: relative; z-index: 210;
  -webkit-tap-highlight-color: transparent;
}
.hamburger-btn:hover { background: #F4F6FA; }
.hamburger-btn:active { background: #E8EDF3; }

.hamburger-icon {
  width: 22px; height: 16px;
  position: relative;
  display: flex; flex-direction: column;
  justify-content: space-between;
}
.hamburger-icon span {
  display: block;
  width: 100%; height: 2.5px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center;
}

/* Hamburger → X animation */
.hamburger-btn.active .hamburger-icon span:nth-child(1) {
  transform: translateY(6.75px) rotate(45deg);
}
.hamburger-btn.active .hamburger-icon span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.hamburger-btn.active .hamburger-icon span:nth-child(3) {
  transform: translateY(-6.75px) rotate(-45deg);
}

/* Mobile overlay */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 99;
  background: rgba(12,35,64,0.3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.sidebar-overlay.visible {
  display: block;
  opacity: 1;
}

/* ─── Animations ─── */
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }
@keyframes fadeInUp { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:translateY(0)} }
@keyframes fadeInDown { from{opacity:0;transform:translateY(-16px)} to{opacity:1;transform:translateY(0)} }
@keyframes fadeInLeft { from{opacity:0;transform:translateX(-20px)} to{opacity:1;transform:translateX(0)} }
@keyframes fadeInRight { from{opacity:0;transform:translateX(20px)} to{opacity:1;transform:translateX(0)} }
@keyframes float-particle { 0%{transform:translateY(100vh) rotate(0deg);opacity:0} 10%{opacity:0.25} 90%{opacity:0.25} 100%{transform:translateY(-20vh) rotate(360deg);opacity:0} }
@keyframes shimmer { 0%{background-position:-200% center} 100%{background-position:200% center} }
@keyframes shimmer-slide { 0%{left:-100%} 100%{left:100%} }
@keyframes spin { 0%{transform:rotate(0deg)} 100%{transform:rotate(360deg)} }
@keyframes pop-in { 0%{transform:scale(0.75);opacity:0} 60%{transform:scale(1.08)} 100%{transform:scale(1);opacity:1} }
@keyframes wave { 0%,100%{transform:rotate(0deg)} 25%{transform:rotate(20deg)} 75%{transform:rotate(-10deg)} }
@keyframes shake { 10%,90%{transform:translate3d(-2px,0,0)} 20%,80%{transform:translate3d(4px,0,0)} 30%,50%,70%{transform:translate3d(-6px,0,0)} 40%,60%{transform:translate3d(6px,0,0)} }
@keyframes logo-pulse { 0%,100%{filter:drop-shadow(0 2px 6px rgba(176,127,31,0.45))} 50%{filter:drop-shadow(0 4px 14px rgba(176,127,31,0.7))} }
@keyframes glow-pulse { 0%,100%{box-shadow:0 0 0 0 rgba(30,58,95,0.3)} 50%{box-shadow:0 0 0 8px rgba(30,58,95,0)} }
@keyframes slide-in-stagger { from{opacity:0;transform:translateX(-16px)} to{opacity:1;transform:translateX(0)} }
@keyframes scale-in { from{opacity:0;transform:scale(0.85)} to{opacity:1;transform:scale(1)} }
@keyframes bounce-in { 0%{transform:scale(0);opacity:0} 60%{transform:scale(1.15);opacity:1} 80%{transform:scale(0.95)} 100%{transform:scale(1);opacity:1} }
@keyframes count-up { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

@keyframes slideInLeft {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}
@keyframes slideOutLeft {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE — TABLET (≤ 1024px)
   ═══════════════════════════════════════════════════ */
@media(max-width: 1024px) {
  .main-content { padding: 24px 20px; }
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE — MOBILE (≤ 768px)
   ═══════════════════════════════════════════════════ */
@media(max-width:768px){
  /* Show mobile topbar — respect iOS notch */
  .mobile-topbar {
    display: flex;
    height: calc(60px + var(--safe-top));
    padding-top: var(--safe-top);
    padding-left: max(16px, var(--safe-left));
    padding-right: max(16px, var(--safe-right));
  }

  /* Sidebar: off-screen by default */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
    width: 290px;
    padding-top: calc(70px + var(--safe-top));
    padding-bottom: calc(20px + var(--safe-bottom));
    padding-left: max(16px, var(--safe-left));
    box-shadow: 8px 0 40px rgba(12,35,64,0.18);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-height: 100vh;
    max-height: 100dvh;
  }
  .sidebar.open { transform: translateX(0); }

  /* Nav itens maiores para toque */
  .nav-item { padding: 13px 16px; font-size: 14px; min-height: 48px; }
  .nav-parent-btn { padding: 13px 16px; min-height: 48px; }
  .nav-sub-item { padding: 10px 14px; font-size: 13px; min-height: 44px; }
  .nav-chevron { font-size: 12px; padding: 8px !important; min-width: 36px; text-align: center; }

  /* Main content: full width + safe-area padding */
  .main-content {
    margin-left: 0;
    padding: calc(76px + var(--safe-top)) max(14px, var(--safe-right)) calc(32px + var(--safe-bottom)) max(14px, var(--safe-left));
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }
  @supports not (overflow-x: clip) {
    .main-content { overflow-x: hidden; }
  }
  /* Garantia extra em todos os filhos diretos */
  .main-content > * { max-width: 100%; min-width: 0; }
  /* Grids/flexes do main-content: filhos com min-width 0 (impede expand) */
  .main-content .stats-row > *,
  .main-content .stats-grid > *,
  .main-content .products-grid > *,
  .main-content .achievs-grid > *,
  .main-content .emp-grid > *,
  .main-content .page-grid > *,
  .main-content .charts-row > *,
  .main-content .bottom-row > * { min-width: 0; }

  /* Previne scroll do body quando menu aberto (sem position: fixed para não quebrar navegação) */
  body.menu-open { overflow: hidden; }

  /* Cards empilhados */
  .card { padding: 16px; border-radius: var(--radius-lg); }
  .card-header { flex-wrap: wrap; gap: 8px; }
  .page-header { margin-bottom: 20px; }
  .page-header h1 { font-size: 22px; }
  .page-header p  { font-size: 12px; }

  /* Tabelas com scroll horizontal e indicador */
  .stock-panel-table,
  .stock-table,
  .table-wrap,
  table { -webkit-overflow-scrolling: touch; }
  .stock-panel-table,
  .stock-table { display: block; overflow-x: auto; white-space: nowrap; }
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    position: relative;
  }
  .table-wrap table { min-width: 560px; }
  .table-wrap thead th, .table-wrap tbody td { font-size: 12px; padding: 9px 10px; }

  /* Gráfico donut empilhado */
  .donut-wrap { flex-direction: column; align-items: center; gap: 20px; }
  .donut-legend { width: 100%; }
  .pie-wrap { gap: 18px; justify-content: center; }

  /* Sub-nav abre mais espaço */
  .nav-sub.open { max-height: 400px; }

  /* Inputs maiores e font-size 16 evita zoom no iOS */
  .input-field {
    font-size: 16px;
    padding: 12px 14px;
    min-height: 46px;
  }
  select.input-field {
    font-size: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394A3B8' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    -webkit-appearance: none;
    appearance: none;
  }

  /* Botões touch-friendly */
  .btn {
    min-height: 44px;
    padding: 12px 20px;
    font-size: 14px;
  }
  .btn-secondary, .btn-primary, .btn-coral, .btn-danger, .btn-success {
    min-height: 46px;
  }

  /* Toggle pass: área de toque maior */
  .toggle-pass {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
  }

  /* Modais full-bottom em mobile */
  .modal-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  .modal {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 24px 20px calc(24px + var(--safe-bottom)) !important;
    max-height: 92vh;
    max-height: 92dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: slide-up-modal 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    box-shadow: 0 -10px 40px rgba(12,35,64,0.18);
    /* arrasta visual */
    position: relative;
  }
  .modal::before {
    content: '';
    position: absolute;
    top: 8px; left: 50%;
    transform: translateX(-50%);
    width: 40px; height: 4px;
    background: #CBD5E1;
    border-radius: 4px;
    pointer-events: none;
  }
  .modal-header { padding-top: 6px; }
  .modal-btns { flex-direction: column-reverse; gap: 8px; }
  .modal-btns .btn { width: 100%; }

  @keyframes slide-up-modal {
    from { transform: translateY(100%); opacity: 0.6; }
    to   { transform: translateY(0); opacity: 1; }
  }

  /* Drawer (perfil de funcionário) também vira bottom sheet */
  .drawer {
    width: 100% !important;
    height: 92vh !important;
    height: 92dvh !important;
    top: auto !important;
    bottom: 0;
    right: 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    transform: translateY(100%) !important;
  }
  .drawer.open { transform: translateY(0) !important; }
  .drawer::before {
    content: '';
    position: absolute;
    top: 8px; left: 50%;
    transform: translateX(-50%);
    width: 40px; height: 4px;
    background: #CBD5E1;
    border-radius: 4px;
    pointer-events: none;
  }
  .drawer-header { padding-top: 22px; }
  .drawer-actions {
    padding-bottom: calc(16px + var(--safe-bottom));
    flex-wrap: wrap;
    gap: 8px;
  }
  .drawer-actions .btn { flex: 1 1 100%; }

  /* Filters bar em coluna */
  .filters-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 14px;
  }
  .filter-group, .filter-group.search { width: 100%; min-width: 0; }
  .filter-group .input-field { width: 100%; min-width: 0; }
  .filter-actions {
    margin-left: 0 !important;
    width: 100%;
    flex-wrap: wrap;
  }
  .filter-actions .btn,
  .filter-actions .btn-secondary,
  .filter-actions .btn-primary,
  .filter-actions .btn-export { flex: 1 1 100px; min-height: 44px; }

  /* Toast em mobile no topo, full width */
  .toast {
    bottom: auto !important;
    top: calc(70px + var(--safe-top));
    left: 12px !important;
    right: 12px !important;
    max-width: none !important;
    transform: translateY(-120%) scale(0.95);
  }
  .toast.show { transform: translateY(0) scale(1); }

  /* Pagination (admin tables) responsivo */
  .pagination { justify-content: center; }
  .pagination-info { width: 100%; text-align: center; }

  /* (removido pointer-events: none — estava bloqueando navegação) */
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE — SMALL MOBILE (≤ 480px)
   ═══════════════════════════════════════════════════ */
@media(max-width:480px){
  .sidebar { width: 86%; max-width: 320px; }
  .main-content {
    padding: calc(70px + var(--safe-top)) max(12px, var(--safe-right)) calc(24px + var(--safe-bottom)) max(12px, var(--safe-left));
  }
  .page-header h1 { font-size: 20px; }
  .page-header p  { font-size: 12px; line-height: 1.5; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .btn { padding: 11px 16px; font-size: 13px; }
  .badge { font-size: 11px; padding: 4px 9px; }
  .card { padding: 14px; }
  .section-title { font-size: 14px; }

  /* Mobile topbar logo menor */
  .mobile-topbar-logo h2 { font-size: 14px; }
  .mobile-topbar-logo p  { font-size: 9px; }
  .mobile-topbar-logo .sidebar-logo-icon,
  .mobile-topbar-logo .sidebar-logo-icon img { width: 32px; height: 32px; }

  /* Avatares menores */
  .avatar { width: 36px; height: 36px; font-size: 12px; }
  .avatar-lg { width: 46px; height: 46px; font-size: 16px; }

  /* Transactions empilhados */
  .transaction-item {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 14px;
  }
  .transaction-info { flex: 1 1 60%; }
  .transaction-amount { flex-shrink: 0; }
}

/* ═══════════════════════════════════════════════════
   TINY MOBILE (≤ 360px)
   ═══════════════════════════════════════════════════ */
@media(max-width:360px){
  .page-header h1 { font-size: 18px; }
  .stats-grid { grid-template-columns: 1fr; }
  .mobile-topbar-logo h2 { font-size: 13px; }
  .mobile-topbar-logo p  { display: none; }
}

/* ═══════════════════════════════════════════════════
   ORIENTATION — Landscape phones
   ═══════════════════════════════════════════════════ */
@media(max-width:900px) and (orientation: landscape) and (max-height: 500px) {
  .login-bg { padding: 16px; min-height: auto; }
  .login-card { padding: 24px 24px; }
  .premium-coin-wrap, .admin-coin-wrap { width: 70px; height: 70px; margin-bottom: 16px; }
  .premium-coin, .admin-coin { width: 70px; height: 70px; }
}

/* ═══════════════════════════════════════════════════
   TOUCH DEVICE TWEAKS
   ═══════════════════════════════════════════════════ */
@media (hover: none) and (pointer: coarse) {
  /* Desabilita transformações de hover em touch (evita "stuck hover") */
  .card:hover,
  .product-card:hover,
  .emp-card:hover,
  .nav-item:hover,
  .stat-card:hover,
  .kpi-card:hover,
  .transaction-item:hover,
  .order-row:hover,
  .notif-item:hover,
  .achiev-card.unlocked:hover,
  .tx-row:hover {
    transform: none;
  }
  /* Mantém animação da imagem dentro do product card */
  .product-card:hover .product-img > :first-child { transform: none; }

  /* Botões dão feedback visual no toque (ativo) */
  .btn:active, .buy-btn:active, .login-btn:active {
    transform: scale(0.97);
    transition: transform 0.05s ease;
  }
  /* Tap highlight global */
  a, button, .btn, .nav-item, .product-card, .order-row, .emp-card, .kpi-card, .tab, .type-btn {
    -webkit-tap-highlight-color: rgba(247,127,0,0.18);
  }
}

/* ═══════════════════════════════════════════════════
   PRINT-LIKE PREFERENCES (for accessibility)
   ═══════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ═══════════════════════════════════════════════════
   GLOBAL MOBILE FIXES
   ═══════════════════════════════════════════════════ */
/* Evita scroll horizontal acidental — usa `clip` para não quebrar scroll vertical */
html, body { max-width: 100%; width: 100%; }

/* Defensive: contenção horizontal forte em mobile */
@media (max-width: 768px) {
  /* Quebra palavras longas em vez de causar overflow */
  h1, h2, h3, h4, h5, h6, p, div, span, label, a {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
  /* Toda card / section padrão respeita largura */
  .card, .balance-hero, .saldo-bar, .user-info-card,
  .stat-card, .kpi-card, .extrato-card, .filters-bar,
  .product-card, .emp-card, .order-row, .transaction-item,
  .notif-item, .achiev-card, .rank-row, .tx-row {
    max-width: 100%;
    min-width: 0;
  }
  /* Containers flex/grid em mobile com filhos contidos */
  .saldo-bar > *,
  .user-info-card > *,
  .order-row > *,
  .transaction-item > *,
  .notif-item > *,
  .rank-row > *,
  .tx-row > * {
    min-width: 0;
  }
  /* Headers que mostram nome + badge: nome trunca */
  .order-info, .transaction-info, .notif-text,
  .tx-info, .rank-info, .user-info-text {
    min-width: 0;
    overflow: hidden;
  }
}

/* Evita zoom em focus em iOS (font-size precisa >= 16px) */
@media(max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="search"],
  input[type="date"],
  textarea, select {
    font-size: 16px !important;
  }
}

/* Melhor scroll em iOS */
.table-wrap, .orders-list, .tx-list, .drawer-body, .modal,
.sidebar, .vchart-scroll {
  -webkit-overflow-scrolling: touch;
}

/* Remove tap highlight feio padrão */
button, a, [role="button"], [onclick] {
  -webkit-tap-highlight-color: transparent;
}

/* Botão flutuante para "voltar ao topo" em mobile (opcional, ativado pelo JS) */
.scroll-to-top {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  right: 20px;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-orange), var(--brand-red));
  color: white; border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; cursor: pointer;
  box-shadow: 0 8px 24px rgba(247,127,0,0.4);
  z-index: 80;
  opacity: 0; pointer-events: none;
  transform: translateY(20px) scale(0.8);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.scroll-to-top.visible {
  opacity: 1; pointer-events: auto;
  transform: translateY(0) scale(1);
}
@media (min-width: 769px) { .scroll-to-top { display: none; } }

/* (overscroll-behavior removido — estava potencialmente afetando scroll do mouse) */

/* ─── Utils ─── */
.flex{display:flex} .flex-col{flex-direction:column}
.items-center{align-items:center} .justify-between{justify-content:space-between}
.gap-2{gap:8px} .gap-3{gap:12px} .gap-4{gap:16px}
.w-full{width:100%} .text-sm{font-size:13px} .text-muted{color:var(--text-secondary)}
.font-bold{font-weight:700} .mb-4{margin-bottom:16px} .mb-6{margin-bottom:24px} .mt-auto{margin-top:auto}

/* ─── Page Transitions ─── */
@keyframes page-enter { from{opacity:0} to{opacity:1} }
@keyframes page-exit  { from{opacity:1} to{opacity:0} }
.app-layout { animation: page-enter 0.28s ease-out; }
body.exiting .app-layout,
body.exiting .login-bg { animation: page-exit 0.2s ease-in forwards; }

/* ─── Ripple Effect ─── */
@keyframes ripple-out { 0%{transform:scale(0);opacity:0.45} 100%{transform:scale(4);opacity:0} }
.ripple-effect {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: rgba(255,255,255,0.38);
  animation: ripple-out 0.58s ease-out forwards;
}

/* ─── Sidebar nav stagger (fade-only, sem translateX para não conflitar com hover) ─── */
@keyframes nav-fade-in { from{opacity:0} to{opacity:1} }
.sidebar-nav .nav-item:nth-child(1),
.sidebar-nav .nav-parent-btn:nth-child(1) { animation: nav-fade-in 0.35s 0.06s ease-out both; }
.sidebar-nav .nav-item:nth-child(2),
.sidebar-nav .nav-parent-btn:nth-child(2) { animation: nav-fade-in 0.35s 0.12s ease-out both; }
.sidebar-nav .nav-item:nth-child(3),
.sidebar-nav .nav-parent-btn:nth-child(3) { animation: nav-fade-in 0.35s 0.18s ease-out both; }
.sidebar-nav .nav-item:nth-child(4),
.sidebar-nav .nav-parent-btn:nth-child(4) { animation: nav-fade-in 0.35s 0.24s ease-out both; }
.sidebar-nav .nav-item:nth-child(5),
.sidebar-nav .nav-parent-btn:nth-child(5) { animation: nav-fade-in 0.35s 0.30s ease-out both; }

/* ─── Sparkle for ranking ─── */
@keyframes sparkle { 0%,100%{transform:scale(1) rotate(0deg);opacity:1} 50%{transform:scale(1.35) rotate(180deg);opacity:0.7} }
@keyframes sparkle-burst { 0%{transform:scale(0) rotate(0deg);opacity:1} 100%{transform:scale(2.5) rotate(90deg);opacity:0} }
.sparkle { position:absolute; pointer-events:none; font-size:14px; animation: sparkle-burst 0.8s ease-out both; }

/* ─── Badge pop ─── */
@keyframes badge-pop { 0%,100%{transform:scale(1)} 40%{transform:scale(1.18)} }
.badge-pulse { animation: badge-pop 1.8s ease-in-out infinite; }

