/* ตรวจงบนนทบุรี — หน้ารายการงบประมาณ */

body.catalog {
  /* rem so the accessibility panel's root scaling reaches body-level text */
  font-size: 1rem;
  background: var(--azure-pale);
}

/* ------------------------------------------------------------ catalog hero */

.catalog-hero {
  background: var(--navy);
  color: var(--white);
  padding: 28px 0 32px;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.72);
  margin-bottom: 12px;
  list-style: none;
  padding: 0;
}

.breadcrumb a {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb li + li::before {
  content: "›";
  margin-right: 6px;
  color: rgba(255, 255, 255, 0.5);
}

.catalog-hero h1 {
  font-size: clamp(1.5rem, 3.2vw, 2.4rem);
  font-weight: 700;
  line-height: 1.2;
}

.catalog-hero .eyebrow {
  margin-bottom: 10px;
}

.catalog-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  margin-top: 14px;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.85);
}

.catalog-summary b {
  color: var(--white);
  font-weight: 600;
}

/* ------------------------------------------------------------------ layout */

.catalog-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 24px;
  align-items: start;
  padding: 24px 0 64px;
}

.mobile-toolbar {
  display: none;
  position: sticky;
  top: var(--header-height);
  z-index: 60;
  padding: 10px 0;
  background: var(--azure-pale);
  border-bottom: 1px solid var(--line);
}

.mobile-toolbar button {
  width: 100%;
  min-height: 48px;
  border-radius: 999px;
  border: 1px solid var(--navy);
  background: var(--navy);
  color: var(--white);
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.filter-count-badge {
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--azure-light);
  color: var(--navy-deep);
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.filter-count-badge[hidden] {
  display: none;
}

/* ------------------------------------------------------------ filter panel */

.filter-panel {
  position: sticky;
  top: calc(var(--header-height) + 16px);
  max-height: calc(100svh - var(--header-height) - 32px);
  overflow-y: auto;
  background: var(--navy);
  color: var(--white);
  border-radius: var(--radius-md);
  padding: 22px;
  box-shadow: var(--shadow-md);
  scrollbar-width: thin;
}

.filter-panel h2 {
  font-size: 1.05rem;
  margin-bottom: 4px;
}

.filter-panel .panel-note {
  font-size: 0.84rem;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 18px;
}

.filter-group {
  padding: 16px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.filter-group:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.filter-group > legend,
.filter-group > .filter-label {
  display: block;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--azure-light);
  margin-bottom: 10px;
  padding: 0;
}

.filter-group {
  border-inline: 0;
  border-bottom: 0;
  margin: 0;
}

fieldset.filter-group {
  border-width: 1px 0 0;
}

.filter-panel input[type="search"],
.filter-panel select {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
  font-size: 0.95rem;
}

.filter-panel select option {
  color: var(--ink);
  background: var(--white);
}

.filter-panel input[type="search"]::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.filter-panel input[type="search"]:focus-visible,
.filter-panel select:focus-visible {
  outline: 3px solid var(--azure-light);
  outline-offset: 2px;
}

.check-list {
  display: grid;
  gap: 4px;
}

.check-list label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 4px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.93rem;
}

.check-list label:hover {
  background: rgba(255, 255, 255, 0.09);
}

.check-list input {
  width: 18px;
  height: 18px;
  accent-color: var(--azure-light);
  flex: 0 0 auto;
}

.check-list .count {
  margin-left: auto;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
  font-variant-numeric: tabular-nums;
}

.filter-reset {
  width: 100%;
  min-height: 46px;
  margin-top: 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: transparent;
  color: var(--white);
  font-weight: 500;
  cursor: pointer;
}

.filter-reset:hover {
  background: var(--white);
  color: var(--navy);
}

.filter-close {
  display: none;
}

/* ----------------------------------------------------------- results panel */

.results-panel {
  min-width: 0;
}

.zero-budget-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 16px 18px;
  border: 1px solid #b9d7fb;
  border-radius: var(--radius-sm);
  background: linear-gradient(120deg, #eef7ff 0%, #f8fbff 58%, #e5f2ff 100%);
  box-shadow: 0 5px 16px rgba(14, 54, 104, 0.07);
  color: var(--navy);
}

