@media (max-width: 767px) {
  /* Centrado global de contenedores y tarjetas */
  .container, .card, .section, .modal, .stackable-row, .table-container, .fe-section, .fe-fieldset {
    margin: 0 auto !important;
    max-width: 460px !important;
    border-radius: 12px !important;
    box-shadow: 0 2px 10px rgba(102,126,234,0.10) !important;
    background: linear-gradient(135deg, #181e2e 80%, #232b4a 100%) !important;
    padding: 12px 14px !important;
  }
  /* Formularios verticales y compactos */
  form, .form-row, .form-grid, .fe-form, .fe-grid, .fe-grid-2, .fe-grid-3 {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    align-items: center !important;
    width: 100%;
    padding: 0 !important;
    margin: 0 !important;
  }
  /* Inputs y selects 100% y centrados */
  input, select, textarea {
    width: 100% !important;
    max-width: 400px !important;
    margin: 0 auto 8px auto !important;
    font-size: 15px !important;
    border-radius: 8px !important;
    box-shadow: 0 1px 4px rgba(102,126,234,0.07) !important;
  }
  label {
    text-align: left !important;
    margin-bottom: 2px !important;
    font-size: 14px !important;
    width: 100%;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
  }
  /* Botones móviles centrados, compactos, sin estiramiento */
  .btn, button, .fe-form-actions .btn, .modal-actions .btn {
    width: 100% !important;
    max-width: 380px !important;
    margin: 6px auto !important;
    display: block !important;
    min-height: 44px !important;
    font-size: 15px !important;
    border-radius: 8px !important;
    box-shadow: 0 1px 4px rgba(102,126,234,0.07) !important;
  }
  /* Tablas stackable/card centradas y compactas */
  table.stackable, .fe-table.stackable, .fe-items-table.stackable {
    width: 100% !important;
    margin: 0 auto 12px auto !important;
    border-radius: 12px !important;
    box-shadow: 0 2px 10px rgba(102,126,234,0.10) !important;
    background: linear-gradient(135deg, #181e2e 80%, #232b4a 100%) !important;
  }
  table.stackable thead, .fe-table.stackable thead, .fe-items-table.stackable thead {
    display: none !important;
  }
  table.stackable tr, .fe-table.stackable tr, .fe-items-table.stackable tr {
    display: flex !important;
    flex-direction: column !important;
    margin-bottom: 10px !important;
    border-radius: 10px !important;
    box-shadow: 0 2px 10px rgba(102,126,234,0.10) !important;
    background: linear-gradient(135deg, #181e2e 80%, #232b4a 100%) !important;
    border: 1px solid #232b4a !important;
    align-items: center !important;
  }
  table.stackable td, .fe-table.stackable td, .fe-items-table.stackable td {
    justify-content: center !important;
    text-align: center !important;
    padding: 10px 0 !important;
    border-radius: 6px !important;
    background: rgba(255,255,255,0.01) !important;
    box-shadow: 0 1px 4px rgba(102,126,234,0.07) !important;
    font-size: 15px !important;
  }
  table.stackable td::before, .fe-table.stackable td::before, .fe-items-table.stackable td::before {
    text-align: left !important;
    font-size: 13px !important;
    opacity: 0.8 !important;
    width: 120px !important;
    min-width: 110px !important;
    margin-right: 8px !important;
    display: inline-block !important;
  }
  /* Eliminar scroll horizontal */
  html, body, .container, .main, .fe-main, .table-container, .fe-table-wrapper, .fe-items-table-wrapper {
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }
  /* Espaciado general compacto */
  .section, .fe-section, .fe-fieldset, .card, .modal {
    margin-bottom: 14px !important;
    padding: 12px 10px !important;
  }
}
/*
    Estilos base para Facturador Electrónico
    - Diseño minimalista y moderno
    - Layout responsivo (sidebar + topbar + contenido)
    - Animaciones suaves
    - Optimizado para Windows, macOS, Linux, Android, iOS
*/

:root {
  /* Gradientes Primarios - Acciones Principales */
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --primary-hover: linear-gradient(135deg, #5568d3 0%, #6a3f8f 100%);

  /* Gradientes Secundarios - Acciones Destructivas */
  --gradient-danger: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
  --danger-hover: linear-gradient(135deg, #ff5252 0%, #d94560 100%);

  /* Colores Base */
  --bg: #0f1320;
  --surface: #151a2b;
  --surface-2: #1b2136;
  --text: #e6e9f0;
  --muted: #a3acc3;
  --primary: #7c9cff;
  --primary-700: #5e7fe6;
  --accent: #23cdb3;
  --danger: #ff6b6b;
  --warning: #ffd166;
  --success: #58d68d;
  --info: #56ccf2;
  --border: #2a3352;

  /* Sombras y Radios */
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  /* Espaciado */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* Layout */
  --sidebar-width: 280px;
  --topbar-height: 64px;
}

/* ========================================
   CROSS-PLATFORM OPTIMIZATIONS
   ======================================== */

* {
  box-sizing: border-box;
  /* Suavizado de fuentes para todos los OS */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Desactivar tap highlight en móviles */
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  scroll-behavior: smooth;
  /* Ajuste de texto para legibilidad en móviles */
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  height: 100%;
  margin: 0;
  padding: 0;
  /* Permitir scroll vertical por defecto; evitar overflow horizontal global */
  overflow-y: auto;
  overflow-x: hidden;
  background: radial-gradient(
    1200px 800px at 10% -10%,
    #1c2240 0%,
    #0f1320 45%,
    #0b0e19 100%
  );
  color: var(--text);
  /* Tipografía base escalable (mobile-first) */
  font: clamp(0.875rem, 0.8rem + 0.4vw, 1rem)/1.5 Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  /* Optimización de renderizado */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Escalas de títulos accesibles */
h1, .h1 { font-size: clamp(1.4rem, 1.1rem + 1.2vw, 2.2rem); line-height:1.2; margin:0 0 0.75em; }
h2, .h2 { font-size: clamp(1.25rem, 1rem + 0.9vw, 1.8rem); line-height:1.25; margin:0 0 0.75em; }
h3, .h3 { font-size: clamp(1.1rem, 0.95rem + 0.6vw, 1.45rem); line-height:1.3; margin:0 0 0.75em; }
h4, .h4 { font-size: clamp(1rem, 0.9rem + 0.4vw, 1.25rem); line-height:1.35; margin:0 0 0.75em; }

/* Contenedor para formularios largos: permite scroll interno sin romper layout */
.form-long { max-height: calc(100vh - var(--topbar-height) - 48px); overflow-y:auto; overscroll-behavior:contain; padding-right:4px; }
.form-long::-webkit-scrollbar { width:6px; }
.form-long::-webkit-scrollbar-track { background: var(--surface); }
.form-long::-webkit-scrollbar-thumb { background: var(--border); border-radius:3px; }

/* Utilidades layout fluidas */
.flex { display:flex; }
.flex-col { flex-direction:column; }
.gap-xs { gap:4px; }
.gap-sm { gap:8px; }
.gap-md { gap:16px; }
.gap-lg { gap:24px; }
.w-full { width:100%; }
.max-w-screen { max-width:100vw; }

/* Botones táctiles: asegurar altura mínima */
button, .btn { min-height:44px; }

/* Evitar desbordes horizontales globales */
body, .content, .app { max-width:100%; overflow-x:hidden; }

/* Optimizaciones específicas para iOS */
@supports (-webkit-touch-callout: none) {
  body {
    /* Evitar zoom en inputs en iOS */
    touch-action: manipulation;
  }
  
  input,
  select,
  textarea {
    font-size: 16px; /* Prevenir zoom en iOS */
  }
}

/* Optimizaciones para Android */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
  select,
  textarea,
  input {
    font-size: 16px;
  }
}

/* Mobile: permitir scroll natural en body */
@media (max-width: 767px) {
  body {
    overflow: visible;
    overflow-x: hidden;
  }
}

/* Permitir scroll vertical en páginas que usan la convención 'body.<name>-page' */
/* Esto habilita scroll en módulos independientes como dashboard, admin, facturación, etc. */
body[class$="-page"] {
  overflow-y: auto;
  overflow-x: hidden;
}

/* Utilidades */
.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  color: var(--text);
  background: var(--surface-2);
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: 0.2s ease;
  /* Cross-platform optimizations */
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* Hover solo en dispositivos con cursor (desktop) */
@media (hover: hover) and (pointer: fine) {
  .btn:hover {
    background: #242c49;
  }
}

/* Active state para touch y mouse */
.btn:active {
  transform: scale(0.98);
}
.btn.primary,
.btn-primary {
  background: var(--gradient-primary);
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(102, 126, 234, 0.25);
  border: none;
  /* Touch-friendly: mínimo 44x44px */
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
  .btn.primary:hover,
  .btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.35);
  }
}

.btn.primary:active,
.btn-primary:active {
  transform: translateY(0);
}
.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
}
.btn.icon {
  padding: 10px;
  width: 40px;
  justify-content: center;
}
.btn.danger {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(255, 107, 107, 0.25);
  border: none;
}

@media (hover: hover) and (pointer: fine) {
  .btn.danger:hover {
    background: linear-gradient(135deg, #ff5252 0%, #d94560 100%);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(255, 107, 107, 0.35);
  }
}

.btn.danger:active {
  transform: translateY(0);
}
.chip {
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
}
.chip.success {
  background: rgba(88, 214, 141, 0.15);
  color: var(--success);
}
.chip.warning {
  background: rgba(255, 209, 102, 0.15);
  color: var(--warning);
}
.chip.danger {
  background: rgba(255, 107, 107, 0.15);
  color: var(--danger);
}
.chip.info {
  background: rgba(86, 204, 242, 0.15);
  color: var(--info);
}

input,
select,
textarea {
  width: 100%;
  background: #0d1120;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  outline: none;
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  /* iOS optimizations */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124, 156, 255, 0.1);
}

/* Prevenir zoom en iOS con font-size mínimo 16px */
@supports (-webkit-touch-callout: none) {
  input,
  select,
  textarea {
    font-size: 16px;
  }
}

input::placeholder,
textarea::placeholder {
  color: #7180a8;
}
label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
  display: block;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card .card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.card .card-body {
  padding: 16px;
}

/* Layout */
.app {
  display: flex;
  height: 100vh;
  width: 100vw;
  /* Permitir scroll dentro del layout cuando sea necesario */
  overflow: auto;
  position: relative;
}

/* Mobile: permitir scroll natural (< 768px) */
@media (max-width: 767px) {
  .app {
    height: auto;
    min-height: 100vh;
    overflow: visible;
    flex-direction: column;
  }
}

/* Desktop/Laptop: garantizar layout sidebar + main (≥ 768px) */
@media (min-width: 768px) {
  .app {
    flex-direction: row;
    height: 100vh;
    overflow: auto;
  }
}
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #12172a 0%, #0f1426 100%);
  border-right: 1px solid var(--border);
  z-index: 20;
  overflow-y: auto;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: grid;
  place-items: center;
  color: white;
  font-weight: 900;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}
.brand-name {
  color: var(--text);
}
.sidebar-close {
  display: none;
}
.menu {
  padding: 8px;
  display: grid;
  gap: 4px;
}
.menu-item {
  color: #cdd5f3;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
}
.menu-item:hover {
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.08) 0%,
    rgba(118, 75, 162, 0.08) 100%
  );
  border-color: rgba(102, 126, 234, 0.2);
}
.menu-item.active {
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.15) 0%,
    rgba(118, 75, 162, 0.15) 100%
  );
  border: 1px solid rgba(102, 126, 234, 0.4);
  color: #fff;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

