/* ================================================
   Alegria Kids QR - Mobile-First Native Styles
   Inspirado em: WhatsApp, Instagram, Nubank, iFood
   ================================================ */

/* ================== Safe Areas & PWA ================== */
:root {
  /* Cores principais */
  --color-primary: #E53935;
  --color-primary-light: #FF6F60;
  --color-primary-dark: #C62828;
  --color-secondary: #FF6FA3;
  --color-accent: #FFD93D;
  
  /* Backgrounds */
  --bg-dark: #111318;
  --bg-card: #1C1F26;
  --bg-input: #252930;
  --bg-hover: #2A2E36;
  
  /* Texto */
  --text-primary: #F8F8FA;
  --text-secondary: #B8BBC2;
  --text-muted: #6B6E76;
  
  /* Status */
  --color-success: #2ECC71;
  --color-error: #E74C3C;
  --color-warning: #F1C40F;
  --color-info: #3498DB;
  
  /* Safe areas (notch, home indicator) */
  --safe-area-top: env(safe-area-inset-top);
  --safe-area-bottom: env(safe-area-inset-bottom);
  --safe-area-left: env(safe-area-inset-left);
  --safe-area-right: env(safe-area-inset-right);
  
  /* Sizes mobile-native */
  --header-height: calc(56px + var(--safe-area-top));
  --bottom-nav-height: calc(56px + var(--safe-area-bottom));
  --touch-target-min: 44px;
  --border-radius: 10px;
  --border-radius-lg: 16px;
  
  /* Shadows native-like */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.1);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
  --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.2);
  
  /* Transitions fluidas 60fps */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
  --spring: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ================== Reset & Base ================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  position: fixed;
  width: 100%;
  height: 100%;
}

/* Seleção consistente com a identidade */
::selection {
  background: rgba(229, 57, 53, 0.35);
  color: #fff;
}

#app {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* ================== Loading Screen ================== */
.loading-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-content {
  text-align: center;
  color: white;
}

.loading-logo {
  font-size: 72px;
  margin-bottom: 16px;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 24px auto 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ================== Screens ================== */
.screen {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  animation: fadeIn var(--transition) ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.hidden {
  display: none !important;
}

/* Visually hidden but accessible to screen readers */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ================== Login Screen ================== */
.login-container {
  max-width: 400px;
  margin: 0 auto;
  padding: 32px 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-header {
  text-align: center;
  margin-bottom: 40px;
}

.logo {
  font-size: 48px; /* reduz o tamanho do ícone/emoji quando usado */
  margin-bottom: 16px;
  animation: bounce 2s ease-in-out infinite;
}

/* Ajuste específico para o SVG do logotipo na tela de login */
.login-header .logo svg {
  width: 56px;
  height: 56px;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.login-header h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 15px;
}

/* Headings */
h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text-primary);
}

h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-primary);
}

h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-primary);
}

h5 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

/* ================== Forms Mobile-Optimized ================== */
.form {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

.form-group {
  margin-bottom: 20px;
  position: relative;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
  transition: var(--transition-fast);
}

.form-group input,
.form-group textarea,
.form-group select,
.form-select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 2px solid transparent;
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 15px; /* iOS zoom prevention */
  transition: var(--transition);
  min-height: var(--touch-target-min);
  font-family: inherit;
  caret-color: var(--color-primary);
}

/* Ajuste de autofill (Chrome/Safari) para manter contraste e tema dark */
.form-group input:-webkit-autofill,
.form-group textarea:-webkit-autofill,
.form-group select:-webkit-autofill {
  -webkit-text-fill-color: var(--text-primary);
  transition: background-color 100000s ease-in-out 0s;
  box-shadow: 0 0 0px 1000px var(--bg-input) inset;
  caret-color: var(--text-primary);
}
.form-group input:-webkit-autofill:focus,
.form-group textarea:-webkit-autofill:focus,
.form-group select:-webkit-autofill:focus {
  box-shadow: 0 0 0px 1000px var(--bg-hover) inset, 0 0 0 3px rgba(229,57,53,.12);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
.form-select:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--bg-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(229, 57, 53, 0.2);
}

/* Aparência consistente do seletor de templates */
.form-select {
  -webkit-appearance: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%),
                    linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
  background-position: calc(100% - 24px) calc(1.1em), calc(100% - 19px) calc(1.1em);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
}

/* Placeholders sutis e legíveis */
.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.85;
}

