/* ================================================================
   PRECIFIKA — MOBILE OPTIMIZATIONS v3 (Full parity with desktop)
   Breakpoints:
     ≤ 900px  → tablet/phablet (sidebar vira overlay)
     ≤ 600px  → smartphone landscape
     ≤ 480px  → smartphone portrait
   ================================================================ */

/* ── Variáveis mobile ── */
:root {
  --bottom-nav-h: 64px;
  --topbar-h-mob: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

/* ================================================================
   1. BOTTOM NAVIGATION BAR (≤ 900px, pós-login)
   ================================================================ */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 900px) {
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(var(--bottom-nav-h) + var(--safe-bottom));
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 20px rgba(0,0,0,.08);
    z-index: 200;
    padding-bottom: var(--safe-bottom);
    align-items: stretch;
  }

  .mob-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: none;
    background: none;
    color: #94a3b8;
    font-size: 10px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    padding: 8px 4px 6px;
    transition: color .15s;
    text-decoration: none;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
  }

  .mob-nav-item i {
    font-size: 20px;
    transition: transform .15s, color .15s;
  }

  .mob-nav-item.active { color: #2563eb; }
  .mob-nav-item.active i { transform: translateY(-2px); }

  .mob-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0; left: 20%; right: 20%;
    height: 3px;
    background: #2563eb;
    border-radius: 0 0 4px 4px;
  }

  /* Botão central +Novo */
  .mob-nav-item--primary { color: #ffffff !important; }
  .mob-nav-item--primary .mob-nav-icon-wrap {
    width: 46px; height: 46px;
    background: linear-gradient(135deg, #2563eb, #0ea5e9);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 14px rgba(37,99,235,.4);
    margin-top: -12px;
    transition: transform .15s, box-shadow .15s;
  }
  .mob-nav-item--primary:active .mob-nav-icon-wrap {
    transform: scale(.93);
    box-shadow: 0 2px 8px rgba(37,99,235,.3);
  }
  .mob-nav-item--primary i { font-size: 20px; transform: none !important; }
  .mob-nav-item--primary::before { display: none !important; }

  .mob-nav-badge {
    position: absolute;
    top: 6px; right: calc(50% - 18px);
    background: #ef4444; color: white;
    font-size: 9px; font-weight: 800;
    width: 16px; height: 16px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid white;
  }

  /* Espaço para não cobrir conteúdo */
  .page-content,
  .page > .page-content {
    padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px) !important;
  }
  .adm-tab {
    padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 12px) !important;
  }
}

/* ================================================================
   2. SIDEBAR — overlay mobile
   ================================================================ */
@media (max-width: 900px) {
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 99;
    backdrop-filter: blur(2px);
  }
  .sidebar-overlay.visible { display: block; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    width: 270px !important;
    border-radius: 0 20px 20px 0;
    box-shadow: 4px 0 24px rgba(0,0,0,.2);
    z-index: 100;
    transition: transform .25s ease;
    overflow-y: auto;
  }
  .sidebar.mobile-open { transform: translateX(0); }

  .main-content { margin-left: 0 !important; }
}

/* ================================================================
   3. TOPBAR MOBILE
   ================================================================ */
@media (max-width: 900px) {
  .topbar {
    height: var(--topbar-h-mob);
    padding: 0 14px;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 50;
  }

  .topbar-breadcrumb {
    font-size: 15px;
    font-weight: 700;
  }

  .topbar-right { gap: 8px; }

  /* Oculta btn "Novo Orçamento" topbar — está no bottom nav */
  .topbar .btn-primary,
  .topbar > .topbar-right > .btn.btn-primary,
  #topbar-new-btn { display: none !important; }

  /* Indicador de uso compacto */
  .topbar-usage { gap: 4px; }
  .topbar-usage-item {
    font-size: 11px;
    padding: 4px 8px;
    gap: 4px;
  }

  /* Instalar: oculta texto, mantém ícone */
  .install-app-btn-label { display: none; }
  .install-app-btn { padding: 6px 8px; font-size: 15px; }

  /* Avatar dropdown */
  .topbar-user-avatar { width: 32px; height: 32px; font-size: 12px; }
}

@media (max-width: 480px) {
  .topbar-usage { display: none !important; }
}

