/* ============================================================================
   VitryApp ERP - Hoja de Estilos 1:1 con VitryApp.Desktop (WPF / XAML)
   Temas soportados:
   - RoyalPurple (Lila Corporativo Claro)
   - matte-purple (Lila Mate con Sidebar Oscuro #3B3148)
   - Ciruela (Ciruela Corporativo #641B56 con Sidebar Degradado #4A1A42 -> #2D1028)
   ============================================================================ */

:root,
html[data-theme="RoyalPurple"] {
  --primary: #4E386F;
  --primary-hover: #3E2C59;
  --primary-light: #EDE8F4;
  --accent: #7A5BA6;
  --accent-light: #F3EFF8;

  --bg: #F8F7FF;
  --surface: #FFFFFF;
  --surface-subtle: #F1EDF5;
  --surface-hover: #E7E0EE;
  --border: #CFC5DA;

  --text-main: #21172D;
  --text-muted: #64576E;
  --text-inverse: #FFFFFF;

  --sidebar-bg: #FFFFFF;
  --sidebar-hover: #F1EDF5;
  --sidebar-text: #21172D;
  --sidebar-muted: #64576E;
  --sidebar-border: #CFC5DA;
  --sidebar-icon: #4E386F;

  --success: #2F7D4E;
  --success-bg: #EBF5EF;
  --warning: #B45309;
  --warning-bg: #FEF3C7;
  --danger: #DC2626;
  --danger-bg: #FEE2E2;
}

html[data-theme="matte-purple"] {
  --primary: #4E386F;
  --primary-hover: #3E2C59;
  --primary-light: #EDE8F4;
  --accent: #7A5BA6;
  --accent-light: #F3EFF8;

  --bg: #F8F7FF;
  --surface: #FFFFFF;
  --surface-subtle: #F1EDF5;
  --surface-hover: #E7E0EE;
  --border: #CFC5DA;

  --text-main: #21172D;
  --text-muted: #64576E;
  --text-inverse: #FFFFFF;

  --sidebar-bg: #3B3148;
  --sidebar-hover: #4B3E5C;
  --sidebar-text: #F8FAFC;
  --sidebar-muted: #E2E8F0;
  --sidebar-border: #524364;
  --sidebar-icon: #D4C2E6;
}

html[data-theme="Ciruela"] {
  --primary: #641B56;
  --primary-hover: #4D1745;
  --primary-light: #F3E8F0;
  --accent: #8C3B7B;
  --accent-light: #F9F2F7;

  --bg: #F8F6F8;
  --surface: #FFFFFF;
  --surface-subtle: #F3EEF2;
  --surface-hover: #EAE0E8;
  --border: #D8C9D5;

  --text-main: #2A1B27;
  --text-muted: #6E5869;
  --text-inverse: #FFFFFF;

  --sidebar-bg: linear-gradient(180deg, #4A1A42 0%, #2D1028 100%);
  --sidebar-hover: #542048;
  --sidebar-text: #FCF9FB;
  --sidebar-muted: #DFC8DA;
  --sidebar-border: #632856;
  --sidebar-icon: #F1DCEB;
}

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

html, body {
  width: 100%;
  height: 100%;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  font-size: 13px;
  color: var(--text-main);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

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

/* ============================================================================
   1. PANTALLA DE LOGIN (LoginWindow.xaml 1:1)
   ============================================================================ */
.login-screen {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 20%, #F5F1FA 0%, #EBE4F3 60%, #E3DAED 100%);
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border: 1px solid rgba(78, 56, 111, 0.16);
  border-radius: 12px;
  padding: 38px 36px 32px;
  box-shadow: 0 16px 40px rgba(78, 56, 111, 0.12), 0 2px 6px rgba(0, 0, 0, 0.04);
  animation: pageFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 26px;
}

.login-logo-box {
  width: 90px;
  height: 74px;
  border-radius: 10px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(78, 56, 111, 0.08);
  padding: 10px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.login-logo-box:hover {
  transform: scale(1.03);
}

.login-logo-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.login-title {
  font-size: 23px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.login-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
  margin-top: 2px;
}

.field-group {
  margin-bottom: 14px;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 5px;
}

.erp-input,
.erp-select,
.erp-textarea {
  width: 100%;
  height: 32px;
  padding: 5px 10px;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text-main);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  outline: none;
  transition: border-color 0.12s ease;
}

.erp-textarea {
  height: auto;
  min-height: 62px;
  resize: vertical;
}

.erp-input:focus,
.erp-select:focus,
.erp-textarea:focus {
  border-color: var(--primary);
}

.login-input {
  height: 36px;
  font-size: 13px;
}

.otp-code-input {
  text-align: center;
  font-family: Consolas, monospace;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.erp-checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  margin: 4px 0 16px;
  user-select: none;
}

.erp-checkbox-row input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
}

.login-error {
  font-size: 12px;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid #FCA5A5;
  border-radius: 4px;
  padding: 8px 10px;
  margin-bottom: 12px;
  text-align: center;
}

.otp-info-banner {
  font-size: 12px;
  color: var(--primary);
  background: var(--primary-light);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 14px;
  line-height: 1.45;
}

.login-submit-btn {
  width: 100%;
  height: 40px;
  font-size: 13px;
}

.login-back-btn {
  width: 100%;
  height: 34px;
  margin-top: 8px;
}

/* ============================================================================
   2. BOTONES CORPORATIVOS (AppStyles.xaml 1:1)
   ============================================================================ */
.btn-primary,
.btn-subtle,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
  text-decoration: none;
}

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

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

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

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

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #FCA5A5;
}

