/* ═══════════════════════════════════════════════════════════════
   MAGNAMEDICA — Sistema de Inventario
   Paleta: Azul #2A7BBD | Teal #008280 | Naranja #E36013
   Fondo: #FFFFFF | Cards: #FAFAFA | Texto: #1F2937
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800&family=Open+Sans:wght@400;500;600&display=swap');

/* ─── Variables ──────────────────────────────────────────────── */
:root {
  --blue:       #2A7BBD;
  --blue-dark:  #1f5f94;
  --blue-light: #CEEFFF;
  --teal:       #008280;
  --teal-dark:  #006362;
  --orange:     #E36013;
  --orange-dark:#c04d0a;
  --white:      #FFFFFF;
  --bg:         #F4F6F8;
  --card:       #FAFAFA;
  --border:     #E5E7EB;
  --text:       #1F2937;
  --text-muted: #69727D;
  --success:    #25D366;
  --danger:     #D9534F;
  --warning:    #F59E0B;
  --sidebar-w:  260px;
  --header-h:   64px;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:  0 4px 12px rgba(0,0,0,.10);
  --transition: all .2s ease;
}

/* ─── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Open Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4,h5,h6 { font-family: 'Montserrat', sans-serif; font-weight: 600; line-height: 1.3; }
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); }
img { max-width: 100%; }
ul { list-style: none; }

/* ─── Layout Principal ───────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--blue);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: var(--transition);
  overflow-y: auto;
}
.sidebar-logo {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,.15);
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--header-h);
}
.sidebar-logo img {
  height: 36px;
  object-fit: contain;
}
.sidebar-logo-text {
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  color: white;
}
.sidebar-logo-text span {
  display: block;
  font-size: 10px;
  font-weight: 500;
  opacity: .75;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.sidebar-nav { flex: 1; padding: 16px 0; }
.sidebar-section {
  padding: 8px 24px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.5);
  margin-top: 8px;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255,255,255,.85);
  border-left: 3px solid transparent;
  transition: var(--transition);
}
.sidebar-item:hover {
  background: rgba(255,255,255,.1);
  color: white;
}
.sidebar-item.active {
  background: rgba(255,255,255,.15);
  border-left-color: white;
  color: white;
}
.sidebar-item i {
  width: 20px;
  text-align: center;
  font-size: 16px;
  opacity: .9;
}
.sidebar-badge {
  margin-left: auto;
  background: var(--orange);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.15);
  padding: 16px 24px;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: white;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: white;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-rol {
  font-size: 11px;
  color: rgba(255,255,255,.6);
  text-transform: capitalize;
}
.btn-logout {
  background: none; border: none;
  color: rgba(255,255,255,.7);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
}
.btn-logout:hover { color: white; background: rgba(255,255,255,.1); }

/* ─── Main Content ───────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Header ─────────────────────────────────────────────────── */
.app-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.header-left { display: flex; align-items: center; gap: 16px; }
.header-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.header-right { display: flex; align-items: center; gap: 12px; }

/* Botón hamburguesa (móvil) */
.btn-menu-toggle {
  display: none;
  background: none; border: none;
  color: var(--text); cursor: pointer;
  padding: 6px; border-radius: 6px;
}
.btn-menu-toggle:hover { background: var(--bg); }

/* ─── Page Content ───────────────────────────────────────────── */
.page-content {
  padding: 24px;
  flex: 1;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Cards / Panels ─────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--card);
}

