/* ═══════════════════════════════════════════════════════════════
   FACTURAME — BASE STYLES
═══════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg2);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* ── SCROLLBAR ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg3); }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── LAYOUT ──────────────────────────────────────────────── */
#screen-login {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: var(--bg2);
}

#app-shell { display: none; }
#app-shell.active { display: flex; flex-direction: column; min-height: 100vh; }

.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1.5px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px;
  gap: 16px;
  box-shadow: var(--shadow-card);
}

.sidebar {
  position: fixed; top: var(--header-h); left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg);
  border-right: 1.5px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  padding: 12px 0 0;
  transition: transform 0.3s ease, width 0.3s cubic-bezier(0.4,0,0.2,1);
  display: flex; flex-direction: column;
}

.main-content {
  margin-top: var(--header-h);
  margin-left: var(--sidebar-w);
  min-height: calc(100vh - var(--header-h));
  padding: 24px;
  overflow-x: hidden;
  background: var(--bg2);
  transition: margin-left 0.3s cubic-bezier(0.4,0,0.2,1);
}

/* ── SIDEBAR NAV ─────────────────────────────────────────── */
.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text3);
  padding: 16px 20px 6px;
}

.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text2);
  transition: background 0.15s, color 0.15s, padding 0.3s;
  border-left: 3px solid transparent;
  user-select: none;
  white-space: nowrap;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active {
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--primary);
  border-left-color: var(--accent);
  font-weight: 700;
}
[data-store="mit"] .nav-item.active { color: var(--accent); }
.nav-item svg { flex-shrink: 0; width: 18px; height: 18px; }

/* NAV TOOLTIP (visible only when sidebar is collapsed) */
.nav-tooltip {
  display: none;
  position: absolute;
  left: calc(100% + 10px); top: 50%;
  transform: translateY(-50%);
  background: var(--text); color: var(--bg);
  padding: 5px 10px; border-radius: 7px;
  font-size: 12px; font-weight: 600;
  white-space: nowrap; z-index: 400;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}
.nav-tooltip::before {
  content: '';
  position: absolute; right: 100%; top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: var(--text);
}

/* ── SIDEBAR COLLAPSED STATE ──────────────────────────────────── */
body.sidebar-collapsed .sidebar { width: 68px; }
body.sidebar-collapsed .main-content { margin-left: 68px; }

body.sidebar-collapsed .nav-label        { display: none; }
body.sidebar-collapsed .nav-section-title { opacity: 0; height: 0; overflow: hidden; padding: 0; }
body.sidebar-collapsed .nav-item {
  padding: 13px 8px;
  justify-content: center;
  gap: 0;
  border-left: none;
}
body.sidebar-collapsed .nav-item.active {
  border-left: none;
  border-radius: 8px;
  margin: 1px 6px;
}
body.sidebar-collapsed .nav-item:hover .nav-tooltip { display: block; }
body.sidebar-collapsed .store-brand-text { display: none; }
body.sidebar-collapsed .store-brand { justify-content: center; gap: 0; }

/* ── SIDEBAR FOOTER ───────────────────────────────────────────── */
.sidebar-nav-list { flex: 1; }
#sidebar-nav { display: flex; flex-direction: column; flex: 1; }
.sidebar-footer {
  padding: 10px 14px;
  border-top: 1.5px solid var(--border2);
  display: flex; align-items: center; justify-content: flex-end;
  flex-shrink: 0;
  margin-top: auto;
}
body.sidebar-collapsed .sidebar-footer { justify-content: center; padding: 10px 8px; }

/* ── SIDEBAR COLLAPSE BUTTON ──────────────────────────────────── */
.sidebar-collapse-btn {
  background: none; border: none;
  width: 30px; height: 30px; border-radius: 8px;
  cursor: pointer; color: var(--text3);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.sidebar-collapse-btn:hover { background: var(--bg3); color: var(--text); }
body.sidebar-collapsed .sidebar-collapse-btn { transform: rotate(180deg); }

/* ── STORE BRAND ─────────────────────────────────────────── */
.store-brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text);
}
.store-brand img, .store-brand svg {
  height: 36px; width: auto; object-fit: contain;
}
.store-brand-name {
  font-size: 14px; font-weight: 800;
  color: var(--primary); line-height: 1.1;
}
.store-brand-sub { font-size: 10px; color: var(--text3); font-weight: 400; }

.header-spacer { flex: 1; }

