/* POS Peces · hoja de estilos 0.7
   Idea: una herramienta de mostrador tranquila y clara. Lo único llamativo es la lectura de la báscula
   (dígitos ámbar sobre fondo oscuro); todo lo demás es blanco, gris verdoso y un solo verde de acción. */

@font-face {
  font-family: 'Plex';
  src: url('/fonts/ibm-plex-sans.woff2') format('woff2');
  font-weight: 100 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #17302b;          /* texto principal: verde casi negro */
  --ink-2: #445a53;        /* texto secundario */
  --muted: #5f716b;        /* notas y etiquetas */
  --canvas: #eef2f0;       /* fondo de la aplicación */
  --surface: #ffffff;      /* paneles */
  --tint: #f5f8f6;         /* zonas suaves dentro de un panel */
  --line: #dde5e1;
  --line-strong: #c5d2cc;
  --primary: #0e6b5a;      /* verde estanque: la acción principal */
  --primary-strong: #0a5446;
  --primary-tint: #e2f0eb;
  --display: #13221e;      /* cuerpo de la báscula */
  --display-line: #2a3d37;
  --amber: #f5a623;        /* dígitos de la báscula */
  --danger: #b3392f;
  --danger-tint: #fbebe8;
  --warn: #8a5a0b;
  --warn-tint: #fff3da;
  --info: #2d5b78;
  --info-tint: #e8f1f7;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(19, 34, 30, .16);
  --font: 'Plex', 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--canvas); font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; line-height: 1.2; }
