:root {
  --ink: #0c2340;
  --muted: #5c6e82;
  --paper: #f3f7fb;
  --card: rgba(255, 255, 255, 0.94);
  --navy: #071e3a;
  --blue: #1568d6;
  --cyan: #14c6e6;
  --line: rgba(12, 35, 64, 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  color: var(--ink);
  font-family: Manrope, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  background:
    radial-gradient(900px 420px at -8% -10%, rgba(20, 198, 230, 0.22), transparent 55%),
    radial-gradient(820px 480px at 110% -8%, rgba(21, 104, 214, 0.18), transparent 52%),
    var(--paper);
}
body.has-photo {
  background:
    linear-gradient(180deg, rgba(7, 30, 58, 0.62), rgba(7, 30, 58, 0.72)),
    var(--photo) center / cover no-repeat;
}
h1, h2, h3, .big, .secret { font-family: Manrope, "Segoe UI", sans-serif; font-weight: 800; letter-spacing: -0.03em; }
h1 { font-size: clamp(2rem, 5vw, 3.15rem); line-height: 1.05; margin: 0 0 8px; }
h2 { font-size: 1.45rem; margin: 0 0 10px; }
h3 { font-size: 1.15rem; margin: 0; }
p { margin: 0 0 8px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }
::selection { background: #d7f4fb; }

#loading {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  background: var(--navy);
  color: #f4f8fc;
  text-align: center;
  font-size: 0.82rem;
  padding: 4px 8px;
}
#toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(12px);
  max-width: min(92vw, 520px);
  background: var(--navy);
  color: white;
  border-radius: 999px;
  padding: 12px 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.ok { background: var(--blue); }

.page { width: min(1120px, calc(100% - 28px)); margin: 0 auto; padding: 18px 0 56px; }
.credit {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 22px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
}
.credit img { width: min(168px, 46vw); height: auto; }
.credit p { margin: 0; }
.auth {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 24px 14px;
}
.auth-card, .auth .credit { width: min(460px, 100%); }
.auth-card, .card, .stat, .list-card, .callout, .modal {
  background: var(--card);
  border-radius: 22px;
  box-shadow: 0 18px 50px rgba(28, 24, 18, 0.1);
}
.auth-card { width: min(460px, 100%); padding: 28px 24px; }
.card, .list-card, .callout { padding: 18px; margin: 14px 0; }
.muted { color: var(--muted); }
.ok { color: #14643d; }
.warn { color: #8a4b12; }
.kicker {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.74rem;
  color: var(--muted);
}
.big { font-size: clamp(1.8rem, 4vw, 2.7rem); margin: 2px 0 4px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

header.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  background: linear-gradient(115deg, #071e3a 0%, #0e4c8a 68%, #1490c8 100%);
  color: #f4f8fc;
  border-radius: 22px;
  padding: 14px 16px;
  box-shadow: inset 0 -3px 0 var(--cyan);
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand strong { display: block; font-size: 1.35rem; font-weight: 800; }
.brand span, .userbox small { color: rgba(244, 248, 252, 0.78); }
.mark { width: 42px; height: 42px; flex: 0 0 auto; }
.userbox { display: flex; gap: 10px; align-items: center; text-align: right; }
.userbox span { font-weight: 650; }
header.top .btn.ghost { color: #f4f8fc; border-color: rgba(244, 248, 252, 0.35); }

.tabs, .subtabs { display: flex; gap: 6px; overflow-x: auto; padding: 12px 0 4px; }
.tabs button, .subtabs button, .segment button, .btn {
  border: 0;
  border-radius: 999px;
  min-height: 44px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
}
.tabs button[aria-current="page"], .subtabs button[aria-current="page"], .segment button[aria-pressed="true"] {
  background: var(--navy);
  color: #f4f8fc;
}
.btn { background: var(--blue); color: #f4f8fc; font-weight: 700; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: #8d3b32; color: white; }
.btn.whatsapp { background: #0f7a49; color: white; }
.btn.small { min-height: 40px; padding: 6px 12px; }
.btn:disabled { opacity: 0.6; cursor: wait; }
.badge {
  display: inline-grid;
  place-items: center;
  min-width: 1.35rem;
  height: 1.35rem;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--cyan);
  color: var(--navy);
  font-size: 0.75rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
  background: var(--card);
  border-radius: 18px;
  padding: 12px;
}
.caption { padding: 12px 16px; }
.field { display: grid; gap: 4px; min-width: 140px; }
.field.grow { flex: 1; }
.segment { display: flex; gap: 4px; padding: 4px; background: #e7eef6; border-radius: 999px; }
label, .field span { font-size: 0.92rem; }
input, select, textarea {
  width: 100%;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  min-height: 44px;
}
textarea { min-height: 90px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stack { display: grid; gap: 12px; }
.check { display: flex; gap: 8px; align-items: center; min-height: 44px; }
.check input { width: auto; min-height: 0; }

.stats { display: grid; grid-template-columns: 1fr 1fr 1.05fr; gap: 12px; }
.stat { padding: 16px; }
.stat.comun { box-shadow: inset 5px 0 0 var(--blue), 0 18px 50px rgba(7, 30, 58, 0.08); }
.stat.extra { box-shadow: inset 5px 0 0 var(--cyan), 0 18px 50px rgba(7, 30, 58, 0.08); }
.stat.total { background: var(--navy); color: #f4f8fc; }
.stat.total .kicker, .stat.total .muted { color: rgba(244, 248, 252, 0.76); }
.bar { height: 8px; border-radius: 99px; background: #e3ebf3; overflow: hidden; margin: 10px 0; }
.bar > span { display: block; height: 100%; background: var(--blue); }
.stat.extra .bar > span { background: var(--cyan); }
.stat.total .bar { background: rgba(255, 255, 255, 0.2); }
.stat.total .bar > span { background: var(--cyan); }
.mini { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; }
.mini li { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.list-card header.card-h { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 8px; }
.month-label { margin: 14px 0 0; color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; }
.item { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.item-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.amount { font-size: 1.25rem; font-weight: 800; }
.pill { display: inline-flex; border-radius: 999px; padding: 3px 10px; font-size: 0.78rem; font-weight: 650; }
.pill.pendiente { background: #e7eef8; color: #0e4c8a; }
.pill.informado { background: #d7f6fb; color: #0b6f86; }
.pill.confirmado { background: #d9f5ea; color: #0f6b45; }
.pill.gasto { background: #e7eef8; color: #0e4c8a; }
.pill.inversion { background: #d7f6fb; color: #0b6f86; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.74rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.callout.slim { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.checklist { display: grid; gap: 8px; }
.preview { width: 100%; max-height: 220px; object-fit: cover; border-radius: 16px; }
.prop-box, .sheet-box { max-height: 190px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; background: white; }
.sheet-box { max-height: 320px; }
.prop-box label { min-height: 36px; }
.secret { font-size: 1.7rem; background: #eef4fa; border-radius: 12px; padding: 8px 12px; margin: 4px 0 12px; }
.overlay { position: fixed; inset: 0; z-index: 30; background: rgba(7, 30, 58, 0.5); display: grid; place-items: center; padding: 16px; }
.modal { width: min(480px, 100%); padding: 22px; }
.transfer-line { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.transfer-line span { color: var(--muted); }
code { font-family: inherit; }

@media (max-width: 860px) {
  .stats, .split, .grid-2 { grid-template-columns: 1fr; }
  header.top { align-items: flex-start; }
  .userbox { flex-direction: column; align-items: flex-end; gap: 4px; }
  .callout.slim { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 640px) {
  .item { flex-direction: column; }
  .item-side { align-items: flex-start; }
  .page { width: min(1120px, calc(100% - 16px)); }
  .segment { width: 100%; }
  .segment button { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
