/* Gastos — light, quiet, one accent (deep green). Large touch targets: the phone is used in the store. */
:root {
  --bg:#f5f6f4; --surface:#fff; --surface-2:#f1f4f1;
  --ink:#0f1a14; --ink-2:#4f5a54; --ink-3:#7c8580;
  --line:#e3e6e2; --line-2:#eef0ed;
  --brand:#0f4d2e; --brand-hover:#0b3d24; --brand-soft:#e8f0eb; --brand-ink:#fff;
  --danger:#b42318; --danger-soft:#fdf1f0; --danger-line:#f3c9c4;
  --warn-soft:#fff7e0; --warn-line:#ecd38a; --warn-ink:#5c4400;
  --ok-soft:#e8f3ec; --ok-ink:#14532d;
  --r:12px; --r-lg:16px;
  --focus:0 0 0 3px rgba(15,77,46,.22);
  /* kept for old references */
  --green:var(--brand); --verde:var(--brand); --muted:var(--ink-2); --red:var(--danger); --amarillo:var(--warn-soft);
}
* { box-sizing:border-box; }
html { -webkit-text-size-adjust:100%; }
body {
  margin:0; background:var(--bg); color:var(--ink);
  font:17px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing:antialiased; -webkit-tap-highlight-color:transparent;
}
.hidden, [hidden] { display:none !important; }
button { font:inherit; color:inherit; cursor:pointer; }
.ic { width:20px; height:20px; flex:0 0 auto; fill:none; stroke:currentColor; stroke-width:1.75; stroke-linecap:round; stroke-linejoin:round; }

/* header */
.top {
  position:sticky; top:0; z-index:10; display:flex; justify-content:space-between; align-items:center; gap:8px;
  max-width:560px; margin:0 auto; padding:calc(10px + env(safe-area-inset-top)) 16px 10px; background:var(--bg);
}
.brand { display:flex; align-items:center; gap:10px; color:var(--ink); text-decoration:none; }
.brand-mark {
  display:flex; align-items:center; justify-content:center; width:34px; height:34px; border-radius:10px;
  background:var(--brand); color:var(--brand-ink); font-size:13px; font-weight:600; letter-spacing:.02em;
}
.brand-text { display:flex; flex-direction:column; font-weight:600; font-size:16px; line-height:1.15; }
.brand-text small { font-size:12px; font-weight:500; color:var(--ink-3); }
.hnav { display:flex; align-items:center; gap:2px; }
.hlink {
  display:inline-flex; align-items:center; justify-content:center; width:44px; height:44px; padding:0;
  border:0; border-radius:12px; background:none; color:var(--ink-2); text-decoration:none;
}
.hlink:active { background:var(--line-2); }
.hlink .ic { width:22px; height:22px; }
.inline { display:inline; margin:0; }

main { max-width:560px; margin:0 auto; padding:8px 16px calc(28px + env(safe-area-inset-bottom)); }
h1 { font-size:26px; font-weight:600; letter-spacing:-.02em; margin:8px 0 16px; }
h2 { font-size:20px; font-weight:600; letter-spacing:-.01em; margin:8px 0 14px; }
h3 { font-size:15px; font-weight:600; margin:22px 0 8px; color:var(--ink-2); }

