/* =========================================
   SaaS Login - Variables y Estilos Base
   ========================================= */
:root {
  --bg-color: #f8fafc; /* Color de fondo general (slate-50) */
  --card-bg: #ffffff;
  
  --text-primary: #0f172a; /* Texto principal (slate-900) */
  --text-secondary: #475569; /* Texto secundario (slate-600) */
  --text-muted: #94a3b8; /* Iconos y placeholders (slate-400) */
  
  --border-color: #e2e8f0; /* Bordes sutiles (slate-200) */
  --border-light: #f1f5f9; /* Bordes extra claros (slate-100) */
  
  --primary-color: #4f46e5; /* Acento Índigo */
  --primary-hover: #4338ca; /* Índigo más oscuro al pasar el ratón */
  --primary-light: #e0e7ff; /* Fondo para iconos */
  --focus-ring: rgba(79, 70, 229, 0.2); /* Sombra suave para el focus */
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  overflow-x: hidden;
}

body:not(.dashboard-layout) {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  padding: 3rem 1rem;
}

/* =========================================
   Contenedores
   ========================================= */
.login-wrapper {
  margin: 0 auto;
  width: 100%;
  max-width: 28rem; /* 448px */
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  background-color: var(--primary-light);
  color: var(--primary-color);
  margin-bottom: 1rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.login-logo svg {
  width: 2rem;
  height: 2rem;
}

.login-title {
  font-size: 1.875rem;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.login-subtitle {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.login-subtitle a {
  color: var(--primary-color);
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s ease;
}

.login-subtitle a:hover {
  color: var(--primary-hover);
}

.login-card {
  background-color: var(--card-bg);
  padding: 2.5rem;
  border-radius: 1rem; /* rounded-2xl */
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  border: 1px solid var(--border-light);
}

/* =========================================
   Formulario e Inputs
   ========================================= */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.input-wrapper {
  position: relative;
}

.input-icon {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  padding-left: 0.85rem;
  display: flex;
  align-items: center;
  pointer-events: none;
  color: var(--text-muted);
}

.input-icon svg {
  width: 1.25rem;
  height: 1.25rem;
}

.form-input {
  display: block;
  width: 100%;
  padding: 0.625rem 1rem;
  padding-left: 2.5rem; /* Espacio para el icono */
  font-size: 0.875rem;
  color: var(--text-primary);
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem; /* rounded-xl */
  transition: all 0.2s ease;
  font-family: inherit;
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--focus-ring); /* Efecto Focus moderno */
}

/* Select dentro del modal no debe tener padding-left de icono */
.modal-body select.form-input {
  padding-left: 1rem;
  display: inline-block;
  width: 100%;
}

/* Input de contraseña con botón de alternar */
.input-wrapper.has-toggle .form-input {
  padding-right: 2.5rem; /* Espacio para el ojo */
}

.toggle-password {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  padding-right: 0.75rem;
  display: flex;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.toggle-password:hover {
  color: var(--text-secondary);
}

.toggle-password:focus {
  outline: none;
  color: var(--primary-color);
}

.toggle-password svg {
  width: 1.25rem;
  height: 1.25rem;
}

.toggle-password .hidden {
  display: none;
}

/* =========================================
   Opciones Extras (Checkboxes y Enlaces)
   ========================================= */
.form-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.checkbox-group {
  display: flex;
  align-items: center;
}

.checkbox-input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--primary-color); /* Color nativo del checkbox */
  cursor: pointer;
}

.checkbox-label {
  margin-left: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.forgot-password {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--primary-color);
  text-decoration: none;
  transition: color 0.2s ease;
}

.forgot-password:hover {
  color: var(--primary-hover);
}

/* =========================================
   Botones
   ========================================= */
.btn {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0.75rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-primary {
  background-color: var(--primary-color);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-primary:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* =========================================
   Login Social (Botones secundarios)
   ========================================= */
.social-divider {
  margin-top: 1.5rem;
  position: relative;
  text-align: center;
}

.social-divider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  border-top: 1px solid var(--border-color);
  z-index: 1;
}

.social-divider span {
  position: relative;
  display: inline-block;
  background-color: var(--card-bg);
  padding: 0 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  z-index: 2;
}

.social-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.btn-social {
  background-color: #fff;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.btn-social:hover {
  background-color: var(--bg-color);
  color: var(--text-primary);
}

.btn-social svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* Responsive para la tarjeta */
@media (max-width: 480px) {
  .login-card {
    padding: 2rem 1.5rem;
    border-radius: 0.75rem;
  }
}
/* =========================================
   Dashboard - Layout Principal
   ========================================= */
.dashboard-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-color);
  width: 100%;
}

