/*
 * Shemify Budgets — Tracker #20 v1
 * Page-scoped styles for Accounting → Budgets.
 *
 * Lessons applied from Tracker #10 ship — locked in BEFORE first commit:
 *   - NO max-width on .bg-page; full width like every other Accounting page
 *   - NO custom .bg-modal-* CSS; defer to global .modal-overlay system in
 *     /app/ui-components.css for orbs/blur/spring/parallax/stagger
 *   - .ui-dropdown { width: auto } from start to override the global
 *     /app/ui-components.css :466 rule that sets width:100%
 *   - KPI label 13px from start (CLAUDE.md anti-pattern: <14px)
 *   - Modal close 44×44 (CLAUDE.md touch-target rule)
 *   - .tp-hint strong → primary ink, applied as .bg-hint strong here too
 *   - .bg-modal marker class on overlays for page-specific tweaks
 */

/* Council Round 1 Artist nit: 28px is off the CLAUDE.md spacing scale
 * (4/8/12/16/24/32/48/64/96). Use 32px to match year_end_taxes_workspace
 * (#year-end-taxes-page padding 24px 32px). */
.bg-page {
  padding: 24px 32px;
  width: 100%;
  box-sizing: border-box;
  color: var(--ink);
  font: 400 14px/1.5 var(--font);
}

/* ──────────────────────────────────────────────────────────────────────
 * Section heads + titles — H1 22px, flex-wrap so toolbar drops to next
 * line on narrow viewports instead of overlapping the title.
 * ────────────────────────────────────────────────────────────────────── */
.bg-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 12px;
  flex-wrap: wrap;
}
.bg-title-wrap { display: flex; align-items: center; gap: 10px; }
.bg-section-title {
  font: 700 22px/1.2 var(--font);
  letter-spacing: -.025em;
  color: var(--ink);
  text-shadow: 0 0 30px rgba(200, 160, 76, .06);
}
.bg-help-btn {
  width: 44px; height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--raised);
  color: var(--ink-3);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
  transition: all .2s var(--spring);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.bg-help-btn:hover { color: var(--gold); transform: scale(1.05); box-shadow: inset 0 0 0 1px var(--gold-glow-ring); }
html.light .bg-help-btn {
  background: rgba(0, 0, 0, .04);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
}
.bg-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bg-page-desc {
  margin: 0 0 16px;
  max-width: 720px;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
}

/* ──────────────────────────────────────────────────────────────────────
 * Buttons — 44px min-height (touch-target rule).
 * ────────────────────────────────────────────────────────────────────── */
.bg-btn {
  min-height: 44px;
  padding: 11px 20px;
  border-radius: var(--r-sm);
  border: none;
  cursor: pointer;
  font: 600 13px var(--font);
  letter-spacing: -.005em;
  transition: all .22s var(--spring);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.bg-btn-primary {
  background: linear-gradient(135deg, var(--gold-bright) 0%, var(--gold) 100%);
  color: var(--void);
  box-shadow: 0 2px 12px rgba(200, 160, 76, .25), 0 0 30px rgba(200, 160, 76, .1), inset 0 1px 0 rgba(255, 255, 255, .2);
}
.bg-btn-primary:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 6px 28px rgba(200, 160, 76, .4), 0 0 60px rgba(200, 160, 76, .15), inset 0 1px 0 rgba(255, 255, 255, .25); }
.bg-btn-primary:active { transform: scale(.97); }
.bg-btn-primary[disabled] {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  background: rgba(255, 255, 255, .06);
  color: var(--ink-3);
  filter: grayscale(1);
}
html.light .bg-btn-primary[disabled] {
  background: rgba(0, 0, 0, .04);
  color: var(--ink-3);
}
.bg-btn-ghost {
  background: rgba(255, 255, 255, .05);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08), 0 2px 8px rgba(0, 0, 0, .2);
}
.bg-btn-ghost:hover { background: rgba(255, 255, 255, .09); transform: translateY(-1px) scale(1.01); }
html.light .bg-btn-ghost {
  background: rgba(0, 0, 0, .04);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08), 0 2px 4px rgba(0, 0, 0, .05);
  color: var(--ink);
}
html.light .bg-btn-ghost:hover { background: rgba(0, 0, 0, .07); }

.bg-btn-danger {
  background: var(--red-glow);
  color: var(--red);
  box-shadow: inset 0 0 0 1px rgba(248, 113, 113, .25);
}
.bg-btn-danger:hover { background: rgba(248, 113, 113, .18); }