.header-btn {
  background: none; border: none;
  width: 38px; height: 38px;
  border-radius: 50%;
  cursor: pointer; color: var(--text2);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.header-btn:hover { background: var(--bg3); color: var(--text); }

/* ── PAGE SYSTEM ─────────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

/* ── CARDS ───────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
}
.card-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text3); margin-bottom: 12px;
}
.card-value {
  font-size: 26px; font-weight: 800;
  color: var(--text); line-height: 1.1;
}
.card-sub { font-size: 12px; color: var(--text3); margin-top: 4px; }
.card-accent { border-top: 3px solid var(--accent); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-icon {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  background: rgba(var(--accent-rgb), 0.15);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); margin-bottom: 12px;
}
[data-store="idealo"] .stat-icon { color: var(--primary); background: rgba(var(--accent-rgb), 0.2); }
[data-store="mit"] .stat-icon { color: var(--accent); background: rgba(var(--accent-rgb), 0.1); }

/* ── SECTION HEADER ──────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.section-title {
  font-size: 20px; font-weight: 800; color: var(--primary);
}
.section-sub { font-size: 13px; color: var(--text3); margin-top: 2px; }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; padding: 9px 18px;
  border-radius: var(--radius-sm); border: none;
  font-size: 13px; font-weight: 700; cursor: pointer;
  transition: transform 0.12s, box-shadow 0.2s, background 0.15s, color 0.15s;
  white-space: nowrap; text-decoration: none; line-height: 1;
}
.btn:active { transform: scale(0.97); }

/* IDEALO primary: navy bg + white text */
[data-store="idealo"] .btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(var(--primary-rgb), 0.25);
}
[data-store="idealo"] .btn-primary:hover {
  background: #2e2e80;
  box-shadow: 0 4px 18px rgba(var(--primary-rgb), 0.35);
}

/* MIT primary: green bg + white text */
[data-store="mit"] .btn-primary {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(var(--accent-rgb), 0.3);
}
[data-store="mit"] .btn-primary:hover {
  background: var(--accent-dark);
  box-shadow: 0 4px 18px rgba(var(--accent-rgb), 0.4);
}

.btn-ghost {
  background: var(--bg3);
  color: var(--text2);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--bg4); color: var(--text); }

.btn-danger  { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

/* Accent highlight button (yellow for IDEALO) */
[data-store="idealo"] .btn-accent {
  background: var(--accent);
  color: var(--primary);
  font-weight: 800;
}

/* ── FORMS ───────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text2); margin-bottom: 6px; letter-spacing: 0.3px;
}
.form-control {
  width: 100%; padding: 10px 14px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}
[data-store="idealo"] .form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1); }
.form-control::placeholder { color: var(--text3); }
.form-control option { background: var(--bg); color: var(--text); }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ── TABLE ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  background: var(--bg2);
  color: var(--text3);
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; padding: 10px 14px; text-align: left;
  border-bottom: 1.5px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border2); transition: background 0.1s; }
tbody tr:hover { background: var(--bg2); }
tbody td { padding: 11px 14px; color: var(--text); vertical-align: middle; }
tbody td.muted { color: var(--text3); font-size: 12.5px; }

/* ── BADGES ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.3px;
}
.badge-success { background: rgba(46,125,50,0.12);  color: #2e7d32; }
.badge-danger  { background: rgba(198,40,40,0.12);  color: #c62828; }
.badge-warning { background: rgba(230,81,0,0.12);   color: #e65100; }
.badge-info    { background: rgba(21,101,192,0.12); color: #1565c0; }
.badge-accent  { background: rgba(var(--accent-rgb), 0.15); color: var(--accent-dark); }

/* ── MODAL ───────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(3px);
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow);
  animation: slideUp 0.25s ease;
}
.modal-lg { max-width: 860px; }
.modal-xl { max-width: 1100px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1.5px solid var(--border2);
  background: var(--bg2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--primary); }
.modal-body { padding: 24px; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 10px; padding: 16px 24px;
  border-top: 1.5px solid var(--border2);
  background: var(--bg2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text3); padding: 4px;
  border-radius: 6px; line-height: 0;
  transition: color 0.15s, background 0.15s;
}
.modal-close:hover { color: var(--danger); background: rgba(198,40,40,0.08); }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── LOGIN SCREEN (FinanzApp style) ──────────────────────────── */
#screen-login {
  background: #080a14 !important;
  position: relative; overflow: hidden; padding: 20px;
}
/* Blob decorativo — arriba izquierda (navy) */
#screen-login::before {
  content: '';
  position: absolute;
  width: min(640px, 90vw); height: min(640px, 90vw);
  background: radial-gradient(circle, rgba(26,26,100,.40) 0%, transparent 68%);
  top: -18%; left: -12%; border-radius: 50%; pointer-events: none;
}
/* Blob decorativo — abajo derecha (dorado FacturaME) */
#screen-login::after {
  content: '';
  position: absolute;
  width: min(440px, 70vw); height: min(440px, 70vw);
  background: radial-gradient(circle, rgba(245,197,24,.10) 0%, transparent 68%);
  bottom: -12%; right: -8%; border-radius: 50%; pointer-events: none;
}

