:root {
  --bg: #f3f6f5;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --border: #dde5e2;
  --text: #13201d;
  --muted: #5b6965;
  --accent: #0f766e;
  --accent-strong: #0b5e57;
  --accent-ink: #ffffff;
  --accent-soft: #d8f0eb;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #a14a07;
  --warn-soft: #fef3c7;
  --info: #1d4ed8;
  --info-soft: #e0eaff;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --wa: #128c4a; /* verde de WhatsApp */
  --shadow-sm: 0 1px 2px rgba(16, 24, 22, .06);
  --shadow: 0 1px 2px rgba(16, 24, 22, .05), 0 6px 20px -6px rgba(16, 24, 22, .10);
  --shadow-lg: 0 24px 64px -12px rgba(10, 20, 18, .35);
  --radius: 18px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --tabs-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1211; --surface: #131c1a; --surface-2: #1a2523; --border: #26332f;
    --text: #e6eeec; --muted: #93a49f; --accent: #2dd4bf; --accent-strong: #5eead4; --accent-ink: #052320;
    --accent-soft: #113833; --ok: #4ade80; --ok-soft: #12301d; --warn: #fbbf24; --warn-soft: #362a0b;
    --info: #93b4ff; --info-soft: #172443; --danger: #f87171; --danger-soft: #3a1414; --wa: #3ddc84;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow: 0 1px 2px rgba(0, 0, 0, .35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1211; --surface: #131c1a; --surface-2: #1a2523; --border: #26332f;
  --text: #e6eeec; --muted: #93a49f; --accent: #2dd4bf; --accent-strong: #5eead4; --accent-ink: #052320;
  --accent-soft: #113833; --ok: #4ade80; --ok-soft: #12301d; --warn: #fbbf24; --warn-soft: #362a0b;
  --info: #93b4ff; --info-soft: #172443; --danger: #f87171; --danger-soft: #3a1414; --wa: #3ddc84;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow: 0 1px 2px rgba(0, 0, 0, .35); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; letter-spacing: -.015em; text-wrap: balance; }
h1 { font-size: clamp(26px, 6vw, 34px); font-weight: 800; line-height: 1.12; }
h2 { font-size: 17px; font-weight: 750; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 13px; font-weight: 700; margin: 18px 0 4px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
p { text-wrap: pretty; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.sm { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.eyebrow { margin: 0 0 4px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
main:focus { outline: none; }
/* Solo aparece al llegar con Tab: el primer elemento enfocable de la página. */
.saltar {
  position: fixed; left: 12px; top: 8px; z-index: 80; padding: 10px 14px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; text-decoration: none; transform: translateY(-160%);
}
.saltar:focus-visible { transform: none; }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-txt { min-width: 0; }
.brand strong { display: block; font-size: 17px; line-height: 1.1; font-weight: 800; }
.brand small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw; }
.logo svg { width: 34px; height: 34px; display: block; }
.logo rect { fill: var(--accent); stroke: none; }
.logo path { stroke: var(--accent-ink); stroke-width: 3.2; }
.top-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.tasa-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform 140ms var(--ease-out), border-color 150ms ease;
}
.tasa-chip:active { transform: scale(.97); }
.tasa-chip .tasa-k { color: var(--muted); font-weight: 600; }
.tasa-chip b { font-variant-numeric: tabular-nums; }
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); cursor: pointer; box-shadow: var(--shadow-sm); transition: transform 140ms var(--ease-out), color 150ms ease;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:active { transform: scale(.94); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.live { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
.dot.manual { background: var(--warn); }
.dot.off { background: var(--muted); }

/* ---------- Pestañas: abajo en el teléfono, arriba en escritorio ---------- */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  position: relative; border: 0; background: none; color: var(--muted); font: inherit; font-size: 11px; font-weight: 650;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: var(--tabs-h); cursor: pointer;
  transition: color 150ms ease;
}
.tabs button svg { transition: transform 160ms var(--ease-out); }
.tabs button:active svg { transform: scale(.88); }
.tabs button.active { color: var(--accent); }
.tabs button.active::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
.tab-badge {
  position: absolute; top: 8px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink); font-style: normal; font-size: 10.5px; font-weight: 800; line-height: 18px; text-align: center;
  font-variant-numeric: tabular-nums;
}
@media (min-width: 860px) {
  :root { --tabs-h: 0px; }
  body { padding-bottom: 40px; }
  .tabs {
    position: sticky; top: 61px; bottom: auto; z-index: 19; display: flex; justify-content: center; gap: 4px;
    border-top: 0; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 82%, transparent); padding: 6px 16px;
  }
  .tabs button { flex-direction: row; height: auto; font-size: 14px; padding: 8px 14px; border-radius: 10px; gap: 8px; }
  .tabs button svg { width: 18px; height: 18px; }
  .tabs button.active { background: var(--accent-soft); }
  .tabs button.active::before { display: none; }
  .tab-badge { position: static; margin-left: 2px; }
}

main { max-width: 1120px; margin: 0 auto; padding: 16px; }
.view { display: none; }
.view.active { display: block; animation: entrar 220ms var(--ease-out); }
@keyframes entrar { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Tarjetas y listas ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card + .card, .grid-2, .kpis { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.count { font-size: 12px; font-weight: 800; background: var(--surface-2); color: var(--muted); padding: 1px 8px; border-radius: 99px; font-variant-numeric: tabular-nums; }
.count:empty { display: none; }
.grid-2 { display: grid; gap: 14px; }
@media (min-width: 860px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.hero { display: flex; flex-direction: column; gap: 18px; padding: 6px 2px 4px; }
.hero-p { margin: 8px 0 0; color: var(--muted); max-width: 58ch; }
@media (min-width: 860px) {
  .hero { flex-direction: row; align-items: flex-end; justify-content: space-between; padding: 14px 4px 8px; }
}

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 860px) { .kpis { grid-template-columns: repeat(4, 1fr); gap: 14px; } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px; min-width: 0; box-shadow: var(--shadow-sm); }
.kpi span { display: block; color: var(--muted); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
/* Los montos nunca se parten: si son largos, se achica la letra. */
.kpi b { display: block; font-size: clamp(17px, 5vw, 23px); font-weight: 800; margin-top: 4px; white-space: nowrap; line-height: 1.25; }
.kpi b.largo { font-size: clamp(14px, 4.2vw, 19px); }
.kpi b.muy-largo { font-size: clamp(12px, 3.6vw, 16px); letter-spacing: -.01em; }
.kpi small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi.neg b { color: var(--danger); }
.kpi.pulse { animation: pulso 700ms var(--ease-out); }
@keyframes pulso { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } to { box-shadow: 0 0 0 12px transparent; } }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border); }
.list > li:first-child { border-top: 0; }
.list > li:has(> .row-btn) { padding: 0; }
.row-btn {
  display: flex; justify-content: space-between; gap: 12px; padding: 11px 8px; margin: 0 -8px; width: calc(100% + 16px);
  border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: 12px;
  transition: background-color 150ms ease, transform 140ms var(--ease-out);
}
.row-btn:active { transform: scale(.985); background: var(--surface-2); }
@media (hover: hover) and (pointer: fine) { .row-btn:hover { background: var(--surface-2); } }
.l { display: flex; flex-direction: column; min-width: 0; }
.r { display: flex; flex-direction: column; align-items: flex-end; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; gap: 2px; flex: none; }
.t { font-weight: 650; }
.l .t, .l .s { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); font-size: 14px; padding: 14px 0; display: block !important; text-wrap: pretty; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  border: 1px solid transparent; border-radius: 12px; padding: 10px 16px; font: inherit; font-weight: 700; cursor: pointer;
  background: var(--surface-2); color: var(--text); white-space: nowrap;
  transition: transform 140ms var(--ease-out), background-color 150ms ease, opacity 150ms ease, box-shadow 150ms ease;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn svg { width: 19px; height: 19px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 0 rgba(255, 255, 255, .15) inset, 0 6px 16px -6px color-mix(in srgb, var(--accent) 70%, transparent); }
@media (hover: hover) and (pointer: fine) { .btn.primary:hover:not(:disabled) { background: var(--accent-strong); } .btn.ghost:hover { background: var(--surface-2); } }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn.lg { min-height: 52px; padding: 14px 22px; font-size: 16px; border-radius: 14px; }
.btn.block { width: 100%; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; }
.link { background: none; border: 0; color: var(--accent); font: inherit; font-weight: 650; cursor: pointer; padding: 8px 0; min-height: 40px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; font-weight: 600;
  padding: 7px 12px; min-height: 36px; border-radius: 99px; cursor: pointer; transition: transform 140ms var(--ease-out), border-color 150ms ease, background-color 150ms ease;
}
.chip:active { transform: scale(.96); background: var(--accent-soft); border-color: var(--accent); }
@media (hover: hover) and (pointer: fine) { .chip:hover { border-color: var(--accent); } }

/* ---------- Registrar pago ---------- */
.steps { display: grid; gap: 14px; }
@media (min-width: 1000px) {
  .steps { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; }
  .steps .step:first-child { grid-row: span 2; position: sticky; top: 124px; }
}
.step { display: flex; flex-direction: column; gap: 14px; scroll-margin-top: 76px; }
.step + .step { margin-top: 0; }
.step-head { display: flex; align-items: center; gap: 10px; }
.step-head .badge { margin-left: auto; }
.step-n { width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 13px; font-weight: 800; background: var(--accent-soft); color: var(--accent); }
.drop {
  position: relative; display: grid; place-items: center; min-height: 170px; border: 2px dashed var(--border); border-radius: 16px;
  background: var(--surface-2); cursor: pointer; overflow: hidden; text-align: center; transition: border-color 150ms ease, background-color 150ms ease;
}
.drop:focus-within { border-color: var(--accent); }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
@media (hover: hover) and (pointer: fine) { .drop:hover { border-color: var(--accent); } }
.drop-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px; color: var(--muted); }
.drop-empty svg { width: 36px; height: 36px; color: var(--accent); margin-bottom: 4px; }
.drop-empty b { color: var(--text); font-size: 16px; }
.drop-empty small { max-width: 30ch; text-wrap: balance; }
.drop img { max-width: 100%; max-height: 340px; display: block; outline: 1px solid rgba(0, 0, 0, .08); outline-offset: -1px; }
/* Línea que recorre la captura mientras el OCR lee: movimiento constante, por eso lineal. */
.scan {
  position: absolute; left: 0; right: 0; top: 0; height: 46px; pointer-events: none; opacity: .8;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--accent) 35%, transparent) 80%, var(--accent));
  animation: escanear 1.6s linear infinite;
}
@keyframes escanear { from { transform: translateY(-46px); } to { transform: translateY(340px); } }
.ocr-status { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.ocr-status.err { color: var(--warn); }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); transition: transform 300ms var(--ease-out); }
.ejemplos { display: flex; flex-direction: column; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 650; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hint { font-weight: 500; }
input, select, textarea {
  font: inherit; font-size: 16px; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 11px; padding: 10px 12px; width: 100%; min-width: 0; min-height: 44px;
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 400ms ease;
}
textarea { resize: vertical; font-size: 14px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input[type="search"] { -webkit-appearance: none; appearance: none; }
/* Campo leído del comprobante: se ilumina un instante y queda con un tinte suave. */
input.detected { background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); animation: detectado 900ms var(--ease-out); }
@keyframes detectado { from { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); } to { box-shadow: 0 0 0 0 transparent; } }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; cursor: pointer; min-height: 40px; padding-top: 8px; }
.check input { width: 20px; height: 20px; min-height: 0; padding: 0; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.check small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.badge { display: inline-block; font-size: 12px; font-weight: 750; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

.calc { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.calc:empty { display: none; }
.calc div { background: var(--surface-2); border-radius: 12px; padding: 10px; min-width: 0; }
.calc span { display: block; font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.calc b { font-size: 14px; overflow-wrap: break-word; }
.note { margin: 0; padding: 10px 12px; border-radius: 12px; font-size: 14px; line-height: 1.45; overflow-wrap: break-word; }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.info { background: var(--info-soft); color: var(--info); }
.note .check { color: var(--text); padding-top: 6px; min-height: 0; }

.sugerencias { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sugerencias > .empty { padding: 4px 0; }
.sug {
  display: flex; gap: 12px; align-items: flex-start; border: 1.5px solid var(--border); border-radius: 14px; padding: 12px;
  cursor: pointer; transition: border-color 150ms ease, background-color 150ms ease, transform 140ms var(--ease-out);
}
.sug:active { transform: scale(.985); }
@media (hover: hover) and (pointer: fine) { .sug:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); } }
.sug.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface)); }
.sug input { accent-color: var(--accent); width: 20px; height: 20px; min-height: 0; padding: 0; margin: 2px 0 0; flex: none; }
.sug .info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sug .t { font-weight: 700; overflow-wrap: break-word; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sug .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sug.anticipo .s { white-space: normal; }
.sug .tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.sug .tags span { font-size: 11.5px; font-weight: 650; background: var(--surface-2); padding: 2px 8px; border-radius: 99px; }
.sug.sel .tags span { background: var(--surface); }
.sug .r { gap: 4px; }
/* Teléfono angosto: monto, "espera" y nivel pasan a una fila bajo el nombre para que el nombre tenga todo el ancho. */
@media (max-width: 420px) {
  .sug { flex-wrap: wrap; row-gap: 6px; }
  .sug .info { flex-basis: calc(100% - 32px); }
  .sug .r { flex-basis: 100%; flex-direction: row; align-items: center; justify-content: flex-start; flex-wrap: wrap; gap: 4px 10px; padding-left: 32px; text-align: left; }
}
.sug.anticipo { border-style: dashed; }
.ant-cli { margin-top: 8px; }
.combo {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 14px;
  background: var(--info-soft); color: var(--info); animation: entrar 220ms var(--ease-out);
}
.combo > div { min-width: 0; }
.combo b, .combo .s { display: block; }
.combo .s { color: inherit; opacity: .85; overflow-wrap: break-word; }
.combo .btn { background: var(--surface); color: var(--info); flex: none; }
.buscar input { min-height: 40px; font-size: 15px; }
.opciones { display: flex; flex-direction: column; gap: 8px; }
.opciones:empty { display: none; }
.opt { background: var(--surface-2); padding: 10px 12px; border-radius: 12px; }

.prev summary { cursor: pointer; font-size: 13px; font-weight: 700; color: var(--muted); padding: 6px 0; list-style: none; display: flex; align-items: center; gap: 8px; min-height: 36px; }
.prev summary::-webkit-details-marker { display: none; }
.prev summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform 160ms var(--ease-out); }
.prev[open] summary::before { transform: rotate(45deg); }

