/* ── Brand color override ───────────────────────────────────── */
:root {
  --bs-primary:          #512888;
  --bs-primary-rgb:      81, 40, 136;
  --bs-link-color:       #512888;
  --bs-link-hover-color: #3a1c61;
}
.btn-primary, .bg-primary         { background-color: #512888 !important; border-color: #512888 !important; }
.btn-primary:hover                 { background-color: #3a1c61 !important; border-color: #3a1c61 !important; }
.btn-outline-primary               { color: #512888 !important; border-color: #512888 !important; }
.btn-outline-primary:hover         { background-color: #512888 !important; color: #fff !important; }
.navbar.bg-primary                 { background-color: #512888 !important; }
.text-primary                      { color: #512888 !important; }
.badge.bg-primary                  { background-color: #512888 !important; }
.border-primary                    { border-color: #512888 !important; }
a                                  { color: #512888; }
a:hover                            { color: #3a1c61; }

/* ── Global ─────────────────────────────────────────────────── */
body { background-color: #f4f6f9; font-size: 0.9rem; }
.card { border-radius: 10px; }
.card-header { border-radius: 10px 10px 0 0 !important; font-size: 0.95rem; }
.navbar-brand { font-size: 1.1rem; letter-spacing: .02em; }
.table th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: .04em; color: #6c757d; font-weight: 600; }
.table td { vertical-align: middle; }
.badge { font-weight: 500; }
.form-label { margin-bottom: 4px; }
.alert { border-radius: 8px; }

/* ── Dark mode ──────────────────────────────────────────────── */
[data-bs-theme="dark"] body         { background-color: #1a1d21; }
[data-bs-theme="dark"] .card        { background-color: #212529; }
[data-bs-theme="dark"] .card-header { background-color: #2b2f33 !important; }
[data-bs-theme="dark"] .table-light { --bs-table-bg: #2b2f33; --bs-table-color: #dee2e6; }

/* ── Budget spreadsheet ─────────────────────────────────────── */
.budget-table td, .budget-table th { vertical-align: middle; font-size: .88rem; }
.budget-table input.cell-yellow    { background: #ffffc0 !important; border-radius: 0; height: 100%; min-height: 32px; }
.budget-table input.cell-yellow:focus { background: #ffff80 !important; box-shadow: none; border: 1px solid #c8a800 !important; }
.budget-table .subtotal-row td     { border-top: 2px solid #dee2e6; }
.budget-table .category-header td  { font-size: .78rem; }

[data-bs-theme="dark"] .budget-table input.cell-yellow       { background: #3d3800 !important; color: #fff; }
[data-bs-theme="dark"] .budget-table input.cell-yellow:focus { background: #4d4700 !important; }

/* ── Disbursement calendar ──────────────────────────────────── */
.disbursement-calendar th,
.disbursement-calendar td  { white-space: nowrap; }
.disbursement-calendar td  { vertical-align: middle; }
[data-bs-theme="dark"] .disbursement-calendar td[style*="background:#d1e7dd"] { background:#0f3d24 !important; }
[data-bs-theme="dark"] .disbursement-calendar td[style*="background:#f8f9fa"] { background:#2b2f33 !important; }
[data-bs-theme="dark"] .disbursement-calendar td[style*="background:#fafafa"] { background:#212529 !important; }
[data-bs-theme="dark"] .disbursement-calendar tr[style*="background:#e9ecef"] { background:#2b2f33 !important; }

/* ── Calculator ─────────────────────────────────────────────── */
.calc-section-label {
  font-size: 11px; font-weight: 500; letter-spacing: .08em;
  text-transform: uppercase; color: #aaa; margin: 0 0 10px;
}
.field-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px;
}
.field-row.single { grid-template-columns: 1fr; }
.field-group      { display: flex; flex-direction: column; gap: 5px; }
.field-group label { font-size: 13px; color: #666; }

.range-hint { font-size: 11px; color: #aaa; margin-top: 3px; display: block; }

.slider-wrap { display: flex; flex-direction: column; gap: 3px; }
.slider-row  { display: flex; align-items: center; gap: 10px; }
.slider-row input[type=range] { flex: 1; accent-color: #512888; cursor: pointer; }
.slider-val  { font-size: 14px; font-weight: 500; min-width: 48px; text-align: right; }
.slider-ends { display: flex; justify-content: space-between; font-size: 11px; color: #bbb; }

.divider { border: none; border-top: 0.5px solid rgba(0,0,0,0.1); margin: 1.5rem 0; }

.result-area {
  background: #f5f5f3; border-radius: 10px;
  padding: 1.25rem 1.5rem; margin-top: 1.5rem; min-height: 80px;
}
.result-main   { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.result-amount { font-size: 36px; font-weight: 500; }
.result-label  { font-size: 13px; color: #888; }
.result-meta   { font-size: 12px; color: #aaa; margin-top: 6px; }

.badge-warn { background: #FFF3CD; color: #856404; display:inline-block; font-size:11px; font-weight:500; border-radius:6px; padding:2px 8px; }
.badge-info { background: #D6EAF8; color: #1a5276; display:inline-block; font-size:11px; font-weight:500; border-radius:6px; padding:2px 8px; }

/* ── Fund source badge ──────────────────────────────────────── */
.badge-fund-source {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: 20px;
  color: #fff;
  vertical-align: middle;
  letter-spacing: 0.01em;
}
/* Fallback when no color is set */
.badge-fund-source.no-color { background-color: #512888; }

.breakdown-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(120px,1fr)); gap: 8px; margin-top: 14px; }
.breakdown-card { background: #fff; border: 0.5px solid rgba(0,0,0,0.1); border-radius: 8px; padding: 10px 12px; }
.bc-label { font-size: 11px; color: #aaa; margin-bottom: 3px; }
.bc-val   { font-size: 14px; font-weight: 500; }

[data-bs-theme="dark"] .result-area    { background: #2b2f33; }
[data-bs-theme="dark"] .breakdown-card { background: #212529; }
[data-bs-theme="dark"] .field-group label { color: #aaa; }

@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }
