:root {
  /* Paleta oficial Nexus Factura */
  --color-primary: #2563EB;
  --color-primary-hover: #1D4ED8;
  --color-primary-soft: #EFF6FF;
  --color-secondary: #1E40AF;
  --color-accent: #06B6D4;
  --color-accent-soft: #ECFEFF;
  --color-success: #10B981;
  --color-success-soft: #ECFDF5;
  --color-warning: #F59E0B;
  --color-warning-soft: #FFFBEB;
  --color-danger: #EF4444;
  --color-danger-soft: #FEF2F2;
  --color-purple: #8B5CF6;
  --color-purple-soft: #F5F3FF;

  /* Superficies y fondos */
  --color-bg: #F8FAFC;
  --color-surface: #FFFFFF;
  --color-surface-subtle: #F1F5F9;
  --color-navy: #0F172A;
  --color-navy-light: #1E293B;
  --color-navy-border: #334155;

  /* Tipografía y bordes */
  --color-text: #0F172A;
  --color-text-secondary: #64748B;
  --color-text-light: #94A3B8;
  --color-border: #E2E8F0;

  /* Sombras y radios */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 28px -4px rgba(15, 23, 42, 0.14), 0 4px 10px -2px rgba(15, 23, 42, 0.06);

  /* Layout */
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 76px;
  --topbar-height: 68px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--color-text-secondary);
}

code {
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.82rem;
  background: var(--color-surface-subtle);
  color: var(--color-secondary);
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
}

/* ==========================================================================
   PANTALLA DE INICIO DE SESIÓN (LOGIN SAAS)
   ========================================================================== */
.login-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(circle at 15% 20%, rgba(37, 99, 235, 0.12), transparent 35%),
    radial-gradient(circle at 85% 80%, rgba(6, 182, 212, 0.12), transparent 35%),
    linear-gradient(180deg, #0F172A 0%, #1E293B 100%);
}

.login-container {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: var(--color-surface);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45);
}

.login-hero {
  background: linear-gradient(145deg, #0F172A 0%, #1E3A8A 65%, #1E40AF 100%);
  color: #FFFFFF;
  padding: 2.75rem 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.login-hero::after {
  content: '';
  position: absolute;
  right: -60px;
  bottom: -60px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.28) 0%, transparent 70%);
  pointer-events: none;
}

.brand-logo-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-mark-svg {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.brand-title {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
  color: #FFFFFF;
}

.brand-tagline {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
  color: #93C5FD;
}

.login-hero-features {
  margin: 2rem 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.hero-feature-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
}

.hero-feature-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(6, 182, 212, 0.2);
  color: #38BDF8;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hero-feature-item h4 {
  margin: 0 0 0.15rem;
  font-size: 0.9rem;
  color: #FFFFFF;
}

.hero-feature-item p {
  margin: 0;
  font-size: 0.78rem;
  color: #CBD5E1;
}

.login-form-pane {
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-form-pane h2 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--color-text);
}

.quick-logins-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  margin: 1.1rem 0 0.5rem;
}

.quick-logins {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.quick-login-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  cursor: pointer;
  transition: all 0.15s ease;
}

.quick-login-btn:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
}

.quick-login-btn strong {
  font-size: 0.8rem;
  color: var(--color-text);
}

.quick-login-btn span {
  font-size: 0.72rem;
  color: var(--color-text-secondary);
}

/* ==========================================================================
   ESTRUCTURA SAAS PRINCIPAL (SIDEBAR + TOPBAR + WORKSPACE)
   ========================================================================== */
.saas-layout {
  display: flex;
  min-height: 100vh;
  background: var(--color-bg);
}

/* Menú lateral azul oscuro (#0F172A) */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-navy);
  color: #E2E8F0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: width 0.22s ease, transform 0.22s ease;
  border-right: 1px solid var(--color-navy-border);
  user-select: none;
}

.saas-layout.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
}

.sidebar-brand {
  height: var(--topbar-height);
  padding: 0 1.15rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.sidebar-brand-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  overflow: hidden;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  white-space: nowrap;
}

.sidebar-brand-text strong {
  font-size: 1.08rem;
  font-weight: 800;
  color: #FFFFFF;
  letter-spacing: -0.02em;
}

.sidebar-brand-text small {
  font-size: 0.68rem;
  color: #38BDF8;
  font-weight: 600;
}