/* ================================================================
   4. DASHBOARD — hero, KPIs, ações rápidas
   ================================================================ */
@media (max-width: 900px) {
  /* Remove padding lateral excessivo */
  #page-dashboard .page-content {
    padding: 14px 14px calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px) !important;
  }

  .db-hero {
    padding: 20px 16px 16px;
    border-radius: 16px;
    margin-bottom: 16px;
  }

  .db-hero-greeting { font-size: 14px; }
  .db-hero-title    { font-size: 20px; line-height: 1.3; }
  .db-hero-sub      { font-size: 13px; }
  .db-hero-stats    { display: none; }

  .db-hero-actions {
    flex-direction: row;
    gap: 8px;
    margin-top: 14px;
  }
  .db-hero-actions .btn {
    flex: 1;
    justify-content: center;
    font-size: 13px;
    padding: 10px 10px;
  }

  /* Insight bar inline */
  .db-insight-bar {
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 14px;
  }

  /* Body grid → 1 coluna */
  .db-body { grid-template-columns: 1fr; gap: 12px; }
  .db-sidebar-col { display: none; }

  /* Cabeçalho de colunas da lista: oculto em mobile */
  .db-list-head--desktop { display: none; }
}

/* ── Ações rápidas mobile do dashboard ── */
.db-mob-actions {
  display: none; /* oculto em desktop */
}

@media (max-width: 900px) {
  .db-mob-actions {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 14px;
  }
}

@media (max-width: 480px) {
  .db-mob-actions {
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }
}

.db-mob-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 10px 4px;
  cursor: pointer;
  font-size: 10.5px;
  font-weight: 600;
  color: #475569;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s, transform .1s;
}

.db-mob-action-btn:active {
  transform: scale(.94);
  background: #f8fafc;
}

.db-mob-action-icon {
  width: 38px; height: 38px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}

@media (max-width: 600px) {
  .db-kpis {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .db-kpi { padding: 14px 12px; border-radius: 14px; }
  .db-kpi-value  { font-size: 20px; }
  .db-kpi-icon   { width: 36px; height: 36px; font-size: 15px; }
  .db-kpi-label  { font-size: 11px; }
  .db-kpi-sub    { font-size: 10.5px; }

  .db-actions-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }
  .db-action-btn   { padding: 12px 4px 10px; border-radius: 12px; }
  .db-action-icon  { font-size: 20px; }
  .db-action-label { font-size: 10px; }
}

@media (max-width: 480px) {
  .db-kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .db-kpi  { padding: 12px 10px; }
  .db-kpi-value { font-size: 18px; }
  .db-kpi-spark { display: none; }
  .db-mob-action-btn { font-size: 9.5px; padding: 8px 3px; }
  .db-mob-action-icon { width: 34px; height: 34px; font-size: 14px; border-radius: 10px; }
}

/* ================================================================
   5. LISTA DE ORÇAMENTOS
   ================================================================ */
@media (max-width: 900px) {
  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .search-box { max-width: 100%; width: 100%; }
  .filter-group { flex-wrap: wrap; gap: 6px; }
  .filter-group select,
  .filter-group .form-select {
    flex: 1;
    min-width: 120px;
    font-size: 13px;
  }
}

@media (max-width: 700px) {
  /* Oculta tabelas em favor de cards */
  .est-table-wrap { display: none !important; }
  .est-cards-wrap { display: flex !important; }

  /* Clientes */
  .cl-table-wrap > .cl-table { display: none !important; }
  #clients-cards { display: flex !important; }

  /* Serviços */
  .srv-table-wrap { display: none !important; }
  .srv-cards { display: flex !important; }
}

@media (max-width: 600px) {
  .db-row { padding: 12px 14px; gap: 6px; }
  .db-row-name   { font-size: 13.5px; font-weight: 700; }
  .db-row-client { font-size: 12px; }
  .db-row-date   { display: none; }
  .db-row-value  { font-size: 14px; font-weight: 800; }
}

/* ── Cards de orçamento (mobile) ── */
.est-cards-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 4px;
}

.est-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
  transition: box-shadow .15s, transform .15s;
  -webkit-tap-highlight-color: transparent;
}

