/* Vida con Camilita: estilos. Paleta y componentes adaptados del diseño de referencia
   (verdes suaves, crema, ocre), con tamaños de letra algo mayores para leer bien en el celular. */
:root {
  --green: #214e43;
  --green-dark: #173c33;
  --ink: #263c34;
  --muted: #647268;
  --faint: #8d978f;
  --line: #e7eae3;
  --bg: #f6f7f3;
  --surface: #ffffff;
  --soft: #edf3ee;
  --soft-2: #f4f6ef;
  --cream: #f3eddc;
  --ochre: #c89b62;
  --ochre-ink: #8f6a30;
  --ochre-soft: #f5eee1;
  --error: #a74038;
  --error-soft: #fcf0ed;
  --ok: #4f7a4c;
  --ok-soft: #edf4e8;
  --accent: var(--green);
  --accent-ink: #ffffff;
  --hero: #214e43;
  --radius: 10px;
  --gutter: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --green: #8fc9b4;
    --green-dark: #a9dcc9;
    --ink: #e8efe9;
    --muted: #a3b4a9;
    --faint: #7f9187;
    --line: #26352f;
    --bg: #0f1815;
    --surface: #16221e;
    --soft: #1d3029;
    --soft-2: #1a2a24;
    --cream: #e9dfc2;
    --ochre: #d8b07a;
    --ochre-ink: #e3bf8b;
    --ochre-soft: #2e281c;
    --error: #ff9a8f;
    --error-soft: #3a1f1c;
    --ok: #8fd09a;
    --ok-soft: #1b3023;
    --accent: #2f7a65;
    --accent-ink: #ffffff;
    --hero: #1c4a3e;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font: 15px/1.5 Arial, Helvetica, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 88px;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 32px; font-weight: 500; letter-spacing: -1px; line-height: 1.15; }
h2 { font-size: 18px; letter-spacing: -0.3px; font-weight: 600; }
h3 { font-size: 16px; }
b, strong { font-weight: 600; }
a { color: var(--green); }
svg { flex-shrink: 0; }
button, input, select, textarea { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; border: 0; transition: background 0.15s ease; }
button:disabled { cursor: default; opacity: 0.5; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--ochre); outline-offset: 3px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #719487; outline-offset: 1px; }

/* ---------- campos ---------- */
select, input[type='text'], input[type='number'], input[type='date'], input[type='email'], input[type='password'], textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); font-size: 16px;
}
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
input[type='checkbox'] { accent-color: var(--green); width: 18px; height: 18px; }