/* home: month summary */
.resumen { background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); padding:18px; margin:6px 0 16px; }
.eyebrow { margin:0; font-size:12px; font-weight:600; letter-spacing:.06em; text-transform:uppercase; color:var(--ink-3); }
.cifra { margin:4px 0 14px; font-size:34px; font-weight:600; letter-spacing:-.03em; font-variant-numeric:tabular-nums; }
.resumen-split { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.resumen-split div { background:var(--surface-2); border-radius:10px; padding:9px 12px; }
.resumen-split span { display:block; font-size:12px; color:var(--ink-2); }
.resumen-split strong { font-size:16px; font-weight:600; font-variant-numeric:tabular-nums; }

/* buttons */
.big {
  display:flex; align-items:center; justify-content:center; gap:10px; width:100%; min-height:56px; padding:14px 18px; margin:0 0 12px;
  border:1px solid var(--line); border-radius:var(--r); background:var(--surface); color:var(--ink);
  font-size:17px; font-weight:600; transition:background .12s, transform .08s;
}
.big:active:not(:disabled) { transform:scale(.985); background:var(--surface-2); }
.big .ic { width:21px; height:21px; }
.primary { background:var(--brand); color:var(--brand-ink); border-color:var(--brand); }
.big.primary:active:not(:disabled) { background:var(--brand-hover); }
.danger { color:var(--danger); border-color:var(--danger-line); background:var(--surface); }
.big:disabled, .tile:disabled, .mrow:disabled { opacity:.45; cursor:default; }
.duo { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:0 0 16px; }
.tile {
  display:flex; flex-direction:column; align-items:flex-start; gap:10px; min-height:84px; padding:14px;
  border:1px solid var(--line); border-radius:var(--r); background:var(--surface); color:var(--ink);
  font-size:15px; font-weight:600; text-align:left; transition:background .12s, transform .08s;
}
.tile .ic { width:22px; height:22px; color:var(--brand); }
.tile:active:not(:disabled) { transform:scale(.985); background:var(--surface-2); }
.menu { background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); overflow:hidden; }
.mrow {
  display:flex; align-items:center; gap:12px; width:100%; min-height:56px; padding:12px 16px;
  border:0; background:none; color:var(--ink); font-size:16px; font-weight:500; text-align:left;
}
.mrow + .mrow { border-top:1px solid var(--line-2); }
.mrow:active:not(:disabled) { background:var(--surface-2); }
.mrow > .ic:first-child { color:var(--ink-2); }
.mrow > .ic:last-child { margin-left:auto; width:18px; height:18px; color:var(--ink-3); }
.mrow .badge + .ic { margin-left:8px; }
.badge {
  margin-left:auto; min-width:24px; padding:2px 8px; border-radius:999px; background:var(--warn-soft);
  color:var(--warn-ink); font-size:13px; font-weight:600; text-align:center; font-variant-numeric:tabular-nums;
}
.link {
  display:block; width:100%; min-height:48px; margin:2px 0 0; padding:12px 0; background:none; border:none;
  color:var(--ink-2); font-size:16px; font-weight:500; text-align:center; text-decoration:none;
}
a.link { display:inline-block; width:auto; text-align:left; }
.small {
  min-height:44px; margin:6px 8px 0 0; padding:8px 14px; border:1px solid var(--line); border-radius:10px;
  background:var(--surface); color:var(--ink); font-size:15px; font-weight:600;
}

/* forms */
.panel { background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); padding:16px 16px 2px; margin:0 0 14px; }
label { display:block; margin:0 0 14px; font-size:13px; font-weight:600; color:var(--ink-2); letter-spacing:.01em; }
input, select {
  display:block; width:100%; min-height:50px; margin-top:6px; padding:12px 14px; font:inherit; font-size:17px; font-weight:400;
  border:1px solid var(--line); border-radius:var(--r); background:var(--surface); color:var(--ink);
  -webkit-appearance:none; appearance:none;
}
select {
  padding-right:40px;
  background:var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237c8580' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center / 18px;
}
.panel input, .panel select { background-color:var(--bg); border-color:transparent; }
input:focus, select:focus { outline:none; border-color:var(--brand); box-shadow:var(--focus); background-color:var(--surface); }
input[type=date], input[type=month] { min-height:50px; }
.monto { font-size:22px; font-weight:600; font-variant-numeric:tabular-nums; }
.fila2 { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.resaltar, .panel .resaltar { background-color:var(--warn-soft); border-color:var(--warn-line); }
.notas {
  margin:0 0 14px; padding:12px 14px; border-radius:var(--r); background:var(--surface-2);
  color:var(--ink-2); font-size:15px; white-space:pre-wrap;
}
.msg, .warn {
  margin:0 0 14px; padding:12px 14px; border:1px solid var(--warn-line); border-radius:var(--r);
  background:var(--warn-soft); color:var(--warn-ink); font-size:15px;
}

/* cards and pages outside the app screen (login, setup, ajustes) */
.card { background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); padding:20px; margin:16px 0; }
.card h2 { margin-top:0; }
.narrow { max-width:420px; margin-left:auto; margin-right:auto; }
.center { text-align:center; }
.btn {
  display:flex; align-items:center; justify-content:center; width:100%; min-height:52px; padding:12px 16px; margin:6px 0;
  background:var(--brand); color:var(--brand-ink); font-size:17px; font-weight:600; text-align:center; text-decoration:none;
  border:1px solid var(--brand); border-radius:var(--r); cursor:pointer;
}
.btn.secondary { background:var(--surface); color:var(--ink); border-color:var(--line); }
.center .btn { display:inline-flex; width:auto; }
.error, .flash { margin:0 0 14px; padding:12px 14px; border-radius:var(--r); font-size:15px; font-weight:500; }
.error { background:var(--danger-soft); color:var(--danger); border:1px solid var(--danger-line); }
.okmsg { background:var(--ok-soft); color:var(--ok-ink); }
.muted { color:var(--ink-2); font-size:14px; font-weight:400; }
details { border-top:1px solid var(--line-2); }
summary { min-height:48px; padding:13px 0; font-weight:600; cursor:pointer; }
details form { padding:4px 0 10px; }
.inactivo strong { text-decoration:line-through; color:var(--ink-3); }