/* Sidebar Footer - Botones de navegación */
.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.btn-dashboard {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  font-weight: 600;
  width: 100%;
  justify-content: center;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.btn-dashboard:hover {
  background: linear-gradient(135deg, #5568d3 0%, #6a3f8f 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-dashboard:active {
  transform: translateY(0);
}

.btn-logout {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
  color: white;
  border: none;
  width: 100%;
  justify-content: center;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
}

.btn-logout:hover {
  background: linear-gradient(135deg, #ff5252 0%, #d94560 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
}

.btn-logout:active {
  transform: translateY(0);
}

/* Botón perfil en dashboard - Compact */
.btn-profile {
  background: var(--gradient-primary);
  color: white;
  border: none;
  padding: 7px 12px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(102, 126, 234, 0.25);
  white-space: nowrap;
}

.btn-profile:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(102, 126, 234, 0.35);
}

.btn-profile:active {
  transform: translateY(0);
}

.profile-icon {
  font-size: 14px;
}

/* Botón logout en dashboard - Compact */
.btn-logout-dashboard {
  background: var(--gradient-danger);
  color: white;
  border: none;
  padding: 7px 12px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(255, 107, 107, 0.25);
  white-space: nowrap;
}

.btn-logout-dashboard:hover {
  background: var(--danger-hover);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(255, 107, 107, 0.35);
}

.btn-logout-dashboard:active {
  transform: translateY(0);
}

.logout-icon {
  font-size: 14px;
}

.logout-text {
  font-weight: 500;
}

.profile-text {
  font-weight: 500;
}

/* Dashboard Header - Centered Vertical Layout */
.dashboard-header {
  margin-bottom: 32px;
  margin-top: 16px;
  width: 100%;
  max-width: 1400px;
  animation: fadeInDown 0.6s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
}

/* Contenedor de acciones en header - Top Centered */
.header-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 12px;
  order: -1;
}

.header-brand {
  width: 100%;
  margin-top: 4px;
}

.header-brand h1 {
  margin: 0;
  font-size: clamp(18px, 4vw, 26px);
  font-weight: 700;
  color: var(--text);
  background: linear-gradient(135deg, #fff 0%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Session Info - Centered Below Title */
.session-info {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  padding: 5px 10px;
  background: rgba(102, 126, 234, 0.08);
  border: 1px solid rgba(102, 126, 234, 0.2);
  border-radius: var(--radius-xs);
  margin: 2px 0;
}

.dashboard-subtitle {
  margin: 0 0 8px 0;
  color: var(--muted);
  font-size: 13px;
  width: 100%;
}

.session-info .badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  background: rgba(88, 214, 141, 0.15);
  color: var(--success);
  border-radius: 4px;
  font-weight: 600;
  font-size: 10px;
}

.session-info .session-timestamp {
  color: var(--muted);
  font-size: 10px;
}

.session-info .session-line {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.session-expire {
  font-size: 11px;
  font-weight: 600;
}

.session-expire.warn {
  color: var(--warning);
}

.session-expire.danger {
  color: var(--danger);
}

/* Botones en topbar */
.btn-back-dashboard {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  font-size: 13px;
  padding: 8px 12px;
  white-space: nowrap;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(102, 126, 234, 0.25);
}

.btn-back-dashboard:hover {
  background: linear-gradient(135deg, #5568d3 0%, #6a3f8f 100%);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(102, 126, 234, 0.35);
}

.btn-back-dashboard:active {
  transform: translateY(0);
}

.btn-logout-top {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
  color: white;
  border: none;
  font-size: 13px;
  padding: 8px 12px;
  white-space: nowrap;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(255, 107, 107, 0.25);
}

.btn-logout-top:hover {
  background: linear-gradient(135deg, #ff5252 0%, #d94560 100%);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(255, 107, 107, 0.35);
}

.btn-logout-top:active {
  transform: translateY(0);
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  flex: 1;
}

/* Mobile: scroll natural del documento (< 768px) */
@media (max-width: 767px) {
  .main {
    height: auto;
    min-height: calc(100vh - var(--topbar-height));
    overflow: visible;
  }
}

/* Desktop/Laptop: mantener contenido encerrado (≥ 768px) */
@media (min-width: 768px) {
  .main {
    height: 100%;
    overflow: hidden;
  }
}
.topbar {
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: rgba(21, 26, 43, 0.6);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10;
  flex-shrink: 0;
}

/* Mobile: topbar sticky */
@media (max-width: 767px) {
  .topbar {
    position: sticky;
    top: 0;
    background: rgba(21, 26, 43, 0.95);
    z-index: 100;
  }
}
.topbar .left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar .right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-title {
  font-size: 16px;
  margin: 0;
  color: #eaf0ff;
}
.hamburger {
  font-size: 18px;
}
.search {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.search input {
  background: transparent;
  border: 0;
  padding: 8px;
  min-width: 240px;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #5062c7, #38b2ac);
  display: grid;
  place-items: center;
  font-weight: 700;
}

/* Session Indicator */
.session-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(88, 214, 141, 0.1);
  border: 1px solid rgba(88, 214, 141, 0.3);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.session-indicator.normal {
  background: rgba(88, 214, 141, 0.1);
  border-color: rgba(88, 214, 141, 0.3);
  color: var(--success);
}

.session-indicator.caution {
  background: rgba(255, 209, 102, 0.1);
  border-color: rgba(255, 209, 102, 0.3);
  color: var(--warning);
  animation: pulse-warning 2s ease-in-out infinite;
}

.session-indicator.warning {
  background: rgba(255, 107, 107, 0.1);
  border-color: rgba(255, 107, 107, 0.3);
  color: var(--danger);
  animation: pulse-danger 1s ease-in-out infinite;
}

.session-icon {
  font-size: 16px;
  line-height: 1;
}

.session-time {
  font-family: "Courier New", monospace;
  letter-spacing: 0.5px;
  min-width: 42px;
  text-align: center;
}

@keyframes pulse-warning {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.02);
  }
}

@keyframes pulse-danger {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.4);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.05);
    box-shadow: 0 0 0 4px rgba(255, 107, 107, 0);
  }
}

.content {
  padding: 16px;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

/* Mobile: scroll natural completo (< 768px) */
@media (max-width: 767px) {
  .content {
    overflow: visible;
    -webkit-overflow-scrolling: touch;
    padding: 12px;
    padding-bottom: 80px;
    min-height: auto;
  }
}

/* Desktop/Laptop: scroll encerrado con scrollbar (≥ 768px) */
@media (min-width: 768px) {
  .content {
    overflow: auto;
    overflow-x: hidden; /* Evitar scroll horizontal innecesario */
    padding: 16px;
    /* Custom scrollbar para Windows/macOS */
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--surface);
  }
  
  .content::-webkit-scrollbar {
    width: 8px;
  }
  
  .content::-webkit-scrollbar-track {
    background: var(--surface);
  }
  
  .content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
  }
  
  .content::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
  }
}
.grid {
  display: grid;
  gap: 16px;
}
.grid-cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid-cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid-cols-1 {
  grid-template-columns: 1fr;
}

