/* Layout: app móvil de una columna; cámara arriba, barra de pestañas fija abajo.
   Identidad: tinta de mar profundo + amarillo de sombrero de paja como único acento. */
:root {
  --bg: #eef3f5;
  --surface: #ffffff;
  --surface-2: #e2eaee;
  --line: #c9d6dd;
  --fg: #0c1a24;
  --muted: #557080;
  --accent: #c98a00;
  --accent-ink: #1a1200;
  --accent-soft: #f7e4b5;
  --ok: #148a5b;
  --warn: #b25b00;
  --danger: #c4323a;
  --stage: #071118;

  --f-display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --r: 10px;
  --tabs-h: 60px;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1a24;
    --surface: #132634;
    --surface-2: #1b3242;
    --line: #26414f;
    --fg: #e6eef2;
    --muted: #8ea7b5;
    --accent: #f2b233;
    --accent-ink: #1a1200;
    --accent-soft: #3a2f12;
    --ok: #3ccf8e;
    --warn: #f0a04b;
    --danger: #ff6b6f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
/* Sin zoom por doble toque ni demora al tocar; los campos a 16px para que iPhone no haga zoom al enfocarlos */
html, body { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button, a, label, input, select, textarea { touch-action: manipulation; }
input, select, textarea { font-size: 16px !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 var(--f-body);
  -webkit-text-size-adjust: 100%;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px));
  min-height: 100dvh;
}
img { max-width: 100%; }
[hidden] { display: none !important; }
.mono { font-family: var(--f-mono); }
h2 { font: 800 1.35rem/1.1 var(--f-display); letter-spacing: .02em; text-transform: uppercase; margin: 0; text-wrap: balance; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) var(--gutter-r) 10px var(--gutter-l);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 22px; height: 30px; border-radius: 3px; flex: none;
  background: linear-gradient(180deg, transparent 78%, var(--accent) 78%, var(--accent) 92%, transparent 92%), var(--fg);
}
.brand-name { font: 800 1.5rem/1 var(--f-display); letter-spacing: .03em; text-transform: uppercase; }
.user-btn { display: inline-flex; align-items: center; justify-content: center; padding: 0; }

main { padding: 14px var(--gutter-r) 20px var(--gutter-l); max-width: 720px; margin: 0 auto; }
.view { display: flex; flex-direction: column; gap: 16px; }

