/* Title font bundled locally; see fonts/wanted-sans/OFL.txt. */
@font-face {
  font-family: "Wanted Sans Brand";
  src: url("/fonts/wanted-sans/WantedSans-Brand.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #eef2f4;
  --panel: #ffffff;
  --panel-soft: #f7f9fb;
  --panel-tint: #f1f6f7;
  --line: #d8e0e5;
  --line-strong: #aebdc8;
  --text: #17212b;
  --muted: #607080;
  --blue: #315e8c;
  --blue-dark: #254b73;
  --teal: #28736f;
  --teal-dark: #205d59;
  --red: #c93b4a;
  --amber: #a26312;
  --green: #28736f;
  --shadow: 0 14px 32px rgba(24, 33, 47, 0.1);
  --shadow-soft: 0 8px 18px rgba(24, 33, 47, 0.06);
  --radius: 8px;
  --radius-sm: 6px;

  /* Navy and blue wordmark palette. */
  --brand-primary: #172b4d;
  --brand-accent: #2563eb;
  --brand-highlight: #bfdbfe;
  --font-brand: "Wanted Sans Brand", "Pretendard", "Noto Sans KR", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #f8fafb 0, var(--bg) 260px),
    var(--bg);
  color: var(--text);
  font-family: Inter, "Pretendard", "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}

.app-header {
  min-height: 60px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 520px) minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 0 22px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid rgba(174, 189, 200, 0.54);
  box-shadow: 0 8px 24px rgba(23, 33, 43, 0.06);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  appearance: none;
  border: 0;
  padding: 0;
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  cursor: pointer;
  justify-self: start;
}

.brand-copy {
  min-width: 0;
  display: block;
}

.header-search-wrap {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  justify-self: center;
}

.header-balance {
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.brand:hover .brand-title,
.brand:focus-visible .brand-title {
  color: #102a43;
}

.brand:focus-visible {
  outline: 3px solid rgba(78, 121, 167, 0.24);
  outline-offset: 4px;
  border-radius: 12px;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  padding: 0;
  border: 0;
  font-family: var(--font-brand);
  font-size: 32px;
  line-height: 1.2;
  letter-spacing: -1px;
  font-weight: 800;
  white-space: nowrap;
}

.brand-title__primary {
  color: var(--brand-primary);
}

.brand-title__accent-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  overflow: visible;
}

.brand-title__accent {
  position: relative;
  z-index: 1;
  color: var(--brand-accent);
}

.brand-title__highlight {
  position: absolute;
  left: 1px;
  right: 14px;
  bottom: -3px;
  height: 4px;
  border-radius: 999px;
  background: var(--brand-highlight);
  opacity: 0.85;
}

.brand-powered {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(11, 58, 83, 0.18);
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #edf5f7);
  color: #516b80;
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
  letter-spacing: -0.01em;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(24, 33, 47, 0.06);
}

.brand small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border: 1px solid #dce5ea;
  border-radius: var(--radius);
  background: linear-gradient(145deg, #fff, #eef5f4);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: 0 0 auto;
  box-shadow: var(--shadow-soft);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.global-search {
  height: 40px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 8px 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  min-width: 0;
  width: 100%;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 8px 18px rgba(24, 33, 47, 0.05);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.global-search:focus-within {
  border-color: rgba(78, 121, 167, 0.56);
  box-shadow: 0 0 0 3px rgba(78, 121, 167, 0.12), 0 8px 18px rgba(24, 33, 47, 0.05);
}

.search-button {
  height: 30px;
  min-width: 46px;
  border: 1px solid var(--blue);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #4e79a7, var(--blue));
  color: #fff;
  padding: 0 9px;
  cursor: pointer;
  font-weight: 750;
  font-size: 12px;
  flex: 0 0 auto;
  line-height: 1;
  white-space: nowrap;
}

.search-button:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
  color: #fff;
}

.global-search svg,
.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.global-search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

select,
.icon-button,
.action-button {
  min-height: 38px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 0 11px;
  border-radius: var(--radius-sm);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, color 0.16s ease;
}

select {
  min-width: 132px;
  background-color: #fff;
  cursor: pointer;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  font-weight: 750;
}

.icon-button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

button:hover,
select:hover,
.action-button:hover {
  border-color: var(--line-strong);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(78, 121, 167, 0.18);
  outline-offset: 2px;
}

.dashboard-shell {
  height: calc(100vh - 60px);
  display: grid;
  grid-template-columns: 244px 280px minmax(560px, 1fr) 260px;
  overflow: hidden;
  gap: 0;
}

body.filters-hidden .dashboard-shell {
  grid-template-columns: 280px minmax(560px, 1fr) 260px;
}

body.filters-hidden .sidebar {
  display: none;
}

.sidebar,
.business-panel,
.main-panel,
.detail-panel {
  min-height: 0;
  border-right: 1px solid rgba(216, 224, 229, 0.86);
  background: var(--panel);
}

.sidebar {
  display: flex;
  flex-direction: column;
}

.filter-block {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.filter-selection-block {
  min-height: 56px;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(180deg, #fff, #fbfcfd);
}

.filter-selection-block > label {
  min-width: 0;
  margin: 0;
  gap: 4px;
  font-size: 11px;
}

.filter-selection-block select {
  min-width: 0;
  min-height: 34px;
  padding: 5px 6px;
  font-size: 12px;
}

.filter-block.grow {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 12px 12px 14px;
}

.filter-block.grow .section-title {
  margin-bottom: 8px;
}

.section-title,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.section-title span,
.panel-heading strong {
  font-weight: 850;
}

.section-title small,
.panel-heading span {
  color: var(--muted);
  font-size: 12px;
}

.section-title button {
  border: 0;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  font-weight: 750;
}

.sidebar-refresh-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--blue);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.sidebar-refresh-button:hover {
  background: #f0f5fa;
  border-color: #bbcedf;
}

.sidebar-refresh-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  margin-left: -5px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ministry-filter,
label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ministry-filter {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

label + label {
  margin-top: 13px;
}

.ministry-filter select,
label select {
  width: 100%;
  color: var(--text);
}

.filter-search-button,
.filter-reset-button {
  min-width: 56px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-weight: 800;
  cursor: pointer;
}

.filter-search-button {
  border: 1px solid var(--blue);
  background: linear-gradient(180deg, #4e79a7, var(--blue));
  color: #fff;
  box-shadow: 0 8px 18px rgba(78, 121, 167, 0.18);
}

.filter-search-button:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.filter-reset-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.filter-reset-button:hover {
  border-color: var(--line-strong);
  background: #f8fbfd;
}

.tree-list {
  display: grid;
  gap: 1px;
}

.tree-button,
.business-item {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.tree-button {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.tree-button span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-button span:last-child {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.tree-all-button {
  margin-bottom: 4px;
  background: #f3f7fa;
  border-color: #c8d8e5;
  font-weight: 800;
}

.tree-all-button span:last-child {
  color: var(--blue);
  font-weight: 800;
}

.tree-button.active,
.tree-button:hover {
  background: #eaf1f7;
  border-color: #bbcedf;
}

.tree-button.active {
  font-weight: 750;
  box-shadow: inset 3px 0 0 var(--blue);
}

.tree-all-button.active,
.tree-all-button:hover {
  background: #e3edf5;
  border-color: #7d9fbd;
  box-shadow: inset 3px 0 0 var(--blue);
}

.data-status {
  padding: 8px 16px 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  background: var(--panel-tint);
  border-top: 1px solid var(--line);
}

.data-status div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.78);
  padding: 5px 10px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.78);
}

.data-status span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.data-status strong {
  font-size: 15px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.business-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.panel-heading {
  min-height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  margin: 0;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #fbfcfd);
}

.panel-heading div {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.panel-heading span {
  white-space: nowrap;
}

.panel-sort {
  min-width: 98px;
  min-height: 32px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 750;
}

.business-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 10px;
  background: var(--panel);
}

.load-more-button {
  flex: 0 0 auto;
  min-height: 44px;
  margin: 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: #f5f8fb;
  color: var(--blue);
  font-weight: 800;
  cursor: pointer;
}

.load-more-button:hover {
  background: #edf3f8;
}

.load-more-button:disabled {
  color: var(--muted);
  cursor: wait;
}

.business-list.home-hero-empty {
  display: flex;
  align-items: stretch;
  padding: 0 0 24px;
  overflow: hidden;
}

.empty-list {
  min-height: 160px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}

.business-item {
  display: grid;
  gap: 5px;
  padding: 10px;
  border-color: var(--line);
  background: var(--panel);
  margin-bottom: 6px;
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.72), 0 8px 16px rgba(24, 33, 47, 0.04);
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.business-item:hover,
.business-item.active {
  border-color: #8aa8c3;
  box-shadow: 0 0 0 2px rgba(78, 121, 167, 0.08), 0 10px 20px rgba(24, 33, 47, 0.08);
}

.business-item.active {
  background: linear-gradient(180deg, #f7fafc, #eaf1f7);
  box-shadow: inset 3px 0 0 var(--blue), 0 0 0 2px rgba(78, 121, 167, 0.08), 0 10px 20px rgba(24, 33, 47, 0.08);
}

.business-item:hover {
  transform: translateY(-1px);
}

.business-hero-card {
  width: 100%;
  height: 100%;
  min-height: 100%;
  display: flex;
  align-items: stretch;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 22px 48px rgba(24, 33, 47, 0.12);
  border: 1px solid rgba(216, 224, 229, 0.9);
}

.business-hero-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  background: transparent;
  transform: scale(1.01);
  transform-origin: center top;
}

.business-item strong {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: anywhere;
  font-weight: 750;
  line-height: 1.35;
}

.business-item .meta,
.business-item .codes {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 19px;
  padding: 0 6px;
  background: #eef2f6;
  color: #3d4d60;
  border: 1px solid #dce3ec;
  border-radius: 999px;
  font-size: 12px;
  max-width: 100%;
  font-weight: 700;
}

.pill.blue {
  background: #edf3f8;
  color: #315e8c;
  border-color: #c8d8e5;
}

.pill.green {
  background: #edf6f4;
  color: var(--green);
  border-color: #cce2dd;
}

.main-panel {
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.36), rgba(255, 255, 255, 0) 190px),
    var(--bg);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 0 24px;
  min-width: 0;
}

body.home-view .main-panel {
  container: home-summary / inline-size;
}

body.home-view .detail-panel {
  display: none;
}

.content-head {
  min-height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0;
  padding: 6px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #f7fafb);
}

.content-head-main {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 2px;
  flex: 1;
}

.content-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-head h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: 0;
  font-weight: 850;
  min-width: 0;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

body.home-view .title-row {
  flex-wrap: wrap;
  column-gap: 10px;
  row-gap: 4px;
}

.budget-proposal-notice {
  max-width: 100%;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

body:not(.home-view) .budget-proposal-notice {
  display: none;
}

.expand-toggle {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex: 0 0 auto;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(24, 33, 47, 0.05);
}

.expand-toggle:hover {
  border-color: #8aa8c3;
  color: var(--blue);
  background: #f7fbff;
}

.center-budget-summary,
.document-view {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 100%;
  min-width: 0;
}

.center-budget-summary {
  padding: 16px;
  margin: 14px 14px 0;
  margin-bottom: 14px;
}

.center-budget-summary .section-title span {
  font-size: 17px;
}

#centerBudgetSummaryBody,
.budget-bundle-block {
  min-width: 0;
}

.center-budget-summary .table-scroll {
  margin: 0;
}

.center-budget-summary .ministry-summary-layout {
  padding: 0;
}

.center-budget-summary {
  --summary-balance-height: 320px;
  --summary-card-padding-y: 10px;
  --summary-card-padding-x: 12px;
  --summary-title-size: 15px;
  --summary-cell-font-size: 14px;
}

.ministry-summary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(280px, 0.98fr);
  gap: 18px;
  align-items: stretch;
}

.ministry-summary-grid > * {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.center-budget-summary .data-table {
  min-width: 780px;
  width: 100%;
  font-size: 14px;
}

.center-budget-summary .summary-snapshot-table-wrap {
  display: flex;
  align-items: stretch;
  height: var(--summary-balance-height);
  max-height: var(--summary-balance-height);
  overflow: auto;
  border-radius: 10px;
}

.center-budget-summary .summary-snapshot-table-wrap .data-table {
  min-width: 100%;
  width: 100%;
  height: 100%;
  font-size: var(--summary-cell-font-size);
}

.center-budget-summary .ministry-summary-table th:first-child,
.center-budget-summary .ministry-summary-table td:first-child {
  text-align: center;
}

.center-budget-summary .summary-name-col {
  width: 22%;
}

.center-budget-summary .summary-year-col {
  width: 10%;
}

.center-budget-summary .summary-budget-col {
  width: 12%;
}

.center-budget-summary .summary-change-col,
.center-budget-summary .summary-rate-col {
  width: 10%;
}

.center-budget-summary .budget-bundle-block:not(.functional-block) .data-table {
  table-layout: fixed;
}

.center-budget-summary .budget-bundle-block:not(.functional-block) .data-table tr:nth-child(2) td {
  white-space: normal;
  line-height: 1.2;
  text-align: center;
}

.center-budget-summary .budget-bundle-block:not(.functional-block) .data-table tr:nth-child(n + 3) td:not(:first-child) {
  white-space: nowrap;
}

.center-budget-summary .data-table th,
.center-budget-summary .data-table td,
.budget-summary .data-table th,
.budget-summary .data-table td {
  padding: var(--summary-card-padding-y) var(--summary-card-padding-x);
  font-size: var(--summary-cell-font-size);
}

.center-budget-summary .data-table th:first-child,
.center-budget-summary .data-table td:first-child,
.budget-summary .data-table th:first-child,
.budget-summary .data-table td:first-child {
  min-width: 150px;
  max-width: 200px;
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.center-budget-summary {
  display: grid;
  gap: 18px;
}

.budget-bundle-block {
  border: 0;
  background: transparent;
  padding: 0;
}

.budget-bundle-block + .budget-bundle-block {
  margin-top: 28px;
}

.bundle-title {
  font-weight: 800;
  font-size: var(--summary-title-size);
  line-height: 1.25;
  margin: 0 0 12px;
  text-align: center;
  color: #243241;
}

.functional-block .bundle-title {
  margin-top: 2px;
  text-align: left;
}

.functional-block .data-table {
  table-layout: auto;
  width: 100%;
  max-width: none;
  min-width: 0;
  font-size: 14px;
}

.functional-block .data-table th {
  white-space: normal;
  line-height: 1.18;
}

.functional-block .data-table tr:first-child th {
  font-size: 14px;
  padding-top: 7px;
  padding-bottom: 7px;
}

.functional-block .data-table tr:nth-child(2) td {
  font-size: 13px;
  line-height: 1.15;
  padding: 5px 4px;
  white-space: normal;
  text-align: center;
}

.functional-block .data-table tr:nth-child(n + 3) td {
  white-space: nowrap;
  text-align: right;
  padding-left: 5px;
  padding-right: 5px;
}

.functional-block .data-table th:first-child,
.functional-block .data-table td:first-child {
  min-width: 100px;
  max-width: 220px;
  white-space: normal;
  text-align: left;
  overflow-wrap: anywhere;
}

.doc-section-label {
  font-weight: 800;
  color: var(--muted);
}


.document-view {
  margin: 0 14px;
  padding: 22px;
  overflow: visible;
}

.document-view.empty-state {
  min-height: 260px;
  color: var(--muted);
  background:
    linear-gradient(135deg, rgba(78, 121, 167, 0.05), rgba(8, 127, 131, 0.05)),
    #fff;
}

.document-view.compact-empty-state {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  overflow: hidden;
}

.document-hero {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.document-hero img {
  display: block;
  width: 100%;
  max-width: none;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  border-radius: 18px;
  box-shadow: 0 22px 48px rgba(24, 33, 47, 0.12);
  border: 1px solid rgba(216, 224, 229, 0.9);
}

.document-empty-message {
  width: fit-content;
  max-width: min(100%, 460px);
  margin: 56px auto;
  padding: 16px 20px;
  border: 1px solid #d7e3ef;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 24px rgba(24, 33, 47, 0.08);
  color: var(--muted);
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}

.document-view h2,
.document-view h3,
.document-view h4 {
  color: var(--text);
  letter-spacing: 0;
}

.document-view h2 {
  margin: 24px 0 12px;
  font-size: 21px;
  font-weight: 850;
}

.document-view h3 {
  margin: 22px 0 12px;
  font-size: 18px;
  font-weight: 830;
}

.document-view h4 {
  margin: 18px 0 9px;
  font-size: 15px;
  font-weight: 820;
}

.document-view h2:first-child,
.document-view h3:first-child {
  margin-top: 0;
}

.doc-line {
  margin: 8px 0;
  line-height: 1.68;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.doc-bullet {
  padding-left: 14px;
  text-indent: -12px;
}

.doc-collapse {
  margin: 14px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  overflow: hidden;
}

.doc-collapse-single {
  margin-top: 18px;
}

.doc-collapse summary {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 15px;
  cursor: pointer;
  font-size: 17px;
  font-weight: 800;
  list-style: none;
  background: linear-gradient(180deg, #fff, #f7fafb);
}

.doc-collapse summary::-webkit-details-marker {
  display: none;
}

.doc-collapse summary::after {
  content: "+";
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  color: var(--blue);
  background: var(--panel);
  border-radius: var(--radius-sm);
  font-weight: 800;
  flex: 0 0 auto;
}

.doc-collapse[open] summary::after {
  content: "-";
}

.doc-collapse-body {
  padding: 2px 15px 15px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.table-scroll {
  width: 100%;
  overflow: auto;
  margin: 12px 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}

.data-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  font-size: 13px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

.data-table th,
.data-table td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  vertical-align: middle;
  word-break: keep-all;
  overflow-wrap: normal;
}

.data-table th,
.data-table td {
  text-align: right;
  white-space: nowrap;
}

.data-table th:first-child,
.data-table td:first-child {
  text-align: left;
  white-space: normal;
  min-width: 170px;
  max-width: 220px;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.data-table th {
  background: #edf3f6;
  font-weight: 750;
  text-align: center;
  color: #263646;
}

.data-table td:first-child {
  text-align: left;
}

.data-table th[colspan],
.data-table th[rowspan] {
  text-align: center;
}

.data-table tr:nth-child(even) td {
  background: #fbfcfd;
}

.data-table tr:hover td {
  background: #f4f9fb;
}

/* The numbered 2027 forms retain their own document and table layout. */
.document-view.document-view-2027 {
  margin-top: 6px;
  padding: 8px 16px 16px;
}

.budget-document-2027 {
  min-width: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.budget-document-2027 .form-section {
  margin: 8px 0;
  border-radius: 12px;
}

.budget-document-2027 > .form-section:first-child {
  margin-top: 0;
}

.budget-document-2027 .form-section > summary {
  padding: 8px 12px;
  color: #1b456c;
  font-size: 16px;
  line-height: 1.6;
}

.budget-document-2027 .form-section > .doc-collapse-body {
  padding: 8px 12px;
}

.budget-document-2027 .doc-collapse-body > :first-child {
  margin-top: 0;
}

.budget-document-2027 .doc-collapse-body > :last-child {
  margin-bottom: 0;
}

.budget-document-2027 .doc-line {
  margin: 4px 0;
  line-height: 1.55;
}

.budget-document-2027 h3 {
  margin: 18px 0 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
  line-height: 1.55;
}

.budget-document-2027 h4 {
  margin: 12px 0 6px;
  color: #34546c;
  font-size: 14px;
  line-height: 1.55;
}

.budget-document-2027 .form-list {
  margin: 6px 0;
  padding-left: 22px;
}

.budget-document-2027 .form-list li + li {
  margin-top: 3px;
}

.budget-document-2027 .form-note,
.budget-document-2027 .form-unit {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.budget-document-2027 .form-unit {
  margin: 0 0 4px;
  text-align: right;
}

.budget-document-2027 .form-table {
  margin: 6px 0 10px;
}

.budget-document-2027 .form-unit + .form-table {
  margin-top: 0;
}

.budget-document-2027 .data-table {
  width: 100%;
  min-width: 100%;
  table-layout: auto;
  font-size: 13px;
  line-height: 1.5;
}

.budget-document-2027 .data-table th,
.budget-document-2027 .data-table td {
  min-width: 0;
  max-width: none;
  padding: 6px 10px;
  text-align: left;
  white-space: normal;
  word-break: normal;
  overflow-wrap: anywhere;
}

.budget-document-2027 .data-table thead th {
  text-align: center;
  vertical-align: middle;
}

.budget-document-2027 .data-table td {
  vertical-align: top;
}

.budget-document-2027 .form-table-key-value > .data-table {
  table-layout: fixed;
}

.budget-document-2027 .form-table-key-value > .data-table th[scope="row"] {
  width: 110px;
  color: #34546c;
  vertical-align: top;
}

.budget-document-2027 .form-table-wide > .data-table {
  min-width: var(--form-table-width);
}

.budget-document-2027 .form-table-wide > .data-table th:first-child,
.budget-document-2027 .form-table-wide > .data-table td:first-child {
  min-width: 150px;
  max-width: 260px;
}

.budget-document-2027 .data-table td.form-number {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.budget-document-2027 .data-table .data-table {
  min-width: 540px;
}

.budget-document-2027 code {
  padding: 2px 4px;
  border-radius: 4px;
  background: #f0f4f7;
  font-size: 0.92em;
}

.budget-document-2027 pre {
  overflow-x: auto;
  padding: 12px;
  background: #f0f4f7;
  border-radius: 8px;
}

@media (max-width: 640px) {
  .budget-document-2027 .form-section > .doc-collapse-body {
    padding: 8px 10px;
  }

  .budget-document-2027 .form-table-key-value > .data-table th[scope="row"] {
    width: 76px;
  }
}

.detail-panel {
  display: flex;
  flex-direction: column;
  border-right: 0;
  min-width: 0;
  background: #fbfcfd;
}

.detail-top {
  min-height: 56px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 6px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #f7fafb);
}

.detail-top span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-top strong {
  display: block;
  margin-top: 4px;
  font-size: 17px;
  line-height: 1.25;
  font-weight: 850;
}

.detail-list {
  margin: 0;
  padding: 10px 14px 12px;
  display: grid;
  gap: 6px;
  overflow: auto;
  min-height: 0;
}

.detail-extra {
  padding: 0 14px 14px;
}

.detail-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 6px 0;
  border-bottom: 1px solid rgba(216, 224, 229, 0.72);
}

.detail-row dt {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.detail-row dd {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.38;
  word-break: keep-all;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.detail-row-empty dd {
  min-height: 1.15em;
}

.detail-basic-group > dt {
  padding: 8px 10px;
  border-radius: 6px;
  background: #edf3f6;
  color: #34546c;
  font-size: 12px;
  font-weight: 800;
}

.detail-basic-group > dd,
.detail-basic-group > dd > dl {
  margin: 0;
}

.detail-basic-group + .detail-basic-group {
  margin-top: 12px;
}

.detail-basic-group .detail-row {
  grid-template-columns: 76px minmax(0, 1fr);
  padding: 10px 0;
}

.detail-basic-group .detail-row dd {
  line-height: 1.6;
}

.detail-row:last-child {
  border-bottom: 0;
}

.detail-row-rich {
  grid-template-columns: 1fr;
  gap: 10px;
  padding-top: 10px;
  padding-bottom: 12px;
}

.detail-row-rich dt {
  font-size: 12px;
}

.detail-row-rich dd {
  margin-top: 2px;
}

.budget-summary {
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  min-height: 190px;
  max-height: 330px;
  overflow: auto;
}

.budget-summary > strong {
  display: block;
  margin-bottom: 8px;
}

.budget-summary .table-scroll {
  margin: 0;
}

.budget-summary .data-table {
  min-width: 700px;
  width: 100%;
  font-size: 14px;
}

.budget-summary .data-table th,
.budget-summary .data-table td {
  text-align: right;
}

.budget-summary .data-table th:first-child,
.budget-summary .data-table td:first-child {
  text-align: left;
}

.budget-summary .data-table th {
  text-align: center;
}

.summary-chart-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(238, 245, 248, 0.98)),
    #fff;
  box-shadow: 0 14px 28px rgba(24, 33, 47, 0.08);
  padding: 16px 18px;
  min-height: var(--summary-balance-height);
  width: 100%;
  box-sizing: border-box;
}

.home-stack-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}

.home-stack-table-wrap {
  height: var(--summary-balance-height);
  max-height: var(--summary-balance-height);
  overflow: auto;
  border-radius: 10px;
}

.home-stack-table {
  min-width: 100%;
  table-layout: fixed;
}

.home-stack-table th,
.home-stack-table td {
  text-align: center;
  vertical-align: middle;
}

.home-stack-table th:first-child {
  width: 100px;
  text-align: left;
}

.center-budget-summary .home-stack-table th,
.center-budget-summary .home-stack-table td {
  padding-left: 6px;
  padding-right: 6px;
}

.home-stack-key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.home-stack-key .chart-swatch {
  margin-right: 0;
  flex-shrink: 0;
}

.home-stack-label-spread {
  display: inline-flex;
  justify-content: space-between;
  width: 3.65em;
  white-space: nowrap;
  vertical-align: middle;
}

.home-stack-chart-card {
  display: grid;
  align-items: stretch;
}

.home-stack-chart {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(var(--home-year-count, 5), minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
}

.home-stack-group {
  gap: 12px;
}

.home-stack-group .summary-bar-label {
  min-height: 32px;
  line-height: 16px;
  text-align: center;
}

.ministry-budget-scope-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-left: 3px solid #76b7b2;
  border-radius: 0 6px 6px 0;
  background: var(--panel-soft);
  color: #465e73;
  font-size: 12px;
  line-height: 1.7;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.home-stack-note,
.home-field-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.home-stack-note a {
  color: var(--blue);
  text-decoration: underline;
}

.home-stack-track {
  max-width: 56px;
  margin: 0 auto;
  padding: 5px;
}

.home-stack-bar {
  width: 100%;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  flex-direction: column-reverse;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.home-stack-segment {
  width: 100%;
  min-height: 3px;
  background: var(--segment-end, #2d76cf);
  box-shadow: 0 4px 8px var(--segment-shadow, rgba(78, 121, 167, 0.16));
}

.home-stack-bar-incomplete {
  background: repeating-linear-gradient(135deg, #e1e8ed 0 4px, #f7fafc 4px 8px);
}

.home-field-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}

.home-field-bar-card,
.home-field-donut-card {
  min-height: var(--summary-balance-height);
}

.home-field-bar-card {
  display: flex;
  align-items: stretch;
}

.home-field-bars {
  width: 100%;
  display: grid;
  gap: 15px;
  align-content: space-evenly;
}

.home-field-bar-row {
  display: grid;
  grid-template-columns: minmax(126px, 0.82fr) minmax(120px, 1.18fr) minmax(78px, auto);
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.home-field-bar-label {
  display: flex;
  align-items: center;
  min-width: 0;
  color: #23384d;
  font-weight: 850;
}

.home-field-bar-label strong {
  min-width: 0;
  font-size: 13px;
  line-height: 1.25;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.home-field-bar-track {
  height: 16px;
  min-width: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #edf3f7, #dfe9ee);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  overflow: hidden;
}

.home-field-bar-fill {
  height: 100%;
  min-width: 5px;
  border-radius: inherit;
  background: var(--bar-color, #2b66cf);
  box-shadow: 0 5px 10px rgba(24, 33, 47, 0.12);
}

.home-field-bar-value {
  display: grid;
  justify-items: end;
  min-width: 0;
  color: #39546e;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.home-field-bar-value strong {
  font-size: 12.5px;
  line-height: 1;
}

.home-field-bar-value span {
  font-size: 11.5px;
  font-weight: 800;
  color: #60768b;
}

.home-field-donut-card {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(150px, 0.82fr);
  align-items: center;
  gap: 14px;
}

.home-field-donut-wrap {
  width: min(100%, 244px);
  aspect-ratio: 1;
  justify-self: center;
}

.home-field-donut-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.home-field-donut-track,
.home-field-donut-segment {
  fill: none;
  stroke-width: 36;
}

.home-field-donut-track {
  stroke: #e3ebf1;
}

.home-field-donut-segment {
  stroke-linecap: butt;
}

.home-field-donut-hole {
  fill: rgba(255, 255, 255, 0.98);
  stroke: rgba(216, 224, 229, 0.72);
}

.home-field-donut-center {
  fill: #1f3951;
  font-weight: 850;
}

.home-field-donut-center tspan:first-child {
  font-size: 22px;
}

.home-field-donut-center tspan:last-child {
  fill: var(--muted);
  font-size: 9.5px;
  font-weight: 800;
}

.home-field-donut-legend {
  list-style: none;
  margin: 0;
  padding: 10px 12px;
  display: grid;
  gap: 0;
  align-self: center;
  border: 1px solid rgba(216, 224, 229, 0.72);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(249, 251, 253, 0.95), rgba(241, 246, 250, 0.92));
  max-height: calc(var(--summary-balance-height) - 28px);
  overflow: auto;
  min-width: 0;
}

.home-field-donut-legend li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 5px 0;
}

.home-field-donut-legend li + li {
  border-top: 1px solid rgba(216, 224, 229, 0.54);
}

.home-field-donut-legend strong,
.home-field-donut-legend span {
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.home-field-donut-legend strong {
  color: #23384d;
  min-width: 0;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.home-field-donut-legend span {
  color: #4d647a;
  font-weight: 850;
  white-space: nowrap;
  text-align: right;
}

.ministry-expense-layout .bundle-title {
  margin-bottom: 12px;
}

.ministry-expense-grid {
  align-items: stretch;
}

.expense-breakdown-table-wrap {
  height: var(--summary-balance-height);
  max-height: var(--summary-balance-height);
  overflow: auto;
  border-radius: 10px;
}

.expense-breakdown-table {
  min-width: 100%;
  table-layout: fixed;
}

.expense-breakdown-table th,
.expense-breakdown-table td {
  vertical-align: middle;
  padding-top: var(--summary-card-padding-y);
  padding-bottom: var(--summary-card-padding-y);
}

.expense-breakdown-table th:first-child {
  text-align: left;
}

.expense-total-row th,
.expense-total-row td {
  font-weight: 850;
  background: rgba(232, 239, 244, 0.72);
}

.chart-swatch {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--swatch, var(--blue));
  display: inline-block;
  margin-right: 8px;
  vertical-align: middle;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.8);
}

.donut-chart-card {
  display: grid;
  grid-template-columns: minmax(210px, 228px) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.donut-chart-wrap {
  position: relative;
  width: min(100%, 238px);
  margin: 0 auto;
  aspect-ratio: 1;
  align-self: center;
  justify-self: center;
}

.donut-chart {
  width: 100%;
  height: 100%;
  display: block;
  transform: rotate(-90deg);
  overflow: visible;
}

.donut-track,
.donut-segment {
  fill: none;
  stroke-width: 26;
}

.donut-track {
  stroke: #e3ebf1;
}

.donut-segment {
  stroke-linecap: butt;
}

.donut-chart-center {
  position: absolute;
  inset: 50%;
  width: 54%;
  height: 54%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: inset 0 0 0 1px rgba(216, 224, 229, 0.72);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 14px;
}

.donut-chart-center strong {
  font-size: 30px;
  line-height: 1;
  color: #1f3951;
}

.donut-chart-center span {
  font-size: 13px;
  line-height: 1.35;
  color: var(--muted);
  font-weight: 700;
}

.donut-legend {
  list-style: none;
  margin: 0;
  padding: 14px 14px;
  display: grid;
  gap: 0;
  align-self: center;
  border: 1px solid rgba(216, 224, 229, 0.72);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(249, 251, 253, 0.95), rgba(241, 246, 250, 0.92));
  max-height: calc(var(--summary-balance-height) - 8px);
  overflow: auto;
  min-width: 0;
  width: 100%;
}

.donut-legend li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  min-height: 42px;
  padding: 6px 0;
  border-radius: 0;
  background: transparent;
}

.donut-legend li + li {
  border-top: 1px solid rgba(216, 224, 229, 0.54);
}

.donut-legend strong,
.donut-legend span {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.donut-legend strong {
  color: #23384d;
  min-width: 0;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.donut-legend span {
  color: #4d647a;
  font-weight: 800;
  white-space: nowrap;
  text-align: right;
  min-width: 0;
}

.expense-budget-chart {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.expense-budget-chart .donut-legend {
  padding: 10px;
}

.expense-budget-chart .donut-legend li {
  min-height: 36px;
}

.expense-budget-chart .donut-legend strong,
.expense-budget-chart .donut-legend span {
  font-size: 11.5px;
}

.expense-budget-chart .donut-chart-center {
  padding: 8px;
}

.expense-budget-chart .donut-chart-center span {
  white-space: nowrap;
  font-size: 12px;
}

.summary-chart-head {
  display: grid;
  gap: 3px;
  margin-bottom: 10px;
}

.summary-chart-head strong {
  font-size: 14px;
  font-weight: 850;
}

.summary-chart-head span,
.summary-chart-foot span {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 800;
}

.summary-chart {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--summary-year-count, 4), minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

.summary-bar-group {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  justify-items: center;
  align-items: stretch;
  min-height: 0;
}

.summary-bar-value,
.summary-bar-label,
.summary-chart-foot strong {
  font-variant-numeric: tabular-nums;
}

.summary-bar-value {
  font-size: 12px;
  color: #35516d;
  font-weight: 800;
  line-height: 1.1;
  min-height: 26px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  text-align: center;
}

.summary-bar-track {
  height: 100%;
  width: 100%;
  max-width: 36px;
  border-radius: 999px;
  display: flex;
  align-items: end;
  padding: 4px;
  background: linear-gradient(180deg, #edf3f7, #dfe9ee);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.summary-bar {
  width: 100%;
  border-radius: 999px;
  background: var(--bar-end, #2d76cf);
  box-shadow: 0 6px 10px var(--bar-shadow, rgba(78, 121, 167, 0.18));
}

.summary-bar-label {
  font-size: 12px;
  color: #2d4257;
  font-weight: 800;
}

.ministry-summary-layout .summary-bar-label {
  min-height: 32px;
  line-height: 16px;
  text-align: center;
}

.summary-chart-foot {
  margin-top: 12px;
  display: grid;
  gap: 6px;
}

.summary-chart-foot div {
  display: grid;
  gap: 2px;
  padding-top: 7px;
  border-top: 1px solid rgba(216, 224, 229, 0.86);
}

.summary-snapshot {
  display: grid;
  gap: 12px;
}

.summary-snapshot-table-wrap {
  margin: 0;
}

.detail-summary-table {
  min-width: 0;
  width: 100%;
  font-size: 12px;
}

.center-budget-summary .detail-summary-table {
  font-size: 14px;
  height: 100%;
}

.center-budget-summary .summary-chart-card {
  height: 100%;
}

.center-budget-summary .detail-summary-table th:first-child,
.center-budget-summary .detail-summary-table td:first-child {
  min-width: 120px;
  max-width: 150px;
  text-align: center;
}

.center-budget-summary .detail-summary-table th,
.center-budget-summary .detail-summary-table td {
  padding: 5px 6px;
  text-align: center;
  vertical-align: middle;
}

.center-budget-summary .summary-agency-name {
  font-weight: 800;
}

.ministry-summary-table {
  min-width: 0;
  width: 100%;
}

.ministry-summary-table th,
.ministry-summary-table td {
  white-space: normal;
}

.ministry-summary-table th:first-child,
.ministry-summary-table td:first-child {
  min-width: 0;
  max-width: none;
}

.detail-actions {
  margin-top: auto;
  padding: 14px 16px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  border-top: 1px solid var(--line);
  background: #f3f7f8;
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-weight: 750;
  min-width: 0;
}

.action-button.strong {
  background: linear-gradient(180deg, #0c8f94, var(--teal));
  border-color: var(--teal);
  color: #fff;
  box-shadow: 0 8px 18px rgba(8, 127, 131, 0.16);
}

.action-button.strong:hover {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
}

.action-button:not(.strong):hover {
  background: #fff;
  color: var(--blue);
}

.hidden {
  display: none !important;
}

.loading {
  opacity: 0.6;
  pointer-events: none;
}

.source-page {
  min-height: 100%;
  overflow: auto;
}

.source-document {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
}

.source-document h1 {
  margin: 12px 0 6px;
  letter-spacing: 0;
}

.source-document > p {
  color: var(--muted);
  margin: 0 0 18px;
}

.source-back {
  color: var(--blue);
  font-weight: 750;
}

@media (max-width: 1440px) {
  .dashboard-shell {
    grid-template-columns: 236px 270px minmax(460px, 1fr) 250px;
  }
}

/* Preserve all four panels while allowing tables to scroll inside the main panel. */
@media (min-width: 1181px) and (max-width: 1245px) {
  .dashboard-shell {
    grid-template-columns: 236px 270px minmax(0, 1fr) 250px;
  }
}

@media (min-width: 1181px) and (max-width: 1440px) {
  body.ministry-summary-view .dashboard-shell {
    grid-template-columns: 236px 270px minmax(640px, 1fr);
  }

  body.ministry-summary-view.filters-hidden .dashboard-shell {
    grid-template-columns: 270px minmax(640px, 1fr);
  }

  body.ministry-summary-view .detail-panel {
    display: none;
  }
}

@media (min-width: 1181px) {
  body.home-view .dashboard-shell {
    grid-template-columns: clamp(236px, 17vw, 244px) clamp(270px, 19vw, 280px) minmax(0, 1fr);
  }

  body.home-view.filters-hidden .dashboard-shell {
    grid-template-columns: clamp(270px, 19vw, 280px) minmax(0, 1fr);
  }
}

/* Stretch the two-row home overview into the available desktop height.
   Keep the original card minimums so short windows scroll instead of clipping. */
@media (min-width: 1181px) {
  @container home-summary (min-width: 901px) {
    body.home-view .center-budget-summary {
      flex: 1 0 auto;
      display: flex;
      flex-direction: column;
    }

    body.home-view #centerBudgetSummaryBody {
      flex: 1;
      display: flex;
      flex-direction: column;
    }

    body.home-view .budget-bundle-block {
      flex: 1;
      display: flex;
      flex-direction: column;
    }

    body.home-view .home-stack-grid,
    body.home-view .home-field-grid {
      flex: 1;
      min-height: 320px;
    }

    body.home-view .home-stack-table-wrap {
      height: 100%;
      max-height: none;
    }

    body.home-view .home-field-donut-wrap {
      width: min(100%, 300px);
    }
  }
}

/* Fit the overview to its panel, including when the sidebar is toggled. */
@container home-summary (max-width: 900px) {
  .home-stack-grid,
  .home-field-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@container home-summary (max-width: 480px) {
  .home-field-donut-card {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
  }

  .home-field-donut-legend {
    width: 100%;
  }

  .home-field-bar-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .home-field-bar-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

@media (max-width: 1180px) {
  .brand-copy {
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
  }

  .app-header {
    grid-template-columns: minmax(0, 1fr);
    padding: 12px;
  }

  .brand,
  .header-search-wrap {
    justify-self: stretch;
  }

  .header-balance {
    display: none;
  }

  .dashboard-shell {
    height: auto;
    min-height: calc(100vh - 150px);
    grid-template-columns: 300px minmax(0, 1fr);
    grid-template-areas:
      "sidebar list"
      "main main"
      "detail detail";
    overflow: visible;
  }

  body.filters-hidden .dashboard-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "list"
      "main"
      "detail";
  }

  .sidebar {
    grid-area: sidebar;
  }

  .business-panel {
    grid-area: list;
  }

  .main-panel {
    grid-area: main;
  }

  .detail-panel {
    grid-area: detail;
  }

  .sidebar,
  .business-panel {
    height: 520px;
  }
}

@media (max-width: 760px) {
  .header-search-wrap {
    grid-template-columns: minmax(0, 1fr);
  }

  .filter-search-button {
    width: 100%;
  }

  .dashboard-shell {
    display: block;
  }

  .sidebar,
  .business-panel,
  .detail-panel {
    height: auto;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar.collapsed {
    display: none;
  }

  .business-list,
  .filter-block.grow,
  .detail-list {
    max-height: 360px;
  }

  .business-list.home-hero-empty,
  .document-view.compact-empty-state {
    display: none;
  }

  body.home-view .detail-panel {
    display: none;
  }

  .document-view {
    padding: 16px;
  }

  .ministry-summary-grid {
    grid-template-columns: 1fr;
  }

  .center-budget-summary .summary-snapshot-table-wrap,
  .summary-chart-card {
    max-height: none;
    min-height: 0;
    height: auto;
  }

  .summary-chart {
    min-height: 220px;
  }

  .donut-chart-wrap {
    width: min(100%, 228px);
  }

  .donut-chart-card {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .donut-legend {
    width: 100%;
    padding: 12px 14px;
  }

  .donut-legend strong,
  .donut-legend span {
    font-size: 12.5px;
  }

  .home-stack-chart {
    grid-template-columns: repeat(var(--home-year-count, 5), minmax(0, 1fr));
    min-height: 260px;
    min-width: 260px;
    gap: 8px;
  }

  .center-budget-summary .home-stack-table-wrap .home-stack-table {
    width: max(480px, 100%);
    min-width: 480px;
  }

  .home-stack-group .summary-bar-label,
  .home-stack-group .summary-bar-value {
    white-space: nowrap;
  }

  .home-stack-chart-card {
    min-height: 0;
    overflow-x: auto;
  }

  .home-field-bar-card,
  .home-field-donut-card {
    min-height: 0;
  }

  .home-field-bar-row {
    grid-template-columns: minmax(104px, 0.9fr) minmax(96px, 1.1fr) auto;
    gap: 8px;
  }

  .home-field-donut-card {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .home-field-donut-wrap {
    width: min(100%, 238px);
  }

  .home-field-donut-legend {
    width: 100%;
  }
}

@container home-summary (max-width: 480px) {
  .home-field-bar-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