/* Barra de acción: pegada abajo en el teléfono, sobre las pestañas */
.action-bar {
  position: sticky; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); z-index: 15; margin: 14px -16px -16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px;
  background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.action-sum { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.action-sum b { font-size: clamp(14px, 4.6vw, 17px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.action-sum span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.action-bar .btn { flex: none; max-width: 62%; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 380px) { .action-bar .btn.lg { padding: 12px 14px; font-size: 15px; min-height: 48px; } .action-bar { gap: 8px; } }
@media (min-width: 860px) {
  .action-bar { bottom: 16px; margin: 14px 0 0; border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); }
}

.asiento { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface); }
.asiento + .asiento, .asiento + .btn { margin-top: 12px; }
.asiento header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; background: var(--surface-2); padding: 9px 12px; font-size: 13px; }
.asiento header b { font-weight: 700; overflow-wrap: break-word; min-width: 0; }
.asiento .meta { display: flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; flex: none; }
.tag { font-style: normal; font-size: 11px; font-weight: 750; padding: 1px 7px; border-radius: 99px; background: var(--surface); }
.tag.t-cobro { color: var(--ok); }
.tag.t-anticipo { color: var(--info); }
.asiento table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.asiento thead th { font-size: 11px; color: var(--muted); font-weight: 650; text-align: right; padding: 5px 12px 0; }
.asiento thead th:first-child { text-align: left; }
.asiento td { padding: 6px 12px; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; overflow-wrap: break-word; vertical-align: top; }
.asiento td:nth-child(2), .asiento td:nth-child(3), .asiento th:nth-child(2), .asiento th:nth-child(3) { text-align: right; width: 27%; white-space: nowrap; overflow-wrap: normal; }
.asiento td.haber-cta { padding-left: 26px; }
.asiento tfoot td { font-weight: 800; }
/* Teléfono: cada línea ocupa el ancho completo y el monto va a la derecha con su lado (Debe/Haber). */
@media (max-width: 560px) {
  .asiento thead { display: none; }
  .asiento tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; align-items: baseline; padding: 7px 12px; border-top: 1px solid var(--border); }
  .asiento td { border: 0; padding: 0 !important; width: auto !important; }
  .asiento td:nth-child(2):empty, .asiento td:nth-child(3):empty { display: none; }
  .asiento td.haber-cta { padding-left: 14px !important; }
  .asiento tbody td:nth-child(2)::after, .asiento tbody td:nth-child(3)::after { display: block; font-size: 10.5px; font-weight: 650; color: var(--muted); }
  .asiento tbody td:nth-child(2)::after { content: "Debe"; }
  .asiento tbody td:nth-child(3)::after { content: "Haber"; }
  .asiento tfoot tr { grid-template-columns: minmax(0, 1fr) auto auto; }
  .asiento header { flex-direction: column; gap: 2px; }
  .asiento .meta { order: -1; }
  .asiento td small { white-space: nowrap; }
}

