/* Layout: libreta de cobros — una columna, agenda por urgencia arriba, todo operable con el pulgar */
:root {
  --bg: #EEF2F1;
  --surface: #FFFFFF;
  --surface-2: #F6F8F7;
  --ink: #13201D;
  --muted: #5A6A66;
  --line: #D9E1DE;
  --accent: #0D6A5B;
  --accent-soft: #DCEFEA;
  --on-accent: #FFFFFF;
  --danger: #B3362B;
  --danger-soft: #FBE4E1;
  --warn: #8F5B00;
  --warn-soft: #FBEFD6;
  --ok: #2B7A4B;
  --ok-soft: #E0F1E6;
  --shadow: 0 1px 2px rgba(19,32,29,.06), 0 8px 24px rgba(19,32,29,.06);
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Consolas, monospace;
  --r: 14px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0D1412; --surface: #151E1B; --surface-2: #1B2522; --ink: #E4EDEA; --muted: #93A49F; --line: #263330;
  --accent: #3CC1A4; --accent-soft: #143A33; --on-accent: #06201A;
  --danger: #F2786D; --danger-soft: #3A1C19; --warn: #E9B44C; --warn-soft: #362A12; --ok: #63CB8E; --ok-soft: #15301F;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #0D1412; --surface: #151E1B; --surface-2: #1B2522; --ink: #E4EDEA; --muted: #93A49F; --line: #263330;
  --accent: #3CC1A4; --accent-soft: #143A33; --on-accent: #06201A;
  --danger: #F2786D; --danger-soft: #3A1C19; --warn: #E9B44C; --warn-soft: #362A12; --ok: #63CB8E; --ok-soft: #15301F;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.45; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--f-mono); letter-spacing: .02em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; margin: 0; letter-spacing: -.01em; }

.wrap { max-width: 920px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
header.top { padding-block: 20px 8px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
header.top h1 { font-size: 28px; font-weight: 700; }
header.top .date { color: var(--muted); font-size: 13px; }
.sync { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.sync::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.sync.db::before { background: var(--ok); }
.sync.local::before { background: var(--warn); }

nav.tabs { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); padding-block: 8px; }
nav.tabs .seg { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
nav.tabs a { flex: 1; text-align: center; padding: 8px 6px; border-radius: 9px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; white-space: nowrap; }
nav.tabs a[aria-current="page"] { background: var(--accent); color: var(--on-accent); }

main { padding-block: 8px 120px; display: grid; gap: 20px; }
.note { border-radius: var(--r); padding: 12px 14px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; font-size: 14px; }
.note.example { background: var(--warn-soft); color: var(--ink); }
.note.local { background: var(--surface); border: 1px dashed var(--line); color: var(--muted); }

/* Resumen */
.summary { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); }
.stat { padding: 16px; border-right: 1px solid var(--line); min-width: 0; }
.stat:last-child { border-right: 0; }
.stat .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.stat .val { font-family: var(--f-display); font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .hint { font-size: 12px; color: var(--muted); }
.stat.danger .val { color: var(--danger); }
.stat.okc .val { color: var(--ok); }
.chart { border-top: 1px solid var(--line); padding: 14px 16px 10px; }
.chart .head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.chart .head b { color: var(--ink); font-weight: 600; }
.legend { display: flex; gap: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.chart svg { width: 100%; height: auto; display: block; margin-top: 6px; }

/* Listas */
.group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-family: var(--f-body); font-weight: 600; display: flex; justify-content: space-between; gap: 8px; padding: 0 4px 8px; }
.group h3 .num { letter-spacing: 0; }
.group.vencidos h3 { color: var(--danger); }
.list { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.row { display: grid; grid-template-columns: 50px minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.when { text-align: center; border-radius: 10px; padding: 6px 0; background: var(--surface-2); line-height: 1.1; }
.when b { display: block; font-family: var(--f-display); font-size: 19px; }
.when span { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.when.vencido { background: var(--danger-soft); color: var(--danger); }
.when.vencido span { color: var(--danger); }
.when.pronto { background: var(--warn-soft); color: var(--warn); }
.when.pronto span { color: var(--warn); }
.what { min-width: 0; }
.who { font-weight: 600; }
.sub { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.chip { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; margin-top: 4px; background: var(--surface-2); color: var(--muted); }
.chip.vencido { background: var(--danger-soft); color: var(--danger); }
.chip.pronto { background: var(--warn-soft); color: var(--warn); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.ej { background: var(--warn-soft); color: var(--warn); }
.side { display: grid; justify-items: end; gap: 6px; }
.amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.acts { display: flex; gap: 6px; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 7px 12px; font-weight: 600; font-size: 13.5px; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--danger); }
.btn.danger.armed { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.icon { padding: 6px 9px; }
.btn svg { width: 16px; height: 16px; }
.empty { background: var(--surface); border-radius: var(--r); padding: 28px 20px; text-align: center; color: var(--muted); box-shadow: var(--shadow); }
.empty h3 { color: var(--ink); margin-bottom: 6px; font-size: 18px; }
.more { width: 100%; border: 0; background: var(--surface-2); padding: 10px; color: var(--accent); font-weight: 600; }

/* Personas */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.person { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; display: grid; gap: 12px; align-content: start; min-width: 0; }
.person .top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.person h3 { font-size: 19px; }
.person .tel { font-size: 13px; color: var(--muted); }
.person .owed { text-align: right; }
.person .owed b { font-family: var(--f-display); font-size: 20px; display: block; font-variant-numeric: tabular-nums; }
.person .owed small { color: var(--muted); font-size: 12px; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.bar-lbl { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }
.loans { display: grid; gap: 2px; }
.loan { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); cursor: pointer; font-size: 14px; align-items: center; }
.loan:hover { outline: 1px solid var(--line); }
.loan .l { min-width: 0; }
.loan .l div:first-child { font-weight: 600; overflow-wrap: anywhere; }
.loan .l div:last-child { font-size: 12px; color: var(--muted); }
.loan.done { opacity: .65; }

/* Métodos */
.methods { display: grid; gap: 12px; }
.method { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 16px; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px 12px; align-items: center; }
.method .k { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.method .v { font-family: var(--f-mono); font-size: 16px; overflow-wrap: anywhere; }
.method .v.txt { font-family: var(--f-body); }
.method .m { font-size: 13px; color: var(--muted); }
.method .acts { grid-column: 1 / -1; flex-wrap: wrap; }
.card-sec { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; display: grid; gap: 12px; }
.card-sec h3 { font-size: 17px; }
.card-sec p { margin: 0; color: var(--muted); font-size: 14px; }
.sec-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.sec-title h2 { font-size: 20px; }

/* FAB */
.fab { position: fixed; right: max(18px, calc(env(safe-area-inset-right, 0px) + 18px)); bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); z-index: 20; border: 0; background: var(--accent); color: var(--on-accent); font-weight: 700; padding: 14px 20px; border-radius: 999px; box-shadow: 0 8px 24px rgba(13,106,91,.35); display: inline-flex; gap: 8px; align-items: center; font-size: 15px; }
.fab svg { width: 18px; height: 18px; }

/* Modal */
dialog { border: 0; padding: 0; border-radius: 18px; background: var(--surface); color: var(--ink); width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(10,20,18,.45); }
.mbody { padding: 20px; display: grid; gap: 16px; overflow-y: auto; max-height: calc(100dvh - 32px); }
.mhead { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.mhead h2 { font-size: 22px; }
.mhead p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.x { border: 0; background: var(--surface-2); border-radius: 50%; width: 34px; height: 34px; font-size: 18px; line-height: 1; flex: none; }
label.f { display: grid; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); }
label.f input, label.f select, label.f textarea, textarea.msg { border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: 15px; font-weight: 400; color: var(--ink); width: 100%; min-width: 0; }
label.f input:focus, label.f select:focus, label.f textarea:focus, textarea.msg:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.hintline { font-size: 12px; font-weight: 400; color: var(--muted); }
.hintline.bad { color: var(--danger); }
.hintline.good { color: var(--ok); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.segctl { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.segctl label { flex: 1; text-align: center; }
.segctl input { position: absolute; opacity: 0; pointer-events: none; }
.segctl span { display: block; padding: 8px 6px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; }
.segctl input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.segctl input:focus-visible + span { outline: 2px solid var(--accent); }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.presets button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 11px; font-size: 13px; font-weight: 600; }
.presets button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.preview { background: var(--surface-2); border-radius: 12px; padding: 12px; font-size: 13.5px; display: grid; gap: 4px; }
.preview .pr { display: flex; justify-content: space-between; gap: 10px; }
.preview .pr span:first-child { color: var(--muted); }
.preview .tot { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 4px; font-weight: 600; }
.mact { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.mact .grow { margin-right: auto; }
.cuotas { display: grid; gap: 4px; }
.cuota { display: grid; grid-template-columns: 30px minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.tick { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); display: grid; place-items: center; padding: 0; }
.tick svg { width: 15px; height: 15px; opacity: 0; }
.tick.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.tick.on svg { opacity: 1; }
.cuota .t { font-weight: 600; font-size: 14px; }
.cuota .d { font-size: 12px; color: var(--muted); }
.cuota.paid .t { color: var(--muted); text-decoration: line-through; }
.checks { display: grid; gap: 4px; }
.checks label { display: grid; grid-template-columns: 22px minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font-size: 14px; cursor: pointer; }
.checks input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.checks .d { font-size: 12px; color: var(--muted); }
.subh { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; }
textarea.msg { min-height: 220px; font-size: 14px; line-height: 1.5; resize: vertical; }
.totalbar { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; }
.totalbar b { font-family: var(--f-display); font-size: 22px; font-variant-numeric: tabular-nums; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.kv span:first-child { color: var(--muted); }
.notes { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 84px); z-index: 50; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 12px; font-size: 14px; display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
#toast button { border: 0; background: transparent; color: var(--accent-soft); font-weight: 700; text-decoration: underline; padding: 0; }
.loading { text-align: center; color: var(--muted); padding: 40px 0; }

@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .stat .val { font-size: 21px; }
  .grid2 { grid-template-columns: 1fr; }
  header.top h1 { font-size: 24px; }
  .fab .lbl-long { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .row, .btn, .tick, nav.tabs a { transition: background-color .15s, border-color .15s, color .15s; }
  .bar i { transition: width .4s ease; }
}

/* ---------- Sitio independiente (fuera de Claude) ---------- */
html { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); -webkit-text-size-adjust: 100%; }
body { margin: 0; font-size: 15px; }
img { max-width: 100%; }
.top-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Inicio de sesión */
.auth { min-height: 100dvh; display: grid; place-items: center; padding-block: 32px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.auth-card { width: min(400px, 100%); background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 28px 24px; display: grid; gap: 16px; }
.auth-brand { display: flex; gap: 12px; align-items: center; }
.auth-brand img { width: 44px; height: 44px; border-radius: 12px; }
.auth-brand h1 { font-size: 26px; }
.auth-card p { margin: 0; color: var(--muted); font-size: 14px; }
.auth-card form { display: grid; gap: 12px; }
.auth-card .btn.primary { justify-content: center; padding: 11px 14px; font-size: 15px; }
.linkish { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 0; font-size: 14px; justify-self: start; }
.auth-msg { font-size: 14px; border-radius: 10px; padding: 10px 12px; background: var(--surface-2); }
.auth-msg.bad { background: var(--danger-soft); color: var(--danger); }
.auth-msg.good { background: var(--ok-soft); color: var(--ok); }
.splash { min-height: 100dvh; display: grid; place-items: center; color: var(--muted); }

/* Teléfono: letra más grande en listas desplegables, campos y subtítulos */
@media (max-width: 640px) {
  label.f input, label.f select, label.f textarea, textarea.msg, select { font-size: 17px; }
  label.f { font-size: 14.5px; }
  label.f select { padding-block: 12px; }
  .sub, .stat .hint, .person .tel, .loan .l div:last-child, .bar-lbl, .cuota .d, .checks .d, .preview, .method .m, .card-sec p, .hintline { font-size: 14.5px; }
  .checks label, .loan, .cuota .t { font-size: 16px; }
  .mhead p, header.top .date, .chart .head { font-size: 15px; }
  .stat .lbl, .subh, .method .k, .group h3 { font-size: 13px; }
  .chip { font-size: 13px; }
  .when span { font-size: 12.5px; }
  .presets button { font-size: 15px; padding: 6px 13px; }
  .segctl span { font-size: 15px; }
}

/* Resumen de deuda */
.res-preview { background: var(--surface-2); border-radius: 12px; padding: 10px; display: flex; justify-content: center; }
.res-preview img { width: 100%; max-width: 640px; height: auto; border-radius: 6px; box-shadow: 0 4px 18px rgba(0,0,0,.12); }
.checks label div:empty, .checks label span:empty { display: none; }