.bg-role-hint {
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: .02em;
}
.bg-export-disabled-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.bg-export-disabled-wrap .bg-role-hint {
  position: absolute;
  bottom: -18px;
  right: 0;
  white-space: nowrap;
}

/* ──────────────────────────────────────────────────────────────────────
 * KPI strip — 13px label (NOT 9.5px; CLAUDE.md anti-pattern).
 * ────────────────────────────────────────────────────────────────────── */
.bg-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 20px 0;
}
.bg-kpi {
  padding: 20px 22px;
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, .03) 0%, rgba(255, 255, 255, .015) 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .05), 0 2px 8px rgba(0, 0, 0, .2);
  backdrop-filter: blur(8px);
  position: relative;
  overflow: hidden;
}
.bg-kpi-label { font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-4); margin-bottom: 8px; }
.bg-kpi-value {
  font: 200 36px var(--font);
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-shadow: 0 2px 20px rgba(0, 0, 0, .5), 0 0 40px var(--gold-glow);
  margin-bottom: 6px;
}
.bg-kpi-foot { font-size: 11px; color: var(--ink-3); }
.bg-kpi.bg-kpi-good .bg-kpi-value { color: var(--green); text-shadow: 0 0 20px var(--green-glow); }
.bg-kpi.bg-kpi-bad  .bg-kpi-value { color: var(--red);   text-shadow: 0 0 20px var(--red-glow); }
.bg-kpi.bg-kpi-warn .bg-kpi-value { color: var(--amber); text-shadow: 0 0 20px var(--amber-glow); }
html.light .bg-kpi-value { text-shadow: 0 2px 6px rgba(0, 0, 0, .06); }
html.light .bg-kpi {
  background: linear-gradient(180deg, rgba(0, 0, 0, .02) 0%, rgba(0, 0, 0, .005) 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .05);
}

/* ──────────────────────────────────────────────────────────────────────
 * Budget list view (default landing).
 * ────────────────────────────────────────────────────────────────────── */
.bg-list-card {
  margin: 16px 0;
  padding: 24px;
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, .03) 0%, rgba(255, 255, 255, .015) 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .05), 0 4px 16px rgba(0, 0, 0, .3);
  backdrop-filter: blur(8px);
}
html.light .bg-list-card {
  background: linear-gradient(180deg, rgba(0, 0, 0, .02) 0%, rgba(0, 0, 0, .005) 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .05);
}
.bg-budget-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.bg-budget-card {
  padding: 18px 20px;
  border-radius: var(--r);
  background: rgba(255, 255, 255, .03);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
  cursor: pointer;
  transition: all .2s var(--spring);
}
.bg-budget-card:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 1px var(--gold-glow-ring), 0 4px 18px rgba(0, 0, 0, .25); }
.bg-budget-card:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(200, 160, 76, .18), inset 0 0 0 1px rgba(200, 160, 76, .4); }
html.light .bg-budget-card { background: rgba(0, 0, 0, .03); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .07); }
.bg-budget-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.bg-budget-card-name { font: 600 15px var(--font); color: var(--ink); }
.bg-budget-card-year { font: 700 11px var(--font); color: var(--ink-3); letter-spacing: .04em; }
.bg-budget-card-meta { font-size: 12px; color: var(--ink-3); }
.bg-budget-card-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  font: 600 11px var(--font);
  border-radius: 9999px;
  margin-top: 8px;
}
.bg-budget-card-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.bg-budget-card-status.is-active { color: var(--green); background: var(--green-glow); }
.bg-budget-card-status.is-draft  { color: var(--amber); background: var(--amber-glow); }

/* ──────────────────────────────────────────────────────────────────────
 * Spreadsheet-grid editor (Budgets detail view).
 * Months across the top, accounts down the side. Sticky first column.
 * ────────────────────────────────────────────────────────────────────── */
