:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --ink: #16302f;
  --ink-soft: #4d6361;
  --line: #e2e8e6;
  --primary: #0f3d3e;
  --primary-soft: #14605f;
  --accent: #c8a24a;
  --obras: #2563eb;
  --servicios: #0d9488;
  --suministros: #9333ea;
  --gestion: #b45309;
  --shadow: 0 1px 2px rgba(16, 48, 47, .06), 0 6px 18px rgba(16, 48, 47, .06);
  --radius: 14px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-soft));
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 14px;
  padding-bottom: 14px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { font-size: 30px; line-height: 1; }
.brand-title { margin: 0; font-size: 1.15rem; font-weight: 700; letter-spacing: .2px; }
.brand-sub { margin: 2px 0 0; font-size: .82rem; opacity: .85; }

.year-picker { display: flex; align-items: center; gap: 8px; }
.year-picker label { font-size: .85rem; opacity: .9; }
#year {
  appearance: none;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 10px;
  padding: 8px 34px 8px 14px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23fff' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
#year option { color: #16302f; }

/* Coverage banner */
.coverage {
  margin: 18px 0 0;
  background: #fff8e6;
  border: 1px solid #f0e0b0;
  color: #6b531b;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: .85rem;
}

/* Summary cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.card .k { font-size: .78rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .4px; }
.card .v { font-size: 1.5rem; font-weight: 700; margin-top: 6px; }
.card .v.small { font-size: 1.15rem; }

/* Controls */
.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin: 6px 0 14px;
}
.search {
  flex: 1 1 240px;
  min-width: 0;
}
.search input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 1rem;
  background: #fff;
}
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  padding: 8px 13px;
  border-radius: 999px;
  font-size: .85rem;
  cursor: pointer;
  white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Section */
.section { margin: 26px 0; }
.section > h2 {
  font-size: 1.05rem;
  margin: 0 0 4px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.section .count { font-size: .82rem; color: var(--ink-soft); font-weight: 500; }
.section-note { margin: 0 0 12px; font-size: .82rem; color: var(--ink-soft); }

/* Table (desktop) */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
  text-align: left;
  background: #f0f4f3;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0;
  white-space: nowrap;
}
th.num, td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8faf9; }
.exp { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; color: var(--ink-soft); white-space: nowrap; }
.obj { min-width: 240px; }
.adj { color: var(--ink-soft); }

/* Type badge */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 600; color: #fff; white-space: nowrap; }
.badge.Obras { background: var(--obras); }
.badge.Servicios { background: var(--servicios); }
.badge.Suministros { background: var(--suministros); }
.badge.Gestion { background: var(--gestion); }
.badge.otro { background: #64748b; }

.estado { font-size: .76rem; color: var(--ink-soft); display: block; margin-top: 3px; }

.empty { padding: 26px; text-align: center; color: var(--ink-soft); background: #fff; border: 1px dashed var(--line); border-radius: var(--radius); }
.loading { padding: 40px 0; text-align: center; color: var(--ink-soft); }

/* Footer */
.site-footer {
  margin-top: 40px;
  padding: 22px 0 36px;
  background: #0c2b2b;
  color: #b9cccb;
  font-size: .8rem;
}
.site-footer p { margin: 0 0 8px; }
.disclaimer-official { color: #ffd9a6; font-weight: 600; }
.site-footer a { color: #e7eeed; }

/* Barra de total del filtro (fija abajo) */
.total-bar {
  position: sticky;
  bottom: 0;
  z-index: 15;
  background: rgba(15, 61, 62, .97);
  color: #fff;
  box-shadow: 0 -2px 14px rgba(16, 48, 47, .18);
  backdrop-filter: saturate(1.4) blur(4px);
}
.total-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  padding-bottom: 12px;
}
#total-bar-count { font-size: .85rem; opacity: .9; }
#total-bar-amount { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
#total-bar-amount .lbl { font-size: .72rem; font-weight: 500; opacity: .85; margin-right: 6px; text-transform: uppercase; letter-spacing: .4px; }

.version {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  opacity: .65;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 50;
  font-size: .9rem;
}

/* Mobile: tables become cards */
@media (max-width: 680px) {
  .brand-title { font-size: 1rem; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  .table-wrap { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  tbody tr {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    padding: 12px 14px;
  }
  tbody td { border: 0; padding: 4px 0; }
  tbody td::before {
    content: attr(data-label);
    display: block;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--ink-soft);
  }
  th.num, td.num { text-align: left; }
  .obj { min-width: 0; font-weight: 600; }
}