.auth-card {
  background: #0f1020;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 22px;
  padding: clamp(28px, 5vw, 46px);
  width: 100%; max-width: 430px;
  position: relative; z-index: 1;
  box-shadow: 0 8px 48px rgba(0,0,0,.65);
}

/* Logo */
.auth-logo {
  display: flex; align-items: center; gap: 14px;
  justify-content: center; margin-bottom: 6px;
}
.auth-logo-img {
  width: 54px; height: 54px; border-radius: 14px; flex-shrink: 0;
}
.auth-logo-txt {
  font-size: 30px; font-weight: 900;
  color: #eeeef5; letter-spacing: -1.5px; line-height: 1;
}
.auth-logo-txt span { color: #F5C518; }
.auth-sub {
  text-align: center; font-size: 13px; color: #6a6a88;
  margin: 6px 0 28px;
}

/* Campos */
.auth-group { margin-bottom: 16px; }
.auth-label {
  display: block; font-size: 11px; font-weight: 700;
  color: #7878aa; margin-bottom: 7px;
  text-transform: uppercase; letter-spacing: .8px;
}
.auth-input-wrap { position: relative; }
.auth-input {
  width: 100%;
  background: #161829;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 13px 16px;
  color: #eeeef5;
  font-size: 15px; font-family: inherit; outline: none;
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none;
}
.auth-input::placeholder { color: #3a3a55; }
.auth-input:focus {
  border-color: #F5C518;
  box-shadow: 0 0 0 3px rgba(245,197,24,.13);
}
/* Ojo para ver/ocultar contraseña */
.auth-eye {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  color: #555577; cursor: pointer; padding: 4px;
  display: flex; align-items: center; transition: color .15s;
}
.auth-eye:hover { color: #9898bb; }

/* Error */
.auth-error {
  color: #f46f6f; font-size: 12px;
  min-height: 18px; margin-bottom: 12px; text-align: center;
}

/* Recordar sesión */
.auth-remember {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; font-size: 12.5px; color: #6a6a88;
  margin-bottom: 16px; user-select: none;
}
.auth-remember input[type="checkbox"] { display: none; }
.auth-remember-box {
  width: 18px; height: 18px; border-radius: 5px; flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,0.15);
  background: #161829;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, background .15s;
}
.auth-remember input:checked ~ .auth-remember-box {
  background: #F5C518; border-color: #F5C518;
}
.auth-remember-box::after {
  content: ''; width: 5px; height: 9px;
  border: 2px solid transparent; border-top: none; border-left: none;
  transform: rotate(45deg) translateY(-1px);
  transition: border-color .15s;
}
.auth-remember input:checked ~ .auth-remember-box::after {
  border-color: #1A1A4E;
}

/* Botón ingresar */
.auth-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, #1A1A4E 0%, #2d2d88 100%);
  border: none; border-radius: 10px;
  padding: 15px; color: #fff;
  font-size: 15px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  transition: opacity .2s, transform .15s;
  letter-spacing: .2px;
  position: relative; overflow: hidden;
}
.auth-btn:hover  { opacity: .88; }
.auth-btn:active { transform: scale(.97); }

/* Footer */
.auth-footer {
  text-align: center; margin-top: 22px;
  font-size: 11px; color: #35354e;
  letter-spacing: .6px; text-transform: uppercase;
}

/* Legacy (por si hay referencias antiguas) */
.login-card, .login-title, .login-sub, .login-logos,
.login-logo-wrap, .login-divider { display: none; }

/* ── FACTURA PAGE ────────────────────────────────────────── */
.factura-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}
.factura-items-table th,
.factura-items-table td { padding: 8px 10px; }
.factura-items-table input {
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: 6px; color: var(--text);
  padding: 6px 8px; font-size: 13px; width: 100%;
  font-family: inherit;
}
.factura-items-table input:focus {
  outline: none; border-color: var(--accent);
  background: var(--bg);
}
.factura-totals td { padding: 6px 14px; }
.factura-totals tr.total-row td {
  font-size: 17px; font-weight: 800;
  padding-top: 10px;
}
[data-store="idealo"] .factura-totals tr.total-row td { color: var(--primary); }
[data-store="mit"]    .factura-totals tr.total-row td { color: var(--accent); }