.saas-layout.sidebar-collapsed .sidebar-brand-text,
.saas-layout.sidebar-collapsed .nav-label,
.saas-layout.sidebar-collapsed .nav-section-title,
.saas-layout.sidebar-collapsed .sidebar-tenant-details {
  display: none;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.nav-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #64748B;
  padding: 0.65rem 0.65rem 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.62rem 0.75rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #94A3B8;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #FFFFFF;
}

.nav-item.active {
  background: var(--color-primary);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-badge {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  background: rgba(245, 158, 11, 0.2);
  color: #FBBF24;
}

.sidebar-footer {
  padding: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.6);
}

.sidebar-tenant-card {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--color-navy-light);
  border: 1px solid var(--color-navy-border);
}

.sidebar-tenant-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.25);
  color: #60A5FA;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-tenant-details {
  overflow: hidden;
  flex: 1;
}

.sidebar-tenant-details strong {
  display: block;
  font-size: 0.8rem;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-tenant-details span {
  display: block;
  font-size: 0.72rem;
  color: #94A3B8;
}

/* Contenedor derecho principal */
.main-area {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left 0.22s ease;
}

.saas-layout.sidebar-collapsed .main-area {
  margin-left: var(--sidebar-collapsed-width);
}

/* Cabecera superior blanca */
.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 80;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex: 1;
  max-width: 620px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.icon-btn:hover {
  background: var(--color-surface-subtle);
  color: var(--color-text);
}

.global-search-wrap {
  position: relative;
  flex: 1;
}

.global-search-input {
  width: 100%;
  padding: 0.55rem 0.9rem 0.55rem 2.35rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  font-size: 0.86rem;
  color: var(--color-text);
  transition: all 0.15s ease;
}

.global-search-input:focus {
  outline: none;
  background: var(--color-surface);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.global-search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-light);
  pointer-events: none;
}

.global-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 340px;
  overflow-y: auto;
  z-index: 120;
  padding: 0.4rem;
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.83rem;
}

.search-result-item:hover {
  background: var(--color-primary-soft);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.company-selector-pill {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--color-surface-subtle);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.company-selector-pill label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-text-secondary);
  margin: 0;
  white-space: nowrap;
}

.company-selector-pill select {
  border: none;
  background: transparent;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--color-text);
  padding: 0.15rem 0.25rem;
  cursor: pointer;
}

.company-selector-pill select:focus {
  outline: none;
}

.notif-wrapper {
  position: relative;
}

.notif-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  background: var(--color-danger);
  color: #FFFFFF;
  font-size: 0.68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.85rem;
  z-index: 120;
}

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

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  color: #FFFFFF;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-meta strong {
  font-size: 0.84rem;
  color: var(--color-text);
}

.user-meta small {
  font-size: 0.72rem;
  color: var(--color-text-secondary);
}

/* Cinta discreta de estado técnico FacturaLibre */
.integration-strip {
  background: #F1F5F9;
  border-bottom: 1px solid var(--color-border);
  padding: 0.45rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.78rem;
}

.strip-items {
  display: flex;
  align-items: center;
  gap: 1.15rem;
  flex-wrap: wrap;
}

/* Contenido de vistas */
.workspace-content {
  padding: 1.5rem;
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.16s ease;
}

.tab-panel.active {
  display: block;
}

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

/* Cabecera de página interna */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.35rem;
}

.page-header h2 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.page-header p {
  margin: 0.2rem 0 0;
  font-size: 0.88rem;
  color: var(--color-text-secondary);
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   TARJETAS KPI Y DASHBOARD (ESTILO IMAGEN DE REFERENCIA)
   ========================================================================== */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.35rem;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow-xs);
  display: flex;
  align-items: flex-start;
  gap: 0.95rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.green {
  background: var(--color-success-soft);
  color: var(--color-success);
}
.stat-icon.blue {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}
.stat-icon.purple {
  background: var(--color-purple-soft);
  color: var(--color-purple);
}
.stat-icon.amber {
  background: var(--color-warning-soft);
  color: var(--color-warning);
}
.stat-icon.cyan {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}
.stat-icon.red {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

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

.stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 0.15rem;
}

.stat-value {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--color-text);
  line-height: 1.2;
}

.stat-sub {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* Grillas del Dashboard */
.dashboard-charts-grid {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.dashboard-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-xs);
  margin-bottom: 1.25rem;
}

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