.form-inline {
  display: flex;
  align-items: center;
  gap: 12px;
}

.no-margin {
  margin: 0 !important;
}

.helper-note {
  font-size: 13px;
  margin-top: -8px;
  color: var(--text-muted);
}

/* ================== Buttons Native-Like ================== */
.btn {
  padding: 12px 20px;
  border-radius: 10px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  min-height: var(--touch-target-min);
  position: relative;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.1);
  transform: scale(0);
  transition: transform var(--transition-fast);
  border-radius: 10px;
}

.btn:active::before {
  transform: scale(1);
}

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

/* Acessibilidade: foco visível consistente para teclado */
:where(button, a, .btn, .nav-item, .mobile-menu-item, .nav-link-icon):focus { outline: none; }
:where(button, a, .btn, .nav-item, .mobile-menu-item, .nav-link-icon):focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(229,57,53,.24);
  background: rgba(255,255,255,0.05);
  border-color: rgba(229,57,53,0.4);
}

/* Respeitar usuários com redução de movimento */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  color: white;
  box-shadow: 0 4px 12px rgba(229, 57, 53, 0.4);
}

.btn-primary:active {
  box-shadow: 0 2px 8px rgba(229, 57, 53, 0.3);
}

/* Estados desabilitados consistentes e acessíveis */
.btn:disabled,
.btn[disabled],
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(10%);
}

/* Estados desabilitados semânticos para âncoras/elementos que parecem botão */
.btn[aria-disabled="true"],
.btn.is-disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(10%);
  pointer-events: none;
}