/* =========================================
   Sidebar (Menú Lateral)
   ========================================= */
.sidebar {
  width: 260px;
  min-width: 260px;
  background-color: var(--card-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  flex-shrink: 0;
  transition: width 0.3s ease, min-width 0.3s ease, transform 0.3s ease;
  z-index: 40;
}

.sidebar-header {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-light);
  overflow: hidden;
}

.sidebar-brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.sidebar-brand {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 800;
  font-size: 1.25rem;
  line-height: 1.25;
  color: var(--text-primary);
  white-space: normal;
  overflow-wrap: anywhere;
}

.sidebar-brand-logo {
  width: 2rem;
  height: 2rem;
  min-width: 2rem;
  border-radius: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-color: var(--primary-light);
  color: var(--primary-color);
}

.sidebar-brand-logo svg,
.sidebar-brand-image {
  width: 100%;
  height: 100%;
  display: block;
}

.sidebar-brand-image {
  object-fit: cover;
}

.sidebar-collapse-btn,
.desktop-sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  background-color: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.3s ease;
}

.sidebar-collapse-btn:hover,
.desktop-sidebar-toggle:hover {
  background-color: var(--bg-color);
  color: var(--primary-color);
}

.sidebar-nav {
  padding: 1.5rem 1rem;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.75rem;
  margin-top: 1.5rem;
  padding-left: 0.5rem;
}

.nav-section-title:first-child { margin-top: 0; }

.nav-item {
  list-style: none;
  margin-bottom: 0.125rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 1rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
  transition: all 0.2s ease;
  min-width: 0;
  overflow: hidden;
}

.nav-icon {
  width: 2rem;
  height: 2rem;
  min-width: 2rem;
  border-radius: 0.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-color);
  color: var(--primary-color);
  font-size: 0.8rem;
  font-weight: 700;
}

.nav-icon svg {
  width: 1.1rem;
  height: 1.1rem;
  display: block;
}

.nav-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 auto;
}

.nav-link:hover {
  background-color: var(--bg-color);
  color: var(--primary-color);
}

.nav-link.active {
  background-color: var(--primary-light);
  color: var(--primary-color);
}

.nav-link svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* =========================================
   Contenido Principal y Cabecera (Header)
   ========================================= */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 0; /* Previene desbordamiento en flexbox */
  width: 100%;
}

.top-header {
  height: 4rem; /* 64px */
  background-color: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-mobile-brand {
  display: none;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  flex: 1 1 auto;
}

.topbar-mobile-brand-logo {
  width: 2rem;
  height: 2rem;
  min-width: 2rem;
  border-radius: 0.65rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-color: var(--primary-light);
  color: var(--primary-color);
}

.topbar-mobile-brand-logo svg,
.topbar-mobile-brand-image {
  width: 100%;
  height: 100%;
  display: block;
}

.topbar-mobile-brand-image {
  object-fit: cover;
}

.topbar-mobile-brand-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.5rem;
}
.mobile-toggle:hover { background-color: var(--bg-color); }

.search-bar {
  display: flex;
  align-items: center;
  background-color: var(--bg-color);
  border-radius: 2rem;
  padding: 0.5rem 1rem;
  width: 300px;
  border: 1px solid transparent;
  transition: border-color 0.2s;
}
.search-bar:focus-within { border-color: var(--primary-light); }

.search-bar input {
  background: transparent;
  border: none;
  outline: none;
  width: 100%;
  margin-left: 0.5rem;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.company-context-form {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.company-context-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.company-context-select {
  min-width: 210px;
  max-width: 260px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 0.65rem;
  background-color: var(--card-bg);
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-family: inherit;
}

.company-context-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.action-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  padding: 0.5rem;
  border-radius: 50%;
  transition: background-color 0.2s;
}
.action-btn:hover {
  background-color: var(--bg-color);
  color: var(--primary-color);
}
.badge {
  position: absolute;
  top: 0;
  right: 0;
  background-color: #ef4444; /* red-500 */
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-left: 1rem;
  border-left: 1px solid var(--border-color);
  position: relative;
}

.user-menu-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  font: inherit;
}

