/* Gastos de la casa — interfaz móvil.
   Una sola idea fuerte: el gasto se revisa como una boleta impresa.
   Todo lo demás queda sobrio, grande y legible. */

:root {
  --bg: #E7EEE9;          /* niebla salvia */
  --paper: #FFFFFF;       /* papel de la boleta */
  --ink: #17302A;         /* tinta verde oscuro */
  --muted: #56695F;
  --line: #C9D6CF;
  --leaf: #2F6B4F;        /* acción principal */
  --leaf-press: #245540;
  --leaf-soft: #D6E8DD;
  --sun-soft: #FFF1D2;    /* avisos */
  --sun-ink: #6B4A00;
  --danger: #A8382A;
  --radius: 18px;
  --shadow: 0 10px 24px -14px rgb(23 48 42 / .45);
  color-scheme: light;
}

:root:not([data-theme="light"]) { }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101814;
    --paper: #1B2621;
    --ink: #E4EEE8;
    --muted: #9DB2A7;
    --line: #34463D;
    --leaf: #4E9C74;
    --leaf-press: #3F845F;
    --leaf-soft: #23382D;
    --sun-soft: #3A2F14;
    --sun-ink: #F2D28B;
    --danger: #E07A6B;
    --shadow: 0 10px 24px -14px rgb(0 0 0 / .8);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 18px/1.45 "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--leaf); outline-offset: 3px; }
[hidden] { display: none !important; }

#view {
  max-width: 480px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px calc(110px + env(safe-area-inset-bottom));
  outline: none;
}