.btn-large {
  padding: 16px 28px;
  font-size: 16px;
  border-radius: 12px;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 2px solid var(--color-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:active {
  background: var(--bg-hover);
}

/* Botões de estado (perigo/alerta) alinhados com a identidade */
.btn-danger {
  background: linear-gradient(135deg, var(--color-error), #d6453a);
  color: #fff;
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.35);
}
.btn-danger:active { box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3); }

.btn-warning {
  background: linear-gradient(135deg, var(--color-warning), #e0b80e);
  color: #111318;
  box-shadow: 0 4px 12px rgba(241, 196, 15, 0.25);
}
.btn-warning:active { box-shadow: 0 2px 8px rgba(241, 196, 15, 0.22); }

.btn-sm {
  padding: 8px 16px;
  font-size: 14px;
  min-height: 36px;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 20px;
  height: 20px;
}

/* ================== Header Mobile ================== */
.app-header {
  position: sticky;
  top: 0;
  /* Header minimalista: transparente e sem ocupar espaço visual */
  background: transparent;
  border-bottom: 0;
  padding: calc(6px + var(--safe-area-top)) 12px 6px;
  z-index: 100;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
  pointer-events: none;
}

/* Consistência visual dos ícones SVG (tamanho, junções e stroke) */
.mobile-menu-item svg,
.nav-icon,
.btn-icon,
.brand-icon {
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.mobile-menu-item svg { width: 20px; height: 20px; }
.btn-icon { width: 20px; height: 20px; }
.nav-icon { width: 26px; height: 26px; }
.brand-icon { width: 24px; height: 24px; }

.header-content {
  max-width: 100%;
  width: 100%;
  position: relative;   /* referência para elementos absolutos internos */
  display: block;       /* sobrescreve display:flex do desktop */
}
.app-header .header-content { display: block; width: 100%; position: relative; }

/* Mobile Header (< 768px) */
.header-mobile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 100%;
  width: 100%;
  flex: 1 1 100%;
  position: relative;
}
.header-mobile .menu-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1003;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  justify-content: flex-start; /* evita sobreposição com hambúrguer */
  min-width: 0;
  pointer-events: auto;
}

.brand-icon {
  color: var(--color-primary);
  flex-shrink: 0;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

/* Menu Toggle (Hambúrguer) - DIREITA */
.menu-toggle {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  order: 2;
  flex-shrink: 0;
  pointer-events: auto;
}

.menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: var(--transition-fast);
}

.menu-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.menu-toggle.active span:nth-child(2) {
  opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

/* Desktop Header (>= 768px) */
.header-desktop {
  display: none;
}

.header-left {
  flex: 1;
  min-width: 0;
}

.org-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.org-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}

.user-role {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  color: var(--color-primary);
  flex-shrink: 0;
}

.header-right {
  flex: 1;
  display: flex;
  justify-content: flex-end;
  min-width: 0;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
  padding: 8px 10px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Ícones no header desktop - estilo minimalista */
.nav-link-icon {
  padding: 8px;
  min-width: 40px;
  min-height: 40px;
}

.nav-link-icon svg {
  opacity: 0.7;
  transition: var(--transition-fast);
}

/* Tooltips sutis em desktop para ícones do header */
@media (min-width: 768px) {
  .nav-link-icon { position: relative; }
  .nav-link-icon:hover::after,
  .nav-link-icon:focus-visible::after {
    content: attr(title);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.75);
    color: #fff;
    font-size: 12px;
    line-height: 1;
    padding: 6px 8px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10;
  }
}

.nav-link:hover,
.nav-link:active {
  color: var(--color-primary);
  background: rgba(229, 57, 53, 0.08);
}

.nav-link-icon:active svg {
  opacity: 1;
  transform: scale(1.08);
}

@media (hover: hover) {
  .nav-link-icon:hover svg {
    opacity: 1;
    transform: scale(1.1);
  }
}

.btn-link {
  background: transparent;
  border: none;
  cursor: pointer;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Nav desktop: links com área clicável arredondada */
.header-nav .nav-link,
.nav-link-icon {
  border-radius: 10px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
}

.user-info span {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

/* Mobile Menu Dropdown */
.mobile-menu-dropdown {
  position: fixed; /* garante que não fique sob o header */
  top: calc(56px + var(--safe-area-top, 0px));
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-bottom: 1px solid rgba(229, 57, 53, 0.2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: var(--transition);
  z-index: 1002; /* acima do header e da bottom-nav */
}

.mobile-menu-dropdown.active {
  max-height: 600px;
  opacity: 1;
  overflow-y: auto;
}

/* Scrollbar discreta no menu (apenas navegadores WebKit) */
.mobile-menu-dropdown::-webkit-scrollbar { width: 6px; }
.mobile-menu-dropdown::-webkit-scrollbar-track { background: transparent; }
.mobile-menu-dropdown::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 8px; }
.mobile-menu-dropdown::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* Scrollbar em navegadores Firefox (com @supports para evitar warnings) */
@supports (scrollbar-width: thin) {
  .mobile-menu-dropdown {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.25) transparent;
  }
}

.mobile-menu-nav {
  padding: 8px;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.mobile-menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px 14px;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
  min-height: var(--touch-target-min);
  touch-action: manipulation;
}

.mobile-menu-item:hover {
  background: var(--bg-hover);
}

.mobile-menu-item:active {
  background: var(--bg-hover);
  transform: scale(0.98);
}

.mobile-menu-item svg {
  color: var(--color-primary);
  flex-shrink: 0;
  transition: var(--transition);
  opacity: 0.9;
}

.mobile-menu-item:active svg {
  opacity: 1;
  transform: translateX(2px);
}

@media (hover: hover) {
  .mobile-menu-item:hover svg {
    opacity: 1;
    transform: translateX(2px);
  }
}

.mobile-menu-item span {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.2px;
}

.mobile-menu-item-danger {
  color: var(--color-error);
}

.mobile-menu-item-danger svg {
  color: var(--color-error);
  opacity: 0.8;
}

.mobile-menu-item-danger:hover svg,
.mobile-menu-item-danger:active svg {
  opacity: 1;
}

.mobile-menu-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 8px 0;
}

/* Responsivo: Desktop */
@media (min-width: 768px) {
  /* Unificar header: usa versão mobile minimalista também no desktop */
  .header-mobile { display: flex; }
  .header-desktop { display: none; }

  /* Habilita dropdown no desktop como popover alinhado à direita */
  .mobile-menu-dropdown {
    display: block;
    left: auto;
    right: 16px;
    width: 360px;
    top: 60px; /* distância do topo em desktop */
    border-left: 1px solid rgba(229, 57, 53, 0.2);
    border-right: 1px solid rgba(229, 57, 53, 0.2);
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
  }
}

/* Ajustes de alinhamento na tela de login */
.login-alt {
  text-align: center;
  margin-top: 12px;
}
.login-alt .btn {
  min-width: 0;
}

/* Rolagem suave em âncoras internas (Perfil) e compensação do header */
.anchor-offset { scroll-margin-top: 80px; }

/* Admin: modal amplo com rolagem interna e cabeçalho/rodapé fixos no cartão */
#admin-dialog .modal-card {
  max-width: min(1000px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
#admin-dialog .modal-header { flex: 0 0 auto; }
#admin-dialog .modal-footer { flex: 0 0 auto; }
#admin-dialog .modal-body {
  flex: 1 1 auto;
  overflow: auto;
  padding-bottom: 16px;
}

/* Mantém as abas de gestão visíveis ao rolar */
#admin-dialog #admin-tabs {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-card);
  padding-top: 8px;
}

