@font-face { font-family: "Bricolage Grotesque"; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url(fonts/bricolage-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Bricolage Grotesque"; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url(fonts/bricolage-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  color-scheme: light dark;
  --bg: #EFEDF5; --surface: #FFFFFF; --surface2: #F3F1F8; --line: #E3E0EE;
  --ink: #17142B; --muted: #6E6A86;
  --btn-bg: #17142B; --btn-ink: #FFFFFF;
  --good: #138A5B; --bad: #D6372F; --warn: #B7791F;
  --p1: #F2552C; --p2: #2A6BF2; --p3: #14A05B; --p4: #9B4DE0;
  --cash: #2BB673; --bizum: #1AA7D8;
  --shadow: 0 1px 2px rgba(23,20,43,.06), 0 8px 24px -12px rgba(23,20,43,.18);
  --r-lg: 24px; --r-md: 18px; --r-sm: 12px;
  --tabh: 68px;
}
/* Tema: sigue al móvil salvo que la persona elija claro u oscuro (data-theme en <html>). */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #100E1A; --surface: #1B1829; --surface2: #26223A; --line: #2F2A47;
    --ink: #F3F1FA; --muted: #A09BBB;
    --btn-bg: #F3F1FA; --btn-ink: #17142B;
    --good: #3DD68C; --bad: #FF7A70; --warn: #F2B84B;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px -14px rgba(0,0,0,.7);
  }
}
:root[data-theme="dark"] {
  --bg: #100E1A; --surface: #1B1829; --surface2: #26223A; --line: #2F2A47;
  --ink: #F3F1FA; --muted: #A09BBB;
  --btn-bg: #F3F1FA; --btn-ink: #17142B;
  --good: #3DD68C; --bad: #FF7A70; --warn: #F2B84B;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px -14px rgba(0,0,0,.7);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif; font-optical-sizing: auto; }
body { min-height: 100dvh; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
b, strong { font-weight: 650; }
small { font-size: .8rem; color: var(--muted); font-weight: 400; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.pos { color: var(--good); } .neg { color: var(--bad); }
.num, .big, .t-n, .p-total, .who-t, .fl-s, dd { font-variant-numeric: tabular-nums lining-nums; }
:focus-visible { outline: 3px solid var(--p2); outline-offset: 2px; border-radius: 10px; }

.wrap { max-width: 560px; margin: 0 auto; padding: 14px 16px calc(var(--tabh) + 36px + env(safe-area-inset-bottom)); }
.wrap.has-bar { padding-bottom: calc(var(--tabh) + 104px + env(safe-area-inset-bottom)); }

/* cabecera */
.top { display: flex; align-items: center; justify-content: space-between; height: 44px; }
.mark { display: inline-flex; }
.mark i { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--bg); margin-left: -7px; }
.mark i:first-child { margin-left: 0; background: hsl(30 82% 52%); }
.mark i:nth-child(2) { background: hsl(165 82% 46%); }
.mark i:nth-child(3) { background: hsl(285 70% 56%); }
.top-r { display: flex; align-items: center; gap: 10px; }
.theme-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--surface); color: var(--ink); cursor: pointer;
  display: grid; place-items: center; box-shadow: var(--shadow); }
.avatar { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--btn-bg); color: var(--btn-ink); font-weight: 700; cursor: pointer; }
.title { font-size: 2.1rem; line-height: 1.1; font-weight: 700; letter-spacing: -.025em; margin: 10px 0 18px; }

/* secciones sin cajas repetidas */
.sec-head { display: flex; align-items: baseline; justify-content: space-between; margin: 30px 0 12px; }
.sec-head h2, h2.q { font-size: 1.1rem; font-weight: 650; letter-spacing: -.01em; }
h2.q { margin: 22px 0 10px; }
.empty { color: var(--muted); padding: 22px 6px; text-align: center; }
.note { color: var(--muted); font-size: .82rem; margin-top: 8px; }