/* ---------- botones e inputs ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--fg);
  font: 600 .95rem/1 var(--f-body); padding: 12px 16px; border-radius: var(--r);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-lg { font-size: 1.05rem; padding: 15px 20px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.input {
  width: 100%; min-width: 0; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); color: var(--fg); font: 500 1rem var(--f-body);
}
.input.mono { font-family: var(--f-mono); letter-spacing: .02em; }
.select { appearance: auto; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--fg); font-size: 1rem; cursor: pointer; flex: none;
}

/* ---------- escenario de cámara ---------- */
.stage {
  position: relative; overflow: hidden; border-radius: 14px;
  background: var(--stage); aspect-ratio: 1 / 1; max-height: 56dvh; width: 100%;
  margin-inline: auto;
}
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* Con la cámara apagada el video se oculta: Android e iPhone dibujan un botón de play sobre un video vacío. */
.stage:not(.live) video { visibility: hidden; }
.stage-idle {
  position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; gap: 12px;
  padding: 24px; color: #e6eef2;
}
.idle-title { font: 800 1.6rem/1 var(--f-display); text-transform: uppercase; letter-spacing: .03em; margin: 0; }
.idle-text { margin: 0; max-width: 34ch; color: #a9bdc8; }
.idle-warn { margin: 0; max-width: 36ch; color: #ffb4a8; font-size: .9rem; }

.guide {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; pointer-events: none; z-index: 2;
}
.stage:not(.live) .guide { display: none; }
/* Franja inferior de la carta: ~63 × 21 mm (nombre arriba, código y rareza abajo a la derecha) */
.guide-strip {
  position: relative; width: 90%; aspect-ratio: 3 / 1; max-height: 70%;
  border: 2px solid #f2b233; border-radius: 6px;
  box-shadow: 0 0 0 100vmax rgba(4, 10, 15, .5);
  display: flex; flex-direction: column; justify-content: space-between; padding: 8px 10px;
}
.guide-strip span { font: 700 .66rem/1 var(--f-mono); color: rgba(242,178,51,.85); text-transform: uppercase; letter-spacing: .1em; }
.gs-name { align-self: center; margin-top: 18%; }
.gs-code { align-self: flex-end; }
.guide-tip { margin: 0; font: 600 .78rem var(--f-body); color: #e6eef2; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.stage.hit .guide-strip { border-color: #3ccf8e; background: rgba(60,207,142,.15); }

.stage-status {
  position: absolute; top: 10px; left: 10px; right: 10px; z-index: 4; text-align: center;
  font: 600 .82rem/1.2 var(--f-mono); color: #e6eef2;
}
.stage-status:empty { display: none; }
.stage-status > span { display: inline-block; background: rgba(4,10,15,.7); padding: 6px 10px; border-radius: 99px; }

.stage-controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 4;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 14px; background: linear-gradient(transparent, rgba(4,10,15,.8));
}
.chip-btn {
  min-height: 38px; padding: 8px 12px; border-radius: 99px; border: 1px solid rgba(255,255,255,.35);
  background: rgba(4,10,15,.55); color: #e6eef2; font: 600 .82rem var(--f-body); cursor: pointer;
}
.chip-btn.is-on { background: #f2b233; color: #1a1200; border-color: #f2b233; }
.switch { display: inline-flex; align-items: center; gap: 6px; color: #e6eef2; font: 600 .82rem var(--f-body);
  background: rgba(4,10,15,.55); border: 1px solid rgba(255,255,255,.35); border-radius: 99px; padding: 8px 12px; min-height: 38px; }
.switch input { accent-color: #f2b233; width: 18px; height: 18px; margin: 0; }
.shutter {
  width: 64px; height: 64px; border-radius: 99px; padding: 0; min-height: 0;
  border: 4px solid rgba(255,255,255,.9); box-shadow: 0 0 0 2px rgba(0,0,0,.25);
}
.shutter.busy { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.92); opacity: .8; } }

/* ---------- entrada manual ---------- */
.manual { display: flex; flex-direction: column; gap: 6px; }
.manual-label { font-size: .85rem; color: var(--muted); }
.manual-row { display: flex; gap: 8px; }
.manual-row .input { flex: 1; text-transform: uppercase; }

/* ---------- sesión ---------- */
.session-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.session-count { font: 600 .85rem var(--f-mono); color: var(--muted); }
.session-list, .inv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.session-list:empty::before { content: "Las cartas que agregues aparecerán aquí."; color: var(--muted); font-size: .9rem; }

/* fila de carta compartida */
.row {
  display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px 8px 8px;
}
.row img { width: 48px; height: 67px; object-fit: cover; border-radius: 4px; background: var(--surface-2); display: block; }
.row-main { min-width: 0; }
.row-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-name-btn {
  display: block; max-width: 100%; padding: 0; border: 0; background: none; color: inherit; font: 600 1rem var(--f-body);
  text-align: left; cursor: pointer; text-decoration: underline dotted var(--muted); text-underline-offset: 3px;
}
.row-sub { font: 500 .78rem/1.4 var(--f-mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tag { font: 700 .66rem/1 var(--f-mono); letter-spacing: .05em; padding: 4px 6px; border-radius: 4px; background: var(--surface-2); color: var(--fg); text-transform: uppercase; }
.tag.single { background: var(--accent-soft); color: var(--fg); }
.tag.var { border: 1px solid var(--accent); background: transparent; }
.tag-btn { border: 0; cursor: pointer; font: 700 .66rem/1 var(--f-mono); min-height: 0; }
.tag.manual { outline: 1.5px dashed var(--accent); outline-offset: -1.5px; }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.row-price { font: 700 .95rem var(--f-mono); font-variant-numeric: tabular-nums; background: none; border: 0; color: var(--fg); padding: 2px 0; cursor: pointer; text-decoration: underline dotted var(--muted); text-underline-offset: 3px; }
.row-price-in { width: 110px; min-height: 34px; padding: 4px 8px; font: 600 .9rem var(--f-mono); text-align: right; }
.row-ctrl { display: flex; align-items: center; gap: 4px; }
.mini {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--fg); font: 600 1rem var(--f-body); cursor: pointer; padding: 0;
}
.mini.del { color: var(--danger); }
.qty { min-width: 26px; text-align: center; font: 700 .9rem var(--f-mono); font-variant-numeric: tabular-nums; }

/* ---------- inventario ---------- */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 560px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; min-width: 0; }
.stat-k { font: 600 .7rem var(--f-body); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.stat-v { font: 800 1.5rem/1.1 var(--f-display); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inv-tools { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
@media (min-width: 560px) { .inv-tools { grid-template-columns: minmax(0, 1fr) auto 150px; } }
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.seg-btn { flex: 1; min-height: 44px; border: 0; background: none; color: var(--fg); font: 600 .9rem var(--f-body); padding: 0 14px; cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn.is-on { background: var(--fg); color: var(--bg); }
.inv-empty { text-align: center; color: var(--muted); padding: 24px 8px; }
.inv-empty .idle-title { color: var(--fg); }
.inv-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.inv-actions .btn { flex: 1 1 150px; }

/* ---------- ajustes ---------- */
.settings { display: flex; flex-direction: column; gap: 16px; }
fieldset { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px 14px; margin: 0; background: var(--surface); display: flex; flex-direction: column; gap: 14px; min-width: 0; }
legend { font: 800 1.1rem var(--f-display); text-transform: uppercase; letter-spacing: .04em; padding: 0 6px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 600; font-size: .9rem; }
.field small, .fine { color: var(--muted); font-size: .8rem; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); margin: 1px 0 0; flex: none; }
.catalog-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.catalog-card p { margin: 0; }

/* ---------- pestañas ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px));
  padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tab {
  border: 0; background: none; color: var(--muted); cursor: pointer;
  font: 800 .9rem var(--f-display); text-transform: uppercase; letter-spacing: .02em;
  display: flex; align-items: center; justify-content: center; position: relative; min-width: 0; padding: 0 2px; white-space: nowrap;
}
.tab.is-on { color: var(--fg); }
.tab[hidden] { display: none; }
/* Con la pestaña Pedidos (cuenta del dueño) son 5: letra un poco más pequeña en celulares */
@media (max-width: 480px) { .tabs:has(#tab-ped:not([hidden])) .tab { font-size: .74rem; letter-spacing: 0; } }
.tab.is-on::before { content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; background: var(--accent); border-radius: 0 0 3px 3px; }
.badge { position: absolute; top: 5px; right: 4px; font: 700 .62rem/1 var(--f-mono); background: var(--accent); color: var(--accent-ink); padding: 3px 5px; border-radius: 99px; }
.badge:empty, .badge[data-zero] { display: none; }

/* ---------- hoja de resultado ---------- */
/* Fondo bloqueado mientras hay una hoja o la vista ampliada abierta (ver lockScroll en app.js) */
body.scroll-locked { position: fixed; left: 0; right: 0; width: 100%; overflow: hidden; }
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(4,10,15,.55); touch-action: none; overscroll-behavior: contain; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; margin: 0 auto; max-width: 720px;
  max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 18px 18px 0 0; border: 1px solid var(--line); border-bottom: 0;
  padding: 8px var(--gutter-r) calc(16px + env(safe-area-inset-bottom, 0px)) var(--gutter-l);
  display: flex; flex-direction: column; gap: 10px;
  animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: .4; } }
.sheet-grip { width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: 2px auto 4px; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sheet-head > div { min-width: 0; }
.sheet-code { margin: 0 0 2px; font-weight: 700; color: var(--accent); letter-spacing: .04em; }
.sheet-meta { margin: 4px 0 0; color: var(--muted); font-size: .88rem; }
.sheet-label { margin: 0 0 6px; font: 600 .72rem var(--f-body); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; display: block; }
.sheet-hint { margin: 6px 0 0; color: var(--muted); font-size: .8rem; font-family: var(--f-mono); }
.sheet-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.variants { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; }
.variant {
  flex: none; width: 112px; scroll-snap-align: start; cursor: pointer;
  border: 2px solid var(--line); border-radius: 10px; padding: 4px; background: var(--surface-2);
  display: flex; flex-direction: column; gap: 4px; text-align: left; color: var(--fg); font: inherit;
}
.variant img { width: 100%; aspect-ratio: 63/88; object-fit: cover; border-radius: 6px; display: block; background: var(--bg); }
.variant-name { font: 600 .75rem/1.2 var(--f-body); padding: 0 2px; }
.variant-code { font: 700 .7rem/1.2 var(--f-mono); color: var(--accent); padding: 0 2px; }
.variant-price { font: 700 .75rem var(--f-mono); color: var(--muted); padding: 0 2px 2px; }
.variant.is-on { border-color: var(--accent); background: var(--accent-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 38px; min-width: 44px; padding: 6px 10px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--fg); font: 700 .85rem var(--f-mono);
}
.chip.is-on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; width: fit-content; }
.stepper button { width: 44px; height: 44px; border: 0; background: var(--surface-2); color: var(--fg); font-size: 1.3rem; cursor: pointer; }
.qty-in {
  width: 64px; height: 44px; border: 0; border-inline: 1px solid var(--line); background: var(--surface); color: var(--fg);
  text-align: center; font: 700 1.1rem var(--f-mono); font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield;
}
.qty-in::-webkit-outer-spin-button, .qty-in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 50; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabs-h) + 12px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 14px; max-width: calc(100% - 32px);
  background: var(--fg); color: var(--bg); padding: 12px 16px; border-radius: 12px; font-weight: 500;
  box-shadow: 0 8px 30px rgba(0,0,0,.25);
}
.toast-text { min-width: 0; display: flex; }
.toast-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast-text > :last-child { flex: none; white-space: pre; }
.toast button { flex: none;  background: none; border: 0; color: var(--accent); font: 700 .9rem var(--f-body); cursor: pointer; padding: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- buscar ---------- */
.find-bar {
  /* Pegada justo debajo de la cabecera (--topbar-h lo mide app.js) y de borde a borde, para que la lista
     no se vea pasar por encima ni por los lados. El margen negativo cubre el hueco de arriba de main. */
  position: sticky; top: var(--topbar-h, 56px); z-index: 10; background: var(--bg);
  margin: -14px calc(-1 * var(--gutter-r)) 0 calc(-1 * var(--gutter-l));
  padding: 14px var(--gutter-r) 8px var(--gutter-l);
}
.find-input { font: 600 1.1rem var(--f-mono); min-height: 52px; letter-spacing: .02em; }
.find-meta { margin: 0; color: var(--muted); font-size: .85rem; min-height: 1.2em; }
.find-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.hit-row {
  width: 100%; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 10px 6px 6px;
  color: var(--fg); font: inherit; cursor: pointer;
}
.hit-row:active { background: var(--surface-2); }
.hit-row img { width: 44px; height: 61px; object-fit: cover; border-radius: 4px; background: var(--surface-2); display: block; }
.hit-code { font: 700 .82rem var(--f-mono); color: var(--accent); }
.hit-code mark { background: var(--accent-soft); color: var(--fg); border-radius: 2px; }
.hit-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hit-sub { font: 500 .75rem var(--f-mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hit-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font: 700 .82rem var(--f-mono); font-variant-numeric: tabular-nums; }
.hit-own { font: 700 .66rem var(--f-mono); background: var(--fg); color: var(--bg); padding: 3px 6px; border-radius: 4px; text-transform: uppercase; }
.find-help { color: var(--muted); padding: 8px 2px; }
.find-help .idle-title { color: var(--fg); font-size: 1.3rem; margin-bottom: 8px; }
.find-help ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.find-help b { color: var(--fg); }

/* ---------- filtros ---------- */
.seg-help { margin: -6px 0 0; color: var(--muted); font-size: .8rem; }
.filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 560px) { .filters { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.filters .select.is-set { border-color: var(--accent); background: var(--accent-soft); }
.filter-sum { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; font-size: .88rem; }
.filter-sum span { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.link-btn { background: none; border: 0; color: var(--accent); font: 600 .88rem var(--f-body); cursor: pointer; padding: 6px 0; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- tasa ---------- */
.rate-box { border: 1px solid var(--line); border-radius: var(--r); padding: 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 6px; }
.rate-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.rate-k { font-weight: 600; font-size: .9rem; }
.rate-v { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.rate-src { margin: 0; color: var(--muted); font-size: .82rem; }
.rate-src.err { color: var(--danger); }
.rate-actions { display: flex; gap: 8px; }
.rate-actions .btn { min-height: 38px; padding: 8px 12px; font-size: .85rem; }
#manualRateField.is-off { opacity: .5; }
.row .qty-btn { background: none; border: 0; color: var(--fg); cursor: pointer; text-decoration: underline dotted var(--muted); text-underline-offset: 3px; padding: 0; }

/* ---------- miniatura tocable ---------- */
.thumb { padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 4px; display: block; }
.thumb img { display: block; }

/* ---------- vista ampliada de la carta ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 60; background: rgba(4, 10, 15, .97); touch-action: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: calc(56px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  animation: fade .18s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.viewer-close {
  position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); right: max(12px, env(safe-area-inset-right, 0px));
  width: 44px; height: 44px; border-radius: 99px; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.08);
  color: #fff; font-size: 1.1rem; cursor: pointer;
}
.viewer-scroll { max-width: 100%; max-height: 72dvh; overflow: hidden; border-radius: 14px; touch-action: none; }
.viewer-scroll img { visibility: visible !important; display: block; height: min(72dvh, calc((100vw - 32px) * 88 / 63)); width: auto; max-width: none; aspect-ratio: 63 / 88; object-fit: contain; cursor: pointer; background: #132634; }
.viewer-info { text-align: center; color: #e6eef2; max-width: 420px; }
.viewer-info p { margin: 0; }
.viewer-code { color: #f2b233; font-weight: 700; letter-spacing: .04em; }
.viewer-name { font: 800 1.5rem/1.15 var(--f-display); text-transform: uppercase; letter-spacing: .02em; margin-top: 2px !important; }
.viewer-meta { color: #a9bdc8; font-size: .88rem; margin-top: 4px !important; }
.viewer-tip { color: #6f8796; font-size: .75rem; margin-top: 8px !important; }

/* ---------- cuenta y nube (ESPEC-04) ---------- */
.cuenta-form { display: flex; flex-direction: column; gap: 14px; margin: 0; }
.cuenta-form > p { margin: 0; }
.cuenta-correo { display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.cuenta-acciones { display: flex; gap: 10px; flex-wrap: wrap; }
.cuenta-acciones .btn { flex: 1 1 140px; }
.cuenta-tienda { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 14px; }
.cuenta-tienda p { margin: 0; }
.cuenta-tienda .btn { align-self: flex-start; }
.cuenta-msg { margin: 0; color: var(--danger); }
.cuenta-msg:empty { display: none; }
.cuenta-msg.ok { color: var(--ok); }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--accent); font: 600 .9rem var(--f-body); cursor: pointer; align-self: flex-start; text-decoration: underline; text-underline-offset: 3px; }
.sync-dot { position: absolute; top: 8px; left: 10px; width: 8px; height: 8px; border-radius: 99px; background: var(--warn); }
.dlg { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--fg); padding: 18px; width: min(420px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgb(0 0 0 / .55); }
.dlg h2 { margin: 0 0 8px; font: 800 1.3rem var(--f-display); text-transform: uppercase; letter-spacing: .03em; }
.dlg p { margin: 0 0 16px; }
.dlg-botones { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Pedidos del dueño (ESPEC-08) ---------- */
.ped-filtros { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter-r)) 0 calc(-1 * var(--gutter-l)); padding: 2px var(--gutter-r) 4px var(--gutter-l); }
.ped-filtros::-webkit-scrollbar { display: none; }
.ped-filtro { flex: none; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); font: 600 .88rem var(--f-body); cursor: pointer; }
.ped-filtro.is-on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.ped-lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ped { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.ped.is-nuevo { border-color: var(--accent); }
.ped-cab { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px; background: none; border: 0; color: inherit; text-align: left; cursor: pointer; font: inherit; }
.ped-cab > span { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ped-cab strong { font-family: var(--f-mono); }
.ped-cab small { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ped-der { align-items: flex-end; flex: none; }
.ped-der b { font-family: var(--f-mono); }
.ped-estado { font: 600 .68rem var(--f-body); padding: 3px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.ped-estado.e-pagado { background: var(--accent); color: var(--accent-ink); }
.ped-estado.e-preparando, .ped-estado.e-listo, .ped-estado.e-enviado { background: var(--accent-soft); color: var(--fg); }
.ped-estado.e-entregado { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.ped-det { border-top: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 12px; font-size: .92rem; }
.ped-det[hidden] { display: none; }
.ped-det h3 { margin: 0 0 4px; font: 800 .95rem var(--f-display); text-transform: uppercase; letter-spacing: .04em; }
.ped-det p { margin: 0; }
.ped-det a { color: var(--accent); }
.ped-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ped-items li { display: flex; justify-content: space-between; gap: 10px; }
.ped-items small, .ped-hist small { display: block; color: var(--muted); font: 500 .74rem var(--f-mono); }
.ped-items b { font-family: var(--f-mono); white-space: nowrap; }
.ped-tot { display: flex; justify-content: space-between; font-weight: 700; border-top: 1px solid var(--line); padding-top: 6px; font-family: var(--f-mono); }
.ped-hist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ped-aviso { background: var(--accent-soft); border-radius: var(--r); padding: 10px 12px; }
.ped-acciones { display: flex; flex-direction: column; gap: 8px; }
.ped-acciones .fila { display: flex; gap: 8px; flex-wrap: wrap; }
.ped-acciones .fila .btn { flex: 1; min-width: 120px; }
.ped-peligro { color: var(--danger); border-color: var(--danger); background: transparent; }
.ped-envios[hidden] { display: none; }
.env-zona { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.env-zona strong { grid-column: 1 / -1; font-size: .9rem; }

/* ---------- Entrada del propietario (la app se ve solo con su sesión) ---------- */
html.bloqueada body > :not(.puerta):not(script) { display: none !important; }
html:not(.bloqueada) .puerta { display: none; }
.puerta { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; box-sizing: border-box; }
.puerta-caja { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 22px 18px; box-sizing: border-box; }
.puerta-titulo { margin: 0; font: 600 1.05rem/1.3 var(--f-body); color: var(--muted); }
.puerta-caja .cuenta-msg, .puerta-tienda { margin: 0; }
.puerta-tienda a { color: inherit; font-weight: 600; }