/* ---------- Facturas ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.toolbar input { flex: 1 1 160px; min-height: 40px; font-size: 15px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; max-width: 100%; overflow-x: auto; }
.seg button {
  border: 0; background: none; font: inherit; font-size: 13px; font-weight: 650; color: var(--muted); padding: 7px 12px; min-height: 36px;
  border-radius: 9px; cursor: pointer; white-space: nowrap; transition: background-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
@media (max-width: 359px) { .solo-ancho { display: none; } }
/* Teléfono: los filtros ocupan el ancho y se reparten; sin barra de desplazamiento */
@media (max-width: 560px) {
  .toolbar .seg { display: flex; width: 100%; scrollbar-width: none; }
  .toolbar .seg::-webkit-scrollbar { display: none; }
  .toolbar .seg button { flex: 1 1 auto; padding: 7px 6px; }
}
@media (max-width: 359px) { .toolbar .seg button { font-size: 12px; padding: 7px 3px; letter-spacing: -.01em; } }
.flist { list-style: none; margin: 0 -8px; padding: 0; }
.flist > li + li { border-top: 1px solid var(--border); }
.flist > .empty { padding-left: 8px; }
.frow {
  display: flex; justify-content: space-between; gap: 12px; width: 100%; padding: 12px 8px; border: 0; background: none; color: inherit;
  font: inherit; text-align: left; cursor: pointer; border-radius: 12px; transition: background-color 150ms ease, transform 140ms var(--ease-out);
}
.frow:active { transform: scale(.985); background: var(--surface-2); }
@media (hover: hover) and (pointer: fine) { .frow:hover { background: var(--surface-2); } }
.frow .t b { font-weight: 800; }
.frow .r { gap: 5px; }
.progress { display: block; height: 4px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 7px; max-width: 220px; }
.progress i { display: block; height: 100%; background: var(--ok); transform-origin: left; border-radius: inherit; }
.progress.lg { height: 8px; max-width: none; margin: 14px 0 4px; }

