
/* Layout: una sola columna de teléfono. Cabecera con mes y total, lista de gastos, barra inferior con las dos acciones. */
:root {
  --bg: #f1f4f8;
  --surface: #ffffff;
  --surface-2: #e8edf4;
  --fg: #16202e;
  --muted: #5a6677;
  --line: #d6dde8;
  --accent: #1f3864;
  --accent-fg: #ffffff;
  --accent-soft: #dce6f1;
  --danger: #a3262a;
  --ok: #1d6b45;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e141c;
    --surface: #161e2a;
    --surface-2: #1f2937;
    --fg: #e7ecf3;
    --muted: #9aa6b6;
    --line: #28344a;
    --accent: #9bb9f0;
    --accent-fg: #0e141c;
    --accent-soft: #22304a;
    --danger: #f08a8d;
    --ok: #7fd1a3;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e141c;
  --surface: #161e2a;
  --surface-2: #1f2937;
  --fg: #e7ecf3;
  --muted: #9aa6b6;
  --line: #28344a;
  --accent: #9bb9f0;
  --accent-fg: #0e141c;
  --accent-soft: #22304a;
  --danger: #f08a8d;
  --ok: #7fd1a3;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.4;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: 96px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.wrap { max-width: 560px; margin: 0 auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Cabecera */
.head {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  padding-block: 14px 12px;
  border-bottom: 1px solid var(--line);
}
.eyebrow { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.monthrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.monthrow h1 { margin: 0; font-size: 20px; font-weight: 600; text-wrap: balance; }
.navbtn {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font-size: 20px; line-height: 1; display: grid; place-items: center;
}
.total { margin-top: 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.total .num { font-family: var(--font-num); font-size: 26px; font-weight: 500; font-variant-numeric: tabular-nums; }
.total .num small { font-size: 13px; color: var(--muted); margin-right: 6px; }
.total .sub { font-size: 13px; color: var(--muted); }

/* Lista */
.list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.item {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  text-align: left; width: 100%; padding: 10px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line);
}
.thumb { width: 52px; height: 52px; border-radius: 8px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.empty { border: 1px dashed var(--line); background: transparent; font-size: 10px; color: var(--muted); text-align: center; line-height: 1.2; }
.main { min-width: 0; }
.main .t { display: block; font-weight: 600; overflow-wrap: anywhere; }
.main .m { display: block; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.amt { text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.amt b { display: block; font-weight: 500; font-size: 15px; }
.amt small { display: block; font-size: 11.5px; color: var(--muted); }
.chip { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 500; }

.empty-state { margin-top: 28px; padding: 22px 18px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); text-align: center; }
.empty-state b { color: var(--fg); display: block; margin-bottom: 4px; }
.banner { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 13px; }

/* Barra inferior */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  background: var(--bg); border-top: 1px solid var(--line);
  padding: 10px max(16px, env(safe-area-inset-left, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-right, 0px));
}
.bar .in { max-width: 560px; margin: 0 auto; display: flex; gap: 10px; }
.btn {
  min-height: 46px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: default; }
.bar .btn { flex: 1; }
.bar .btn.primary { flex: 1.2; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 9;
  bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  max-width: min(520px, calc(100% - 32px)); background: var(--fg); color: var(--bg);
  padding: 10px 14px; border-radius: 10px; font-size: 14px; text-align: center;
}

/* Formulario */
.sheet {
  position: fixed; inset: 0; z-index: 10; background: var(--bg); overflow-y: auto;
  padding-top: env(safe-area-inset-top, 0px);
}
.sheet .in { max-width: 560px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-left, 0px)) calc(28px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-right, 0px)); }
.sheet h2 { margin: 0 0 14px; font-size: 20px; font-weight: 600; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.f { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.f.full { grid-column: 1 / -1; }
.f label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.f input, .f select, .f textarea {
  width: 100%; min-height: 46px; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
}
.f textarea { min-height: 72px; resize: vertical; }
.f .num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.photo { border: 1px dashed var(--line); border-radius: 12px; padding: 12px; background: var(--surface); display: flex; flex-direction: column; gap: 10px; }
.photo img { max-height: 280px; width: auto; max-width: 100%; border-radius: 8px; align-self: center; }
.photo .row { display: flex; gap: 8px; flex-wrap: wrap; }
.photo .btn { min-height: 40px; font-size: 14px; flex: 1; }
.equiv { grid-column: 1 / -1; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-family: var(--font-num); font-size: 14px; }
.actions { grid-column: 1 / -1; display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.actions .btn { flex: 1; }
.err { grid-column: 1 / -1; color: var(--danger); font-size: 13.5px; min-height: 0; }
.check { grid-column: 1 / -1; padding: 10px 12px; border-radius: 10px; font-size: 14px; line-height: 1.45; }
.check.ok { background: var(--accent-soft); color: var(--ok); }
.check.warn { background: var(--surface); color: var(--danger); border: 1px solid var(--danger); }
.check.info { background: var(--surface-2); color: var(--muted); }
.chip.warn { background: transparent; color: var(--danger); border: 1px solid var(--danger); }

/* Ajustes y resultado del PDF */
.iconbtn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; font-size: 18px; }
.headtop { display: flex; justify-content: space-between; align-items: center; }
.panel { display: flex; flex-direction: column; gap: 12px; }
.panel p { margin: 0; color: var(--muted); font-size: 13.5px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.check { padding: 10px 12px; border-radius: 10px; font-size: 14px; line-height: 1.45; }
.check.ok { background: var(--accent-soft); color: var(--ok); }
.check.warn { background: var(--surface); color: var(--danger); border: 1px solid var(--danger); }
.check.info { background: var(--surface-2); color: var(--muted); }
.chip.warn { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
a.btn { text-decoration: none; color: inherit; }

/* Inicio y kilómetros */
:root { --km: #0f5f5c; --km-fg: #ffffff; --km-soft: #d8eeec; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --km: #6fd0c9; --km-fg: #0e141c; --km-soft: #17383a; } }
:root[data-theme="dark"] { --km: #6fd0c9; --km-fg: #0e141c; --km-soft: #17383a; }
.hometitle { margin: 10px 0 0; font-size: 24px; font-weight: 600; text-wrap: balance; }
.homecards { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.homecard { text-align: left; padding: 22px 20px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: 6px; border-left: 6px solid var(--accent); }
.homecard.km { border-left-color: var(--km); }
.hc-t { font-size: 22px; font-weight: 600; }
.hc-s { font-size: 14px; color: var(--muted); }
.backrow { display: flex; align-items: center; gap: 10px; }
.btn.primary.km { background: var(--km); border-color: var(--km); color: var(--km-fg); }
.head.km .total .num.sec { font-size: 18px; color: var(--muted); }
.head .sub { margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chipbtn { padding: 8px 12px; min-height: 40px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; }
.chipbtn.on { background: var(--km-soft); border-color: var(--km); color: var(--km); font-weight: 600; }
.check-row { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; font-size: 14px; }
.check-row input { width: 20px; height: 20px; }
#kEquiv { background: var(--km-soft); color: var(--km); }
.item.km .chip { background: var(--km-soft); color: var(--km); }
.panel h3 { margin: 10px 0 0; font-size: 15px; font-weight: 600; }
.destlist { display: flex; flex-direction: column; gap: 6px; }
.destrow { display: flex; gap: 8px; align-items: stretch; }
.destrow .edit { flex: 1; text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); display: flex; justify-content: space-between; gap: 8px; }
.destrow .del { width: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--danger); }
.item.km { grid-template-columns: minmax(0, 1fr) auto; }
