/* ============================================
   GMASYSTEM MEDENTREGA - DESIGN SYSTEM
   Cores extraídas da logo GMASystem
   ============================================ */

:root {
  --gma-laranja:     #FF6B35;
  --gma-rosa:        #E8185C;
  --gma-roxo:        #8B1FC8;
  --gma-roxo-escuro: #5A0E8A;
  --gma-fundo:       #0F0F1A;
  --gma-fundo2:      #1A1A2E;
  --gma-fundo3:      #16213E;
  --gma-card:        #1E1E35;
  --gma-border:      #2D2D50;
  --gma-texto:       #E8E8F0;
  --gma-texto-muted: #8888AA;
  --gma-grad-main:   linear-gradient(135deg, #FF6B35 0%, #E8185C 50%, #8B1FC8 100%);
  --gma-grad-card:   linear-gradient(135deg, #FF6B35 0%, #E8185C 100%);
  --gma-grad-roxo:   linear-gradient(135deg, #E8185C 0%, #8B1FC8 100%);
  --sidebar-width:   260px;
}

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

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--gma-fundo);
  color: var(--gma-texto);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
  min-height: 100vh;
  background: var(--gma-fundo);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(139,31,200,0.25) 0%, transparent 70%);
  top: -150px; right: -150px;
  border-radius: 50%;
  animation: pulse-bg 6s ease-in-out infinite alternate;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(255,107,53,0.20) 0%, transparent 70%);
  bottom: -150px; left: -100px;
  border-radius: 50%;
  animation: pulse-bg 8s ease-in-out infinite alternate-reverse;
}

@keyframes pulse-bg {
  from { transform: scale(1); opacity: 0.6; }
  to   { transform: scale(1.2); opacity: 1; }
}

.login-card {
  background: var(--gma-card);
  border: 1px solid var(--gma-border);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 10;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5),
              0 0 0 1px rgba(139,31,200,0.15);
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gma-grad-main);
  border-radius: 20px 20px 0 0;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo img {
  width: 120px;
  filter: drop-shadow(0 0 20px rgba(232,24,92,0.4));
  animation: logo-float 3s ease-in-out infinite alternate;
}

@keyframes logo-float {
  from { transform: translateY(0); }
  to   { transform: translateY(-6px); }
}

.login-logo h1 {
  font-size: 1.1rem;
  color: var(--gma-texto-muted);
  margin-top: 12px;
  font-weight: 400;
  letter-spacing: 0.05em;
}

.login-logo h1 span {
  background: var(--gma-grad-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
}

/* ============================================
   SIDEBAR
   ============================================ */
.layout-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--gma-fundo2);
  border-right: 1px solid var(--gma-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--gma-border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(180deg, rgba(139,31,200,0.08) 0%, transparent 100%);
}

.sidebar-brand img {
  width: 44px;
  filter: drop-shadow(0 0 8px rgba(232,24,92,0.5));
}

.sidebar-brand-text .brand-name {
  font-weight: 800;
  font-size: 1rem;
  background: var(--gma-grad-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}

.sidebar-brand-text .brand-sub {
  font-size: 0.65rem;
  color: var(--gma-texto-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gma-texto-muted);
  padding: 16px 12px 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--gma-texto-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  margin-bottom: 2px;
  position: relative;
}

.sidebar-link:hover {
  background: rgba(255,107,53,0.08);
  color: var(--gma-laranja);
}

.sidebar-link.active {
  background: linear-gradient(90deg, rgba(255,107,53,0.15) 0%, rgba(139,31,200,0.08) 100%);
  color: var(--gma-texto);
  border: 1px solid rgba(255,107,53,0.2);
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--gma-grad-card);
  border-radius: 0 3px 3px 0;
}

.sidebar-link i {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

.sidebar-link .badge-alert {
  margin-left: auto;
  background: var(--gma-rosa);
  color: #fff;
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 700;
}

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

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.03);
  border-radius: 10px;
  margin-bottom: 8px;
}