.bg-grid-card {
  margin: 16px 0;
  padding: 24px;
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, .03) 0%, rgba(255, 255, 255, .015) 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .05), 0 4px 16px rgba(0, 0, 0, .3);
  backdrop-filter: blur(8px);
}
html.light .bg-grid-card {
  background: linear-gradient(180deg, rgba(0, 0, 0, .02) 0%, rgba(0, 0, 0, .005) 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .05);
}
.bg-grid-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.bg-grid-title { font: 600 16px var(--font); letter-spacing: -.015em; color: var(--ink); }
.bg-grid-meta { font-size: 11px; color: var(--ink-3); letter-spacing: .04em; text-transform: uppercase; }
.bg-grid-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.bg-grid-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r-sm);
}
.bg-grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.bg-grid thead th {
  position: sticky;
  top: 0;
  background: var(--elevated);
  font: 700 10px var(--font);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 10px 8px;
  text-align: right;
  white-space: nowrap;
  z-index: 2;
}
.bg-grid thead th.bg-grid-th-account {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 3;
  min-width: 240px;
}
.bg-grid tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, .03);
}
html.light .bg-grid tbody tr { border-bottom: 1px solid rgba(0, 0, 0, .04); }
.bg-grid tbody tr:hover td { background: rgba(255, 255, 255, .02); }
html.light .bg-grid tbody tr:hover td { background: rgba(0, 0, 0, .02); }
.bg-grid td {
  padding: 4px 6px;
  text-align: right;
  border-bottom: 1px solid rgba(255, 255, 255, .02);
}
html.light .bg-grid td { border-bottom: 1px solid rgba(0, 0, 0, .03); }
.bg-grid td.bg-grid-td-account {
  position: sticky;
  left: 0;
  background: linear-gradient(90deg, rgba(0, 0, 0, .25), rgba(0, 0, 0, .12));
  text-align: left;
  padding: 8px 12px;
  z-index: 1;
  font-weight: 500;
}
html.light .bg-grid td.bg-grid-td-account {
  background: linear-gradient(90deg, rgba(0, 0, 0, .03), rgba(0, 0, 0, .01));
}
.bg-grid-account-code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--ink-3);
  margin-right: 6px;
}
.bg-grid-account-type {
  display: inline-block;
  font: 700 9px var(--font);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin-left: 8px;
}

/* Cell input — borderless, focus highlight, tabular numbers. */
.bg-cell-input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--ink);
  font: 500 13px var(--font);
  font-variant-numeric: tabular-nums;
  padding: 8px 10px;
  text-align: right;
  border-radius: 6px;
  transition: box-shadow .15s, background .15s;
  -moz-appearance: textfield;
}
.bg-cell-input::-webkit-outer-spin-button,
.bg-cell-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
/* Council Round 1 hotfix: `shell-override-v2.css:540-547` applies
 * `box-shadow: ... !important` to `.page input[type="number"]:focus`
 * for the global page-input styling, which clobbers our `.bg-cell-input
 * :focus` rule on cell inputs nested inside a `.page` ancestor. To win
 * the cascade we add `!important` to BOTH the focus ring (Order 8) and
 * the save-flash classes (Order 11). Same for hover/saving/error states.
 * Specificity-bumping with `#budgets-host .bg-cell-input:focus` would
 * not be enough — the override has its own !important. */
.bg-cell-input:hover { background: rgba(255, 255, 255, .03) !important; }
.bg-cell-input:focus {
  outline: none !important;
  background: rgba(200, 160, 76, .08) !important;
  box-shadow: 0 0 0 2px var(--gold), inset 0 0 0 1px var(--gold) !important;
}
html.light .bg-cell-input:hover { background: rgba(0, 0, 0, .025) !important; }
html.light .bg-cell-input:focus {
  background: rgba(150, 117, 10, .06) !important;
  box-shadow: 0 0 0 2px #966D0A, inset 0 0 0 1px #966D0A !important;
}
.bg-cell-input.is-saving { background: rgba(96, 165, 250, .08) !important; }
.bg-cell-input.is-error {
  background: rgba(248, 113, 113, .10) !important;
  box-shadow: inset 0 0 0 2px rgba(248, 113, 113, .35) !important;
}
.bg-cell-input.is-saved {
  background: rgba(74, 222, 128, .12) !important;
  box-shadow: inset 0 0 0 1px rgba(74, 222, 128, .35) !important;
  transition: background .3s, box-shadow .3s;
}

/* Total column — emphasized read-only. */
.bg-grid-td-total, .bg-grid-th-total {
  background: rgba(200, 160, 76, .04);
  font-weight: 700;
  color: var(--gold);
}
html.light .bg-grid-td-total, html.light .bg-grid-th-total {
  background: rgba(150, 117, 10, .04);
  color: var(--gold);
}

/* Variance columns */
.bg-grid-td-actual, .bg-grid-th-actual {
  background: rgba(96, 165, 250, .04);
  color: var(--blue);
  font-weight: 600;
}
.bg-grid-td-variance, .bg-grid-th-variance {
  font-weight: 700;
}
.bg-grid-td-variance.is-negative { color: var(--red); }
.bg-grid-td-variance.is-positive { color: var(--green); }

/* Section divider rows (Revenue / Expense headings inside the grid) */
.bg-grid-section-row td {
  background: rgba(255, 255, 255, .04);
  font: 700 9px var(--font);
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 10px 12px;
  text-align: left;
}
html.light .bg-grid-section-row td { background: rgba(0, 0, 0, .03); }