/* ─── KPI Cards ──────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.kpi-icon.blue   { background: var(--blue-light); color: var(--blue); }
.kpi-icon.teal   { background: #d0f0ef; color: var(--teal); }
.kpi-icon.orange { background: #fde8d8; color: var(--orange); }
.kpi-icon.red    { background: #fde8e8; color: var(--danger); }
.kpi-icon.green  { background: #d4f7e5; color: #16a34a; }
.kpi-value {
  font-family: 'Montserrat', sans-serif;
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

/* ─── Grid Layout ────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-12 { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; }
.grid-21 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 6px;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary   { background: var(--blue);   color: white; }
.btn-primary:hover   { background: var(--blue-dark); }
.btn-teal      { background: var(--teal);   color: white; }
.btn-teal:hover      { background: var(--teal-dark); }
.btn-orange    { background: var(--orange); color: white; }
.btn-orange:hover    { background: var(--orange-dark); }
.btn-danger    { background: var(--danger); color: white; }
.btn-danger:hover    { background: #b33030; }
.btn-success   { background: var(--success); color: white; }
.btn-outline   { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover   { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }
.btn-ghost     { background: transparent; color: var(--text-muted); }
.btn-ghost:hover     { background: var(--bg); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; }

/* ─── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-blue    { background: var(--blue-light); color: var(--blue); }
.badge-teal    { background: #d0f0ef; color: var(--teal); }
.badge-orange  { background: #fde8d8; color: var(--orange); }
.badge-danger  { background: #fde8e8; color: var(--danger); }
.badge-success { background: #d4f7e5; color: #16a34a; }
.badge-gray    { background: #F3F4F6; color: var(--text-muted); }

/* Estados de pedidos */
.badge-borrador   { background: #F3F4F6; color: #6B7280; }
.badge-pendiente  { background: #FEF3C7; color: #92400E; }
.badge-confirmado { background: var(--blue-light); color: var(--blue); }
.badge-despachado { background: #d0f0ef; color: var(--teal); }
.badge-entregado  { background: #d4f7e5; color: #16a34a; }
.badge-cancelado  { background: #fde8e8; color: var(--danger); }
.badge-aprobada   { background: #d4f7e5; color: #16a34a; }
.badge-rechazada  { background: #fde8e8; color: var(--danger); }

/* ─── Tablas ─────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
thead th {
  background: #F9FAFB;
  padding: 11px 14px;
  text-align: left;
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #F9FAFB; }
tbody td {
  padding: 12px 14px;
  color: var(--text);
  vertical-align: middle;
}
.td-muted { color: var(--text-muted); font-size: 13px; }
.td-bold { font-weight: 600; }
.td-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ─── Formularios ─────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Montserrat', sans-serif;
  color: var(--text);
  margin-bottom: 6px;
}
.form-label.required::after {
  content: ' *';
  color: var(--danger);
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: 'Open Sans', sans-serif;
  color: var(--text);
  background: var(--white);
  transition: var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(42,123,189,.12);
}
.form-control::placeholder { color: #B0B7BE; }
.form-control:disabled { background: var(--bg); cursor: not-allowed; }
select.form-control { cursor: pointer; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* Toggle / Checkbox */
.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.toggle input[type="checkbox"] {
  position: relative;
  width: 40px; height: 22px;
  appearance: none;
  background: var(--border);
  border-radius: 11px;
  cursor: pointer;
  transition: background .2s;
}
.toggle input[type="checkbox"]:checked { background: var(--blue); }
.toggle input[type="checkbox"]::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  background: white;
  border-radius: 50%;
  top: 2px; left: 2px;
  transition: left .2s;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.toggle input[type="checkbox"]:checked::after { left: 20px; }
.toggle-label { font-size: 14px; font-weight: 500; }

/* ─── Search Bar ─────────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: var(--transition);
}
.search-bar:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(42,123,189,.12);
}
.search-bar i {
  padding: 0 12px;
  color: var(--text-muted);
  font-size: 15px;
}
.search-bar input {
  flex: 1;
  padding: 9px 12px 9px 0;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: 'Open Sans', sans-serif;
  background: transparent;
}

/* ─── Filtros ────────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-select {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--white);
  cursor: pointer;
  color: var(--text);
  outline: none;
}
.filter-select:focus { border-color: var(--blue); }

/* ─── Alertas / Notificaciones UI ───────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}
.alert i { margin-top: 1px; flex-shrink: 0; }
.alert-info    { background: var(--blue-light); color: var(--blue); border: 1px solid #93c6e7; }
.alert-success { background: #d4f7e5; color: #15803d; border: 1px solid #86efac; }
.alert-warning { background: #FEF3C7; color: #92400E; border: 1px solid #FCD34D; }
.alert-danger  { background: #fde8e8; color: #991b1b; border: 1px solid #FCA5A5; }

/* Banner de alerta con icono grande */
.alert-banner {
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.alert-banner .icon { font-size: 28px; }
.alert-banner-title { font-weight: 700; font-size: 15px; margin-bottom: 2px; }
.alert-banner-text  { font-size: 13px; opacity: .85; }

/* ─── Modales ────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalIn .2s ease;
}
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1000px; }
@keyframes modalIn {
  from { opacity: 0; transform: scale(.95) translateY(-10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 16px;
  font-weight: 700;
}
.modal-close {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 18px; padding: 4px;
  border-radius: 4px; transition: var(--transition);
}
.modal-close:hover { color: var(--danger); background: #fde8e8; }
.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ─── Toast / Snackbar ───────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--text);
  color: white;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn .25s ease;
  max-width: 360px;
}
.toast.success { background: var(--teal); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--orange); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ─── Loading / Skeleton ─────────────────────────────────────── */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
}
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 400% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
}
@keyframes shimmer { 0%{background-position:100%} 100%{background-position:-100%} }

/* ─── Productos delicados — panel especial ───────────────────── */
.delicado-panel {
  border: 2px solid var(--teal);
  border-radius: var(--radius);
  overflow: hidden;
}
.delicado-header {
  background: var(--teal);
  color: white;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 15px;
}
.delicado-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #d0f0ef;
  color: var(--teal);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}
.refrigeracion-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #dbeafe;
  color: #1d4ed8;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}

/* ─── Vencimiento — colores por urgencia ────────────────────── */
.vence-critico  { color: var(--danger); font-weight: 700; }
.vence-urgente  { color: var(--orange); font-weight: 700; }
.vence-proximo  { color: var(--warning); font-weight: 600; }
.vence-ok       { color: var(--success); }
.stock-bajo     { color: var(--danger); font-weight: 700; }
.stock-ok       { color: var(--success); }

/* ─── Paginación ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
  padding: 12px 0;
}
.page-btn {
  min-width: 34px; height: 34px;
  padding: 0 8px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--white);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.page-btn:hover { border-color: var(--blue); color: var(--blue); }
.page-btn.active { background: var(--blue); border-color: var(--blue); color: white; }
.page-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ─── Estadísticas / Barra de progreso ──────────────────────── */
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .4s ease;
}
.progress-fill.blue   { background: var(--blue); }
.progress-fill.teal   { background: var(--teal); }
.progress-fill.orange { background: var(--orange); }
.progress-fill.danger { background: var(--danger); }

/* ─── Login Page ─────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1f5f94 0%, var(--blue) 50%, var(--teal) 100%);
  padding: 24px;
}
.login-card {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0,0,0,.25);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}
.login-header {
  background: var(--blue);
  padding: 32px 40px 28px;
  text-align: center;
}
.login-logo {
  height: 52px;
  object-fit: contain;
  margin-bottom: 8px;
}
.login-tagline {
  color: rgba(255,255,255,.8);
  font-size: 13px;
  margin-top: 4px;
}
.login-body { padding: 32px 40px 40px; }
.login-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
}
.login-footer {
  text-align: center;
  padding: 16px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

/* ─── Empty State ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state i {
  font-size: 48px;
  opacity: .3;
  margin-bottom: 16px;
  display: block;
}
.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.empty-state p { font-size: 14px; }

/* ─── Tab Bar (reportes y otros) ─────────────────────────────── */
.tab-bar {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 10px 18px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: var(--transition);
  flex-shrink: 0;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ─── Action Bar (botones encima de listas) ───────────────────── */
.action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ─── Mobile Bottom Navigation ───────────────────────────────── */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: var(--white);
  border-top: 1px solid var(--border);
  z-index: 150;
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
}
.mobile-nav-items {
  display: flex;
  height: 100%;
}
.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 10px;
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  transition: var(--transition);
  position: relative;
  padding-bottom: env(safe-area-inset-bottom, 0);
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
}
.mobile-nav-item i {
  font-size: 18px;
  transition: var(--transition);
}
.mobile-nav-item.active {
  color: var(--blue);
}
.mobile-nav-item.active i {
  transform: translateY(-1px);
}
.mobile-nav-item .mobile-nav-badge {
  position: absolute;
  top: 8px;
  left: 50%;
  margin-left: 4px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
}
/* Botón "Más" abre el sidebar completo */
.mobile-nav-more {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 10px;
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  text-transform: uppercase;
  background: none;
  border: none;
  -webkit-tap-highlight-color: transparent;
}
.mobile-nav-more i { font-size: 18px; }

/* ─── PWA install banner ──────────────────────────────────────── */
#pwa-install-banner {
  display: none;
  position: fixed;
  bottom: 68px;
  left: 12px; right: 12px;
  background: var(--blue);
  color: white;
  border-radius: 10px;
  padding: 12px 16px;
  z-index: 999;
  box-shadow: var(--shadow-md);
  align-items: center;
  gap: 12px;
  animation: toastIn .3s ease;
}
#pwa-install-banner.show { display: flex; }
#pwa-install-banner i { font-size: 22px; flex-shrink: 0; }
#pwa-install-banner .banner-text { flex: 1; }
#pwa-install-banner .banner-title { font-weight: 700; font-size: 14px; }
#pwa-install-banner .banner-sub   { font-size: 12px; opacity: .85; }
#pwa-install-banner .banner-btns  { display: flex; gap: 8px; flex-shrink: 0; }
#pwa-install-banner button {
  border: none; cursor: pointer; border-radius: 6px;
  font-family: 'Montserrat', sans-serif; font-size: 12px; font-weight: 700;
  padding: 7px 14px;
}
#pwa-install-banner .btn-install { background: white; color: var(--blue); }
#pwa-install-banner .btn-dismiss { background: rgba(255,255,255,.15); color: white; }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; --mobile-nav-h: 60px; }

  /* ── Sidebar ── */
  .sidebar { transform: translateX(-260px); width: 260px; }
  .sidebar.open { transform: translateX(0); }

  /* ── Layout ── */
  .main-content { margin-left: 0; }
  .page-content { padding: 12px 12px 80px; } /* 80px = nav + breathing room */
  .btn-menu-toggle { display: flex; }

  /* ── Header ── */
  .app-header { padding: 0 14px; height: 54px; }
  --header-h: 54px;
  .header-title { font-size: 15px; max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* ── Page header ── */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 14px;
  }
  .page-title { font-size: 18px; }
  .page-header .action-bar { justify-content: flex-start; }
  .page-header .btn { flex: 1; justify-content: center; min-width: 0; }

  /* ── KPI ── */
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
  .kpi-card { padding: 14px 12px; gap: 10px; }
  .kpi-icon { width: 42px; height: 42px; font-size: 17px; border-radius: 10px; }
  .kpi-value { font-size: 20px; }
  .kpi-label { font-size: 11px; }

  /* ── Grids CSS classes ── */
  .grid-2, .grid-3, .grid-12, .grid-21 { grid-template-columns: 1fr; }

  /* ── Grids inline en JS (attribute selector) ── */
  [style*="grid-template-columns:repeat(3"],
  [style*="grid-template-columns:repeat(4"],
  [style*="grid-template-columns:repeat(2"],
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Formularios ── */
  .form-row, .form-row-3 { grid-template-columns: 1fr; gap: 12px; }

  /* ── Cards ── */
  .card-header { flex-wrap: wrap; gap: 8px; padding: 12px 14px; }
  .card-body { padding: 14px; }
  .card-title { font-size: 14px; }

  /* ── Modales: bottom sheet ── */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100%;
    width: 100%;
    margin: 0;
    border-radius: 18px 18px 0 0;
    max-height: 90vh;
    animation: modalInMobile .25s ease;
  }
  .modal-lg, .modal-xl { max-width: 100%; }
  @keyframes modalInMobile {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  .modal-header { padding: 16px 18px 12px; }
  .modal-body { padding: 16px 18px; }
  .modal-footer {
    padding: 12px 18px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .modal-footer .btn { flex: 1; justify-content: center; min-width: 120px; }

  /* Drag indicator en modales */
  .modal-header::before {
    content: '';
    display: block;
    width: 36px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 12px;
  }

  /* ── Tablas ── */
  .table-wrapper { -webkit-overflow-scrolling: touch; border-radius: 0; }
  .card .table-wrapper { margin: 0 -1px; } /* stretch to card edges */
  table { min-width: 560px; font-size: 13px; }
  thead th { padding: 9px 10px; font-size: 11px; }
  tbody td { padding: 10px 10px; }
  .td-actions { flex-wrap: wrap; gap: 4px; }
  .td-actions .btn-sm { padding: 5px 8px; font-size: 11px; }

  /* ── Filters bar ── */
  .filters-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .filters-bar::-webkit-scrollbar { display: none; }
  .filters-bar .search-bar { min-width: 180px; flex-shrink: 0; }
  .filter-select { flex-shrink: 0; }

  /* ── Paginación ── */
  .pagination { justify-content: center; flex-wrap: wrap; padding: 8px 0; gap: 3px; }
  .page-btn { min-width: 32px; height: 32px; font-size: 12px; }

  /* ── Toast ── */
  #toast-container { bottom: 70px; right: 10px; left: 10px; }
  .toast { max-width: 100%; font-size: 13px; padding: 10px 14px; border-radius: 10px; }

  /* ── Mobile nav ── */
  .mobile-nav { display: flex; }

  /* ── Tabs (reportes etc.) ── */
  .tab-bar { gap: 0; margin-bottom: 14px; }
  .tab-btn { padding: 10px 14px; font-size: 12px; }
  .tab-btn i { display: none; } /* ocultar íconos en tabs móvil */

  /* ── Alert banners ── */
  .alert-banner { padding: 12px 14px; gap: 10px; }
  .alert-banner .icon { font-size: 22px; }
  .alert-banner-title { font-size: 14px; }

  /* ── Bodegas grid ── */
  #bodegas-grid { grid-template-columns: 1fr !important; }

  /* ── Buttons en page-header ── */
  .page-header > div:last-child { display: flex; flex-wrap: wrap; gap: 8px; }
  .page-header > div:last-child .btn { flex: 1; min-width: 130px; justify-content: center; }
}

@media (max-width: 480px) {
  /* KPIs 2 col siguen siendo OK en 480, colapsan solo en muy pequeños */
  .kpi-grid { gap: 8px; }
  .kpi-card { padding: 12px 10px; }
  .kpi-value { font-size: 18px; }

  .grid-3 { grid-template-columns: 1fr; }
  .login-header { padding: 24px 20px 20px; }
  .login-body { padding: 24px 20px 28px; }

  /* Ocultar columnas secundarias en tablas muy pequeñas */
  .table-wrapper table { min-width: 480px; }

  /* Modal más alto en pantallas pequeñas */
  .modal { max-height: 94vh; }

  /* Header compacto */
  .header-right .btn-icon:not(:last-child) { display: none; } /* oculta botones extra del header */
}

/* ─── Safe area para iPhone (notch / home bar) ───────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .mobile-nav {
    height: calc(60px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
  }
  @media (max-width: 768px) {
    :root { --mobile-nav-h: calc(60px + env(safe-area-inset-bottom)); }
    .page-content { padding-bottom: calc(var(--mobile-nav-h) + 20px); }
  }
}

/* ─── Utilities ──────────────────────────────────────────────── */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8   { margin-top: 8px; }
.mt-16  { margin-top: 16px; }
.mt-24  { margin-top: 24px; }
.mb-16  { margin-bottom: 16px; }
.mb-24  { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-small  { font-size: 13px; }
.text-bold   { font-weight: 700; }
.text-blue   { color: var(--blue); }
.text-teal   { color: var(--teal); }
.text-orange { color: var(--orange); }
.text-danger { color: var(--danger); }
.text-success{ color: var(--success); }
.w-full { width: 100%; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hidden { display: none !important; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