.btn-danger:hover {
  background: #FECACA;
}

.btn-xs {
  height: 24px;
  padding: 0 8px;
  font-size: 11px;
}

/* ============================================================================
   3. SHELL PRINCIPAL: SIDEBAR + TOPBAR + VIEW HOST + STATUSBAR (MainWindow.xaml)
   ============================================================================ */
.erp-shell {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* --- SIDEBAR IZQUIERDO --- */
.erp-sidebar {
  width: 278px;
  min-width: 278px;
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  transition: width 0.16s ease, min-width 0.16s ease;
  user-select: none;
  z-index: 20;
}

.erp-sidebar.collapsed {
  width: 64px;
  min-width: 64px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 12px;
  gap: 8px;
}

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

.sidebar-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-brand-titles {
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-store-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--sidebar-text);
  text-overflow: ellipsis;
  overflow: hidden;
}

.sidebar-store-sub {
  font-size: 8.5px;
  font-weight: 600;
  color: var(--sidebar-muted);
  letter-spacing: 0.5px;
  margin-top: 1px;
}

.sidebar-collapse-btn {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: transparent;
  border: none;
  color: var(--sidebar-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
  background: var(--sidebar-hover);
}

.erp-sidebar.collapsed .sidebar-brand-left {
  display: none;
}

.erp-sidebar.collapsed .sidebar-brand {
  justify-content: center;
  padding: 14px 8px 12px;
}

.erp-sidebar.collapsed .sidebar-chevron-icon {
  transform: rotate(180deg);
}

.sidebar-divider {
  height: 1px;
  background: var(--sidebar-border);
  margin: 0 12px 6px;
}

/* Navegación Acordeón */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 10px;
}

.sidebar-nav::-webkit-scrollbar {
  width: 5px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(120, 110, 135, 0.3);
  border-radius: 3px;
}

.nav-item-btn,
.nav-module-header {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  margin: 1px 0;
  border: none;
  border-left: 3px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--sidebar-text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  text-align: left;
}

.nav-module-header {
  height: 38px;
  font-weight: 600;
}

.nav-item-left {
  display: flex;
  align-items: center;
  gap: 11px;
  overflow: hidden;
  white-space: nowrap;
}

.nav-icon {
  width: 16px;
  height: 16px;
  color: var(--sidebar-icon);
  flex-shrink: 0;
}