@media (min-width: 1024px) {
  /* Em telas largas, dar mais respiro horizontal para seções ricas */
  #admin-dialog .modal-body .card { margin-bottom: 16px; }
}

/* Grid para Webhooks (evita overflow vertical) */
.admin-webhooks-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 1024px) {
  .admin-webhooks-grid {
    grid-template-columns: 1.2fr 1fr;
    gap: 16px;
  }
}
.webhook-events-list {
  max-height: 160px;
  overflow: auto;
  padding: 8px;
  border: 1px dashed rgba(255,255,255,0.08);
  border-radius: 10px;
}
.webhooks-configured-list {
  max-height: 420px;
  overflow: auto;
}

/* Responsivo: telas muito pequenas */
@media (max-width: 360px) {
  .brand-name {
    font-size: 16px;
  }
  .org-name {
    max-width: 100px;
  }
}

/* ================== Bottom Navigation ================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid rgba(229, 57, 53, 0.15);
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding: 8px 0 calc(8px + var(--safe-area-bottom));
  z-index: 99;
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.08);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
  position: relative;
  min-height: var(--touch-target-min);
  touch-action: manipulation;
}

.nav-icon {
  width: 26px;
  height: 26px;
  transition: var(--transition);
  opacity: 0.7;
}

.nav-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  opacity: 0.8;
}

.nav-item.active {
  color: var(--color-primary);
}

.nav-item.active .nav-icon {
  opacity: 1;
}

.nav-item.active .nav-label {
  opacity: 1;
}

/* Melhor destaque para item ativo da navegação: pill sutil e elevação */
.nav-item.active {
  background: linear-gradient(135deg, rgba(229,83,77,0.1), rgba(255,111,96,0.05));
  border-radius: 14px;
  box-shadow: 0 4px 12px rgba(229,57,53,0.06);
  color: var(--color-primary);
}

.nav-item.active .nav-icon {
  transform: translateY(-2px);
}

.nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 16px);
  background: var(--color-error);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* ================== Content Area ================== */
.app-content {
  /* Respeita altura real do header + safe area e dá mais largura útil */
  padding: calc(var(--header-height) + 4px) 12px calc(var(--bottom-nav-height) + 16px);
  max-width: 100%;
  overflow-y: auto;
  height: 100vh; /* não desconta o header para ganhar espaço útil */
}

@supports (scrollbar-gutter: stable) {
  .app-content { scrollbar-gutter: stable both-edges; }
}

.tab-content {
  display: none;
  animation: slideInUp var(--transition) ease-out;
}

.tab-content.active {
  display: block;
}

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

/* ================== Cards ================== */
.card {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

/* Offset sutil abaixo do header: aplica somente ao primeiro card de cada aba */
.app-content .tab-content .card:first-child {
  margin-top: 4px;
}

.card h2, .card h3 {
  margin-bottom: 16px;
  font-size: 18px;
  font-weight: 700;
}

/* ================== QR Display ================== */
.qr-display {
  text-align: center;
  padding: 20px;
  background: white;
  border-radius: var(--border-radius);
  margin: 16px 0;
}

.qr-display.transparent {
  background: transparent;
}

.qr-caption {
  margin-top: 12px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.qr-code-text {
  font-family: 'SF Mono', 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  word-break: break-all;
  letter-spacing: 0.5px;
  background: var(--bg-input);
  padding: 8px 12px;
  border-radius: 8px;
}

.qr-info {
  background: var(--bg-input);
  border-radius: 10px;
  padding: 14px;
  margin: 16px 0;
}

.qr-info p {
  margin-bottom: 8px;
  font-size: 14px;
}

.code-text {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 12px;
  color: var(--color-accent);
  word-break: break-all;
}

/* ================== Scanner Fullscreen ================== */
.scanner-fullscreen {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  animation: fadeIn var(--transition-fast);
}

.scanner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--safe-area-top)) 16px 12px;
  background: rgba(0, 0, 0, 0.8);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.scanner-header h3 {
  font-size: 17px;
  font-weight: 600;
  color: white;
}