.est-card:active {
  transform: scale(.98);
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

.est-card-avatar {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800;
  color: white; flex-shrink: 0;
}

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

.est-card-name {
  font-size: 14px; font-weight: 700; color: #0f172a;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 3px;
}

.est-card-client {
  font-size: 12px; color: #64748b;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 5px;
}
.est-card-client i { margin-right: 3px; }

.est-card-meta {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
}

.est-card-date {
  font-size: 11.5px; color: #94a3b8;
}
.est-card-date i { margin-right: 3px; }

.est-card-status {
  font-size: 11.5px; font-weight: 600;
}
.est-card-status i { margin-right: 3px; }

.est-card-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.est-card-value {
  font-size: 15px; font-weight: 800; color: #0f172a;
  white-space: nowrap;
}

.est-card-actions {
  display: flex; gap: 6px;
}

.est-card-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}

.est-card-btn--pdf {
  background: #eff6ff; color: #2563eb;
}
.est-card-btn--pdf:hover { background: #dbeafe; }

.est-card-btn--del {
  background: #fef2f2; color: #ef4444;
}
.est-card-btn--del:hover { background: #fee2e2; }

/* ================================================================
   6. EDITOR DE ORÇAMENTO (estimate builder)
   ================================================================ */
@media (max-width: 900px) {
  /* Layout coluna única */
  .eb-layout {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  /* Topbar do editor */
  .eb-topbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 14px;
    background: white;
    position: sticky;
    top: var(--topbar-h-mob);
    z-index: 40;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
  }

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

  .eb-title   { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .eb-subtitle { display: none; }

  /* Botões de salvar: linha completa */
  .eb-topbar .btn-group {
    width: 100%;
    gap: 6px;
  }
  .eb-topbar .btn-group .btn {
    flex: 1;
    justify-content: center;
    font-size: 12.5px;
    padding: 8px 6px;
  }
  .eb-topbar .btn-group .btn span { display: none; }
  .eb-topbar .btn-group .btn i { margin: 0; font-size: 16px; }

  .eb-form-section { padding: 16px; border-radius: 14px; }
  .eb-section-title { font-size: 14px; }

  /* Coluna aside vem depois no mobile */
  .eb-aside { order: 2; }
  .eb-main-col { order: 1; }

  /* Botão de adicionar item — fixo acima do bottom nav */
  .eb-add-item-btn-wrap {
    position: sticky;
    bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 8px);
    z-index: 50;
    padding: 8px 0;
    background: linear-gradient(to top, rgba(248,250,252,1) 60%, transparent);
  }

  /* PDF/AI botões */
  .eb-action-bar {
    flex-wrap: wrap;
    gap: 8px;
  }
  .eb-action-bar .btn {
    flex: 1;
    justify-content: center;
    min-width: 120px;
    font-size: 13px;
  }
}

@media (max-width: 600px) {
  /* form-row → 1 coluna */
  .eb-layout .form-row,
  #page-estimate-builder .form-row {
    grid-template-columns: 1fr;
  }

  /* Linha de item → cards empilhados */
  .eb-item-row {
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    margin-bottom: 8px;
  }
  .eb-item-row .form-group { margin: 0; }

  /* Total */
  .eb-total-row  { font-size: 15px; }
  .eb-grand-total { font-size: 22px; }

  /* AI card */
  .eb-ai-card { border-radius: 14px; }
  .eb-ai-output { font-size: 13px; min-height: 120px; }

  /* Header de itens — botões empilhados em mobile */
  .eb-items-header {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
  .eb-items-header-right {
    width: 100%;
    display: flex;
    gap: 6px;
  }
  .eb-items-header-right .btn {
    flex: 1;
    justify-content: center;
    font-size: 12.5px;
  }
}

/* ── Cards de itens do editor (mobile) ── */
.eb-items-mobile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
}

.eb-item-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px;
}

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

.eb-item-card-num {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  background: #e2e8f0;
  padding: 2px 8px;
  border-radius: 20px;
}

.eb-item-card-del {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: none;
  background: #fef2f2;
  color: #ef4444;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  -webkit-tap-highlight-color: transparent;
}

.eb-item-card-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.eb-item-card-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
  font-size: 13px;
  color: #64748b;
}

.eb-item-card-total strong {
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
}

/* ================================================================
   7. CLIENTES — lista, detalhe, formulário
   ================================================================ */
