/* Envelope Duo. Paleta: tinta #14213D, verde #1F6F50, papel #F7F5F0. Contraste AA verificado con axe. Fuente del sistema. */
:root {
  --ink: #14213d; --ink2: #2b3654; --muted: #545c6b; --paper: #f7f5f0; --card: #fff; --line: #dcd7cb;
  --green: #1f6f50; --green-d: #165840; --tint: #e5f1ea; --danger: #b42318; --danger-bg: #fdecea;
  --warn: #8a5300; --warn-bg: #fff3dc; --amber: #e9a23b; --focus: #1f6f50;
  --r: 14px; --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 4px 14px rgba(20, 33, 61, .06);
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-wrap: break-word; /* mails largos (code screen) sin desbordar; no cambia el min-content de flex */
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.6rem, 4.5vw, 2.6rem); letter-spacing: -.01em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
a { color: var(--green); text-underline-offset: 2px; }
a:hover { color: var(--green-d); }
img, svg { max-width: 100%; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 99; }
.skip:focus { left: 8px; color: #fff; }
.small { font-size: .9rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.neg { color: var(--danger); }
.pos { color: var(--green); }
.num, .amt, .big, .price, .total { font-variant-numeric: tabular-nums; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.stack > * + * { margin-top: 14px; }

/* botones y campos */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px;
  border: 2px solid var(--green); border-radius: 999px; background: var(--green); color: #fff; font: inherit; font-weight: 650;
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--green-d); border-color: var(--green-d); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--green); }
.btn.ghost:hover { background: var(--tint); color: var(--green-d); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.ghost.danger:hover { background: var(--danger-bg); }
.btn.small { min-height: 36px; padding: 6px 14px; font-size: .92rem; }
.btn.big { min-height: 52px; padding: 12px 26px; font-size: 1.08rem; }
.link { background: none; border: 0; padding: 4px 0; color: var(--green); font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; min-height: 32px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label, legend { font-weight: 600; font-size: .95rem; }
.hint { margin: 0; color: var(--muted); font-size: .88rem; }
input[type=text], input[type=email], input[type=search], input[type=date], input:not([type]), select {
  width: 100%; min-height: 44px; padding: 9px 12px; border: 1.5px solid #8b8fa0; border-radius: 10px;
  background: #fff; color: var(--ink); font: inherit;
}
input.code { font-size: 1.6rem; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
input[type=checkbox], input[type=radio] { width: 22px; height: 22px; accent-color: var(--green); margin: 0; flex: none; }
fieldset { border: 0; padding: 0; margin: 0; }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.check label { font-weight: 400; }
.error { color: var(--danger); font-weight: 600; margin: 0; }
.error:empty, .okmsg:empty { display: none; }
.okmsg { color: var(--green); font-weight: 600; }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.tag { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: var(--tint); color: var(--green-d); font-size: .75rem; font-weight: 700; vertical-align: middle; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); }
.banner { background: var(--tint); border-radius: 12px; padding: 12px 14px; margin: 0; }
.banner.warn { background: var(--warn-bg); color: #5c3800; }
.banner p { margin: 0 0 8px; }
.tbl { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl td.num, .tbl th.num { text-align: right; }

/* ================= sitio ================= */
.top { background: var(--paper); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; font-size: 1.15rem; text-decoration: none; white-space: nowrap; }
.brand img { width: 34px; height: 34px; }
.nav { display: flex; align-items: center; gap: 4px 18px; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.nav a { color: var(--ink); text-decoration: none; font-weight: 600; padding: 8px 2px; }
.nav a[aria-current=page] { text-decoration: underline; text-decoration-color: var(--green); text-decoration-thickness: 3px; text-underline-offset: 6px; }
.nav .btn { color: #fff; padding: 8px 16px; min-height: 40px; }
@media (max-width: 640px) {
  .nav .sec { display: none; }
  /* marca y botón en un renglón */
  .top .wrap { gap: 8px; }
  .brand { font-size: 1.05rem; gap: 8px; }
  .brand img { width: 30px; height: 30px; }
  .nav .btn { padding: 8px 14px; }
}
@media (max-width: 379px) {
  /* 320 a 379 px (SE, Android chicos): un renglón igual */
  .top .wrap { padding: 0 14px; gap: 6px; }
  .brand { font-size: .95rem; gap: 6px; }
  .brand img { width: 26px; height: 26px; }
  .nav .btn { padding: 7px 11px; font-size: .9rem; }
}
.hero { padding: 56px 0 40px; }
.hero .wrap { display: grid; gap: 36px; align-items: center; }
@media (min-width: 900px) { .hero .wrap { grid-template-columns: 1.1fr .9fr; } }
.hero .lede, .lede { font-size: 1.15rem; color: var(--ink2); max-width: 40em; }
.hero .cta { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 22px 0 10px; }
.kick { display: inline-block; font-weight: 700; color: var(--green-d); background: var(--tint); border-radius: 999px; padding: 4px 12px; font-size: .9rem; margin-bottom: 14px; }
.phone { justify-self: center; width: min(340px, 100%); background: var(--ink); border-radius: 34px; padding: 12px; box-shadow: 0 18px 40px rgba(20, 33, 61, .22); }
.phone .screen { background: var(--paper); border-radius: 24px; padding: 16px 14px; }
.phone .who-row { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin-bottom: 10px; }
.mini { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.mini li { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: .92rem; }
.mini .n { font-weight: 650; }
.mini .a { font-weight: 700; font-variant-numeric: tabular-nums; }
.mini .s { grid-column: 1 / -1; color: var(--muted); font-size: .8rem; }
.mini .bar { grid-column: 1 / -1; }
.mini .fill.w40 { width: 40%; } .mini .fill.w45 { width: 45%; } .mini .fill.w65 { width: 65%; } .mini .fill.w70 { width: 70%; }
.section { padding: 48px 0; }
.section.alt { background: #fff; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section h2 { font-size: clamp(1.35rem, 3vw, 1.9rem); }
.features { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); list-style: none; padding: 0; margin: 24px 0 0; }
.features li { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.section.alt .features li { background: var(--paper); }
.features h3 { display: flex; gap: 10px; align-items: center; }
.features h3 svg { flex: none; }
.features p { margin: 0; color: var(--ink2); }
.steps { counter-reset: s; list-style: none; padding: 0; display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.steps li { counter-increment: s; padding-left: 52px; position: relative; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 38px; height: 38px; border-radius: 50%; background: var(--green); color: #fff; font-weight: 800; display: grid; place-items: center; }
.plans { display: grid; gap: 16px; margin-bottom: 18px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.plan { background: var(--card); border: 1.5px solid var(--line); border-radius: var(--r); padding: 18px; }
.plan.pro { border-color: var(--green); }
.plan ul { padding-left: 1.2em; margin: 0; }
.price { font-size: 1.5rem; font-weight: 800; margin: 0 0 10px; }
.waitlist { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 14px; }
.waitlist .field { flex: 1 1 220px; }
.cmp { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.cmp th, .cmp td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.cmp thead th { background: var(--ink); color: #fff; }
.cmp tbody th { font-weight: 650; width: 34%; }
.cmp td.us { background: var(--tint); }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.prose { max-width: 46em; }
.prose h2 { margin-top: 1.6em; }
.prose li { margin-bottom: .4em; }
.faq details { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 0 16px; margin-bottom: 10px; }
.faq summary { cursor: pointer; font-weight: 650; padding: 14px 0; min-height: 44px; }
.faq details p { margin: 0 0 14px; }
.crumbs { margin: 18px 0 0; color: var(--muted); }
.foot { background: var(--ink); color: #e9ecf3; padding: 36px 0 28px; margin-top: 40px; }
.foot a { color: #fff; }
.foot .cols { display: grid; gap: 22px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.foot h2 { font-size: 1rem; color: #fff; }
.foot ul { list-style: none; padding: 0; margin: 0; }
.foot li { margin: 0 0 8px; }
.foot .fine { margin-top: 26px; font-size: .85rem; color: #c9cfdc; }
.notfound { padding: 80px 0; text-align: center; }

/* ================= app ================= */
body.app { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
.apphead { position: sticky; top: 0; z-index: 5; background: var(--paper); border-bottom: 1px solid var(--line); }
.apphead .in { max-width: 760px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 56px; }
.apphead .brand { font-size: 1.05rem; }
.apphead .brand img { width: 30px; height: 30px; }
.sync { border: 1.5px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .85rem; font-weight: 600; min-height: 36px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.sync::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #8b8fa0; }
.sync.ok::before { background: var(--green); }
.sync.busy::before { background: var(--amber); }
.sync.warn { background: var(--warn-bg); color: #5c3800; border-color: #e8c98f; }
.sync.warn::before { background: #c27a00; }
.sync.local::before { background: var(--ink2); }
@media (max-width: 379px) {
  /* cabecera de la app en un renglón a 320 px (va después de .apphead .brand para ganar el orden) */
  .apphead .brand { font-size: .95rem; }
  .apphead .sync { padding-left: 10px; padding-right: 10px; }
}
main:focus { outline: none; }
body.app #main { max-width: 760px; margin: 0 auto; padding: 18px 16px; outline: none; }
#tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: #fff; border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); }
#tabs[hidden] { display: none; }
#tabs .in { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; max-width: 760px; }
#tabs button { background: none; border: 0; font: inherit; font-size: .78rem; font-weight: 600; color: var(--muted); padding: 8px 4px 10px; min-height: 58px; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; }
#tabs button svg { width: 24px; height: 24px; }
#tabs button[aria-current=page] { color: var(--green-d); }
#tabs button[aria-current=page] svg { stroke: var(--green); }
.fab { position: fixed; z-index: 7; right: max(16px, calc(50vw - 364px)); bottom: calc(74px + env(safe-area-inset-bottom)); min-height: 52px; padding: 12px 22px; box-shadow: 0 6px 18px rgba(20, 33, 61, .25); font-size: 1.05rem; }
.fab[hidden] { display: none; }
@media (min-width: 820px) {
  body.app { padding-bottom: 100px; } /* que el último renglón quede arriba del botón + Add */
  #tabs { position: sticky; top: 57px; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); }
  #tabs button { flex-direction: row; justify-content: center; gap: 8px; font-size: .95rem; min-height: 48px; }
  #tabs button[aria-current=page] { box-shadow: inset 0 -3px 0 var(--green); }
  .fab { bottom: 28px; }
}
.welcome { max-width: 480px; margin: 6vh auto 0; }
.welcome h1 { font-size: 1.9rem; }
.unalloc { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.label { margin: 0; font-weight: 650; color: var(--muted); font-size: .9rem; }
.big { font-size: 1.9rem; font-weight: 800; margin: 0; }
.totals { display: block; width: 100%; text-align: left; border: 0; border-radius: 10px; padding: 10px 12px; font: inherit; font-size: .88rem; cursor: pointer; font-variant-numeric: tabular-nums; }
.totals.ok { background: var(--tint); color: var(--green-d); }
.totals.warn { background: var(--warn-bg); color: #5c3800; font-weight: 600; }
.group h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
.group summary { cursor: pointer; font-weight: 650; color: var(--muted); padding: 10px 0; }
.list { list-style: none; margin: 0; padding: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.list.card { padding: 0; }
.list li + li { border-top: 1px solid var(--line); }
.row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 12px; width: 100%; text-align: left; background: #fff; border: 0; padding: 12px 14px; font: inherit; color: var(--ink); min-height: 56px; }
button.row { cursor: pointer; }
button.row:hover { background: #fbfaf7; }
.row .name { font-weight: 650; overflow-wrap: anywhere; }
.row .amt { font-weight: 750; text-align: right; white-space: nowrap; }
.row .sub { grid-column: 1 / -1; color: var(--muted); font-size: .85rem; }
.row.more { grid-template-columns: 1fr; }
.row.txn { grid-template-columns: auto 1fr auto; }
.row.txn .sub { grid-column: 2 / -1; }
.row .amt.neutral { color: var(--muted); }
.who { grid-row: span 2; width: 30px; height: 30px; border-radius: 50%; background: var(--tint); color: var(--green-d); font-weight: 800; font-size: .85rem; display: grid; place-items: center; }
.bar { grid-column: 1 / -1; display: block; height: 6px; border-radius: 6px; background: #ebe8e0; overflow: hidden; margin-top: 4px; }
.bar .fill { display: block; height: 100%; width: 0; background: var(--green); border-radius: 6px; }
.bar.over .fill { background: var(--danger); }
.empty { color: var(--muted); text-align: center; padding: 28px 10px; }
.filters { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .filters { grid-template-columns: 2fr 1fr 1fr; } }
.grid2 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid2 .field > label, .fillgrid .field > label { flex: 1; } /* etiquetas de 2 renglones: los campos quedan alineados */
.fillgrid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.total { font-weight: 700; margin: 0; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); border: 1.5px solid var(--green); border-radius: 12px; overflow: hidden; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label { text-align: center; padding: 10px 4px; font-weight: 650; font-size: .92rem; color: var(--green-d); cursor: pointer; min-height: 44px; display: grid; place-items: center; }
.seg label + input + label, .seg input + label ~ label { border-left: 1px solid var(--line); }
.seg input:checked + label { background: var(--green); color: #fff; }
.seg input:focus-visible + label { outline: 3px solid var(--ink); outline-offset: -4px; }
.split { display: grid; grid-template-columns: 1fr 120px 44px; gap: 8px; align-items: end; }
.split .x { height: 44px; }
.dlg { width: min(560px, calc(100vw - 20px)); max-height: calc(100dvh - 20px); border: 0; border-radius: 18px; padding: 0; color: var(--ink); box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.dlg.wide { width: min(760px, calc(100vw - 20px)); }
.dlg::backdrop { background: rgba(20, 33, 61, .45); }
.dlg > .stack, .dlg > form, .dlg > div:not(.dhead) { padding: 4px 18px 20px; }
.dhead { position: sticky; top: 0; background: #fff; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px 10px; z-index: 1; }
.dhead h2 { margin: 0; font-size: 1.2rem; }
.x { background: none; border: 1.5px solid var(--line); border-radius: 50%; width: 40px; height: 40px; font-size: 1.4rem; line-height: 1; color: var(--ink); cursor: pointer; flex: none; }
.x:hover { background: var(--paper); }
@media (max-width: 560px) {
  .dlg, .dlg.wide { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 18px 18px 0 0; max-height: 92dvh; }
}
.toast { position: fixed; left: 50%; bottom: calc(140px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; max-width: min(92vw, 480px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20; font-weight: 600; }
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (min-width: 820px) { .toast { bottom: 100px; } }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
