/* Layout: una columna tipo celular, barra de pestañas abajo, hojas deslizables para cada formulario. */
:root {
  --bg: #F2F6F7;
  --surface: #FFFFFF;
  --surface2: #E8EFF1;
  --ink: #10242B;
  --muted: #566D75;
  --line: #D6E1E4;
  --accent: #0B6E80;
  --accent-ink: #FFFFFF;
  --accent-soft: #D3ECF1;
  --good: #1B7F55;
  --good-soft: #DCF2E7;
  --warn: #8F5A07;
  --warn-soft: #FAEAC8;
  --bad: #B2382A;
  --bad-soft: #F8DCD7;
  --scrim: rgba(10, 25, 30, .45);
  color-scheme: light;
  --font-display: "Sora", "Segoe UI", system-ui, sans-serif;
  --font-body: "Public Sans", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B161A; --surface: #13242A; --surface2: #1A3037; --ink: #E5EFF1; --muted: #93AAB2;
    --line: #24404A; --accent: #55BFCF; --accent-ink: #06242A; --accent-soft: #17414A;
    --good: #5CCB99; --good-soft: #143A2B; --warn: #E8B04F; --warn-soft: #3F2F10;
    --bad: #F08A7B; --bad-soft: #4A211C; --scrim: rgba(0, 0, 0, .6); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B161A; --surface: #13242A; --surface2: #1A3037; --ink: #E5EFF1; --muted: #93AAB2;
  --line: #24404A; --accent: #55BFCF; --accent-ink: #06242A; --accent-soft: #17414A;
  --good: #5CCB99; --good-soft: #143A2B; --warn: #E8B04F; --warn-soft: #3F2F10;
  --bad: #F08A7B; --bad-soft: #4A211C; --scrim: rgba(0, 0, 0, .6); color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.45;
  padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px));
  padding-block: env(safe-area-inset-top, 0px) 0;
  margin: 0;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