.user-avatar {
  width: 36px; height: 36px;
  background: var(--gma-grad-main);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.user-name { font-size: 0.8rem; font-weight: 600; line-height: 1.1; }
.user-role { font-size: 0.65rem; color: var(--gma-texto-muted); text-transform: capitalize; }

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--gma-fundo2);
  border-bottom: 1px solid var(--gma-border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
}

.topbar-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gma-texto);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-content {
  padding: 28px;
  flex: 1;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn-gma {
  background: var(--gma-grad-main);
  border: none;
  color: #fff;
  font-weight: 600;
  border-radius: 10px;
  padding: 10px 22px;
  transition: all 0.2s ease;
  cursor: pointer;
  font-size: 0.875rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-gma:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(232,24,92,0.35);
  color: #fff;
}

.btn-gma-outline {
  background: transparent;
  border: 1px solid rgba(255,107,53,0.4);
  color: var(--gma-laranja);
  font-weight: 600;
  border-radius: 10px;
  padding: 8px 18px;
  transition: all 0.2s ease;
  cursor: pointer;
  font-size: 0.875rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-gma-outline:hover {
  background: rgba(255,107,53,0.1);
  border-color: var(--gma-laranja);
  color: var(--gma-laranja);
}

.btn-sm-gma {
  padding: 5px 12px;
  font-size: 0.78rem;
  border-radius: 7px;
}

/* ============================================
   CARDS
   ============================================ */
.gma-card {
  background: var(--gma-card);
  border: 1px solid var(--gma-border);
  border-radius: 16px;
  padding: 24px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.gma-card:hover {
  border-color: rgba(232,24,92,0.25);
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

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

.gma-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gma-texto);
}

/* STAT CARDS */
.stat-card {
  background: var(--gma-card);
  border: 1px solid var(--gma-border);
  border-radius: 16px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  opacity: 0;
  transition: opacity 0.2s;
}

.stat-card:hover { transform: translateY(-3px); box-shadow: 0 12px 40px rgba(0,0,0,0.3); }
.stat-card:hover::before { opacity: 1; }

.stat-card.laranja::before { background: var(--gma-laranja); }
.stat-card.rosa::before    { background: var(--gma-rosa); }
.stat-card.roxo::before    { background: var(--gma-roxo); }
.stat-card.perigo::before  { background: #dc3545; }
.stat-card.aviso::before   { background: #ffc107; }
.stat-card.sucesso::before { background: #28a745; }

.stat-icon {
  width: 54px; height: 54px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-icon.laranja { background: rgba(255,107,53,0.15); color: var(--gma-laranja); }
.stat-icon.rosa    { background: rgba(232,24,92,0.15);  color: var(--gma-rosa); }
.stat-icon.roxo    { background: rgba(139,31,200,0.15); color: var(--gma-roxo); }
.stat-icon.perigo  { background: rgba(220,53,69,0.15);  color: #dc3545; }
.stat-icon.aviso   { background: rgba(255,193,7,0.15);  color: #ffc107; }
.stat-icon.sucesso { background: rgba(40,167,69,0.15);  color: #28a745; }

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  background: var(--gma-grad-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--gma-texto-muted);
  margin-top: 3px;
  font-weight: 500;
}

/* ============================================
   TABLE
   ============================================ */
.gma-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}

.gma-table thead th {
  background: rgba(255,255,255,0.03);
  color: var(--gma-texto-muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gma-border);
  white-space: nowrap;
}

.gma-table tbody tr {
  border-bottom: 1px solid rgba(45,45,80,0.5);
  transition: background 0.15s ease;
}

.gma-table tbody tr:hover {
  background: rgba(255,107,53,0.04);
}

.gma-table tbody td {
  padding: 13px 16px;
  color: var(--gma-texto);
  vertical-align: middle;
}

/* ============================================
   BADGES / GRAVIDADE
   ============================================ */
.badge-gma {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-alta    { background: rgba(220,53,69,0.18); color: #ff6b6b; border: 1px solid rgba(220,53,69,0.3); }
.badge-media   { background: rgba(255,193,7,0.18); color: #ffd43b; border: 1px solid rgba(255,193,7,0.3); }
.badge-baixa   { background: rgba(40,167,69,0.18); color: #69db7c; border: 1px solid rgba(40,167,69,0.3); }

.badge-entregue     { background: rgba(40,167,69,0.18);  color: #69db7c; border: 1px solid rgba(40,167,69,0.3); }
.badge-agendada     { background: rgba(139,31,200,0.18); color: #be4bdb; border: 1px solid rgba(139,31,200,0.3); }
.badge-em_rota      { background: rgba(255,107,53,0.18); color: var(--gma-laranja); border: 1px solid rgba(255,107,53,0.3); }
.badge-cancelada    { background: rgba(108,117,125,0.18); color: #adb5bd; border: 1px solid rgba(108,117,125,0.3); }
.badge-nao_encontrado { background: rgba(220,53,69,0.18); color: #ff6b6b; border: 1px solid rgba(220,53,69,0.3); }

.badge-essencial  { background: rgba(139,31,200,0.18); color: #be4bdb; border: 1px solid rgba(139,31,200,0.3); }
.badge-alto_custo { background: rgba(255,107,53,0.18); color: var(--gma-laranja); border: 1px solid rgba(255,107,53,0.3); }
.badge-insumo     { background: rgba(40,167,69,0.18);  color: #69db7c; border: 1px solid rgba(40,167,69,0.3); }

.badge-ok      { background: rgba(40,167,69,0.18);  color: #69db7c; border: 1px solid rgba(40,167,69,0.3); }
.badge-atencao { background: rgba(255,193,7,0.18);  color: #ffd43b; border: 1px solid rgba(255,193,7,0.3); }
.badge-critico { background: rgba(255,107,53,0.18); color: var(--gma-laranja); border: 1px solid rgba(255,107,53,0.3); }
.badge-vencido { background: rgba(220,53,69,0.18);  color: #ff6b6b; border: 1px solid rgba(220,53,69,0.3); }

/* ============================================
   FORMS
   ============================================ */
.form-label {
  color: var(--gma-texto-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.form-control, .form-select {
  background: rgba(255,255,255,0.04) !important;
  border: 1px solid var(--gma-border) !important;
  color: var(--gma-texto) !important;
  border-radius: 10px !important;
  padding: 10px 14px !important;
  font-size: 0.875rem !important;
  transition: border-color 0.2s, box-shadow 0.2s !important;
}

.form-control:focus, .form-select:focus {
  border-color: var(--gma-rosa) !important;
  box-shadow: 0 0 0 3px rgba(232,24,92,0.12) !important;
  background: rgba(255,255,255,0.06) !important;
  outline: none !important;
}

.form-control::placeholder { color: rgba(136,136,170,0.6) !important; }

.form-check-input {
  background-color: rgba(255,255,255,0.05) !important;
  border-color: var(--gma-border) !important;
}

.form-check-input:checked {
  background-color: var(--gma-rosa) !important;
  border-color: var(--gma-rosa) !important;
}

/* ============================================
   ALERTS & NOTIFICATIONS
   ============================================ */
.alert-gma {
  background: rgba(220,53,69,0.1);
  border: 1px solid rgba(220,53,69,0.25);
  color: #ff6b6b;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(45,45,80,0.5);
  transition: background 0.15s;
}

.notif-item:last-child { border-bottom: none; }

.notif-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}

.notif-icon.danger  { background: rgba(220,53,69,0.15); color: #ff6b6b; }
.notif-icon.warning { background: rgba(255,193,7,0.15); color: #ffd43b; }
.notif-icon.info    { background: rgba(139,31,200,0.15); color: #be4bdb; }

.notif-text { font-size: 0.8rem; line-height: 1.5; }
.notif-text strong { color: var(--gma-texto); }
.notif-time { font-size: 0.7rem; color: var(--gma-texto-muted); margin-top: 3px; }

/* ============================================
   MAPA
   ============================================ */
#map {
  height: 600px;
  border-radius: 16px;
  border: 1px solid var(--gma-border);
  overflow: hidden;
}

.map-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.map-legend {
  background: var(--gma-card);
  border: 1px solid var(--gma-border);
  border-radius: 12px;
  padding: 16px 20px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--gma-texto-muted);
  margin-bottom: 8px;
}

.legend-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}

/* ============================================
   PROGRESS BAR
   ============================================ */
.gma-progress {
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.gma-progress-bar {
  height: 100%;
  border-radius: 3px;
  background: var(--gma-grad-main);
  transition: width 0.6s ease;
}

/* ============================================
   MODAL DARK
   ============================================ */
.modal-content {
  background: var(--gma-card) !important;
  border: 1px solid var(--gma-border) !important;
  border-radius: 16px !important;
  color: var(--gma-texto) !important;
}

.modal-header {
  border-bottom: 1px solid var(--gma-border) !important;
  background: linear-gradient(90deg, rgba(255,107,53,0.08), rgba(139,31,200,0.08)) !important;
  border-radius: 16px 16px 0 0 !important;
}

.modal-footer {
  border-top: 1px solid var(--gma-border) !important;
}

.modal-title { font-weight: 700; }

.btn-close {
  filter: invert(1) !important;
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gma-fundo2); }
::-webkit-scrollbar-thumb { background: var(--gma-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(232,24,92,0.4); }

/* ============================================
   UTILITIES
   ============================================ */
.gradient-text {
  background: var(--gma-grad-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

.text-muted-gma { color: var(--gma-texto-muted) !important; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .stat-value { font-size: 1.5rem; }
  .page-content { padding: 16px; }
}

/* ============================================
   ANIMAÇÕES
   ============================================ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in-up {
  animation: fadeInUp 0.4s ease forwards;
}

.fade-in-up:nth-child(1) { animation-delay: 0.05s; }
.fade-in-up:nth-child(2) { animation-delay: 0.10s; }
.fade-in-up:nth-child(3) { animation-delay: 0.15s; }
.fade-in-up:nth-child(4) { animation-delay: 0.20s; }
.fade-in-up:nth-child(5) { animation-delay: 0.25s; }
.fade-in-up:nth-child(6) { animation-delay: 0.30s; }
/* ============================================================
   RESPONSIVIDADE COMPLETA — Android, iPhone, Tablet, Desktop
   ============================================================ */

/* ── Overlay para sidebar mobile ───────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 99;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ── Layout base ───────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .3s ease;
}

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--gma-fundo2);
  border-bottom: 1px solid var(--gma-border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
}
.topbar-title {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60vw;
}

/* ── Tabelas — scroll horizontal no mobile ─────────────────── */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 10px;
}
.gma-table {
  min-width: 600px;
}

/* ── Cards — grid responsivo ───────────────────────────────── */
.row.g-3 > [class*="col-"] {
  transition: none;
}

/* ── Botões — tamanho mínimo para toque ────────────────────── */
.btn-gma, .btn-gma-outline, .btn-sm-gma {
  min-height: 40px;
  touch-action: manipulation;
}

/* ── Formulários ────────────────────────────────────────────── */
.form-control, .form-select {
  font-size: 16px !important; /* evita zoom no iOS ao focar input */
}

/* ══════════════════════════════════════════════════
   TABLET (≤ 992px)
   ══════════════════════════════════════════════════ */
@media (max-width: 992px) {
  :root { --sidebar-width: 240px; }

  .topbar { padding: 10px 16px; }
  .page-content { padding: 16px; }

  /* Tabelas: esconder colunas menos importantes */
  .gma-table .col-hide-tablet { display: none; }
}

/* ══════════════════════════════════════════════════
   MOBILE GRANDE (≤ 768px) — Android e iPhone Plus
   ══════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Sidebar fecha por padrão */
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
    width: 280px;
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }

  /* Topbar mobile */
  .topbar {
    padding: 10px 14px;
    gap: 10px;
  }
  .topbar-title { font-size: .9rem; max-width: 50vw; }
  #menuToggle { display: flex !important; align-items: center; }

  /* Conteúdo */
  .page-content { padding: 12px; }

  /* Cards de stat menores */
  .stat-value { font-size: 1.4rem; }
  .gma-card { padding: 14px; }
  .gma-card-header { flex-wrap: wrap; gap: 8px; }

  /* Botões — empilhar em mobile */
  .d-flex.gap-2.flex-wrap { gap: 6px !important; }
  .btn-gma, .btn-gma-outline {
    font-size: .82rem;
    padding: 10px 14px;
  }

  /* Grid de relatórios — 2 colunas em mobile */
  .col-xl-3 { flex: 0 0 50%; max-width: 50%; }

  /* Tabelas */
  .gma-table { font-size: .78rem; }
  .gma-table td, .gma-table th { padding: 8px 10px; }
  .gma-table .col-hide-mobile { display: none; }

  /* Filtros — empilhar */
  .row.g-3 .col-md-3,
  .row.g-3 .col-md-4,
  .row.g-3 .col-md-6 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Dashboard stats — 2 colunas */
  .row.g-3 .col-md-3.col-xl-3 {
    flex: 0 0 50%;
    max-width: 50%;
  }

  /* Header das páginas */
  .d-flex.justify-content-between.align-items-center {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 12px;
  }
  .d-flex.justify-content-between.align-items-center > div:last-child {
    width: 100%;
  }
  .d-flex.justify-content-between > .btn-gma,
  .d-flex.justify-content-between > .btn-gma-outline {
    width: 100%;
    justify-content: center;
  }

  /* Formulários */
  .col-md-1, .col-md-2 {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* ══════════════════════════════════════════════════
   MOBILE PEQUENO (≤ 480px) — iPhone SE, Galaxy A
   ══════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .page-content { padding: 10px; }
  .gma-card { padding: 12px; border-radius: 12px; }
  .stat-value { font-size: 1.2rem; }

  /* Stats — 1 coluna */
  .row.g-3 .col-md-3.col-xl-3,
  .row.g-3 .col-6 {
    flex: 0 0 50%;
    max-width: 50%;
  }

  /* Topbar */
  .topbar-title { font-size: .82rem; max-width: 45vw; }

  /* Tabela — compactar mais */
  .gma-table td, .gma-table th { padding: 6px 8px; font-size: .72rem; }

  /* Badges menores */
  .badge-gma { font-size: .62rem; padding: 2px 7px; }

  /* Botões de ação na tabela — ícone só */
  .btn-acao-texto { display: none; }
}

/* ══════════════════════════════════════════════════
   iOS SAFARI — safe areas (notch/home bar)
   ══════════════════════════════════════════════════ */
@supports (padding: max(0px)) {
  .topbar {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
  .page-content {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
  footer {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
}

/* ══════════════════════════════════════════════════
   PWA — quando instalado como app
   ══════════════════════════════════════════════════ */
@media (display-mode: standalone) {
  .topbar {
    padding-top: max(14px, env(safe-area-inset-top));
  }
}

/* ── Sidebar scroll suave no mobile ────────────────────────── */
.sidebar { -webkit-overflow-scrolling: touch; }

/* ── Melhorar toque em links da sidebar ─────────────────────── */
.sidebar-link {
  min-height: 44px; /* mínimo recomendado pela Apple/Google */
  -webkit-tap-highlight-color: transparent;
}

/* ── Evitar seleção acidental de texto em botões ────────────── */
.btn-gma, .btn-gma-outline, .btn-sm-gma, .sidebar-link {
  -webkit-user-select: none;
  user-select: none;
}

/* ── Scroll suave global ────────────────────────────────────── */
html { scroll-behavior: smooth; }

/* ── Imagens responsivas ────────────────────────────────────── */
img { max-width: 100%; height: auto; }