/* Empty / loading / error states */
.bg-empty {
  margin: 60px auto;
  max-width: 520px;
  padding: 40px 30px;
  text-align: center;
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, .03), rgba(255, 255, 255, .01));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .05);
}
html.light .bg-empty {
  background: linear-gradient(180deg, rgba(0, 0, 0, .02), rgba(0, 0, 0, .005));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
}
.bg-empty-title { font: 600 16px var(--font); margin-bottom: 8px; color: var(--ink); }
.bg-empty-desc { font-size: 13px; color: var(--ink-2); margin-bottom: 16px; }

.bg-skel-strip {
  height: 100px;
  margin: 16px 0;
  border-radius: var(--r-lg);
  background:
    linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, .04) 50%, transparent 100%),
    rgba(255, 255, 255, .02);
  background-size: 200% 100%;
  animation: bg-shimmer 1.4s ease-in-out infinite;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .04);
}
.bg-skel-row {
  height: 28px;
  margin: 8px 0;
  border-radius: 6px;
  background:
    linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, .04) 50%, transparent 100%),
    rgba(255, 255, 255, .02);
  background-size: 200% 100%;
  animation: bg-shimmer 1.4s ease-in-out infinite;
}
@keyframes bg-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
html.light .bg-skel-strip, html.light .bg-skel-row {
  background: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, .05) 50%, transparent 100%), rgba(0, 0, 0, .02);
  background-size: 200% 100%;
}

.bg-error-card {
  margin: 20px 0;
  padding: 20px 24px;
  border-radius: var(--r-lg);
  background: var(--red-glow);
  box-shadow: inset 0 0 0 1px rgba(248, 113, 113, .18);
  color: var(--ink);
}
.bg-error-title { font: 600 14px var(--font); color: var(--red); margin-bottom: 6px; }
.bg-error-desc { font-size: 12px; color: var(--ink-2); font-family: ui-monospace, monospace; word-break: break-word; }

/* ──────────────────────────────────────────────────────────────────────
 * Form helpers (used inside global modals). Mirrors year-end / tax-prep
 * structure but page-scoped to .bg-* selectors so modal content rendered
 * by buildModal still gets nice typography + focus rings.
 * ────────────────────────────────────────────────────────────────────── */
.bg-form { display: flex; flex-direction: column; gap: 16px; }
.bg-form-row { display: flex; flex-direction: column; gap: 6px; }
.bg-form-row > label {
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3);
}
.bg-form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .bg-form-grid-2 { grid-template-columns: 1fr; } }

.bg-input,
select.bg-input {
  padding: 10px 14px;
  font: 500 14px var(--font);
  background: rgba(255, 255, 255, .03);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
  border: none;
  border-radius: var(--r-sm);
  color: var(--ink);
  transition: all .2s var(--spring);
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
}
.bg-input:hover { background: rgba(255, 255, 255, .05); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); }
.bg-input:focus {
  box-shadow: 0 0 0 3px var(--gold-glow), inset 0 0 0 1px rgba(200, 160, 76, .2);
  outline: none;
}
select.bg-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%239898A8' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M3 4.5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  color-scheme: dark;
}
html.light select.bg-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23A8A29E' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M3 4.5l3 3 3-3'/%3E%3C/svg%3E");
  color-scheme: light;
}
html.light .bg-input,
html.light select.bg-input {
  background-color: rgba(0, 0, 0, .025);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
  color: var(--ink);
}

.bg-hint { font-size: 11px; color: var(--ink-3); line-height: 1.5; }
.bg-hint strong { color: var(--ink); font-weight: 700; }
.bg-readonly {
  padding: 10px 14px;
  background: rgba(255, 255, 255, .02);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .04);
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font: 500 14px var(--font);
}
html.light .bg-readonly {
  background: rgba(0, 0, 0, .025);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .05);
  color: var(--ink-2);
}

/* ──────────────────────────────────────────────────────────────────────
 * Modal — page-scoped tweaks ONLY. Heavy lifting is handled by the
 * global .modal-overlay / .modal-panel / .rgb-orb / .modal-hd / .modal-body
 * / .modal-ft / .modal-close classes from /app/ui-components.css.
 * The .bg-modal marker class on the overlay lets us widen the panel for
 * forms with grid layouts, and bumps the close button to 44×44 per the
 * Section 4.6 touch-target rule.
 * ────────────────────────────────────────────────────────────────────── */