.zero-budget-bar > div { display: grid; gap: 3px; }
.zero-budget-bar strong { font-size: 1rem; }
.zero-budget-bar span { color: var(--muted); font-size: .9rem; }
.zero-budget-bar.is-active { border-color: var(--azure); background: linear-gradient(120deg, #ddecff, #f1f8ff); }
.zero-budget-bar button {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 9px;
  min-height: 44px; padding: 6px 13px; border: 1px solid #a7c8ed;
  border-radius: 999px; background: var(--white); color: var(--navy);
  font: inherit; font-weight: 600; cursor: pointer;
}
.zero-switch-track { width: 38px; height: 22px; padding: 2px; border-radius: 999px; background: #a7b7ca; }
.zero-switch-track i { display: block; width: 18px; height: 18px; border-radius: 50%; background: white; transition: transform .18s ease; }
#zero-budget-toggle[aria-checked="true"] .zero-switch-track { background: var(--azure); }
#zero-budget-toggle[aria-checked="true"] .zero-switch-track i { transform: translateX(16px); }

@media (max-width: 600px) {
  .zero-budget-bar { align-items: flex-start; }
  .zero-budget-bar > div span { font-size: .84rem; }
}

@media (prefers-reduced-motion: reduce) { .zero-switch-track i { transition: none; } }

.results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.results-head h2 {
  font-size: 1.2rem;
  color: var(--navy);
}

.results-count {
  color: var(--muted);
  font-size: 0.94rem;
}

.results-actions {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pill-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--navy);
  font-weight: 500;
  font-size: 0.92rem;
  cursor: pointer;
}

.pill-button:hover {
  background: var(--azure-soft);
  border-color: var(--azure);
}

.pill-button[aria-pressed="true"] {
  background: var(--azure-soft);
  border-color: var(--azure);
}

.view-switch {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--white);
  gap: 2px;
}

.view-switch button {
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--navy);
  font-size: 0.9rem;
  cursor: pointer;
}

.view-switch button[aria-pressed="true"] {
  background: var(--navy);
  color: var(--white);
  font-weight: 500;
}

.page-size {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

.page-size select {
  min-height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--navy);
}

.quality-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 18px;
  margin-bottom: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  border-left: 4px solid var(--azure);
  background: var(--white);
  font-size: 0.9rem;
  color: var(--muted);
}

.quality-banner b {
  color: var(--navy);
}

.quality-banner > span:first-child {
  flex: 1 1 260px;
  min-width: 0;
}

.quality-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.quality-banner #quality-dismiss {
  min-height: 32px;
  border: 0;
  background: transparent;
  color: var(--azure-ink);
  cursor: pointer;
  font-size: 0.88rem;
}

.quality-pages {
  flex: 1 1 100%;
  min-width: 0;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.quality-pages summary {
  cursor: pointer;
  color: var(--azure-ink);
  font-weight: 500;
}

.issue-page-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
}

.issue-page-list li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.78rem;
}

.issue-page-list .count {
  font-weight: 600;
  color: var(--navy);
}

/* --------------------------------------------------- flagged review points */

.badge.badge-issue {
  background: #fdeede;
  color: #8a4b08;
}