.kpi {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #121832, #0f1426);
  box-shadow: var(--shadow);
}
.kpi .label {
  color: var(--muted);
  font-size: 12px;
}
.kpi .value {
  font-size: 24px;
  font-weight: 800;
}
.kpi .delta {
  font-size: 12px;
  color: var(--success);
}

/* Tablas y contenedores scrollables */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 720px;
}
th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
th {
  position: sticky;
  top: 0;
  background: #151a2b;
  z-index: 1;
}
tbody tr:hover {
  background: #141a33;
}

/* Tablas responsivas: scroll táctil y conversión a tarjetas en móvil */
.table-wrap { -webkit-overflow-scrolling:touch; overscroll-behavior:contain; }

/* Estado stackable activado por JS para pantallas pequeñas */
table.stackable { min-width:0; border-collapse:separate; }
@media (max-width: 575px) {
  table.stackable thead { display:none; }
  table.stackable tbody { display:grid; gap:12px; }
  table.stackable tr { display:grid; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:8px 12px; box-shadow:var(--shadow); gap:6px; }
  table.stackable td { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; padding:4px 0; border:0; }
  table.stackable td::before { content: attr(data-label); font-weight:600; color: var(--muted); flex:1; }
}

/* Mejoras para orientación landscape en móviles: permitir más ancho a la búsqueda */
@media (max-width: 900px) and (orientation: landscape) {
  .search input { min-width:140px; }
}

/* Breakpoints adicionales para ≥1920px: aprovechar espacio sin exagerar ancho de texto */
@media (min-width:1920px) {
  .content { padding:24px; }
  .grid-cols-3 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Formularios */
.form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(12, 1fr);
}
.col-12 {
  grid-column: span 12;
}
.col-6 {
  grid-column: span 6;
}
.col-4 {
  grid-column: span 4;
}
.col-3 {
  grid-column: span 3;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Mejoras responsivas para formularios y tarjetas en móvil */
@media (max-width: 575px) {
  .form-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .col-12, .col-6, .col-4, .col-3 {
    grid-column: span 1 !important;
  }
  .login-container, .login-card, .card, .modal {
    border-radius: 14px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.18);
    padding: 10px 6px;
    margin: 0 2px;
    width: 100%;
    max-width: 100vw;
  }
  .login-header h1, .card .card-header h1 {
    font-size: 1.3rem;
  }
  .btn, .btn-login, button {
    min-width: 100%;
    font-size: 1rem;
    padding: 14px 0;
    border-radius: 10px;
  }
  input, select, textarea {
    font-size: 1rem;
    padding: 14px 10px;
    border-radius: 10px;
  }
  label {
    font-size: 1rem;
  }
  .form-group {
    margin-bottom: 12px;
  }
}