/* ── SEARCH BOX ──────────────────────────────────────────── */
.search-wrap { position: relative; }
.search-wrap svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text3); pointer-events: none;
}
.search-wrap input { padding-left: 34px !important; }

/* ── PRODUCT SEARCH DROPDOWN ─────────────────────────────── */
.product-dropdown {
  position: absolute; z-index: 300;
  top: 100%; left: 0; right: 0;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  max-height: 240px; overflow-y: auto;
  margin-top: 4px;
}
.product-dropdown-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; cursor: pointer;
  font-size: 13px; border-bottom: 1px solid var(--border2);
  transition: background 0.1s;
}
.product-dropdown-item:hover { background: var(--bg2); }
.product-dropdown-item:last-child { border-bottom: none; }
.product-dropdown-item .pname  { color: var(--text); font-weight: 600; }
.product-dropdown-item .pcat   { color: var(--text3); font-size: 11px; }
[data-store="idealo"] .product-dropdown-item .pprice { color: var(--primary); font-weight: 800; }
[data-store="mit"]    .product-dropdown-item .pprice { color: var(--accent); font-weight: 800; }

/* ── INVENTORY ───────────────────────────────────────────── */
.stock-low { color: var(--danger) !important; font-weight: 700; }
.stock-ok  { color: var(--success); font-weight: 600; }

.inv-bar-wrap { background: var(--bg3); border-radius: 20px; height: 7px; min-width: 60px; }
.inv-bar      { height: 7px; border-radius: 20px; background: var(--accent); transition: width 0.5s ease; }
.inv-bar.low  { background: var(--danger); }

/* ── DASHBOARD CHART ─────────────────────────────────────── */
.chart-bar-wrap {
  display: flex; align-items: flex-end; gap: 6px;
  height: 120px; padding-top: 8px;
}
.chart-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.chart-bar {
  width: 100%; border-radius: 4px 4px 0 0;
  transition: height 0.5s ease; cursor: default; min-height: 4px;
}
[data-store="idealo"] .chart-bar { background: rgba(var(--primary-rgb), 0.2); }
[data-store="idealo"] .chart-bar:hover { background: rgba(var(--accent-rgb), 0.7); }
[data-store="mit"]    .chart-bar { background: rgba(var(--accent-rgb), 0.2); }
[data-store="mit"]    .chart-bar:hover { background: rgba(var(--accent-rgb), 0.6); }
.chart-bar-label { font-size: 10px; color: var(--text3); }

/* ── TOAST ───────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  min-width: 240px; max-width: 360px;
  padding: 12px 18px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 13px; color: var(--text);
  display: flex; align-items: center; gap: 10px;
  animation: toastIn 0.3s ease;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.info    { border-left: 4px solid var(--accent); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text3); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.3; }
.empty-state h3 { font-size: 15px; color: var(--text2); margin-bottom: 6px; }
.empty-state p  { font-size: 13px; }

/* ── CODE / INVOICE NUMBER ───────────────────────────────── */
code {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg3);
}
[data-store="idealo"] code { color: var(--primary); }
[data-store="mit"]    code { color: var(--accent-dark); }

/* ── PRINT ───────────────────────────────────────────────── */
@media print {
  .sidebar, .app-header, .no-print, .btn { display: none !important; }
  .main-content { margin: 0 !important; padding: 0 !important; }
  body { background: #fff !important; color: #000 !important; font-size: 12px; }
}

/* ── TOGGLE SWITCH ───────────────────────────────────────── */
.toggle-switch {
  position: relative; display: inline-block;
  width: 44px; height: 24px; flex-shrink: 0; cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--bg3); border: 1.5px solid var(--border);
  border-radius: 20px; transition: background .2s, border-color .2s;
}
.toggle-slider::before {
  content: ''; position: absolute;
  height: 16px; width: 16px; left: 3px; bottom: 3px;
  background: var(--text3); border-radius: 50%; transition: transform .2s, background .2s;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--accent); border-color: var(--accent);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px); background: #fff;
}

