/* Finanzas · app de datos, navegación persistente + libro de cuentas · cálida y serena.
   Paleta: style-lock existente; contraste AA en ambos temas. Sin semilla cromática nueva.
   Crítica (1–5): representación 5, coherencia 5, jerarquía 5, especificidad 5, contención 5, variedad 4. */
:root {
  color-scheme: light;
  --oliva: #46532c; --crema-tostado: #eee5d5; --crema-claro: #fffaf0;
  --azafran: #8a5700; --granada: #9c303b; --texto: #293020; --texto-suave: #62634f;
  --borde: #d3c9b6; --sobre-oliva: #fffaf0;
  --espacio-1: .5rem; --espacio-2: 1rem; --espacio-3: 1.5rem; --espacio-4: 2rem; --espacio-5: 3rem;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
}
@media (prefers-color-scheme: dark) { :root {
  color-scheme: dark; --oliva: #ccd6ac; --crema-tostado: #191e14; --crema-claro: #242b1d;
  --azafran: #e7bb55; --granada: #ffabb1; --texto: #f6efdf; --texto-suave: #c0c5af;
  --borde: #424b36; --sobre-oliva: #191e14;
} }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--crema-tostado); color: var(--texto); font: 1rem/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, input, select, summary { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
a { color: var(--oliva); }
.shell { max-width: 76rem; min-height: 100svh; margin: auto; padding: max(1.5rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right)) max(1.5rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left)); display: flex; flex-direction: column; }
.masthead, .header-tools, .section-head, .monthnav, .save-line, .actions { display: flex; align-items: center; gap: 1rem; }
.masthead, .section-head { justify-content: space-between; }
.header-tools { color: var(--texto-suave); font-size: .875rem; min-width: 0; }
#user-name { overflow-wrap: anywhere; }
.wordmark { color: var(--texto); font: 700 2rem/1.2 Georgia, serif; letter-spacing: -.05em; text-decoration: none; }
.wordmark span { color: var(--oliva); }
#navigation { display: flex; gap: 1.5rem; margin-top: 2rem; border-bottom: 1px solid var(--borde); }
#navigation a { display: flex; align-items: center; gap: .5rem; padding: 1rem 0; border-bottom: 3px solid transparent; color: var(--texto-suave); text-decoration: none; font-size: .875rem; font-weight: 600; }
#navigation a[aria-current="page"] { color: var(--oliva); border-color: var(--oliva); }
#navigation svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
main { flex: 1; padding-block: 2rem 3rem; min-width: 0; }
.auth-card { max-width: 32rem; margin: 4rem auto; }
h1, h2, h3, p { margin: 0; overflow-wrap: anywhere; }
h1, h2, h3 { text-wrap: balance; }
h1 { font: 400 clamp(2rem, 5vw, 2.75rem)/1.15 Georgia, serif; letter-spacing: -.035em; }
h2 { font: 400 1.5rem/1.3 Georgia, serif; letter-spacing: -.02em; }
h3 { font-size: 1rem; font-weight: 600; }
p { color: var(--texto-suave); }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.eyebrow, .label, .note, .muted { color: var(--texto-suave); }
.eyebrow { font-size: .8125rem; margin-bottom: .5rem; }
.note { font-size: .875rem; }
.monthnav { gap: .25rem; }
.monthnav select { max-width: 15rem; border-color: transparent; background: transparent; font-weight: 600; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; padding: .5rem; width: 44px; min-height: 44px; border: 1px solid transparent; border-radius: .5rem; background: transparent; color: var(--oliva); text-decoration: none; cursor: pointer; font-size: 1.5rem; flex-shrink: 0; }
.icon-button svg { display: block; }
.save-line { min-height: 1.5rem; flex-wrap: wrap; font-size: .8125rem; margin-bottom: 1.5rem; gap: .5rem; }
#view { display: grid; gap: 1.5rem; min-width: 0; }
.card { min-width: 0; padding: 1.5rem; border: 1px solid var(--borde); border-radius: 1rem; background: var(--crema-claro); }
.card > * + * { margin-top: 1rem; }
.section-head { align-items: baseline; flex-wrap: wrap; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--borde); border-radius: 1rem; background: var(--crema-claro); overflow: hidden; }
.kpi { padding: 1.5rem; min-width: 0; border-inline-end: 1px solid var(--borde); }
.kpi:last-child { border: 0; }
.kpi .label { display: block; font-size: .8125rem; }
.kpi .big { margin-top: .5rem; font: 400 clamp(1.5rem, 2.5vw, 2rem)/1.2 Georgia, serif; letter-spacing: -.025em; }
.kpi .note { display: block; margin-top: .5rem; font-size: .75rem; }
.kpi input { border: 0; border-bottom: 1px dashed var(--oliva); padding: 0 0 .25rem; border-radius: 0; width: 100%; background: transparent; color: var(--texto); }
.num, .big, table, input { font-variant-numeric: tabular-nums; }
.positive, .good { color: var(--azafran); }
.error, .negative, .over { color: var(--granada); }
.near { color: var(--oliva); }
.none { color: var(--texto-suave); }
.average { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 1.5rem; border-top: 3px solid var(--azafran); }
.average > * + * { margin-top: 0; }
.average .verdict { font: 400 clamp(1.5rem, 3vw, 2rem)/1.2 Georgia, serif; }
.average p + p { margin-top: .5rem; }
.budget-alert { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem 1rem; padding-block: 1rem; border-bottom: 1px solid var(--borde); }
.budget-alert:last-child { border: 0; padding-bottom: 0; }
.budget-alert .meter { grid-column: 1 / -1; width: 100%; }
.meter { width: 7rem; height: .5rem; border-radius: 1rem; overflow: hidden; display: block; background: var(--borde); }
.meter span { display: block; height: 100%; background: currentColor; transform-origin: left; }
.pill { display: inline-block; border: 1px solid currentColor; border-radius: 2rem; padding: .125rem .625rem; white-space: nowrap; font-size: .75rem; font-weight: 600; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; gap: .5rem; border: 1px solid var(--oliva); border-radius: .5rem; padding: .5rem 1rem; background: var(--oliva); color: var(--sobre-oliva); font-weight: 600; text-decoration: none; cursor: pointer; transition: transform 120ms var(--ease-out); }
.secondary { background: transparent; color: var(--oliva); }
.danger { color: var(--granada); background: transparent; border-color: var(--granada); }
.button:active, .icon-button:active { transform: translateY(1px); }
button:disabled { cursor: default; opacity: .65; }
.link { min-height: 44px; padding: .25rem 0; color: var(--oliva); border: 0; background: transparent; font: inherit; text-align: start; text-decoration: underline; text-underline-offset: .2em; cursor: pointer; }
input, select, textarea { max-width: 100%; min-width: 0; background: var(--crema-claro); border: 1px solid var(--texto-suave); border-radius: .5rem; padding: .5rem; min-height: 44px; }
input[type="checkbox"] { min-height: auto; accent-color: var(--oliva); width: 18px; height: 18px; }
input[aria-invalid="true"] { border-color: var(--granada); }
label { display: grid; gap: .5rem; font-size: .875rem; }
.switch { display: flex; align-items: center; gap: .5rem; min-height: 44px; }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 1.5rem; }
.actions { flex-wrap: wrap; }
.table-wrap { overflow: auto; max-width: 100%; border-radius: .5rem; overscroll-behavior-x: contain; }
.table-wrap:focus-visible { outline-offset: -3px; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { padding: .75rem .5rem; text-align: end; vertical-align: middle; border-bottom: 1px solid var(--borde); white-space: nowrap; }
th { color: var(--texto-suave); font-size: .75rem; font-weight: 600; }
th:first-child, td:first-child { text-align: start; }
caption { text-align: start; margin-bottom: .5rem; color: var(--texto-suave); }
.group th { padding-top: 1.5rem; font-size: .875rem; color: var(--oliva); text-align: start; }
.name { min-width: 12rem; max-width: 19rem; white-space: normal; overflow-wrap: anywhere; }
.name small { display: block; font-size: .75rem; color: var(--texto-suave); }
.amount-input { width: 7.5rem; text-align: end; }
.total td { font-weight: 600; border-bottom: 0; border-top: 2px solid var(--borde); }
.description { text-align: start; min-width: 15rem; max-width: 25rem; white-space: normal; overflow-wrap: anywhere; }
.movement-select { width: 16rem; }
.movements tbody tr { content-visibility: auto; contain-intrinsic-size: auto 70px; }
.editor { background: var(--crema-tostado); padding: 1.5rem; border-radius: .5rem; }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.editor-grid .full { grid-column: 1 / -1; }
.sub-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: .5rem; max-height: 13rem; overflow: auto; margin: 0; padding: 1rem; border: 1px solid var(--texto-suave); border-radius: .5rem; }
.sub-options label { display: flex; align-items: center; gap: .5rem; min-height: 44px; }
fieldset legend { padding-inline: .5rem; font-size: .875rem; }
.chart-box { position: relative; height: 19rem; min-width: 0; }
.chart-box canvas { max-width: 100%; }
details.card > summary { cursor: pointer; font: 400 1.5rem/1.3 Georgia, serif; padding-block: .25rem; }
details > summary::marker { color: var(--oliva); }
.chart-data { font-size: .875rem; }
.chart-data > summary { cursor: pointer; color: var(--oliva); padding-block: .5rem; }
.category-row { cursor: pointer; }
.selected-row { background: var(--crema-tostado); }
.empty { padding: 2rem 1rem; text-align: center; }
.coming { padding-block: 3rem; }
.coming h2 { margin-bottom: 1rem; }
.auth-card > .button { width: 100%; }
footer { font-size: .8125rem; color: var(--texto-suave); }
:focus-visible { outline: 3px solid var(--oliva); outline-offset: 3px; }
.skip { position: absolute; top: -10rem; padding: .5rem 1rem; color: var(--sobre-oliva); background: var(--oliva); z-index: 10; }
.skip:focus { top: 1rem; }
@media (hover: hover) and (pointer: fine) {
  button:not(:disabled):hover, .button:hover, .icon-button:hover, #navigation a:hover { text-decoration: underline; text-underline-offset: .2em; }
}
@media (max-width: 1000px) { .kpi { padding: 1rem; } }
@media (max-width: 767px) {
  .shell { padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) calc(6rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); }
  .wordmark { font-size: 1.75rem; }
  .header-tools { gap: .5rem; }
  #user-name { max-width: 9rem; font-size: .75rem; }
  #navigation { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; margin: 0; padding: .25rem max(.25rem, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(.25rem, env(safe-area-inset-left)); border: 0; border-top: 1px solid var(--borde); background: var(--crema-claro); gap: 0; justify-content: space-around; }
  #navigation a { flex: 1; min-width: 0; min-height: 60px; flex-direction: column; justify-content: center; gap: .25rem; padding: .5rem 0; border-bottom: 0; border-top: 3px solid transparent; font-size: .625rem; }
  #navigation a[aria-current="page"] { border-top-color: var(--oliva); }
  #navigation svg { width: 20px; height: 20px; }
  main { padding-top: 2rem; }
  .page-heading { gap: 1rem; }
  .monthnav { width: 100%; justify-content: space-between; border-block: 1px solid var(--borde); padding-block: .25rem; }
  .monthnav select { text-align: center; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 1rem; border-bottom: 1px solid var(--borde); }
  .kpi:nth-child(2) { border-inline-end: 0; }
  .kpi:nth-child(3) { border-bottom: 0; }
  .kpi .big { font-size: 1.5rem; }
  .card { padding: 1.5rem; }
  .average { grid-template-columns: 1fr; }
  .editor { padding: 1rem; }
  .editor-grid { grid-template-columns: 1fr; }
  .chart-box { height: 17rem; }
  .budget-alert { grid-template-columns: 1fr; }
  .budget-alert .meter { grid-column: auto; }
  .save-line { margin-bottom: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  .button { transition: none; }
  .button:active, .icon-button:active { transform: none; }
}
