/* Semantic navigation links use the same colours as the municipal dashboard. */
.nav-toggle { display: none; }
.nav a[data-view] {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 45px;
  padding: 11px;
  color: #c9ded3;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.3;
  font-weight: 500;
  text-decoration: none;
  counter-increment: section;
}
.nav a[data-view]::before {
  content: counter(section, decimal-leading-zero);
  min-width: 15px;
  color: #8bc0a4;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.nav a[data-view]:hover { color: white; border-color: #82c2a02e; background: #ffffff09; }
.nav a[data-view][aria-current="page"], .nav a[data-view].active {
  background: var(--brand-control);
  border-color: #cbf58b;
  color: #102518;
  font-weight: 700;
}
.nav a[data-view][aria-current="page"]::before, .nav a[data-view].active::before { color: #24442c; }
.table-swipe-note { display: none; }
.table-wrap:focus-visible, .comparison-table:focus-visible, .nav-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media screen and (max-width: 1024px) {
  aside.sidebar {
    position: relative;
    inset: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    width: 100%;
    padding: 12px clamp(12px, 3vw, 32px);
    gap: 0 12px;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(115deg, var(--benavente-green), #104434 48%, #20391c);
  }
  .sidebar .brand {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: clamp(8px, 2vw, 18px);
    min-width: 0;
    padding: 0;
    margin: 0;
    border: 0;
  }
  .sidebar .brand-logo { width: clamp(77px, 15vw, 117px); padding: 5px 7px; flex: none; }
  .brand-budget .brand-title { margin: 0; font-size: clamp(12px, 2vw, 17px); letter-spacing: .02em; }
  .brand-budget .brand-year { margin: 0; font-size: clamp(22px, 3vw, 31px); line-height: 1; letter-spacing: -.04em; }
  .sidebar-footer { display: none; }
  .sidebar .nav {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    overflow: visible;
    margin: 12px 0 0;
    padding: 10px 0 0;
    border-top: 1px solid #82c2a042;
  }
  .sidebar .nav :is(a[data-view], button) {
    min-height: 44px;
    padding: 9px 10px;
    font-size: 13px;
    line-height: 1.35;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .sidebar .nav :is(a[data-view], button)::before { display: none; }
  .nav-ready .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 44px;
    max-width: 12.5em;
    padding: 7px 12px;
    border: 1px solid #86ac8e;
    border-radius: 8px;
    background: #123d2b;
    color: #f0f9e9;
    font: 600 13px/1.25 Arial, sans-serif;
  }
  .nav-toggle::after {
    content: "";
    flex: none;
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
  }
  .nav-toggle[aria-expanded="true"]::after { transform: translateY(2px) rotate(225deg); }
  .nav-ready .nav-toggle[aria-expanded="false"] + .nav { display: none; }
  main { margin-left: 0; padding: 22px clamp(12px, 3vw, 32px) 30px; }
  .metrics, .metrics.five, .legal-summary, .comparison-metrics {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  }
  .mini-metrics { grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); }
  .metric, .legal-card, .comparison-metric, .panel, .grid-two > *, .source-card, .field { min-width: 0; }
  .field input, .field select, #global-search, .legal-field input,
  .legal-field select, .legal-evidence textarea, .comparison-toolbar :is(input, select) {
    min-height: 44px;
    font-size: 16px;
  }
  .button, .close, .segmented button, .comparison-tabs :is(button, a),
  .global-search-controls .button, .legal-actions .button, .theme-chips .button,
  .panel-head .button, .results-head .button { min-height: 44px; }
  .table-wrap, .comparison-table { min-width: 0; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
  .table-swipe-note:not([hidden]) { display: block; margin: 0 0 6px; color: var(--muted); font-size: 12px; }
  dialog#detail { max-height: 90vh; max-height: 90dvh; overscroll-behavior: contain; }
  .dialog-head {
    position: sticky;
    top: 0;
    z-index: 2;
    align-items: center;
    background: #133322;
  }
  .dialog-head .eyebrow { margin: 0; }
  .source-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media screen and (min-width: 701px) and (max-width: 1024px) {
  .filterbar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; }
  .filterbar .field { min-width: 0; }
  .filterbar .field.search { grid-column: span 2; }
  .comparison-toolbar { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .comparison-toolbar > .field.search { grid-column: 1/-1; }
}

@media screen and (max-width: 700px) {
  .sidebar .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  main { padding-top: 17px; }
  .topline { margin-bottom: 14px; padding-bottom: 11px; }
  .global-search-shell { margin-bottom: 20px; }
  .page-head, .panel-head { flex-wrap: wrap; }
  .page-head h1 { font-size: clamp(28px, 7.6vw, 36px); line-height: 1.12; }
  .page-head .lede { font-size: 14px; }
  .panel { padding: clamp(14px, 3.6vw, 20px); }
  .panel-head .text-link { min-height: 44px; padding-block: 8px; }
  .global-search-shell label, .filterbar .field label, .comparison-toolbar label { font-size: 12px; }
  .global-search-shell p, .chart-note, .metric-detail, .legal-card p,
  .legal-field small, .legal-note, .comparison-metric p, .comparison-metric small { font-size: 12px; }
  .metric-label { min-height: 0; }
  .metrics, .metrics.five, .comparison-metrics { gap: 10px; }
  .metrics .metric-value, .metrics.five .metric-value { font-size: clamp(23px, 5.4vw, 29px); }
  .legal-summary { grid-template-columns: repeat(auto-fit, minmax(min(100%, 218px), 1fr)); }
  .source-cards, .year-bars { grid-template-columns: 1fr; }
  .global-search-controls { display: grid; grid-template-columns: 1fr 1fr; }
  .global-search-controls input { grid-column: 1 / -1; min-width: 0; }
  .filterbar, .comparison-toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
    gap: 12px;
  }
  .filterbar .field, .filterbar .field.search, .comparison-toolbar .field { min-width: 0; }
  .filterbar .field.search, .comparison-toolbar .field.search { grid-column: 1/-1; }
  #reset, #comparison-clear-category { min-height: 44px; justify-self: start; }
  .legal-actions .button { min-width: min(100%, 140px); }
  .comparison-change-item { flex-wrap: wrap; }
  .comparison-change-item > span:first-child { flex: 1 1 155px; }
  .comparison-bar-label { flex-wrap: wrap; }
  .legend .legend-row {
    display: grid;
    grid-template-columns: 11px minmax(0, 1fr) auto;
    grid-template-areas: "swatch label value" ". label percent";
    align-items: start;
    gap: 2px 8px;
    min-height: 44px;
  }
  .legend-row .swatch { grid-area: swatch; margin-top: .4em; }
  .legend-label { grid-area: label; align-self: center; }
  .legend-value { grid-area: value; }
  .legend-percent { grid-area: percent; width: auto; text-align: right; }
  #detail-content { overflow-wrap: anywhere; padding: 16px; }
  dialog#detail { width: calc(100% - 16px); max-height: 94vh; max-height: 94dvh; }
  .dialog-head { padding: 10px 16px; }
  .kpi-strip, .funding-line { flex-wrap: wrap; }
}

/* On a phone, keep the title, years and source for each result in one view. */
@media screen and (max-width: 600px) {
  .table-wrap.mobile-records, .comparison-table.mobile-records {
    overflow: visible;
    background: transparent;
    border: 0;
  }
  .mobile-records table, .mobile-records tbody, .mobile-records tr,
  .mobile-records td { display: block; }
  .table-wrap.mobile-records table, .comparison-table.mobile-records table { width: 100%; min-width: 0; }
  .mobile-records thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    clip-path: inset(50%);
    overflow: hidden;
    white-space: nowrap;
  }
  .mobile-records tbody { display: grid; gap: 10px; }
  .mobile-records tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
    gap: 9px 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #102e1e;
  }
  .mobile-records tbody td, .comparison-table.mobile-records tbody td {
    min-width: 0;
    padding: 0;
    border: 0;
    font-size: 13px;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .mobile-records td::before {
    content: attr(data-mobile-label);
    content: attr(data-mobile-label) / "";
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font: 400 11px/1.45 Arial, sans-serif;
  }
  .mobile-records .record-title { grid-column: 1 / -1; grid-row: 1; }
  .mobile-records .record-title::before { display: none; }
  .mobile-records button.row-title, .comparison-table.mobile-records button.row-title {
    min-width: 0;
    max-width: 100%;
    min-height: 36px;
    padding-block: 5px;
    font-size: 15px;
    line-height: 1.4;
  }
  .mobile-records .row-meta { font-size: 12px; }
  .mobile-records td a { display: inline-flex; align-items: center; min-height: 36px; }
  .mobile-records td .funding-percentages { min-width: 0; }
}

@media screen and (max-width: 440px) {
  .nav-ready .nav-toggle { max-width: 110px; padding: 6px 9px; font-size: 12px; }
  .filterbar, .comparison-toolbar { grid-template-columns: 1fr; }
  .metrics, .metrics.five, .comparison-metrics { grid-template-columns: 1fr 1fr; }
  .metrics .metric, .comparison-metric { padding: 14px 11px; }
  .metrics .metric-value, .metrics.five .metric-value { white-space: normal; }
  .mini-metrics { grid-template-columns: 1fr; }
  .bar-top { flex-wrap: wrap; }
  .bar-top strong { white-space: normal; }
  .comparison-pair, .detail-grid { grid-template-columns: 1fr; }
}

.skip-link {
  position: absolute;
  z-index: 99;
  inset: 8px auto auto 8px;
  padding: 10px 15px;
  border-radius: 7px;
  color: #0a2718;
  background: #d3f6a8;
  transform: translateY(calc(-100% - 12px));
}
.skip-link:focus { transform: none; }

.nav-section-label {
  grid-column: 1 / -1;
  margin: 8px 0 0;
  padding: 13px 11px 2px;
  border-top: 1px solid var(--line);
  color: #c1d5c6;
  font-size: .78rem;
}
@media screen and (min-width:1025px) {
  aside.sidebar {overflow-y:auto}
  .sidebar .brand, .sidebar .nav, .sidebar-footer {flex-shrink:0}
}
body:is([data-view="updates"],[data-view="creator"]) :is(.global-search-shell, .topline .status) {display:none}
footer nav {display:flex; flex-wrap:wrap; gap:8px 18px; margin-top:10px}
footer nav a {color:inherit; text-underline-offset:3px}