/* panel principal (dinero, KPI) */
.panel { background: var(--surface); border-radius: var(--r-lg); padding: 20px 18px 8px; box-shadow: var(--shadow); }
.lead { color: var(--muted); font-size: .9rem; }
.big { font-size: clamp(2.6rem, 13vw, 3.4rem); line-height: 1.05; font-weight: 750; letter-spacing: -.035em; margin: 2px 0 14px; }
.share { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--surface2); gap: 2px; }
.share span { display: block; min-width: 4px; }
.who { list-style: none; margin: 8px 0 0; padding: 0; }
.who li { display: grid; grid-template-columns: 12px 1fr auto; gap: 12px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.who li:first-child { border-top: 0; }
.who i { width: 12px; height: 12px; border-radius: 50%; }
.who-n b { display: block; font-size: 1.05rem; }
.who-n small { line-height: 1.35; display: block; }
.who-t { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; }

/* botones */
.btn { display: block; width: 100%; background: var(--btn-bg); color: var(--btn-ink); border: 0; border-radius: var(--r-md);
  padding: 15px 18px; font-weight: 650; cursor: pointer; text-align: center; transition: transform .12s, opacity .12s; }
.btn:active { transform: scale(.98); }
.btn.big { padding: 19px 18px; font-size: 1.1rem; border-radius: 20px; }
.btn.cta { margin: 14px 0 0; }
.btn.ghost { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.danger { background: color-mix(in oklab, var(--bad) 14%, transparent); color: var(--bad); }
.btn.sm { display: inline-block; width: auto; padding: 8px 14px; font-size: .85rem; border-radius: 12px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns .btn { flex: 1; }
.btns.stack { flex-direction: column; margin-top: 16px; }

/* formularios */
label { display: block; color: var(--muted); font-size: .85rem; margin: 18px 0 7px; font-weight: 500; }
input, select, textarea { width: 100%; background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; padding: 14px; transition: border-color .15s; }
input:focus, select:focus { outline: none; border-color: var(--ink); }
input::placeholder { color: color-mix(in oklab, var(--muted) 70%, transparent); }
.fields { margin-top: 4px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--surface2); padding: 4px; border-radius: 16px; }
.seg button { background: transparent; border: 0; padding: 12px 6px; border-radius: 12px; color: var(--muted); font-weight: 600; cursor: pointer; transition: background .15s, color .15s; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(23,20,43,.14); }
.seg.wide { margin-bottom: 4px; }

.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { flex: none; width: 48px; height: 50px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); font-size: 1.4rem; cursor: pointer; }
.stepper input { text-align: center; font-size: 1.15rem; font-weight: 700; padding-left: 4px; padding-right: 4px; }

/* baldosas de sabor: el color es el sabor y el nivel es el stock */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { --fc: hsl(var(--h) var(--s) 52%); position: relative; overflow: hidden; text-align: left; border: 2px solid transparent; cursor: pointer;
  border-radius: 20px; min-height: 92px; padding: 12px 14px; display: flex; flex-direction: column; justify-content: space-between;
  background: color-mix(in oklab, var(--fc) 11%, var(--surface)); transition: transform .12s, border-color .15s; isolation: isolate; }
.tile:active { transform: scale(.97); }
.tile .fill { position: absolute; inset: auto 0 0 0; height: calc(var(--lvl) * 100%); z-index: -1;
  background: linear-gradient(180deg, color-mix(in oklab, var(--fc) 46%, transparent), color-mix(in oklab, var(--fc) 30%, transparent)); }
.t-name { font-weight: 650; line-height: 1.15; max-width: 85%; }
.t-n { font-size: 1.9rem; font-weight: 750; letter-spacing: -.03em; line-height: 1; }
.t-tag { position: absolute; right: 12px; bottom: 12px; font-size: .72rem; font-weight: 650; padding: 3px 9px; border-radius: 99px; background: var(--surface); color: var(--ink); }
.tile.low .t-tag { color: var(--warn); }
.tile.out { background: repeating-linear-gradient(135deg, var(--surface2) 0 8px, var(--surface) 8px 16px); }
.tile.out .t-name, .tile.out .t-n { color: var(--muted); }
.tile.out .t-tag { color: var(--bad); }
.tile.sel { border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in oklab, var(--fc) 45%, transparent); }
.tile:disabled { cursor: not-allowed; }

/* momento de entrada: los frascos se llenan una vez al abrir la app */
.intro .tile .fill { animation: fillup .9s cubic-bezier(.2,.8,.2,1) both; }
@keyframes fillup { from { height: 0; } }