/* ---------- Libro ---------- */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
.balance { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 520px; }
.balance th { text-align: right; font-size: 11.5px; color: var(--muted); font-weight: 650; padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.balance th:first-child, .balance td:first-child { text-align: left; }
.balance td { padding: 8px; border-bottom: 1px solid var(--border); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.balance td:first-child { white-space: normal; overflow-wrap: break-word; }
.balance tfoot td { font-weight: 800; border-bottom: 0; }
.foot-actions { display: flex; justify-content: flex-end; margin-top: 16px; }

/* ---------- Diálogos: hoja inferior en el teléfono, ventana centrada en escritorio ---------- */
dialog {
  border: 1px solid var(--border); padding: 20px; background: var(--surface); color: var(--text);
  width: 100%; max-width: 100%; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  margin: auto auto 0; border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg);
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateY(0); opacity: 1;
  transition: transform 340ms var(--ease-drawer), opacity 200ms ease, display 340ms allow-discrete, overlay 340ms allow-discrete;
}
dialog:not([open]) { transform: translateY(100%); transition-duration: 200ms; }
@starting-style { dialog[open] { transform: translateY(100%); } }
dialog::backdrop { background: rgba(8, 16, 14, .45); opacity: 1; transition: opacity 260ms ease, display 260ms allow-discrete, overlay 260ms allow-discrete; }
dialog:not([open])::backdrop { opacity: 0; }
@starting-style { dialog[open]::backdrop { opacity: 0; } }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: -8px auto 8px; }
@media (min-width: 640px) {
  dialog {
    width: min(500px, calc(100vw - 32px)); margin: auto; border-radius: 22px; padding-bottom: 20px;
    transition: transform 220ms var(--ease-out), opacity 200ms var(--ease-out), display 220ms allow-discrete, overlay 220ms allow-discrete;
  }
  dialog:not([open]) { transform: scale(.97); opacity: 0; transition-duration: 150ms; }
  @starting-style { dialog[open] { transform: scale(.96); opacity: 0; } }
  .sheet-grip { display: none; }
}
dialog h2 { margin-bottom: 2px; }
dialog h2:focus, dialog h2:focus-visible { outline: none; }
.det-head .eyebrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.det-head .eyebrow .badge { text-transform: none; letter-spacing: 0; }
.det-head h2 { overflow-wrap: break-word; }
.det-head p { margin: 2px 0 0; overflow-wrap: break-word; }
.det-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
@media (max-width: 359px) { .det-grid { grid-template-columns: minmax(0, 1fr); } }
.det-grid > div { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.det-grid span { display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
/* Montos y RIF no se parten (el guion del RIF es punto de corte para el navegador). */
.det-grid b { display: block; font-size: clamp(14px, 4.4vw, 16px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.det-grid small { display: block; color: var(--muted); font-size: 12px; overflow-wrap: break-word; }
.det-actions { margin-top: 16px; }

/* Éxito: el check se dibuja una vez (momento poco frecuente: se permite un poco de deleite) */
.exito { text-align: center; }
.exito h2 { justify-content: center; font-size: 20px; margin-top: 4px; overflow-wrap: break-word; }
.exito .row { margin-top: 18px; }
.exito .row .btn { flex: 1 1 140px; }
.check-anim { display: grid; place-items: center; margin: 4px auto 6px; }
.check-anim svg { width: 64px; height: 64px; }
.check-anim circle { stroke: var(--ok); stroke-width: 3; fill: var(--ok-soft); stroke-dasharray: 152; stroke-dashoffset: 152; }
.check-anim path { stroke: var(--ok); stroke-width: 4; stroke-dasharray: 40; stroke-dashoffset: 40; }
dialog.exito[open] .check-anim circle { animation: trazo 500ms var(--ease-out) 120ms forwards; }
dialog.exito[open] .check-anim path { animation: trazo 320ms var(--ease-out) 460ms forwards; }
dialog.exito[open] .check-anim svg { animation: pop 500ms var(--ease-out) 120ms both; }
@keyframes trazo { to { stroke-dashoffset: 0; } }
@keyframes pop { from { transform: scale(.85); } 60% { transform: scale(1.04); } to { transform: scale(1); } }
.resumen { margin: 14px 0 0; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.resumen > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 12px; background: var(--surface-2); border-radius: 12px; }
.resumen dt { color: var(--muted); font-size: 13px; font-weight: 600; flex: none; }
.resumen dd { margin: 0; text-align: right; min-width: 0; }
.resumen dd b { display: block; overflow-wrap: break-word; }
.resumen dd small { display: block; color: var(--muted); font-size: 12px; overflow-wrap: break-word; }

/* ---------- Toast (popover: queda encima de los diálogos) ---------- */
.toast {
  position: fixed; top: auto; right: auto; left: 50%; bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom)); z-index: 60;
  margin: 0; border: 0; overflow: visible; height: auto;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 14px; font-weight: 650; font-size: 14px;
  box-shadow: var(--shadow-lg); width: max-content; max-width: calc(100vw - 32px); text-wrap: pretty; text-align: center;
  transition: transform 260ms var(--ease-out), opacity 200ms ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }
.toast.con-accion.show { pointer-events: auto; display: flex; align-items: center; gap: 14px; text-align: left; padding: 8px 8px 8px 16px; }
.toast button {
  flex: none; min-height: 36px; padding: 6px 12px; border: 0; border-radius: 10px; font: inherit; font-weight: 800; cursor: pointer;
  background: color-mix(in srgb, var(--bg) 16%, transparent); color: inherit; transition: transform 140ms var(--ease-out);
}
.toast button:active { transform: scale(.96); }

/* ---------- Franja de aviso (sin red, guardado, datos recuperados) ---------- */
.aviso {
  position: sticky; top: calc(61px + env(safe-area-inset-top)); z-index: 18; display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; font-size: 13.5px; line-height: 1.4; border-bottom: 1px solid var(--border);
  opacity: 1; transform: none; transition: opacity 200ms ease, transform 240ms var(--ease-out);
}
@starting-style { .aviso { opacity: 0; transform: translateY(-6px); } }
.aviso-txt { flex: 1; min-width: 0; text-wrap: pretty; }
.aviso .btn { flex: none; background: var(--surface); }
.aviso-ico { width: 8px; height: 8px; border-radius: 50%; flex: none; background: currentColor; }
.aviso.info { background: var(--info-soft); color: var(--info); }
.aviso.warn { background: var(--warn-soft); color: var(--warn); }
.aviso.error { background: var(--danger-soft); color: var(--danger); }
@media (min-width: 860px) { .aviso { top: 61px; justify-content: center; } .aviso-txt { flex: 0 1 auto; } }

/* Tasa: el punto late mientras se consulta al BCV (movimiento constante, por eso lineal) */
.tasa-chip.cargando .dot { animation: latido 900ms linear infinite; }
@keyframes latido { 50% { opacity: .3; } }

/* ---------- Banner de datos de ejemplo ---------- */
.demo-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
  padding: 12px 14px; border-radius: 16px; background: var(--accent-soft); color: var(--text); font-size: 14px; line-height: 1.45;
}
.demo-banner span { flex: 1 1 220px; text-wrap: pretty; }
.demo-banner .btn { background: var(--surface); color: var(--accent); flex: none; }

/* ---------- Estados vacíos ---------- */
.vacio {
  display: flex !important; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 22px 12px !important;
  border: 0 !important; color: var(--muted); font-size: 14px;
}
.vacio b { color: var(--text); font-size: 15px; }
.vacio span:not(.vacio-ico) { max-width: 34ch; text-wrap: pretty; }
.vacio .btn { margin-top: 10px; }
.vacio-ico { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); margin-bottom: 6px; }
.vacio-ico svg { width: 22px; height: 22px; }
.vacio.es-ok .vacio-ico { background: var(--ok-soft); color: var(--ok); }