.nav-arrow {
  width: 9px;
  height: 9px;
  color: var(--sidebar-muted);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.nav-module-group.open .nav-arrow {
  transform: rotate(180deg);
}

.nav-item-btn:hover,
.nav-module-header:hover {
  background: var(--sidebar-hover);
}

.nav-item-btn.active {
  background: var(--sidebar-hover);
  border-left-color: var(--sidebar-icon);
  font-weight: 600;
}

.nav-sub-list {
  display: none;
  padding-left: 24px;
  margin-bottom: 4px;
}

.nav-module-group.open .nav-sub-list {
  display: block;
}

.nav-sub-btn {
  width: 100%;
  height: 31px;
  padding: 0 10px 0 14px;
  margin: 1px 0;
  border: none;
  border-left: 3px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--sidebar-text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 400;
  display: flex;
  align-items: center;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-sub-btn:hover {
  background: var(--sidebar-hover);
}

.nav-sub-btn.active {
  background: var(--sidebar-hover);
  border-left-color: var(--sidebar-icon);
  font-weight: 600;
}

.nav-nested-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--sidebar-muted);
  padding: 6px 10px 3px 14px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.erp-sidebar.collapsed .nav-label,
.erp-sidebar.collapsed .nav-arrow,
.erp-sidebar.collapsed .nav-sub-list {
  display: none !important;
}

.erp-sidebar.collapsed .nav-item-btn,
.erp-sidebar.collapsed .nav-module-header {
  justify-content: center;
  padding: 0;
}

.sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
  padding: 8px 10px;
}

