* { box-sizing: border-box; }

:root {
  --bg: #f4f5f7;
  --card: #fff;
  --border: #dde1e6;
  --text: #1f2933;
  --muted: #6b7785;
  --primary: #d9480f;
  --primary-dark: #b23a0b;
  --ok: #2b8a3e;
  --error: #c92a2a;
  /* Superficies y estados (modo claro). */
  --surface-2: #f8f9fa;
  --surface-3: #f1f3f5;
  --accent-soft: #fff4e6;
  --ok-soft: #ebfbee;
  --error-soft: #fff5f5;
  --error-border: #f1aeb5;
  --danger-strong: #a61e4d;
  --input-bg: #fff;
  --track: #ced4da;
  --topbar: #222;
  --on-text: #fff;
  --on-primary: #fff;
  --shadow: rgba(0,0,0,.12);
  --tip-bg: #1f2933;
  --tip-text: #fff;
  color-scheme: light;
}

/* Modo oscuro (theme.js): paleta de alto contraste. */
:root[data-theme="dark"] {
  --bg: #0f1418;
  --card: #1a2128;
  --border: #33404c;
  --text: #edf1f5;
  --muted: #a3b0bd;
  --primary: #ff7a3d;
  --primary-dark: #ff9b6b;
  --ok: #5fd27a;
  --error: #ff7070;
  --surface-2: #151b21;
  --surface-3: #252f39;
  --accent-soft: #3b2516;
  --ok-soft: #163222;
  --error-soft: #3d1b1f;
  --error-border: #7c3139;
  --danger-strong: #ff9fbd;
  --input-bg: #11171c;
  --track: #4b5866;
  --topbar: #090c0f;
  --on-text: #0f1418;
  --on-primary: #10151a;
  --shadow: rgba(0,0,0,.5);
  --tip-bg: #edf1f5;
  --tip-text: #0f1418;
  color-scheme: dark;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 20px;
  background: var(--topbar);
  color: #fff;
}
.topbar h1 { margin: 0; font-size: 1.2rem; white-space: nowrap; }
.topbar h1 span { color: var(--primary); }
.search { flex: 1; display: flex; align-items: center; gap: 12px; }
.search input { flex: 1; max-width: 640px; }
.search .muted { color: #aaa; }

input[type="search"], input[type="number"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
}

.layout { flex: 1; display: flex; min-height: 0; }

.catalog { flex: 1; overflow-y: auto; padding: 16px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}
.product {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  transition: box-shadow .15s, border-color .15s;
}
.product:hover, .product:focus-within { border-color: var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.product .add {
  margin-top: 8px;
  padding: 8px;
  font: inherit;
  font-weight: 600;
  color: var(--on-primary);
  background: var(--primary);
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.product .add:hover { background: var(--primary-dark); }
.product img { width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--surface-2); border-radius: 4px; }
.product .name { font-size: 0.85rem; margin: 6px 0 4px; line-height: 1.25; flex: 1; }
.product .code { font-size: 0.75rem; color: var(--muted); }
.product .row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; }
.product .price { font-weight: 600; }
.product .stock { font-size: 0.75rem; color: var(--muted); }
.product .stock.out { color: var(--error); }

.cart {
  width: 380px;
  background: var(--card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px;
  min-height: 0;
}
.cart h2 { font-size: 1rem; margin: 16px 0 8px; }

.customer label { font-size: 0.8rem; color: var(--muted); display: block; margin-bottom: 4px; }
.customer-picker { position: relative; }
.customer-picker input { width: 100%; }
.dropdown {
  position: absolute;
  z-index: 10;
  top: 100%;
  left: 0;
  right: 0;
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 260px;
  overflow-y: auto;
  box-shadow: 0 4px 12px var(--shadow);
}
.dropdown li { padding: 8px 10px; cursor: pointer; font-size: 0.9rem; }
.dropdown li:hover, .dropdown li.active { background: var(--accent-soft); }
.dropdown li small { display: block; color: var(--muted); }
.customer-selected {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  padding: 6px 10px;
  background: var(--accent-soft);
  border-radius: 6px;
  font-size: 0.9rem;
}

.cart-items { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; min-height: 0; }
.cart-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.cart-item .name { font-size: 0.85rem; }
.cart-item .subtotal { font-weight: 600; text-align: right; }
.cart-item .controls { display: flex; align-items: center; gap: 4px; }
.cart-item .controls input { width: 70px; padding: 4px 6px; text-align: right; }
.cart-item .controls .unit { font-size: 0.8rem; color: var(--muted); margin-left: 4px; }
.qty-btn {
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
}
.remove { justify-self: end; }

.cart-footer { border-top: 2px solid var(--border); padding-top: 12px; }
.total { display: flex; justify-content: space-between; font-size: 1.3rem; }
.subtotal-row, .rounding-row { display: flex; justify-content: space-between; align-items: center; font-size: .95rem; margin-bottom: 6px; }
.rounding-controls { display: flex; align-items: center; gap: 4px; }
.rounding-controls input { width: 96px; padding: 4px 6px; text-align: right; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.rounding-controls input.invalid { border-color: var(--error); background: var(--error-soft); }
.qty-btn:disabled { opacity: .4; cursor: not-allowed; }
.qty-btn.auto-btn { width: auto; padding: 0 6px; font-size: .75rem; }
.qty-btn.auto-btn.active { background: var(--border); font-weight: 600; }
.rounding-hint { color: var(--error); margin: 0 0 6px; }
.small { font-size: 0.75rem; margin: 4px 0 12px; }
.muted { color: var(--muted); }

button.primary {
  width: 100%;
  padding: 14px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--on-primary);
  background: var(--primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
button.primary:hover:not(:disabled) { background: var(--primary-dark); }
button.primary:disabled { opacity: .5; cursor: not-allowed; }
button.link { background: none; border: none; color: var(--primary); cursor: pointer; padding: 0; font-size: 0.8rem; }

.message { margin-top: 12px; padding: 10px; border-radius: 6px; font-size: 0.9rem; }
.message.ok { background: var(--ok-soft); color: var(--ok); }
.message.error { background: var(--error-soft); color: var(--error); }
.message strong { font-size: 1.1rem; }

.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 40px 0; }

/* ------------------------------------------------------------------ barra superior: enlaces */

.topbar-link {
  color: #fff;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 6px;
  padding: 7px 12px;
  font: inherit;
  font-size: .9rem;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.topbar-link:hover { background: rgba(255,255,255,.2); }
.topbar-actions { display: flex; gap: 8px; margin-left: auto; }

/* ------------------------------------------------------------------ panel de administración */

body.admin .topbar { flex-wrap: wrap; }
.admin-nav { display: flex; gap: 4px; }
.admin-nav button, .admin-nav .tab-link {
  font: inherit; color: #ccc; background: none; border: none;
  padding: 8px 14px; border-radius: 6px; cursor: pointer; text-decoration: none;
}
.admin-nav button:hover, .admin-nav .tab-link:hover { color: #fff; background: rgba(255,255,255,.08); }
.admin-nav button[aria-current="page"] { color: var(--on-primary); background: var(--primary); }
.admin-main { flex: 1; overflow-y: auto; padding: 20px; }
.admin-main h2 { margin: 0; font-size: 1.25rem; }
.admin-main h3 { font-size: 1rem; margin: 24px 0 10px; }
.admin-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.admin-toolbar h2 { margin-right: auto; }
.admin-toolbar label { display: flex; align-items: center; gap: 6px; font-size: .9rem; }
input[type="date"], input[type="password"], input[type="text"], input[type="email"], select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font: inherit; font-size: .95rem; background: var(--input-bg);
}
button.small-btn { width: auto; padding: 8px 14px; font-size: .9rem; }

.login-card {
  max-width: 360px; margin: 60px auto; padding: 24px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
}
.login-card form { display: grid; gap: 10px; margin-top: 16px; }
.login-card label { font-size: .85rem; color: var(--muted); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.stat-card h3 { margin: 0 0 6px; font-size: .85rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat-value { display: block; font-size: 1.6rem; margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.stat-card p { margin: 2px 0; font-size: .85rem; }
.pay-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.pay-card {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--muted);
  border-radius: 8px; padding: 12px 14px;
}
.pay-card strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.pay-cash { border-left-color: var(--ok); }
.pay-card.pay-total { border-left-color: var(--text); background: var(--surface-2); }
.pay-card span { font-size: .85rem; color: var(--muted); }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.sales-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.sales-table th, .sales-table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.sales-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--surface-2); }
.sales-table td.num, .sales-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.sales-table tbody tr:hover { background: var(--surface-2); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-3); }
.pill.state-sale, .pill.state-paid, .pill.state-done, .pill.state-invoiced { background: var(--ok-soft); color: var(--ok); }
.pill.state-draft, .pill.state-sent { background: var(--accent-soft); color: var(--primary-dark); }
.pill.state-cancel { background: var(--error-soft); color: var(--error); }

.settings-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; margin-top: 16px; }
.settings-card h3 { margin: 0 0 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 16px; }
.form-grid > label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
.form-grid > label.invalid select { border-color: var(--error); }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid fieldset { border: none; margin: 0; padding: 0; font-size: .9rem; }
.form-grid fieldset legend { font-size: .85rem; color: var(--muted); margin-bottom: 6px; padding: 0; }
.form-grid fieldset.inline label { margin-right: 14px; }
.form-grid fieldset.checks label { display: block; margin: 3px 0; }
.arca-status p { margin: 8px 0; }
.arca-status .issues { margin: 4px 0 0; padding-left: 20px; color: var(--error); font-size: .9rem; }
.fiscal-data { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 16px 0 0; font-size: .9rem; }
.fiscal-data dt { color: var(--muted); }
.fiscal-data dd { margin: 0; font-weight: 600; }
.settings-actions { display: flex; align-items: center; gap: 16px; margin: 16px 0 40px; }
.settings-actions button.primary { width: auto; padding: 12px 24px; }
.settings-actions .message { margin: 0; }

/* ------------------------------------------------------------------ factura ARCA */

.invoice-box { margin-bottom: 12px; }
.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; min-height: 36px; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-track {
  flex: none;
  width: 42px; height: 24px;
  border-radius: 999px;
  background: var(--track);
  position: relative;
  transition: background .15s;
}
.toggle-track::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
  transition: transform .15s;
}
.toggle input:checked + .toggle-track { background: var(--primary); }
.toggle input:checked + .toggle-track::after { transform: translateX(18px); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--primary); outline-offset: 2px; }
.toggle input:disabled ~ * { opacity: .5; cursor: not-allowed; }
.invoice-options { margin-top: 8px; }
.segmented { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented label { flex: 1; cursor: pointer; }
.segmented label[hidden] { display: none; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented span { display: block; padding: 10px 6px; text-align: center; font-weight: 600; }
.segmented label + label { border-left: 1px solid var(--border); }
.segmented input:checked + span { background: var(--text); color: var(--on-text); }
.segmented input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: -2px; }
.segmented.payment { margin-top: 6px; }
.segmented.payment span { font-weight: 500; padding: 8px 4px; font-size: .9rem; }
.invoice-hint { margin: 6px 0 0; }
.invoice-hint.warn { color: var(--danger-strong); font-weight: 600; }

/* ------------------------------------------------------------------ modales */

.modal {
  border: none;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  color: var(--text);
  background: var(--card);
}
.modal::backdrop { background: rgba(0,0,0,.45); }
.modal h2 { margin: 0; font-size: 1.2rem; }
.modal-icon {
  flex: none;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 1.6rem;
  line-height: 48px;
  text-align: center;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.close {
  width: 44px; height: 44px;
  border: none; border-radius: 50%;
  background: var(--surface-3);
  font-size: 1.6rem; line-height: 1;
  cursor: pointer;
}
button.secondary {
  width: 100%;
  padding: 12px;
  font: inherit;
  font-weight: 600;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

/* Selector de variante (táctil: objetivos de 44px como mínimo) */
.variant-modal {
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
}
.variant-modal[open] { display: flex; flex-direction: column; }
.variant-modal .modal-header { padding: 16px 20px 0; }
.variant-body { overflow-y: auto; padding: 4px 20px 16px; flex: 1; min-height: 120px; }
.attribute { border: none; margin: 0 0 16px; padding: 0; }
.attribute legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px;
  min-width: 56px;
  padding: 6px 14px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
}
.chip small { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.chip:hover { border-color: var(--primary); }
.chip.active { border-color: var(--primary); background: var(--accent-soft); font-weight: 600; }
.chip.active small { color: var(--primary-dark); }
.chip.unavailable:not(.active) { opacity: .45; border-style: dashed; }
.chip:disabled { opacity: .4; cursor: not-allowed; }
.swatch { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0,0,0,.2); }
.variant-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 12px 12px;
}
.variant-summary { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.variant-summary .variant-name { font-weight: 600; }
.variant-summary strong { font-size: 1.4rem; }
.variant-footer button.primary { width: auto; padding: 14px 22px; }

.badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--primary-dark);
  font-weight: 600;
}