.scanner-close,
.scanner-torch {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.scanner-close:active,
.scanner-torch:active {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(0.95);
}

.scanner-close svg,
.scanner-torch svg {
  width: 24px;
  height: 24px;
}

.scanner-torch.active {
  background: var(--color-accent);
  color: #000;
}

.scanner-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#qr-reader-fullscreen {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scanner-corners {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(80%, 300px);
  height: min(80%, 300px);
}

.corner {
  position: absolute;
  width: 40px;
  height: 40px;
  border: 4px solid var(--color-accent);
  animation: scanPulse 2s ease-in-out infinite;
}

.corner.top-left {
  top: 0;
  left: 0;
  border-right: none;
  border-bottom: none;
  border-top-left-radius: 12px;
}

.corner.top-right {
  top: 0;
  right: 0;
  border-left: none;
  border-bottom: none;
  border-top-right-radius: 12px;
}

.corner.bottom-left {
  bottom: 0;
  left: 0;
  border-right: none;
  border-top: none;
  border-bottom-left-radius: 12px;
}

.corner.bottom-right {
  bottom: 0;
  right: 0;
  border-left: none;
  border-top: none;
  border-bottom-right-radius: 12px;
}

@keyframes scanPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.scanner-footer {
  padding: 20px 20px calc(20px + var(--safe-area-bottom));
  background: rgba(0, 0, 0, 0.8);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  text-align: center;
  color: white;
  font-size: 15px;
}

/* ================== Messages & Toasts ================== */
.error-message,
.success-message {
  padding: 14px 16px;
  border-radius: 12px;
  margin-top: 16px;
  font-size: 14px;
  animation: slideInDown var(--transition);
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.error-message {
  background: rgba(231, 76, 60, 0.15);
  border: 2px solid var(--color-error);
  color: var(--color-error);
}

.success-message {
  background: rgba(46, 204, 113, 0.15);
  border: 2px solid var(--color-success);
  color: var(--color-success);
}

.result-card {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  padding: 24px 20px;
  margin-top: 16px;
  text-align: center;
  border: 2px solid;
  animation: scaleIn var(--spring);
}

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

.result-card.success {
  border-color: var(--color-success);
  background: rgba(46, 204, 113, 0.1);
}

.result-card.error {
  border-color: var(--color-error);
  background: rgba(231, 76, 60, 0.1);
}

.result-icon {
  font-size: 48px;
  margin-bottom: 12px;
  animation: bounceIn 0.6s var(--spring);
}

@keyframes bounceIn {
  0% { transform: scale(0); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* ================== Lists ================== */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.filter-btn {
  padding: 8px 16px;
  background: var(--bg-input);
  border: 2px solid transparent;
  border-radius: 16px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
  flex-shrink: 0;
}

.filter-btn:active {
  transform: scale(0.95);
}

.filter-btn.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.qr-list {
  display: grid;
  gap: 12px;
}

.qr-item {
  background: var(--bg-input);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition-fast);
  border-left: 3px solid transparent;
  min-height: var(--touch-target-min);
}

.qr-item:active {
  transform: scale(0.98);
  background: var(--bg-hover);
}

.qr-item.used {
  border-left-color: var(--color-success);
}

.qr-item.unused {
  border-left-color: var(--color-warning);
}

.qr-item-info {
  flex: 1;
}

.qr-item-amount {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 4px;
}

.qr-item-note {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.qr-item-date {
  font-size: 12px;
}

.qr-item-status {
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 10px;
  font-weight: 600;
}

.qr-item-status.used {
  background: rgba(46, 204, 113, 0.2);
  color: var(--color-success);
}

.qr-item-status.unused {
  background: rgba(241, 196, 15, 0.2);
  color: var(--color-warning);
}

.qr-item-status.purchased {
  background: rgba(52, 152, 219, 0.2);
  color: var(--color-info);
}

/* ================== Utilities ================== */
.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-muted);
}

/* Tamanhos utilitários de texto */
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }

/* Badges: estados visuais pequenos e informativos */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 9999px;
  line-height: 1.6;
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.12);
}
.badge.info { background: rgba(52, 152, 219, 0.18); color: var(--color-info); border-color: rgba(52,152,219,0.35); }
.badge.success { background: rgba(46, 204, 113, 0.18); color: var(--color-success); border-color: rgba(46,204,113,0.35); }
.badge.warning { background: rgba(241, 196, 15, 0.18); color: var(--color-warning); border-color: rgba(241,196,15,0.35); }
.badge.error { background: rgba(231, 76, 60, 0.18); color: var(--color-error); border-color: rgba(231,76,60,0.35); }
.badge.muted { background: rgba(255,255,255,0.06); color: var(--text-secondary); border-color: rgba(255,255,255,0.1); }

