/* Estilos base — pensados para personas mayores, con diseño moderno. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --primary: #2563eb;
  --primary-text: #ffffff;
  --primary-soft: #eff6ff;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #059669;
  --row-alt: #f9fafb;
  --focus: #3b82f6;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.07), 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 260px;
}

html[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-elevated: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --border: #334155;
  --border-strong: #475569;
  --primary: #60a5fa;
  --primary-text: #0f172a;
  --primary-soft: rgba(96, 165, 250, 0.15);
  --danger: #f87171;
  --warn: #fbbf24;
  --ok: #34d399;
  --row-alt: #1e293b;
  --focus: #60a5fa;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.25), 0 4px 12px rgba(0, 0, 0, 0.18);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 18px;
  line-height: 1.45;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: transparent;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.55rem 1rem;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}
.btn:hover { background: var(--row-alt); box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn-xl {
  min-height: 56px;
  padding: 0.75rem 1.25rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
}
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
html[data-theme="dark"] .btn-primary:hover { background: #3b82f6; border-color: #3b82f6; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover { background: var(--row-alt); }

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

/* ---------- Login ---------- */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.login-title { margin: 0; font-size: 1.8rem; }
.login-label { font-weight: 600; }
.login-input {
  min-height: 56px;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.login-error { color: var(--danger); margin: 0; min-height: 1.4em; }

/* ---------- Layout app ---------- */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.75rem;
  z-index: 50;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding: 0 0.5rem;
}

.sidebar-close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  color: var(--muted);
}
.sidebar-close:hover { background: var(--row-alt); }

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.brand-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
}
.brand-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-height: 48px;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 600;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover {
  background: var(--row-alt);
  color: var(--text);
}
.nav-item.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: inset 3px 0 0 var(--primary);
}

.nav-icon {
  flex: 0 0 auto;
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.nav-item--theme .theme-icon-moon,
html[data-theme="dark"] .nav-item--theme .theme-icon-sun { display: none; }

.nav-item--theme .theme-icon-sun,
html[data-theme="dark"] .nav-item--theme .theme-icon-moon { display: block; }

.nav-item--logout {
  color: var(--danger);
}
.nav-item--logout:hover {
  background: rgba(220, 38, 38, 0.08);
}
html[data-theme="dark"] .nav-item--logout:hover {
  background: rgba(248, 113, 113, 0.12);
}

/* ---------- Overlay ---------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 40;
}

/* ---------- Contenido ---------- */
.content {
  padding: 1.25rem 1.5rem 2rem;
  overflow-x: hidden;
}

.content-header {
  display: none;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow);
}
.sidebar-toggle:hover { background: var(--row-alt); }

.content-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}
.content-spacer { flex: 1; }

/* ---------- Búsqueda + toolbar / filtros ---------- */
.search-bar {
  margin-bottom: 0.75rem;
}
.search-bar .input-xl {
  /* El input ya tiene estilos globales; ajustamos solo la altura para que
     combine con los botones de filtro. */
  min-height: 48px;
}
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.view-title { margin: 0; font-size: 1.3rem; }
.filter-group {
  display: flex;
  gap: 0.35rem;
  background: var(--surface);
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.filter-btn {
  min-height: 40px;
  padding: 0.45rem 0.9rem;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  font-weight: 600;
  color: var(--text);
}
.filter-btn:hover { background: var(--row-alt); }
.filter-btn.is-active {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
}
.rate-display { color: var(--muted); }
.rate-display strong { color: var(--text); }

/* ---------- Tabla tipo Excel ---------- */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  background: var(--surface);
  box-shadow: var(--shadow);
  max-height: 70vh;
}
.grid {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 880px;
}
.grid th, .grid td {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0;
  text-align: left;
  vertical-align: middle;
}
.grid th {
  background: var(--row-alt);
  font-weight: 700;
  padding: 0.65rem 0.85rem;
  position: sticky;
  top: 0;
  z-index: 1;
}
.grid tbody tr:hover td { background: var(--primary-soft); }
.grid tr:nth-child(even) td { background: var(--row-alt); }
.grid tr:nth-child(even):hover td { background: var(--primary-soft); }
html[data-theme="dark"] .grid tbody tr:hover td,
html[data-theme="dark"] .grid tr:nth-child(even):hover td { background: rgba(96, 165, 250, 0.12); }
.grid tr.row-new td { background: #fffbe6; }
html[data-theme="dark"] .grid tr.row-new td { background: rgba(251, 191, 36, 0.12); }
html[data-theme="dark"] .grid tr.row-new:hover td { background: rgba(251, 191, 36, 0.18); }
.grid tr.row-out td { color: var(--muted); text-decoration: line-through; }

.grid td.cell-edit {
  padding: 0.35rem;
}
.grid td.cell-edit > .cell-input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0.55rem 0.8rem;
  font-size: 1rem;
  color: var(--text);
  outline: none;
  transition: background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.grid td.cell-edit > .cell-input:hover {
  border-color: var(--border-strong);
}
.grid td.cell-edit > .cell-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
html[data-theme="dark"] .grid td.cell-edit > .cell-input {
  background: var(--surface-elevated);
  border-color: var(--border-strong);
}
html[data-theme="dark"] .grid td.cell-edit > .cell-input:focus {
  background: var(--surface);
}
.grid td.cell-num > .cell-input { text-align: right; }
.grid td.cell-name > .cell-input { text-align: left; }
.grid td.cell-check { text-align: center; }
.grid td.cell-actions { text-align: center; }

.col-name { width: 28%; }
.col-num  { width: 10%; }
.col-check { width: 7%; }
.col-actions { width: 15%; }

.cell-price-bs { padding: 0.6rem 0.85rem; font-weight: 600; }

.hint {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0.7rem 0 0;
}
.hint kbd {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 0.4rem;
  font-family: ui-monospace, Menlo, monospace;
}

/* ---------- Inputs grandes ---------- */
.input-xl {
  width: 100%;
  min-height: 52px;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 1.05rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input-xl:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  outline: none;
}

.field { display: flex; flex-direction: column; gap: 0.45rem; }
.field-label { font-weight: 600; color: var(--muted); }

/* ---------- Vender ---------- */
.sell-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 800px) {
  .sell-grid { grid-template-columns: 1fr; }
}
.sell-left, .sell-right {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.results-list, .cart-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 50vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.results-list li, .cart-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  min-height: 48px;
}
.results-list li:last-child, .cart-list li:last-child { border-bottom: 0; }
.results-list .name { font-weight: 600; }
.results-list .meta { color: var(--muted); font-size: 0.95rem; }
.results-list .add-btn { min-height: 40px; padding: 0.3rem 0.8rem; }