@media (max-width: 900px) {
  .cl-toolbar { flex-direction: column; gap: 8px; }
  .cl-toolbar .search-box { max-width: 100%; }

  .cl-stats-strip {
    padding: 12px 14px;
    gap: 8px;
    border-radius: 12px;
    flex-wrap: wrap;
  }
  .cl-stat     { font-size: 12px; flex: 1; min-width: 60px; }
  .cl-stat-val { font-size: 18px; }
}

@media (max-width: 600px) {
  .cl-card { padding: 14px; border-radius: 12px; }

  /* Detalhe do cliente */
  .cd-hero-card { padding: 16px; border-radius: 14px; }
  .cd-hero-name { font-size: 18px; }
  .cd-layout    { grid-template-columns: 1fr; }

  .cd-topbar {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
  .cd-actions { width: 100%; flex-wrap: wrap; gap: 6px; }
  .cd-actions .btn {
    flex: 1;
    justify-content: center;
    min-width: 0;
    font-size: 12.5px;
  }

  /* Lista de orçamentos do cliente */
  .cd-estimates-list .db-row { padding: 10px 12px; }
}

/* ── Cards mobile de clientes ── */
.cl-cards-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cl-mob-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow .15s;
}

.cl-mob-card:active {
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

.cl-mob-avatar {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; color: white;
  flex-shrink: 0;
}

.cl-mob-card-body {
  flex: 1; min-width: 0;
}

.cl-mob-name {
  font-size: 14.5px; font-weight: 700; color: #0f172a;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 3px;
}

.cl-mob-info {
  font-size: 12px; color: #64748b;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}
.cl-mob-info i { margin-right: 4px; width: 12px; text-align: center; }
.cl-mob-info--email { color: #3b82f6; }

.cl-mob-card-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.cl-mob-est-badge {
  font-size: 11px; font-weight: 700;
  background: #eff6ff; color: #2563eb;
  border: 1px solid #bfdbfe;
  padding: 2px 8px; border-radius: 20px;
  white-space: nowrap;
}

.cl-mob-actions {
  display: flex; gap: 6px;
}

.cl-mob-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  background: #f1f5f9; color: #475569;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s;
}
.cl-mob-btn:hover { background: #e2e8f0; }
.cl-mob-btn--del { background: #fef2f2; color: #ef4444; }
.cl-mob-btn--del:hover { background: #fee2e2; }

/* ── Menu rápido mobile de configurações ── */
.settings-mob-menu {
  display: none; /* oculto em desktop */
}

@media (max-width: 900px) {
  .settings-mob-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 16px;
  }
}

.settings-mob-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  text-decoration: none;
  color: #1e293b;
  border-bottom: 1px solid #f1f5f9;
  -webkit-tap-highlight-color: transparent;
  transition: background .1s;
}
.settings-mob-item:last-child { border-bottom: none; }
.settings-mob-item:active { background: #f8fafc; }

.settings-mob-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.settings-mob-label {
  flex: 1;
  font-size: 14px; font-weight: 600;
}

.settings-mob-arrow {
  font-size: 12px;
  color: #94a3b8;
}

/* ================================================================
   8. MODAIS — bottom sheet em mobile
   ================================================================ */
@media (max-width: 600px) {
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    border-radius: 24px 24px 0 0;
    max-height: 92vh;
    overflow-y: auto;
    width: 100%;
    max-width: 100%;
    animation: slideUp .25s ease;
    padding-bottom: calc(var(--safe-bottom) + 12px);
  }

  /* Handle drag visual */
  .modal::before {
    content: '';
    display: block;
    width: 40px; height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    margin: 10px auto -4px;
  }

  .modal-header {
    padding: 16px 18px 12px;
    position: sticky;
    top: 0;
    background: white;
    z-index: 2;
    border-bottom: 1px solid #f1f5f9;
    border-radius: 24px 24px 0 0;
  }

  .modal-body { padding: 16px 18px; }

  .modal-footer {
    padding: 12px 18px 16px;
    flex-direction: column;
    gap: 8px;
    position: sticky;
    bottom: 0;
    background: white;
    border-top: 1px solid #f1f5f9;
  }
  .modal-footer .btn { width: 100%; justify-content: center; }

  .modal-lg { max-height: 95vh; }
}

/* ================================================================
   9. SERVIÇOS — tabela → cards
   ================================================================ */
@media (max-width: 600px) {
  .srv-table-wrap { display: none !important; }

  .srv-cards {
    display: flex !important;
    flex-direction: column;
    gap: 10px;
  }

  .srv-card-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px;
  }

  .srv-card-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: #eff6ff; color: #2563eb;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0;
  }

  .srv-card-body { flex: 1; min-width: 0; }
  .srv-card-name {
    font-size: 13.5px; font-weight: 700; color: #1e293b;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .srv-card-meta  { font-size: 11.5px; color: #64748b; margin-top: 2px; }
  .srv-card-price { font-size: 14px; font-weight: 800; color: #0f172a; white-space: nowrap; }

  /* Toolbar de serviços */
  .srv-toolbar { flex-direction: column; gap: 8px; }
  .srv-toolbar .search-box { max-width: 100%; }
}

/* ================================================================
   10. CONFIGURAÇÕES
   ================================================================ */
@media (max-width: 600px) {
  #page-settings .page-content {
    padding: 14px 14px calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px) !important;
  }

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

  .settings-section,
  .settings-card {
    padding: 16px;
    border-radius: 14px;
    margin-bottom: 14px;
  }

  .settings-section-title,
  .settings-card .card-title { font-size: 14px; }

  .logo-upload-area { padding: 20px; }

  /* Segurança */
  .security-email-status { flex-wrap: wrap; gap: 10px; }
  .security-section-title { font-size: 13px; }
}

/* ================================================================
   11. PLANOS — cards responsivos
   ================================================================ */
@media (max-width: 600px) {
  .plans-grid { grid-template-columns: 1fr; gap: 14px; }
  .plan-card  { padding: 20px 16px; }
  .plan-card-price { font-size: 32px; }

  .plan-status-card {
    flex-direction: column;
    gap: 14px; padding: 16px;
    border-radius: 14px;
  }
  .plan-status-meters { width: 100%; }
  .plan-meter { min-width: 0; flex: 1; }

  /* Tabela comparativa → scroll horizontal */
  .feature-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ================================================================
   12. INDICAÇÃO (referral)
   ================================================================ */
@media (max-width: 600px) {
  .ref-share-btns {
    flex-direction: column;
    gap: 8px;
  }
  .ref-share-btns .btn { width: 100%; justify-content: center; }

  .ref-stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .ref-code-display {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
  .ref-code-display .btn { width: 100%; justify-content: center; }
}

/* ================================================================
   13. PAINEL ADMIN — KPIs, tabela, modais
   ================================================================ */
@media (max-width: 900px) {
  /* Header admin compacto */
  .adm2-header {
    flex-direction: column;
    gap: 12px;
    padding: 16px 14px;
    border-radius: 14px;
  }
  .adm2-header-right {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
  }
  .adm2-header-title { font-size: 18px; }

  /* Nav admin: scroll horizontal se necessário */
  .adm2-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
    padding-bottom: 2px;
  }
  .adm2-nav-btn { flex-shrink: 0; font-size: 13px; padding: 9px 14px; }

  /* ── Painel de filtros admf — 900px ── */
  .admf-panel { padding: 14px 14px 12px; gap: 10px; border-radius: 12px; }
  .admf-chips { gap: 5px; }
  .admf-chip  { font-size: 12px; padding: 5px 10px; }
  .admf-chip-count { min-width: 16px; height: 16px; font-size: 10px; }
  .admf-advanced { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .admf-select   { font-size: 12px; padding: 7px 10px; }
  .admf-search-input { font-size: 14px; } /* iOS zoom prevention */

  /* KPI grid 2 colunas */
  .adm2-kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }

  .adm2-kpi {
    padding: 14px 12px;
    border-radius: 14px;
  }
  .adm2-kpi-icon  { width: 38px; height: 38px; font-size: 16px; border-radius: 10px; }
  .adm2-kpi-val   { font-size: 22px; }
  .adm2-kpi-label { font-size: 10.5px; }
  .adm2-kpi-sub   { font-size: 10px; }
  .adm2-kpi-arrow { display: none; }

  /* MRR banner */
  .adm2-mrr-banner {
    flex-direction: column;
    gap: 14px; padding: 16px;
    border-radius: 14px;
  }
  .adm2-mrr-val { font-size: 26px; }
  .adm2-mrr-cycle { width: 100%; justify-content: space-around; }

  /* Stats row */
  .adm2-stats-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  /* Seção de pendentes — 900px */
  .adm2-pending-item { flex-wrap: wrap; }
  .adm2-pending-item-actions { flex-wrap: wrap; }
  .adm2-pending-btn { font-size: 12px; padding: 7px 11px; }

  /* Banner inconsistências — 900px */
  .adm2-inconsistency-item { font-size: 12px; }

  /* Selects avançados — grid 2+1+1 no tablet */
  .admf-advanced { grid-template-columns: 1fr 1fr 1fr; }

  /* Modal Ativar PRO — tablet */
  .adm-pro-cycle-btns { flex-wrap: wrap; }
  .adm-pro-cycle-btn  { min-width: 80px; }
}

@media (max-width: 600px) {
  /* Toolbar legado */
  .adm2-toolbar { flex-direction: column; gap: 8px; }
  .adm2-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .adm2-select       { font-size: 12.5px; padding: 8px 10px; }
  .adm2-search-input { font-size: 14px; }

  /* ── Painel de filtros admf — 600px ── */
  .admf-panel { padding: 12px 12px 10px; border-radius: 10px; gap: 9px; }
  .admf-search-row { flex-wrap: wrap; gap: 8px; }
  .admf-clear-all  { width: 100%; justify-content: center; font-size: 12px; padding: 8px 12px; }
  .admf-chips-row  { gap: 6px; }
  .admf-chips-label { display: none; } /* oculta no mobile muito pequeno */
  .admf-chips { gap: 5px; }
  .admf-chip  { font-size: 11.5px; padding: 4px 9px; gap: 4px; }
  .admf-chip-count { min-width: 15px; height: 15px; font-size: 9.5px; padding: 0 4px; }
  .admf-advanced { grid-template-columns: 1fr 1fr; gap: 5px; }
  .admf-select   { font-size: 12px; padding: 7px 9px; }
  .admf-result-bar { padding-top: 8px; }
  .admf-result-label { font-size: 11.5px; }
  .admf-result-count { font-size: 11px; }

  /* Tabela desktop → oculta; cards → visível */
  .adm2-panel--table { display: none !important; }
  .adm2-user-cards   { display: flex !important; }

  /* Cards de usuário admin */
  .adm2-user-card { padding: 13px; border-radius: 11px; }
  .adm2-user-card-top { gap: 10px; margin-bottom: 10px; }
  .adm2-user-card-av  { width: 36px; height: 36px; font-size: 12px; border-radius: 9px; }
  .adm2-user-card-name  { font-size: 13.5px; }
  .adm2-user-card-email { font-size: 11.5px; }
  .adm2-card-badges { gap: 5px; margin: 6px 0; }
  .adm2-card-paid-banner { font-size: 10.5px; padding: 3px 8px; border-radius: 6px; }

  /* Ações inline dos cards — 3 colunas iguais */
  .adm2-user-card-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 5px;
  }
  .adm-card-action {
    font-size: 11px !important;
    padding: 7px 5px !important;
    border-radius: 7px !important;
  }

  /* Modal de detalhe do admin → bottom sheet */
  .adm2-modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .adm2-modal {
    border-radius: 24px 24px 0 0;
    max-height: 94vh;
    overflow-y: auto;
    width: 100%;
    max-width: 100%;
    animation: slideUp .25s ease;
  }
  .adm2-modal::before {
    content: '';
    display: block;
    width: 40px; height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    margin: 10px auto -4px;
  }
  .adm2-modal-header-inner {
    padding: 18px 18px 14px;
    border-radius: 24px 24px 0 0;
  }

  /* Métricas 2x2 */
  .adm2-modal-metrics { grid-template-columns: 1fr 1fr; gap: 8px; }

  /* Info grid 1 coluna */
  .adm2-modal-info-grid { grid-template-columns: 1fr; }

  /* Ações */
  .adm2-modal-actions { grid-template-columns: 1fr 1fr; gap: 8px; }
  .adm2-action-big    { padding: 12px 8px; border-radius: 12px; font-size: 12px; }
  .adm2-action-big i  { font-size: 18px; }

  /* Row confirmação de email */
  .adm2-email-confirm-row {
    flex-direction: column;
    align-items: flex-start;
  }

  /* Ref / Sub rows */
  .adm2-ref-row,
  .adm2-sub-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    font-size: 12px;
  }

  /* Overview grid */
  .adm2-overview-grid { grid-template-columns: 1fr; gap: 12px; }
  .adm2-stats-row     { grid-template-columns: 1fr 1fr; }
  .adm2-stat-card     { padding: 12px 10px; border-radius: 12px; }
  .adm2-stat-card-icon { width: 32px; height: 32px; font-size: 14px; }

  /* Gráficos menores */
  .adm2-chart-wrap { min-height: 200px; }

  /* ── Modal Ativar PRO ── */
  .adm-pro-modal-plans { grid-template-columns: 1fr 1fr; gap: 6px; }
  .adm-pro-plan-card   { padding: 8px 10px; }
  .adm-pro-plan-icon   { font-size: 16px; }
  .adm-pro-plan-name   { font-size: 12px; }
  .adm-pro-plan-desc   { font-size: 10px; }
  .adm-pro-cycle-btns  { gap: 5px; }
  .adm-pro-cycle-btn   { font-size: 12px; padding: 8px 10px; }

  /* ── Seção de pendentes ── */
  .adm2-pending-item {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .adm2-pending-item-info { min-width: 0; }
  .adm2-pending-item-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .adm2-pending-btn--view {
    grid-column: span 2;
  }
  .adm2-pending-btn { font-size: 12px; padding: 9px 12px; justify-content: center; }

  /* ── Banner de inconsistências ── */
  .adm2-inconsistency-item {
    font-size: 12px;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .adm2-inconsistency-fix-btn { margin-left: 0; align-self: flex-end; }

  /* ── Select de status de pagamento ── */
  .admf-advanced { grid-template-columns: 1fr 1fr; }

  /* Stats de card menores no mobile */
  .adm2-user-card-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
  }
  .adm2-user-card-stat-val   { font-size: 14px; }
  .adm2-user-card-stat-label { font-size: 10px; }
}

/* ================================================================
   14. FORMULÁRIO DE AUTH (tela de login/cadastro e fluxos auth)
   ================================================================ */
@media (max-width: 600px) {
  /* Container geral */
  .auth-screen {
    padding: 12px 10px;
    min-height: 100dvh;
    align-items: flex-start;
  }
  .auth-container { width: 100%; max-width: 100%; gap: 12px; }
  .auth-brand { padding: 8px 0 0; }
  .auth-brand-logo { width: 160px; }
  .auth-brand-tagline { font-size: 12.5px; }

  /* Card principal */
  .auth-card {
    padding: 20px 16px 22px;
    border-radius: 20px;
    width: 100%;
  }

  .auth-title    { font-size: 19px; margin-bottom: 4px; }
  .auth-subtitle { font-size: 12.5px; margin-bottom: 14px; }

  /* form-row no cadastro → 1 coluna */
  #register-form .form-row { grid-template-columns: 1fr; }

  /* Previne zoom no iOS ao focar inputs */
  .form-input, .form-select, .form-textarea {
    font-size: 16px !important;
  }

  /* ── Botão voltar ── */
  .af-back-btn {
    font-size: 12.5px;
    margin-bottom: 16px;
    padding: 4px 0;
  }

  /* ── Ícone no topo dos formulários ── */
  .af-icon-wrap {
    width: 52px; height: 52px;
    font-size: 20px;
    margin-bottom: 12px;
  }

  /* ── Passos visuais (steps) ── */
  .af-steps {
    gap: 4px;
    margin-bottom: 16px;
    padding: 10px 10px;
  }
  .af-step-num { width: 24px; height: 24px; font-size: 11px; }
  .af-step span { font-size: 10px; }
  .af-step-line { min-width: 16px; }

  /* ── Banner de instrução do token ── */
  .af-token-hint {
    font-size: 12px;
    padding: 9px 11px;
    margin-bottom: 14px;
    border-radius: 10px;
  }

  /* ── Input de token grande (confirm/reset) ── */
  .af-token-input, .confirm-token-input {
    font-size: 22px !important;
    letter-spacing: 5px;
    text-align: center;
    padding: 12px 10px !important;
  }

  /* ── Email badge (confirm-email-form) ── */
  .af-email-display {
    font-size: 12px;
    padding: 8px 10px;
    gap: 6px;
  }

  /* ── Linha de reenvio ── */
  .af-resend-row {
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    text-align: center;
  }
  .af-resend-btn {
    font-size: 13px;
    padding: 7px 14px;
  }

  /* ── Mensagens de auth ── */
  .auth-msg { font-size: 13px; padding: 9px 12px; }

  /* ── Switch links ── */
  .auth-switch { font-size: 13px; margin-top: 14px; }

  /* ── Botão submit fullwidth no mobile ── */
  .btn-full { padding: 13px 16px; font-size: 14px; }

  /* ── Força de senha ── */
  .chpw-rules { gap: 4px 8px; }
  .chpw-rule  { font-size: 11px; }
}

/* Extra pequeno (≤ 380px) */
@media (max-width: 380px) {
  .auth-card { padding: 18px 14px 20px; }
  .auth-title { font-size: 17px; }
  .af-token-input, .confirm-token-input { font-size: 20px !important; letter-spacing: 4px; }
  .atm-token-val { font-size: 22px !important; letter-spacing: 4px; }
}

/* ================================================================
   15. PDF PREVIEW — bottom sheet mobile
   ================================================================ */
@media (max-width: 600px) {
  .pdf-preview-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .pdf-preview-modal {
    border-radius: 24px 24px 0 0;
    max-height: 96vh;
    height: 96vh;
    width: 100%;
    max-width: 100%;
  }
  .pdf-preview-toolbar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 14px;
  }
  .pdf-preview-toolbar .btn {
    flex: 1;
    justify-content: center;
    font-size: 12px;
    padding: 8px 8px;
  }
  .pdf-preview-toolbar .btn span { display: none; }
}