/* Subtítulo sutil (ex: Escopo: ...) */
.subtitle-small {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: -4px;
}

/* Utilitários leves para evitar estilos inline */
.label-min-120 { min-width: 120px; }

/* Margins */
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 8px; }
.mt-10 { margin-top: 16px; }
.mt-20 { margin-top: 24px; }
.mb-5 { margin-bottom: 8px; }
.mb-10 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 24px; }
.ml-5 { margin-left: 8px; }
.ml-10 { margin-left: 16px; }
.ml-12 { margin-left: 12px; }
.mr-5 { margin-right: 8px; }
.mr-10 { margin-right: 16px; }
.ml-0-5 { margin-left: 4px; }

.full-width {
  width: 100% !important;
}

/* Flex utilities */
.flex-1 {
  flex: 1;
}

/* Form row para campos lado a lado */
.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

/* Label inline com checkbox/radio */
label.inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
}

label.inline input[type="checkbox"],
label.inline input[type="radio"] {
  margin: 0;
}

/* Actions row para botões lado a lado */
.actions-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.divider {
  text-align: center;
  margin: 20px 0;
  color: var(--text-muted);
  position: relative;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.divider::before,
.divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--bg-hover);
}

.divider::before {
  left: 0;
}

.divider::after {
  right: 0;
}

/* ================== Validation Mode Selector ================== */
.validation-mode-selector {
  margin-bottom: 20px;
}

.validation-mode-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
}

.validation-mode-buttons {
  display: flex;
  gap: 10px;
}

.mode-btn {
  flex: 1;
}

/* Estados de ativo por modo */
#mode-purchase.is-active {
  /* Azul para "Validar Compra" */
  background: #2D7FF9;
  color: #ffffff;
  border-color: #2D7FF9;
}

#mode-use.is-active {
  /* Amarelo para "Validar Uso" com alto contraste */
  background: #FFD93D;
  color: #111318;
  border-color: #FFD93D;
}

.validation-mode-help {
  margin-top: 8px;
  font-size: 0.85rem;
}

