/* Tokens del sistema Broadsheet usados por el diseño */
@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,wght@0,400;0,600;1,400&display=swap');

:root {
  --nav: calc(88px + env(safe-area-inset-bottom));
  --color-bg: #f3f2f2;
  --color-text: #201e1d;
  --color-accent: #0088b0;
  --color-neutral-100: #f8f4f4;
  --color-neutral-200: #eae7e7;
  --color-neutral-300: #d7d3d3;
  --color-neutral-500: #9b9797;
  --color-neutral-600: #7d7979;
  --color-neutral-700: #605d5d;
  --radius-md: 2px;
  --radius-lg: 4px;
  --shadow-sm: 0 1px 2px color-mix(in srgb, #2d2b2b 14%, transparent);
  --shadow-md: 0 3px 10px color-mix(in srgb, #2d2b2b 16%, transparent);
  --shadow-lg: 0 12px 32px color-mix(in srgb, #2d2b2b 22%, transparent);

  --berry: oklch(0.50 0.19 18);
  --berry-dark: oklch(0.42 0.17 15);
  --berry-ink: oklch(0.40 0.16 15);
  --berry-tint: oklch(0.95 0.03 18);
  --green: oklch(0.47 0.10 150);
  --green-dark: oklch(0.40 0.09 150);
  --green-ink: oklch(0.34 0.08 150);
  --green-text: oklch(0.42 0.10 150);
  --green-tint: oklch(0.94 0.045 150);
  --purple: oklch(0.40 0.12 310);
  --purple-dark: oklch(0.34 0.11 310);
  --purple-ink: oklch(0.36 0.11 310);
  --purple-tint: oklch(0.95 0.025 310);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--color-bg); color: var(--color-text);
  font-family: "Source Serif 4", system-ui, sans-serif; font-size: 15px; line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
}
button, input { font-family: inherit; color: inherit; }
button { cursor: pointer; border: none; }
button:active { filter: brightness(.92); }
input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
input::placeholder { color: var(--color-neutral-500); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--color-neutral-700); }

/* Pantalla */
#app { position: relative; height: 100dvh; max-width: 520px; margin: 0 auto; overflow: hidden; background: var(--color-bg); }
.scroll {
  position: absolute; top: 0; left: 0; right: 0; bottom: var(--nav); overflow-y: auto;
  padding: calc(env(safe-area-inset-top) + 16px) 20px 28px; display: flex; flex-direction: column; gap: 18px;
}
.scroll.sub { top: calc(env(safe-area-inset-top) + 60px); padding-top: 4px; gap: 22px; }
.scroll.no-nav { bottom: calc(var(--nav) + 104px); }
.topbar {
  position: absolute; top: env(safe-area-inset-top); left: 0; right: 0; height: 56px;
  padding: 0 12px; display: flex; align-items: center; gap: 6px;
}
.topbar .t { font-size: 26px; font-weight: 600; }
.back { width: 48px; height: 48px; background: transparent; font-size: 26px; display: flex; align-items: center; justify-content: center; }
.label { font-size: 15px; letter-spacing: .06em; text-transform: uppercase; color: var(--color-neutral-700); }
.stack { display: flex; flex-direction: column; }
.row { display: flex; }

/* Barra inferior */
.nav {
  position: absolute; z-index: 5; left: 0; right: 0; bottom: 0; height: var(--nav); padding-bottom: env(safe-area-inset-bottom); background: #fff;
  box-shadow: 0 -4px 18px rgba(32,30,29,.08); display: grid; grid-template-columns: repeat(5, 1fr);
  align-items: start; padding-top: 8px;
}
.nav button { background: transparent; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--color-neutral-700); font-size: 13px; }
.nav button i { font-size: 28px; }
.nav button.on { color: var(--berry-dark); font-weight: 600; }
.nav .fab { margin-top: -26px; }
.nav .fab span { width: 60px; height: 60px; border-radius: 50%; background: var(--berry); color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-md); }
.nav .fab span i { font-size: 30px; }