/* lists */
.lista { list-style:none; padding:0; margin:0 0 14px; background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); overflow:hidden; }
.lista:empty { display:none; }
.lista li { padding:12px 16px; font-size:16px; }
.lista li + li { border-top:1px solid var(--line-2); }
.lista li:has(> .row) { padding:0; }
.lista .row {
  display:block; width:100%; min-height:56px; padding:12px 16px; background:none; border:0;
  text-align:left; color:var(--ink); font-size:16px;
}
.lista .row:active { background:var(--surface-2); }
.lista .row.subida { background:var(--warn-soft); }
.g-main { display:flex; justify-content:space-between; align-items:baseline; gap:12px; }
.g-name { font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.g-amt { font-weight:600; font-variant-numeric:tabular-nums; white-space:nowrap; }
.g-sub { display:flex; align-items:center; gap:6px; margin-top:2px; font-size:14px; color:var(--ink-2); }
.g-sub .ic { width:15px; height:15px; color:var(--ink-3); }
.g-tag { display:inline-block; margin-top:6px; padding:2px 10px; border-radius:999px; background:var(--ok-soft);
  color:var(--ok-ink); font-size:13px; font-weight:600; }
.g-tag.hidden { display:none; }
#pr-lista .g-name, #pr-pregunta .g-name { white-space:normal; } /* the whole name: the pack size is often at the end */
#pr-lista .cf-card .lista { margin:0; border:0; border-radius:0; background:none; }
#pr-lista .cf-card .lista .row { padding-left:4px; padding-right:4px; }
#pr-pregunta .cf-card { background:var(--warn-soft); border-color:var(--warn-line); }
#pr-pregunta .cf-card .lista { margin:0; border:0; border-radius:0; background:none; }
#pr-pregunta .cf-card .lista .row { padding-left:4px; padding-right:4px; }
.subida-texto { display:block; margin-top:3px; font-size:14px; color:var(--warn-ink); }
.subida-texto.muted { color:var(--ink-3); }
.total {
  display:flex; justify-content:space-between; align-items:baseline; margin:0 0 16px; padding:0 4px;
  font-size:17px; font-weight:600; font-variant-numeric:tabular-nums;
}
.total span:last-child { font-size:22px; letter-spacing:-.02em; }

/* photos */
.thumbs { display:flex; gap:8px; overflow-x:auto; margin-bottom:14px; }
.thumbs a { display:block; flex:0 0 auto; }
.thumbs .thumb { display:block; flex:0 0 auto; width:auto; max-width:85vw; height:200px; object-fit:contain; border-radius:10px; background:var(--line-2); border:1px solid var(--line); }
.panel .thumbs { margin:12px 0 14px; }
.paginas { display:grid; grid-template-columns:repeat(3, 1fr); gap:8px; margin-bottom:14px; }
.pg-item { position:relative; }
.pg-thumb { display:block; width:100%; height:120px; object-fit:cover; border-radius:var(--r); background:var(--line-2); border:1px solid var(--line); }
.pg-quitar {
  position:absolute; top:4px; right:4px; display:flex; align-items:center; justify-content:center; width:40px; height:40px;
  border-radius:50%; border:none; background:rgba(15,26,20,.72); color:#fff;
}
.pg-quitar .ic { width:18px; height:18px; }
.thumb, .pg-thumb { cursor:zoom-in; }
.pg-espera { display:flex; align-items:center; justify-content:center; font-size:13px; color:var(--ink-3); cursor:default; }
.pg-ms { position:absolute; left:6px; bottom:6px; padding:2px 6px; border-radius:8px; background:rgba(15,26,20,.72); color:#fff; font-size:12px; }

/* detail, done, loading */
#detalle .panel { padding-bottom:4px; }
#d-titulo { margin:0 0 4px; }
.d-info { margin:0 0 6px; color:var(--ink-2); font-size:15px; }
#d-articulos { margin-bottom:18px; }
#d-articulos h3 { margin:20px 0 6px; }
#d-preguntas .warn { margin:8px 0; }
.done-mark {
  display:flex; align-items:center; justify-content:center; width:64px; height:64px; margin:28px auto 14px;
  border-radius:50%; background:var(--brand-soft); color:var(--brand);
}
.done-mark .ic { width:30px; height:30px; stroke-width:2.2; }
.ok { margin:0 0 22px; font-size:18px; font-weight:600; text-align:center; }
#done-articulos { text-align:center; color:var(--ink-2); font-size:15px; }
.spinner {
  width:44px; height:44px; margin:90px auto 18px; border:4px solid var(--line); border-top-color:var(--brand);
  border-radius:50%; animation:girar .9s linear infinite;
}
@keyframes girar { to { transform:rotate(360deg); } }
#loading p { text-align:center; color:var(--ink-2); }

/* full-screen photo viewer (no new windows: home-screen web apps have no way back) */
#visor {
  position:fixed; inset:0; z-index:1000; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px;
  padding:calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)); background:rgba(8,12,10,.95);
}
#visor img { display:block; width:auto; max-width:100%; min-height:0; margin:0; flex:1 1 auto; object-fit:contain; background:none; }
.visor-cerrar {
  display:flex; align-items:center; justify-content:center; gap:8px; flex:0 0 auto; min-width:180px; min-height:52px; padding:12px 24px;
  border:0; border-radius:999px; background:#fff; color:var(--ink); font-size:17px; font-weight:600;
}