/* Botão outline (fallback visual quando não ativo) */
.btn-outline {
  background: transparent;
  border: 2px solid var(--bg-hover, #2A2E36);
  color: var(--text-primary, #F8F8FA);
}

.btn-outline:hover {
  background: var(--bg-hover, #2A2E36);
}

/* Acessibilidade e feedback de foco/press */
.mode-btn:focus-visible {
  outline: 3px solid var(--color-accent, #FFD93D);
  outline-offset: 2px;
}

/* Foco acessível para botões principais */
.btn:focus-visible {
  outline: 3px solid rgba(229,57,53,0.18);
  outline-offset: 3px;
}

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

/* ================== Responsive ================== */
@media (min-width: 768px) {
  .app-content {
    padding: calc(var(--header-height) + 20px) 20px 20px;
    max-width: 760px;
    margin: 0 auto;
  }

  .bottom-nav {
    max-width: 760px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
  }
}

/* Telas grandes: deixar ainda mais arejado, sem perder foco */
@media (min-width: 1200px) {
  .app-content {
    max-width: 920px;
  }
  .bottom-nav {
    max-width: 920px;
  }
}

/* Telas extra grandes: dá um pouco mais de respiro mantendo foco */
@media (min-width: 1440px) {
  .app-content {
    max-width: 1040px;
  }
  .bottom-nav {
    max-width: 1040px;
  }
}

/* ================== Print ================== */
@media print {
  body {
    background: white;
  }

  .app-header,
  .bottom-nav,
  .btn {
    display: none;
  }

  .qr-display {
    break-inside: avoid;
  }
}

/* ================== Dark Mode Support ================== */
@media (prefers-color-scheme: light) {
  :root {
    --bg-dark: #F5F5F7;
    --bg-card: #FFFFFF;
    --bg-input: #F0F0F3;
    --bg-hover: #E8E8EB;
    --text-primary: #1C1C1E;
    --text-secondary: #3A3A3C;
    --text-muted: #8E8E93;
  }
}

/* ================== Modal (Código amigável) ================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  padding: 16px;
}
.modal-card {
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: 14px;
  box-shadow: var(--shadow-float);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}
.modal-card.small { max-width: 380px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.modal-body { padding: 16px; }
.modal-footer {
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.code-block { margin: 12px 0; }
.code-block.subtle { opacity: 0.85; }
.code-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.code-value {
  background: var(--bg-input);
  border-radius: 10px;
  padding: 9px 11px;
  word-break: break-word;
}
.code-actions { margin-top: 8px; display: flex; gap: 8px; }
.monospace { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 15px; letter-spacing: 0.5px; }
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin-bottom: 8px;
}
.info-grid .label { font-size: 12px; color: var(--text-muted); }
.info-grid .value { font-size: 13px; font-weight: 600; }
.pending-list { margin-top: 12px; }

/* Pending actions */
.pending-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ================== Center Popup ================== */
.center-popup-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.35);
  z-index: 1100;
}
.center-popup-card {
  width: 86vw;
  max-width: 420px;
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: 14px;
  box-shadow: var(--shadow-float);
  padding: 16px;
  text-align: center;
  border: 1px solid transparent;
  transform: scale(0.96);
  opacity: 0;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}
.center-popup-card.show { transform: scale(1); opacity: 1; }
.center-popup-icon { width: 36px; height: 36px; margin: 0 auto 8px; }
.center-popup-icon svg { width: 100%; height: 100%; }
.center-popup-title { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.center-popup-message { font-size: 13px; color: var(--text-secondary); }
.center-popup-overlay.success .center-popup-card { border-color: var(--color-success); }
.center-popup-overlay.error .center-popup-card { border-color: var(--color-error); }
.center-popup-overlay.warning .center-popup-card { border-color: var(--color-warning); }
.center-popup-overlay.info .center-popup-card { border-color: var(--color-info); }

/* ================== Dashboard & Stats ================== */
.dashboard-header {
  margin-bottom: 16px;
}

.dashboard-header h2 {
  margin-bottom: 12px;
}

.dashboard-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.dashboard-controls .filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-input);
  border-radius: var(--border-radius);
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

@media (hover: hover) {
  .stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: rgba(255, 255, 255, 0.12);
  }
}

.stat-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  font-size: 16px;
}

.stat-icon.success { background: rgba(46, 204, 113, 0.15); color: var(--color-success); }
.stat-icon.error { background: rgba(231, 76, 60, 0.15); color: var(--color-error); }
.stat-icon.warning { background: rgba(241, 196, 15, 0.15); color: var(--color-warning); }
.stat-icon.info { background: rgba(52, 152, 219, 0.15); color: var(--color-info); }
.stat-icon.primary { background: rgba(229, 57, 53, 0.15); color: var(--color-primary); }
.stat-icon.secondary { background: rgba(255, 111, 163, 0.15); color: var(--color-secondary); }

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-value.currency {
  font-size: 18px;
}

.stat-change {
  font-size: 11px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-change.positive { color: var(--color-success); }
.stat-change.negative { color: var(--color-error); }

.charts-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.chart-card {
  background: var(--bg-input);
  border-radius: var(--border-radius);
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.chart-card.full-width {
  grid-column: 1 / -1;
}

.chart-card h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chart-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.chart-card-header h3 {
  margin: 0;
  flex: 1 1 100%;
}

.chart-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}

/* Control genérico para labels com inputs/selects */
.control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.chart-controls .control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  flex: 1 1 140px;
}

.select-sm {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  padding: 7px 9px;
  font-size: 12px;
  transition: var(--transition-fast);
}
.select-sm:hover { border-color: rgba(229,57,53,0.35); }
.select-sm:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(229,57,53,.12); background: var(--bg-hover); }

/* Selects modernos (mapeados para o visual dos inputs) */
.select-modern {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  transition: var(--transition-fast);
}
.select-modern:hover { border-color: rgba(229,57,53,0.35); }
.select-modern:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(229,57,53,.12); background: var(--bg-hover); }
.select-compact { padding: 7px 9px; font-size: 12px; }

/* Inputs e selects do modal de perfil: aparência consistente e moderna */
#profile-dialog .form-group input,
#profile-dialog .form-group select,
#profile-dialog .form-group textarea {
  background: var(--bg-input);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
}
#profile-dialog .form-inline input {
  background: var(--bg-input);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}