h2 { font-size: 17px; line-height: 1.3; margin-bottom: 12px; }
h3 { font-size: 14.5px; margin: 18px 0 8px; }
p { margin: 0 0 10px; }
a { color: var(--primary); text-underline-offset: 3px; }
strong { font-weight: 600; }
small { font-size: 12.5px; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid #7fc1ad; outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

button, .button, input, select, textarea { font: inherit; color: inherit; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font-size: 14.5px; font-weight: 500; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s;
}
button:hover, .button:hover { border-color: var(--primary); background: #f6faf8; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
button.danger { color: var(--danger); }
button.small, .button.small { min-height: 32px; padding: 5px 10px; font-size: 13px; border-radius: 8px; }
button.link { min-height: 0; padding: 0; border: 0; background: none; color: var(--primary); text-decoration: underline; text-underline-offset: 3px; font-weight: 500; }
button.link:hover { background: none; color: var(--primary-strong); }
.text-button { border: 0; background: none; color: var(--ink-2); padding: 6px 8px; min-height: 36px; }
.text-button:hover { background: var(--tint); }
.icon-button { width: 40px; padding: 0; }
.icon-button.small { width: 32px; }
.wide { width: 100%; }
kbd { font: 600 11px/1 var(--font); padding: 3px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); color: var(--ink-2); }

input, select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); outline: none; font-size: 15px;
}
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14, 107, 90, .16); }
input[type=checkbox], input[type=radio] { width: 18px; min-height: 18px; height: 18px; accent-color: var(--primary); margin: 0; }
label { display: block; margin-bottom: 6px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
label.check { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 14.5px; margin: 4px 0 8px; }
.field { margin-bottom: 14px; }
.field-label { margin-top: 4px; }
span.field-label { display: block; margin-bottom: 6px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
.hint { color: var(--muted); font-size: 13px; line-height: 1.55; }
.lead { color: var(--ink-2); font-size: 14.5px; margin-bottom: 18px; }
.dangertext { color: var(--danger) !important; }
.oktext { color: var(--primary); }
.field-error { color: var(--danger); background: var(--danger-tint); padding: 9px 12px; border-radius: 8px; font-size: 13.5px; margin: 10px 0; }
.notice { background: var(--warn-tint); color: var(--warn); padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }
#error { background: var(--danger-tint); color: var(--danger); padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- Armazón: menú lateral y barra superior ---------- */
#app { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
#sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 14px 16px; border-right: 1px solid var(--line); background: var(--canvas); overflow-y: auto; z-index: 30; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px 18px; }
.brand strong { display: block; font-size: 16px; letter-spacing: -.01em; }
.brand small { display: block; color: var(--muted); font-size: 12px; line-height: 1.3; }
.logo { width: 36px; height: 36px; border-radius: 10px; background: var(--primary); display: grid; place-items: center; flex: none; }
.logo svg { width: 24px; height: 24px; fill: #fff; stroke: none; }
.logo svg circle { fill: var(--primary); }
#nav { display: grid; gap: 14px; }
.nav-group { display: grid; gap: 2px; }
.nav-group + .nav-group { padding-top: 14px; border-top: 1px solid var(--line); }
#nav button { justify-content: flex-start; gap: 12px; width: 100%; min-height: 40px; padding: 8px 10px; border: 0; background: transparent; color: var(--ink-2); font-weight: 500; border-radius: 9px; }
#nav button:hover { background: rgba(255, 255, 255, .7); color: var(--ink); }
#nav button.active { background: var(--surface); color: var(--primary); box-shadow: inset 0 0 0 1px var(--line); }
#nav button.active .icon { stroke-width: 2; }
.session { margin-top: auto; padding: 16px 8px 0; display: grid; gap: 8px; font-size: 13px; }
.session .who strong { display: block; font-size: 14px; }
.session .who small, .session > small { display: block; color: var(--muted); font-size: 12px; }
#point-picker label { font-size: 12px; margin-bottom: 4px; }
#point-picker select { min-height: 36px; padding: 6px 8px; font-size: 13.5px; }
.point-label { display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; }
.logout { justify-content: flex-start; min-height: 34px; padding: 6px 8px; border: 0; background: none; color: var(--ink-2); font-size: 13.5px; }
.logout:hover { background: var(--surface); }
.logout .icon { width: 18px; height: 18px; }
#scrim { position: fixed; inset: 0; background: rgba(19, 34, 30, .4); z-index: 25; }
@media (min-width: 901px) { #scrim { display: none !important; } }

#workspace { min-width: 0; padding: 0 28px 48px; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; min-height: 68px; margin: 0 -28px 18px; padding: 12px 28px; background: var(--canvas); }
#menu-button { display: none; }
.topbar .date { color: var(--muted); font-size: 13.5px; order: 2; }
#title { order: 1; }
#page-tools { order: 3; margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.page { max-width: 1440px; }

/* Herramientas de la barra superior */
.chip { min-height: 38px; border-radius: 999px; padding: 6px 14px 6px 10px; font-size: 14px; }
.chip.ok { background: var(--primary-tint); border-color: #b9dccf; color: var(--primary-strong); }
.chip.warn { background: var(--warn-tint); border-color: #ecd7a8; color: var(--warn); }
.chip .icon { width: 18px; height: 18px; }
.chip .short { display: none; }
.tool { position: relative; min-height: 38px; padding: 6px 12px; font-size: 14px; }
.tool .icon { width: 18px; height: 18px; color: var(--ink-2); }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--primary); color: #fff; font-size: 11.5px; font-weight: 600; }

/* ---------- Piezas comunes ---------- */
.panel, .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; }
.page > .panel, .page > div > .panel, .page > section.panel, #clients-body > .panel, #stats-body > .panel, #settings-body > .panel, .page > details.panel { margin-bottom: 16px; }
details.panel > summary, details > summary { cursor: pointer; font-weight: 500; font-size: 14.5px; }
details[open] > summary { margin-bottom: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row > h2 { margin-bottom: 0; }
.panel > .row:first-child { margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stack { display: grid; gap: 16px; }
.layout > *, .stack > *, .grid2 > * { min-width: 0; }
.page > .grid2 { gap: 16px; margin-bottom: 16px; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.actions.start { justify-content: flex-start; margin-top: 12px; }
.line { height: 1px; background: var(--line); margin: 16px 0; }
.page-note { margin: -4px 0 14px; }
.summary-line { display: flex; flex-wrap: wrap; gap: 6px 22px; align-items: baseline; margin: 0 0 12px; font-size: 14.5px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 14px; }
.toolbar input { max-width: 380px; }
.link-list { display: grid; gap: 8px; }
.period-title { margin: 6px 0 12px; font-size: 18px; }

.pill, .badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; background: var(--tint); border: 1px solid var(--line); color: var(--ink-2); font-size: 12.5px; font-weight: 500; white-space: nowrap; vertical-align: middle; }
.pill.ok { background: var(--primary-tint); border-color: #c5e2d7; color: var(--primary-strong); }
.pill.warn, .badge.warn { background: var(--warn-tint); border-color: #ecd7a8; color: var(--warn); }
.pill.danger, .badge.red { background: var(--danger-tint); border-color: #f0c9c3; color: var(--danger); }

/* Pestañas: subrayado bajo la pestaña elegida */
.tabs { display: flex; gap: 4px; margin: -2px 0 18px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button { min-height: 42px; padding: 8px 12px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--ink-2); font-weight: 500; margin-bottom: -1px; }
.tabs button:hover { background: none; color: var(--ink); }
.tabs button[aria-selected=true] { color: var(--primary-strong); border-bottom-color: var(--primary); font-weight: 600; }

/* Indicadores en una sola franja: las líneas finas entre celdas son el fondo que asoma por el espacio de 1px */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.kpis > * { background: var(--surface); padding: 16px 20px; border: 0; border-radius: 0; min-width: 0; }
.kpis label { font-size: 13px; font-weight: 500; color: var(--muted); margin: 0; }
.kpis .hint, .kpis > * > small { display: block; margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.kpis .link { font-size: 13px; }
.panel .kpis { margin: 12px 0; background: var(--line); }
.panel .kpis > * { background: var(--tint); }
.metric { font-size: 27px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; margin: 4px 0 2px; overflow-wrap: anywhere; }
.metric small { font-size: 14px; font-weight: 500; color: var(--muted); letter-spacing: 0; }

.ledger-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.ledger-row:last-child { border-bottom: 0; }
.ledger-row > span { min-width: 0; }
.ledger-row small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.5; margin-top: 2px; }
.ledger-row > div { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px 12px; text-align: right; }
.ledger-row > div > small { margin: 0; }
.ledger-row.voided > span strong { color: var(--muted); text-decoration: line-through; }
.row-actions { display: inline-flex; gap: 6px; }
.breakdown { display: grid; margin: 8px 0 12px; }
.breakdown > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.breakdown.muted > div { color: var(--ink-2); }
.breakdown .breakdown-total { border-bottom: 0; border-top: 1px solid var(--ink); margin-top: 2px; padding-top: 10px; font-weight: 600; }
.pair-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; padding: 3px 0; }

table { width: 100%; border-collapse: collapse; font-size: 14px; text-align: left; }
th { padding: 10px 12px; font-size: 12.5px; font-weight: 500; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
th.num, td.num { text-align: right; }
.tablewrap { overflow-x: auto; }
.panel.tablewrap { padding: 4px 10px; }
.cell-actions { white-space: nowrap; text-align: right; }
.cell-actions button + button { margin-left: 6px; }
.cell-products { max-width: 220px; }

.filter-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; margin-bottom: 16px; }
.filter-row .field { margin: 0; }
.filter-row input[type=date] { min-width: 150px; }
.filter-row select { min-width: 150px; }
#history-q { min-width: 230px; }

.alerts { display: grid; gap: 8px; margin-bottom: 16px; }
.alert { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 16px; border-radius: var(--radius-sm); font-size: 14px; line-height: 1.45; }
.alert .link { color: inherit; font-weight: 600; }
.alert-danger { background: var(--danger-tint); color: var(--danger); }
.alert-warning { background: var(--warn-tint); color: var(--warn); }
.alert-info { background: var(--info-tint); color: var(--info); }
.alert-ok { background: var(--primary-tint); color: var(--primary-strong); }

/* ---------- Vender ---------- */
.last-sale { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 12px 10px 16px; margin-bottom: 14px; border-radius: var(--radius-sm); background: var(--primary-tint); color: var(--primary-strong); font-size: 14px; }
.last-sale span, .last-sale strong { display: block; }
.last-sale.with-warning { background: var(--warn-tint); color: var(--warn); }
.warn-text { display: block; margin-top: 4px; font-size: 13px; }

.pos { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 400px); gap: 18px; align-items: start; }
.capture { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px; min-width: 0; }
.capture-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.single-product { font-size: 18px; }
.segmented { display: inline-flex; padding: 4px; gap: 4px; border-radius: 13px; background: var(--canvas); }
.segmented button { min-height: 46px; padding: 8px 24px; border: 0; border-radius: 10px; background: transparent; color: var(--ink-2); font-size: 16.5px; font-weight: 600; }
.segmented button:hover { background: rgba(255, 255, 255, .7); }
.segmented button[aria-pressed=true] { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(10, 84, 70, .4); }

/* La báscula: lo único llamativo de la pantalla */
.scale { background: var(--display); border-radius: 16px; padding: 14px 20px 12px; color: #c9dad3; }
.scale-label { color: #9db4ac; font-size: 13px; margin-bottom: 0; }
.scale-read { display: flex; align-items: baseline; gap: 12px; }
.scale-read input { flex: 1; min-width: 0; min-height: 0; height: auto; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--amber); caret-color: var(--amber); font-size: clamp(52px, 6.4vw, 84px); font-weight: 600; line-height: 1.1; letter-spacing: -.02em; }
.scale-read input:focus { box-shadow: none; }
.scale-read input::placeholder { color: #3d524b; }
.scale-read input::-webkit-inner-spin-button, .scale-read input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.scale-read input { -moz-appearance: textfield; }
.scale-unit { color: var(--amber); font-size: 24px; font-weight: 600; }
.scale-foot { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--display-line); font-size: 14px; }
.scale-foot label { margin: 0; color: #9db4ac; font-size: 14px; }
.scale-foot input { width: 96px; min-height: 36px; padding: 5px 10px; background: #1c2f29; border-color: #34493f; color: #fff; font-size: 16px; font-weight: 600; }
.scale-foot input:focus { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(245, 166, 35, .2); }
.scale-small { color: #9db4ac; }
.scale-net { margin-left: auto; color: #9db4ac; }
.scale-net strong { color: #fff; font-size: 20px; margin-left: 6px; }

.capture-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 14px; }
.capture-actions button { min-height: 46px; padding: 8px 16px; font-size: 15.5px; }
.capture-actions .icon { width: 18px; height: 18px; }
#weight-list h3 { margin: 18px 0 4px; font-size: 14px; color: var(--ink-2); }
.pesada { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.pesada:last-child { border-bottom: 0; }
.pesada .number { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--canvas); color: var(--ink-2); font-size: 12px; font-weight: 600; }
.pesada strong { font-size: 15.5px; }
.pesada small { display: block; color: var(--muted); }
.shortcuts { margin: 16px 0 0; color: var(--muted); font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.shortcuts kbd { margin-left: 6px; }
.shortcuts kbd:first-child { margin-left: 0; }

.ticket { position: sticky; top: 84px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px 20px 14px; display: grid; gap: 0; }
.ticket > * + * { border-top: 1px dashed var(--line-strong); }
.ticket-client { padding-bottom: 14px; }
.ticket-client .row label { margin: 0; font-size: 14px; color: var(--ink); font-weight: 600; }
.ticket-client .row { margin-bottom: 8px; }
.client-search { position: relative; }
.client-results { position: absolute; z-index: 24; top: calc(100% + 4px); left: 0; right: 0; max-height: 300px; overflow: auto; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.client-results button { display: block; width: 100%; min-height: 0; padding: 9px 10px; border: 0; border-radius: 8px; text-align: left; white-space: normal; }
.client-results button[aria-selected=true], .client-results button:hover { background: var(--primary-tint); }
.client-results small { display: block; color: var(--muted); font-weight: 400; margin-top: 2px; }
.search-empty { padding: 8px 10px; margin: 0; }
.client-bottom { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-top: 7px; }
.client-bottom .hint { margin: 0; }
.ticket-body { padding: 12px 0; }
.ticket-lines { display: grid; gap: 8px; }
.ticket-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.ticket-line small { display: block; color: var(--muted); font-size: 13px; }
.ticket-line > strong { font-size: 15.5px; }
.ticket-empty { color: var(--muted); font-size: 14px; margin: 4px 0; }
.ticket-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; }
.price-options > summary { color: var(--primary); font-size: 13.5px; text-decoration: underline; text-underline-offset: 3px; list-style: none; }
.price-options > summary::-webkit-details-marker { display: none; }
.price-options[open] { width: 100%; padding: 12px; border-radius: var(--radius-sm); background: var(--tint); }
.ticket-total { padding: 14px 0 12px; }
.ticket-total .row span:first-child { font-weight: 600; }
.total { font-size: 44px; font-weight: 600; letter-spacing: -.03em; line-height: 1.1; margin: 2px 0; }
.charge-button { width: 100%; min-height: 60px; justify-content: space-between; padding: 10px 20px; border-radius: 12px; font-size: 19px; font-weight: 600; border-top: 0; }
.ticket > .charge-button { border-top: 1px solid var(--primary); }
.charge-button kbd { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .35); color: #fff; }
.ticket-secondary { display: flex; justify-content: space-between; padding-top: 8px; border-top: 0 !important; }
.ticket-secondary .icon { width: 18px; height: 18px; }
.ticket-extras { padding-top: 10px; margin-top: 6px; }
.ticket-extras > summary { color: var(--ink-2); font-size: 13.5px; font-weight: 500; }
.mobile-charge { display: none; }

/* ---------- Ventanas ---------- */
dialog { width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 32px); padding: 26px 26px 22px; border: 0; border-radius: 18px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); overflow: auto; }
dialog::backdrop { background: rgba(19, 34, 30, .42); }
dialog h2 { font-size: 21px; margin: 0 44px 8px 0; }
dialog .close { position: absolute; top: 16px; right: 16px; width: 36px; min-height: 36px; border-color: transparent; background: var(--tint); }
dialog.sheet { margin: 0 0 0 auto; width: min(480px, 100%); height: 100dvh; max-height: 100dvh; border-radius: 18px 0 0 18px; padding: 26px 24px; }
@media (prefers-reduced-motion: no-preference) {
  dialog[open] { animation: rise .16s ease-out; }
  dialog.sheet[open] { animation: slide .2s ease-out; }
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes slide { from { transform: translateX(40px); opacity: .4; } }

.cash-hero { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 16px 18px; margin: 4px 0 6px; border-radius: 14px; background: var(--display); color: #9db4ac; }
.cash-hero strong { color: var(--amber); font-size: 30px; letter-spacing: -.02em; }
.closures { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }

.payment-title { margin-bottom: 4px; }
.pay-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 14px 0 18px; padding: 14px 16px; border-radius: 12px; background: var(--tint); }
.pay-heading strong, .pay-heading span { display: block; }
.pay-heading span { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.pay-heading .total { font-size: 32px; margin: 0; white-space: nowrap; }
.pay-methods { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 18px; }
.pay-methods button { flex-direction: column; align-items: flex-start; gap: 2px; min-height: 60px; padding: 10px 14px; text-align: left; white-space: normal; }
.pay-methods button strong { font-size: 15px; }
.pay-methods button small { color: var(--muted); font-weight: 400; }
.pay-methods button[aria-pressed=true] { border: 2px solid var(--primary); padding: 9px 13px; background: var(--primary-tint); }
.pay-methods button[aria-pressed=true] strong { color: var(--primary-strong); }
#received, #cash { font-size: 26px; font-weight: 600; min-height: 54px; }
.change-line, .credit-remainder { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 10px 0; color: var(--primary-strong); font-size: 14px; }
.change-line strong, .credit-remainder strong { font-size: 22px; }
.payment-note { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--warn-tint); color: var(--warn); font-size: 13.5px; }
.sample-request { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.sample-request summary { font-size: 13.5px; color: var(--ink-2); }
#finish-sale kbd { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .35); color: #fff; margin-left: 6px; }

.held-row { display: flex; align-items: center; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.held-row > div { flex: 1; min-width: 0; }
.held-row small { display: block; color: var(--muted); }
.recent-sale { display: flex; width: 100%; justify-content: space-between; gap: 12px; min-height: 0; padding: 12px 4px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; text-align: left; white-space: normal; }
.recent-sale:hover { background: var(--tint); }
.recent-sale strong, .recent-sale small { display: block; }
.recent-sale small { color: var(--muted); font-weight: 400; }
.account-head { align-items: flex-start; flex-wrap: wrap; margin: 12px 0 16px; }
.account-head label { margin: 0; }
.account-head .total { font-size: 32px; }
.product-picker.small { display: flex; flex-wrap: wrap; gap: 16px; margin: 0 0 14px; }
.product-picker.small label { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--ink); font-size: 15px; }
#return-preview { line-height: 1.7; }

.receipt { font-size: 14px; }
.receipt-kind { color: var(--muted); font-size: 12.5px; margin: 0 0 4px; }
.receipt h2 { margin-bottom: 8px; }
.receipt-line { border-top: 1px dashed var(--line-strong); padding-top: 10px; margin-top: 10px; }
.receipt-line table { margin: 6px 0; font-size: 13px; }
.receipt-line th, .receipt-line td { padding: 6px 4px; }
.receipt-line .hint { margin: 0; }
.receipt-total { border-top: 1px solid var(--ink); margin-top: 12px; padding-top: 8px; }
.receipt .total { font-size: 30px; }

/* ---------- Inventario, producción, tablero, compras ---------- */
.stock-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stock-card h2 { margin-bottom: 12px; }
.stock-items { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stock-item { padding: 12px 14px; border-radius: 12px; background: var(--tint); border: 1px solid var(--line); }
.stock-item label { margin: 0; color: var(--ink-2); }
.stock-item .metric { font-size: 25px; white-space: nowrap; margin: 2px 0 0; }
.stock-item small { color: var(--muted); }
.stock-item.negative { background: var(--danger-tint); border-color: #f0c9c3; }
.stock-item.negative .metric, .stock-item.negative small { color: var(--danger); }
.yield-card .metric, .yield-note .metric { color: var(--primary); font-size: 30px; }
.yield-live { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; margin-bottom: 14px; padding: 12px 14px; border-radius: 12px; background: var(--primary-tint); color: var(--primary-strong); }
.yield-live strong { font-size: 24px; }
.yield-live small { margin-left: auto; color: var(--ink-2); }

.record-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 18px; padding: 10px 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.record-bar > span { color: var(--muted); font-size: 13.5px; margin-right: 4px; }
.record-bar button { min-height: 38px; font-size: 14px; }
.pool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-bottom: 16px; }
.pool-card { display: flex; flex-direction: column; gap: 4px; }
.pool-card .row h2 { margin: 0; }
.pool-card > button { align-self: flex-start; margin-top: 10px; }
#production > .panel { margin-bottom: 14px; }

.dash-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.dash-grid > .panel { min-width: 0; }
.dash-wide { grid-column: span 2; }
.dash-grid h3 { margin: 12px 0 0; font-size: 13px; color: var(--muted); font-weight: 500; }
.chart { position: relative; }
.trend-chart { display: block; width: 100%; height: auto; margin-top: 4px; }
.trend-chart .bar { fill: #4e9c8a; }
.trend-chart .bar-today { fill: var(--primary); }
.trend-chart .hit { fill: transparent; }
.trend-chart g:hover .bar, .trend-chart g:focus .bar { fill: #3a8574; }
.trend-chart .bar-value { font: 600 12px var(--font); fill: var(--ink); }
.trend-chart .bar-label { font: 11px var(--font); fill: var(--muted); }
.trend-chart .axis { stroke: var(--line-strong); stroke-width: 1; }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; padding: 8px 10px; border-radius: 8px; background: var(--ink); color: #fff; font-size: 12.5px; line-height: 1.45; white-space: nowrap; transform: translate(-50%, calc(-100% - 8px)); }
.chart-tip strong { display: block; font-size: 14px; }
.cat-row { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 7px 0; font-size: 14px; }
.cat-bar { height: 10px; border-radius: 5px; background: var(--tint); overflow: hidden; }
.cat-bar i { display: block; height: 100%; width: 0; border-radius: 0 4px 4px 0; background: #4e9c8a; }
.roles-note { margin-top: 14px; }

/* ---------- Entrada ---------- */
#auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(440px, 100%); padding: 30px 28px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.auth-card .brand { padding: 0 0 26px; }
.auth-card .logo .icon { width: 24px; height: 24px; fill: #fff; stroke: #fff; stroke-width: 1; }
.auth-card h1 { font-size: 24px; margin-bottom: 6px; }
.auth-card form { margin: 18px 0 14px; }
.auth-card button.primary { min-height: 48px; font-size: 16px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; display: none; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px; background: var(--ink); color: #fff; font-size: 14.5px; box-shadow: var(--shadow); text-align: center; }

/* ---------- Pantallas medianas ---------- */
@media (max-width: 1180px) {
  #app { grid-template-columns: 204px minmax(0, 1fr); }
  .pos { grid-template-columns: minmax(0, 1fr) minmax(310px, 350px); }
  .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .segmented button { padding: 8px 18px; }
}

/* ---------- Teléfono y tableta: el menú se desliza desde la izquierda ---------- */
@media (max-width: 900px) {
  #app { display: block; }
  #sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(290px, 84vw); height: 100dvh; background: var(--canvas); transform: translateX(-102%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s; }
  #app.menu-open #sidebar { transform: none; visibility: visible; box-shadow: var(--shadow); transition: transform .2s ease; }
  #menu-button { display: inline-flex; border-color: transparent; background: var(--surface); }
  #workspace { padding: 0 16px 40px; }
  .topbar { margin: 0 -16px 14px; padding: 10px 16px; min-height: 60px; gap: 10px; }
  .topbar .date { display: none; }
  .pos { grid-template-columns: minmax(0, 1fr); }
  .ticket { position: static; }
  .ticket .ticket-total, .ticket > .charge-button { display: none; }
  .ticket-secondary { border-top: 1px dashed var(--line-strong) !important; padding-top: 10px; margin-top: 4px; }
  #sale { padding-bottom: 92px; }
  .mobile-charge { position: fixed; left: 0; right: 0; bottom: 0; z-index: 22; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -10px 30px rgba(19, 34, 30, .1); }
  .mobile-charge small { display: block; color: var(--muted); font-size: 12.5px; }
  .mobile-charge strong { font-size: 26px; letter-spacing: -.02em; }
  .mobile-charge button { min-width: 150px; min-height: 52px; font-size: 18px; font-weight: 600; border-radius: 12px; }
  body[data-page=sale] #toast { bottom: 96px; }
  .shortcuts { display: none; }
  .layout, .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .dash-wide { grid-column: auto; }
}

@media (max-width: 640px) {
  body { font-size: 15.5px; }
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  #page-tools:empty { display: none; }
  .tool span, .chip .long { display: none; }
  .chip .short { display: inline; }
  .tool { padding: 6px 10px; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .capture, .ticket { padding: 16px; border-radius: 16px; }
  .segmented { display: flex; width: 100%; }
  .segmented button { flex: 1; padding: 8px 10px; }
  .scale { padding: 12px 16px 10px; }
  .scale-foot { flex-wrap: wrap; }
  .scale-foot input { width: 84px; }
  .capture-actions button { width: 100%; }
  .capture-actions .hint { display: none; }
  dialog { padding: 22px 18px 18px; width: calc(100% - 16px); }
  dialog.sheet { width: 100%; max-width: 100%; border-radius: 0; }
  .pay-heading .total { font-size: 26px; }
  .pay-methods button { padding: 9px 10px; }
  #finish-sale kbd, .charge-button kbd { display: none; }
  .filter-row .field { flex: 1 1 140px; }
  .filter-row input[type=date], .filter-row select, #history-q { min-width: 0; }
  .ledger-row { align-items: flex-start; }
  .alert { align-items: flex-start; }
  .cat-row { grid-template-columns: 90px minmax(0, 1fr) auto; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body:not([data-page=sale]) .topbar { position: static; }
  #page-tools { flex-wrap: nowrap; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  #page-tools > * { flex: none; }
  .kpis > * { padding: 14px 16px; }
  .metric { font-size: 23px; }
}

/* ---------- Impresión: solo el comprobante o el cierre ---------- */
@media print {
  body { background: #fff; }
  body > *:not(dialog) { display: none !important; }
  dialog, dialog.sheet { position: static; display: block; width: 100%; max-width: none; max-height: none; height: auto; margin: 0; padding: 0; box-shadow: none; border-radius: 0; }
  dialog .actions, dialog .close { display: none; }
  .receipt { max-width: 76mm; margin: auto; }
  .receipt th, .receipt td { padding: 4px 2px; font-size: 11px; }
  .cash-hero { background: none; color: #000; padding: 6px 0; }
  .cash-hero strong { color: #000; }
}

/* Avisos dentro de una ventana abierta */
.modal-msg { margin: 12px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--info-tint); color: var(--info); font-size: 14px; }
.modal-msg.error { background: var(--danger-tint); color: var(--danger); }

@media (max-width: 360px) {
  .mobile-charge strong { font-size: 21px; }
  .mobile-charge button { min-width: 0; flex: 1; max-width: 160px; }
  .topbar h1 { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  #sidebar { transition: none !important; }
}

/* Mostrador: la tanda de detalle abierta */
.counter { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 0 0 12px; padding: 10px 12px 10px 14px; border-radius: 12px; background: var(--tint); border: 1px solid var(--line); }
.counter > span { min-width: 0; flex: 1; }
.counter strong { display: block; font-size: 14.5px; }
.counter small { display: block; color: var(--muted); font-size: 12.5px; }
.counter.empty { border-style: dashed; }
.counter-bar { display: block; height: 6px; margin-top: 7px; border-radius: 3px; background: var(--line); overflow: hidden; }
.counter-bar b { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--primary); }
.counter.low .counter-bar b { background: #c98a12; }
.counter.low strong { color: var(--warn); }
.counter.over strong { color: var(--danger); }
.counter-note { display: block; margin-top: 2px; color: var(--primary-strong) !important; }
.loss-line { margin: 2px 0 14px; padding: 12px 14px; border-radius: 10px; background: var(--warn-tint); color: var(--warn); font-size: 14.5px; }
.loss-line strong { font-size: 17px; }
.loss-line.over { background: var(--danger-tint); color: var(--danger); }

/* ---------- Cosecha: la misma báscula de Vender ---------- */
.capture-title { margin: 0; font-size: 16px; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin-bottom: 10px; }
.choice-card { flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; min-height: 62px; padding: 10px 14px; text-align: left; white-space: normal; }
.choice-card strong { font-size: 15.5px; }
.choice-card small { color: var(--muted); font-weight: 400; }
.choice-card[aria-pressed=true] { border: 2px solid var(--primary); padding: 9px 13px; background: var(--primary-tint); }
.choice-card[aria-pressed=true] strong { color: var(--primary-strong); }
.choice-card.quiet { border-style: dashed; }
.choice-card.quiet[aria-pressed=true] { border-style: solid; }
.choice-grid + .hint { margin: -2px 0 12px; }
.choice-grid + .scale, .choice-grid + .hint + .scale { margin-top: 4px; }
.list-title { margin: 18px 0 8px; font-size: 14px; color: var(--ink-2); }
.basket-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
.basket { display: flex; align-items: center; gap: 6px; padding: 3px 3px 3px 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--tint); }
.basket .number { min-width: 16px; color: var(--muted); font-size: 12px; }
.basket strong { flex: 1; font-size: 15px; white-space: nowrap; }
.basket strong small { color: var(--muted); font-weight: 400; }
.basket .icon-button.small { width: 30px; min-height: 30px; border-color: transparent; background: transparent; }
.basket .icon-button.small:hover { background: var(--surface); border-color: var(--line); }
.basket .icon { width: 16px; height: 16px; }
.ticket-label { display: block; margin-bottom: 2px; color: var(--muted); font-size: 12.5px; font-weight: 500; }
#h-origin { display: block; font-size: 18px; }
#h-origin.muted { color: var(--muted); font-weight: 500; }
#h-origin-sub { display: block; margin-top: 2px; }
.field-note { margin: 6px 0 0; }
.stock-flow { margin: 4px 0 10px; padding: 10px 12px; border-radius: 10px; background: var(--primary-tint); color: var(--primary-strong); font-size: 13.5px; line-height: 1.5; }
.segmented.compact button { min-height: 38px; padding: 6px 14px; font-size: 14.5px; }
.ticket-secondary .hint { margin: 0; align-self: center; font-size: 12.5px; }
.harvest-recent { margin-top: 16px; }
.harvest-recent .row { flex-wrap: wrap; }
.harvest-recent .row .hint { margin: 0; }
.harvest-recent .ledger-row > div > strong { white-space: nowrap; }
.more-rows > summary { margin-top: 10px; color: var(--primary); font-size: 14px; }
.harvest-line { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 10px; margin: 0 0 6px; padding: 10px 12px; border-radius: 10px; background: var(--tint); border: 1px solid var(--line); color: var(--ink-2); font-size: 13.5px; }
.harvest-line .icon, .record-bar .icon { width: 17px; height: 17px; }
@media (max-width: 900px) {
  #harvest { padding-bottom: 92px; }
  body[data-page=harvest] #toast { bottom: 96px; }
}
@media (max-width: 640px) {
  .choice-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .basket-list { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .ticket-secondary { flex-wrap: wrap; }
}

/* ---------- Captura rápida en ventanas (0.7.4) ---------- */
fieldset.field { min-width: 0; margin: 0 0 14px; padding: 0; border: 0; }
fieldset.field > legend { margin-bottom: 6px; padding: 0; font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
.options { display: flex; flex-wrap: wrap; gap: 6px; }
.option { position: relative; margin: 0; font-weight: 400; }
.option input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.option span { display: flex; flex-direction: column; justify-content: center; min-height: 42px; padding: 7px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-size: 15px; font-weight: 600; line-height: 1.3; }
.option small { margin-top: 1px; color: var(--muted); font-size: 12.5px; font-weight: 400; }
.option:hover span { border-color: var(--primary); }
.option input:checked + span { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); background: var(--primary-tint); color: var(--primary-strong); }
.option input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.option input:disabled { cursor: not-allowed; }
.option input:disabled + span { opacity: .4; border-style: dashed; }
.options.cards .option { flex: 1 1 180px; }
.options.cards .option span { min-height: 58px; }
.form-more { margin: 2px 0 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--tint); }
.form-more > summary { color: var(--ink-2); font-size: 14px; font-weight: 500; }
.form-more[open] > summary { margin-bottom: 12px; }
.form-more > .field:last-child, .form-more > fieldset:last-child { margin-bottom: 2px; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.quick button { min-height: 32px; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 500; }
.quick button[hidden] { display: none; }
.input-unit { display: flex; align-items: stretch; }
.input-unit input { flex: 1; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-unit > span, .input-unit > select { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--tint); color: var(--ink-2); font-size: 14px; }
.input-unit > select { width: auto; min-height: 0; }
.daily-list { display: grid; gap: 6px; margin-bottom: 8px; }
.daily-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 150px; align-items: center; gap: 6px 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--tint); }
.daily-row:not(:has(select)) { grid-template-columns: minmax(0, 1fr) 150px; }
.daily-row:has(.count-diff) { grid-template-columns: minmax(0, 1fr) 150px 84px; }
.daily-name strong { display: block; font-size: 15px; }
.daily-name small { color: var(--muted); font-size: 12.5px; }
.daily-row select { min-height: 40px; max-width: 170px; font-size: 14px; }
.daily-value input { min-height: 42px; font-size: 17px; font-weight: 600; text-align: right; }
.count-diff { text-align: right; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.daily-total { min-height: 20px; margin: 4px 0 12px; font-size: 14px; font-weight: 500; color: var(--ink-2); }
@media (max-width: 640px) {
  .daily-row { grid-template-columns: minmax(0, 1fr) 128px; }
  .daily-row select { grid-column: 1 / -1; grid-row: 2; max-width: none; }
  .daily-row:has(.count-diff) { grid-template-columns: minmax(0, 1fr) 128px; }
  .daily-row .count-diff { grid-column: 1 / -1; }
  .options.cards .option { flex-basis: 100%; }
}
