:root {
  --navy: #0F2744;
  --navy-2: #1B3A61;
  --navy-soft: #E8EEF7;
  --ink: #0F1B2D;
  --muted: #5B6B7F;
  --line: #E3E8EF;
  --bg: #F4F6F9;
  --white: #FFFFFF;
  --ok: #1F7A4D;   --ok-bg: #E6F4EC;
  --warn: #8A5A00; --warn-bg: #FFF3D6;
  --bad: #B42318;  --bad-bg: #FDECEA;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { background: #DDE3EC; }
body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--bg);
  max-width: 520px;
  min-height: 100vh;
  margin: 0 auto;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.opt { font-weight: 500; color: var(--muted); font-size: 12px; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }

.screen { min-height: 100vh; padding-bottom: calc(100px + var(--bottom)); }
.screen.no-nav { padding-bottom: calc(32px + var(--bottom)); }

/* ---------- Encabezados ---------- */
.topbar { background: var(--navy); color: #fff; padding: calc(18px + var(--top)) 18px 20px; }
.topbar .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.hello { font-size: 21px; font-weight: 700; }
.sub { font-size: 13px; opacity: .78; margin-top: 2px; }
.back { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; margin-left: -4px; min-height: 40px; }
.back span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; background: rgba(255,255,255,.12); display: grid; place-items: center; position: relative; flex-shrink: 0; }
.icon-btn .dot { position: absolute; top: 10px; right: 11px; width: 8px; height: 8px; border-radius: 50%; background: #F5B83D; }

.hero-top { padding-top: calc(40px + var(--top)); padding-bottom: 32px; }
.hero-top .logo { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; font-family: "Plus Jakarta Sans", sans-serif; font-weight: 800; font-size: 26px; letter-spacing: -.02em; }
.hero-top .logo svg { height: 34px; width: auto; }
.hero-top .logo b { color: #4FD18B; font-weight: 800; }
.hero-top h1 { font-size: 27px; line-height: 1.2; margin-bottom: 10px; }
.hero-top p { opacity: .82; line-height: 1.5; }

.month { margin-top: 16px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); border-radius: 16px; padding: 14px; }
.month .lbl { font-size: 12px; opacity: .78; }
.month .big { font-size: 30px; font-weight: 800; margin: 2px 0 10px; }
.month .split { display: flex; gap: 10px; font-size: 13px; }
.month .split div { flex: 1; background: rgba(255,255,255,.08); border-radius: 10px; padding: 8px 10px; }
.month .split b { display: block; font-size: 15px; }

/* ---------- Secciones y tarjetas ---------- */
.section { padding: 18px 16px 0; }
.section-title { font-size: 15px; font-weight: 700; color: var(--navy); margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.section-title a { font-size: 13px; font-weight: 600; color: var(--navy-2); }
.card { display: block; background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 10px; }
.card.list { padding: 0 14px; }
.more { display: block; text-align: center; font-size: 14px; font-weight: 600; color: var(--navy-2); padding: 6px; }

.lote-card:active { background: var(--navy-soft); }
.lote-head { display: flex; gap: 12px; align-items: center; }
.emoji { width: 46px; height: 46px; border-radius: 12px; background: var(--navy-soft); display: grid; place-items: center; font-size: 25px; flex-shrink: 0; }
.lote-name { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lote-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.lote-mid { display: flex; align-items: center; gap: 10px; margin: 12px 0 10px; }
.lote-mid .bar { flex: 1; margin: 0; }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--navy); border-radius: 99px; }
.lote-stats { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.lote-stats b { color: var(--ink); font-size: 14px; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 99px; white-space: nowrap; }
.pill.ok { color: var(--ok); background: var(--ok-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.bad { color: var(--bad); background: var(--bad-bg); }

.empty { text-align: center; background: var(--white); border: 1px dashed #B9C6D8; border-radius: 18px; padding: 28px 20px; }
.empty-emoji { font-size: 40px; margin-bottom: 8px; }
.empty b { font-size: 17px; color: var(--navy); }
.empty p { color: var(--muted); margin: 6px 0 16px; line-height: 1.45; font-size: 14px; }

.todo { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.todo:last-child { border-bottom: 0; }
.t { font-size: 15px; font-weight: 600; }
.s { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.late { color: var(--bad); font-weight: 600; }
.check { width: 30px; height: 30px; border: 2px solid #C5D0DE; border-radius: 9px; flex-shrink: 0; display: grid; place-items: center; color: #fff; }
.check.on { background: var(--ok); border-color: var(--ok); }

/* ---------- Navegación inferior ---------- */
.nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 520px; height: calc(74px + var(--bottom)); padding-bottom: var(--bottom); background: var(--white); border-top: 1px solid var(--line); display: flex; justify-content: space-around; align-items: center; z-index: 10; }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); font-weight: 500; width: 64px; padding: 6px 0; }
.nav a.active { color: var(--navy); font-weight: 700; }
.nav .plus { width: 58px; height: 58px; border-radius: 18px; background: var(--navy); color: #fff; display: grid; place-items: center; margin-top: -28px; box-shadow: 0 8px 18px -6px rgba(15,39,68,.6); }
.nav .plus-wrap { color: var(--navy); font-weight: 700; }

/* ---------- Formularios ---------- */
.form { padding: 18px 16px; }
.q { font-size: 17px; font-weight: 700; margin-bottom: 12px; color: var(--navy); }
.q.small { font-size: 15px; margin-bottom: 10px; }
.species { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 22px; }
.sp { position: relative; background: var(--white); border: 2px solid var(--line); border-radius: 16px; padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; font-size: 15px; font-weight: 600; min-height: 92px; cursor: pointer; }
.sp input { position: absolute; opacity: 0; pointer-events: none; }
.sp .e { font-size: 28px; }
.sp small { font-weight: 500; color: var(--muted); font-size: 12px; }
.sp:has(input:checked) { border-color: var(--navy); background: var(--navy-soft); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.help { font-size: 12px; color: var(--muted); margin-top: 5px; }
.input { width: 100%; background: var(--white); border: 1.5px solid var(--line); border-radius: 14px; min-height: 54px; display: flex; align-items: center; padding: 0 14px; font-size: 17px; font-weight: 600; gap: 8px; }
.input:focus-within, input.input:focus, select.input:focus { border-color: var(--navy-2); outline: none; box-shadow: 0 0 0 3px rgba(27,58,97,.12); }
.input input { border: 0; outline: 0; background: none; width: 100%; height: 50px; font-weight: 600; font-size: 17px; min-width: 0; }
input.input::placeholder, .input input::placeholder { color: #A3AFBF; font-weight: 500; }
.input .pre { color: var(--muted); font-weight: 500; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: right 18px center, right 12px center; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 30px; }
input[type=date].input { display: block; line-height: 50px; -webkit-appearance: none; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.total { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--navy-soft); border-radius: 14px; padding: 12px 14px; font-size: 14px; margin-bottom: 14px; }
.total b { font-size: 18px; color: var(--navy); }
.info { display: flex; gap: 10px; background: var(--white); border: 1px dashed #B9C6D8; border-radius: 14px; padding: 12px; font-size: 13.5px; line-height: 1.45; color: var(--muted); margin-bottom: 18px; }
.info b { color: var(--ink); }
.error { color: var(--bad); font-size: 14px; font-weight: 600; min-height: 4px; margin-bottom: 10px; }
.error:empty { margin: 0; }
.advanced { margin-bottom: 14px; border: 1.5px solid var(--line); border-radius: 14px; padding: 0 14px; background: var(--white); }
.advanced summary { padding: 14px 0; font-weight: 600; font-size: 14px; color: var(--navy-2); cursor: pointer; }
.advanced p { margin-bottom: 12px; }

.btn { width: 100%; height: 56px; border-radius: 16px; background: var(--navy); color: #fff; font-size: 17px; font-weight: 700; display: flex; align-items: center; justify-content: center; text-align: center; cursor: pointer; }
.btn:active { opacity: .85; }
.btn.ghost { background: var(--white); color: var(--navy); border: 1.5px solid var(--line); }
.btn.danger { background: var(--white); color: var(--bad); border: 1.5px solid #F3C7C2; }
.btn.small { height: 46px; font-size: 15px; width: auto; padding: 0 18px; border-radius: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip { position: relative; padding: 11px 13px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--white); font-size: 14px; font-weight: 600; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) { background: var(--navy); border-color: var(--navy); color: #fff; }

.amount { text-align: center; padding: 8px 0 18px; }
.amount .lbl { display: block; font-size: 14px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.amount-input { display: flex; align-items: baseline; justify-content: center; gap: 6px; border-bottom: 2px solid var(--line); padding-bottom: 6px; margin: 0 24px; }
.amount-input:focus-within { border-color: var(--navy-2); }
.amount-input span { font-size: 24px; color: var(--muted); font-weight: 600; }
.amount-input input { width: 100%; max-width: 220px; border: 0; outline: 0; background: none; font-size: 44px; font-weight: 800; color: var(--navy); text-align: center; letter-spacing: -.02em; }
.amount-input input::placeholder { color: #C5D0DE; }

.lote-pick { display: flex; align-items: center; gap: 10px; background: var(--white); border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 14px; margin-bottom: 16px; position: relative; }
.lote-pick .lbl { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }
.lote-pick select { width: 100%; border: 0; background: none; font-size: 16px; font-weight: 700; appearance: none; outline: 0; padding: 2px 0; }
.lote-pick .change { font-size: 13px; color: var(--navy-2); font-weight: 700; pointer-events: none; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.act { background: var(--white); border: 1.5px solid var(--line); border-radius: 16px; padding: 16px 14px; display: flex; flex-direction: column; gap: 5px; min-height: 112px; }
.act:active { background: var(--navy-soft); }
.act .e { font-size: 28px; }
.act b { font-size: 16px; }
.act small { font-size: 12.5px; color: var(--muted); }
.act.opt { border-style: dashed; }

/* ---------- Detalle del lote ---------- */
.dash-top { background: var(--navy); color: #fff; padding: calc(16px + var(--top)) 18px 56px; }
.dash-top .meta { font-size: 13px; opacity: .82; margin-top: 6px; }
.dash-top .bar { background: rgba(255,255,255,.18); margin-top: 10px; }
.dash-top .bar span { background: #fff; }
.hero { margin: -42px 16px 0; background: var(--white); border-radius: 18px; padding: 16px; box-shadow: 0 10px 24px -14px rgba(15,39,68,.4); border: 1px solid var(--line); position: relative; }
.hero .lbl { font-size: 13px; color: var(--muted); font-weight: 600; }
.hero .val { font-size: 36px; font-weight: 800; color: var(--navy); letter-spacing: -.02em; margin: 2px 0; }
.hero .val small { font-size: 15px; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.hero .val.pos { color: var(--ok); } .hero .val.neg { color: var(--bad); }
.hero .gain { margin-top: 10px; background: var(--ok-bg); color: var(--ok); border-radius: 12px; padding: 10px 12px; font-size: 14px; line-height: 1.45; }
.hero .gain.loss { background: var(--bad-bg); color: var(--bad); }
.hero .gain.neutral { background: var(--bg); color: var(--muted); }
.hero .gain b { font-size: 16px; }
.hero .note { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.4; }
.edit-price summary { font-size: 13px; color: var(--navy-2); font-weight: 600; margin-top: 10px; cursor: pointer; list-style: none; }
.edit-price summary::-webkit-details-marker { display: none; }
.inline-form { display: flex; gap: 8px; margin-top: 10px; }
.inline-form .input { flex: 1; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.kpi .lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .val { font-size: 22px; font-weight: 800; margin: 2px 0 6px; letter-spacing: -.01em; }
.kpi .ref { font-size: 11.5px; color: var(--muted); margin-top: 6px; line-height: 1.35; }

.split-bar { display: flex; height: 14px; border-radius: 99px; overflow: hidden; margin-bottom: 12px; gap: 2px; }
.legend { display: grid; gap: 8px; font-size: 13.5px; }
.legend div { display: flex; align-items: center; gap: 8px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend span { flex: 1; }
.legend em { font-style: normal; color: var(--muted); width: 40px; text-align: right; }

.tip { display: flex; gap: 10px; background: var(--navy-soft); border-radius: 16px; padding: 14px; font-size: 14px; line-height: 1.45; }
.tip a { display: inline-block; margin-top: 6px; font-weight: 700; color: var(--navy); }

.timeline { padding: 2px 14px; }
.timeline .item { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); align-items: center; }
.timeline .item:last-child { border-bottom: 0; }
.timeline .item.done .t { text-decoration: line-through; color: var(--muted); }
.day { width: 52px; text-align: center; background: var(--bg); border-radius: 10px; padding: 5px 0; font-size: 11px; color: var(--muted); font-weight: 600; flex-shrink: 0; text-transform: capitalize; }
.day b { display: block; font-size: 17px; color: var(--navy); }
.day.late { background: var(--bad-bg); color: var(--bad); }
.day.late b { color: var(--bad); }

.chart { display: flex; align-items: flex-end; gap: 8px; height: 120px; }
.chart div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; font-size: 11px; color: var(--muted); height: 100%; }
.chart div small { font-size: 10px; }
.chart div span { width: 100%; max-height: 80px; background: #7D9CC4; border-radius: 6px 6px 2px 2px; }
.chart div.today span { background: var(--navy); }
.chart div.today b { color: var(--navy); }

.reg { display: flex; gap: 10px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.reg:last-child { border-bottom: 0; }
.reg .t { font-size: 14px; }
.reg b { white-space: nowrap; font-size: 14px; }
.reg-ico { width: 34px; height: 34px; border-radius: 10px; background: var(--bg); display: grid; place-items: center; font-size: 17px; flex-shrink: 0; }
.del { color: #A3AFBF; padding: 6px; margin-right: -6px; }
.del:active { color: var(--bad); }
.more-list summary { font-size: 14px; font-weight: 600; color: var(--navy-2); padding: 8px 0 12px; cursor: pointer; }
.actions-end { display: grid; gap: 10px; padding-top: 26px; }
.add-task summary { font-weight: 700; color: var(--navy); cursor: pointer; }

/* ---------- Aviso flotante ---------- */
#toast { position: fixed; left: 50%; bottom: calc(96px + var(--bottom)); transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: .2s; z-index: 20; max-width: 90vw; }
#toast.visible { opacity: 1; transform: translate(-50%, 0); }
