/* Optimización Android / touch (v2.3) */
html, body { max-width: 100%; min-height: 100%; overflow-x: hidden; }
body { -webkit-text-size-adjust: 100%; }
button, a, input, select, textarea { touch-action: manipulation; }
button, a { -webkit-tap-highlight-color: rgba(0, 64, 128, .12); }
input, select, textarea { border-radius: 7px; }

@media (max-width: 600px) {
  .app-shell { min-height: 100dvh; }
  .content { padding: 16px max(14px, env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); overflow-x: hidden; }
  .mobile-topbar { position: sticky; top: 0; z-index: 130; padding: max(8px, env(safe-area-inset-top)) 14px 8px; background: rgba(244, 246, 248, .96); border-bottom: 1px solid var(--gray-border); backdrop-filter: blur(8px); }
  .sidebar { width: min(88vw, 340px); height: 100dvh; max-height: 100dvh; padding-top: max(18px, env(safe-area-inset-top)); padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .sidebar-brand { padding-left: 18px; padding-right: 18px; }
  .sidebar-nav { overflow-y: auto; overscroll-behavior: contain; padding-left: 10px; padding-right: 10px; }
  .sidebar-account { margin-top: 14px; }
  .sidebar-logout { min-height: 44px; padding-left: 14px; padding-right: 14px; }
  .nav-item { min-height: 44px; padding-top: 10px; padding-bottom: 10px; margin-bottom: 2px; }
  .page-header { display: block; margin-bottom: 16px; }
  .page-header h1 { font-size: 21px; line-height: 1.2; }
  .page-header p { font-size: 13px; line-height: 1.45; }
  .card { padding: 15px; border-radius: 10px; margin-bottom: 14px; }
  .card h2 { font-size: 18px; }
  .form-grid { gap: 12px; }
  .field label { font-size: 12px; }
  .field input, .field select, .field textarea { min-height: 44px; font-size: 16px; }
  .form-actions { display: grid; grid-template-columns: 1fr; gap: 10px; }
  .btn { min-height: 44px; width: 100%; }
  .table-wrap { max-width: calc(100vw - 28px); overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
  table { min-width: 620px; }
  .toolbar, .filters, .cal-filtros { gap: 8px; }
  .toolbar input, .toolbar select, .filters input, .filters select { min-height: 44px; font-size: 16px; }
  #toast-container { left: 14px; right: 14px; bottom: 14px; }
  .toast { min-width: 0; width: 100%; box-sizing: border-box; }
}

@media (max-width: 380px) {
  .content { padding: 12px 10px calc(24px + env(safe-area-inset-bottom)); }
  .card { padding: 12px; }
  .sidebar { width: 90vw; }
  .sidebar-account-label { font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .sidebar-logout { transition: none; }
}


/* Cotizaciones: tarjetas legibles en móvil en lugar de una tabla de trece columnas. */
@media (max-width: 600px) {
  .cotizaciones-list-table { width: 100%; min-width: 0; table-layout: fixed; border-collapse: separate; border-spacing: 0; }
  .table-wrap:has(.cotizaciones-list-table) { max-width: 100%; overflow-x: visible; }
  .cotizaciones-list-table thead { display: none; }
  .cotizaciones-list-table tbody { display: block; width: 100%; }
  .cotizaciones-list-table tbody tr { display: block; margin: 0 0 12px; padding: 5px 12px; background: var(--white); border: 1px solid var(--gray-border); border-radius: 12px; box-shadow: var(--shadow); }
  .cotizaciones-list-table tbody td { display: grid; grid-template-columns: minmax(96px, 35%) minmax(0, 1fr); align-items: start; gap: 8px; min-width: 0; padding: 9px 2px; border-bottom: 1px solid var(--gray-border); font-size: 13px; line-height: 1.35; white-space: normal; overflow-wrap: anywhere; }
  .cotizaciones-list-table tbody td::before { content: attr(data-label); color: var(--text-muted); font-size: 11px; font-weight: 700; }
  .cotizaciones-list-table tbody td:first-child { font-size: 14px; font-weight: 700; }
  .cotizaciones-list-table tbody td.actions-cell { display: flex; justify-content: flex-end; border-bottom: 0; padding: 9px 0 3px; }
  .cotizaciones-list-table tbody td.actions-cell::before { content: none; }
  .cotizaciones-list-table tbody td.actions-cell .btn { width: auto; min-height: 40px; padding-inline: 16px; }
  .cotizaciones-list-table tbody td[colspan] { display: block; border: 0; }
  .cotizaciones-list-table tbody td[colspan]::before { content: none; }
  #cotizacion-resumen { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px !important; }
  #cotizacion-resumen > * { min-width: 0 !important; padding: 11px !important; }
  #cotizacion-resumen > * div:nth-child(2) { font-size: 17px !important; overflow-wrap: anywhere; }
}