/* Recién registrado: se ilumina una vez al aparecer, para ver dónde quedó */
.nuevo > .row-btn, .nuevo > .frow, li.nuevo:not(:has(> button)), .asiento.nuevo { animation: resaltar 1800ms var(--ease-out); }
.asiento.nuevo { border-color: var(--accent); }
@keyframes resaltar { from { background-color: color-mix(in srgb, var(--accent) 22%, var(--surface)); } to { background-color: transparent; } }
.anulado .t, .anulado .r .t { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 70%, transparent); color: var(--muted); }
.cobros-det .anular { align-self: flex-start; padding: 2px 0; min-height: 32px; font-size: 13px; color: var(--danger); }
.tag.t-anulacion { color: var(--danger); }
.tag.t-devolucion { color: var(--warn); }
.badge.anulada { background: var(--danger-soft); color: var(--danger); }
/* Anticipo del cliente en el detalle de la factura: aplicar o devolver */
.ant-box { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: var(--info-soft); color: var(--info); }
.ant-box b, .ant-box .s { display: block; }
.ant-box .s { color: inherit; opacity: .85; }
.ant-box .btn { background: var(--surface); color: var(--info); }
/* Cierre del día */
.cierre-fecha { margin: 12px 0 6px; max-width: 220px; }
.cierre-lista { margin-top: 6px; }
.cierre-acciones { margin-top: 16px; }
.cierre-acciones a.btn { text-decoration: none; }
.editar-cli { display: block; margin: 4px 0 0 auto; font-size: 13px; min-height: 36px; }
.det-anular { margin-right: auto; color: var(--danger); font-size: 14px; }
/* Recordar pago: verde de WhatsApp, reconocible de un vistazo */
.btn.whatsapp { margin-top: 16px; background: #128c4a; color: #fff; text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .btn.whatsapp:hover { background: #0f7a40; } }
.recordar-nota { margin: 6px 2px 0; text-wrap: pretty; }
/* Por cliente: la fila abre su factura más vieja; el botón verde, el recordatorio de WhatsApp */
.clientes-total { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 8px; color: var(--muted); font-size: 14px; }
.clientes-total b { color: var(--text); font-size: 17px; }
.crow { display: flex; align-items: center; gap: 4px; }
.crow .frow { flex: 1; min-width: 0; }
.wa-mini {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; margin-right: 4px;
  background: color-mix(in srgb, var(--wa) 16%, var(--surface)); color: var(--wa); transition: transform 140ms var(--ease-out);
}
.wa-mini:active { transform: scale(.94); }
.wa-mini svg { width: 21px; height: 21px; }
.tab-dot { position: absolute; top: 10px; left: calc(50% + 9px); width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--surface); animation: pop 300ms var(--ease-out); }
@media (min-width: 860px) { .tab-dot { position: static; margin-left: 2px; box-shadow: none; } }