/* Tarjetas y botones */
.card { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.hero { box-shadow: var(--shadow-md); padding: 22px 20px; gap: 16px; }
.tile { border-radius: var(--radius-lg); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.tile .k { font-size: 15px; }
.tile .v { font-size: 24px; font-weight: 600; }
.btn { border-radius: var(--radius-lg); font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 10px; }
.btn-big { height: 76px; background: var(--berry); color: #fff; font-size: 24px; box-shadow: var(--shadow-md); }
.btn-big i { font-size: 32px; }
.btn-mid { height: 64px; font-size: 19px; }
.btn-mid i { font-size: 26px; }
.btn-save { width: 100%; height: 64px; color: #fff; font-size: 21px; box-shadow: var(--shadow-md); }
.btn-pay { height: 52px; font-size: 17px; gap: 8px; color: #fff; background: var(--purple); }
.btn-wa {
  height: 52px; border: 2px solid var(--green); border-radius: var(--radius-lg); background: #fff; color: oklch(0.38 0.09 150);
  font-size: 17px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.btn-wa:hover { background: var(--green-tint); }
.btn-wa i { font-size: 24px; }
.footer-save { position: absolute; left: 0; right: 0; bottom: var(--nav); padding: 14px 20px 14px; background: var(--color-bg); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

/* Chips seleccionables */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border-radius: var(--radius-lg); border: 2px solid transparent; background: #fff; font-weight: 600; text-align: left; }
.chip small { display: block; font-size: 13px; font-weight: 400; opacity: .85; }
.chip.c-client { min-height: 48px; padding: 6px 14px; font-size: 17px; line-height: 1.15; }
.chip.c-sup { min-height: 64px; padding: 8px 12px; font-size: 17px; line-height: 1.2; display: flex; flex-direction: column; justify-content: center; }
.chip.c-sup small { font-size: 14px; }
.chip.c-size { flex: 1; height: 52px; font-size: 18px; text-align: center; }
.chip.c-pay { height: 56px; font-size: 17px; text-align: center; }
.chip.c-cat { height: 96px; font-size: 19px; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.chip.c-cat i { font-size: 34px; }
.chip.on-berry { border-color: var(--berry); background: var(--berry-tint); color: oklch(0.36 0.15 15); }
.chip.on-green { border-color: var(--green); background: var(--green-tint); color: oklch(0.32 0.08 150); }
.chip.on-purple { border-color: var(--purple); background: var(--purple-tint); color: oklch(0.32 0.10 310); }

/* Campos */
.field { width: 100%; border: 2px solid var(--color-neutral-300); border-radius: var(--radius-lg); background: #fff; font-size: 18px; height: 52px; padding: 0 14px; }
.search { position: relative; }
.search i { position: absolute; left: 14px; top: 15px; font-size: 22px; color: var(--color-neutral-600); }
.search .field { padding-left: 46px; }
.result { min-height: 52px; padding: 8px 14px; border-radius: var(--radius-lg); background: #fff; font-size: 18px; text-align: left; display: flex; justify-content: space-between; align-items: center; width: 100%; margin-top: 10px; }
.result small { font-size: 14px; color: var(--color-neutral-700); }
.money { display: flex; align-items: center; background: #fff; border-radius: var(--radius-lg); gap: 4px; }
.money input { flex: 1; min-width: 0; border: none; background: transparent; padding: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.money.edit { height: 54px; padding: 0 12px; border: 2px solid var(--purple); }
.money.edit span { font-size: 20px; }
.money.edit input { font-size: 21px; }
.money.big { height: 76px; padding: 0 16px; border: 2px solid var(--color-neutral-300); gap: 6px; }
.money.big span { font-size: 32px; font-weight: 600; }
.money.big input { font-size: 40px; }
.quick { flex: 1; height: 48px; border-radius: var(--radius-lg); background: var(--color-neutral-200); font-size: 17px; }
.quick:active { background: var(--color-neutral-300); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; background: var(--color-neutral-200); border-radius: var(--radius-lg); }
.seg button { height: 50px; border-radius: var(--radius-md); background: transparent; font-size: 17px; font-weight: 600; }
.seg button.on { background: #fff; box-shadow: var(--shadow-sm); }

/* Venta */
.prod { background: #fff; border-radius: var(--radius-lg); border: 2px solid transparent; padding: 12px 12px 12px 14px; display: flex; align-items: center; gap: 10px; }
.prod.on { border-color: var(--berry); }
.prod .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.prod .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.prod .pname { font-size: 19px; font-weight: 600; }
.price { display: flex; align-items: center; height: 38px; padding: 0 8px; background: var(--color-neutral-100); border-radius: var(--radius-md); gap: 2px; }
.price input { width: 72px; border: none; background: transparent; font-size: 17px; font-weight: 600; padding: 0; font-variant-numeric: tabular-nums; }
.price i { font-size: 15px; color: var(--color-neutral-600); }
.price .cur { font-size: 16px; color: var(--color-neutral-700); }
.step { width: 48px; height: 48px; border-radius: var(--radius-lg); background: var(--color-neutral-200); font-size: 24px; display: flex; align-items: center; justify-content: center; }
.step.plus { background: var(--berry); color: #fff; }
.step[disabled] { opacity: .35; }
.qty { width: 34px; text-align: center; font-size: 26px; font-weight: 600; }
.venta-footer {
  position: absolute; left: 0; right: 0; bottom: var(--nav); background: #fff; box-shadow: 0 -6px 22px rgba(32,30,29,.10);
  padding: 14px 20px 14px; display: flex; flex-direction: column; gap: 12px;
}
.venta-footer .total { font-size: 42px; font-weight: 600; line-height: 1; }
.pay { height: 66px; font-size: 18px; flex-direction: column; gap: 2px; color: #fff; }
.pay i { font-size: 24px; }
.pay.debe { border: 2px solid var(--berry); background: #fff; color: var(--berry-dark); font-size: 16px; line-height: 1.1; }
.pay[disabled] { opacity: .4; }

/* Fruta */
.cajas { display: flex; align-items: center; justify-content: space-between; background: #fff; border-radius: var(--radius-lg); padding: 10px; }
.cajas .step { width: 64px; height: 64px; font-size: 30px; }
.cajas .step.plus { background: var(--green); }
.cajas .n { font-size: 56px; font-weight: 600; line-height: 1; }

/* Listas */
.mov { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.mov .n { font-size: 18px; font-weight: 600; }
.mov .s { font-size: 15px; color: var(--color-neutral-700); }
.mov .a { font-size: 19px; font-weight: 600; }
.bar { height: 8px; border-radius: 4px; background: var(--color-neutral-200); overflow: hidden; }
.bar div { height: 100%; background: var(--green); }
.chip-ok { font-size: 14px; padding: 4px 10px; border-radius: var(--radius-lg); background: var(--green-tint); color: var(--green-ink); font-weight: 600; white-space: nowrap; height: fit-content; }
.sum { display: flex; justify-content: space-between; }
.sum.total { padding-top: 12px; border-top: 3px solid var(--color-text); font-weight: 600; font-size: 21px; }
.weeknav { display: flex; align-items: center; justify-content: space-between; }
.weeknav button { width: 48px; height: 48px; border-radius: var(--radius-lg); background: var(--color-neutral-200); font-size: 22px; display: flex; align-items: center; justify-content: center; }
.weeknav button[disabled] { opacity: .4; }
.tip { display: flex; gap: 12px; align-items: flex-start; background: var(--green-tint); border-radius: var(--radius-lg); padding: 14px 16px; color: oklch(0.34 0.08 150); font-size: 17px; line-height: 1.35; }
.tip i { font-size: 30px; flex: none; }

/* Aviso: claro, sobre la barra de abajo y sin bloquear toques */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav) + 12px);
  width: min(480px, calc(100% - 40px)); background: var(--green-tint); color: var(--green-ink); border: 1px solid var(--green);
  border-radius: var(--radius-lg); padding: 12px 16px; font-size: 17px; display: flex; gap: 10px; align-items: center;
  box-shadow: var(--shadow-md); z-index: 10; pointer-events: none;
}
.toast[hidden] { display: none; }
.toast i { font-size: 24px; color: var(--green); flex: none; }
.toast.bad { background: var(--berry-tint); color: var(--berry-ink); border-color: var(--berry); }
.toast.bad i { color: var(--berry); }
@media (min-width: 521px) { #app { box-shadow: var(--shadow-lg); } }

/* Configuración */
.gear { width: 44px; height: 44px; border-radius: var(--radius-lg); background: #fff; box-shadow: var(--shadow-sm); font-size: 26px; display: flex; align-items: center; justify-content: center; color: var(--color-neutral-700); }
.item { width: 100%; background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 14px 16px; display: flex; align-items: center; gap: 14px; text-align: left; }
.item .lead { font-size: 30px; color: var(--berry-dark); flex: none; }
.item .chev { font-size: 20px; color: var(--color-neutral-600); flex: none; }
.item .t { font-size: 19px; font-weight: 600; }
.item .s { font-size: 14px; color: var(--color-neutral-700); line-height: 1.35; }
.tagx { font-size: 12px; padding: 2px 8px; border-radius: var(--radius-md); background: var(--color-neutral-200); color: var(--color-neutral-700); flex: none; }
.hint { font-size: 14px; color: var(--color-neutral-700); line-height: 1.4; }
.field.pin { font-size: 28px; letter-spacing: .3em; text-align: center; height: 64px; }

/* Pedidos y facturas */
.days { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.daychip { position: relative; flex: none; width: 62px; height: 66px; border-radius: var(--radius-lg); background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; border: 2px solid transparent; }
.daychip .d1 { font-size: 13px; color: var(--color-neutral-700); }
.daychip .d2 { font-size: 22px; font-weight: 600; line-height: 1.1; }
.daychip.on { background: var(--berry-tint); border-color: var(--berry); }
.daychip .badge { position: absolute; top: -6px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--berry); color: #fff; font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.inv { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-md); background: var(--color-neutral-100); border: 2px solid transparent; }
.inv.on { border-color: var(--green); background: var(--green-tint); }
.inv > i { font-size: 26px; color: var(--green); flex: none; }
.inv .t { font-size: 17px; font-weight: 600; }
.inv .s { font-size: 14px; }
.inv .a { font-size: 18px; font-weight: 600; }

/* Reportes */
.rbar { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.rbar .l { width: 62px; flex: none; color: var(--color-neutral-700); }
.rbar .track { flex: 1; height: 14px; border-radius: 3px; background: var(--color-neutral-200); overflow: hidden; }
.rbar .fill { height: 100%; background: var(--green); min-width: 2px; }
.rbar .fill.neg { background: var(--berry); }
.rbar .v { width: 92px; flex: none; text-align: right; font-weight: 600; }

/* Selector de clientes */
.pick-btn { width: 100%; min-height: 56px; padding: 8px 14px; background: #fff; border: 2px solid var(--color-neutral-300); border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; }
.pick-btn.open { border-color: var(--berry); }
.pick-btn .t { font-size: 19px; font-weight: 600; }
.pick-btn .s { font-size: 14px; color: var(--color-neutral-700); }
.pick-btn > i { font-size: 22px; color: var(--color-neutral-600); flex: none; }
.pick-panel { margin-top: 8px; background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.pick-list { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.pick-list .result { margin-top: 0; background: var(--color-neutral-100); }