.card-header h3,
.card h3 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--color-text);
}

/* Gráfico de barras SVG y Donut */
.bar-chart-container {
  height: 220px;
  display: flex;
  align-items: flex-end;
  gap: 0.85rem;
  padding: 1rem 0.5rem 0.25rem;
  border-bottom: 1px solid var(--color-border);
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  height: 100%;
  justify-content: flex-end;
}

.bar-fill {
  width: 100%;
  max-width: 44px;
  background: linear-gradient(180deg, #3B82F6 0%, #2563EB 100%);
  border-radius: 6px 6px 0 0;
  transition: height 0.3s ease;
  min-height: 6px;
}

.bar-label {
  font-size: 0.72rem;
  color: var(--color-text-secondary);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}

.bar-val {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-text);
}

.donut-layout {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 1.25rem;
  padding: 0.5rem 0;
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  flex: 1;
}

.legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.83rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 0.5rem;
}

/* Listas de productos y actividad reciente en Dashboard */
.ranked-list,
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.ranked-item,
.activity-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
}

.rank-num {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--color-surface-subtle);
  color: var(--color-text-secondary);
  font-weight: 700;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   PUNTO DE VENTA (POS) — DISEÑO DE ALTA VELOCIDAD
   ========================================================================== */
.pos-layout {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 1.25rem;
  align-items: start;
}

.pos-catalog-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  box-shadow: var(--shadow-xs);
}

.pos-search-bar {
  display: flex;
  gap: 0.65rem;
  margin-bottom: 0.9rem;
}

.pos-search-input-wrap {
  position: relative;
  flex: 1;
}

.pos-search-input-wrap input {
  padding-left: 2.35rem;
  padding-right: 2.5rem;
}

.pos-category-pills {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding-bottom: 0.65rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--color-border);
}

.category-pill {
  padding: 0.42rem 0.95rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.category-pill:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.category-pill.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #FFFFFF;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 0.85rem;
}

.product-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.55rem;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.product-tile:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.product-thumb {
  height: 74px;
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.25rem;
}

.product-tile h4 {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.product-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--color-text-secondary);
}

.product-price {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--color-primary);
}

.stock-text-ok {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--color-success);
}

.stock-text-low {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--color-warning);
}

/* Carrito derecho fijo en POS */
.pos-cart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: calc(var(--topbar-height) + 1rem);
}

.pos-cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 0.75rem;
}

.cart-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 270px;
  overflow-y: auto;
  margin-bottom: 0.9rem;
  padding-right: 0.2rem;
}

.cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}

.qty-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  overflow: hidden;
}

.qty-stepper button {
  border: none;
  background: transparent;
  width: 26px;
  height: 26px;
  font-weight: 700;
  color: var(--color-text);
  cursor: pointer;
}

.qty-stepper button:hover {
  background: var(--color-surface-subtle);
}

