/* Infladle · estilo "Ticket de súper"
   Layout: en el celu, una sola pantalla (ticket que se imprime arriba, posnet abajo).
   Desde 900px de ancho, dos columnas: ticket a la izquierda y posnet a la derecha. */
:root {
  --counter: #D3D7DB;
  --device: #E6E9EC;
  --device-ink: #1B1D20;
  --device-muted: #5D636B;
  --device-line: #C9CED4;
  --slot: #1B1D20;
  --paper: #FFFFFF;
  --paper-ink: #1E1F21;
  --paper-muted: #6B6E73;
  --key: #FFFFFF;
  --key-ink: #1B1D20;
  --key-shadow: #AEB4BB;
  --lcd: #A8B697;
  --lcd-ink: #1E2A16;
  --lcd-frame: #2A2E33;
  --frio: #2F6DB5;
  --frio-ink: #FFFFFF;
  --tibio: #F2C230;
  --caliente: #EE7B2E;
  --clavado: #22A05C;
  --sem-ink: #1E1F21;
  --red: #C42D2D;
  --red-shadow: #7E1A1A;
  --yellow: #F2C230;
  --yellow-shadow: #A07F12;
  --green: #177A44;
  --green-shadow: #0B4526;
  --on-color: #FFFFFF;
  --stamp-win: #177A44;
  --stamp-lose: #C42D2D;
  --shadow: rgba(20, 22, 25, 0.35);
  --scrim: rgba(10, 11, 13, 0.55);
  --mono: "Martian Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --lcd-font: "VT323", ui-monospace, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --counter: #0C0D0F;
    --device: #1A1C20;
    --device-ink: #ECEDEF;
    --device-muted: #8B9097;
    --device-line: #2E3238;
    --slot: #000000;
    --paper: #DAD8D0;
    --paper-ink: #18191B;
    --paper-muted: #55575B;
    --key: #2C3036;
    --key-ink: #ECEDEF;
    --key-shadow: #000000;
    --lcd: #93A283;
    --lcd-ink: #16200F;
    --lcd-frame: #000000;
    --stamp-win: #0F6A38;
    --stamp-lose: #A92424;
    --shadow: rgba(0, 0, 0, 0.6);
    --scrim: rgba(0, 0, 0, 0.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --counter: #0C0D0F;
  --device: #1A1C20;
  --device-ink: #ECEDEF;
  --device-muted: #8B9097;
  --device-line: #2E3238;
  --slot: #000000;
  --paper: #DAD8D0;
  --paper-ink: #18191B;
  --paper-muted: #55575B;
  --key: #2C3036;
  --key-ink: #ECEDEF;
  --key-shadow: #000000;
  --lcd: #93A283;
  --lcd-ink: #16200F;
  --lcd-frame: #000000;
  --stamp-win: #0F6A38;
  --stamp-lose: #A92424;
  --shadow: rgba(0, 0, 0, 0.6);
  --scrim: rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body {
  height: 100%;
  margin: 0;
  background: var(--device);
  color: var(--device-ink);
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
a { color: inherit; text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--frio); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Estructura (celu primero) ---------- */
.app {
  height: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding-inline: 16px;
  padding-block: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.brand { flex: 1 1 0; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.logo { margin: 0; font: 800 1.15rem/1.1 var(--mono); letter-spacing: 0.06em; }
.sub { margin: 0; font-size: 0.6rem; letter-spacing: 0.1em; color: var(--device-muted); text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tools { display: flex; gap: 6px; }
.modes {
  order: 3;
  flex-basis: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.modes button {
  height: 34px;
  border-radius: 8px;
  border: 1.5px solid var(--device-muted);
  background: transparent;
  color: var(--device-ink);
  font: 600 0.7rem var(--mono);
  letter-spacing: 0.08em;
  cursor: pointer;
}
.modes button[aria-pressed="true"] { background: var(--device-ink); color: var(--device); border-color: var(--device-ink); }

.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; }

/* ---------- Teclas ---------- */
.key {
  border: 0;
  border-radius: 10px;
  background: var(--key);
  color: var(--key-ink);
  box-shadow: 0 3px 0 var(--key-shadow);
  font: 600 1.25rem var(--mono);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}
.key:active, .key.pressed { transform: translateY(2px); box-shadow: 0 1px 0 var(--key-shadow); }
.key:disabled { opacity: 0.45; cursor: default; transform: none; }
.icon { width: 44px; height: 44px; display: grid; place-items: center; font-size: 0.95rem; font-weight: 800; }
.icon svg { width: 18px; height: 18px; }
.k-red { background: var(--red); color: var(--on-color); box-shadow: 0 3px 0 var(--red-shadow); }
.k-yellow { background: var(--yellow); color: var(--sem-ink); box-shadow: 0 3px 0 var(--yellow-shadow); }
.k-green { background: var(--green); color: var(--on-color); box-shadow: 0 3px 0 var(--green-shadow); }
.k-red:active, .k-red.pressed { box-shadow: 0 1px 0 var(--red-shadow); }
.k-yellow:active, .k-yellow.pressed { box-shadow: 0 1px 0 var(--yellow-shadow); }
.k-green:active, .k-green.pressed { box-shadow: 0 1px 0 var(--green-shadow); }
.k-fn { font-size: 0.62rem; font-weight: 800; letter-spacing: 0.06em; }
.k-go { font-size: 0.85rem; font-weight: 800; letter-spacing: 0.08em; }
.k-wide { grid-column: span 2; }

/* ---------- Impresora y ticket ---------- */
.printer { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.slot { position: relative; z-index: 2; flex-shrink: 0; height: 9px; border-radius: 5px; background: var(--slot); }
.paper-scroll {
  flex: 1;
  min-height: 0;
  margin-top: -4px;
  padding-inline: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.paper {
  background: var(--paper);
  color: var(--paper-ink);
  padding: 14px 16px 10px;
  font-size: 0.72rem;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.tear {
  height: 10px;
  background:
    linear-gradient(-45deg, transparent 6px, var(--paper) 0),
    linear-gradient(45deg, transparent 6px, var(--paper) 0);
  background-size: 12px 12px;
  background-repeat: repeat-x;
  background-position: left bottom;
}
.r-title { text-align: center; font: 800 0.95rem/1.3 var(--mono); letter-spacing: 0.12em; }
.r-center { text-align: center; }
.r-small { font-size: 0.6rem; letter-spacing: 0.06em; color: var(--paper-muted); }
.r-rule { border-top: 1.5px dashed var(--paper-muted); margin: 5px 0; }
.r-head { position: sticky; top: 0; z-index: 1; background: var(--paper); padding-top: 4px; margin-top: -4px; display: flex; flex-direction: column; gap: 3px; }
.r-item { font-weight: 800; font-size: 0.78rem; text-wrap: balance; }
.r-indent { padding-left: 1.6em; font-size: 0.64rem; }
.r-muted { color: var(--paper-muted); }
.r-line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto 4.8em;
  align-items: center;
  gap: 8px;
  min-height: 21px;
}
.r-line .n { color: var(--paper-muted); }
.r-line .v { text-align: right; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.r-line .d { text-align: right; font-weight: 800; white-space: nowrap; }
.r-line.empty .v { color: var(--paper-muted); letter-spacing: 0.25em; }
.chip { padding: 1px 6px; font-size: 0.56rem; font-weight: 800; letter-spacing: 0.08em; white-space: nowrap; }
.t-frio { background: var(--frio); color: var(--frio-ink); }
.t-tibio { background: var(--tibio); color: var(--sem-ink); }
.t-caliente { background: var(--caliente); color: var(--sem-ink); }
.t-clavado { background: var(--clavado); color: var(--sem-ink); }
.r-hint { font-size: 0.64rem; font-weight: 600; }
.r-total { position: relative; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: 2px; }
.r-total b { font: 800 1rem var(--mono); }
.r-total strong { font: 800 1.15rem var(--mono); font-variant-numeric: tabular-nums; }
.r-row { display: flex; justify-content: space-between; gap: 8px; font-size: 0.66rem; }
.r-big { font-size: 0.8rem; font-weight: 800; align-items: baseline; }
.r-big span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.stamp-row { display: flex; justify-content: center; padding: 10px 0 6px; }
.stamp {
  display: inline-block;
  border: 3px solid currentColor;
  border-radius: 6px;
  padding: 4px 10px;
  font: 800 0.9rem var(--mono);
  letter-spacing: 0.08em;
  white-space: nowrap;
  transform: rotate(-11deg);
  background: color-mix(in srgb, var(--paper) 85%, transparent);
  pointer-events: none;
}
.stamp.win { color: var(--stamp-win); }
.stamp.lose { color: var(--stamp-lose); }
.r-chart { margin: 4px 0 0; }
.r-chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.c-line { fill: none; stroke: var(--paper-ink); stroke-width: 2.5; stroke-linejoin: round; }
.c-pt { fill: var(--paper); stroke: var(--paper-ink); stroke-width: 1.5; }
.c-cur { fill: var(--paper-ink); }
.c-axis { stroke: var(--paper-muted); stroke-width: 1; stroke-dasharray: 3 4; }
.c-lbl { fill: var(--paper-muted); font: 500 11px var(--mono); }
.c-lbl.strong { fill: var(--paper-ink); font-weight: 800; font-size: 12px; }

/* ---------- Posnet ---------- */
.pos { flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; }
.lcd {
  height: 54px;
  border-radius: 8px;
  background: var(--lcd);
  border: 3px solid var(--lcd-frame);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px;
  color: var(--lcd-ink);
  font-family: var(--lcd-font);
}
.lcd-main { font-size: 2.4rem; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.lcd-side { font-size: 1.25rem; line-height: 1; white-space: nowrap; }
.caret { animation: blink 1s steps(1) infinite; }
.keypad { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.keypad .key { height: 46px; }
.after { display: flex; flex-direction: column; gap: 8px; }
.after-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.after .key { height: 48px; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.06em; padding: 0 8px; }
.sharebox {
  width: 100%;
  min-height: 8em;
  font: 400 0.8rem var(--mono);
  background: var(--paper);
  color: var(--paper-ink);
  border: 1px solid var(--device-line);
  border-radius: 6px;
  padding: 10px;
}
.pos-note { margin: 0; text-align: center; font-size: 0.6rem; color: var(--device-muted); }

/* ---------- Modales (también son tickets) ---------- */
.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px; background: var(--scrim); }
.modal {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: calc(100% - 32px);
  overflow: auto;
  background: var(--paper);
  color: var(--paper-ink);
  padding: 22px 20px 18px;
  font-size: 0.74rem;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 20px 40px -16px var(--shadow);
}
.modal h2 { margin: 0; font: 800 1rem var(--mono); letter-spacing: 0.1em; text-align: center; }
.modal p { margin: 0; }
.modal .close { position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; }
.modal .r-line { font-size: 0.7rem; }
.modal details summary { cursor: pointer; font-weight: 800; }
.modal ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; text-align: center; }
.kpis b { display: block; font: 800 1.4rem var(--mono); font-variant-numeric: tabular-nums; }
.kpis span { font-size: 0.56rem; letter-spacing: 0.06em; color: var(--paper-muted); }
.dist { display: grid; gap: 5px; }
.dist div { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 8px; align-items: center; font-weight: 600; }
.dist span { display: block; min-width: 2.2em; padding: 2px 8px; text-align: right; background: var(--paper-muted); color: var(--paper); font-variant-numeric: tabular-nums; }
.dist span.today { background: var(--clavado); color: var(--sem-ink); }
#global { display: flex; flex-direction: column; gap: 3px; }
#global:empty { display: none; }
#global-dist { display: grid; gap: 8px; }
#global-dist .dist span { min-width: 3.4em; }
.m-sub { margin: 0; font: 800 0.8rem var(--mono); letter-spacing: 0.1em; }

/* Interruptor del modo difícil */
.switch { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.switch-ui { position: relative; width: 46px; height: 26px; border-radius: 13px; background: var(--paper-muted); transition: background 0.15s ease; }
.switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--paper);
  transition: transform 0.15s ease;
}
.switch input:checked + .switch-ui { background: var(--green); }
.switch input:checked + .switch-ui::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-ui { outline: 3px solid var(--frio); outline-offset: 2px; }
.install { width: 100%; height: 46px; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em; }

/* Lista del archivo */
.modal .archive-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.archive-day {
  width: 100%;
  min-height: 44px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1.5px dashed var(--paper-muted);
  border-radius: 4px;
  background: transparent;
  color: var(--paper-ink);
  font: 600 0.7rem var(--mono);
  letter-spacing: 0.06em;
  text-align: left;
  cursor: pointer;
}
.archive-day:hover { border-style: solid; }
.archive-day .st { white-space: nowrap; font-weight: 800; }
.archive-day .st.ok { color: var(--stamp-win); }
.archive-day .st.ko { color: var(--stamp-lose); }
.archive-day .st.muted { color: var(--paper-muted); font-weight: 600; }

/* ---------- Animaciones ---------- */
.print { animation: print 0.4s steps(6, end) both; }
.stamp.show { animation: stamp-in 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) 0.35s both; }
.lcd.flash .lcd-main { animation: lcd-flash 0.25s steps(1) 3; }
@keyframes print { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes stamp-in {
  from { transform: rotate(-11deg) scale(2.4); opacity: 0; }
  to { transform: rotate(-11deg) scale(1); opacity: 1; }
}
@keyframes lcd-flash { 50% { opacity: 0; } }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .print, .stamp.show, .lcd.flash .lcd-main, .caret { animation: none; }
  .key { transition: none; }
}

/* ---------- Celus chicos ---------- */
@media (max-width: 359px) {
  .app { padding-inline: 10px; }
  .keypad .key { height: 42px; }
  .key { font-size: 1.1rem; }
  .k-fn { font-size: 0.54rem; }
  .tools { gap: 4px; }
  .icon { width: 40px; height: 40px; }
  .after .key { font-size: 0.6rem; letter-spacing: 0.03em; }
}
@media (max-height: 640px) and (max-width: 899px) {
  .app { gap: 8px; padding-block: 8px 10px; }
  .modes button { height: 30px; }
  .lcd { height: 46px; }
  .lcd-main { font-size: 2rem; }
  .keypad .key { height: 40px; }
}
/* Celu horizontal o pantallas muy bajas: la página scrollea en vez de apretar todo. */
@media (max-height: 520px) and (max-width: 899px) {
  .app { height: auto; min-height: 100%; }
  .paper-scroll { overflow: visible; }
  .r-head { position: static; }
}

/* ---------- Compu: dos columnas ---------- */
@media (min-width: 900px) {
  body { background: var(--counter); }
  .app { height: auto; min-height: 100%; max-width: 1040px; padding-inline: 24px; padding-block: 28px 48px; gap: 22px; }
  .logo { font-size: 1.75rem; }
  .sub { font-size: 0.7rem; }
  .modes { order: 0; flex-basis: auto; display: flex; margin-left: auto; }
  .modes button { height: 40px; padding: 0 18px; font-size: 0.75rem; }
  .stage { flex-direction: row; align-items: flex-start; justify-content: center; gap: 40px; }
  .printer { flex: 1 1 420px; max-width: 480px; }
  .paper-scroll { overflow: visible; padding-inline: 14px; }
  .r-head { position: static; }
  .paper { font-size: 0.82rem; padding: 20px 22px 14px; box-shadow: 0 10px 24px -14px var(--shadow); }
  .r-title { font-size: 1.15rem; }
  .r-item { font-size: 0.9rem; }
  .r-big { font-size: 0.92rem; }
  .pos {
    position: sticky;
    top: 24px;
    flex: 1 1 340px;
    max-width: 400px;
    padding: 22px;
    border-radius: 28px;
    background: var(--device);
    box-shadow: 0 24px 40px -24px var(--shadow);
    gap: 14px;
  }
  .lcd { height: 64px; }
  .lcd-main { font-size: 2.8rem; }
  .keypad { gap: 8px; }
  .keypad .key { height: 54px; }
}