h1 { font-size: 30px; line-height: 1.15; margin: 8px 0 6px; letter-spacing: -.01em; }
h2 { font-size: 20px; margin: 32px 0 12px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- botones ---------- */
.big-btn {
  display: flex; align-items: center; gap: 16px;
  width: 100%; min-height: 84px; padding: 18px 22px;
  border: 0; border-radius: var(--radius);
  background: var(--leaf); color: #fff;
  font-size: 22px; font-weight: 700; text-align: left;
  box-shadow: var(--shadow);
  transition: transform .08s ease, background .15s ease;
}
.big-btn:active { transform: scale(.985); background: var(--leaf-press); }
.big-btn svg { width: 36px; height: 36px; flex: none; fill: currentColor; }
.big-btn small { display: block; font-size: 15px; font-weight: 400; opacity: .85; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 60px; padding: 12px 18px;
  border: 2px solid var(--line); border-radius: 14px;
  background: var(--paper); color: var(--ink);
  font-size: 18px; font-weight: 700;
}
.btn svg { width: 24px; height: 24px; fill: currentColor; flex: none; }
.btn:active { background: var(--leaf-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 44px; font-size: 16px; padding: 8px 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.stack > * + * { margin-top: 12px; }
.linkish { background: none; border: 0; padding: 8px 0; color: var(--leaf); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- ingreso ---------- */
.login { text-align: center; padding-top: 6vh; }
.login .brand { font-size: 34px; margin-bottom: 4px; }
.who { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 28px 0; }
.who button {
  min-height: 120px; border: 0; border-radius: var(--radius);
  background: var(--paper); box-shadow: var(--shadow);
  font-size: 24px; font-weight: 700;
}
.who button span { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 8px;
  border-radius: 50%; background: var(--leaf-soft); color: var(--leaf); font-size: 24px; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0 22px; min-height: 22px; }
.pin-dots i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--leaf); }
.pin-dots i.on { background: var(--leaf); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 320px; margin: 0 auto; }
.keypad button {
  height: 68px; border: 0; border-radius: 16px; background: var(--paper);
  font-size: 28px; font-weight: 700; box-shadow: var(--shadow);
}
.keypad button:active { background: var(--leaf-soft); }
.keypad .enter { background: var(--leaf); color: #fff; font-size: 19px; }
.keypad .del { font-size: 18px; }
.error { color: var(--danger); font-weight: 700; min-height: 26px; margin-top: 14px; }

/* ---------- inicio ---------- */
.hello { margin-bottom: 22px; }
.hello .status { font-size: 19px; color: var(--muted); }
.hello .status strong { color: var(--ink); }
.pending {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; margin-bottom: 16px; padding: 16px 18px;
  border: 2px solid var(--sun-ink); border-radius: 14px;
  background: var(--sun-soft); color: var(--sun-ink); font-weight: 700; text-align: left;
}
.write-form { margin-top: 12px; padding: 16px; border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
textarea, input[type="text"], input[type="date"], input[inputmode], select {
  width: 100%; padding: 14px; border: 2px solid var(--line); border-radius: 12px; background: var(--paper);
  font-size: 19px;
}
textarea { min-height: 96px; resize: vertical; }
textarea:focus, input:focus, select:focus { border-color: var(--leaf); outline: none; }
.hint { font-size: 15px; color: var(--muted); margin: 8px 0 12px; }

.list { list-style: none; margin: 0; padding: 0; background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list li + li { border-top: 1px solid var(--line); }
.list > li > button {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center;
  width: 100%; padding: 14px 16px; border: 0; background: none; text-align: left;
}
.list .emoji { font-size: 26px; text-align: center; }
.list .what { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .meta { display: block; font-size: 15px; color: var(--muted); font-weight: 400; white-space: normal; }
.list .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { padding: 22px; text-align: center; color: var(--muted); background: var(--paper); border-radius: var(--radius); }

/* ---------- la boleta ---------- */
.ticket-wrap { filter: drop-shadow(0 12px 14px rgb(23 48 42 / .16)); margin: 8px 0 22px; }
.ticket {
  background: var(--paper);
  padding: 22px 22px 40px;
  border-radius: 8px 8px 0 0;
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 20px 100%;
          mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 20px 100%;
}
.ticket .thumb { display: block; width: 100%; max-height: 170px; object-fit: cover; border-radius: 6px; margin-bottom: 16px; border: 0; padding: 0; background: none; }
.ticket .thumb img { width: 100%; max-height: 170px; object-fit: cover; border-radius: 6px; display: block; }
.t-merchant { font-size: 22px; font-weight: 700; text-align: center; margin: 0; }
.t-date { text-align: center; color: var(--muted); margin: 2px 0 14px; }
.t-amount {
  text-align: center; font-size: 46px; font-weight: 700; line-height: 1.1; margin: 0;
  padding: 14px 0; border-block: 2px dashed var(--line); font-variant-numeric: tabular-nums;
}
.t-amount small { display: block; font-size: 16px; font-weight: 400; color: var(--muted); }
.t-rows { margin: 16px 0 0; }
.t-rows div { display: grid; grid-template-columns: 112px 1fr; gap: 10px; padding: 8px 0; }
.t-rows div + div { border-top: 1px dotted var(--line); }
.t-rows dt { color: var(--muted); }
.t-rows dd { margin: 0; font-weight: 700; }
.t-rows dd.unknown { color: var(--sun-ink); font-weight: 400; font-style: italic; }
.t-warn { list-style: none; margin: 16px 0 0; padding: 12px 14px; border-radius: 10px; background: var(--sun-soft); color: var(--sun-ink); font-size: 16px; }
.t-warn li + li { margin-top: 6px; }
.stamp { text-align: center; margin: 12px 0 0; font-weight: 700; color: var(--leaf); }
.stamp.void { color: var(--danger); }
.step { color: var(--muted); font-weight: 700; margin: 0; }

.reading .t-amount span, .reading .bar-skel {
  display: block; height: 18px; border-radius: 6px; background: var(--line); margin: 10px auto;
  animation: pulse 1.4s ease-in-out infinite;
}
.reading .t-amount span { height: 40px; width: 60%; }
@keyframes pulse { 50% { opacity: .45; } }

/* ---------- corregir ---------- */
.form { margin-top: 18px; }
.form label.field { display: block; margin-bottom: 16px; font-weight: 700; }
.form label.field > input, .form label.field > select { margin-top: 6px; font-weight: 400; }
fieldset { border: 0; padding: 0; margin: 0 0 20px; }
legend { font-weight: 700; margin-bottom: 8px; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label, .seg label, .cards label { position: relative; }
.chips input, .seg input, .cards input { position: absolute; opacity: 0; pointer-events: none; }
.chips span {
  display: inline-block; padding: 10px 14px; border: 2px solid var(--line); border-radius: 999px;
  background: var(--paper); font-size: 16px;
}
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; }
.seg span, .cards span {
  display: block; padding: 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--paper);
  text-align: center; font-weight: 700;
}
.cards { display: grid; gap: 10px; }
.cards span { text-align: left; }
.cards small { display: block; font-weight: 400; color: var(--muted); font-size: 15px; }
.chips input:checked + span, .seg input:checked + span, .cards input:checked + span {
  border-color: var(--leaf); background: var(--leaf-soft); color: var(--ink);
}
.chips input:focus-visible + span, .seg input:focus-visible + span, .cards input:focus-visible + span {
  outline: 3px solid var(--leaf); outline-offset: 2px;
}

/* ---------- resumen ---------- */
.month-nav { display: grid; grid-template-columns: 52px 1fr 52px; align-items: center; gap: 8px; }
.month-nav h1 { text-align: center; font-size: 26px; margin: 0; }
.month-nav button { height: 52px; border: 0; border-radius: 14px; background: var(--paper); font-size: 26px; box-shadow: var(--shadow); }
.month-nav button:disabled { opacity: .35; box-shadow: none; }
.total-line { text-align: center; margin: 18px 0 4px; }
.total-line .big { display: block; font-size: 42px; font-weight: 700; font-variant-numeric: tabular-nums; }
.panel { background: var(--paper); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.panel p:last-child { margin-bottom: 0; }
.balance-text { font-size: 21px; font-weight: 700; }
.bars { list-style: none; margin: 0; padding: 0; }
.bars li + li { margin-top: 14px; }
.bars .top { display: flex; justify-content: space-between; gap: 10px; }
.bars .top b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bars .top span { min-width: 0; }
.bars .track { position: relative; height: 12px; margin-top: 6px; border-radius: 6px; background: var(--bg); overflow: hidden; }
.bars .fill { position: absolute; inset: 0 auto 0 0; border-radius: 6px; background: var(--leaf); }
.bars .fill.warn { background: #C98A12; }
.bars .fill.over { background: var(--danger); }
.bars .sub { font-size: 15px; color: var(--muted); }
.people { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.people th, .people td { padding: 8px 4px; text-align: right; }
.people th:first-child, .people td:first-child { text-align: left; }
.people thead th { font-size: 15px; color: var(--muted); font-weight: 400; }
.people tbody tr + tr td { border-top: 1px dotted var(--line); }
.inline-form { display: grid; grid-template-columns: 1fr 120px; gap: 10px; margin-top: 14px; }
.inline-form .btn { grid-column: 1 / -1; }
.footer-actions { display: grid; gap: 10px; margin-top: 32px; }

/* ---------- barra inferior y avisos ---------- */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: var(--paper); border-top: 1px solid var(--line);
}
.tabbar button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 0; background: none; padding: 6px; color: var(--muted); font-size: 15px; font-weight: 700;
}
.tabbar svg { width: 28px; height: 28px; fill: currentColor; }
.tabbar button[aria-current="page"] { color: var(--leaf); }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 20;
  transform: translateX(-50%); width: min(440px, calc(100% - 32px));
  padding: 16px 18px; border-radius: 14px; background: var(--ink); color: var(--bg);
  font-weight: 700; box-shadow: var(--shadow);
}
.toast.bad { background: var(--danger); color: #fff; }

.viewer { position: fixed; inset: 0; z-index: 30; background: rgb(0 0 0 / .88); display: grid; place-items: center; padding: 16px; border: 0; width: 100%; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- cola de lectura ---------- */
.queue { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.q-item {
  display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: center;
  padding: 12px; border-radius: 14px; background: var(--paper); box-shadow: var(--shadow);
}
.q-item.bad { border: 2px solid var(--sun-ink); background: var(--sun-soft); }
.q-thumb {
  position: relative; display: grid; place-items: center; width: 56px; height: 56px;
  border-radius: 10px; overflow: hidden; background: var(--leaf-soft); color: var(--leaf);
}
.q-thumb img { width: 100%; height: 100%; object-fit: cover; }
.q-thumb svg { width: 26px; height: 26px; fill: currentColor; }
.q-thumb.busy::after {
  content: ""; position: absolute; inset: 0; border: 3px solid var(--leaf); border-radius: 10px;
  animation: pulse 1.4s ease-in-out infinite;
}
.q-body { min-width: 0; }
.q-body b { display: block; }
.q-body .meta { display: block; font-size: 15px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-item.bad .meta { color: var(--sun-ink); white-space: normal; }
.q-actions { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; }

.stamp .edited { display: block; font-weight: 400; color: var(--muted); font-size: 15px; margin-top: 2px; }

/* ---------- plan ---------- */
.ledger { margin: 0; font-variant-numeric: tabular-nums; }
.ledger div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; }
.ledger div + div { border-top: 1px dotted var(--line); }
.ledger dt { color: var(--muted); }
.ledger dd { margin: 0; font-weight: 700; white-space: nowrap; }
.ledger .soft dd, .ledger .soft dt { color: var(--muted); font-weight: 400; }
.ledger .total { border-top: 2px dashed var(--line) !important; margin-top: 4px; font-size: 21px; }
.ledger .total dt { color: var(--ink); font-weight: 700; }
.ledger .neg dd { color: var(--danger); }
.row-item { display: grid; grid-template-columns: 40px 1fr auto; gap: 4px 12px; align-items: center; padding: 14px 16px; }
.row-item .emoji { font-size: 26px; text-align: center; }
.row-item .what { font-weight: 700; min-width: 0; }
.row-item .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-actions { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions:empty { display: none; }
.pend { color: var(--sun-ink); }
.card-panel + .card-panel { margin-top: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-head .meta { display: block; font-size: 15px; color: var(--muted); }
.card-head .linkish { padding: 0; }
.statements { list-style: none; margin: 12px 0 0; padding: 0; }
.statements .st { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; }
.statements .st + .st { border-top: 1px dotted var(--line); }
.statements .meta { display: block; font-size: 15px; color: var(--muted); }
.statements .st.paid { opacity: .6; }
.statements .st.due b:first-child { color: var(--sun-ink); }
.st-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; gap: 10px; align-items: center; margin: 4px 0 20px; font-weight: 700; }
.check input { width: 24px; height: 24px; accent-color: var(--leaf); }