.qty-stepper span {
  min-width: 26px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.totals-box {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin: 0.85rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.totals-box > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.totals-box .grand-total {
  border-top: 1px solid var(--color-border);
  padding-top: 0.55rem;
  margin-top: 0.25rem;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--color-primary);
}

/* ==========================================================================
   FILTROS, PESTAÑAS INTERNAS, TABLAS Y FORMULARIOS
   ========================================================================== */
.subtabs-bar {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.subtab-pill {
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.subtab-pill.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #FFFFFF;
}

.filters-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
  background: var(--color-bg);
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  margin-bottom: 1rem;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.85rem;
}

.form-row {
  margin-bottom: 0.75rem;
}

label {
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 0.3rem;
}

input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin: 0.65rem 0;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

.checkbox-row input {
  margin-top: 0.2rem;
}

.form-actions {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  justify-content: flex-end;
  margin-top: 0.65rem;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.58rem 1.05rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-sm {
  padding: 0.36rem 0.7rem;
  font-size: 0.78rem;
}

.btn-primary {
  background: var(--color-primary);
  color: #FFFFFF;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

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

.btn-secondary {
  background: var(--color-secondary);
  color: #FFFFFF;
}

.btn-secondary:hover {
  background: #1E3A8A;
}

.btn-success {
  background: var(--color-success);
  color: #FFFFFF;
}

.btn-danger {
  background: var(--color-danger);
  color: #FFFFFF;
}

.btn-danger-outline {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  border: 1px solid #FECACA;
}

.btn-outline {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.btn-outline:hover {
  background: var(--color-surface-subtle);
}

/* Badges / Etiquetas de estado */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.73rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-success {
  background: var(--color-success-soft);
  color: #047857;
}

.badge-warn {
  background: var(--color-warning-soft);
  color: #B45309;
}

.badge-danger {
  background: var(--color-danger-soft);
  color: #B91C1C;
}

.badge-info {
  background: var(--color-primary-soft);
  color: var(--color-secondary);
}

.badge-cyan {
  background: var(--color-accent-soft);
  color: #0E7490;
}

.badge-neutral {
  background: var(--color-surface-subtle);
  color: var(--color-text-secondary);
}

/* Tablas modernas */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  background: var(--color-surface);
}

th,
td {
  text-align: left;
  padding: 0.72rem 0.9rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

th {
  background: var(--color-bg);
  color: var(--color-text-secondary);
  font-weight: 700;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr:hover {
  background: #F8FAFC;
}

tbody tr:last-child td {
  border-bottom: none;
}

/* Estados vacíos profesionales */
.empty-state {
  text-align: center;
  padding: 2.25rem 1rem;
  color: var(--color-text-secondary);
}

.empty-state h4 {
  margin: 0.5rem 0 0.25rem;
  color: var(--color-text);
  font-size: 0.95rem;
}

/* Modales */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 200;
}

.modal-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border);
  padding: 1.5rem;
}

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

.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

/* Notificaciones Toast flotantes */
.toast-area {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 250;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 420px;
}

.toast {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.84rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.55rem;
  animation: fadeIn 0.2s ease;
}

.toast-ok {
  background: #065F46;
  color: #ECFDF5;
  border-left: 4px solid var(--color-success);
}

.toast-err {
  background: #7F1D1D;
  color: #FEF2F2;
  border-left: 4px solid var(--color-danger);
}

/* Reportes Grid */
.reports-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  box-shadow: var(--shadow-xs);
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--color-primary);
  margin: 0.3rem 0;
}

/* ==========================================================================
   RESPONSIVE DESIGN (ESCRITORIO, PORTÁTIL, TABLET Y MÓVIL)
   ========================================================================== */
.mobile-pos-bar {
  display: none;
}

@media (max-width: 1120px) {
  .pos-layout,
  .dashboard-charts-grid,
  .dashboard-bottom-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  .pos-cart-card {
    position: static;
  }
}

@media (max-width: 860px) {
  .login-container {
    grid-template-columns: 1fr;
  }

  .login-hero {
    padding: 1.75rem;
  }

  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
  }

  .saas-layout.mobile-nav-open .sidebar {
    transform: translateX(0);
  }

  .main-area,
  .saas-layout.sidebar-collapsed .main-area {
    margin-left: 0;
  }

  .topbar {
    padding: 0 0.85rem;
  }

  .user-meta {
    display: none;
  }

  .workspace-content {
    padding: 1rem;
    padding-bottom: 4.5rem;
  }

  .mobile-pos-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-navy);
    color: #FFFFFF;
    padding: 0.7rem 1rem;
    align-items: center;
    justify-content: space-between;
    z-index: 90;
    box-shadow: 0 -4px 12px rgba(15, 23, 42, 0.2);
  }
}

/* ==========================================================================
   MEJORAS ESPECIALES PARA QUIOSCOS, BODEGAS, TIENDAS Y BOTICAS
   ========================================================================== */

/* Selector visual rápido de Medio de Pago (Efectivo, Yape, Plin, Tarjeta) */
.payment-method-pills {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}

.payment-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.45rem 0.3rem;
  border-radius: 10px;
  border: 1.5px solid var(--color-border);
  background: #FFFFFF;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.15s ease;
}

.payment-pill:hover {
  border-color: #93C5FD;
  background: #F8FAFC;
}

.payment-pill.active.cash {
  border-color: #10B981;
  background: #ECFDF5;
  color: #065F46;
}

.payment-pill.active.yape {
  border-color: #7C3AED;
  background: #F5F3FF;
  color: #5B21B6;
}

.payment-pill.active.plin {
  border-color: #06B6D4;
  background: #ECFEFF;
  color: #0E7490;
}

.payment-pill.active.card {
  border-color: #2563EB;
  background: #EFF6FF;
  color: #1E40AF;
}