/* lists inside an Ajustes card: plain rows, no second box */
.card .lista { margin:0 0 12px; background:none; border:0; border-radius:0; }
.card .lista li { padding:12px 0; border-top:1px solid var(--line-2); }
.card .lista li:first-child { border-top:0; }
.card .lista details { border-top:0; }
.card .lista summary { padding:2px 0; }
summary::marker { color:var(--ink-3); }
p:has(> a.link) { margin:4px 0 0; }

/* batch of invoices: finished ones above the current one */
.pg-lote { display:flex; flex-direction:column; gap:8px; margin-bottom:18px; }
.lote-row { display:flex; align-items:center; gap:12px; padding:8px 6px 8px 8px; background:var(--surface); border:1px solid var(--line); border-radius:var(--r); }
.lote-row img { width:44px; height:56px; object-fit:cover; border-radius:8px; background:var(--line-2); cursor:zoom-in; }
.lr-text { flex:1; display:flex; flex-direction:column; min-width:0; }
.lr-sub { font-size:14px; color:var(--ink-2); }
.lr-quitar { display:flex; align-items:center; justify-content:center; width:44px; height:44px; border:0; border-radius:10px; background:transparent; color:var(--ink-2); }
.lr-quitar .ic { width:18px; height:18px; }

/* batch: "Factura 2 de 3" above the form, and the summary screen */
.lote-info { display:flex; justify-content:space-between; align-items:baseline; gap:12px; margin:0 0 12px; font-size:15px; }
.lf-nota { text-align:center; margin:14px 0 18px; }

/* pile of photos ("Varias facturas") */