/* ================================================================
   16. TOAST — acima do bottom nav em mobile
   ================================================================ */
@media (max-width: 900px) {
  .toast {
    bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 12px) !important;
    right: 12px !important;
    left: 12px;
    max-width: calc(100% - 24px);
    font-size: 13.5px;
  }
}

/* ================================================================
   17. POPUP DE UPGRADE / PROMO
   ================================================================ */
@media (max-width: 600px) {
  .promo-popup {
    border-radius: 20px 20px 0 0;
    bottom: 0; top: auto;
    left: 0; right: 0;
    max-height: 90vh;
    overflow-y: auto;
    max-width: 100%;
    transform: none;
    position: fixed;
    animation: slideUp .3s ease;
  }
  .promo-popup-header { padding: 20px 18px 14px; }
  .promo-popup-body   { padding: 0 18px 20px; }
}

/* ================================================================
   18. INPUT GERAL — previne zoom iOS em inputs com font < 16px
   ================================================================ */
@media (max-width: 900px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="password"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* ================================================================
   19. TOUCH — melhora área de toque e remove highlight azul
   ================================================================ */
@media (max-width: 900px) {
  button,
  a,
  [onclick],
  .btn,
  .nav-item,
  .db-kpi,
  .db-row,
  .cl-card,
  .adm2-kpi,
  .mob-nav-item {
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
  }

  /* Scroll suave */
  * { -webkit-overflow-scrolling: touch; }

  /* Oculta scrollbars no mobile */
  ::-webkit-scrollbar { width: 0; height: 0; }
}

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

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

/* ================================================================
   21. PÁGINA DE CONTEÚDO — padding correto em mobile
   ================================================================ */
@media (max-width: 900px) {
  .page-content {
    padding: 16px 14px calc(var(--bottom-nav-h) + var(--safe-bottom) + 20px) !important;
  }

  /* Page headers compactos */
  .page-header {
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
  }
  .page-header .page-title    { font-size: 20px; }
  .page-header .page-subtitle { font-size: 13px; }
  .page-header .btn { align-self: flex-start; }
}

/* ================================================================
   22. CHIPS / BADGES — legíveis em mobile
   ================================================================ */
@media (max-width: 480px) {
  .plan-badge { font-size: 10px; padding: 2px 7px; }
  .adm-badge  { font-size: 10px; padding: 2px 7px; }
}