.issue-list {
  display: grid;
  gap: 12px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.issue-list li {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  border-left: 3px solid #d98324;
  background: #fffaf3;
}

.issue-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.issue-meta {
  font-size: 0.76rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.issue-text {
  margin: 8px 0 0;
  font-size: 0.88rem;
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------ load failure */

.load-error {
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  border-left: 4px solid var(--danger);
  background: #fdf3f2;
}

.load-error h3 {
  margin: 0 0 6px;
  color: var(--danger);
}

.load-error p {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: var(--muted);
}

.status-detail {
  margin-top: 12px;
  font-size: 0.76rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.checksum {
  font-size: 0.72rem;
  overflow-wrap: anywhere;
}

.pill-button.primary {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--white);
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.active-filters:empty {
  display: none;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 8px 0 14px;
  border-radius: 999px;
  background: var(--navy-soft);
  border: 1px solid var(--azure);
  color: var(--navy);
  font-size: 0.86rem;
}

.filter-chip button {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 0;
  background: rgba(11, 42, 91, 0.12);
  color: var(--navy);
  cursor: pointer;
  line-height: 1;
  font-size: 0.9rem;
}

.filter-chip button:hover {
  background: var(--navy);
  color: var(--white);
}

/* ------------------------------------------------------------------- cards */

.budget-grid {
  display: grid;
  gap: 14px;
}

.budget-grid.view-cards {
  /* min() keeps the 300px track from forcing a column wider than the screen —
     the bare minmax(300px, 1fr) made every card overflow on a 375px phone. */
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
}

.budget-grid.view-review {
  grid-template-columns: 1fr;
}

.budget-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 10px;
  padding: 18px;
  text-align: left;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.budget-card:hover,
.budget-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--azure);
}

.budget-card.is-reviewed {
  border-left: 4px solid var(--success);
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  max-width: 100%;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 500;
  background: var(--azure-soft);
  color: var(--navy);
  /* was nowrap: a long category name pushed the whole card past the viewport */
  overflow-wrap: anywhere;
}

.badge.badge-group {
  background: var(--navy);
  color: var(--white);
}

.badge.badge-saved {
  background: #fff3cd;
  color: #7a5b00;
}

.badge.badge-reviewed {
  background: #d8f2e3;
  color: var(--success);
}

.budget-card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.view-cards .budget-card h3 {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.budget-card .card-amount {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: -0.01em;
}

.budget-card .card-path {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: auto;
  overflow-wrap: anywhere;
}

.budget-card .card-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 0.82rem;
  color: var(--muted);
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.view-review .budget-card {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "badges amount"
    "title  amount"
    "path   amount"
    "foot   foot";
  align-items: start;
  column-gap: 24px;
}

.view-review .budget-card .card-badges { grid-area: badges; }
.view-review .budget-card h3 { grid-area: title; }
.view-review .budget-card .card-path { grid-area: path; margin-top: 0; }
.view-review .budget-card .card-amount { grid-area: amount; text-align: right; white-space: nowrap; }
.view-review .budget-card .card-foot { grid-area: foot; }

.shelf {
  margin-bottom: 26px;
}

.shelf-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 0 4px 10px;
  border-bottom: 2px solid var(--navy);
  margin-bottom: 14px;
}

.shelf-head h3 {
  font-size: 1.05rem;
  color: var(--navy);
}

.shelf-head span {
  font-size: 0.88rem;
  color: var(--muted);
  white-space: nowrap;
}

.shelf-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.skeleton-card {
  height: 190px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: linear-gradient(100deg, #fff 30%, var(--azure-pale) 50%, #fff 70%);
  background-size: 220% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  from { background-position: 120% 0; }
  to { background-position: -20% 0; }
}

.status-state {
  padding: 48px 24px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--white);
  color: var(--muted);
}

.status-state h3 {
  color: var(--navy);
  margin-bottom: 8px;
}

.status-state button {
  margin-top: 14px;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-top: 26px;
}

.pagination button {
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--navy);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

.pagination button:hover:not(:disabled) {
  background: var(--azure-soft);
  border-color: var(--azure);
}

.pagination button[aria-current="page"] {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--white);
  font-weight: 600;
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: default;
}

.pagination .page-ellipsis {
  color: var(--muted);
  padding: 0 4px;
}

/* ------------------------------------------------------------------ drawer */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 190;
  background: rgba(6, 24, 56, 0.5);
  backdrop-filter: blur(2px);
}

.drawer-backdrop[hidden] {
  display: none;
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  width: min(760px, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--white);
  box-shadow: var(--shadow-lg);
  transform: translateX(0);
}

.detail-drawer[hidden] {
  display: none;
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--navy);
  color: var(--white);
  flex: 0 0 auto;
}

.drawer-head h2 {
  font-size: 0.95rem;
  font-weight: 500;
  margin-right: auto;
}

.drawer-nav-button,
.drawer-close {
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
  cursor: pointer;
}

.drawer-nav-button:hover:not(:disabled),
.drawer-close:hover {
  background: var(--white);
  color: var(--navy);
}

.drawer-nav-button:disabled {
  opacity: 0.4;
  cursor: default;
}

.drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 24px 40px;
}

.drawer-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.4;
  margin-bottom: 10px;
}

.drawer-amount {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.02em;
}

.drawer-amount small {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--muted);
  margin-left: 6px;
}

.drawer-section {
  margin-top: 26px;
}

.drawer-section > h3 {
  font-size: 0.84rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--azure-ink);
  margin-bottom: 10px;
}

.hierarchy-path {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 0.92rem;
}