/* ---------- botones ---------- */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 10px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--green); text-decoration: none; font-size: 14px; font-weight: 600; line-height: 1.3;
}
button:hover:not(:disabled), .btn:hover { background: var(--soft); }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover:not(:disabled), .btn.primary:hover { background: var(--green-dark); color: var(--accent-ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) button.primary:hover:not(:disabled), :root:not([data-theme='light']) .btn.primary:hover { background: #3a8c75; } }
button.danger { background: var(--error-soft); color: var(--error); border-color: transparent; }
button.ghost { background: transparent; border-color: transparent; color: var(--green); padding-left: 8px; padding-right: 8px; }
button.ghost:hover:not(:disabled) { background: var(--soft); }
button.block, .btn.block { width: 100%; }
.actions { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 16px 0; }
@media (min-width: 560px) { .actions { grid-template-columns: repeat(3, 1fr); } }

/* ---------- estructura: barra lateral, cabecera, navegación móvil ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 240px; background: var(--surface); border-right: 1px solid var(--line);
  padding: 28px 20px; display: none; flex-direction: column; z-index: 5;
}
.main-shell { min-height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--green); line-height: 1.05; font-size: 14px; }
.brand strong { display: block; font-size: 22px; font-weight: 700; letter-spacing: -1px; }
.brand strong span { color: var(--ochre); }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: var(--hero); color: var(--cream); }
.side-label { font-size: 11px; letter-spacing: 1.6px; font-weight: 700; color: var(--faint); margin: 36px 8px 10px; }
.house-card { border: 1px solid var(--line); border-radius: 9px; padding: 11px 10px; display: flex; align-items: center; gap: 10px; }
.house-card strong { font-size: 13px; display: block; }
.house-card small { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.house-icon { display: grid; place-items: center; width: 32px; height: 32px; background: var(--soft); border-radius: 8px; color: var(--green); }
.side-nav { display: flex; flex-direction: column; gap: 4px; margin-top: 24px; }
.side-nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 8px; color: var(--muted);
  font-size: 14px; text-decoration: none; min-height: 44px;
}
.side-nav a:hover { background: var(--soft-2); }
.side-nav a.on { background: var(--soft); color: var(--green); font-weight: 600; }
.nav-count { margin-left: auto; border-radius: 5px; background: var(--hero); color: #fff; padding: 1px 7px; font-size: 12px; font-weight: 600; }
.side-bottom { margin-top: auto; }
.privacy-note { padding: 16px 13px; background: var(--soft-2); border-radius: 9px; margin-bottom: 14px; color: var(--muted); display: flex; gap: 12px; align-items: center; font-size: 13px; line-height: 1.6; }
.privacy-note strong { color: var(--green); }
.side-user { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); padding: 6px 4px; }
.side-user > span:not(.avatar) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.topbar {
  position: sticky; top: 0; z-index: 4; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { display: flex; align-items: center; gap: 12px; max-width: 1180px; margin: auto; padding: 10px var(--gutter); min-height: 64px; }
.topbar .brand { flex: 1; min-width: 0; font-size: 12px; }
.topbar .brand strong { font-size: 18px; }
.topbar .brand-mark { width: 36px; height: 36px; border-radius: 11px; }
.crumb { display: none; flex: 1; color: var(--faint); font-size: 13px; }
.crumb b { color: var(--ink); }
.period-select { width: auto; max-width: 52%; min-height: 40px; padding: 6px 12px; font-size: 14px; font-weight: 600; border-radius: 8px; }
.demo-banner { display: flex; align-items: center; gap: 9px; padding: 9px var(--gutter); background: var(--ok-soft); color: var(--ok); font-size: 13px; justify-content: center; text-align: center; }
.demo-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
main { max-width: 1180px; margin: auto; padding: 8px var(--gutter) 0; }
.mobile-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  padding: 6px 8px max(6px, env(safe-area-inset-bottom));
}
.mobile-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; color: var(--faint); font-size: 12px; text-decoration: none; border-radius: 10px; position: relative; }
.mobile-nav a.on { color: var(--green); font-weight: 600; }
.mobile-nav a.on svg { fill: var(--soft); }
.mobile-nav .dot { position: absolute; top: 3px; left: calc(50% + 7px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--ochre); color: #fff; font-size: 11px; line-height: 17px; text-align: center; font-weight: 700; }
@media (min-width: 760px) {
  body { padding-bottom: 0; }
  .sidebar { display: flex; }
  .main-shell { margin-left: 240px; }
  .mobile-nav { display: none; }
  .topbar .brand { display: none; }
  .crumb { display: block; }
  .topbar-in { padding: 14px 40px; min-height: 72px; }
  main { padding: 8px 40px 40px; }
  .demo-banner { margin-left: 240px; }
}

/* ---------- encabezados de página ---------- */
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 26px 0 22px; }
.eyebrow { font-size: 11px; letter-spacing: 2px; font-weight: 700; color: #9b9f88; margin-bottom: 10px; }
.page-heading p { color: var(--muted); font-size: 14px; margin-top: 8px; }
@media (max-width: 759px) { h1 { font-size: 27px; letter-spacing: -0.8px; } .page-heading { margin: 22px 0 18px; } }

/* ---------- tarjetas y piezas ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 0 0 18px; }
.card h2 + * { margin-top: 12px; }
.card.empty { text-align: center; color: var(--muted); padding: 30px 18px; }
.empty { text-align: center; color: var(--muted); padding: 28px 8px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap-row { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.big { font-size: 26px; font-weight: 500; letter-spacing: -0.5px; line-height: 1.2; }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.kicker { font-size: 11px; letter-spacing: 1.3px; font-weight: 700; color: var(--faint); text-transform: uppercase; }
.chip { display: inline-block; padding: 3px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--green); white-space: nowrap; }
.chip.warn { background: var(--ochre-soft); color: var(--ochre-ink); }
.chip.grey { background: var(--soft-2); color: var(--muted); }
.status { display: inline-flex; gap: 6px; align-items: center; border-radius: 6px; padding: 5px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.open { background: var(--ok-soft); color: var(--ok); }
.status.closed { background: var(--soft-2); color: var(--muted); }
.period-bar { display: flex; align-items: center; gap: 24px; padding: 14px 20px; margin-bottom: 18px; }
.period-bar .p-name { font-size: 16px; font-weight: 600; }
.period-bar .p-dates { border-left: 1px solid var(--line); padding-left: 24px; }
.period-bar .p-dates small { display: block; font-size: 11px; letter-spacing: 1px; color: var(--faint); font-weight: 700; margin-bottom: 3px; text-transform: uppercase; }
.period-bar .p-dates span { font-size: 14px; color: var(--muted); }
.period-bar .status { margin-left: auto; }
@media (max-width: 759px) { .period-bar { gap: 12px; padding: 13px 14px; flex-wrap: wrap; } .period-bar .p-dates { border: 0; padding: 0; } }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.metric .k { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 11px; letter-spacing: 1.2px; font-weight: 700; text-transform: uppercase; }
.metric-icon { background: var(--soft-2); color: #779170; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; }
.metric > strong { display: block; font-size: 28px; font-weight: 500; letter-spacing: -0.7px; margin: 12px 0 8px; font-variant-numeric: tabular-nums; }
.metric p, .metric a { font-size: 13px; color: var(--muted); text-decoration: none; }
@media (max-width: 759px) {
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .metric { padding: 14px; }
  .metric > strong { font-size: 22px; }
  .metric:last-child { grid-column: span 2; }
}
.dash-cols { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; margin-bottom: 18px; }
.dash-cols > .card { margin: 0; }
@media (max-width: 759px) { .dash-cols { grid-template-columns: 1fr; } }

/* tarjeta verde del saldo */
.settlement-card { border-radius: var(--radius); background: var(--hero); padding: 24px; color: #fff; display: flex; flex-direction: column; overflow: hidden; position: relative; }
.settlement-card::before { content: ''; position: absolute; width: 200px; height: 200px; border: 1px solid #ffffff14; border-radius: 50%; right: -70px; top: -100px; pointer-events: none; }
.settlement-card .card-kicker { display: flex; align-items: center; gap: 10px; font-size: 11px; letter-spacing: 1.5px; font-weight: 700; color: #bdcec0; text-transform: uppercase; }
.settlement-card .small-icon { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: #ffffff14; color: #bdd2be; }
.settlement-card h2 { font-weight: 400; font-size: 21px; margin: 18px 0 16px; line-height: 1.3; }
.transfer-line { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.transfer-line strong { font-size: 14px; }
.transfer-line svg { color: #a3b7a4; }
.transfer-amount { font-size: 40px; font-weight: 400; letter-spacing: -1.2px; margin-bottom: 20px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.settlement-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid #ffffff1c; display: flex; flex-direction: column; gap: 10px; }
.settlement-footer p { font-size: 12px; display: flex; gap: 6px; align-items: center; color: #b4c7b3; }
.settlement-footer a { color: #f0f2d6; font-size: 14px; text-decoration: none; display: inline-flex; gap: 6px; align-items: center; width: max-content; font-weight: 600; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; background: #e5ece0; color: #496b4c; font-size: 13px; font-weight: 700; }
.avatar.tan { background: #f3e9d9; color: #a18154; }
.avatar.light { background: #ffffff1c; color: #e4ecd8; border: 1px solid #ffffff14; }
.avatar.light.tan { background: #d9c2982e; color: #f1dfba; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .avatar { background: #24382f; color: #a9d3b0; } :root:not([data-theme='light']) .avatar.tan { background: #3a3120; color: #e0c28a; } }

/* reparto */
.prop-bar { height: 10px; border-radius: 10px; display: flex; overflow: hidden; background: var(--soft-2); margin: 18px 0 20px; }
.prop-bar span:first-child { background: var(--hero); }
.prop-bar span:last-child { background: var(--ochre); }
.member-prop { display: flex; align-items: center; justify-content: space-between; margin: 14px 0; gap: 10px; }
.member-prop > div { display: flex; align-items: center; gap: 11px; min-width: 0; }
.member-prop strong { font-size: 14px; display: block; }
.member-prop small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.member-prop b { font-size: 18px; font-weight: 500; }
.hint { font-size: 13px; color: var(--muted); line-height: 1.6; }
.card .hint.top { padding-top: 14px; border-top: 1px solid var(--line); margin-top: 14px; }

/* gasto por regla (gráfico de barras) */
.rule-bars { display: grid; gap: 14px; margin-top: 16px; }
.rule-bars .rb-head { display: flex; justify-content: space-between; font-size: 14px; gap: 10px; }
.rule-bars .rb-head span { color: var(--muted); }
.rule-bars .rb-track { height: 8px; border-radius: 8px; background: var(--soft-2); margin-top: 7px; overflow: hidden; }
.rule-bars .rb-track i { display: block; height: 100%; border-radius: 8px; background: var(--hero); }
.rule-bars .rb-1 i { background: var(--hero); }
.rule-bars .rb-2 i { background: var(--ochre); }
.rule-bars .rb-3 i { background: #7ea593; }
.rule-bars .rb-4 i { background: #b9a37a; }

.bar { height: 8px; background: var(--soft-2); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.bar > span { display: block; height: 100%; background: var(--hero); }

/* ---------- listas y movimientos ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list li.tap { cursor: pointer; }
.list li.tap:hover { background: color-mix(in srgb, var(--soft-2) 70%, transparent); }
.list .title { flex: 1; min-width: 0; }
.list .title div:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.mi { width: 36px; height: 36px; display: grid; place-items: center; background: var(--soft-2); border-radius: 9px; color: #789364; font-size: 15px; font-weight: 700; flex-shrink: 0; }
.mi.ochre { background: var(--ochre-soft); color: var(--ochre-ink); }
.tiny-avatar { width: 20px; height: 20px; display: inline-grid; place-items: center; border-radius: 50%; background: var(--soft); color: var(--green); font-size: 10px; font-weight: 700; flex-shrink: 0; }
.mrow .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.mrow .cols { display: none; }
.pill { font-size: 12px; color: var(--green); background: var(--soft-2); padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.pill.pend { background: var(--ochre-soft); color: var(--ochre-ink); }
.mrow .amount { font-weight: 600; font-size: 15px; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
@media (min-width: 760px) {
  .mrow .meta .who, .mrow .meta .pill { display: none; }
  .mrow .cols { display: flex; align-items: center; gap: 18px; }
  .mrow .cols .payer { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); width: 120px; }
  .mrow .cols .pill { width: 140px; text-align: center; }
}
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-head a { font-size: 14px; text-decoration: none; font-weight: 600; display: inline-flex; gap: 6px; align-items: center; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; margin-bottom: 4px; scrollbar-width: none; }
.chips button { min-height: 38px; padding: 6px 14px; font-size: 13px; white-space: nowrap; border-radius: 8px; color: var(--muted); font-weight: 500; }
.chips button.on { background: var(--soft); border-color: #adc39b; color: var(--green); font-weight: 600; }
.rules { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.rules button { min-height: 54px; }
.rules button.suggested { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* tablas */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 8px; text-align: right; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr.sep td { background: var(--soft); }
.table-scroll { overflow-x: auto; margin: 0 -6px; }

/* ---------- formularios y diálogos ---------- */
dialog { border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: min(600px, calc(100vw - 24px)); max-height: 90dvh; background: var(--surface); color: var(--ink); box-shadow: 0 24px 100px #173c3333; }
dialog::backdrop { background: #12261b66; backdrop-filter: blur(3px); }
dialog h2 { font-size: 22px; margin-bottom: 4px; }
dialog form > .row:last-child { border-top: 1px solid var(--line); padding-top: 16px; }
.upload-zone { display: flex; flex-direction: column; align-items: center; gap: 10px; border: 1px dashed #b3c5a0; background: var(--soft-2); border-radius: 10px; padding: 26px 16px; margin: 14px 0 4px; color: #739063; text-align: center; }
.upload-zone input { max-width: 100%; }
.import-stats { display: flex; justify-content: space-around; gap: 12px; padding: 14px; background: var(--soft-2); border-radius: 9px; margin: 14px 0; color: var(--muted); font-size: 12px; text-align: center; }
.import-stats b { display: block; color: var(--green); font-size: 24px; font-weight: 500; }
.auth-card { max-width: 480px; margin: 36px auto; padding: 28px; }
.auth-card .brand { margin-bottom: 18px; }

/* avisos */
.alert { display: flex; align-items: center; gap: 8px; font-size: 14px; border-radius: 8px; margin: 14px 0; padding: 12px 14px; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 100px; background: var(--hero); color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 20; max-width: 90vw; font-size: 14px; box-shadow: 0 8px 30px #0003; }
.toast.err { background: var(--error); color: #fff; }
pre.explain { white-space: pre-wrap; font: inherit; font-size: 14px; background: var(--soft-2); border-radius: 9px; padding: 14px; margin: 0; line-height: 1.6; }
details summary { cursor: pointer; font-weight: 600; padding: 8px 0; }
.gentle { color: var(--faint); display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; margin: 24px 0 30px; text-align: center; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

@media (max-width: 759px) {
  th, td { padding: 11px 5px; font-size: 13px; }
  .card { padding: 17px 15px; }
}