.user-profile-meta {
  text-align: right;
  display: none;
}

.user-profile-name {
  font-size: 0.875rem;
  font-weight: 600;
}

.user-profile-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.user-profile-company {
  font-size: 0.7rem;
  color: var(--primary-color);
  margin-top: 0.15rem;
}

.user-menu-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: transform 0.2s ease, color 0.2s ease;
}

.user-menu.is-open .user-menu-caret {
  transform: rotate(180deg);
  color: var(--primary-color);
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 0.75rem);
  right: 0;
  min-width: 190px;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.9rem;
  box-shadow: 0 18px 32px rgba(15, 23, 42, 0.12);
  padding: 0.4rem;
  display: none;
  z-index: 90;
}

.user-menu.is-open .user-menu-dropdown {
  display: block;
}

.user-menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.75rem 0.85rem;
  border-radius: 0.7rem;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.user-menu-item:hover,
.user-menu-item:focus-visible {
  background-color: var(--bg-color);
  color: var(--primary-color);
  outline: none;
}

.user-menu-item-danger:hover,
.user-menu-item-danger:focus-visible {
  color: #dc2626;
}
.avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background-color: var(--primary-light);
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
}

@media (min-width: 640px) {
  .user-profile-meta {
    display: block;
  }
}

/* =========================================
   Contenido del Dashboard (Métricas y Tablas)
   ========================================= */
.content-area {
  padding: 2rem;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

body.sidebar-collapsed .sidebar {
  width: 88px;
  min-width: 88px;
}

body.sidebar-collapsed .sidebar-brand,
body.sidebar-collapsed .nav-section-title,
body.sidebar-collapsed .nav-text {
  display: none;
}

body.sidebar-collapsed .sidebar-header {
  padding-inline: 1rem;
}

body.sidebar-collapsed .sidebar-brand-wrap {
  justify-content: center;
  width: 100%;
}

body.sidebar-collapsed .sidebar-nav {
  padding-inline: 0.75rem;
}

body.sidebar-collapsed .nav-link {
  justify-content: center;
  padding-inline: 0.5rem;
  position: relative;
}

body.sidebar-collapsed .desktop-sidebar-toggle {
  transform: rotate(180deg);
}

body.sidebar-collapsed .nav-link::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 0.75rem);
  top: 50%;
  transform: translateY(-50%);
  background-color: var(--text-primary);
  color: var(--card-bg);
  padding: 0.45rem 0.65rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  z-index: 60;
}