/* Venta registrada */
.success-modal { width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
.success-modal[open] { display: flex; flex-direction: column; gap: 16px; }
.success-head { display: flex; align-items: center; gap: 14px; }
.success-head p { margin: 2px 0 0; }
.order-number { font-size: 1.3rem; color: var(--text); letter-spacing: .02em; }
.ticket-preview {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px 0;
  background: var(--surface-3);
  border-radius: 8px;
}
.ticket-actions { display: grid; gap: 10px; }
.ticket-actions form { margin: 0; }
button.primary.print { font-size: 1.15rem; padding: 16px; }
.paper { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.paper button {
  flex: 1; padding: 8px;
  font: inherit; background: var(--card); color: var(--text);
  border: none; cursor: pointer;
}
.paper button + button { border-left: 1px solid var(--border); }
.paper button[aria-pressed="true"] { background: var(--text); color: var(--on-text); font-weight: 600; }

/* ------------------------------------------------------------------ ticket térmico
   Ancho imprimible: 72 mm en papel de 80 mm y 48 mm en papel de 58 mm.
   Solo negro puro: los cabezales térmicos no imprimen grises. */

.ticket {
  margin: 0 auto;
  padding: 3mm 0;
  background: #fff;
  color: #000;
  font-family: "DejaVu Sans Mono", "Liberation Mono", "Courier New", monospace;
  line-height: 1.3;
  word-break: break-word;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.ticket-80 { width: 72mm; font-size: 12px; }
.ticket-58 { width: 48mm; font-size: 10px; }
.ticket-preview .ticket { padding-left: 2mm; padding-right: 2mm; box-sizing: content-box; }
.ticket hr { border: none; border-top: 1px dashed #000; margin: 2mm 0; }
.ticket .t-center { text-align: center; }
.ticket .t-company { font-size: 1.35em; font-weight: 700; margin-bottom: 1mm; }
.ticket .t-title { font-weight: 700; font-size: 1.15em; margin-bottom: 1mm; }
.ticket .t-row { display: flex; justify-content: space-between; gap: 2mm; }
/* El rótulo no se comprime (antes un valor largo lo partía letra por letra); el valor ocupa el resto y parte por palabras. */
.ticket .t-row > span:first-child { flex: 0 0 auto; max-width: 60%; }
.ticket .t-row > span:last-child { flex: 1 1 auto; min-width: 0; text-align: right; white-space: normal; overflow-wrap: anywhere; }
.ticket .t-client { display: block; width: 100%; margin: .5mm 0; }
.ticket .t-client-label { display: block; font-weight: 700; }
.ticket .t-client-name { display: block; width: 100%; overflow-wrap: anywhere; }
.ticket .t-item { margin-bottom: 1.5mm; }
.ticket .t-item .t-row { padding-left: 2mm; }
.ticket .t-total { font-size: 1.3em; font-weight: 700; }
.ticket .t-strong { font-weight: 700; }
.ticket .t-small { font-size: .9em; margin-bottom: 1mm; }
.ticket .t-reprint { text-align: center; font-weight: 700; font-size: 1.05em; letter-spacing: .04em; border: 1.5px dashed currentColor; padding: 1mm; margin-bottom: 2mm; }
.ticket .t-letter { font-size: 1.5em; margin-bottom: 0; }
/* QR de ARCA: ≥ 30 mm para lectura con cámara; pixelado nítido en cabezal térmico. */
.ticket .t-qr { display: block; margin: 3mm auto 2mm; width: 34mm; height: 34mm; image-rendering: pixelated; }
.ticket-58 .t-qr { width: 30mm; height: 30mm; }
.ticket .t-qr-web { width: 24mm; height: 24mm; margin: 3mm auto 1mm; }
.ticket-58 .t-qr-web { width: 22mm; height: 22mm; }

#print-root { display: none; }

@media print {
  /* Solo se imprime la copia del ticket: el resto de la app (y los <dialog>) se ocultan. */
  html, body { height: auto; background: #fff; margin: 0; padding: 0; display: block; }
  body > :not(#print-root) { display: none !important; }
  #print-root { display: block; }
  #print-root .ticket { box-shadow: none; padding: 2mm 0; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .variant-footer { flex-direction: column; align-items: stretch; }
  .variant-footer button.primary { width: 100%; }
  .cart { width: 100%; border-left: none; border-top: 1px solid var(--border); }
}

/* ---------------------------------------------------------------- /admin/parametros */
.admin-nav .nav-link { color: #ced4da; text-decoration: none; padding: 8px 12px; border-radius: 6px; font-size: .95rem; }
.admin-nav .nav-link:hover { color: #fff; background: rgba(255,255,255,.08); }
.params-split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.params-split .ticket-sample { position: sticky; top: 0; }
.ticket-sample .ticket-preview { display: flex; justify-content: center; }
@media (max-width: 900px) { .params-split { grid-template-columns: 1fr; } .params-split .ticket-sample { position: static; } }
.logo-row { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.logo-box { width: 140px; height: 90px; border: 1px dashed var(--border); border-radius: 8px; display: flex; align-items: center; justify-content: center; background: #fff; }
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.rounding-example { margin: 0; font-size: .9rem; }
.warn, .fiscal-data dd.warn { color: var(--error); font-weight: 600; }
.ticket .t-logo { display: block; max-width: 60%; max-height: 22mm; margin: 0 auto 4px; object-fit: contain; filter: grayscale(1); }
.logo-row .small-btn { width: auto; display: block; margin-top: 8px; }

/* ---------------------------------------------------------------- /admin/stock y /admin/comercial */
.nav-badge { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--error); color: #fff; font-size: .75rem; line-height: 18px; text-align: center; }
.admin-toolbar input[type="search"] { min-width: 260px; flex: 1; max-width: 420px; }
.sales-table td.wrap { white-space: normal; min-width: 180px; }
.sales-table td.small-cell { font-size: .8rem; color: var(--muted); max-width: 260px; }
.sales-table td.warn { color: var(--error); font-weight: 600; }
.sales-table td.strong { font-weight: 700; }
.sales-table td.in { color: var(--ok); font-weight: 600; }
.sales-table td.out { color: var(--error); font-weight: 600; }
.sales-table td.actions { display: flex; gap: 10px; align-items: center; }
.sales-table .qty-input { width: 100px; padding: 6px 8px; text-align: right; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.block { display: block; }
.form-modal { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
.wide-modal { width: min(820px, calc(100vw - 32px)); }
.pm-summary { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-bottom: 16px; padding: 12px 14px; background: var(--surface-2); border-radius: 8px; }
.pm-summary > div { display: flex; flex-direction: column; }
.pm-summary .small { margin: 0; }
.pm-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.pm-actions button { width: auto; padding: 10px 18px; }
.form-modal .form-grid > label input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.form-grid.single { grid-template-columns: 1fr; margin-top: 12px; }
.form-grid.single fieldset legend { margin-bottom: 6px; }
.mov-type { margin-bottom: 8px; }
.mov-table { margin-top: 12px; }
.picker-label .customer-picker { display: block; }
.picker-label input, .kardex-picker input { width: 100%; }
.kardex-picker { min-width: 320px; flex: 1; max-width: 480px; }
.stat-value.small-value { font-size: 1.1rem; }
.stat-card.debt .stat-value { color: var(--error); }
.acc-split { grid-template-columns: minmax(0, 1fr) 340px; margin-top: 8px; }
.receipt-card { position: sticky; top: 0; }
.receipt-card button.primary { margin-top: 8px; }
.qm-validity { grid-template-columns: 220px auto; align-items: end; margin: 16px 0; }
.qm-validity button { justify-self: start; }
.convert-box { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: grid; gap: 10px; }
.convert-box legend { font-weight: 600; padding: 0 6px; }
#qm-invoice-options { display: grid; gap: 6px; }
#qm-invoice-options[hidden] { display: none; }
.check-line { display: flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--error); font-weight: 600; }
button.secondary.danger { color: var(--error); border-color: var(--error-border); }
.nt-total { font-weight: 700; margin: 12px 0; }
.nt-lines { margin: 12px 0; }
.product .location { color: var(--primary-dark); font-weight: 600; }
.account-toggle { margin-top: 10px; }
#tab-notes .message { margin: 0 0 12px; }
@media (max-width: 900px) { .acc-split, .qm-validity { grid-template-columns: 1fr; } .receipt-card { position: static; } }
button.secondary.small-btn { width: auto; }
.form-grid > label.toggle { flex-direction: row; color: var(--text); font-size: .9rem; }
.acc-split .sales-table td, .acc-split .sales-table th { white-space: normal; }
/* El atributo hidden gana sobre los display de los componentes. */
.form-grid > [hidden], .nav-badge[hidden], .sales-table [hidden] { display: none; }

/* ---------------------------------------------------------------- menú principal (/dashboard) */
.home-link { font-weight: 600; }
.dash-brand { display: flex; align-items: center; gap: 12px; }
.dash-brand img { height: 34px; max-width: 160px; object-fit: contain; background: #fff; border-radius: 6px; padding: 3px 6px; }
.arca-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; font-size: .85rem; background: rgba(255,255,255,.08); color: #e9ecef; }
.arca-pill .dot { width: 9px; height: 9px; border-radius: 50%; background: #adb5bd; flex: none; }
.arca-pill.arca-prod .dot { background: #40c057; }
.arca-pill.arca-test .dot { background: #4dabf7; }
.arca-pill.arca-blocked .dot { background: #fab005; }
.arca-pill.arca-off .dot { background: #fa5252; }
.arca-pill small { color: #ffd43b; }
.role-chip { align-self: center; padding: 4px 10px; border-radius: 999px; background: var(--primary); color: var(--on-primary); font-size: .8rem; font-weight: 700; }
.dash-main { max-width: 1280px; width: 100%; margin: 0 auto; }
.dash-clock { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
@media (max-width: 700px) { .dash-clock { margin-left: 0; white-space: normal; } }
.kpi-grid { margin-bottom: 8px; }
.kpi.tone-warn { border-left: 4px solid #f08c00; }
.kpi.tone-warn .stat-value { color: #e8590c; }
.kpi.tone-ok { border-left: 4px solid var(--ok); }
.dash-section { margin-top: 28px; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.module-card {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 16px; min-height: 132px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); text-decoration: none;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
a.module-card:hover, a.module-card:focus-visible { border-color: var(--primary); box-shadow: 0 4px 14px rgba(0,0,0,.08); transform: translateY(-1px); outline: none; }
.module-card.soon { opacity: .6; cursor: default; }
.module-icon { flex: none; width: 46px; height: 46px; border-radius: 12px; background: var(--accent-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; }
.module-card.soon .module-icon { background: var(--surface-3); color: var(--muted); }
.module-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.module-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.module-title { font-weight: 700; font-size: 1.02rem; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.module-desc { font-size: .88rem; color: var(--muted); }
.module-features { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.module-features span { font-size: .72rem; padding: 2px 7px; border-radius: 999px; background: var(--surface-3); color: var(--text); }
@media (max-width: 700px) { .dash-topbar { flex-wrap: wrap; gap: 10px; } .module-grid { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- encabezado: logotipo del negocio */
.topbar h1.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { height: 34px; max-width: 160px; object-fit: contain; background: #fff; border-radius: 6px; padding: 3px 6px; }
.brand-logo[hidden] { display: none; }

/* ---------------------------------------------------------------- lector QR (qr-scanner.js) */
.qr-wrap { display: flex; align-items: stretch; gap: 4px; width: 100%; min-width: 0; }
.qr-wrap > input { flex: 1; min-width: 0; }
.search .qr-wrap { max-width: 680px; }
.qr-btn {
  flex: none; width: 38px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: var(--text); cursor: pointer; padding: 0;
}
.qr-btn:hover, .qr-btn:focus-visible { border-color: var(--primary); color: var(--primary); }
.qr-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.qr-modal { width: min(480px, calc(100vw - 32px)); }
.qr-video { position: relative; background: #000; border-radius: 8px; overflow: hidden; aspect-ratio: 4 / 3; }
.qr-video video { width: 100%; height: 100%; object-fit: cover; display: block; }
.qr-frame { position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,.85); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0,0,0,.25); }
.qr-status { margin: 10px 0 0; }
.qr-image { width: 132px; height: 132px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 6px; }

/* ---------------------------------------------------------------- inventario (/admin/inventario) */
.inv-layout { display: grid; grid-template-columns: 250px 1fr; gap: 16px; align-items: start; }
.inv-categories { position: sticky; top: 12px; max-height: calc(100vh - 120px); overflow-y: auto; padding: 12px; }
.inv-categories h3 { margin: 0 0 8px; }
.inv-main { min-width: 0; }
.cat-filter { list-style: none; margin: 0; padding: 0; }
.cat-item {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 6px 8px; border: none; border-radius: 6px; background: none; font: inherit; font-size: .9rem; text-align: left; cursor: pointer; color: var(--text);
}
.cat-item:hover { background: var(--surface-3); }
.cat-item.active { background: var(--accent-soft); color: var(--primary-dark); font-weight: 600; }
.cat-item small { color: var(--muted); font-weight: 400; }
.sales-table tr.archived td { color: var(--muted); }
.qr-code-link { font-family: ui-monospace, monospace; font-size: .8rem; }
.link.danger, button.link.danger { color: var(--error); }
.link:disabled { opacity: .4; cursor: not-allowed; }
.product-form .form-grid { margin-bottom: 12px; }
.qr-panel { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; }
.qr-panel h3 { margin: 0 0 4px; }
.qr-list { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; }
.qr-item { display: flex; gap: 10px; align-items: center; margin: 0; }
.qr-item figcaption { display: flex; flex-direction: column; gap: 3px; }
.qr-item figcaption strong { font-family: ui-monospace, monospace; }
.qr-actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.pl-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.pl-list-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pl-list-head h3 { margin: 0; }
.pl-list { list-style: none; margin: 10px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.pl-item {
  width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; font: inherit;
  padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); cursor: pointer; color: var(--text);
}
.pl-item:hover { border-color: var(--primary); }
.pl-item.active { border-color: var(--primary); background: var(--accent-soft); }
.pl-item.archived { opacity: .65; }
.pl-detail { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.pl-detail > h2 { margin: 0; }
.pl-detail .settings-card { margin: 0; }
.pl-customers { list-style: none; margin: 10px 0 0; padding: 0; }
.pl-customers li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.rule-type { margin: 12px 0; }
@media (max-width: 900px) { .inv-layout, .pl-layout { grid-template-columns: 1fr; } .inv-categories { position: static; max-height: 240px; } }

/* ---------------------------------------------------------------- POS: punto de venta y caja */
.pos-chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08); color: #fff; font: inherit; font-size: .85rem; cursor: pointer; white-space: nowrap;
}
.pos-chip::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: #adb5bd; }
.pos-chip.open::before { background: #40c057; }
.pos-chip.closed::before { background: #fa5252; }
.pos-chip:hover { border-color: var(--primary); }
.pricelist-info { margin: 6px 0 0; color: var(--muted); }
.pricelist-info strong { color: var(--text); }
.pos-select { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); margin-bottom: 12px; }
.pos-select select { padding: 8px; font-size: .95rem; }
.pos-status dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 12px; font-size: .9rem; }
.pos-status dt { color: var(--muted); }
.pos-status dd { margin: 0; font-weight: 600; }
.pos-cash-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin: 8px 0; }
.pos-cash-form label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
.pos-cash-form input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: .95rem; }

/* ---------------------------------------------------------------- parámetros: PV, monedas y ARCA */
.pv-list { display: flex; flex-direction: column; gap: 12px; }
.pv-card { margin: 0; }
.pv-card.inactive { opacity: .7; }
.pv-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.pv-card-head h3 { margin: 0; }
.pv-card-head .spacer { flex: 1; }
.pv-status { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .85rem; margin-top: 8px; }
.pv-code { width: 90px; font-family: ui-monospace, monospace; }
.env-switch { margin: 10px 0; }
#arca-env-card h4 { margin: 18px 0 8px; }
.check-result { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; }
.rate-cell { display: flex; gap: 6px; align-items: center; }
.rate-cell input[type="number"] { width: 120px; }
.rate-cell input[type="date"] { width: 140px; }
.pos-cash-form[hidden], .qr-panel[hidden], .pv-status[hidden], .rounding-example[hidden], .inv-layout [hidden], .pl-detail [hidden] { display: none; }
.form-grid > label.check-line { flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px; }


/* ---------------------------------------------------------------- modo oscuro: controles nativos y bordes */
input, select, textarea { color: var(--text); background-color: var(--input-bg); }
input:disabled, select:disabled { opacity: .65; }
.topbar input[type="search"] { background-color: var(--input-bg); }
:root[data-theme="dark"] .modal::backdrop { background: rgba(0,0,0,.7); }
:root[data-theme="dark"] main a:not(.icon-btn):not(.module-card) { color: var(--primary-dark); }
:root[data-theme="dark"] .topbar-link, :root[data-theme="dark"] .module-card { color: inherit; }
:root[data-theme="dark"] .product img, :root[data-theme="dark"] .qr-image { background: #fff; } /* fotos y QR sobre blanco */
:root[data-theme="dark"] .ticket-preview .ticket { box-shadow: 0 1px 4px rgba(0,0,0,.6); }
.theme-toggle {
  flex: none; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid rgba(255,255,255,.25); border-radius: 8px; background: rgba(255,255,255,.08); color: #fff; cursor: pointer; padding: 0;
}
.theme-toggle:hover, .theme-toggle:focus-visible { border-color: var(--primary); }
.theme-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- íconos de acción con tooltip (icons.js) */
.icon-btn {
  position: relative; flex: none; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); cursor: pointer; padding: 0;
}
.icon-btn + .icon-btn { margin-left: 4px; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover:not(:disabled), .icon-btn:focus-visible { border-color: var(--primary); color: var(--primary); outline: none; }
.icon-btn.danger { color: var(--error); }
.icon-btn.danger:hover:not(:disabled) { border-color: var(--error); color: var(--error); background: var(--error-soft); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn.busy { opacity: .6; cursor: progress; }
.sales-table td.actions { white-space: nowrap; }
/* Tooltip flotante: en hover y en foco de teclado (también en botones deshabilitados, vía el contenedor). */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip); position: absolute; z-index: 30; bottom: calc(100% + 8px); left: 50%; transform: translate(-50%, 4px);
  padding: 5px 9px; border-radius: 6px; background: var(--tip-bg); color: var(--tip-text); font-size: .78rem; font-weight: 500; line-height: 1.2;
  white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s, transform .12s; box-shadow: 0 4px 12px var(--shadow);
}
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
.topbar [data-tip]::after { bottom: auto; top: calc(100% + 8px); }

/* ---------------------------------------------------------------- variantes (Inventario y Stock) */
.variants-panel { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 16px; }
.variants-panel h3 { margin: 0 0 4px; }
.attr-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.attr-chip { padding: 4px 10px; border-radius: 999px; background: var(--surface-3); font-size: .85rem; }
.variant-add { align-items: end; margin-bottom: 10px; }
.va-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.va-actions #va-preview { flex: 1 1 200px; }
.va-rows { display: grid; gap: 8px; margin-bottom: 8px; }
.va-row { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(200px, 2fr) auto; gap: 8px; align-items: end; }
.va-row label { display: grid; gap: 4px; font-size: .85rem; }
.va-row .va-new { margin-top: 4px; }
@media (max-width: 640px) { .va-row { grid-template-columns: 1fr; } }
.price-cell { display: flex; gap: 6px; align-items: center; }
.price-cell select.cell-input { min-width: 0; width: auto; }
.variants-table .price-cell .cell-input[type="number"] { text-align: right; max-width: 110px; }
.cell-input { width: 100%; min-width: 90px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font: inherit; font-size: .88rem; background: var(--input-bg); color: var(--text); }
.variants-table td.num .cell-input { text-align: right; max-width: 120px; }
.variants-table td { vertical-align: middle; }
.variant-siblings { margin-top: 14px; }
.variant-siblings h3 { margin: 0 0 6px; font-size: 1rem; }
.variants-table tr.current td { background: var(--accent-soft); }

/* ---------------------------------------------------------------- POS: cobro multi-medio y cierre de caja */
.card-type { margin-top: 6px; }
.card-type[hidden], .pay-split[hidden], .pay-check[hidden], #pos-summary-box[hidden] { display: none; }
.pay-split { display: flex; gap: 8px; align-items: flex-end; margin-top: 8px; }
.pay-split label { flex: 1; display: flex; flex-direction: column; gap: 3px; font-size: .8rem; color: var(--muted); }
.pay-split input { width: 100%; padding: 7px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: .95rem; text-align: right; }
.pay-change { flex: 1; font-weight: 700; font-size: .95rem; padding-bottom: 8px; }
.pay-check { margin: 6px 0 0; font-weight: 600; }
.pay-check.ok { color: var(--ok); }
.pay-check.error { color: var(--error); }
.close-summary { width: 100%; }
.close-summary dl { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; margin: 0 0 8px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); font-size: .9rem; }
.close-summary dt { color: var(--muted); }
.close-summary dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.close-summary dt.sum-total, .close-summary dd.sum-total { color: var(--text); font-weight: 800; border-top: 1px solid var(--border); padding-top: 3px; }
#pos-summary-box { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.product .add svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
/* Celda de acciones: sigue siendo una celda de tabla (mismo alto, fondo y borde que la fila). */
.sales-table td.actions { display: table-cell; vertical-align: middle; }
.sales-table td.actions > * { vertical-align: middle; }
.sales-table td.actions > * + * { margin-left: 6px; }
/* Tooltips de la última columna: se abren hacia la izquierda para no cortarse contra el borde. */
.sales-table td:last-child [data-tip]::after, .pl-list-head [data-tip]::after, #pm-variants-actions [data-tip]::after { left: auto; right: 0; transform: translate(0, 4px); }
.sales-table td:last-child [data-tip]:hover::after, .sales-table td:last-child [data-tip]:focus-visible::after,
.pl-list-head [data-tip]:hover::after, #pm-variants-actions [data-tip]:hover::after { transform: translate(0, 0); }

/* El atributo hidden siempre oculta (algunas reglas con display: flex/grid lo pisaban). */
[hidden] { display: none !important; }
/* POS: con el cobro desplegado el panel crece; se desplaza el panel entero y el carrito conserva su alto mínimo. */
.cart { overflow-y: auto; }
.cart-items { flex: 1 0 auto; min-height: 110px; overflow-y: visible; }
.breakdown-split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.breakdown-split .settings-card { margin: 0; }
#breakdown-modal { width: min(640px, calc(100vw - 32px)); }
@media (max-width: 640px) { .breakdown-split { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- POS: arqueo por billetes */
.pos-user { margin: 0 0 8px; color: var(--muted); }
.pos-user strong { color: var(--text); }
.denom-box { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 0; }
.denom-box legend { font-size: .85rem; font-weight: 600; padding: 0 4px; }
.denom-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 14px; }
.denom-row { display: grid; grid-template-columns: 1fr 72px 1fr; align-items: center; gap: 6px; font-size: .88rem; }
.denom-row .denom-value { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.denom-row input { width: 100%; padding: 5px 6px; border: 1px solid var(--border); border-radius: 6px; text-align: right; font-size: .9rem; }
.denom-row .denom-sub { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; font-size: .82rem; }
.denom-total { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin: 10px 0 0; font-size: .95rem; font-weight: 600; }
.denom-total input { width: 170px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; text-align: right; font-size: 1.15rem; font-weight: 700; background: var(--input-bg); color: var(--text); }
.denom-source { margin: 4px 0 0; text-align: right; }
@media (max-width: 520px) { .denom-grid { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- ver contraseña (theme.js) */
.pw-wrap { position: relative; display: block; width: 100%; }
.pw-wrap > input { width: 100%; padding-right: 42px; }
.pw-toggle {
  position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
  width: 34px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; padding: 0;
}
.pw-toggle:hover, .pw-toggle:focus-visible { color: var(--primary); background: var(--surface-3); outline: none; }
.pw-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pw-toggle[data-tip]::after { left: auto; right: 0; transform: translate(0, 4px); }
.pw-toggle[data-tip]:hover::after { transform: translate(0, 0); }

/* ---------------------------------------------------------------- POS: modal de cobro y cierre de caja */
#pay-modal { width: min(460px, calc(100vw - 32px)); }
#pay-modal .segmented { margin-top: 10px; }
.pay-total-box { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px; border-radius: 10px; background: var(--surface-2); margin-bottom: 4px; }
.pay-total-box span { color: var(--muted); font-size: .85rem; }
.pay-total-box strong { font-size: 1.8rem; font-variant-numeric: tabular-nums; }
#pay-confirm { margin-top: 14px; }
.pos-close-btn { border-color: var(--error-border); }
.close-check { margin: 8px 0; padding: 8px 10px; border-radius: 8px; font-weight: 700; font-size: .92rem; }
.close-check.ok { background: var(--ok-soft); color: var(--ok); }
.close-check.warn { background: var(--error-soft); color: var(--error); }
.pos-actions { display: flex; flex-direction: column; gap: 8px; }
.pos-actions button.secondary { width: 100%; padding: 10px; font-weight: 600; }
#pay-modal .invoice-options { margin-top: 10px; }

/* Etiquetas PDF: "Generar PDF" arriba y la lista de etiquetas con scroll propio. */
.lb-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 12px 0 8px; }
.lb-actions .rounding-example { margin: 0; flex: 1 1 240px; }
.lb-list { max-height: min(42vh, 420px); overflow: auto; overscroll-behavior: contain; }
.lb-list thead th { position: sticky; top: 0; z-index: 1; }

/* Modal de cobro: "Generar Factura ARCA" (desmarcado = ticket interno). */
.pay-invoice { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); cursor: pointer; }
.pay-invoice input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
.pay-invoice strong { color: var(--text); }

/* ---------------------------------------------------------------- POS: modal de caja horizontal (sin scroll) */
#pos-modal { width: min(1100px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 18px 22px; }
#pos-modal .modal-header { margin-bottom: 8px; }
.pos-top { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 6px 20px; align-items: start; margin-bottom: 8px; }
.pos-top .pos-select { margin-bottom: 4px; }
.pos-top .pos-user { margin: 0; }
.pos-status dl { grid-template-columns: repeat(2, auto minmax(0, 1fr)); gap: 3px 12px; margin: 0; font-size: .86rem; }
.cash-layout { display: grid; grid-template-columns: 1fr; gap: 10px 18px; align-items: start; margin: 4px 0 0; }
.cash-layout.cash-close { grid-template-columns: minmax(320px, 1.2fr) minmax(380px, 1fr); }
.cash-col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cash-col .close-summary dl { margin: 0; padding: 8px 10px; font-size: .86rem; }
.cash-col #pos-close-diff { margin: 0; }
.cash-col .close-check { margin: 0; }
.cash-layout .denom-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 5px 12px; }
.cash-layout .denom-row input { padding: 4px 6px; }
/* Acciones al pie: siempre visibles (fijas abajo si la ventana es baja). */
.cash-actions { grid-column: 1 / -1; position: sticky; bottom: -18px; z-index: 2; display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px 14px;
  margin: 0 -22px -18px; padding: 10px 22px 14px; border-top: 1px solid var(--border); background: var(--card); }
.cash-actions .denom-source { flex: 1 1 220px; margin: 0; text-align: left; }
.cash-actions .denom-total { margin: 0; flex-direction: row; color: var(--text); }
.cash-actions .denom-total input { width: 160px; }
.cash-actions button[type="submit"] { width: auto; flex: none; padding-left: 28px; padding-right: 28px; }
.cash-col .close-summary dt { white-space: nowrap; }
#pos-modal .message { margin: 8px 0 0; }
@media (max-width: 860px) {
  .pos-top, .cash-layout.cash-close { grid-template-columns: 1fr; }
  .pos-status dl { grid-template-columns: auto minmax(0, 1fr); }
}

/* Selector de empresa activa (multi-empresa) en la barra superior del panel. */
.company-switch { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border: 1px solid rgba(255,255,255,.25); border-radius: 8px; color: var(--on-text); font-size: .85rem; }
.company-switch span { opacity: .75; }
.company-switch select { max-width: 260px; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--input-bg); color: var(--text); font: inherit; }

/* Enlace de la primera columna de las grillas: abre lo mismo que el ícono Editar / Ver. */
.row-link { color: var(--primary); font-weight: 600; text-decoration: none; border-bottom: 1px dashed currentColor; }
.row-link:hover, .row-link:focus-visible { text-decoration: none; border-bottom-style: solid; }

/* Compras: accesos directos (remitos y facturas de la orden), selector de documentos y vistas. */
.smart-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.smart-buttons:empty { display: none; }
.smart-btn {
  display: inline-grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center;
  min-width: 170px; min-height: 48px; padding: 6px 14px; text-align: left; font: inherit; color: var(--text);
  background: var(--card); border: 1.5px solid var(--border); border-radius: 10px; cursor: pointer;
}
.smart-btn svg { grid-row: span 2; width: 22px; height: 22px; fill: none; stroke: var(--primary); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.smart-btn small { color: var(--muted); font-size: .78rem; }
.smart-btn:hover:not(:disabled) { border-color: var(--primary); background: var(--accent-soft); }
.smart-btn:disabled { opacity: .5; cursor: not-allowed; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.chip-row .chip { min-height: 34px; flex-direction: row; padding: 4px 12px; font-size: .9rem; }
.chip-row .chip[aria-pressed="true"] { border-color: var(--primary); background: var(--accent-soft); font-weight: 600; }
.bill-foot { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 24px; margin-top: 12px; }
.small-heading { font-size: .95rem; margin: 0 0 6px; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: 3px 0; }
.ok-text { color: var(--ok); }

/* Parámetros › Configuración de documentos */
.opacity-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.opacity-row input[type="range"] { flex: 1; min-width: 160px; max-width: 320px; }
.doc-preview-frame { width: 100%; height: min(72vh, 900px); border: 1px solid var(--border); border-radius: 8px; background: #fff; }
/* Deuda con pagos parciales (compras, cuentas por pagar y cuenta corriente). */
.badge-partial { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: #12b76a; color: #fff;
  font-size: 0.72rem; font-weight: 800; letter-spacing: .06em; vertical-align: middle; box-shadow: 0 0 0 2px rgba(18, 183, 106, .22); }
.bill-dates { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; }
@media (max-width: 640px) { .bill-dates { grid-template-columns: 1fr; } }
.locked-tag { display: inline-flex; align-items: center; gap: 4px; }
.locked-tag svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; }

/* Devoluciones y vales de crédito */
.returns-modal { width: min(980px, 96vw); max-width: 96vw; }
.returns-modal .rt-results { max-height: 50vh; overflow: auto; }
.returns-modal .rt-result { width: 100%; text-align: left; padding: 8px 10px; border: 1px solid var(--border, #d0d5dd); border-radius: 8px; background: var(--surface, #fff); color: inherit; cursor: pointer; margin: 4px 0; }
.returns-modal .rt-result:hover, .returns-modal .rt-result:focus-visible { border-color: var(--primary); }
.returns-modal .rt-mode { margin: 8px 0 12px; }
.returns-modal .rt-kind { margin: 0 0 8px; }
.ticket .t-voucher-code { font: 800 15px/1.2 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .08em; margin: 2mm 0 0; }
.pay-voucher { display: grid; gap: 8px; margin: 8px 0; padding: 10px 12px; border: 1px dashed var(--primary); border-radius: 8px; }
.pay-voucher-row { display: flex; gap: 8px; align-items: center; }
.pay-voucher-row input { flex: 1; text-transform: uppercase; }
.pay-voucher .voucher-info { margin: 0; }

/* Historial de órdenes del POS */
.history-modal { width: min(1480px, 98vw); }
.history-modal .sales-table { font-size: .85rem; }
.history-modal .sales-table th, .history-modal .sales-table td { padding-left: 8px; padding-right: 8px; }
.history-modal .oh-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 4px; }
.history-modal .oh-q-wrap { flex: 1 1 260px; }
.topbar .history-btn { font-weight: 700; }
.history-modal .pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.history-modal .pill.ok { background: var(--ok-soft); color: var(--ok); }
.history-modal .pill.warn { background: var(--error-soft); color: var(--error); }
.history-modal .pill.fiscal { background: var(--accent-soft); color: var(--primary-dark); }
.history-modal .pill.internal { background: var(--surface-3); color: var(--muted); }
/* Botón de devolución deshabilitado (plazo vencido): el tooltip se muestra sobre el contenedor. */
.history-modal .rt-expired { display: inline-block; cursor: help; }
.history-modal .rt-expired button { pointer-events: none; opacity: .45; }

/* Usuario logueado en el encabezado del POS */
.pos-user-chip { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--primary); color: var(--on-primary); font-size: .85rem; font-weight: 700; white-space: nowrap; }
.pos-user-chip svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pos-user-chip small { font-weight: 400; opacity: .85; }

/* Modal de confirmación / aviso del sistema (ui-dialog.js) */
.ui-dialog { width: min(460px, calc(100vw - 32px)); padding: 0; overflow: hidden; }
.ui-dialog-head { display: flex; align-items: center; gap: 14px; padding: 20px 22px 12px; border-top: 4px solid var(--primary); }
.ui-dialog-icon { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font: 800 1.35rem/1 system-ui, sans-serif; background: var(--accent-soft); color: var(--primary); }
.ui-dialog-warning .ui-dialog-head, .ui-dialog-error .ui-dialog-head { border-top-color: var(--error); }
.ui-dialog-warning .ui-dialog-icon, .ui-dialog-error .ui-dialog-icon { background: var(--error-soft); color: var(--error); }
.ui-dialog-success .ui-dialog-head { border-top-color: var(--ok); }
.ui-dialog-success .ui-dialog-icon { background: var(--ok-soft); color: var(--ok); }
.ui-dialog h2 { font-size: 1.15rem; }
.ui-dialog-body { padding: 0 22px 8px; }
.ui-dialog-body p { margin: 0 0 8px; line-height: 1.45; }
.ui-dialog-details { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 8px 0; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.ui-dialog-details dt { color: var(--muted); font-size: .85rem; }
.ui-dialog-details dd { margin: 0; font-weight: 700; text-align: right; overflow-wrap: anywhere; }
.ui-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 22px 18px; background: var(--surface-2); border-top: 1px solid var(--border); }
.ui-dialog-actions button { width: auto; min-width: 110px; padding: 10px 18px; font-size: .95rem; }
.ui-dialog-actions button.primary.danger { background: var(--error); }

/* Ticket: total enmarcado, pago en una fila, aire bajo el QR y margen de corte. */
.ticket .t-total-box { border: 2px solid #000; border-radius: 1.5mm; padding: 1.5mm 2mm; margin: 1.5mm 0; }
.ticket .t-nowrap > span:first-child { max-width: none; white-space: nowrap; }
.ticket .t-nowrap > span:last-child { white-space: nowrap; }
.ticket .t-qr { margin-bottom: 4mm; }
.ticket .t-qr + .t-small, .ticket .t-qr-web + .t-small { padding-bottom: 2mm; }
.ticket .t-cut { height: 10mm; }

/* Reportes de productos */
.report-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin: 0 0 16px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); }
.report-filters label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
.report-filters .spacer { flex: 1; }
.report-shortcuts button { padding: 8px 12px; border: 1px solid var(--border); background: var(--input-bg); color: var(--text); cursor: pointer; font: inherit; font-size: .85rem; }
.report-shortcuts button:first-child { border-radius: 8px 0 0 8px; }
.report-shortcuts button:last-child { border-radius: 0 8px 8px 0; }
.report-shortcuts button + button { border-left: none; }
.report-shortcuts button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 700; }
.report-kpis { margin-bottom: 14px; }
.report-table td.rank { color: var(--muted); font-weight: 700; width: 3em; }
.report-table td.strong { font-weight: 700; }
.report-table tr.negative td { color: var(--error); }
.cost-flag { color: var(--primary); font-weight: 700; cursor: help; }

/* POS: cajas abiertas (unirse a la sesión), preventa y Caja Central */
.pos-chip.presale::before { background: #4dabf7; }
.pos-sessions { margin: 4px 0 12px; padding: 10px 12px; border: 1px dashed var(--primary); border-radius: 10px; background: var(--accent-soft); }
.pos-sessions h3 { margin: 0 0 6px; font-size: .95rem; }
.pos-session-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--border); }
.pos-session-row:first-child { border-top: none; }
.pos-session-row button.small-btn { width: auto; padding: 8px 14px; font-size: .9rem; }
.presale-hint { color: var(--primary-dark); }
.topbar .central-btn { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 700; }
#central-modal { width: min(1000px, 96vw); }
#central-modal label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
#central-modal button.small-btn { width: auto; padding: 6px 14px; }
/* Historial: acciones con íconos (devolución y reimpresión) */
.history-modal td.actions { white-space: nowrap; }
.history-modal td.actions .icon-btn + .icon-btn, .history-modal td.actions .rt-expired + .icon-btn { margin-left: 6px; }
.history-modal .rt-expired[data-tip]::after { white-space: normal; width: 280px; text-align: left; left: auto; right: 0; transform: translate(0, 4px); }
.history-modal .rt-expired[data-tip]:hover::after, .history-modal .rt-expired[data-tip]:focus-visible::after { transform: translate(0, 0); }
/* Acciones siempre visibles aunque la grilla tenga scroll horizontal. */
.history-modal .sales-table th:last-child, .history-modal .sales-table td.actions { position: sticky; right: 0; z-index: 1; background: var(--card); box-shadow: -6px 0 6px -6px var(--shadow); }

/* ---------------------------------------------------------------- Reportes: Mostrar / Ocultar Columnas */
.col-picker { position: relative; }
.col-picker > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--input-bg); color: var(--text); font-size: .85rem; user-select: none; }
.col-picker > summary::-webkit-details-marker { display: none; }
.col-picker > summary::after { content: "▾"; font-size: .75rem; color: var(--muted); }
.col-picker[open] > summary { border-color: var(--primary); }
.col-picker-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 230px; max-width: calc(100vw - 32px); padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }
.col-picker-menu .check-line { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: .9rem; color: var(--text); flex-direction: row; }
.col-picker-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
@media (max-width: 640px) { .col-picker-menu { left: 0; right: auto; } }

/* ---------------------------------------------------------------- Usuarios: permisos de Reportes */
.perm-box { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 4px 0 0; }
.perm-box legend { padding: 0 6px; font-weight: 700; }
.perm-box .check-line { color: var(--text); font-weight: 400; flex-direction: row; }
.perm-box .perm-main { font-size: .95rem; }
.perm-items { display: grid; gap: 4px; margin: 6px 0 4px 24px; }
.perm-items .check-line { font-size: .9rem; }
.perm-items.disabled { opacity: .55; }

/* ---------------------------------------------------------------- PDV: cobro en dólares */
.pay-usd { align-items: end; }
.pay-usd .pay-change { color: var(--muted); font-weight: 400; }
/* Formas de pago: con Dólares son seis opciones; se acomodan en dos filas en lugar de cortarse. */
.segmented.payment { flex-wrap: wrap; }
.segmented.payment label { flex: 1 1 30%; box-shadow: inset 0 0 0 .5px var(--border); }
.segmented.payment label + label { border-left: none; }
.segmented.payment span { height: 100%; display: flex; align-items: center; justify-content: center; }

/* Asientos contables (journal-entry.js, Contabilidad › Libro Diario) */
.je-modal { width: min(1040px, calc(100vw - 32px)); }
.je-body { display: grid; gap: 16px; overflow: auto; }
.je-entry { border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.je-entry.je-unbalanced { border-color: #c0392b; }
.je-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 6px 16px; margin: 0 0 10px; }
.je-meta dt { font-size: .78em; color: var(--muted, #6b7280); text-transform: uppercase; letter-spacing: .03em; }
.je-meta > div { min-width: 0; }
.je-meta dd { margin: 0 0 4px; font-weight: 600; overflow-wrap: anywhere; }
.je-lines tfoot th { border-top: 2px solid var(--border); }
.le-row { cursor: pointer; }
.le-row[aria-expanded="true"] { background: var(--hover, rgba(0,0,0,.04)); }
.le-detail > td { padding: 0 8px 12px; }

/* Seguridad & Usuarios: matriz de permisos */
.sec-roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.sec-role { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.sec-role h3 { margin: 0 0 4px; font-size: 1rem; }
.sec-matrix { width: 100%; border-collapse: collapse; }
.sec-matrix th, .sec-matrix td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.sec-matrix td.chk { text-align: center; width: 90px; }
.sec-matrix tr.group th { background: var(--hover, rgba(0,0,0,.04)); font-size: .8em; text-transform: uppercase; letter-spacing: .04em; }
.sec-matrix input:disabled + span { opacity: .6; }
.perm-summary { display: flex; flex-wrap: wrap; gap: 4px; }
.perm-summary .pill { font-size: .75em; }
.sec-modal { width: min(720px, calc(100vw - 32px)); }