#profile-dialog .form-group input:focus,
#profile-dialog .form-group select:focus,
#profile-dialog .form-group textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--bg-hover);
  box-shadow: 0 0 0 3px rgba(229,57,53,.12);
}
#profile-dialog .form-inline input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--bg-hover);
  box-shadow: 0 0 0 3px rgba(229,57,53,.12);
}
#profile-dialog .form-inline { gap: 10px; align-items: center; }

/* Classe utilitária para modernizar inputs em qualquer container */
.input-modern {
  background: var(--bg-input);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px !important;
  padding: 10px 12px !important;
  font-size: 13px !important;
  transition: var(--transition-fast);
}
.input-modern:hover { border-color: rgba(229,57,53,0.35); }
.input-modern:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--bg-hover);
  box-shadow: 0 0 0 3px rgba(229,57,53,.12);
}

.table-wrapper { overflow-x: auto; margin-top: 12px; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 8px 10px; text-align: left; }
.data-table thead th { font-size: 12px; color: var(--text-muted); border-bottom: 1px solid rgba(255,255,255,0.08); cursor: pointer; }
.data-table tbody td { font-size: 13px; color: var(--text-primary); border-bottom: 1px dashed rgba(255,255,255,0.06); }
.data-table.compact td { padding: 6px 8px; }
.data-table th.sort-asc::after { content: ' \25B2'; font-size: 10px; color: var(--text-muted); }
.data-table th.sort-desc::after { content: ' \25BC'; font-size: 10px; color: var(--text-muted); }

.chart-card canvas {
  max-height: 280px;
}

.chart-card.full-width canvas {
  max-height: 220px;
}

/* Dashboard responsive */
@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .stat-value {
    font-size: 20px;
  }
  
  .stat-value.currency {
    font-size: 18px;
  }
  
  .charts-container {
    grid-template-columns: 1fr;
  }
  
  .chart-card canvas {
    max-height: 240px;
  }
  
  .dashboard-controls {
    gap: 10px;
  }
}

@media (min-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .charts-container {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* =============== Perfil: modal mais usável (grande e com rolagem) =============== */
/* Aumenta o tamanho do modal de perfil e melhora navegação em conteúdo extenso */
#profile-dialog .modal-card {
  width: 96vw;
  max-width: 820px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
#profile-dialog .modal-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-card);
}
#profile-dialog .modal-body {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
}
#profile-dialog .modal-footer {
  position: sticky;
  bottom: 0;
  z-index: 1;
  background: var(--bg-card);
}
/* Fullscreen amigável no mobile: ocupa a tela inteira e remove bordas arredondadas */
@media (max-width: 640px) {
  #profile-dialog .modal-card {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }
  #profile-dialog .modal-header { padding-top: calc(14px + var(--safe-area-top)); }
  #profile-dialog .modal-footer { padding-bottom: calc(16px + var(--safe-area-bottom)); }
}

/* ================== Profile Tabs (no modal de Perfil) ================== */
.profile-tabs {
  display: flex;
  gap: 6px;
  margin: 6px 2px 12px 2px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding-bottom: 6px;
  position: sticky;
  top: 0; /* fica logo abaixo do header sticky */
  background: var(--bg-card);
  z-index: 1;
}
.profile-tab {
  padding: 7px 11px;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}
.profile-tab:hover { background: var(--bg-hover); }
.profile-tab.active {
  color: var(--text-primary);
  background: var(--bg-input);
  border-color: rgba(255,255,255,0.08);
}

/* ================== Subtabs (navegação interna por seção) ================== */
.profile-subtabs {
  display: flex;
  gap: 6px;
  margin: 4px 0 12px 0;
  border-bottom: 1px dashed rgba(255,255,255,0.06);
  padding-bottom: 6px;
  position: sticky;
  top: 40px; /* aparece logo abaixo das tabs principais */
  background: var(--bg-card);
  z-index: 1;
}
.profile-subtabs .subtab {
  padding: 5px 9px;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 11px;
  text-decoration: none;
}
.profile-subtabs .subtab:hover { background: var(--bg-hover); }
.profile-subtabs .subtab.active {
  color: var(--text-primary);
  background: var(--bg-input);
  border-color: rgba(255,255,255,0.08);
}

/* Offset para âncoras internas (considera header e tabs stickies) */
.anchor-offset { scroll-margin-top: 96px; }

/* ================== Layout em duas colunas (desktop) ================== */
.profile-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
}
.profile-two-col .col-left,
.profile-two-col .col-right { min-width: 0; }

@media (max-width: 900px) {
  .profile-two-col { grid-template-columns: 1fr; }
}

