/* ShopiMonster ventas — todos los colores viven aquí arriba */
@font-face {
  font-family: "Bricolage";
  src: url("/fonts/bricolage.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson";
  src: url("/fonts/atkinson-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson";
  src: url("/fonts/atkinson-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --paper: #F2EFF6;
  --card: #FFFFFF;
  --ink: #22192F;
  --muted: #6B6279;
  --line: #E1DAEA;
  --monster: #5326D9;
  --monster-dark: #3D18A8;
  --monster-soft: #ECE6FD;
  --kraft: #E7D5B8;
  --kraft-dark: #C9B08A;
  --owe: #C3245A;
  --owe-soft: #FBE7EE;
  --ok: #0C8257;
  --ok-soft: #E2F4EC;

  --display: "Bricolage", "Avenir Next", system-ui, sans-serif;
  --body: "Atkinson", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 12px;
  --tabbar-h: 68px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.45 var(--body);
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  -webkit-tap-highlight-color: transparent;
}
body.no-tabbar { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
body.no-tabbar .tabbar { display: none; }
body.logged-out .tabbar, body.logged-out .topbar .icon-btn { display: none; }

h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; letter-spacing: -0.01em; }
a { color: var(--monster); }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid var(--monster); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 8px) 14px 8px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.topbar h1 { font-size: 21px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand img { width: 30px; height: 30px; }
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: transparent; color: var(--ink); cursor: pointer; text-decoration: none;
}
.icon-btn:active { background: var(--line); }

main { max-width: 560px; margin: 0 auto; padding: 4px 16px 24px; outline: none; overflow-x: clip; }

/* ---------- barra inferior ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 0 4px env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 0 9px; color: var(--muted); text-decoration: none; font-size: 12.5px;
}
.tabbar a.active { color: var(--monster); font-weight: 700; }
.tabbar .tab-new { color: var(--ink); font-weight: 700; padding-top: 0; }
.tabbar .plus {
  display: grid; place-items: center; width: 54px; height: 54px; margin-top: -20px;
  border-radius: 18px; background: var(--monster); color: #fff;
  box-shadow: 0 6px 16px rgba(83, 38, 217, .35);
}
.tabbar .plus svg { width: 28px; height: 28px; stroke-width: 2.4; }

/* ---------- textos y secciones ---------- */
.hello { color: var(--muted); margin: 6px 0 2px; }
.owed { margin: 0 0 18px; }
.owed .amount { font-family: var(--display); font-size: clamp(44px, 13vw, 60px); font-weight: 800; line-height: 1; letter-spacing: -0.03em; }
.owed .amount.zero { color: var(--ok); }
.owed p { margin: 6px 0 0; color: var(--muted); }
.figures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 26px; }
.figures div { background: var(--card); padding: 12px 12px 10px; }
.figures b { display: block; font-family: var(--display); font-size: 19px; font-weight: 700; }
.figures span { font-size: 13.5px; color: var(--muted); line-height: 1.25; display: block; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 26px 0 10px; }
.section-head h2 { font-size: 20px; }
.section-head a { font-weight: 700; text-decoration: none; white-space: nowrap; }
.hint { color: var(--muted); font-size: 15px; margin: 4px 0 0; }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty img { width: 64px; margin: 0 auto 10px; opacity: .9; }
.empty .btn { margin-top: 14px; }

/* ---------- etiquetas (pedidos y artículos) ---------- */
.tags { display: grid; gap: 10px; filter: drop-shadow(0 0 .7px rgba(34, 25, 47, .5)) drop-shadow(0 2px 2px rgba(34, 25, 47, .05)); }
.tag {
  position: relative; display: grid; grid-template-columns: 24px 60px minmax(0, 1fr); gap: 0 12px; align-items: center;
  min-height: 84px; padding: 10px 14px 12px 0; background: var(--card); color: inherit; text-decoration: none;
  clip-path: polygon(16px 0, 100% 0, 100% 100%, 16px 100%, 0 calc(100% - 16px), 0 16px);
}
.tag-head { align-self: stretch; margin: -10px 0 -12px; background: var(--kraft); position: relative; }
.tag-head::after {
  content: ""; position: absolute; left: 7px; top: 50%; width: 10px; height: 10px; margin-top: -5px;
  border-radius: 50%; background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--kraft-dark);
}
.tag.is-owing .tag-head { background: var(--owe-soft); }
.tag.is-owing .tag-head::after { box-shadow: inset 0 0 0 1.5px var(--owe); }
.tag.is-paid .tag-head { background: var(--ok-soft); }
.tag.is-paid .tag-head::after { box-shadow: inset 0 0 0 1.5px var(--ok); }
.tag.is-cancelled { opacity: .55; }
.thumb {
  width: 60px; height: 60px; border-radius: 8px; overflow: hidden; background: var(--monster-soft);
  display: grid; place-items: center; color: var(--monster); font-family: var(--display); font-weight: 700; font-size: 20px;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.tag-body { min-width: 0; display: grid; gap: 1px; }
.tag-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.tag-name { min-width: 0; font-family: var(--display); font-size: 17.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag-date { font-size: 14px; color: var(--muted); white-space: nowrap; }
.tag-items { font-size: 15px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 8px; margin-top: 3px; font-size: 15px; }
.state { font-size: 13.5px; padding: 1px 8px; border-radius: 999px; background: var(--paper); color: var(--muted); white-space: nowrap; }
.due { font-weight: 700; white-space: nowrap; }
.due.owe { color: var(--owe); }
.due.ok { color: var(--ok); }
.meter { position: relative; height: 4px; border-radius: 2px; background: var(--line); margin-top: 7px; }
.meter i { position: absolute; inset: 0 auto 0 0; border-radius: 2px; background: var(--ok); }
.meter b { position: absolute; top: -3px; width: 2px; height: 10px; background: var(--ink); border-radius: 1px; }
.meter.big { height: 8px; border-radius: 4px; margin-top: 12px; }
.meter.big b { top: -4px; height: 16px; }
.badge-missing { display: inline-block; white-space: nowrap; font-size: 13.5px; font-weight: 700; color: var(--owe); background: var(--owe-soft); padding: 1px 8px; border-radius: 999px; }

/* artículos dentro de un pedido */
.tag.item { grid-template-columns: 24px 72px minmax(0, 1fr); min-height: 96px; }
.tag.item .thumb { width: 72px; height: 72px; cursor: zoom-in; }
.tag.item .price { font-family: var(--display); font-weight: 700; font-size: 17.5px; white-space: nowrap; }
.tag.item .cost { font-size: 14px; color: var(--muted); }
.tag-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* ---------- botones y campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 0; cursor: pointer;
  background: var(--monster); color: #fff; font-weight: 700; text-decoration: none; font-size: 17px;
}
.btn:active { background: var(--monster-dark); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.secondary { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.secondary:active { background: var(--paper); }
.btn.whatsapp { background: #128C4B; }
.btn.whatsapp:active { background: #0D6E3A; }
.btn.danger { background: transparent; color: var(--owe); box-shadow: inset 0 0 0 1.5px var(--owe-soft); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 15px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn svg { width: 20px; height: 20px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.btn-row .btn { flex: 1 1 auto; }
.link-btn { background: none; border: 0; padding: 6px 0; color: var(--monster); font-weight: 700; cursor: pointer; }

.field { display: grid; gap: 4px; margin: 0 0 12px; }
.field > span, .label { font-size: 14.5px; color: var(--muted); font-weight: 700; }
.input, input:not([type]), input[type="text"], input[type="tel"], input[type="search"], input[type="password"], input[type="date"], input[type="number"], textarea, select {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--card); font-size: 17px;
}
textarea { min-height: 76px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--monster); outline: none; }
.money-input { position: relative; display: block; min-width: 0; }
.money-input::before {
  content: attr(data-prefix); position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 15px; pointer-events: none;
}
.money-input input { padding-left: calc(14px + var(--prefix-w, 1ch)); text-align: right; font-variant-numeric: tabular-nums; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid-2 > *, .grid-3 > * { min-width: 0; }
input, textarea, select { min-width: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 6px 14px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--card); cursor: pointer; font-size: 15.5px; line-height: 1.15; text-align: center;
}
.chip small { display: block; font-size: 13px; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--monster); border-color: var(--monster); color: #fff; font-weight: 700; }
.chip[aria-pressed="true"] small { color: #E5DCFF; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 6px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chips.scroll .chip { flex: none; }

/* ---------- bloques ---------- */
.panel { background: var(--card); border-radius: var(--radius); padding: 14px; margin: 0 0 12px; box-shadow: 0 0 0 1px var(--line); }
.panel h2 { font-size: 18px; margin-bottom: 10px; }
.panel h2.with-action { display: flex; justify-content: space-between; align-items: center; }
details.more > summary { list-style: none; cursor: pointer; color: var(--monster); font-weight: 700; padding: 8px 0; }
details.more > summary::-webkit-details-marker { display: none; }
details.more[open] > summary { margin-bottom: 8px; }

/* ---------- nueva venta ---------- */
.picker { position: relative; }
.picker-results { position: absolute; z-index: 15; left: 0; right: 0; top: calc(100% + 4px); background: var(--card); border-radius: 12px; box-shadow: 0 0 0 1px var(--line), 0 12px 28px rgba(34, 25, 47, .14); overflow: hidden; }
.picker-results button { display: flex; width: 100%; justify-content: space-between; gap: 10px; padding: 12px 14px; border: 0; background: none; text-align: left; cursor: pointer; border-bottom: 1px solid var(--line); }
.picker-results button:last-child { border-bottom: 0; }
.picker-results button:active, .picker-results button:focus-visible { background: var(--monster-soft); }
.picker-results .sub { color: var(--muted); font-size: 14.5px; }
.picker-results .new { color: var(--monster); font-weight: 700; }
.chosen { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--monster-soft); }
.chosen .who { flex: 1; min-width: 0; }
.chosen .who b { font-family: var(--display); font-size: 18px; display: block; }
.chosen .who span { font-size: 14.5px; color: var(--muted); }
.chosen .who span.owe { color: var(--owe); font-weight: 700; }

.item-block { background: var(--card); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; box-shadow: 0 0 0 1px var(--line); }
.item-main { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 12px; }
.item-main .fields { display: grid; gap: 8px; min-width: 0; }
.item-head { display: flex; gap: 8px; }
.item-head input { flex: 1; min-width: 0; }
.remove-item { flex: none; width: 48px; height: 48px; border-radius: 10px; border: 0; background: var(--paper); color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.item-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 14.5px; color: var(--muted); }
.item-foot .gain b { color: var(--ok); }
.item-foot .gain.neg b { color: var(--owe); }
.item-extra { margin-top: 8px; }

.photo-pick {
  position: relative; width: 76px; height: 76px; border-radius: 10px; overflow: hidden; cursor: pointer;
  display: grid; place-items: center; background: var(--paper); border: 1.5px dashed var(--kraft-dark); color: var(--muted);
  font-size: 13px; text-align: center;
}
.photo-pick svg { width: 26px; height: 26px; margin: 0 auto 2px; }
.photo-pick img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.photo-pick:focus-within { outline: 3px solid var(--monster); outline-offset: 2px; }
.photo-pick[data-state="uploading"]::after {
  content: ""; position: absolute; inset: 0; background: rgba(255, 255, 255, .55) center / 26px no-repeat
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9' fill='none' stroke='%235326D9' stroke-width='3' stroke-dasharray='40 20'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 12 12' to='360 12 12' dur='0.8s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E");
}
.photo-pick[data-state="error"] { border-color: var(--owe); border-style: solid; }

.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.savebar-inner { max-width: 560px; margin: 0 auto; display: flex; align-items: center; gap: 14px; }
.savebar .total { flex: 1; line-height: 1.15; }
.savebar .total span { font-size: 13.5px; color: var(--muted); display: block; }
.savebar .total b { font-family: var(--display); font-size: 24px; }
.savebar .btn { flex: 0 0 auto; min-width: 150px; }

/* ---------- detalle de pedido ---------- */
.order-head { margin: 4px 0 14px; }
.order-head h2 { font-size: 28px; line-height: 1.1; }
.order-head h2 a { color: inherit; text-decoration: none; }
.order-head p { margin: 2px 0 0; color: var(--muted); }
.totals { display: grid; grid-template-columns: repeat(3, 1fr); text-align: left; gap: 8px; }
.totals span { display: block; font-size: 14px; color: var(--muted); }
.totals b { font-family: var(--display); font-size: 21px; }
.totals .owe b { color: var(--owe); }
.totals .ok b { color: var(--ok); }
.deposit-note { margin: 10px 0 0; font-size: 15px; }
.deposit-note.owe { color: var(--owe); font-weight: 700; }
.deposit-note.ok { color: var(--ok); }
.status-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border-radius: 12px; overflow: hidden; box-shadow: inset 0 0 0 1.5px var(--line); background: var(--card); }
.status-pick button { min-height: 48px; border: 0; background: none; cursor: pointer; font-size: 14.5px; line-height: 1.1; padding: 4px 2px; border-right: 1px solid var(--line); }
.status-pick button:last-child { border-right: 0; }
.status-pick button[aria-pressed="true"] { background: var(--ink); color: #fff; font-weight: 700; }
.pay-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pay-row:last-of-type { border-bottom: 0; }
.pay-row .when { font-size: 15px; }
.pay-row .when span { display: block; color: var(--muted); font-size: 13.5px; }
.pay-row b { font-family: var(--display); font-size: 18px; color: var(--ok); }
.profit-line { display: flex; justify-content: space-between; padding: 6px 0; font-size: 15.5px; }
.profit-line.total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px; font-weight: 700; }

/* ---------- clientes ---------- */
.search { margin: 4px 0 12px; }
.rows { background: var(--card); border-radius: var(--radius); box-shadow: 0 0 0 1px var(--line); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.row:last-child { border-bottom: 0; }
.row:active { background: var(--paper); }
.row .avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--kraft); font-family: var(--display); font-weight: 700; color: var(--ink); }
.row .who { flex: 1; min-width: 0; }
.row .who b { display: block; font-family: var(--display); font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .who span { font-size: 14.5px; color: var(--muted); }
.row .bal { text-align: right; font-size: 14px; color: var(--muted); white-space: nowrap; }
.row .bal b { display: block; font-family: var(--display); font-size: 17px; color: var(--owe); }
.contact { display: grid; gap: 4px; margin: 4px 0 14px; color: var(--muted); }
.contact a { text-decoration: none; }

/* ---------- hoja inferior ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(34, 25, 47, .42); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; background: var(--paper);
  border-radius: 20px 20px 0 0; padding: 8px 16px calc(18px + env(safe-area-inset-bottom));
  animation: rise .22s ease-out;
}
.sheet-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 2px auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-head h2 { font-size: 21px; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.photo-view { position: fixed; inset: 0; z-index: 60; background: rgba(15, 10, 22, .92); display: grid; place-items: center; padding: 16px; }
.photo-view img { max-height: 90dvh; border-radius: 10px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px); z-index: 70;
  transform: translateX(-50%); width: max-content; max-width: calc(100vw - 32px); text-align: center;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 700;
  box-shadow: 0 10px 24px rgba(34, 25, 47, .25);
}
.toast.error { background: var(--owe); }
body.no-tabbar .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }

/* ---------- entrar ---------- */
.login { max-width: 380px; margin: 8vh auto 0; text-align: left; }
.login img { width: 84px; margin-bottom: 14px; }
.login h2 { font-size: 30px; margin-bottom: 4px; }
.login p { color: var(--muted); margin: 0 0 20px; }
.form-error { color: var(--owe); font-weight: 700; margin: 0 0 12px; }

.skeleton { height: 84px; border-radius: 10px; background: linear-gradient(90deg, var(--card) 30%, var(--paper) 50%, var(--card) 70%) 0 0 / 300% 100%; animation: shimmer 1.2s infinite linear; margin-bottom: 10px; }
@keyframes shimmer { to { background-position: -150% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (min-width: 700px) {
  main { padding-top: 12px; }
}
