:root {
  --bg: #f7f3eb;
  --panel: rgba(255, 252, 246, 0.9);
  --panel-strong: #fffdf8;
  --line: #d8cfc3;
  --ink: #2f2a24;
  --muted: #6f675e;
  --accent: #1f6a67;
  --accent-soft: #d7efec;
  --sand: #efe3d2;
  --sand-strong: #e1cfb6;
  --anterior: #dceaf8;
  --actual: #ffe7bf;
  --acumulado: #d9f1df;
  --saldo: #f8d7d7;
  --danger: #9b3d3d;
  --shadow: 0 20px 45px rgba(80, 59, 40, 0.1);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 15px;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 231, 191, 0.9), transparent 28%),
    radial-gradient(circle at top right, rgba(215, 239, 236, 0.8), transparent 30%),
    linear-gradient(180deg, #fbf8f1 0%, var(--bg) 55%, #f2ede3 100%);
}

.page-shell {
  width: min(1680px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.hero,
.panel,
.stat-card {
  background: var(--panel);
  border: 1px solid rgba(216, 207, 195, 0.8);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  padding: 28px;
  border-radius: calc(var(--radius) + 4px);
}

.eyebrow {
  margin: 0 0 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 2.6vw, 3.3rem);
  line-height: 0.98;
  font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

.hero-copy {
  max-width: 72ch;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-content: flex-start;
  gap: 10px;
}

.button {
  border: 1px solid rgba(47, 42, 36, 0.14);
  background: var(--panel-strong);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.8rem 1.15rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(47, 42, 36, 0.08);
}

.button-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #3a8b81 100%);
  color: white;
  border-color: transparent;
}

.button-danger {
  color: var(--danger);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 1.2fr) minmax(220px, 0.8fr) minmax(300px, 1.1fr);
  gap: 16px;
  margin-top: 18px;
  padding: 18px;
  border-radius: var(--radius);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field > span {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.field input[type="search"] {
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fffdf9;
  padding: 0 14px;
  font: inherit;
}

.checkbox-field {
  justify-content: center;
  padding: 12px 16px;
  border-radius: 18px;
  background: rgba(239, 227, 210, 0.55);
}

.checkbox-field input {
  inline-size: 18px;
  block-size: 18px;
}

.checkbox-field span {
  color: var(--ink);
}

.hint-field {
  padding: 12px 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(215, 239, 236, 0.72), rgba(255, 231, 191, 0.72));
}

.hint-field p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.stat-card {
  padding: 18px;
  border-radius: 20px;
}

.stat-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-value {
  margin: 0;
  font-size: clamp(1.3rem, 2.1vw, 2rem);
  font-weight: 800;
}

.stat-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.table-panel {
  margin-top: 18px;
  padding: 14px;
  border-radius: calc(var(--radius) + 2px);
}

.table-wrap {
  overflow: auto;
  border-radius: 18px;
  border: 1px solid rgba(216, 207, 195, 0.9);
  background: #fffcf7;
}

.valuation-table {
  width: max(100%, 1800px);
  border-collapse: separate;
  border-spacing: 0;
}

.valuation-table th,
.valuation-table td {
  border-right: 1px solid rgba(216, 207, 195, 0.6);
  border-bottom: 1px solid rgba(216, 207, 195, 0.6);
  padding: 10px 12px;
  vertical-align: middle;
}

.valuation-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f8f1e7;
  text-align: center;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.valuation-table thead tr:first-child th {
  top: 0;
}

.valuation-table thead tr:nth-child(2) th {
  top: 46px;
  z-index: 4;
}

.valuation-table th:first-child,
.valuation-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
}

.valuation-table th:nth-child(2),
.valuation-table td:nth-child(2) {
  position: sticky;
  left: 133px;
  z-index: 2;
}

.valuation-table thead th:first-child,
.valuation-table thead th:nth-child(2) {
  z-index: 6;
}

.valuation-table td:first-child,
.valuation-table td:nth-child(2) {
  background: #fff9f0;
}

.group-head.anterior-head,
.metric-input.anterior-input,
.metric-read.anterior-read {
  background: var(--anterior);
}

.group-head.actual-head,
.metric-input.actual-input,
.metric-read.actual-read {
  background: var(--actual);
}

.group-head.acumulado-head,
.metric-read.acumulado-read {
  background: var(--acumulado);
}

.group-head.saldo-head,
.metric-read.saldo-read {
  background: var(--saldo);
}

.chapter-row td {
  background: linear-gradient(90deg, #dfc3a3 0%, #eadbc8 100%) !important;
  font-weight: 800;
}

.section-row td {
  background: linear-gradient(90deg, #dbece2 0%, #edf5f0 100%) !important;
  font-weight: 800;
}

.group-row td {
  background: linear-gradient(90deg, #e6eef3 0%, #f5f8fa 100%) !important;
  color: #325165;
  font-weight: 700;
}

.group-label {
  white-space: nowrap;
}

.group-title {
  color: inherit;
}

.detail-row td {
  background: #fffdf9;
}

.item-cell {
  min-width: 132px;
  font-weight: 700;
  color: #675846;
}

.description-cell {
  min-width: 500px;
}

.description-indent {
  display: inline-block;
}

.unit-cell,
.number-cell {
  text-align: center;
  white-space: nowrap;
}

.number-cell {
  font-variant-numeric: tabular-nums;
}

.metric-input {
  width: 100%;
  min-width: 112px;
  border: 1px solid rgba(47, 42, 36, 0.1);
  border-radius: 12px;
  padding: 0.62rem 0.7rem;
  font: inherit;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.metric-input:focus {
  outline: 2px solid rgba(31, 106, 103, 0.22);
  border-color: rgba(31, 106, 103, 0.45);
}

.metric-read {
  min-width: 112px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.muted-value {
  color: var(--muted);
}

.loading-cell,
.empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 26px !important;
}

@media (max-width: 1180px) {
  .hero,
  .toolbar,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .hero-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100vw - 16px, 100%);
    padding-top: 14px;
  }

  .hero,
  .toolbar,
  .stat-card,
  .table-panel {
    border-radius: 18px;
  }

  .hero {
    padding: 20px;
  }

  .valuation-table th:nth-child(2),
  .valuation-table td:nth-child(2) {
    left: 117px;
  }

  .item-cell {
    min-width: 116px;
  }
}