.cf-card { padding:12px; margin:0 0 12px; background:var(--surface); border:1px solid var(--line); border-radius:var(--r); }
.cf-card p { margin:0 0 4px; }
.cf-head { font-weight:700; }
.cf-sub, .cf-motivo { font-size:14px; color:var(--ink-2); }
.cf-nota { font-size:14px; color:var(--warn-ink); }
.cf-card .warn { margin:8px 0 0; }
.cf-fotos { display:flex; flex-wrap:wrap; gap:8px; margin-top:8px; }
.cf-thumb { width:64px; height:84px; object-fit:cover; border-radius:8px; background:var(--line-2); border:1px solid var(--line); cursor:pointer; }
.cf-sin-fila { display:flex; align-items:center; gap:12px; margin:0 0 8px; }
.cf-sin-fila p { margin:0; }
.hoja-fondo { position:fixed; inset:0; z-index:900; display:flex; align-items:flex-end; background:rgba(8,12,10,.5); }
.hoja {
  width:100%; max-width:560px; margin:0 auto; padding:16px 16px calc(16px + env(safe-area-inset-bottom));
  background:var(--surface); border-radius:var(--r-lg) var(--r-lg) 0 0;
  max-height:90vh; max-height:90dvh; overflow-y:auto; -webkit-overflow-scrolling:touch; overscroll-behavior:contain;
}
.hoja-titulo { margin:0 0 12px; font-weight:700; }
.hoja .big { margin-bottom:8px; }

/* "Paga:" on a payment form (Por pagar) */
.paga { margin:0 0 12px; padding:10px 12px; border:1px solid var(--line-2); border-radius:12px; background:var(--surface-2); }
.paga p { margin:2px 0; }
.paga .paga-titulo { font-weight:600; }
.paga .paga-suma { font-weight:600; margin-top:6px; }

/* Por pagar list: a checkbox to pay, the row to open */
.pp-fila { display:flex; align-items:center; gap:10px; }
.pp-fila input[type=checkbox] { /* a real checkbox: undo the text-field look every input gets above */
  -webkit-appearance:checkbox; appearance:auto; width:24px; height:24px; min-height:0; margin:0 0 0 16px; padding:0;
  flex:none; accent-color:var(--brand); }
.pp-fila .row { flex:1; min-width:0; padding-left:4px; }

/* Buscar precio: the item's picture (or a camera) left of each row; the row itself still opens the invoice */
.lista li.pr-fila { display:flex; align-items:center; gap:10px; padding:0 0 0 12px; }
.cf-card .lista li.pr-fila { padding-left:0; }
.pr-fila .row { flex:1; min-width:0; padding-left:0; }
.pr-foto {
  order:-1; flex:none; display:flex; align-items:center; justify-content:center; width:48px; height:48px; min-height:0;
  margin:0; padding:0; overflow:hidden; border:1px solid var(--line); border-radius:10px; background:var(--surface-2); color:var(--ink-3);
}
.pr-foto img { display:block; width:100%; height:100%; max-width:none; margin:0; padding:0; border:0; border-radius:0; object-fit:cover; background:none; }
.pr-foto .ic { width:22px; height:22px; }
/* Buscar precio: one item at several suppliers (spec 2026-11-16) */
.pr-comp-cabeza { display:flex; align-items:center; gap:10px; margin:0 0 8px; }
.pr-comp-texto { flex:1; min-width:0; }
.cf-card .pr-comp-nombre { margin:0; font-weight:600; line-height:1.3; overflow-wrap:anywhere; }
.cf-card .pr-comp-cuenta { margin:2px 0 0; font-size:13px; color:var(--ink-3); }
#pr-lista .pr-comp .lista .row.pr-comp-fila {
  display:flex; align-items:center; gap:12px; min-height:52px; padding:10px 8px;
}
.pr-comp-izq { flex:1; min-width:0; display:flex; flex-direction:column; }
.pr-comp-prov { font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.pr-comp-sub { margin-top:2px; font-size:13px; color:var(--ink-2); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.pr-comp-der { flex:none; display:flex; flex-direction:column; align-items:flex-end; }
.pr-comp-precio { font-weight:600; font-variant-numeric:tabular-nums; white-space:nowrap; }
.pr-comp-extra { margin-top:2px; font-size:13px; color:var(--danger); white-space:nowrap; }
.pr-comp-extra:empty { display:none; }
#pr-lista .pr-comp .lista .row.pr-barato { background:var(--ok-soft); }
.pr-barato .pr-comp-precio, .pr-barato .pr-comp-extra { color:var(--ok-ink); }
.pr-girando { width:20px; height:20px; border:3px solid var(--line); border-top-color:var(--brand); border-radius:50%; animation:girar .9s linear infinite; }
.visor-cambiar { background:var(--brand); color:#fff; }