/* ── ITBIS SELECTOR (factura / cotización) ────────────────── */
.itbis-selector {
  margin: 14px 0 4px;
  padding: 14px;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
}
.itbis-selector-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; color: var(--text3); margin-bottom: 10px;
}
.itbis-selector-opts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.itbis-opt {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
  user-select: none;
}
.itbis-opt input[type="radio"] { display: none; }
.itbis-opt-icon {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg3); color: var(--text3);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; flex-shrink: 0;
  transition: background .15s, color .15s;
}
.itbis-opt-txt {
  font-size: 12.5px; font-weight: 600; color: var(--text2);
  line-height: 1.3; transition: color .15s;
}
.itbis-opt-txt small { font-size: 10px; font-weight: 400; }

/* Active state — Sin ITBIS */
#opt-sin-itbis.itbis-opt-active {
  border-color: var(--danger);
  background: rgba(198,40,40,0.07);
}
#opt-sin-itbis.itbis-opt-active .itbis-opt-icon {
  background: rgba(198,40,40,0.15); color: var(--danger);
}
#opt-sin-itbis.itbis-opt-active .itbis-opt-txt { color: var(--danger); }

/* Active state — Con ITBIS */
#opt-con-itbis.itbis-opt-active {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
}
#opt-con-itbis.itbis-opt-active .itbis-opt-icon {
  background: rgba(var(--accent-rgb), 0.18); color: var(--accent);
}
#opt-con-itbis.itbis-opt-active .itbis-opt-txt { color: var(--accent); font-weight: 800; }

/* Hover */
.itbis-opt:not(.itbis-opt-active):hover {
  background: var(--bg2); border-color: var(--text3);
}

/* ── ITBIS TOGGLE ROW (legacy — kept for cotizaciones) ────── */
.itbis-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  gap: 12px;
}
.itbis-toggle-label { font-size: 13px; font-weight: 700; color: var(--text); }
.itbis-toggle-sub   { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* ── USER AVATAR (small — used in user management table) ──── */
.user-avatar-sm {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(var(--accent-rgb), 0.18);
  color: var(--accent);
  font-size: 13px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}
[data-store="idealo"] .user-avatar-sm {
  background: rgba(var(--primary-rgb), 0.15);
  color: var(--primary);
}

/* ── LOADING PULSE ───────────────────────────────────────── */
.loading-pulse {
  animation: loadPulse 1.4s ease-in-out infinite;
  color: var(--text3);
}
@keyframes loadPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .main-content { margin-left: 0; padding: 16px; }
  .factura-layout { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  /* Reset collapse on mobile — mobile uses overlay instead */
  body.sidebar-collapsed .sidebar { width: var(--sidebar-w); }
  body.sidebar-collapsed .main-content { margin-left: 0; }
  body.sidebar-collapsed .nav-label { display: inline; }
  body.sidebar-collapsed .nav-section-title { opacity: 1; height: auto; overflow: visible; padding: 16px 20px 6px; }
  body.sidebar-collapsed .nav-item { padding: 11px 20px; justify-content: flex-start; gap: 12px; border-left: 3px solid transparent; margin: 0; border-radius: 0; }
  body.sidebar-collapsed .nav-item.active { border-left-color: var(--accent); border-radius: 0; margin: 0; }
  body.sidebar-collapsed .store-brand-text { display: block; }
  body.sidebar-collapsed .store-brand { justify-content: flex-start; gap: 10px; }
  .sidebar-collapse-btn { display: none; }
  /* Modal full-width on tablet */
  .modal { max-width: 100% !important; margin: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-header { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .modal-footer { border-radius: 0; }
}
@media (max-width: 600px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .bulb-option { padding: 7px 10px; font-size: 10px; min-width: 78px; }
  .section-header { flex-direction: column; align-items: flex-start; }
  .section-header .btn { width: 100%; justify-content: center; }
  .app-header { padding: 0 12px; gap: 10px; }
  .main-content { padding: 12px; }
  /* Hide store brand text on very small screens to save space */
  .store-brand-text { display: none; }
  /* Bigger tap targets */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }
  /* Table: make it scrollable with sticky first col hint */
  .table-wrap { border-radius: var(--radius-sm); }
  tbody td, thead th { padding: 9px 10px; font-size: 12.5px; }
  /* Toast full-width bottom */
  #toast-container { bottom: 12px; right: 12px; left: 12px; }
  .toast { min-width: unset; max-width: 100%; }
}