/* --- ÁREA PRINCIPAL DERECHA --- */
.erp-main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Barra Superior (46px) */
.erp-topbar {
  height: 46px;
  min-height: 46px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-menu-btn {
  display: none;
  padding: 0 10px;
  height: 30px;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

.topbar-branch-badge {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-user-badge {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 5px 10px;
  font-size: 11.5px;
}

.topbar-logout-btn {
  height: 28px;
  padding: 0 12px;
  font-size: 11.5px;
}

/* Contenedor de Vistas */
.erp-view-host {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  background: var(--bg);
}

/* Barra de Estado Inferior estilo SAP (28px) */
.erp-statusbar {
  height: 28px;
  min-height: 28px;
  background: var(--surface-subtle);
  border-top: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.statusbar-left,
.statusbar-center,
.statusbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.statusbar-left strong {
  color: var(--text-main);
  font-weight: 600;
}

.status-sep {
  color: var(--border);
}

.status-shortcut-link {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
}

.status-shortcut-link:hover {
  color: var(--primary);
  background: var(--surface-hover);
}

.statusbar-right {
  font-weight: 600;
}

/* ============================================================================
   4. COMPONENTES DE VISTAS ERP (ErpHomeView, ProductsView, PosView, etc.)
   ============================================================================ */
.erp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
}

.section-header-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
}

/* 4x2 Grid de Módulos (ModuleTileButtonStyle en ErpHomeView.xaml) */
.module-tiles-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.module-tile-btn {
  height: 54px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  transition: background 0.12s ease, border-color 0.12s ease;
}

.module-tile-btn:hover {
  background: var(--surface-subtle);
  border-color: var(--primary);
}

.module-tile-icon-box {
  width: 34px;
  height: 34px;
  border-radius: 4px;
  background: var(--primary);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Banner Corporativo (ErpHomeView.xaml) */
.company-banner-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 22px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.company-banner-left {
  display: flex;
  align-items: center;
  gap: 18px;
}

.company-banner-logo {
  width: 68px;
  height: 68px;
  border-radius: 8px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.company-banner-logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.company-banner-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.company-banner-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
}

.company-banner-badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
}

.company-banner-meta {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

.company-banner-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.company-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 4 KPI Cards (ErpHomeView.xaml) */
.kpi-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
}

.kpi-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.kpi-value {
  font-size: 21px;
  font-weight: 700;
  color: var(--text-main);
  margin: 6px 0 4px;
}

.kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* 2x2 BI DataGrids (ErpHomeView.xaml) */
.bi-grid-2x2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.bi-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 255px;
}

.bi-panel-header {
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bi-panel-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bi-panel-bar {
  width: 4px;
  height: 14px;
  border-radius: 2px;
  background: var(--primary);
}

.bi-panel-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
}

.bi-panel-link {
  background: transparent;
  border: none;
  color: var(--primary);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.bi-panel-link:hover {
  text-decoration: underline;
}

.bi-panel-body {
  flex: 1;
  overflow-y: auto;
}

/* ============================================================================
   5. TABLAS DATAGRID EMPRESARIALES (FlatDataGridStyle en AppStyles.xaml)
   ============================================================================ */
.datagrid-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.datagrid-scroll {
  width: 100%;
  overflow-x: auto;
}

.erp-datagrid {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.erp-datagrid thead th {
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  white-space: nowrap;
}

.erp-datagrid thead th:last-child {
  border-right: none;
}

.erp-datagrid tbody tr {
  background: var(--surface);
  border-bottom: 1px solid var(--surface-subtle);
}

.erp-datagrid tbody tr:nth-child(even) {
  background: #FAF9FC;
}

.erp-datagrid tbody tr:hover {
  background: var(--primary-light);
}

.erp-datagrid tbody td {
  padding: 8px 12px;
  color: var(--text-main);
  vertical-align: middle;
}

.text-right {
  text-align: right !important;
}

.text-center {
  text-align: center !important;
}

.font-bold {
  font-weight: 700;
}

.color-primary {
  color: var(--primary);
  font-weight: 700;
}

.color-success {
  color: var(--success);
  font-weight: 700;
}

.color-danger {
  color: var(--danger);
  font-weight: 700;
}

/* Miniatura de producto 40x40 (ProductsView.xaml) */
.prod-thumb-box {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.prod-thumb-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.badge-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.badge-primary {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ============================================================================
   6. BARRAS DE HERRAMIENTAS DE VISTAS (ProductsView.xaml, InvoicesView.xaml)
   ============================================================================ */
.view-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.toolbar-search-wrap {
  flex: 1;
  min-width: 260px;
  position: relative;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sync-status-bar {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* ============================================================================
   7. PUNTO DE VENTA (PosView.xaml 1:1)
   ============================================================================ */
.pos-layout {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 16px;
  min-height: calc(100vh - 125px);
}

.pos-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 10px;
  max-height: calc(100vh - 230px);
  overflow-y: auto;
  padding-right: 4px;
}

.pos-product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.12s ease, transform 0.08s ease;
}

.pos-product-card:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.pos-product-img {
  width: 100%;
  height: 86px;
  border-radius: 4px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.pos-product-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ============================================================================
   8. PESTAÑAS INTERNAS (AdminView.xaml, AccountingView.xaml)
   ============================================================================ */
.erp-tabs-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
}

.erp-tab-btn {
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

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

.erp-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ============================================================================
   9. VENTANAS MODALES (ProductEditDialog.xaml 1:1)
   ============================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 14, 28, 0.52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-window {
  width: 100%;
  max-width: 980px;
  max-height: 92vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.22);
}

.modal-header {
  padding: 16px 22px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

.modal-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.modal-body {
  padding: 18px 22px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 22px;
  background: var(--surface-subtle);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* Layout de 2 columnas de ProductEditDialog.xaml (300px foto izquierda + formulario derecha) */
.product-dialog-grid {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 20px;
}

.product-photo-panel {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.product-photo-preview {
  width: 240px;
  height: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 10px 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.product-photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.form-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

/* Toast Notification */
.toast-host {
  position: fixed;
  right: 20px;
  bottom: 40px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast-msg {
  background: var(--primary);
  color: #FFFFFF;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.toast-msg.error {
  background: var(--danger);
}

/* ============================================================================
   10. ANIMACIONES Y MICRO-INTERACCIONES MODERNAS
   ============================================================================ */
@keyframes pageFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulseSubtle {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

.erp-view-host > * {
  animation: pageFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-primary, .btn-secondary, .btn-subtle, .btn-danger {
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.btn-primary:active, .btn-secondary:active, .btn-subtle:active {
  transform: scale(0.97);
}

.erp-input:focus, .erp-select:focus, .erp-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(78, 56, 111, 0.14);
}

/* Telón de fondo oscuro para el menú móvil */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 12, 28, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 205;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* ============================================================================
   11. RESPONSIVIDAD MÓVIL Y ADAPTACIÓN PWA
   ============================================================================ */
@media (max-width: 1024px) {
  .module-tiles-grid,
  .kpi-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .bi-grid-2x2,
  .pos-layout,
  .product-dialog-grid {
    grid-template-columns: 1fr;
  }
  .statusbar-center {
    display: none;
  }
}

@media (max-width: 768px) {
  /* Cabecera Móvil Compacta */
  .erp-topbar {
    height: 50px;
    min-height: 50px;
    padding: 0 12px;
  }

  .topbar-left {
    gap: 8px;
    flex: 1;
    overflow: hidden;
  }

  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    font-size: 18px;
    border-radius: 6px;
    background: var(--surface-subtle);
  }

  .topbar-title {
    font-size: 14.5px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
  }

  .topbar-branch-badge {
    display: none;
  }

  .topbar-right {
    gap: 6px;
  }

  .topbar-user-badge {
    padding: 4px 8px;
    font-size: 11px;
    max-width: 110px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-logout-btn {
    height: 30px;
    padding: 0 8px;
    font-size: 11px;
  }

  /* Menú lateral como cajón deslizante sobrepuesto */
  .erp-sidebar {
    position: fixed;
    left: -300px;
    top: 0;
    bottom: 0;
    width: 285px;
    max-width: 84vw;
    z-index: 210;
    box-shadow: 6px 0 28px rgba(0, 0, 0, 0.22);
    transition: left 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .erp-sidebar.mobile-open {
    left: 0;
  }

  .sidebar-collapse-btn {
    display: none;
  }

  /* Área de Contenido y Tarjetas */
  .erp-view-host {
    padding: 14px 12px;
  }

  .erp-card {
    padding: 16px 14px;
    margin-bottom: 14px;
    border-radius: 8px;
  }

  /* Pestañas Horizontales Touch sin scrollbar invasivo */
  .erp-tabs-bar {
    display: flex;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    padding-bottom: 4px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
  }

  .erp-tabs-bar::-webkit-scrollbar {
    display: none;
  }

  .erp-tab-btn {
    padding: 8px 14px;
    font-size: 12px;
  }

  /* Formularios a 1 Columna en Celulares */
  .form-grid-2,
  .form-grid-3,
  .form-grid-4 {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  .erp-input,
  .erp-select,
  .erp-textarea {
    height: 38px;
    font-size: 13.5px;
  }

  .btn-primary,
  .btn-secondary,
  .btn-subtle {
    height: 38px;
    font-size: 13px;
  }

  /* Pantalla de Login en Móvil */
  .login-screen {
    padding: 14px;
  }

  .login-card {
    padding: 28px 20px 24px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(78, 56, 111, 0.12);
  }

  .login-title {
    font-size: 21px;
  }

  /* Barra de Estado en Móvil */
  .erp-statusbar {
    height: 26px;
    min-height: 26px;
    padding: 0 10px;
    font-size: 10px;
  }

  .statusbar-right {
    display: none;
  }

  /* Tablas adaptables con scroll táctil */
  .erp-table-container,
  .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .erp-table {
    min-width: 600px;
  }
}

@media (max-width: 480px) {
  .topbar-title {
    max-width: 130px;
    font-size: 13.5px;
  }

  .module-tiles-grid {
    grid-template-columns: 1fr;
  }
}