/* Ítems de factura */
.items {
  display: grid;
  gap: 8px;
}
.item-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 8px;
  align-items: center;
}
.totals {
  display: grid;
  gap: 6px;
  max-width: 360px;
  margin-left: auto;
  padding: 12px;
}
.totals .row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}

/* Modales */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 16px;
  overflow-y: auto;
  /* Touch optimization */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.modal {
  width: 100%;
  max-width: 640px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: pop 0.2s ease;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-body {
  padding: 16px;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

/* Animaciones del modal según dispositivo */
@media (max-width: 767px) {
  .modal {
    animation: slideUpIn 0.3s ease-out;
  }

  .modal-backdrop {
    animation: fadeIn 0.2s ease-out;
  }
}

@media (min-width: 768px) {
  .modal {
    animation: pop 0.2s ease-out;
  }

  .modal-backdrop {
    animation: fadeIn 0.2s ease-out;
  }
}

@keyframes slideUpIn {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes pop {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Sidebar móvil */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 15;
  display: none;
}
.sidebar {
  transition: transform 0.2s ease, margin-left 0.2s ease;
}
.sidebar-hidden .sidebar {
  margin-left: calc(-1 * var(--sidebar-width));
}

/* ============================
   BREAKPOINTS PARA FACTURACIÓN
   ============================ */

/* Desktop Large (1200px+) */
@media (min-width: 1200px) {
  .grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .search input {
    min-width: 280px;
  }
}

/* Laptop (992px - 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
  .grid-cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search input {
    min-width: 200px;
  }

  .content {
    padding: 14px;
  }
}

/* Tablet Landscape (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: var(--sidebar-width);
    margin-left: 0;
    z-index: 30;
  }

  .sidebar-close {
    display: inline-flex;
  }

  .sidebar-hidden .sidebar {
    transform: translateX(-100%);
    margin-left: 0;
  }

  .app:not(.sidebar-hidden) .backdrop {
    opacity: 1;
    pointer-events: auto;
    display: block;
  }

  .grid-cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .col-6 {
    grid-column: span 6;
  }

  .col-4 {
    grid-column: span 6;
  }

  .col-3 {
    grid-column: span 6;
  }

  .search input {
    min-width: 160px;
  }

  .content {
    padding: 14px;
  }

  .kpi .value {
    font-size: 22px;
  }
}

/* Tablet Portrait & Mobile Large (576px - 767px) */
@media (min-width: 576px) and (max-width: 767px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: var(--sidebar-width);
    margin-left: 0;
    z-index: 30;
  }

  .sidebar-close {
    display: inline-flex;
  }

  .sidebar-hidden .sidebar {
    transform: translateX(-100%);
    margin-left: 0;
  }

  .app:not(.sidebar-hidden) .backdrop {
    opacity: 1;
    pointer-events: auto;
    display: block;
  }

  .grid-cols-3,
  .grid-cols-2 {
    grid-template-columns: 1fr;
  }

  .col-6,
  .col-4,
  .col-3 {
    grid-column: span 12;
  }

  .search input {
    min-width: 120px;
  }

  .topbar-title {
    font-size: 15px;
  }

  .btn-back-dashboard,
  .btn-logout-top {
    font-size: 12px;
    padding: 7px 10px;
  }

  .content {
    padding: 12px;
  }

  .item-row {
    grid-template-columns: 1fr 1fr 1fr 1fr auto;
  }

  table {
    min-width: 640px;
    font-size: 13px;
  }

  th,
  td {
    padding: 10px 12px;
  }

  .kpi .value {
    font-size: 20px;
  }

  .modal {
    max-width: 95vw;
  }
}

/* Mobile (< 576px) */
@media (max-width: 575px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 260px;
    margin-left: 0;
    z-index: 30;
  }

  .sidebar-close {
    display: inline-flex;
  }

  .sidebar-hidden .sidebar {
    transform: translateX(-100%);
    margin-left: 0;
  }

  .app:not(.sidebar-hidden) .backdrop {
    opacity: 1;
    pointer-events: auto;
    display: block;
  }

  .grid-cols-3,
  .grid-cols-2 {
    grid-template-columns: 1fr;
  }

  .topbar-title {
    display: none;
  }

  .topbar {
    padding: 0 8px;
  }

  .topbar .right {
    gap: 6px;
  }

  .btn-back-dashboard,
  .btn-logout-top {
    font-size: 12px;
    padding: 6px 8px;
  }

  .btn-back-dashboard {
    display: none; /* Ocultar en móvil para ahorrar espacio */
  }

  .hamburger {
    font-size: 20px;
  }

  .search {
    width: 100%;
    padding: 4px;
  }

  .search input {
    min-width: 0;
    width: 100%;
    padding: 6px;
    font-size: 14px;
  }

  .avatar {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }

  .session-indicator {
    padding: 4px 8px;
    font-size: 12px;
    gap: 4px;
  }

  .session-icon {
    font-size: 14px;
  }

  .session-time {
    min-width: 38px;
    font-size: 12px;
  }

  .content {
    padding: 10px;
  }

  .card .card-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px;
  }

  .card .card-body {
    padding: 12px;
  }

  .col-6,
  .col-4,
  .col-3 {
    grid-column: span 12;
  }

  .form-grid {
    gap: 10px;
  }

  .item-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .item-row input:nth-child(1) {
    grid-column: 1;
  }

  .item-row input:nth-child(2),
  .item-row input:nth-child(3),
  .item-row input:nth-child(4) {
    grid-column: 1;
  }

  .item-row button {
    grid-column: 1;
    width: 100%;
  }

  .totals {
    max-width: 100%;
    padding: 10px;
  }

  table {
    min-width: 600px;
    font-size: 12px;
  }

  th,
  td {
    padding: 8px 10px;
  }

  .kpi {
    padding: 12px;
  }

  .kpi .value {
    font-size: 18px;
  }

  .kpi .label {
    font-size: 11px;
  }

  .modal {
    max-width: 95vw;
  }

  .modal-header,
  .modal-body,
  .modal-actions {
    padding: 12px;
  }

  .sidebar-footer {
    padding: 10px 8px;
  }

  .btn-dashboard,
  .btn-logout {
    font-size: 12px;
    padding: 9px 10px;
  }

  .btn {
    padding: 8px 10px;
    font-size: 13px;
  }

  input,
  select,
  textarea {
    padding: 9px 10px;
    font-size: 14px;
  }
}