body.sidebar-collapsed .nav-link:hover::after,
body.sidebar-collapsed .nav-link:focus-visible::after {
  opacity: 1;
  visibility: visible;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.metric-card {
  background-color: var(--card-bg);
  padding: 1.5rem;
  border-radius: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  transition: transform 0.2s ease;
}
.metric-card:hover { transform: translateY(-2px); }

.metric-info h3 {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.metric-value {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-trend {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 0.5rem;
}
.trend-up { color: #10b981; }
.trend-down { color: #ef4444; }

.metric-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Colores de iconos */
.icon-blue { background-color: #eff6ff; color: #3b82f6; }
.icon-emerald { background-color: #ecfdf5; color: #10b981; }
.icon-amber { background-color: #fffbeb; color: #f59e0b; }
.icon-purple { background-color: #faf5ff; color: #a855f7; }

/* Variante compacta (route=productos): tarjetas más pequeñas */
.metrics-grid.metrics-compact {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.metrics-grid.metrics-compact .metric-card { padding: 0.9rem 1rem; border-radius: 0.75rem; }
.metrics-grid.metrics-compact .metric-card:hover { transform: none; }
.metrics-grid.metrics-compact .metric-info h3 { font-size: 0.75rem; margin-bottom: 0.25rem; }
.metrics-grid.metrics-compact .metric-value { font-size: 1.35rem; }
.metrics-grid.metrics-compact .metric-trend { font-size: 0.68rem; margin-top: 0.25rem; }
.metrics-grid.metrics-compact .metric-icon { width: 2.25rem; height: 2.25rem; border-radius: 0.6rem; flex-shrink: 0; }
.metrics-grid.metrics-compact .metric-icon svg { width: 18px; height: 18px; }

/* Panel resumen de productos (route=productos): dos tarjetas anchas */
.catalog-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}
.catalog-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: 0.9rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  padding: 1rem 1.15rem;
}
.catalog-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.catalog-card-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}
.catalog-card-scope { font-size: 0.7rem; color: var(--text-muted); }
.catalog-total { font-size: 1.7rem; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.catalog-total small { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); }
.catalog-sub { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.4rem; flex-wrap: wrap; }
.catalog-pill {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}
.pill-green { background-color: #ecfdf5; color: #047857; }
.pill-amber { background-color: #fffbeb; color: #b45309; }
.catalog-hint { font-size: 0.7rem; color: var(--text-muted); }
.catalog-sync { margin-top: 0.7rem; padding-top: 0.7rem; border-top: 1px solid var(--border-light); }
.catalog-sync-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}
.catalog-progress {
  height: 6px;
  border-radius: 999px;
  background-color: var(--bg-color);
  border: 1px solid var(--border-light);
  overflow: hidden;
}
.catalog-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7c3aed, #a855f7);
  transition: width 0.3s ease;
}
.catalog-cta {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #7c3aed;
  text-decoration: none;
}
.catalog-cta:hover { text-decoration: underline; }
.catalog-ok { display: inline-block; margin-top: 0.5rem; font-size: 0.75rem; font-weight: 700; color: #047857; }

/* Tabla de Datos */
.card-panel {
  background-color: var(--card-bg);
  border-radius: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

/* Tarjeta genérica (usada en ~20 vistas: marcas, mesas, menú, cocina...) */
.card {
  background-color: var(--card-bg);
  border-radius: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border: 1px solid var(--border-light);
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.card-title {
  font-weight: 600;
  color: var(--text-primary);
}

.company-dashboard-card {
  padding: 1.5rem;
}

.company-dashboard-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.company-dashboard-logo {
  width: 4.25rem;
  height: 4.25rem;
  border-radius: 1rem;
  background-color: var(--primary-light);
  color: var(--primary-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 0 0 auto;
}

.company-dashboard-logo svg,
.company-dashboard-logo img {
  width: 100%;
  height: 100%;
  display: block;
}

.company-dashboard-logo img {
  object-fit: cover;
}

.company-dashboard-copy h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.company-dashboard-copy p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.company-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.company-dashboard-item {
  border: 1px solid var(--border-color);
  border-radius: 0.85rem;
  padding: 1rem;
  background-color: var(--bg-color);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.company-dashboard-item-full {
  grid-column: 1 / -1;
}

.company-dashboard-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 700;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
}

.profile-static-value {
  min-height: 2.875rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  background-color: var(--bg-color);
  color: var(--text-primary);
  display: flex;
  align-items: center;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  white-space: normal;
  table-layout: auto;
}

.data-table th, .data-table td {
  padding: 1rem 1.5rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border-light);
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  vertical-align: top;
}

.data-table th {
  background-color: var(--bg-color);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
  padding: 0.65rem 1rem;
  position: sticky;
  top: 0;
  z-index: 2;
}

.data-table tbody tr:hover {
  background-color: var(--bg-color);
}

.status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: normal;
}
.status-completed { background-color: #ecfdf5; color: #065f46; }
.status-pending { background-color: #fffbeb; color: #92400e; }
.status-cancelled { background-color: #fef2f2; color: #991b1b; }

.search-bar,
.page-header > div,
.card-header > div,
.card-header > form,
.card-header > .search-bar {
  min-width: 0;
}

.card-header form {
  flex-wrap: wrap;
  max-width: 100%;
}

.config-icon-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.config-icon-preview {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border-color);
  background-color: var(--primary-light);
  color: var(--primary-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.config-icon-preview svg {
  width: 1.15rem;
  height: 1.15rem;
  display: block;
}

.config-icon-select-wrap {
  min-width: 0;
  flex: 1 1 auto;
}

.config-icon-select.form-input {
  padding-left: 1rem;
}

.config-icon-hint {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.25rem;
  padding: 1.5rem;
}

.settings-field-full {
  grid-column: 1 / -1;
}

.settings-input,
.settings-textarea {
  padding-left: 1rem;
}

.settings-textarea {
  resize: vertical;
  min-height: 7rem;
}

.company-asset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.company-asset-card {
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  padding: 1rem;
  background-color: var(--bg-color);
}

.company-asset-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.company-asset-preview {
  min-height: 8.5rem;
  border: 1px dashed var(--border-color);
  border-radius: 0.9rem;
  background-color: var(--card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 1rem;
}

.company-asset-preview img {
  max-width: 100%;
  max-height: 140px;
  display: block;
  object-fit: contain;
}

.company-asset-preview-icon img {
  max-width: 72px;
  max-height: 72px;
}

.company-asset-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.system-views-table-wrap {
  overflow-x: auto;
}

.system-views-table {
  min-width: 1080px;
  table-layout: auto;
}

.system-views-table th,
.system-views-table td {
  vertical-align: middle;
}

.system-views-col-name {
  width: 22%;
}

.system-views-col-slug {
  width: 16%;
}

.system-views-col-module {
  width: 12%;
}

.system-views-col-icon {
  width: 20%;
}

.system-views-col-type {
  width: 12%;
}

.system-views-col-permissions {
  width: 18%;
}

.system-views-table .config-icon-control {
  min-width: 210px;
}

.system-views-table .config-icon-select.form-input {
  width: 100%;
  min-width: 170px;
}

.data-table code,
.history-user-agent {
  white-space: normal;
  overflow-wrap: anywhere;
}

.companies-table code {
  display: inline-block;
  padding: 0.2rem 0.45rem;
  border-radius: 0.45rem;
  border: 1px solid var(--border-light);
  background-color: var(--bg-color);
  color: var(--primary-color);
  font-size: 0.75rem;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.active {
  visibility: visible;
  opacity: 1;
}

.modal-container {
  background: var(--card-bg);
  border-radius: 12px;
  width: 90%;
  max-width: 480px;
  padding: 1.75rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  transform: translateY(-20px);
  transition: transform 0.25s ease;
  border: 1px solid var(--border-light);
}

.modal-overlay.active .modal-container {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.modal-close {
  cursor: pointer;
  color: var(--text-muted);
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s, background-color 0.15s;
}

.modal-close:hover {
  color: var(--text-primary);
  background-color: var(--bg-color);
}

.modal-body {
  padding-bottom: 1.25rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  border-top: 1px solid var(--border-light);
  padding-top: 1.25rem;
}

/* =========================================
   Diseño Responsivo (Mobile)
   ========================================= */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.5); /* Oscurece el fondo */
  z-index: 35;
  opacity: 0;
  transition: opacity 0.3s ease;
}

@media (max-width: 768px) {
  .profile-grid,
  .company-dashboard-brand,
  .company-dashboard-grid {
    grid-template-columns: 1fr;
  }

  .company-dashboard-brand {
    flex-direction: column;
    align-items: flex-start;
  }

  .settings-grid,
  .company-asset-grid {
    grid-template-columns: 1fr;
  }

  /* Ocultar el sidebar y ponerlo por encima */
  .sidebar {
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    width: 260px;
    min-width: 260px;
    transform: translateX(-100%);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
    opacity: 1;
  }

  /* Mostrar botón hamburguesa */
  .mobile-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .desktop-sidebar-toggle {
    display: none;
  }

  /* Ocultar barra de búsqueda en móviles por espacio */
  .search-bar {
    display: none;
  }

  .top-header {
    height: auto;
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
  }

  .content-area {
    padding: 1.5rem 1rem;
  }

  .page-header,
  .card-header {
    align-items: stretch;
  }

  .card-header form,
  .header-left,
  .header-actions,
  .user-profile {
    width: 100%;
    min-width: 0;
  }

  .header-left {
    width: auto;
    flex: 1 1 auto;
    gap: 0.75rem;
  }

  .topbar-mobile-brand {
    display: inline-flex;
  }

  .header-actions {
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
  }

  .company-context-form {
    width: 100%;
    order: 3;
    flex: 1 1 100%;
    gap: 0;
  }

  .company-context-label {
    display: none;
  }

  .company-context-select {
    width: 100%;
    max-width: none;
    min-width: 0;
    padding: 0.625rem 0.75rem;
    font-size: 0.8125rem;
  }

  .user-profile {
    width: auto;
    flex-wrap: nowrap;
    justify-content: flex-end;
    margin-left: auto;
    padding-left: 0.75rem;
  }

  .user-menu-toggle {
    width: auto;
    justify-content: flex-end;
    gap: 0.4rem;
  }

  .user-menu-dropdown {
    right: 0;
    left: auto;
    min-width: 170px;
  }

  .theme-toggle-btn,
  .action-btn {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    flex: 0 0 auto;
  }

  .badge {
    top: -0.1rem;
    right: -0.1rem;
  }

  .avatar {
    width: 2rem;
    height: 2rem;
    font-size: 0.8125rem;
  }

  .user-menu-caret {
    display: none;
  }
}

@media (min-width: 769px) {
  .mobile-toggle {
    display: none;
  }
}

/* =========================================
   UI Kit - Componentes Extra
   ========================================= */

/* Variantes de Botones */
.btn-secondary {
  background-color: var(--bg-color);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover { background-color: var(--border-light); }

.btn-danger {
  background-color: #ef4444;
  color: #fff;
  box-shadow: 0 1px 2px rgba(239,68,68,0.2);
}
.btn-danger:hover { background-color: #dc2626; }

.btn-outline {
  background-color: transparent;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
}
.btn-outline:hover { background-color: var(--primary-light); }

/* Variantes de Badges */
.badge-primary { background-color: var(--primary-light); color: var(--primary-color); }
.badge-warning { background-color: #fffbeb; color: #d97706; }
.badge-info { background-color: #eff6ff; color: #2563eb; }
.badge-gray { background-color: #f1f5f9; color: #475569; }

/* Barras de Progreso */
.progress-wrapper {
  margin-top: 0.75rem;
}
.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
  font-weight: 500;
}
.progress-container {
  width: 100%;
  height: 0.5rem;
  background-color: var(--border-light);
  border-radius: 9999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background-color: var(--primary-color);
  border-radius: 9999px;
  transition: width 0.5s ease;
}
.progress-emerald { background-color: #10b981; }
.progress-amber { background-color: #f59e0b; }
.progress-danger { background-color: #ef4444; }

/* Contenedores para Gráficos */
.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
  margin-top: 1rem;
}

/* Tablas Avanzadas */
.table-checkbox {
  width: 1rem;
  height: 1rem;
  accent-color: var(--primary-color);
}
.table-user-cell {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.user-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background-color: var(--border-color);
  object-fit: cover;
}
.table-actions {
  display: flex;
  gap: 0.5rem;
}
.action-icon {
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s;
}
.action-icon:hover { color: var(--primary-color); }
.action-icon.delete:hover { color: #ef4444; }

/* Layout de Secciones UI */
.ui-section {
  margin-bottom: 3rem;
}
.ui-section-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border-light);
  padding-bottom: 0.5rem;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
}
@media (max-width: 600px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* =========================================
   UI Kit - Tipografía
   ========================================= */

/* Encabezados Globales */
h1, .h1 { font-size: 2.25rem; font-weight: 800; line-height: 1.2; letter-spacing: -0.025em; color: var(--text-primary); margin-bottom: 0.5rem;}
h2, .h2 { font-size: 1.875rem; font-weight: 700; line-height: 1.3; letter-spacing: -0.025em; color: var(--text-primary); margin-bottom: 0.5rem;}
h3, .h3 { font-size: 1.5rem; font-weight: 600; line-height: 1.4; color: var(--text-primary); margin-bottom: 0.5rem;}
h4, .h4 { font-size: 1.25rem; font-weight: 600; line-height: 1.5; color: var(--text-primary); margin-bottom: 0.5rem;}
h5, .h5 { font-size: 1rem; font-weight: 600; line-height: 1.5; color: var(--text-primary); margin-bottom: 0.5rem;}
h6, .h6 { font-size: 0.875rem; font-weight: 600; line-height: 1.5; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }

/* Párrafos */
p { margin-bottom: 1rem; color: var(--text-secondary); }

/* Clases utilitarias de tamaño */
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-xs { font-size: 0.75rem; line-height: 1rem; }

/* Clases utilitarias de peso (grosor) */
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }

/* Clases utilitarias de color */
.text-brand { color: var(--primary-color); }
.color-muted { color: var(--text-muted); }

/* =========================================
   UI Kit - Alertas, Toasts y Modales
   ========================================= */

/* 1. Alertas Estáticas */
.alert {
  padding: 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.875rem;
}
.alert-icon {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
}
.alert-content { flex: 1; }
.alert-title { font-weight: 600; margin-bottom: 0.25rem; }

/* Colores de Alertas */
.alert-success { background-color: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-success .alert-icon { color: #10b981; }

.alert-danger { background-color: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-danger .alert-icon { color: #ef4444; }

.alert-warning { background-color: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-warning .alert-icon { color: #f59e0b; }

.alert-info { background-color: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-info .alert-icon { color: #3b82f6; }


/* 2. Toasts (Notificaciones Flotantes) */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 9999;
}
.toast {
  min-width: 300px;
  background-color: var(--card-bg);
  border-radius: 0.5rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  border-left: 4px solid var(--border-color);
  padding: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.toast.show { transform: translateX(0); }
.toast-success { border-left-color: #10b981; }
.toast-danger { border-left-color: #ef4444; }
.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: auto;
}
.toast-close:hover { color: var(--text-primary); }


/* 3. Modales de Confirmación */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  z-index: 9990;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  backdrop-filter: blur(2px);
}
.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}
.modal-content {
  background-color: var(--card-bg);
  border-radius: 1rem;
  width: 100%;
  max-width: 28rem; /* 448px */
  padding: 1.5rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  transform: scale(0.95);
  transition: transform 0.2s ease;
}
.modal-overlay.show .modal-content { transform: scale(1); }

.modal-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}
.modal-icon.danger { background-color: #fef2f2; color: #ef4444; }
.modal-icon.warning { background-color: #fffbeb; color: #f59e0b; }

.modal-title { font-size: 1.125rem; font-weight: 600; color: var(--text-primary); margin-bottom: 0.5rem; }
.modal-body { color: var(--text-secondary); font-size: 0.875rem; margin-bottom: 1.5rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.75rem; }

/* =========================================
   UI Kit - Modales Amplios y Tablas Complejas
   ========================================= */

/* Modales Amplios (Para Formularios) */
.modal-lg {
  max-width: 42rem; /* 672px - Más ancho para formularios a 2 columnas */
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.modal-header .modal-title { 
  margin: 0; 
  font-size: 1.25rem;
}

.modal-close-btn {
  background: none; 
  border: none; 
  cursor: pointer; 
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  border-radius: 0.25rem;
  transition: background-color 0.2s;
}
.modal-close-btn:hover { 
  color: var(--text-primary);
  background-color: var(--bg-color);
}

/* Tablas: Agrupación y Filas de Totales */
.table-group-header {
  background-color: var(--bg-color); /* Fondo ligeramente distinto para separar */
}

.table-group-header td {
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  color: var(--primary-color);
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border-color);
}

/* Fila de Totales en el pie de la tabla */
.data-table tfoot {
  background-color: var(--card-bg);
  font-weight: 700;
  border-top: 2px solid var(--border-color); /* Línea más gruesa para el total */
}

.data-table tfoot td {
  color: var(--text-primary);
  font-size: 1rem;
}

/* =========================================
   Paleta de Colores - Modo Oscuro (Dark Theme)
   ========================================= */
/* =========================================
   Paleta de Colores - Modo Oscuro (Dark Theme)
   ========================================= */
body.dark-mode {
  --bg-color: #0f172a !important;       /* Fondo general oscuro (slate-900) */
  --card-bg: #1e293b !important;        /* Fondo de tarjetas (slate-800) */
  
  --text-primary: #f8fafc !important;   /* Texto principal blanco (slate-50) */
  --text-secondary: #cbd5e1 !important; /* Texto secundario gris claro (slate-300) */
  --text-muted: #64748b !important;     /* Iconos y textos mudos (slate-500) */
  
  --border-color: #334155 !important;   /* Bordes más oscuros (slate-700) */
  --border-light: #1e293b !important;   /* Bordes sutiles iguales a la tarjeta */
  
  /* Ajustamos el Índigo para que resalte mejor sobre negro */
  --primary-color: #818cf8 !important;  /* Índigo-400 */
  --primary-hover: #6366f1 !important;  /* Índigo-500 */
  --primary-light: rgba(99, 102, 241, 0.15) !important; /* Fondo transparente para botones/iconos */
}

/* Selectores explícitos para modo oscuro - garantizar que funcione */
body.dark-mode {
  background-color: #0f172a !important;
  color: #f8fafc !important;
}

body.dark-mode .dashboard-layout {
  background-color: #0f172a !important;
}

body.dark-mode .sidebar,
body.dark-mode .top-header {
  background-color: #1e293b !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}

body.dark-mode .card-panel,
body.dark-mode .metric-card {
  background-color: #1e293b !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}

body.dark-mode .content-area {
  background-color: #0f172a !important;
  color: #f8fafc !important;
}

body.dark-mode .form-input {
  background-color: #1e293b !important;
  color: #f8fafc !important;
  border-color: #334155 !important;
}

body.dark-mode .form-label,
body.dark-mode .checkbox-label {
  color: #cbd5e1 !important;
}

body.dark-mode .data-table {
  background-color: #1e293b !important;
  color: #f8fafc !important;
}

body.dark-mode .data-table th {
  background-color: #0f172a !important;
  color: #cbd5e1 !important;
  border-color: #334155 !important;
}

body.dark-mode .data-table td {
  border-color: #334155 !important;
}

body.dark-mode .search-bar {
  background-color: #1e293b !important;
  border-color: #334155 !important;
}

body.dark-mode .search-bar input {
  color: #f8fafc !important;
}

body.dark-mode .action-btn {
  color: #cbd5e1 !important;
}

body.dark-mode .topbar-mobile-brand-name {
  color: #f8fafc !important;
}

body.dark-mode .user-menu-dropdown {
  background-color: #1e293b !important;
  border-color: #334155 !important;
  box-shadow: 0 18px 32px rgba(2, 6, 23, 0.45);
}

body.dark-mode .user-menu-item {
  color: #f8fafc !important;
}

body.dark-mode .user-menu-item:hover,
body.dark-mode .user-menu-item:focus-visible {
  background-color: #0f172a !important;
  color: #818cf8 !important;
}

body.dark-mode .mobile-toggle {
  color: #cbd5e1 !important;
}

body.dark-mode .login-wrapper {
  color: #f8fafc !important;
}

body.dark-mode .login-logo {
  background-color: rgba(99, 102, 241, 0.15) !important;
  color: #818cf8 !important;
}

body.dark-mode .login-title {
  color: #f8fafc !important;
}

body.dark-mode .login-subtitle {
  color: #cbd5e1 !important;
}

body.dark-mode .login-subtitle a {
  color: #818cf8 !important;
}

body.dark-mode .login-subtitle a:hover {
  color: #6366f1 !important;
}

body.dark-mode .theme-toggle-btn:hover {
  background-color: var(--bg-color) !important;
  color: var(--primary-color) !important;
}

/* Transición suave para todos los elementos al cambiar de tema */
body, .card-panel, .metric-card, .sidebar, .top-header, .form-input, .form-label, .checkbox-label, 
.data-table, .data-table th, .data-table td, .modal-content, .alert, .toast, 
.page-title, .card-title, h1, h2, h3, h4, h5, h6, p, a {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Botón del Tema en el Header */
.theme-toggle-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, color 0.2s;
}
.theme-toggle-btn:hover {
  background-color: var(--bg-color);
  color: var(--primary-color);
}

/* Ajustes responsivos para tablas en pantallas móviles */
@media (max-width: 768px) {
  .table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-responsive .data-table {
    width: max-content;
    min-width: 100%;
    table-layout: auto;
  }
  .table-responsive .data-table th,
  .table-responsive .data-table td {
    white-space: nowrap;
  }
}

/* Fixes responsive 2026-09: colapso de grids 2-col dentro de modales (<600px).
   Selector acotado a .modal-overlay .modal-body: cubre compras, clientes,
   categorias, mesas, menu, componentes y punto_venta sin tocar otros layouts. */
@media (max-width: 600px) {
  .modal-overlay .modal-body [style*="1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

/* Fixes responsive 2026-09: grupos de acciones inline dentro de .page-header
   (productos, punto_venta, rentas_comprobante, etc.) pueden envolverse solo
   en movil. Nota: .page-header ya tiene flex-wrap global (linea ~891); esto
   extiende el wrap a los grupos internos que usan style="display:flex; gap". */
@media (max-width: 600px) {
  .page-header > div[style*="display:flex"] {
    flex-wrap: wrap;
  }
}