.wrap { max-width: 560px; margin: 0 auto; padding-bottom: 150px; }
.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* barra superior */
.top { display: flex; align-items: center; justify-content: space-between; padding: 16px 0 8px; }
.brand { font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: -.02em; }
.sync { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sync i { width: 8px; height: 8px; border-radius: 50%; background: var(--good); display: inline-block; }
.sync.local i { background: var(--warn); }

/* selector de mes */
.month { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 14px; }
.month .label { font-family: var(--font-display); font-weight: 600; font-size: 17px; }
.iconbtn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; }
.iconbtn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* tarjetas */
.stack { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; min-width: 0; }
.card.hero { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.card.hero .muted { color: inherit; opacity: .8; }
.sec-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.sec-title h2 { font-family: var(--font-display); font-size: 15px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.eyebrow { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; color: var(--muted); }
.hero .eyebrow { color: inherit; opacity: .8; }
.bignum { font-family: var(--font-display); font-weight: 700; font-size: 34px; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.03em; margin: 4px 0 12px; overflow-wrap: anywhere; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pair > div { min-width: 0; }
.pair .v { font-family: var(--font-display); font-weight: 600; font-size: 17px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.trio .cell { background: var(--surface2); border-radius: 12px; padding: 10px; min-width: 0; }
.trio .v { font-family: var(--font-display); font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.pos { color: var(--good); } .neg { color: var(--bad); }

/* botones */
.btn { border: 0; border-radius: 12px; min-height: 46px; padding: 0 18px; font-weight: 600; background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: var(--surface2); color: var(--ink); }
.btn.line { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: default; }
.hero .btn.ghost { background: rgba(255,255,255,.18); color: inherit; }

/* chips y barras */
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface2); color: var(--muted); white-space: nowrap; }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.ex { background: var(--accent-soft); color: var(--accent); }
.bar { height: 8px; border-radius: 99px; background: var(--surface2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.bar > i.warn { background: var(--warn); } .bar > i.bad { background: var(--bad); } .bar > i.good { background: var(--good); }
.bar > i.soft { background: var(--muted); opacity: .45; }

/* filas */
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); min-width: 0; }
.row:first-child { border-top: 0; padding-top: 2px; }
.row .grow { flex: 1; min-width: 0; text-align: left; }
.row .t { font-weight: 600; overflow-wrap: anywhere; }
.row .s { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.row .amt { font-family: var(--font-display); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.row .amt small { display: block; font-family: var(--font-body); font-weight: 400; color: var(--muted); font-size: 12px; }
.tapper { background: none; border: 0; padding: 0; display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-align: left; }
.dot { width: 38px; height: 38px; flex: none; border-radius: 12px; display: grid; place-items: center; font-family: var(--font-display); font-weight: 600; background: var(--surface2); color: var(--muted); }
.dot.in { background: var(--good-soft); color: var(--good); }
.dot.out { background: var(--accent-soft); color: var(--accent); }
.dot.late { background: var(--bad-soft); color: var(--bad); }
.dayhead { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 18px 2px 6px; display: flex; justify-content: space-between; }

/* quincenas */
.qrow { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; margin-top: 10px; }
.qbars { display: flex; flex-direction: column; gap: 5px; }
.qbars .l { display: flex; align-items: center; gap: 8px; font-size: 12px; font-variant-numeric: tabular-nums; }
.qbars .l .bar { flex: 1; }
.qbars .l span { min-width: 74px; text-align: right; }

/* segmentado */
.segs { display: flex; gap: 4px; background: var(--surface2); padding: 4px; border-radius: 14px; }
.segs label { position: relative; }
.segs label, .segs button { flex: 1; text-align: center; padding: 9px 6px; border-radius: 10px; font-weight: 600; font-size: 14px; color: var(--muted); border: 0; background: none; cursor: pointer; }
.segs input { position: absolute; opacity: 0; pointer-events: none; }
.segs label:has(input:checked), .segs button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.segs label:has(input:focus-visible) { outline: 2px solid var(--accent); }

/* navegación inferior */
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); z-index: 20; }
.nav .in { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); }
.nav button { background: none; border: 0; padding: 6px 0 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); }
.nav button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav button[aria-current="page"] { color: var(--accent); }
.fab { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(76px + env(safe-area-inset-bottom, 0px)); z-index: 19; box-shadow: 0 6px 18px rgba(0,0,0,.25); border-radius: 16px; min-height: 52px; padding: 0 20px; display: flex; align-items: center; gap: 8px; }
.fab svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; }

/* hoja de formulario */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 30; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; background: var(--surface); border-radius: 22px 22px 0 0; max-height: 92dvh; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; border: 1px solid var(--line); border-bottom: 0; }
.sheet header { display: flex; align-items: center; justify-content: space-between; padding: 14px max(16px, env(safe-area-inset-right, 0px)) 6px max(16px, env(safe-area-inset-left, 0px)); }
.sheet header h2 { font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.sheet .body { overflow-y: auto; padding: 8px max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 14px; }
.sheet footer { padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); border-top: 1px solid var(--line); display: flex; gap: 8px; }
.sheet footer .btn { flex: 1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .lbl { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-size: 16px; }
.field input.money { font-family: var(--font-display); font-size: 28px; font-weight: 600; min-height: 60px; }
.field .hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips .grp { width: 100%; font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 6px; letter-spacing: .04em; text-transform: uppercase; }
.chips label { position: relative; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips label span { display: inline-block; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); font-size: 14px; }
.chips input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chips input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.err { color: var(--bad); font-size: 13px; font-weight: 600; min-height: 0; }
.check { display: flex; align-items: center; gap: 10px; }
.check input { width: 22px; height: 22px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; z-index: 50; max-width: calc(100vw - 32px); }
.empty { text-align: center; padding: 24px 12px; }
.empty p { margin-top: 6px; }
.banner { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--bad-soft); color: var(--bad); font-weight: 600; font-size: 14px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 3px 0; }
.kv b { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: up .22s ease-out; }
  @keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
}