/* ---------- Ajustes: tus datos ---------- */
.datos-sec { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 4px; }
.datos-sec h3 { margin-top: 12px; }
.datos-sec p { margin: 4px 0 10px; }
.datos-acciones { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.datos-acciones .btn:not(.sm) { flex: 1 1 180px; }
label.btn { position: relative; }

/* ---------- Exportar ---------- */
.exp-seg { display: flex; margin: 14px 0 10px; }
.exp-seg button { flex: 1; }
.exp-resumen { display: flex; flex-direction: column; gap: 2px; margin: 0 0 14px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); font-size: 14px; }
.exp-resumen span { color: var(--muted); }
.exp-acciones { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Bienvenida (una sola vez: aquí sí cabe un poco de deleite) ---------- */
.bienvenida { text-align: center; }
.logo.big svg { width: 56px; height: 56px; margin: 4px auto 10px; }
.bienvenida h2 { justify-content: center; font-size: 22px; line-height: 1.2; }
.pasos { list-style: none; counter-reset: paso; margin: 18px 0; padding: 0; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.pasos li { counter-increment: paso; display: grid; grid-template-columns: 30px 1fr; column-gap: 12px; padding: 12px; border-radius: 14px; background: var(--surface-2); }
.pasos li::before { content: counter(paso); grid-row: span 2; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 14px; background: var(--accent); color: var(--accent-ink); }
.pasos span { color: var(--muted); font-size: 13.5px; text-wrap: pretty; }
dialog.bienvenida[open] .pasos li { animation: subir 420ms var(--ease-out) both; }
dialog.bienvenida[open] .pasos li:nth-child(2) { animation-delay: 70ms; }
dialog.bienvenida[open] .pasos li:nth-child(3) { animation-delay: 140ms; }
@keyframes subir { from { opacity: 0; transform: translateY(10px); } }
.bien-acciones { display: flex; flex-direction: column; gap: 8px; }
.bien-nota { margin: 12px 0 0; }

/* ---------- Confirmar y deshacer ---------- */
.confirmar p { margin: 8px 0 0; text-wrap: pretty; }
.confirmar .row { margin-top: 18px; }
.btn.primary.peligro { background: var(--danger); color: #fff; box-shadow: none; }
@media (hover: hover) and (pointer: fine) { .btn.primary.peligro:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 85%, #000); } }
.deshacer { display: block; margin: 12px auto 0; font-size: 13.5px; color: var(--muted); min-height: 36px; }
body[data-vista="pago"] .toast { bottom: calc(var(--tabs-h) + 92px + env(safe-area-inset-bottom)); }
@media (min-width: 860px) { .toast { bottom: 28px; } body[data-vista="pago"] .toast { bottom: 110px; } }

/* ---------- Movimiento reducido: sin desplazamientos, solo opacidad ---------- */
@media (prefers-reduced-motion: reduce) {
  .view.active, .combo { animation: aparecer 160ms ease; }
  @keyframes aparecer { from { opacity: 0; } to { opacity: 1; } }
  .scan { animation: none; opacity: .35; }
  dialog, dialog:not([open]) { transform: none; transition: opacity 160ms ease, display 160ms allow-discrete, overlay 160ms allow-discrete; }
  dialog:not([open]) { opacity: 0; }
  @starting-style { dialog[open] { opacity: 0; transform: none; } }
  .btn:active:not(:disabled), .chip:active, .sug:active, .frow:active, .row-btn:active, .tasa-chip:active, .icon-btn:active, .tabs button:active svg { transform: none; }
  dialog.exito[open] .check-anim svg { animation: none; }
  dialog.exito[open] .check-anim circle, dialog.exito[open] .check-anim path { animation: none; stroke-dashoffset: 0; }
  .kpi.pulse, input.detected { animation: none; }
  .toast { transition: opacity 200ms ease; transform: translate(-50%, 0); }
  .aviso { transition: opacity 200ms ease; transform: none; }
  dialog.bienvenida[open] .pasos li { animation: aparecer 200ms ease both; }
  .tab-dot { animation: none; }
  .toast button:active { transform: none; }
}

/* Solo desarrollo (?datos=…): selector de datos de prueba */
.dev-toggle {
  position: fixed; left: 50%; top: calc(66px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 70;
  display: flex; gap: 2px; padding: 3px; background: #e5e7eb; border-radius: 10px; font: 12px/1 system-ui, sans-serif; box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}
.dev-toggle a { padding: 7px 9px; border-radius: 7px; color: #374151; text-decoration: none; white-space: nowrap; }
.dev-toggle a.on { background: #fff; color: #111; font-weight: 600; }
