:root {
  color-scheme: light;
  --mantel: #f5f5f2;
  --velo: #e6e5e0;
  --plata: #b4b6b2;
  --cala: #56634f;
  --cera: #cdbb98;
  --grafito: #23251f;
  --ink: var(--grafito);
  --ink-soft: #5b5d57;
  --rule: #d4d4ce;
  --bg: var(--mantel);
  --danger: #9a3b2e;
  --ok: var(--cala);
  --btn-bg: var(--grafito);
  --btn-ink: var(--mantel);
  --font-display: "Bodoni Moda", "Bodoni 72", Didot, serif;
  --font-text: "Jost", "Futura", system-ui, sans-serif;
  --step-3: 2.5rem;
  --step-4: clamp(2.6rem, 5.5vw, 4.2rem);
  --step-5: clamp(3.4rem, 10vw, 7.5rem);
  --gutter: clamp(1rem, 4vw, 3rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #ecebe6;
    --ink-soft: #a9aaa4;
    --rule: #3a3c36;
    --velo: #2a2c26;
    --bg: #1a1b17;
    --danger: #e08a7c;
    --ok: #a7b89d;
    --btn-bg: var(--mantel);
    --btn-ink: var(--grafito);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 1.0625rem;
  font-weight: 350;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
small { font-family: var(--font-text); font-size: .72rem; letter-spacing: .08em; color: var(--ink-soft); }
.muted { color: var(--ink-soft); font-weight: 350; }

.wrap { max-width: 78rem; margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }


/* Cabecera */
.site-header { display: flex; justify-content: space-between; align-items: center; gap: 1.5rem; padding: 1.1rem var(--gutter); }
.brand { display: inline-flex; align-items: center; gap: .7rem; text-decoration: none; }
.monogram { width: 2.2rem; height: 2.2rem; display: block; overflow: visible; }
.monogram-letter { font-family: var(--font-display); font-size: 98px; font-style: italic; font-weight: 400; }
.brand-name { font-family: var(--font-display); font-size: 1.3rem; line-height: 1; }
.site-header .link { color: var(--ink-soft); }

/* Portada */
.hero { padding-top: clamp(2.5rem, 7vw, 5rem); padding-bottom: clamp(2rem, 4vw, 3rem); }
.eyebrow { display: block; font-size: .75rem; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-soft); }
h1 { margin: .9rem 0 0; font-family: var(--font-display); font-weight: 400; font-size: var(--step-5); line-height: .95; letter-spacing: -.01em; }
.lead { margin: 1.1rem 0 0; font-family: var(--font-display); font-style: italic; font-size: 1.4rem; line-height: 1.35; }
h2 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: var(--step-3); line-height: 1.08; }
h2.big { font-size: var(--step-4); }
h3 { margin: 0; font-family: var(--font-display); font-weight: 400; line-height: 1.15; }

/* Cifras, como los pasos 01–04 del sitio */
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(1rem, 3vw, 2.5rem); margin-top: 0; margin-bottom: clamp(2.5rem, 5vw, 3.5rem); }
.figures div { padding-top: 1rem; border-top: 1px solid var(--ink); min-width: 0; }
.figures dt { font-family: var(--font-display); font-size: 1.15rem; }
.figures dd { margin: .35rem 0 0; font-family: var(--font-display); font-size: clamp(1.6rem, 3vw, 2.4rem); line-height: 1.1; white-space: nowrap; }

/* Pestañas */
.tabs { position: sticky; top: 0; z-index: 5; background: var(--bg); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.tabs [role="tablist"] { display: flex; gap: clamp(1.2rem, 4vw, 3rem); }
.tabs button {
  position: relative;
  padding: 1.05rem 0 .95rem;
  border: 0;
  background: none;
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--ink-soft);
  white-space: nowrap;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); }
.tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--ink); }
.tab-count { margin-left: .3rem; font-family: var(--font-text); font-size: .75rem; color: var(--ink-soft); }

.panels { padding-top: clamp(2rem, 5vw, 3.5rem); padding-bottom: clamp(2rem, 5vw, 3rem); min-height: 60vh; }
.panels > .filters { max-width: 34rem; margin-bottom: clamp(2rem, 5vw, 3rem); }
.panel.narrow { max-width: 34rem; }
.panel > h2 { margin-bottom: .4rem; }
[hidden] { display: none !important; }