/* Calculadora de Vuelto en Efectivo (Quioscos / Bodegas / Boticas) */
.cash-calculator-box {
  background: #F8FAFC;
  border: 1px solid #CBD5E1;
  border-radius: 10px;
  padding: 0.65rem;
  margin-bottom: 0.7rem;
}

.quick-bill-row {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.quick-bill-btn {
  flex: 1;
  min-width: 48px;
  padding: 0.3rem 0.4rem;
  font-size: 0.73rem;
  font-weight: 700;
  border-radius: 7px;
  border: 1px solid #CBD5E1;
  background: #FFFFFF;
  color: #0F172A;
  cursor: pointer;
  transition: all 0.12s ease;
}

.quick-bill-btn:hover {
  background: #EFF6FF;
  border-color: #2563EB;
  color: #1E40AF;
}

.change-highlight-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ECFDF5;
  border: 1px solid #A7F3D0;
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  margin-top: 0.45rem;
  color: #065F46;
  font-weight: 800;
  font-size: 0.92rem;
}

.change-highlight-box.insufficient {
  background: #FEF2F2;
  border-color: #FECACA;
  color: #991B1B;
}

/* Etiquetas de Anaquel / Lote / Vencimiento en tarjetas del POS */
.prd-meta-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.prd-tag-Chip {
  font-size: 0.66rem;
  padding: 0.1rem 0.38rem;
  border-radius: 5px;
  background: #F1F5F9;
  color: #475569;
  font-weight: 600;
}

.prd-tag-Chip.exp-warn {
  background: #FEF3C7;
  color: #92400E;
}

.prd-tag-Chip.exp-danger {
  background: #FEE2E2;
  color: #991B1B;
}

/* ==========================================================================
   TICKET TÉRMICO IMPRIMIBLE DE 80MM (COMPROBANTE Y ARQUEO DE CAJA)
   ========================================================================== */
.thermal-ticket-paper {
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
  background: #FFFFFF;
  color: #000000;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  line-height: 1.35;
  padding: 16px 14px;
  border: 1px dashed #94A3B8;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
  border-radius: 4px;
}

.thermal-header {
  text-align: center;
  margin-bottom: 8px;
}

.thermal-header h4 {
  margin: 0 0 2px 0;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
}

.thermal-voucher-box {
  border: 1.5px solid #000000;
  padding: 6px;
  text-align: center;
  margin: 8px 0;
  font-weight: 700;
}

.thermal-sim-banner {
  background: #FFFBEB;
  border: 1px dashed #D97706;
  color: #92400E;
  text-align: center;
  font-weight: 700;
  font-size: 10.5px;
  padding: 4px;
  margin: 6px 0;
}

.thermal-divider {
  border: none;
  border-top: 1px dashed #000000;
  margin: 6px 0;
}

.thermal-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.thermal-items-table th {
  border-bottom: 1px dashed #000000;
  padding: 3px 2px;
  text-align: left;
  font-size: 10.5px;
  background: transparent;
  color: #000000;
}

.thermal-items-table td {
  padding: 3px 2px;
  border: none;
  vertical-align: top;
  color: #000000;
}

.thermal-totals-row {
  display: flex;
  justify-content: space-between;
  margin: 2px 0;
}

.thermal-totals-row.grand {
  font-size: 13.5px;
  font-weight: 800;
  border-top: 1px dashed #000000;
  border-bottom: 1px dashed #000000;
  padding: 4px 0;
  margin: 4px 0;
}

.thermal-qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 10px 0 4px;
  text-align: center;
}

.signature-box {
  margin-top: 26px;
  border-top: 1px solid #000000;
  text-align: center;
  padding-top: 4px;
  font-size: 11px;
}

@media print {
  body * {
    visibility: hidden !important;
  }
  #thermalTicketModal:not(.hidden),
  #thermalTicketModal:not(.hidden) *,
  #cashCloseTicketModal:not(.hidden),
  #cashCloseTicketModal:not(.hidden) * {
    visibility: visible !important;
  }
  #thermalTicketModal:not(.hidden),
  #cashCloseTicketModal:not(.hidden) {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    background: #FFFFFF !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .no-print {
    display: none !important;
  }
  .thermal-ticket-paper {
    box-shadow: none !important;
    border: none !important;
    max-width: 80mm !important;
    width: 80mm !important;
    padding: 2mm !important;
  }
}