/* Mobile Small (< 400px) */
@media (max-width: 399px) {
  .sidebar {
    width: 240px;
  }

  .topbar {
    padding: 0 6px;
  }

  .content {
    padding: 8px;
  }

  .search {
    padding: 3px;
  }

  .search input {
    padding: 5px;
    font-size: 13px;
  }

  .card .card-header,
  .card .card-body {
    padding: 10px;
  }

  .form-grid {
    gap: 8px;
  }

  .kpi {
    padding: 10px;
  }

  .kpi .value {
    font-size: 16px;
  }

  table {
    font-size: 11px;
  }

  th,
  td {
    padding: 6px 8px;
  }

  .btn {
    padding: 7px 9px;
    font-size: 12px;
  }

  input,
  select,
  textarea {
    padding: 8px 9px;
    font-size: 13px;
  }
}

/* ============================
   ESTILOS PARA LOGIN
   ============================ */
.login-page {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(
    1200px 800px at 50% 20%,
    #1c2240 0%,
    #0f1320 45%,
    #0b0e19 100%
  );
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 24px;
}

.login-card {
  background: linear-gradient(180deg, #12172a 0%, #0f1426 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  padding: 40px 32px;
  animation: fadeInUp 0.5s ease;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 900;
  font-size: 28px;
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
}

.login-header h1 {
  margin: 0 0 8px 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.login-header p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 0;
}

.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrapper input {
  flex: 1;
  padding-right: 45px;
}

.form-group input {
  padding: 12px 14px;
  background: #0d1120;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-size: 14px;
  transition: all 0.2s ease;
  width: 100%;
}

.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124, 156, 255, 0.1);
}

.toggle-password {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  padding: 6px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.toggle-password:hover {
  background: rgba(124, 156, 255, 0.1);
  color: var(--primary);
}

.toggle-password:active {
  transform: translateY(-50%) scale(0.95);
}

.toggle-password .eye-icon {
  display: block;
  filter: grayscale(100%);
  transition: filter 0.2s ease;
}

.toggle-password:hover .eye-icon {
  filter: grayscale(0%);
}

.toggle-password.active .eye-icon::after {
  content: "";
  position: absolute;
  width: 2px;
  height: 24px;
  background: var(--danger);
  transform: rotate(45deg);
  left: 50%;
  top: 50%;
  margin-left: -1px;
  margin-top: -12px;
}

.error-message {
  padding: 12px 14px;
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.3);
  border-radius: var(--radius-xs);
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  animation: shake 0.3s ease;
}

.btn-login {
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-weight: 600;
  font-size: 15px;
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 8px;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
  min-height: 44px; /* tamaño táctil recomendado */
}

