:root {
  --bg: #f4f6f5; --card: #ffffff; --fg: #17211f; --muted: #55625f; --line: #d5dcda; --line2: #e3e9e7; --soft: #eaf0ee;
  --brand: #0e5a4b; --brand-fg: #ffffff; --hero: #0e5a4b; --hero-fg: #ffffff;
  --accent: #e3f1ed; --accent-fg: #0a4237;
  --in: #0b6b4c; --in-bg: #e3f3ec; --in-bar: #0f7a58; --out: #a63620; --out-bg: #fbe6df; --out-bar: #e8896f;
  --amber: #6b4300; --amber-bg: #fdefc8;
  --warn: var(--out); --warn-bg: var(--out-bg); --ok: var(--in); --ok-bg: var(--in-bg);
  --r: 22px; --shadow: 0 12px 32px rgba(14, 90, 75, .14);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.4 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif; font-variant-numeric: tabular-nums; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
main { max-width: 720px; margin: 0 auto; padding: 16px; }
[hidden] { display: none !important; }
h1 { font-size: 24px; margin: 4px 0 12px; }
h2 { font-size: 19px; font-weight: 800; margin: 0; }
a { color: var(--brand); }
svg { flex: none; }

/* Cabecera con color */
.band { background: var(--hero); color: var(--hero-fg); padding: 22px 20px 96px; border-radius: 0 0 32px 32px; display: flex; flex-direction: column; gap: 16px; }
.band.corta { padding-bottom: 28px; }
.band-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 720px; width: 100%; margin: 0 auto; }
.band-in { max-width: 720px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.band h1 { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.band .sub { font-size: 14px; opacity: .88; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar { flex: none; width: 46px; height: 46px; border-radius: 50%; background: var(--accent); color: #0a4237; font-weight: 800; font-size: 20px; display: flex; align-items: center; justify-content: center; }
.who small { display: block; font-size: 13px; opacity: .85; }
.who b { display: block; font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.round { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .16); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none; }
.pull { margin-top: -84px; }

/* Selectores de período y filtros */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chip { flex: 0 0 auto; min-height: 44px; padding: 0 18px; border: 1px solid transparent; border-radius: 99px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; background: rgba(255, 255, 255, .16); color: #fff; }
.chip.on { background: var(--accent); color: var(--accent-fg); font-weight: 700; }
.band .chips .chip { flex: 1 1 0; padding: 0 8px; }
.filtros { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 14px 0 8px; }
.filtros .chip { background: var(--card); color: var(--fg); border-color: var(--line); }
.filtros .chip.on { background: var(--brand); color: var(--brand-fg); border-color: var(--brand); }

/* Tarjetas */
.card { background: var(--card); border: 0; border-radius: var(--r); padding: 16px; margin: 12px 0; }
.sheet { background: var(--card); border-radius: 26px; padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px; }
.lbl { font-size: 14px; font-weight: 600; color: var(--muted); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tag { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: var(--in-bg); color: var(--in); white-space: nowrap; }
.tag.warn { background: var(--amber-bg); color: var(--amber); }
.tag.bad { background: var(--out-bg); color: var(--out); }
.money { display: flex; align-items: baseline; gap: 6px; }
.money small { font-size: 20px; font-weight: 700; color: var(--muted); }
.money b { font-size: 48px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.money b.in { color: var(--in); }
.money b.out { color: var(--out); }
.tiles { display: flex; gap: 10px; }
.tile { flex: 1; border-radius: 18px; padding: 12px; display: flex; gap: 10px; align-items: center; background: var(--soft); min-width: 0; }
.tile.in { background: var(--in-bg); }
.tile.out { background: var(--out-bg); }
.tile.warn { background: var(--amber-bg); }
.tile .t-l { font-size: 12px; font-weight: 700; }
.tile.in .t-l { color: var(--in); }
.tile.out .t-l { color: var(--out); }
.tile.warn .t-l { color: var(--amber); }
.tile .t-v { font-size: 18px; font-weight: 800; }
.tile .t-box { display: flex; flex-direction: column; min-width: 0; }
.dot { flex: none; width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--in-bar); color: #fff; }
.dot.out { background: #c8402a; }
.tiles.cuadre .tile { flex-direction: column; text-align: center; gap: 3px; padding: 10px 6px; }
.tiles.cuadre .t-v { font-size: 18px; }

/* Gráfico de barras en pares: lo que entra (verde) y lo que sale (coral) */
.bars { display: flex; gap: 6px; align-items: flex-end; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.bar-pair { display: flex; gap: 2px; align-items: flex-end; height: 64px; }
.bar { width: 10px; border-radius: 4px 4px 2px 2px; background: var(--in-bar); }
.bar.out { background: var(--out-bar); }
.bars.fino .bar-pair { height: 78px; gap: 1px; }
.bars.fino .bar { width: 6px; border-radius: 3px 3px 1px 1px; }
.bars.fino .bar-label { font-size: 10.5px; }
.bar-label { font-size: 12px; color: var(--muted); }
.bar-label.hoy { font-weight: 800; color: var(--fg); }
.legend { display: flex; gap: 14px; font-size: 12px; font-weight: 600; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; background: var(--in-bar); }
.legend i.out { background: var(--out-bar); }

/* Indicadores */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--card); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.kpi .k-l { font-size: 13px; font-weight: 600; color: var(--muted); }
.kpi .k-v { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.kpi .k-s { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.kpi .k-s.in { color: var(--in); }
.kpi .k-s.warn { color: var(--amber); }
.kpi.amarillo { background: var(--amber-bg); }
.sec { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 26px 4px 10px; }
.sec .muted { font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* Avisos y listas */
.aviso { background: var(--card); border-radius: var(--r); padding: 14px; display: flex; gap: 12px; align-items: center; }
.aviso .a-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.aviso .a-t { font-size: 15px; font-weight: 700; }
.aviso .a-s { font-size: 13px; color: var(--muted); line-height: 1.35; }
.aviso a.ver { flex: none; min-height: 44px; display: flex; align-items: center; padding: 0 6px; font-size: 14px; font-weight: 700; text-decoration: none; }
.ico { flex: none; width: 44px; height: 44px; border-radius: 16px; display: flex; align-items: center; justify-content: center; background: var(--soft); color: var(--muted); }
.ico.in { background: var(--in-bg); color: var(--in); }
.ico.out { background: var(--out-bg); color: var(--out); }
.ico.warn { background: var(--amber-bg); color: var(--amber); }
.lista { background: var(--card); border-radius: 24px; padding: 4px 16px; }
.it { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line2); }
.it:last-child { border-bottom: 0; }
.it .ico { width: 40px; height: 40px; border-radius: 50%; }
.it-m { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.it-t { font-size: 14.5px; font-weight: 700; }
.it-s { font-size: 12.5px; color: var(--muted); }
.it-r { flex: none; text-align: right; display: flex; flex-direction: column; gap: 2px; }
.it-a { font-size: 16.5px; font-weight: 800; }
.it-a.in { color: var(--in); }
.it-a.out { color: var(--out); }
.it-a.warn { color: var(--amber); }
.it-b { font-size: 12px; color: var(--muted); }
.dia { display: flex; justify-content: space-between; padding: 16px 0 4px; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sello { align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 800; padding: 3px 8px; border-radius: 99px; background: var(--in-bg); color: var(--in); }
.sello.pend { background: var(--amber-bg); color: var(--amber); }
.mas { display: flex; align-items: center; justify-content: center; min-height: 52px; font-size: 14px; font-weight: 700; width: 100%; border: 0; background: none; color: var(--brand); font-family: inherit; cursor: pointer; }
.tip { background: var(--amber-bg); border-radius: 24px; padding: 18px; display: flex; flex-direction: column; gap: 10px; margin-top: 18px; color: var(--fg); }
.tip .burbuja { background: var(--card); border-radius: 16px 16px 16px 4px; padding: 12px 14px; font-size: 14px; font-weight: 600; }
.tip small { color: var(--muted); font-size: 13.5px; line-height: 1.4; }

/* Reparto horizontal (cómo te pagan / en qué se fue) */
.strip { display: flex; height: 16px; border-radius: 99px; overflow: hidden; gap: 3px; }
.seg { border-radius: 4px; min-width: 6px; }
.seg.efectivo { background: #0b5d4b; }
.seg.qr_ok { background: #17936f; }
.seg.transferencia { background: #7ccba8; }
.seg.qr_pend { background: #f6b93b; }
.met { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.met .sw { flex: none; width: 14px; height: 14px; border-radius: 4px; }
.met .sw.efectivo { background: #0b5d4b; }
.met .sw.qr_ok { background: #17936f; }
.met .sw.transferencia { background: #7ccba8; }
.met .sw.qr_pend { background: #f6b93b; }
.met .m-n { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.met .m-n b { font-size: 14.5px; }
.met .m-n small { font-size: 12px; color: var(--muted); }
.met .m-v { text-align: right; display: flex; flex-direction: column; }
.met .m-v b { font-size: 15px; font-weight: 800; }
.met .m-v small { font-size: 12px; color: var(--muted); }
.hbar { height: 10px; border-radius: 99px; background: var(--soft); }
.hbar i { display: block; height: 10px; border-radius: 99px; background: var(--out-bar); }
.gasto { display: flex; flex-direction: column; gap: 6px; }
.gasto .g-t { display: flex; justify-content: space-between; font-size: 14.5px; font-weight: 700; }

/* Productos */
.prod { display: flex; flex-direction: column; gap: 12px; background: var(--card); border-radius: 24px; padding: 16px; text-decoration: none; color: inherit; }
.prod .p-top { display: flex; gap: 12px; align-items: center; }
.prod .ini { flex: none; width: 50px; height: 50px; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 800; background: var(--in-bg); color: var(--in); }
.prod .ini.t1 { background: var(--amber-bg); color: var(--amber); }
.prod .ini.t2 { background: var(--out-bg); color: var(--out); }
.prod .ini.t3 { background: var(--soft); color: var(--muted); }
.prod .p-n { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.prod .p-n b { font-size: 16px; }
.prod .p-n small { font-size: 12.5px; color: var(--muted); }
.prod .p-s { flex: none; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.prod .p-s b { font-size: 28px; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.prod .p-s b.bajo { color: var(--out); }
.prod .p-s small { font-size: 12px; color: var(--muted); }
.prod .p-bot { display: flex; align-items: center; gap: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.prod .mini { display: flex; flex-direction: column; gap: 2px; min-width: 56px; }
.prod .mini small { font-size: 12px; color: var(--muted); }
.prod .mini b { font-size: 15px; font-weight: 800; }
.prod .mini b.in { color: var(--in); }
.prod .mini b.out { color: var(--out); }
.spark { flex: 1; min-width: 0; height: 34px; }
.spark polyline { fill: none; stroke: var(--in-bar); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.spark.bajo polyline { stroke: var(--out); }
.reponer { flex: none; font-size: 12px; font-weight: 800; color: var(--amber); background: var(--amber-bg); padding: 5px 10px; border-radius: 99px; }
.busca { display: flex; align-items: center; gap: 10px; background: var(--card); color: var(--fg); border-radius: 99px; padding: 0 16px; min-height: 50px; }
.busca input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; min-height: 48px; padding: 0; font-size: 15px; }
.nivel { width: 100%; height: auto; display: block; }
.nivel .area { fill: var(--in-bar); fill-opacity: .14; }
.nivel .linea { fill: none; stroke: var(--in-bar); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.nivel .minimo { stroke: var(--out); stroke-width: 1.5; stroke-dasharray: 5 5; }
.legend i.min { background: none; border-top: 2px dashed var(--out); height: 0; width: 22px; border-radius: 0; vertical-align: middle; }
.nivel .punto { fill: var(--card); stroke: var(--in-bar); stroke-width: 3; }
.ejes { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

/* Formularios y botones (se conservan para el resto de pantallas) */
.muted { color: var(--muted); font-size: 14px; }
input, select, textarea { width: 100%; min-height: 48px; padding: 10px 12px; font: inherit; color: var(--fg); background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
input:focus-visible, button:focus-visible, a:focus-visible, select:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
.btn { min-height: 52px; padding: 10px 18px; border: 0; border-radius: 16px; background: var(--brand); color: var(--brand-fg); font: inherit; font-weight: 800; cursor: pointer; }
.btn.alt { background: transparent; color: var(--brand); border: 2px solid var(--brand); }
.btn[disabled] { opacity: .55; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 13px; background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--warn-bg); color: var(--warn); }
.msg { min-height: 1.4em; margin: 8px 0; font-size: 15px; }
.msg.err { color: var(--warn); }
.msg.ok { color: var(--ok); }
.full { width: 100%; }
.mt { margin-top: 12px; }
.acciones { display: flex; gap: 10px; margin-top: 16px; }
.acciones .btn { flex: 1; }

/* Barra inferior */
.tabs { position: fixed; inset: auto 0 0 0; display: flex; justify-content: center; background: var(--card); border-top: 1px solid var(--line); padding: 8px 8px calc(10px + env(safe-area-inset-bottom)); z-index: 5; }
.tabs a { flex: 1 1 0; max-width: 160px; min-width: 0; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 12px; font-weight: 600; text-decoration: none; }
.tabs a .pastilla { height: 30px; min-width: 54px; border-radius: 99px; display: flex; align-items: center; justify-content: center; }
.tabs a.on { color: var(--brand); font-weight: 800; }
.tabs a.on .pastilla { background: var(--accent); color: var(--accent-fg); }

@media (min-width: 900px) {
  main { max-width: 960px; }
  .band-top, .band-in { max-width: 960px; }
  .grid2.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .duo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
}
@media (max-width: 440px) { .tabs { padding-left: 2px; padding-right: 2px; } .tabs a { font-size: 11px; } .tabs a .pastilla { min-width: 40px; } }
/* Tablas compartidas (js/tabla.js) e interruptor de vista */
.vista { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.vista .chip { min-height: 40px; padding: 0 14px; background: var(--card); color: var(--fg); border: 1px solid var(--line); font: inherit; font-weight: 600; cursor: pointer; border-radius: 99px; }
.vista .chip.on { background: var(--brand); color: var(--brand-fg); border-color: var(--brand); }
.tabla { background: var(--card); border-radius: 22px; overflow-x: auto; padding: 4px 0; margin-bottom: 8px; }
.tabla table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabla th, .tabla td { padding: 9px 7px; text-align: left; border-bottom: 1px solid var(--line2); }
.tabla th:first-child, .tabla td:first-child { padding-left: 12px; }
.tabla th:last-child, .tabla td:last-child { padding-right: 12px; }
.tabla th { font-size: 12.5px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.tabla th.n, .tabla td.n { text-align: right; white-space: nowrap; }
.tabla td.in { color: var(--in); }
.tabla td.out, .tabla td.neg { color: var(--out); }
.tabla td.muted { color: var(--muted); }
.tabla td a { color: var(--brand); font-weight: 700; text-decoration: none; }
.tabla tfoot td { font-weight: 800; background: var(--soft); border-bottom: 0; }
@media print { .vista { display: none; } }

/* Marca de agua: el fénix, muy tenue (la opacidad ya viene en img/marca.svg), sobre el contenido y sin interceptar toques. */
body::before { content: ""; position: fixed; inset: 0; z-index: 5; pointer-events: none; background: url("../img/marca.svg") center / min(78vw, 560px) auto no-repeat; }
@media print { body::before { display: none; } }