.cart-title { margin: 0; font-size: 1.2rem; }
.cart-list .qty {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.cart-list .qty button {
  min-width: 36px;
  min-height: 36px;
  border: 1px solid var(--border-strong);
  background: var(--surface-elevated);
  color: var(--text);
  border-radius: 6px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.cart-list .qty button:hover {
  background: var(--surface);
  border-color: var(--primary);
}
.cart-list .qty input {
  width: 64px;
  text-align: center;
  min-height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 1rem;
  background: var(--surface-elevated);
  color: var(--text);
}
.totals { display: flex; gap: 1.5rem; font-size: 1.1rem; }
.pay-block {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border-top: 1px dashed var(--border);
  padding-top: 0.75rem;
}
.change-display { font-size: 1.3rem; }
.change-display strong { color: var(--ok); }
.change-display.is-negative strong { color: var(--danger); }

/* ---------- Configuración ---------- */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.card-title { margin: 0; font-size: 1.25rem; font-weight: 700; }

/* ---------- Copia de seguridad (settings) ---------- */
.backup-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.backup-actions .btn { flex: 1 1 auto; min-width: 0; }
.backup-file-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}
.backup-file-info {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.75rem;
  background: var(--surface-elevated);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
}

/* ---------- Factura inline ---------- */
.invoice-area {
  margin-top: 1rem;
}
.invoice-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.invoice-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.invoice-header h2 { margin: 0; }
.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0 1rem;
}
.invoice-table th, .invoice-table td {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.invoice-table .totals-row td { font-weight: 700; border-top: 1px solid var(--text); border-bottom: 0; }
.invoice-actions {
  display: flex;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

/* ---------- Carga masiva ---------- */
.bulk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  align-items: start;
}
.bulk-grid > .bulk-result { grid-column: 1 / -1; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 180px;
  padding: 1.25rem;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--row-alt);
  color: var(--text);
  cursor: pointer;
  text-align: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.dropzone:hover { background: var(--bg); }
.dropzone.is-over {
  background: var(--primary-soft);
  border-color: var(--primary);
}
.dropzone-title {
  font-size: 1.2rem;
  font-weight: 700;
}
.dropzone-sub {
  color: var(--muted);
  font-size: 1rem;
}
.dropzone-formats {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.bulk-file-info {
  font-size: 1.05rem;
  padding: 0.6rem 0.8rem;
  background: var(--primary-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.bulk-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.bulk-actions .btn-xl { flex: 1 1 220px; }

.bulk-result .bulk-counters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.bulk-result .counter {
  background: var(--row-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  text-align: center;
}
.bulk-result .counter-label {
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 600;
}
.bulk-result .counter-value {
  font-size: 2rem;
  font-weight: 800;
  margin-top: 0.2rem;
}
.bulk-result .counter-ok    .counter-value { color: var(--ok); }
.bulk-result .counter-info  .counter-value { color: var(--primary); }
.bulk-result .counter-err   .counter-value { color: var(--danger); }
.bulk-result .counter-total .counter-value { color: var(--text); }

.card-subtitle {
  margin: 0.5rem 0 0.4rem;
  font-size: 1rem;
  color: var(--muted);
}

.bulk-howto {
  margin: 0;
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 1rem;
}
.bulk-howto code {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  padding: 0 0.3rem;
  border-radius: 4px;
  font-size: 0.95rem;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 0.7rem 1.1rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 100;
  max-width: 80vw;
}

/* ---------- Paginación (inventario) ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}
/* El atributo HTML `hidden` debe ganar a `display: flex` de la clase. */
.pagination[hidden] { display: none; }
.pagination .page-info {
  color: var(--muted);
  font-size: 0.95rem;
}
.pagination .page-info strong {
  color: var(--text);
  font-weight: 700;
}
.pagination-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.btn-pag {
  min-height: 40px;
  min-width: 100px;
  padding: 0.4rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.btn-pag:hover:not(:disabled) {
  background: var(--surface-elevated);
  border-color: var(--primary);
}
.btn-pag:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  html { font-size: 17px; }

  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
    border-right: 0;
  }
  .sidebar.is-open {
    transform: translateX(0);
  }
  .sidebar-close {
    display: inline-flex;
  }
  .sidebar-overlay {
    display: block;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .sidebar-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  .content {
    padding: 0.75rem;
  }
  .content-header {
    display: flex;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .filter-group { justify-content: stretch; }
  .filter-btn { flex: 1; }
  .rate-display { text-align: center; }

  .pagination {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  .pagination .page-info { text-align: center; }
  .pagination-nav {
    justify-content: space-between;
  }
  .btn-pag { flex: 1; min-width: 0; }

  .table-wrap {
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    max-height: none;
    overflow: visible;
  }
  .grid,
  .grid thead,
  .grid tbody,
  .grid th,
  .grid td,
  .grid tr {
    display: block;
    width: 100%;
    min-width: 0;
  }
  .grid thead { display: none; }
  .grid tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    box-shadow: var(--shadow);
  }
  .grid td {
    border: 0;
    padding: 0.4rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
  }
  .grid td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--muted);
    flex: 0 0 auto;
  }
  .grid td.cell-edit > .cell-input,
  .grid td .cell-input {
    flex: 1 1 auto;
    text-align: right;
    padding: 0.5rem;
    min-height: 44px;
    background: var(--surface-elevated);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    color: var(--text);
  }
  .grid td.cell-edit > .cell-input:focus,
  .grid td .cell-input:focus {
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-soft);
  }
  .grid td.cell-check {
    justify-content: flex-start;
    gap: 1rem;
  }
  .grid td.cell-check::before { content: attr(data-label); }
  .grid td.cell-actions {
    justify-content: flex-start;
    padding-top: 0.6rem;
    border-top: 1px dashed var(--border);
  }
  .grid td.cell-actions::before { display: none; }
  .grid td.cell-actions .btn { flex: 1; min-height: 44px; }
  .grid td.cell-price-bs {
    font-size: 1.1rem;
    font-weight: 700;
  }
  .grid tr.row-new td { padding: 0.5rem 0; }
  .grid tr.row-new td::before { content: attr(data-label); }

  .sell-grid { gap: 0.75rem; }
  .sell-left, .sell-right { padding: 0.75rem; gap: 0.6rem; }
  .results-list li, .cart-list li {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    min-height: 56px;
  }
  .results-list .add-btn,
  .cart-list .qty { align-self: stretch; justify-content: center; }
  .cart-list .qty input { flex: 1; max-width: 80px; }
  .totals {
    flex-direction: column;
    gap: 0.4rem;
  }

  .invoice-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  .invoice-header h2 { font-size: 1.3rem; }
  .invoice-table,
  .invoice-table thead,
  .invoice-table tbody,
  .invoice-table th,
  .invoice-table td,
  .invoice-table tr { display: block; width: 100%; }
  .invoice-table thead { display: none; }
  .invoice-table tr {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
  }
  .invoice-table td { border: 0; padding: 0; }
  .invoice-table td:nth-child(1) { width: 100%; font-weight: 600; }
  .invoice-table td:nth-child(2),
  .invoice-table td:nth-child(3),
  .invoice-table td:nth-child(4) { flex: 1; text-align: center !important; }
  .invoice-table .totals-row { justify-content: flex-end; }
  .invoice-table .totals-row td { text-align: right !important; }

  .bulk-grid,
  .settings-grid { grid-template-columns: 1fr; }
  .bulk-actions { flex-direction: column; }
  .bulk-actions .btn-xl { width: 100%; }
  .dropzone { min-height: 160px; }

  .login-card { padding: 1.5rem; }
  .card { padding: 0.875rem; }
}

@media (max-width: 400px) {
  html { font-size: 16px; }
  .brand-title { font-size: 1.15rem; }
  .content-title { font-size: 1.3rem; }
  .btn-xl { min-height: 52px; padding: 0.65rem 1rem; }
}

/* ---------- Impresión (factura / lista) ---------- */
@media print {
  body { background: #fff; color: #000; }
  .no-print, .sidebar, .sidebar-toggle, .sidebar-overlay, .content-header, .toolbar, .invoice-actions, .toast { display: none !important; }
  .app-layout { grid-template-columns: 1fr; }
  .content { padding: 0; }
  .invoice-area { position: static; background: #fff; padding: 0; }
  .invoice-card { box-shadow: none; border: 0; }
  .table-wrap { box-shadow: none; border: 0; max-height: none; overflow: visible; }
  .grid { min-width: 0; }
  .grid th { background: #fff; }
}