.btn-login:hover {
  background: linear-gradient(135deg, #5568d3 0%, #6a3f8f 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-login:active {
  transform: translateY(0);
}

/* ============================
   ESTILOS PARA DASHBOARD
   ============================ */
.dashboard-page {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  height: auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background: radial-gradient(
    1200px 800px at 50% 20%,
    #1c2240 0%,
    #0f1320 45%,
    #0b0e19 100%
  );
  background-attachment: fixed;
}

.dashboard-container {
  min-height: 100vh;
  height: auto;
  padding: 48px 24px 80px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

.dashboard-header {
  margin-bottom: 32px;
  margin-top: 16px;
  width: 100%;
  max-width: 1400px;
  animation: fadeInDown 0.6s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
}

.dashboard-header h1 {
  margin: 0;
  font-size: clamp(22px, 5vw, 32px);
  font-weight: 700;
  color: var(--text);
  background: linear-gradient(135deg, #fff 0%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
}

.dashboard-header p {
  margin: 0;
  color: var(--muted);
  font-size: clamp(13px, 2vw, 16px);
  text-align: center;
}

.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  max-width: 1400px;
  width: 100%;
  justify-content: center;
}

.module-card {
  position: relative;
  background: linear-gradient(180deg, #12172a 0%, #0f1426 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
  animation: fadeInUp 0.6s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.module-card.active:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 50px rgba(102, 126, 234, 0.4);
  border-color: transparent;
  background: linear-gradient(
    180deg,
    rgba(102, 126, 234, 0.1) 0%,
    rgba(118, 75, 162, 0.1) 100%
  );
  border: 1px solid rgba(102, 126, 234, 0.3);
}

.module-card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.module-card.disabled:hover {
  transform: none;
}

.module-icon {
  font-size: 48px;
  margin-bottom: 16px;
  filter: grayscale(0);
  transition: all 0.3s ease;
}

.module-card.active:hover .module-icon {
  transform: scale(1.1);
}

.module-card.disabled .module-icon {
  filter: grayscale(1);
}

.module-card h2 {
  margin: 0 0 8px 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.module-card p {
  margin: 0 0 16px 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.module-status {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.module-card.active .module-status {
  background: rgba(88, 214, 141, 0.15);
  color: var(--success);
}

.module-card.disabled .module-status {
  background: rgba(255, 209, 102, 0.15);
  color: var(--warning);
}

/* Animaciones */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

/* ============================
   SESSION MANAGER - Modal de Inactividad
   ============================ */

.session-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.3s ease;
}

.session-modal {
  background: linear-gradient(180deg, #1a2138 0%, #12172a 100%);
  border: 1px solid rgba(255, 209, 102, 0.3);
  border-radius: 16px;
  padding: 40px 32px;
  max-width: 480px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 209, 102, 0.1);
  animation: modalSlideIn 0.4s ease;
}

.session-modal-icon {
  font-size: 64px;
  margin-bottom: 20px;
  animation: pulse 2s ease-in-out infinite;
}

.session-modal h2 {
  margin: 0 0 16px 0;
  font-size: 26px;
  font-weight: 700;
  color: var(--warning);
  text-shadow: 0 2px 8px rgba(255, 209, 102, 0.3);
}

.session-modal p {
  margin: 0 0 12px 0;
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

.session-countdown {
  margin: 24px 0;
  padding: 20px;
  background: rgba(255, 209, 102, 0.1);
  border: 2px solid var(--warning);
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(255, 209, 102, 0.2);
}

.countdown-time {
  font-size: 48px;
  font-weight: 900;
  color: var(--warning);
  font-family: "Courier New", monospace;
  text-shadow: 0 2px 12px rgba(255, 209, 102, 0.5);
  display: block;
  letter-spacing: 4px;
}

.session-hint {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 24px;
}

.session-modal-buttons {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.session-modal-buttons .btn {
  flex: 1;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 600;
  justify-content: center;
}

.btn-logout-modal {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
  color: white;
  border: none;
  box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
  transition: all 0.3s ease;
}

.btn-logout-modal:hover {
  background: linear-gradient(135deg, #ff5252 0%, #d94560 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

/* Responsive para modal de sesión */
@media (max-width: 576px) {
  .session-modal {
    padding: 32px 24px;
    width: 95%;
  }

  .session-modal h2 {
    font-size: 22px;
  }

  .countdown-time {
    font-size: 40px;
  }

  .session-modal-buttons {
    flex-direction: column;
  }

  .session-modal-buttons .btn {
    width: 100%;
  }
}

/* ============================
   LOGOUT CONFIRMATION MODAL
   ============================ */

.logout-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.2s ease;
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.logout-modal-overlay.closing {
  animation: fadeOut 0.2s ease;
}

.logout-modal {
  background: linear-gradient(180deg, #1a2138 0%, #12172a 100%);
  border: 1px solid rgba(255, 107, 107, 0.3);
  border-radius: 12px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modalBounceIn 0.3s ease;
  position: relative;
}

.logout-modal-overlay.closing .logout-modal {
  animation: modalBounceOut 0.2s ease;
}

.logout-modal-header {
  padding: 24px 24px 16px 24px;
  border-bottom: 1px solid var(--border);
}

.logout-modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.logout-modal-header h3::before {
  content: "🚪";
  font-size: 24px;
}

.logout-modal-body {
  padding: 24px;
}

.logout-modal-body p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.logout-modal-footer {
  padding: 16px 24px 24px 24px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.logout-modal-footer .btn {
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 120px;
  justify-content: center;
  border: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  /* Touch-friendly: mínimo 44x44px */
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-secondary:hover,
.btn-secondary:focus {
  background: #242c49;
  border-color: rgba(124, 156, 255, 0.3);
  outline: none;
}

.btn-secondary:active {
  transform: scale(0.98);
}

.btn-logout-confirm {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
}

.btn-logout-confirm:hover,
.btn-logout-confirm:focus {
  background: linear-gradient(135deg, #ff5252 0%, #d94560 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
  outline: none;
}

.btn-logout-confirm:active {
  transform: translateY(0);
}

/* Animaciones del modal de logout */
@keyframes modalBounceIn {
  0% {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  50% {
    transform: scale(1.02) translateY(0);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes modalBounceOut {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.95);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* Responsive para modal de logout */
@media (max-width: 576px) {
  .logout-modal {
    max-width: 100%;
    border-radius: 12px 12px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    animation: slideUpIn 0.3s ease;
  }

  .logout-modal-overlay.closing .logout-modal {
    animation: slideDownOut 0.2s ease;
  }

  .logout-modal-header {
    padding: 20px 20px 14px 20px;
  }

  .logout-modal-header h3 {
    font-size: 18px;
  }

  .logout-modal-body {
    padding: 20px;
  }

  .logout-modal-body p {
    font-size: 15px;
  }

  .logout-modal-footer {
    padding: 14px 20px 20px 20px;
    flex-direction: column-reverse;
  }

  .logout-modal-footer .btn {
    width: 100%;
    min-width: unset;
  }
}

@keyframes slideUpIn {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes slideDownOut {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(100%);
  }
}

/* Soporte para dispositivos táctiles */
@media (hover: none) and (pointer: coarse) {
  .logout-modal-footer .btn {
    padding: 14px 24px;
    font-size: 16px;
    min-height: 48px;
  }

  .btn-secondary:hover {
    background: var(--surface-2);
    transform: none;
  }

  .btn-logout-confirm:hover {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    transform: none;
  }
}

/* ============================
   RESPONSIVE BREAKPOINTS
   ============================ */

/* Desktop Large (1920px+) */
@media (min-width: 1920px) {
  .login-container {
    max-width: 480px;
  }

  .login-card {
    padding: 48px 40px;
  }

  .modules-grid {
    grid-template-columns: repeat(4, minmax(280px, 320px));
    gap: 32px;
  }

  .header-brand h1 {
    font-size: 30px;
  }

  .dashboard-subtitle {
    font-size: 15px;
  }

  .header-actions {
    gap: 12px;
  }
}

/* Desktop (1200px - 1919px) */
@media (min-width: 1200px) and (max-width: 1919px) {
  .modules-grid {
    grid-template-columns: repeat(3, minmax(280px, 320px));
    max-width: 1100px;
  }
}

/* Laptop/Tablet Landscape (992px - 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
  .login-container {
    max-width: 400px;
  }

  .modules-grid {
    grid-template-columns: repeat(3, minmax(260px, 300px));
    gap: 20px;
    max-width: 980px;
  }

  .header-brand h1 {
    font-size: 26px;
  }

  .dashboard-subtitle {
    font-size: 14px;
  }

  .header-actions {
    gap: 10px;
  }
}

/* Tablet Portrait (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
  .login-container {
    max-width: 420px;
    padding: 20px;
  }

  .login-card {
    padding: 36px 28px;
  }

  .login-header h1 {
    font-size: 22px;
  }

  .login-logo {
    width: 56px;
    height: 56px;
    font-size: 24px;
  }

  .modules-grid {
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    gap: 20px;
    max-width: 700px;
  }

  .header-brand h1 {
    font-size: 24px;
  }

  .dashboard-subtitle {
    font-size: 13px;
  }

  .header-actions {
    gap: 10px;
    margin-bottom: 10px;
  }

  .btn-profile,
  .btn-logout-dashboard {
    padding: 7px 12px;
    font-size: 12px;
  }

  .session-info {
    font-size: 11px;
    padding: 5px 10px;
  }

  .dashboard-container {
    padding: 36px 20px 80px 20px;
    min-height: auto;
  }

  .module-card {
    padding: 28px 20px;
  }

  .module-icon {
    font-size: 42px;
  }
}

/* Mobile Large (576px - 767px) */
@media (min-width: 576px) and (max-width: 767px) {
  .login-container {
    max-width: 380px;
    padding: 16px;
  }

  .login-card {
    padding: 32px 24px;
  }

  .login-header h1 {
    font-size: 20px;
  }

  .login-logo {
    width: 52px;
    height: 52px;
    font-size: 22px;
  }

  .form-group input {
    padding: 12px;
    font-size: 14px;
  }

  .btn-login {
    padding: 13px 18px;
    font-size: 14px;
  }

  .modules-grid {
    grid-template-columns: 1fr;
    max-width: 380px;
    gap: 16px;
  }

  .header-brand h1 {
    font-size: 20px;
  }

  .dashboard-subtitle {
    font-size: 12px;
  }

  .header-actions {
    gap: 8px;
    margin-bottom: 10px;
  }

  .btn-profile,
  .btn-logout-dashboard {
    padding: 7px 11px;
    font-size: 11px;
  }

  .profile-icon,
  .logout-icon {
    font-size: 13px;
  }

  .profile-text,
  .logout-text {
    display: inline;
    font-size: 11px;
  }

  .session-info {
    font-size: 10px;
    padding: 4px 8px;
    max-width: 90%;
  }

  .session-info .session-line {
    flex-direction: column;
    gap: 2px;
  }

  .dashboard-container {
    padding: 28px 16px 60px 16px;
    min-height: auto;
  }

  .module-card {
    padding: 28px 20px;
  }

  .module-card h2 {
    font-size: 19px;
  }

  .module-icon {
    font-size: 44px;
  }
}

/* Mobile Medium (400px - 575px) */
@media (min-width: 400px) and (max-width: 575px) {
  .login-container {
    max-width: 100%;
    padding: 16px;
  }

  .login-card {
    padding: 28px 20px;
  }

  .login-header {
    margin-bottom: 28px;
  }

  .login-header h1 {
    font-size: 19px;
  }

  .login-header p {
    font-size: 13px;
  }

  .login-logo {
    width: 48px;
    height: 48px;
    font-size: 20px;
    margin-bottom: 12px;
  }

  .form-group input {
    padding: 11px 12px;
    font-size: 14px;
  }

  .btn-login {
    padding: 12px 16px;
    font-size: 14px;
  }

  .modules-grid {
    grid-template-columns: 1fr;
    max-width: 100%;
    gap: 14px;
  }

  .header-brand h1 {
    font-size: 18px;
  }

  .dashboard-subtitle {
    font-size: 12px;
  }

  .header-actions {
    gap: 8px;
    margin-bottom: 8px;
  }

  .btn-logout-dashboard,
  .btn-profile {
    padding: 7px 11px;
    font-size: 11px;
  }

  .profile-icon,
  .logout-icon {
    font-size: 13px;
  }

  .profile-text,
  .logout-text {
    display: inline;
    font-size: 11px;
  }

  .session-info {
    font-size: 10px;
    padding: 4px 8px;
    max-width: 95%;
  }

  .session-info .session-line {
    flex-direction: column;
    gap: 2px;
    text-align: center;
  }

  .dashboard-container {
    padding: 24px 16px 60px 16px;
    min-height: auto;
  }

  .module-card {
    padding: 24px 18px;
  }

  .module-card h2 {
    font-size: 18px;
  }

  .module-card p {
    font-size: 13px;
  }

  .module-icon {
    font-size: 40px;
    margin-bottom: 12px;
  }
}

/* Mobile Small (< 400px) */
@media (max-width: 399px) {
  .login-container {
    padding: 12px;
  }

  .login-card {
    padding: 24px 16px;
  }

  .login-header {
    margin-bottom: 24px;
  }

  .login-header h1 {
    font-size: 18px;
  }

  .login-header p {
    font-size: 12px;
  }

  .login-logo {
    width: 44px;
    height: 44px;
    font-size: 18px;
    margin-bottom: 10px;
  }

  .login-form {
    gap: 16px;
  }

  .form-group label {
    font-size: 12px;
  }

  .form-group input {
    padding: 10px 11px;
    font-size: 13px;
  }

  .btn-login {
    padding: 11px 14px;
    font-size: 13px;
  }

  .error-message {
    padding: 10px 12px;
    font-size: 12px;
  }

  .modules-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .dashboard-header {
    margin-bottom: 24px;
  }

  .header-brand h1 {
    font-size: 16px;
  }

  .dashboard-subtitle {
    font-size: 11px;
  }

  .header-actions {
    gap: 6px;
    margin-bottom: 8px;
  }

  .btn-logout-dashboard,
  .btn-profile {
    padding: 7px 10px;
    font-size: 10px;
  }

  .profile-icon,
  .logout-icon {
    font-size: 12px;
  }

  .profile-text,
  .logout-text {
    display: inline;
    font-size: 10px;
  }

  .session-info {
    justify-content: center;
    font-size: 9px;
    padding: 3px 7px;
    max-width: 100%;
  }

  .session-info .session-line {
    flex-direction: column;
    gap: 1px;
    text-align: center;
  }

  .session-info .badge {
    font-size: 9px;
    padding: 2px 6px;
  }

  .session-info .session-timestamp {
    font-size: 9px;
  }

  .profile-text,
  .logout-text {
    font-size: 10px;
  }

  .dashboard-container {
    padding: 20px 12px 60px 12px;
    min-height: auto;
  }

  .module-card {
    padding: 20px 16px;
  }

  .module-card h2 {
    font-size: 17px;
  }

  .module-card p {
    font-size: 12px;
    margin-bottom: 12px;
  }

  .module-icon {
    font-size: 36px;
    margin-bottom: 10px;
  }

  .module-status {
    padding: 5px 12px;
    font-size: 11px;
  }
}

/* Extra Small Screens - Solo iconos si es necesario */
@media (max-width: 320px) {
  .header-brand h1 {
    font-size: 14px;
  }

  .btn-profile,
  .btn-logout-dashboard {
    padding: 7px 8px;
  }

  .profile-text,
  .logout-text {
    display: none;
  }

  .profile-icon,
  .logout-icon {
    font-size: 14px;
  }
}

/* Landscape orientation adjustments */
@media (max-height: 600px) and (orientation: landscape) {
  .login-container {
    padding: 12px;
  }

  .login-card {
    padding: 20px 24px;
  }

  .login-header {
    margin-bottom: 20px;
  }

  .login-logo {
    width: 40px;
    height: 40px;
    font-size: 16px;
    margin-bottom: 8px;
  }

  .login-header h1 {
    font-size: 18px;
    margin-bottom: 4px;
  }

  .login-form {
    gap: 14px;
  }

  .dashboard-container {
    padding: 20px 16px;
  }

  .dashboard-header {
    margin-bottom: 20px;
    gap: 8px;
  }

  .header-brand h1 {
    font-size: 20px;
  }

  .header-actions {
    margin-bottom: 8px;
    gap: 8px;
  }

  .btn-logout-dashboard,
  .btn-profile {
    font-size: 11px;
    padding: 6px 10px;
  }

  .module-card {
    padding: 20px 16px;
  }

  .module-icon {
    font-size: 32px;
    margin-bottom: 8px;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .btn-login {
    padding: 14px 20px;
    font-size: 15px;
  }

  .form-group input {
    padding: 13px 14px;
    font-size: 16px; /* Previene zoom en iOS */
  }

  .module-card.active {
    transition: all 0.2s ease;
  }

  .module-card.active:active {
    transform: scale(0.98);
  }
}

/* ======================
   Profile Modal Styles
   ====================== */

.modal-perfil {
  max-width: 700px;
}

.modal-perfil .modal-body {
  padding: var(--space-5);
  max-height: 75vh;
  overflow-y: auto;
}

.modal-perfil .form-group {
  margin-bottom: var(--space-4);
}

.modal-perfil .form-group label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.modal-perfil .form-group input,
.modal-perfil .form-group select {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  transition: all 0.2s ease;
  /* Touch-friendly: mínimo 44x44px */
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.modal-perfil .form-group input:focus,
.modal-perfil .form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124, 156, 255, 0.1);
}

.modal-perfil .readonly-field {
  background: rgba(15, 19, 32, 0.6);
  cursor: not-allowed;
  opacity: 0.65;
  color: var(--muted);
  border-color: rgba(42, 51, 82, 0.5);
}

.modal-perfil .readonly-field:hover {
  border-color: rgba(42, 51, 82, 0.7);
}

.modal-perfil select.readonly-field {
  pointer-events: none;
  background-image: none;
}

.modal-perfil select:disabled {
  background: rgba(15, 19, 32, 0.6);
  cursor: not-allowed;
  opacity: 0.65;
  color: var(--muted);
  border-color: rgba(42, 51, 82, 0.5);
}

.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrapper input {
  padding-right: 48px;
}

.toggle-password {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  transition: background 0.2s ease;
  /* Touch-friendly: mínimo 44x44px */
  min-width: 44px;
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.toggle-password:hover {
  background: rgba(124, 156, 255, 0.1);
}

.toggle-password .eye-icon {
  font-size: 18px;
  user-select: none;
}

.field-hint {
  display: block;
  margin-top: var(--space-2);
  font-size: 12px;
  color: var(--muted);
}

.form-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.error-message,
.success-message {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-4);
  font-size: 14px;
  animation: slideDown 0.3s ease;
}

.error-message {
  background: rgba(255, 107, 107, 0.15);
  border: 1px solid var(--danger);
  color: var(--danger);
}

.success-message {
  background: rgba(88, 214, 141, 0.15);
  border: 1px solid var(--success);
  color: var(--success);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.profile-metadata {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 2px solid var(--border);
}

.profile-metadata h3 {
  font-size: 16px;
  color: var(--text);
  margin-bottom: var(--space-4);
  font-weight: 600;
}

.metadata-grid {
  display: grid;
  gap: var(--space-3);
}

.metadata-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.metadata-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.metadata-item span:last-child {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 28px;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: rgba(255, 107, 107, 0.15);
  color: var(--danger);
}

/* Responsive - Mobile-First según ESPECIFICACIONES_PROYECTO.md */

/* ========================================
   BASE MOBILE-FIRST: < 480px
   ======================================== */

/* Grid: columna única por defecto */
.grid-cols-3,
.grid-cols-2,
.grid-cols-1 {
  grid-template-columns: 1fr;
}

/* Formularios: columna única */
.form-grid {
  grid-template-columns: 1fr;
}

.form-grid .field,
.form-grid .col-12,
.form-grid .col-6,
.form-grid .col-4,
.form-grid .col-3 {
  grid-column: 1 / -1;
}

/* Botones táctiles */
.btn {
  min-height: 44px;
  min-width: 44px;
}

/* Cards responsive */
.card .card-header {
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.card .card-header .actions,
.card .card-header > div {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.card .card-header button,
.card .card-header input,
.card .card-header select {
  width: 100%;
  min-height: 44px;
}

/* Tables scroll horizontal */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  min-width: 600px;
  font-size: 13px;
}

/* Items factura */
.item-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.totals {
  width: 100%;
  max-width: 100%;
  margin-left: 0;
}

/* Inputs */
input,
select,
textarea {
  min-height: 44px;
  font-size: 14px;
}

/* Modales */
.modal {
  max-width: 95vw;
  margin: 8px;
}

/* ========================================
   BREAKPOINT: 480px - Smartphones medianos
   ======================================== */
@media (min-width: 480px) {
  .content {
    padding: 14px;
    padding-bottom: 80px;
  }
  
  .card .card-header {
    padding: 14px;
  }
  
  .card .card-body {
    padding: 14px;
  }
  
  table {
    font-size: 14px;
  }
  
  .modal {
    max-width: 90vw;
  }
}

/* ========================================
   BREAKPOINT: 768px - Tablets
   ======================================== */
@media (min-width: 768px) {
  .main {
    height: 100vh;
    overflow: hidden;
  }
  
  .content {
    overflow: auto;
    padding: 16px;
    padding-bottom: 16px;
  }
  
  /* 2 columnas en tablets */
  .grid-cols-3,
  .grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .form-grid {
    grid-template-columns: repeat(12, 1fr);
  }
  
  .col-12 { grid-column: span 12; }
  .col-6 { grid-column: span 6; }
  .col-4 { grid-column: span 4; }
  .col-3 { grid-column: span 3; }
  
  /* Card header horizontal */
  .card .card-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
  }
  
  .card .card-header > div {
    flex-direction: row;
    width: auto;
  }
  
  .card .card-header button,
  .card .card-header input {
    width: auto;
  }
  
  .card .card-body {
    padding: 16px;
  }
  
  /* Items en grid */
  .item-row {
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 8px;
  }
  
  .totals {
    max-width: 400px;
    margin-left: auto;
  }
  
  .modal {
    max-width: 640px;
  }
}

/* ========================================
   BREAKPOINT: 992px - Laptops
   ======================================== */
@media (min-width: 992px) {
  .grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .search input {
    min-width: 200px;
  }
  
  table {
    font-size: 14px;
  }
}

/* ========================================
   BREAKPOINT: 1200px - Desktop
   ======================================== */
@media (min-width: 1200px) {
  .search input {
    min-width: 280px;
  }
  
  .content {
    padding: 20px;
  }
  
  .card .card-header {
    padding: 16px 20px;
  }
  
  .card .card-body {
    padding: 20px;
  }
}

/* ========================================
   LANDSCAPE MODE: Smartphones horizontales
   ======================================== */
@media (max-height: 600px) and (orientation: landscape) {
  .topbar {
    min-height: 56px;
    height: 56px;
  }
  
  .sidebar {
    position: fixed;
    z-index: 30;
  }
  
  .sidebar-hidden .sidebar {
    transform: translateX(-100%);
  }
  
  .content {
    padding: 12px;
    padding-bottom: 40px;
  }
  
  .card .card-header {
    padding: 10px 12px;
  }
  
  .card .card-body {
    padding: 12px;
  }
  
  input,
  select,
  textarea,
  .btn {
    min-height: 40px;
  }
}

/* Smartphone Small */
@media (max-width: 400px) {
  .modal-perfil {
    max-width: 98%;
    margin: var(--space-2);
  }

  .modal-perfil .modal-body {
    padding: var(--space-3);
    max-height: 80vh;
  }

  .modal-perfil .form-group label {
    font-size: 13px;
  }

  .modal-perfil .form-group input,
  .modal-perfil .form-group select {
    font-size: 14px;
    padding: 10px 12px;
  }

  .profile-metadata h3 {
    font-size: 14px;
  }
}

/* Smartphone Portrait */
@media (min-width: 401px) and (max-width: 575px) {
  .modal-perfil {
    max-width: 96%;
  }

  .modal-perfil .modal-body {
    padding: var(--space-4);
    max-height: 75vh;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .metadata-item {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }
}

/* Tablet Portrait / Smartphone Landscape */
@media (min-width: 576px) and (max-width: 767px) {
  .modal-perfil {
    max-width: 90%;
  }

  .modal-perfil .modal-body {
    padding: var(--space-4);
    max-height: 72vh;
  }

  .form-actions {
    flex-direction: row;
  }

  .form-actions .btn {
    flex: 1;
  }
}

/* Tablet Landscape */
@media (min-width: 768px) and (max-width: 991px) {
  .modal-perfil {
    max-width: 600px;
  }

  .modal-perfil .modal-body {
    padding: var(--space-5);
    max-height: 70vh;
  }
}

/* Desktop Standard / Laptop */
@media (min-width: 992px) and (max-width: 1199px) {
  .modal-perfil {
    max-width: 650px;
  }
}

/* Desktop Large */
@media (min-width: 1200px) and (max-width: 1919px) {
  .modal-perfil {
    max-width: 700px;
  }
}

/* Desktop Extra Large */
@media (min-width: 1920px) {
  .modal-perfil {
    max-width: 750px;
  }

  .modal-perfil .modal-body {
    padding: var(--space-6);
  }
    gap: var(--space-2);
  }
}
