/* Budget center: scoped to avoid changing existing SMIS-PQ modules. */
#budget-center-page,
#budget-center-page button,
#budget-center-page input,
#budget-center-page select,
#budget-center-page textarea {
  font-family: 'Prompt', 'Kanit', 'Segoe UI', 'Sarabun', Tahoma, sans-serif;
}
#budget-center-page { color: var(--color-text); font-size: 13px; line-height: 1.55; }
#budget-center-page * { min-width: 0; }
#budget-center-page.bc-layout { display: grid; gap: 14px; }
#budget-center-page .bc-filters,
#budget-center-page .bc-cards { display: grid; gap: 10px; }
#budget-center-page .bc-card { background: #fff; padding: 15px; }
#budget-center-page .bc-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#budget-center-page .bc-bar { background: #e2e8f0; border-radius: 10px; overflow: hidden; }
#budget-center-page .bc-bar span { display: block; height: 100%; background: var(--color-primary-light); }
#budget-center-page .bc-alert { border-left: 4px solid var(--color-danger); padding: 9px 12px; margin: 6px 0; border-radius: 6px; }
#budget-center-page .bc-warning-panel { border-color: #fecaca; background: #fff7f7; padding: 0; }
#budget-center-page .bc-warning-panel summary { cursor: pointer; padding: 11px 15px; color: #b91c1c; font-weight: 600; list-style: none; }
#budget-center-page .bc-warning-panel summary::-webkit-details-marker { display: none; }
#budget-center-page .bc-warning-panel summary span { float: right; font-size: 11px; font-weight: 500; }
#budget-center-page .bc-warning-list { max-height: 260px; overflow: auto; padding: 0 12px 10px; }
#budget-center-page .bc-edit,
#budget-center-page .bc-edit-row { display: grid; }
#budget-center-page .bc-edit-row { gap: 8px; align-items: end; }
#budget-center-page .bc-hero {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 18px 20px; border: 1px solid rgba(30,58,138,.1); border-radius: var(--radius);
  background: linear-gradient(115deg,#fff 0%,#f1f5ff 100%); box-shadow: var(--shadow-soft);
}
#budget-center-page .bc-hero-icon {
  display: grid; place-items: center; flex: 0 0 52px; width: 52px; height: 52px;
  border-radius: 14px; background: linear-gradient(135deg,var(--color-primary-light),var(--color-primary));
  color: #fff; font-size: 27px; box-shadow: 0 7px 17px rgba(30,58,138,.22);
}
#budget-center-page .bc-hero-copy { flex: 1 1 330px; }
#budget-center-page .bc-hero h2 { margin: 0; color: var(--color-primary); font-size: clamp(17px,2vw,22px); line-height: 1.3; }
#budget-center-page .bc-hero p { margin: 3px 0 0; color: var(--color-text-muted); font-size: 12px; }
#budget-center-page .bc-toolbar { gap: 8px; }
#budget-center-page .bc-toolbar .btn { white-space: nowrap; font-size: 12px; font-weight: 500; }
#budget-center-page .bc-export-xlsx { background: var(--color-primary-light); color: #fff; }
#budget-center-page .bc-export-xls { background: var(--color-success); color: #fff; }
#budget-center-page .bc-export-pdf { background: var(--color-danger); color: #fff; }
#budget-center-page .bc-filters {
  grid-template-columns: repeat(4,minmax(150px,1fr)); gap: 10px;
  padding: 14px; background: #fff; border: 1px solid #e2e8f0;
  border-radius: 14px; box-shadow: var(--shadow-soft);
}
#budget-center-page .bc-filters label { border: 0; border-radius: 0; box-shadow: none; padding: 0; background: transparent; color: var(--color-primary); font-size: 12px; font-weight: 600; }
#budget-center-page input,
#budget-center-page select,
#budget-center-page textarea {
  display: block; width: 100%; min-height: 39px; margin-top: 5px; padding: 8px 11px;
  border: 1px solid #cbd5e1; border-radius: 9px; background: #fff;
  color: var(--color-text); font-size: 13px; font-weight: 400; line-height: 1.45;
  box-shadow: inset 0 1px 2px rgba(30,58,138,.03); transition: border-color .15s, box-shadow .15s;
}
#budget-center-page input:focus,
#budget-center-page select:focus,
#budget-center-page textarea:focus {
  outline: none; border-color: var(--color-primary-light);
  box-shadow: 0 0 0 3px rgba(59,91,219,.14);
}
#budget-center-page input::placeholder { color: #94a3b8; opacity: 1; }
#budget-center-page .bc-card { border: 1px solid #e2e8f0; border-radius: 14px; box-shadow: var(--shadow-soft); }
#budget-center-page .bc-card h3 { margin: 0 0 12px; color: var(--color-primary); font-size: 15px; line-height: 1.45; }
#budget-center-page .bc-cards { grid-template-columns: repeat(4,minmax(0,1fr)); }
#budget-center-page .bc-metric { position: relative; overflow: hidden; padding: 15px 16px; border-color: transparent; }
#budget-center-page .bc-metric::before { content: ''; position: absolute; top: 0; left: 0; width: 5px; height: 100%; background: currentColor; }
#budget-center-page .bc-metric:nth-child(1) { color: #1d4ed8; background: linear-gradient(135deg,#f8fbff,#dbeafe); }
#budget-center-page .bc-metric:nth-child(2) { color: #166534; background: linear-gradient(135deg,#f7fff9,#dcfce7); }
#budget-center-page .bc-metric:nth-child(3) { color: #3949ab; background: linear-gradient(135deg,#f8f9ff,#e0e7ff); }
#budget-center-page .bc-metric:nth-child(4) { color: #b91c1c; background: linear-gradient(135deg,#fff9f9,#fee2e2); }
#budget-center-page .bc-metric small { color: #475569; font-size: 11px; }
#budget-center-page .bc-metric b { margin: 4px 0; color: inherit; font-size: clamp(18px,1.7vw,24px); line-height: 1.3; white-space: nowrap; }
#budget-center-page .bc-section-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 10px; }
#budget-center-page .bc-section-head h3 { margin: 0; }
#budget-center-page .bc-source-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; color: var(--color-text-muted); font-size: 11px; }
#budget-center-page .bc-source-legend span { display: inline-flex; align-items: center; gap: 5px; }
#budget-center-page .bc-source-legend i { width: 9px; height: 9px; border-radius: 50%; }
#budget-center-page .bc-legend-blue { background: #3b82f6; }
#budget-center-page .bc-legend-gray { background: #cbd5e1; }
#budget-center-page .bc-legend-red { background: #e11d48; }
#budget-center-page .bc-source-table { min-width: 780px; font-variant-numeric: tabular-nums; }
#budget-center-page .bc-source-table th:nth-child(1) { width: 22%; }
#budget-center-page .bc-source-table th:nth-child(2),
#budget-center-page .bc-source-table th:nth-child(3),
#budget-center-page .bc-source-table th:nth-child(5) { width: 15%; }
#budget-center-page .bc-source-table th:nth-child(4) { width: 24%; }
#budget-center-page .bc-source-table th:nth-child(6) { width: 9%; }
#budget-center-page .bc-source-table tbody td { padding-top: 7px; padding-bottom: 7px; }
#budget-center-page .bc-source-name { font-weight: 600; color: var(--color-primary) !important; }
#budget-center-page .bc-progress-cell { display: flex; align-items: center; gap: 8px; }
#budget-center-page .bc-progress-cell small { min-width: 54px; text-align: right; color: #475569; font-size: 11px; }
#budget-center-page .bc-source-progress { display: block; position: relative; width: 100%; min-width: 75px; height: 11px; padding: 0; border: 0; border-radius: 99px; overflow: hidden; background: #e2e8f0; cursor: pointer; }
#budget-center-page .bc-source-progress:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
#budget-center-page .bc-source-progress-fill { display: block; height: 100%; border-radius: inherit; }
#budget-center-page .bc-fill-allocated { background: #3b82f6; }
#budget-center-page .bc-fill-over { background: #e11d48; }
#budget-center-page .bc-status { display: inline-flex; align-items: center; justify-content: center; min-width: 76px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
#budget-center-page .bc-status-over, #budget-center-page .bc-status.bc-delta-up { background: #fee2e2; color: #b91c1c; }
#budget-center-page .bc-status-remaining, #budget-center-page .bc-status.bc-delta-down { background: #dcfce7; color: #15803d; }
#budget-center-page .bc-status-even, #budget-center-page .bc-status.bc-delta-even { background: #eef2f7; color: #1e293b; }
#budget-center-page .bc-status.bc-delta-unknown { background: #f1f5f9; color: #64748b; }
#budget-center-page .bc-table tbody td.num.bc-delta-up { color: #b91c1c; font-weight: 700; }
#budget-center-page .bc-table tbody td.num.bc-delta-down { color: #15803d; font-weight: 700; }
#budget-center-page .bc-table tbody td.num.bc-delta-even { color: #111827; }
#budget-center-page .bc-table tbody td.num.bc-delta-unknown { color: #64748b; }
#budget-center-page .bc-table-wrap { width: 100%; overflow: auto; border: 1px solid #dbe4ef; border-radius: 10px; }
#budget-center-page .bc-table { width: 100%; min-width: 720px; margin: 0; border-collapse: separate; border-spacing: 0; font-size: 12px; }
#budget-center-page .bc-table thead tr { background: #eaf1fa; }
#budget-center-page .bc-table thead th {
  position: sticky; top: 0; z-index: 1; padding: 10px 11px;
  background: #eaf1fa; color: #173365 !important; border-bottom: 2px solid #c9d8eb;
  font-family: inherit; font-size: 12px; font-weight: 700; line-height: 1.4;
  text-align: left; white-space: nowrap;
}
#budget-center-page .bc-table thead th.num,
#budget-center-page .bc-table tbody td.num { text-align: right; }
#budget-center-page .bc-table tbody td {
  padding: 10px 11px; color: var(--color-text); background: #fff;
  border-bottom: 1px solid #e8eef5; vertical-align: middle; font-size: 12px;
}
#budget-center-page .bc-table tbody tr:hover td { background: #f8fbff; }
#budget-center-page .bc-table tbody tr.bc-project-row td { background: #f5f8fd; font-weight: 600; }
#budget-center-page .bc-table tbody tr.bc-project-row:hover td { background: #edf3fc; }
#budget-center-page .bc-table details summary { cursor: pointer; color: var(--color-primary); }
#budget-center-page .bc-table details summary b { display: inline; font-size: 12px; }
#budget-center-page .bc-table details small { display: block; margin-top: 3px; font-weight: 400; }
#budget-center-page .bc-table .bc-source-chip { display: inline-flex; margin: 2px 3px 2px 0; padding: 2px 8px; border-radius: 999px; background: #eef2ff; color: var(--color-primary); white-space: nowrap; }
#budget-center-page .bc-table .bc-amount-over { color: var(--color-danger); font-weight: 700; }
#budget-center-page .bc-table .bc-table-action { padding: 6px 9px; border-color: #bacbe3; color: var(--color-primary); font-size: 11px; white-space: nowrap; }
#budget-center-page .bc-muted { color: var(--color-text-muted); }
#budget-center-page .bc-scope-note { margin: -4px 2px 0; font-size: 11px; }
#budget-center-page .bc-alert { border-color: #ef4444; background: #fff5f5; color: #9f1239; font-size: 12px; }
#budget-center-page .bc-edit { gap: 12px; padding: 20px; }
#budget-center-page .bc-edit label { color: var(--color-primary); font-size: 12px; font-weight: 600; }
#budget-center-page .bc-edit-row { grid-template-columns: minmax(160px,2fr) minmax(130px,1fr) auto; }
#budget-center-page .bc-edit .bc-card { box-shadow: none; }
#budget-center-page .bc-edit .bc-cards { grid-template-columns: repeat(3,minmax(0,1fr)); }
#budget-center-page .bc-edit .bc-cards b { color: var(--color-primary); font-size: 19px; }
#budget-center-page .bc-good { color: var(--color-success); }
#budget-center-page .bc-danger { color: var(--color-danger); }
@media (max-width:1100px) {
  #budget-center-page .bc-cards { grid-template-columns: repeat(3,minmax(0,1fr)); }
  #budget-center-page .bc-filters { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width:700px) {
  #budget-center-page .bc-hero { padding: 14px; }
  #budget-center-page .bc-hero .bc-toolbar { width: 100%; }
  #budget-center-page .bc-hero .bc-toolbar .btn { flex: 1 1 140px; }
  #budget-center-page .bc-cards { grid-template-columns: repeat(2,minmax(0,1fr)); }
  #budget-center-page .bc-edit .bc-cards { grid-template-columns: 1fr; }
  #budget-center-page .bc-edit-row { grid-template-columns: 1fr 1fr; }
  #budget-center-page .bc-edit-row button { grid-column: span 2; }
  #budget-center-page .bc-source-table { min-width: 0; display: block; }
  #budget-center-page .bc-source-table thead { display: none; }
  #budget-center-page .bc-source-table tbody { display: grid; gap: 8px; padding: 8px; }
  #budget-center-page .bc-source-table tbody tr { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); border: 1px solid #e2e8f0; border-radius: 9px; overflow: hidden; }
  #budget-center-page .bc-source-table tbody td { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px solid #eef2f7; text-align: right; }
  #budget-center-page .bc-source-table tbody td:first-child,
  #budget-center-page .bc-source-table tbody td:nth-child(4) { grid-column: 1 / -1; }
  #budget-center-page .bc-source-table tbody td:first-child { text-align: left; background: #f5f8fd; }
  #budget-center-page .bc-source-table tbody td:nth-child(4) { display: block; }
  #budget-center-page .bc-source-table tbody td:nth-child(4)::before { content: 'สัดส่วนการจัดสรร'; display: block; margin-bottom: 4px; text-align: left; color: #64748b; font-size: 10px; }
  #budget-center-page .bc-source-table tbody td:nth-child(2)::before { content: 'วงเงิน'; }
  #budget-center-page .bc-source-table tbody td:nth-child(3)::before { content: 'จัดสรร'; }
  #budget-center-page .bc-source-table tbody td:nth-child(5)::before { content: 'เหลือ / เกิน'; }
  #budget-center-page .bc-source-table tbody td:nth-child(6)::before { content: 'สถานะ'; }
  #budget-center-page .bc-source-table tbody td::before { color: #64748b; font-size: 10px; font-weight: 500; }
}
@media (max-width:460px) {
  #budget-center-page .bc-filters { grid-template-columns: 1fr; }
  #budget-center-page .bc-cards { grid-template-columns: 1fr; }
  #budget-center-page .bc-source-table tbody tr { grid-template-columns: 1fr; }
  #budget-center-page .bc-source-table tbody td { grid-column: 1 / -1; }
}