/* Campos: solo línea inferior */
label { display: block; margin: 1.6rem 0 .2rem; font-size: .8rem; letter-spacing: .06em; color: var(--ink-soft); }
input, select {
  width: 100%;
  min-height: 46px;
  padding: 0;
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
input::placeholder { color: var(--plata); }
select {
  padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 11px) 52%, calc(100% - 6px) 52%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
select option { color: var(--grafito); background: var(--mantel); }
input:focus, select:focus, .price:focus-within { border-bottom-color: var(--ink); }
.price { display: flex; align-items: center; gap: .6rem; border-bottom: 1px solid var(--rule); }
.price input { border: 0; }
.price span { color: var(--ink-soft); font-size: .9rem; }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.filters label { margin-top: 0; }

/* Registrar + pendientes */
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset:disabled { opacity: .6; }
.form-actions { display: flex; align-items: center; gap: 1.5rem; margin-top: 2.2rem; flex-wrap: wrap; }
.save { padding: .85rem 1.5rem; border: 0; background: var(--btn-bg); color: var(--btn-ink); font-size: .98rem; transition: opacity .2s; }
.save:hover:not(:disabled) { opacity: .85; }
.link { padding: 0; border: 0; background: none; font-size: .95rem; text-decoration: underline; text-underline-offset: 3px; }
.note { margin: 1.4rem 0 0; font-size: .9rem; color: var(--ink-soft); max-width: 34rem; }
.success, .error { margin: 1rem 0 0; font-size: .95rem; }
.success { color: var(--ok); }
.error { color: var(--danger); }
.empty { margin: 1.4rem 0 0; font-family: var(--font-display); font-style: italic; font-size: 1.15rem; color: var(--ink-soft); }

.summary { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-top: 2rem; padding-bottom: .8rem; border-bottom: 1px solid var(--ink); }
.summary span { font-size: .9rem; color: var(--ink-soft); }
.summary strong { font-family: var(--font-display); font-weight: 400; font-size: 1.6rem; white-space: nowrap; }

.list { margin: 0; padding: 0; list-style: none; max-height: 560px; overflow: auto; }
.list li { display: flex; justify-content: space-between; gap: 1rem; padding: 1.1rem 0; border-bottom: 1px solid var(--rule); }
.list li > div:first-child { min-width: 0; }
.list h3 { font-size: 1.2rem; overflow-wrap: anywhere; }
.list p { margin: .2rem 0 0; font-size: .85rem; color: var(--ink-soft); }
.row-price { text-align: right; flex-shrink: 0; }
.row-price strong { font-weight: 400; white-space: nowrap; }
.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 1rem; margin-top: .3rem; }
.row-actions button, .row-price > button { padding: 0; border: 0; background: none; font-size: .85rem; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px; }
.row-actions button:hover, .row-price > button:hover { color: var(--ink); }
.row-price > button { margin-top: .3rem; }
.row-actions .delete { color: var(--danger); }

/* Gastos clasificados */
.summary-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 2rem; margin-bottom: clamp(2rem, 4vw, 2.8rem); }
.summary-heading p { margin: .8rem 0 0; font-size: .9rem; color: var(--ink-soft); }
.grand-total { text-align: right; }
.grand-total span { display: block; font-size: .75rem; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-soft); }
.grand-total strong { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.6rem, 3vw, 2.2rem); line-height: 1.1; white-space: nowrap; }

.group-section { max-width: none; }
.group-section + .group-section { margin-top: clamp(2.5rem, 5vw, 3.5rem); }
.group-section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .4rem; }
.group-section-head h3 { font-style: italic; font-size: 1.9rem; }
.group-section-head span { padding-right: 2.5rem; font-size: .9rem; color: var(--ink-soft); white-space: nowrap; }

/* Filas como las preguntas frecuentes del sitio */
.group { border-top: 1px solid var(--rule); }
.group:last-child { border-bottom: 1px solid var(--rule); }
.group-flat { padding-top: .4rem; }
.group-flat ul, .group-flat .group-total { padding-left: 0; margin-left: 0; }
.group summary { display: grid; grid-template-columns: minmax(0, 1fr) auto auto 1rem; align-items: baseline; gap: 1.5rem; padding: 1.1rem 0; cursor: pointer; list-style: none; }
.group summary::-webkit-details-marker { display: none; }
.group summary::after { content: "+"; justify-self: end; color: var(--ink-soft); }
.group[open] summary::after { content: "–"; }
.group-name { font-family: var(--font-display); font-size: 1.3rem; overflow-wrap: anywhere; }
.group-count { font-size: .85rem; color: var(--ink-soft); white-space: nowrap; }
.group summary strong { font-weight: 400; white-space: nowrap; min-width: 7em; text-align: right; }
.pending-note { margin: 0 0 .8rem; font-size: .9rem; color: var(--ink-soft); }
.group ul { margin: 0; padding: 0 0 0 clamp(0rem, 3vw, 2rem); list-style: none; max-height: 420px; overflow: auto; }
.group li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto 1rem; align-items: baseline; gap: 1.5rem; padding: .55rem 0; font-size: .95rem; color: var(--ink-soft); }
.item-name { min-width: 0; overflow-wrap: anywhere; color: var(--ink); }
.item-name small { margin-left: .7rem; letter-spacing: 0; font-size: .8rem; }
.group li strong { font-weight: 400; color: var(--ink); white-space: nowrap; min-width: 7em; text-align: right; }
.group li .row-actions { margin-top: 0; }
/* Precios de compras, total del evento y fila del evento terminan en la misma columna (antes del +). */
.group-total { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin: .6rem 0 1.4rem clamp(0rem, 3vw, 2rem); padding: .8rem 2.5rem 0 0; border-top: 1px solid var(--rule); }
.group-total span { font-size: .9rem; color: var(--ink-soft); }
.group-total strong { font-family: var(--font-display); font-weight: 400; font-size: 1.35rem; white-space: nowrap; }