/* barra fija de la venta */
.sellbar { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabh) + 18px + env(safe-area-inset-bottom)); z-index: 6; max-width: 536px; margin: 0 auto;
  display: flex; align-items: center; gap: 14px; background: var(--surface); border-radius: 22px; padding: 10px 10px 10px 18px; box-shadow: var(--shadow); }
.sellbar > div { flex: none; }
.sellbar small { display: block; line-height: 1.1; }
.sellbar b { font-size: 1.5rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.sellbar .btn { flex: 1; padding: 15px 12px; }

/* navegación */
nav.tabs { position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); height: var(--tabh); max-width: 536px; margin: 0 auto; z-index: 7;
  display: flex; gap: 2px; padding: 6px; background: var(--surface); border-radius: 26px; box-shadow: var(--shadow); }
nav.tabs button { flex: 1; min-width: 0; border: 0; background: none; border-radius: 20px; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .66rem; font-weight: 600; transition: background .18s, color .18s; }
nav.tabs button.on { background: var(--btn-bg); color: var(--btn-ink); }

/* stock */
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.duo > div { background: var(--surface); border-radius: var(--r-md); padding: 14px 16px; box-shadow: var(--shadow); }
.duo b { display: block; font-size: 1.6rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; }
.flist { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; }
.flist li { --fc: hsl(var(--h) var(--s) 52%); background: var(--surface); border-radius: var(--r-md); padding: 14px 16px; box-shadow: var(--shadow); }
.flist li.off { opacity: .55; }
.fl-top { display: flex; align-items: center; gap: 12px; }
.sw { width: 14px; height: 38px; border-radius: 7px; background: var(--fc); flex: none; }
.fl-n { flex: 1; min-width: 0; } .fl-n b { display: block; } .fl-n small { display: block; }
.fl-s { font-size: 1.8rem; font-weight: 750; letter-spacing: -.03em; }
.fl-s.low { color: var(--warn); } .fl-s.out { color: var(--bad); }
.lvl { height: 6px; border-radius: 99px; background: var(--surface2); margin-top: 12px; overflow: hidden; }
.lvl i { display: block; height: 100%; background: var(--fc); border-radius: 99px; }
.fl-act { display: flex; gap: 8px; margin-top: 12px; }
.chip { display: inline-block; font-size: .72rem; padding: 2px 9px; border-radius: 99px; background: var(--surface2); color: var(--muted); font-weight: 600; }

/* dinero */
.person { --pc: var(--p1); background: var(--surface); border-radius: var(--r-lg); padding: 18px; margin-bottom: 12px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.person::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--pc); }
.p-head { display: flex; align-items: center; gap: 10px; }
.p-head h2 { font-size: 1.05rem; font-weight: 650; }
.p-head .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pc); }
.p-total { font-size: 2.5rem; font-weight: 750; letter-spacing: -.035em; line-height: 1.1; margin: 6px 0 10px; }
.kv { margin: 0; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; text-align: right; }
.kv dd small { margin-left: 4px; }
.kv.plain { background: var(--surface); border-radius: var(--r-md); padding: 4px 16px; box-shadow: var(--shadow); }
.kv.plain > div:first-child { border-top: 0; }
.kv .strong dt { color: var(--ink); font-weight: 650; }

/* historial */
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { display: grid; grid-template-columns: 10px 1fr auto; gap: 12px; align-items: start; padding: 14px 0; border-top: 1px solid var(--line); }
.hist li:first-child { border-top: 0; }
.hist .hd { width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; }
.h-top { display: flex; justify-content: space-between; gap: 10px; }
.h-amt { font-weight: 700; white-space: nowrap; }
.h-meta { display: flex; flex-wrap: wrap; gap: 2px 14px; color: var(--muted); font-size: .8rem; margin-top: 3px; }
.h-meta b { color: var(--ink); font-weight: 600; }
.hist li.void { opacity: .45; } .hist li.void .h-top b { text-decoration: line-through; }