.bg-modal.modal-overlay .modal-panel { max-width: 720px; }
.bg-modal.modal-overlay .modal-panel.bg-modal-md { max-width: 560px; }
.bg-modal.modal-overlay .modal-panel.bg-modal-sm { max-width: 440px; }
.bg-modal.modal-overlay .modal-close {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  font-size: 18px;
}

/* ──────────────────────────────────────────────────────────────────────
 * .ui-dropdown scoped to #budgets-host AND .bg-modal — overrides the
 * /app/ui-components.css :466 rule that sets `.ui-dropdown { width: 100% }`
 * which would otherwise stretch the dropdown to fill its toolbar flex
 * parent and force toolbar siblings onto a second row. (This was the
 * Phase 10_g hotfix on Tracker #10 — applying the lesson here from
 * the start.)
 * ────────────────────────────────────────────────────────────────────── */
#budgets-host .ui-dropdown,
.bg-modal .ui-dropdown {
  position: relative;
  display: inline-block;
  width: auto;
}
#budgets-host .ui-dropdown-trigger,
.bg-modal .ui-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .02));
  color: var(--ink);
  font: 500 13px var(--font);
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all .22s var(--spring);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .07), 0 2px 12px rgba(0, 0, 0, .20);
  min-height: 44px;
}
html.light #budgets-host .ui-dropdown-trigger,
html.light .bg-modal .ui-dropdown-trigger {
  background: linear-gradient(180deg, #FFFFFF, #FAFAF8);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08), 0 2px 12px rgba(0, 0, 0, .04);
}
#budgets-host .ui-dropdown-trigger:hover,
.bg-modal .ui-dropdown-trigger:hover {
  background: linear-gradient(180deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, .04));
  transform: translateY(-1px);
}
#budgets-host .ui-dropdown-trigger:focus-visible,
.bg-modal .ui-dropdown-trigger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(200, 160, 76, .18), inset 0 0 0 1px rgba(200, 160, 76, .4);
}
#budgets-host .ui-dropdown-chevron,
.bg-modal .ui-dropdown-chevron {
  transition: transform .22s var(--spring);
  opacity: .6;
}
#budgets-host .ui-dropdown.open .ui-dropdown-chevron,
.bg-modal .ui-dropdown.open .ui-dropdown-chevron {
  transform: rotate(180deg);
}
#budgets-host .ui-dropdown-menu,
.bg-modal .ui-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 100%;
  background: var(--elevated);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08), 0 8px 32px rgba(0, 0, 0, .50);
  border-radius: var(--r);
  padding: 6px;
  max-height: 320px;
  overflow-y: auto;
  opacity: 0;
  transform: translateY(-8px) scale(.98);
  pointer-events: none;
  transition: all .22s var(--spring);
  z-index: 1100;
}
html.light #budgets-host .ui-dropdown-menu,
html.light .bg-modal .ui-dropdown-menu {
  background: #FFFFFF;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06), 0 8px 32px rgba(0, 0, 0, .10);
}
#budgets-host .ui-dropdown.open .ui-dropdown-menu,
.bg-modal .ui-dropdown.open .ui-dropdown-menu {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
#budgets-host .ui-dropdown-item,
.bg-modal .ui-dropdown-item {
  padding: 8px 12px 8px 28px;
  border-radius: 8px;
  font: 400 13px var(--font);
  color: var(--ink);
  cursor: pointer;
  transition: background .15s ease;
  position: relative;
}
#budgets-host .ui-dropdown-item:hover,
.bg-modal .ui-dropdown-item:hover { background: rgba(255, 255, 255, .05); }
html.light #budgets-host .ui-dropdown-item:hover,
html.light .bg-modal .ui-dropdown-item:hover { background: rgba(0, 0, 0, .04); }
#budgets-host .ui-dropdown-item.selected::before,
.bg-modal .ui-dropdown-item.selected::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px rgba(200, 160, 76, .5);
}

/* ──────────────────────────────────────────────────────────────────────
 * Responsive
 * ────────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .bg-page { padding: 16px; }
  .bg-grid thead th { padding: 8px 6px; font-size: 9px; }
  .bg-grid td { padding: 3px 4px; }
  .bg-grid thead th.bg-grid-th-account { min-width: 160px; }
  .bg-cell-input { padding: 6px 8px; font-size: 12px; }
}
@media (max-width: 480px) {
  .bg-section-head { flex-direction: column; align-items: stretch; }
  .bg-toolbar { flex-direction: column; align-items: stretch; }
  .bg-kpi-grid { grid-template-columns: 1fr; }
  .bg-budget-list { grid-template-columns: 1fr; }
}