.payroll-total { margin: 2.5rem 0 0; font-size: .95rem; color: var(--ink-soft); }
.reconciliation { margin: 1.2rem 0 0; max-width: 46rem; font-family: var(--font-display); font-style: italic; font-size: clamp(1.2rem, 2.2vw, 1.6rem); line-height: 1.35; }
.reconciliation span { display: block; margin-top: .5rem; font-family: var(--font-text); font-style: normal; font-size: .85rem; color: var(--ink-soft); }

/* Papelera */
#papelera h2 .muted { font-family: var(--font-text); font-size: 1rem; }

/* Pie oscuro, como el del sitio */
.site-footer { margin-top: clamp(3rem, 6vw, 5rem); padding: 2.2rem 0; background: var(--grafito); color: var(--mantel); }
.site-footer .wrap { display: flex; justify-content: space-between; align-items: center; gap: 1rem 2rem; flex-wrap: wrap; font-size: .85rem; color: #f5f5f2b3; }
.site-footer .brand { color: var(--mantel); }
.site-footer .monogram { width: 2.8rem; height: 2.8rem; }
.brand-sub { display: block; margin-top: .25rem; font-size: .7rem; letter-spacing: .2em; color: #f5f5f2b3; }
@media (prefers-color-scheme: dark) { .site-footer { background: #121310; } }

@media (max-width: 900px) {
  .figures { grid-template-columns: 1fr 1fr; row-gap: 1.4rem; }
}
@media (max-width: 560px) {
  .site-header { padding-top: .8rem; padding-bottom: .4rem; }
  .hero { padding-top: 1.4rem; padding-bottom: 1.6rem; }
  h1 { font-size: 3.4rem; }
  .lead { font-size: 1.15rem; }
  .figures { gap: 1rem; row-gap: 1.1rem; }
  .figures div { padding-top: .7rem; }
  .figures dt { font-size: 1rem; }
  .figures dd { font-size: 1.45rem; }
  .tabs [role="tablist"] { justify-content: space-between; gap: .5rem; }
  .tabs button { font-size: 1rem; padding: .9rem 0 .8rem; }
  .tab-count { margin-left: .15rem; }
  h2 { font-size: 2rem; }
  .filters { gap: 1rem; }
  .group-section-head h3 { font-size: 1.6rem; }
  .summary-heading { flex-direction: column; align-items: flex-start; }
  .grand-total { text-align: left; }
  .list { max-height: none; }
  .list li { flex-direction: column; gap: .4rem; }
  .row-price { text-align: left; display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
  .row-actions { margin-top: 0; }
  .group summary { grid-template-columns: minmax(0, 1fr) auto 1rem; gap: 1rem; }
  .group summary .group-count { display: none; }
  .group li { grid-template-columns: minmax(0, 1fr) auto 1rem; gap: .2rem 1rem; }
  .group li .item-name { grid-row: 1; }
  .group li strong { grid-row: 1; grid-column: 2; min-width: 0; }
  .group li .row-actions { grid-row: 2; grid-column: 1 / -1; justify-content: flex-start; }
  .group-total, .group-section-head span { padding-right: 2rem; }
  .item-name small { margin-left: .5rem; }
  .group ul { max-height: none; padding-left: 0; }
  .group li { padding: .7rem 0; border-top: 1px solid var(--rule); }
  .group li:first-child { border-top: 0; }
  .group-total { margin-top: .2rem; }
  #gastos .grand-total { display: none; }
  .summary-heading { margin-bottom: 1.6rem; }
  .group-total { margin-left: 0; }
}
@media (max-width: 380px) {
  .tabs [role="tablist"] { gap: .4rem; }
  .tabs button { font-size: .9rem; }
  .tab-count { font-size: .65rem; margin-left: .1rem; }
}

/* Todas las cifras en Jost fina y de ancho fijo; Bodoni queda para las palabras. */
.figures dd, .summary strong, .grand-total strong, .group-total strong {
  font-family: var(--font-text);
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