.hierarchy-path span {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--azure-soft);
  color: var(--navy);
}

.hierarchy-path i {
  color: var(--muted);
  font-style: normal;
}

.drawer-description {
  font-size: 0.98rem;
  line-height: 1.75;
  color: var(--ink);
  white-space: pre-line;
}

.drawer-description + .clause-list {
  margin-top: 12px;
}

.clause-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.clause-list li {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--azure-pale);
  border: 1px solid var(--line);
}

.clause-no {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--navy);
  color: var(--white);
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.clause-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
}

.clause-body p {
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.6;
  color: var(--ink);
  flex: 1 1 260px;
}

.clause-amount {
  flex: 0 0 auto;
  white-space: nowrap;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.definition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 0;
}

.definition-grid div {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--azure-pale);
  border: 1px solid var(--line);
}

.definition-grid dt {
  font-size: 0.8rem;
  color: var(--muted);
}

.definition-grid dd {
  margin: 2px 0 0;
  font-weight: 500;
  color: var(--navy);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.history-table th,
.history-table td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.history-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.history-table th {
  color: var(--muted);
  font-weight: 500;
  background: var(--azure-pale);
}

.history-table tr:last-child td {
  border-bottom: 0;
}

.delta {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.delta.up { color: var(--danger); }
.delta.down { color: var(--success); }

.reference-list,
.funding-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.funding-list li {
  display: flex;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--azure-pale);
  border: 1px solid var(--line);
  font-size: 0.92rem;
}

.funding-list li b {
  margin-left: auto;
  white-space: nowrap;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.reference-list .reference-search {
  display: grid;
  gap: 4px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  font-size: 0.9rem;
  color: inherit;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.badge-zero {
  color: #754900;
  background: #fff4d6;
  border-color: #efc96d;
}

.card-zero-history {
  display: block;
  margin-top: -4px;
  color: var(--muted);
  font-size: .84rem;
}

/* Citizen-facing item reading panel */
.drawer-item-hero { padding: 24px; border-radius: 22px; background: linear-gradient(125deg, #eaf3ff, #f7fbff); border: 1px solid #d9e7f8; margin-bottom: 26px; }
.drawer-hero-kicker { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: .8rem; margin-bottom: 16px; }
.drawer-item-hero .drawer-title { font-size: clamp(1.25rem, 2.4vw, 1.65rem); overflow-wrap: anywhere; }
.drawer-item-hero .drawer-amount { font-size: clamp(2rem, 4vw, 2.8rem); line-height: 1.3; margin: 12px 0; overflow-wrap: anywhere; }
.drawer-agency { font-size: .86rem; color: var(--navy); }
.drawer-agency small { display: block; color: var(--muted); margin-top: 3px; }
#drawer-hero-change { display: inline-block; margin-top: 16px; padding: 7px 12px; border-radius: 10px; background: white; color: var(--azure-ink); font-size: .85rem; }
.drawer-classification { border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-top: 22px; }
.drawer-classification > summary, .history-table-details > summary { cursor: pointer; color: var(--navy); font-weight: 600; padding: 4px 0; }
.drawer-classification[open] > summary { margin-bottom: 16px; }
.explanation-tools { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin: 16px 0; }
.explanation-modes { display: flex; background: #edf3fb; border-radius: 12px; padding: 4px; }
.explanation button { font: inherit; cursor: pointer; }
.explanation-modes button { border: 0; border-radius: 9px; padding: 9px 12px; background: transparent; color: var(--navy); font-size: .82rem !important; min-height: 42px; }
.explanation-modes button[aria-pressed=true] { background: #fff; box-shadow: 0 2px 6px #11335918; font-weight: 600; }
.explanation button:focus-visible, .drawer-classification summary:focus-visible, .history-table-details summary:focus-visible { outline: 3px solid var(--azure); outline-offset: 3px; }
.reading-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.95; }
.reading-text.is-clamped { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.reading-label { font-size: .76rem; color: var(--muted); margin-bottom: 8px; }
.reading-paragraph { margin-bottom: 12px; }
.clause-controls { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); margin-bottom: 10px; }
.reading-clause { margin-bottom: 10px; border: 1px solid #dae5f3; border-radius: 14px; background: #f8fbff; overflow: hidden; }
.reading-clause-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 0; }
.reading-clause-number { color: var(--azure-ink); font-size: .8rem; font-weight: 600; padding: 4px 7px; border-radius: 7px; background: #e3efff; }
.reading-clause-amount { font-size: .85rem; font-weight: 600; color: var(--navy); }
.reading-clause > p { padding: 0 16px 16px; margin-bottom: 0; }
.budget-history-chart { display: grid; gap: 16px; margin: 20px 0; }
.budget-history-row > div:first-child { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; font-size: .83rem; margin-bottom: 6px; }
.budget-history-track { height: 10px; background: #edf2f9; border-radius: 10px; overflow: hidden; }
.budget-history-track span { display: block; height: 100%; background: #788ba7; border-radius: inherit; }
.budget-history-row.is-estimate .budget-history-track span { background: #2473d4; }
.history-comparison { color: var(--navy); font-weight: 600; }
.history-comparison small { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; margin-top: 4px; }
.history-table-details { margin-top: 14px; }
.drawer-local-note { flex-basis: 100%; text-align: center; font-size: .7rem; color: var(--muted); margin: 0; }
.drawer-actions { padding-bottom: max(12px, env(safe-area-inset-bottom)) !important; }
.drawer-actions .pill-button { min-height: 42px; font-size: .78rem; }
@media (max-width: 540px) {
  .drawer-item-hero { padding: 18px; }
  .drawer-actions { gap: 6px; padding-left: 12px; padding-right: 12px; }
  .drawer-actions .pill-button { flex: 1 1 40%; padding: 8px; }
  #drawer-share { flex-basis: 100%; }
  .drawer-head { padding: 10px 14px; }
}

.reference-list .reference-search:hover {
  border-color: var(--azure-ink);
  background: var(--azure-pale);
}

.reference-list .reference-search:focus-visible {
  outline: 3px solid var(--azure-ink);
  outline-offset: 3px;
}

.reference-search-hint {
  color: var(--azure-ink);
  font-size: 0.78rem;
  margin-top: 4px;
}

.reference-list .ref-type {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--azure-ink);
}

.source-text {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: #f4f6fa;
  border: 1px solid var(--line);
  font-size: 0.88rem;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.drawer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.drawer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  background: var(--white);
  flex: 0 0 auto;
}

.drawer-actions .pill-button {
  flex: 1 1 auto;
  justify-content: center;
}

.drawer-actions .pill-button[aria-pressed="true"] {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--white);
}

.empty-note {
  font-size: 0.92rem;
  color: var(--muted);
  font-style: italic;
}

/* ------------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 220;
  padding: 12px 22px;
  border-radius: 999px;
  background: var(--navy-deep);
  color: var(--white);
  font-size: 0.92rem;
  box-shadow: var(--shadow-lg);
}

.toast[hidden] {
  display: none;
}

/* ------------------------------------------------------------- breakpoints */

@media (max-width: 1180px) {
  .catalog-layout {
    grid-template-columns: 262px 1fr;
  }
}

@media (max-width: 960px) {
  .catalog-layout {
    grid-template-columns: 1fr;
  }

  .mobile-toolbar {
    display: block;
  }

  .filter-panel {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 200;
    width: 400px;
    max-width: 100%;
    max-height: none;
    border-radius: 0;
    padding: 20px 20px 40px;
    overscroll-behavior: contain;
  }

  .filter-panel[hidden] {
    display: none;
  }

  .filter-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: transparent;
    color: var(--white);
    font-size: 1.3rem;
    cursor: pointer;
  }

  .results-actions {
    margin-left: 0;
    width: 100%;
  }
}

@media (max-width: 760px) {
  .view-review .budget-card {
    grid-template-columns: 1fr;
    grid-template-areas: "badges" "title" "amount" "path" "foot";
  }

  .view-review .budget-card .card-amount {
    text-align: left;
  }

  .budget-grid.view-cards,
  .shelf-body {
    grid-template-columns: 1fr;
  }

  .detail-drawer {
    width: min(760px, 100vw);
  }

  .drawer-body {
    padding: 20px 18px 32px;
  }
}

@media (max-width: 540px) {
  .catalog-hero {
    padding: 20px 0 24px;
  }

  .results-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .view-switch {
    justify-content: space-between;
  }

  .view-switch button {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-card {
    animation: none;
  }
}
.pill-button[hidden] {
  display: none;
}