/* análisis */
.kpi-main { padding-bottom: 14px; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--line); }
.kpis dd { margin: 0; font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }
.kpis dt { color: var(--muted); font-size: .72rem; line-height: 1.25; margin-top: 2px; }
.delta { display: inline-block; font-size: .78rem; font-weight: 650; padding: 2px 9px; border-radius: 99px; background: var(--surface2); color: var(--muted); }
.delta.up { background: color-mix(in oklab, var(--good) 16%, transparent); color: var(--good); }
.delta.down { background: color-mix(in oklab, var(--bad) 16%, transparent); color: var(--bad); }
.plot { background: var(--surface); border-radius: var(--r-md); padding: 14px 12px 10px; box-shadow: var(--shadow); }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 9px; font-family: inherit; }
.chart .axis { stroke: var(--line); stroke-width: 1.2; }
.chart .grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .ylab { font-size: 8px; }
.chart .bar { fill: var(--btn-bg); opacity: .78; } .chart .bar.now { opacity: 1; }
.chart .end { stroke: var(--surface); stroke-width: 2; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 10px; font-size: .88rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; }
.legend b { color: var(--ink); }
.hb { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.hb-top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.hb-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.hb-track { background: var(--surface2); border-radius: 99px; height: 10px; overflow: hidden; }
.hb-bar { height: 100%; border-radius: 99px; }
.hb small { display: block; margin-top: 4px; }
.split { display: flex; height: 16px; border-radius: 99px; overflow: hidden; background: var(--surface2); gap: 2px; margin-bottom: 10px; }
.split span { display: block; }

/* diálogos como hoja inferior */
dialog { background: var(--surface); color: var(--ink); border: 0; border-radius: 28px 28px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  width: min(100%, 520px); max-height: 88dvh; margin: auto auto 0; box-shadow: 0 -20px 50px -20px rgba(0,0,0,.4); }
@media (min-width: 640px) { dialog { margin: auto; border-radius: 28px; } }
dialog::backdrop { background: rgba(16,14,26,.55); backdrop-filter: blur(3px); }
dialog h3 { font-size: 1.3rem; font-weight: 700; letter-spacing: -.02em; margin-bottom: 4px; }
dialog .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); }
dialog .row:first-of-type { border-top: 0; }
dialog .sub { color: var(--muted); font-size: .8rem; }
dialog .pill { display: inline-block; font-size: .72rem; padding: 2px 9px; border-radius: 99px; background: var(--surface2); color: var(--muted); font-weight: 600; }
dialog .pill.warn { background: color-mix(in oklab, var(--warn) 18%, transparent); color: var(--warn); }
dialog .pill.bad { background: color-mix(in oklab, var(--bad) 16%, transparent); color: var(--bad); }
dialog .pill.ok { background: color-mix(in oklab, var(--good) 16%, transparent); color: var(--good); }
.code { font: 700 2rem/1.2 ui-monospace, Consolas, monospace; letter-spacing: .12em; text-align: center; background: var(--surface2);
  border: 2px dashed var(--ink); border-radius: 16px; padding: 18px 8px; margin: 14px 0; user-select: all; }
.wa { background: #E3F6EA; border-radius: 14px; padding: 12px 14px; margin: 4px 0 0; white-space: pre-wrap; font: .85rem/1.5 inherit; color: #123524; max-height: 36vh; overflow: auto; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .wa { background: #12301f; color: #cdeedb; } }
:root[data-theme="dark"] .wa { background: #12301f; color: #cdeedb; }

#toast { position: fixed; left: 50%; bottom: calc(var(--tabh) + 92px + env(safe-area-inset-bottom)); transform: translate(-50%, 16px); opacity: 0;
  background: var(--btn-bg); color: var(--btn-ink); padding: 12px 20px; border-radius: 99px; font-weight: 600; pointer-events: none;
  transition: .25s; z-index: 20; max-width: 90vw; text-align: center; box-shadow: var(--shadow); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--bad); color: #fff; }

/* acceso */
.auth { max-width: 400px; margin: 0 auto; padding: 9vh 20px 40px; }
.auth .mark { margin-bottom: 18px; } .auth .mark i { border-color: var(--bg); width: 30px; height: 30px; }
.auth h1 { font-size: 2.3rem; letter-spacing: -.03em; line-height: 1.1; margin-bottom: 8px; }
.auth p { color: var(--muted); margin-bottom: 8px; }
.auth h3 { font-size: 1.05rem; }
.err-msg { color: var(--bad); font-size: .9rem; min-height: 1.3em; margin-top: 10px; }

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