.beta-active .workspace { grid-template-columns: 190px minmax(0, 1fr); }
.beta-active .preview,
.beta-active .actionbar,
.beta-active #saveState,
.beta-active #historyButton { display: none; }
.beta-active .editor-main { max-width: none; min-width: 0; }

.bs-page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 8px 8px 42px;
  color: var(--text);
}
.bs-page h1,
.bs-page h2,
.bs-page h3,
.bs-page p { margin: 0; }
.bs-page h1 {
  margin-top: 9px;
  font-size: clamp(30px, 3.4vw, 44px);
  font-weight: 650;
  letter-spacing: -.055em;
}
.bs-page h2 {
  font-size: 19px;
  font-weight: 620;
  letter-spacing: -.03em;
}
.bs-page h3 { font-size: 15px; font-weight: 620; }
.bs-page p { color: var(--muted); line-height: 1.6; }
.bs-kicker {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .14em;
  line-height: 1.4;
  text-transform: uppercase;
}
.bs-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 24px;
}
.bs-header p { max-width: 680px; margin-top: 10px; font-size: 13px; }
.bs-refresh { flex: 0 0 auto; margin-top: 4px; }
.bs-refresh span { display: inline-block; margin-right: 7px; font-size: 15px; }

.bs-overview {
  display: flex;
  flex-direction: column-reverse;
  gap: 12px;
  margin-bottom: 18px;
}
.bs-health,
.bs-panel,
.bs-results {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(18, 20, 22, .68);
  box-shadow: 0 18px 55px rgba(0, 0, 0, .12);
}
.bs-health {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) minmax(200px, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 0;
  padding: 14px 18px;
  border-color: rgba(142, 184, 154, .22);
  background: linear-gradient(145deg, rgba(142, 184, 154, .1), rgba(255, 255, 255, .018));
}
.bs-health--warn {
  border-color: rgba(214, 188, 131, .3);
  background: linear-gradient(145deg, rgba(214, 188, 131, .1), rgba(255, 255, 255, .018));
}
.bs-health--muted {
  border-color: var(--line);
  background: rgba(255, 255, 255, .022);
}
.bs-health__heading { display: flex; align-items: flex-start; gap: 12px; }
.bs-health__dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(142, 184, 154, .1);
}
.bs-health--warn .bs-health__dot { background: #d6bc83; box-shadow: 0 0 0 5px rgba(214, 188, 131, .11); }
.bs-health--muted .bs-health__dot { background: var(--muted); box-shadow: 0 0 0 5px rgba(146, 152, 161, .1); }
.bs-health h2 { margin-top: 0; font-size: 14px; }
.bs-health .bs-kicker,.bs-health__meta > span { display: none; }
.bs-health > p { max-width: 43ch; margin: 0; font-size: 12px; }
.bs-health__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 11px;
}
.bs-text-button {
  padding: 0;
  border: 0;
  color: var(--accent);
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-align: left;
}
.bs-text-button:hover { color: var(--text); }
.bs-text-button:focus-visible,
.bs-customer:focus-visible,
.bs-icon-button:focus-visible,
.bs-page input:focus-visible,
.bs-page select:focus-visible,
.bs-page summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.bs-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.bs-metric {
  min-width: 0;
  min-height: 89px;
  padding: 17px 19px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255, 255, 255, .022);
}
.bs-metric--accent {
  border-color: rgba(142, 184, 154, .25);
  background: linear-gradient(145deg, rgba(142, 184, 154, .1), rgba(255, 255, 255, .02));
}
.bs-metric--warn {
  border-color: rgba(214, 188, 131, .28);
  background: rgba(214, 188, 131, .05);
}
.bs-metric--good { border-color: rgba(142, 184, 154, .19); }
.bs-metric span,
.bs-metric small { display: block; color: var(--muted); }
.bs-metric span { font-size: 11px; font-weight: 650; }
.bs-metric strong {
  display: block;
  margin: 8px 0 3px;
  font-size: clamp(20px, 2vw, 27px);
  font-weight: 620;
  letter-spacing: -.045em;
}
.bs-metric small { font-size: 10px; }

.bs-panel { padding: 19px; margin-bottom: 18px; }
.bs-panel__heading,
.bs-results__heading,
.bs-dialog__header,
.bs-dialog-section__heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}
.bs-panel__heading { margin-bottom: 17px; }
.bs-controls .bs-panel__heading { display: none; }
.bs-panel__heading h2 { margin-top: 5px; }
.bs-controls__hint,
.bs-results__meta,
.bs-dialog-section__heading > span { color: var(--muted); font-size: 11px; }
.bs-controls__hint { text-align: right; }
.bs-filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}
.bs-search { grid-column: span 3; }
.bs-filters__actions { grid-column: span 2; justify-content: flex-end; }
.bs-filters input,.bs-filters select { font-size: 12px; }
.bs-presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.bs-preset { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 10px; min-height: 38px; padding: 8px 12px; font-size: 12px; cursor: pointer; }
.bs-preset span { margin-left: 8px; color: var(--soft); font-variant-numeric: tabular-nums; }
.bs-preset[aria-pressed=true] { background: rgba(142,184,154,.09); border-color: rgba(142,184,154,.3); color: var(--text); }
.bs-preset:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.bs-stale { color: #d6bc83; }
.bs-page .bs-detail-caption { margin: 10px 0 16px; font-size: 12px; }
.bs-page .bs-dialog .bs-alert { margin: 12px 0 20px; }
.bs-results__meta::before { display: none; }
.bs-page button:disabled { cursor: default; }
.bs-number,.bs-metric strong { font-variant-numeric: tabular-nums; }
.bs-filters label { display: grid; min-width: 0; gap: 7px; color: var(--muted); font-size: 10px; }
.bs-filters input,
.bs-filters select {
  width: 100%;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  background: var(--surface-2);
  font: inherit;
  outline: none;
}
.bs-filters input::placeholder { color: #6f757e; }
.bs-filters input:focus,
.bs-filters select:focus { border-color: var(--line-strong); box-shadow: 0 0 0 3px rgba(142, 184, 154, .08); }
.bs-filters__actions { display: flex; align-items: center; gap: 5px; }
.bs-filters__actions .button { min-height: 42px; padding-inline: 13px; white-space: nowrap; }

.bs-results { overflow: hidden; }
.bs-results__heading { align-items: center; padding: 21px 21px 17px; }
.bs-results__heading h2 { margin-top: 5px; }
.bs-results__meta { text-align: right; white-space: nowrap; }
.bs-results__meta::before { content: "•"; margin-right: 7px; color: var(--success); }
.bs-alert {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  margin: 0 20px 16px;
  padding: 12px 14px;
  border: 1px solid rgba(223, 157, 146, .28);
  border-radius: 13px;
  color: var(--danger);
  background: rgba(223, 157, 146, .06);
  font-size: 12px;
}
.bs-alert span { color: var(--muted); line-height: 1.45; }
.bs-alert--soft { border-color: rgba(214, 188, 131, .27); color: #d6bc83; background: rgba(214, 188, 131, .06); }
.bs-alert--soft span { color: var(--soft); }
.bs-table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
.bs-table { width: 100%; min-width: 790px; border-collapse: collapse; font-size: 12px; }
.bs-table th {
  padding: 12px 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, .018);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .08em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.bs-table td { padding: 16px; border-top: 1px solid var(--line); vertical-align: middle; }
.bs-table tbody tr { transition: background .16s ease; }
.bs-table tbody tr:hover { background: rgba(255, 255, 255, .025); }
.bs-table td small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.bs-customer {
  display: grid;
  max-width: 210px;
  gap: 4px;
  padding: 0;
  border: 0;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.bs-customer strong { overflow: hidden; font-size: 13px; font-weight: 620; text-overflow: ellipsis; white-space: nowrap; }
.bs-customer span { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.bs-customer:hover strong { color: var(--accent); }
.bs-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, .035);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.bs-pill--good { border-color: rgba(142, 184, 154, .27); color: #b9d9c1; background: rgba(142, 184, 154, .09); }
.bs-pill--pending { border-color: rgba(214, 188, 131, .28); color: #d6bc83; background: rgba(214, 188, 131, .08); }
.bs-pill--warn { border-color: rgba(214, 188, 131, .25); color: #d6bc83; background: rgba(214, 188, 131, .07); }
.bs-pill--bad { border-color: rgba(223, 157, 146, .3); color: #df9d92; background: rgba(223, 157, 146, .07); }
.bs-pill--muted { color: var(--muted); }
.bs-number { display: block; font-size: 13px; font-weight: 620; white-space: nowrap; }
.bs-number--small { font-size: 12px; }
.bs-breakdown { max-width: 225px; }
.bs-icon-button {
  display: grid;
  place-items: center;
  width: 33px;
  height: 33px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--soft);
  background: rgba(255, 255, 255, .025);
  cursor: pointer;
  font-size: 16px;
}
.bs-icon-button:hover { border-color: var(--line-strong); color: var(--accent); background: rgba(142, 184, 154, .08); }
.bs-table__action { width: 55px; text-align: right; }
.bs-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.bs-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 20px 18px;
  color: var(--muted);
  font-size: 11px;
}
.bs-pagination > div { display: flex; gap: 6px; }
.bs-pagination .button { min-height: 35px; font-size: 11px; }

.bs-loading,
.bs-empty {
  margin: 16px 20px 20px;
  padding: 42px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 15px;
  text-align: center;
}
.bs-loading p,
.bs-empty p { margin: 8px auto 18px; font-size: 12px; }
.bs-skeleton {
  height: 12px;
  margin: 11px auto;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,255,255,.05), rgba(255,255,255,.12), rgba(255,255,255,.05));
  background-size: 200% 100%;
  animation: bs-shimmer 1.5s ease-in-out infinite;
}
.bs-skeleton--wide { width: 65%; height: 18px; }
.bs-skeleton:not(.bs-skeleton--wide) { width: 45%; }
.bs-empty__icon { display: block; color: var(--muted); font-size: 28px; }
.bs-empty h3 { margin-top: 10px; }
.bs-help { margin: 16px 2px 0; color: var(--muted); font-size: 12px; }
.bs-help summary { width: fit-content; cursor: pointer; color: var(--soft); font-weight: 650; }
.bs-help p { max-width: 78ch; margin-top: 10px; font-size: 12px; }
.bs-help strong { color: var(--soft); }

.bs-page dialog {
  width: min(680px, calc(100vw - 28px));
  max-height: min(86vh, 780px);
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  color: var(--text);
  background: #121416;
  box-shadow: var(--shadow);
}
.bs-page dialog::backdrop { background: rgba(0, 0, 0, .67); backdrop-filter: blur(5px); }
.bs-dialog__header { align-items: flex-start; margin-bottom: 21px; }
.bs-dialog__header h2 { margin-top: 6px; font-size: 23px; }
.bs-dialog__header p { margin-top: 5px; font-size: 12px; overflow-wrap: anywhere; }
.bs-detail-loading { padding: 42px 10px; color: var(--muted); text-align: center; }
.bs-detail-summary {
  display: grid;
  grid-template-columns: 1.35fr repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 23px;
}
.bs-detail-summary > div {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, .025);
}
.bs-detail-summary__main { border-color: rgba(142, 184, 154, .25) !important; background: rgba(142, 184, 154, .08) !important; }
.bs-detail-summary span,
.bs-detail-summary small { display: block; color: var(--muted); font-size: 10px; }
.bs-detail-summary strong { display: block; margin: 8px 0 3px; font-size: 17px; letter-spacing: -.03em; }
.bs-detail-summary__main strong { font-size: 23px; }
.bs-dialog-section + .bs-dialog-section { margin-top: 25px; }
.bs-dialog-section__heading { align-items: baseline; margin-bottom: 10px; }
.bs-dialog-section__heading h3 { margin: 0; }
.bs-grants,
.bs-ledger { display: grid; gap: 7px; }
.bs-grant {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .022);
}
.bs-grant > div { min-width: 0; }
.bs-grant strong,
.bs-grant span,
.bs-grant small { display: block; }
.bs-grant span,
.bs-grant small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.bs-grant.is-revoked { opacity: .55; }
.bs-ledger__row {
  display: grid;
  grid-template-columns: 125px minmax(0, 1fr) auto;
  gap: 6px 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 11px;
}
.bs-ledger__row span,
.bs-ledger__row small { color: var(--muted); }
.bs-ledger__row em { color: var(--soft); font-style: normal; }
.bs-ledger__row small { grid-column: 2 / -1; overflow-wrap: anywhere; }
.bs-muted { color: var(--muted); font-size: 12px; }

@keyframes bs-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (max-width: 1120px) {
  .bs-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bs-search { grid-column: span 2; }
  .bs-filters__actions { grid-column: span 2; justify-content: flex-end; }
}
@media (min-width:861px) and (max-width:1120px) { .beta-active .workspace { grid-template-columns:76px minmax(0,1fr); } }
@media (max-width: 860px) {
  .beta-active .workspace { grid-template-columns: 76px minmax(0, 1fr); }
  .bs-overview { grid-template-columns: 1fr; }
  .bs-health { min-height: 0; }
  .bs-health { grid-template-columns: 1fr auto; gap: 10px; }
  .bs-health > p { grid-row: 2; }
  .bs-health__meta { grid-column: 2; grid-row: 1 / span 2; }
  .bs-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bs-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bs-search { grid-column: 1 / -1; }
  .bs-filters__actions { grid-column: 1 / -1; justify-content: flex-end; }
}
@media (max-width: 600px) {
  .bs-page { padding: 0 0 28px; }
  .bs-header { align-items: stretch; flex-direction: column; gap: 15px; }
  .bs-header .bs-refresh { width: 100%; margin-top: 0; }
  .bs-metrics { gap: 8px; }
  .bs-health { grid-template-columns: 1fr; }
  .bs-health__meta { grid-column: auto; grid-row: auto; }
  .bs-metric { padding: 14px; }
  .bs-metric strong { font-size: 21px; }
  .bs-panel { padding: 16px; }
  .bs-panel__heading { align-items: flex-start; flex-direction: column; gap: 7px; }
  .bs-controls__hint { text-align: left; }
  .bs-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bs-search,.bs-filters__actions { grid-column: 1 / -1; }
  .bs-filters__actions { justify-content: stretch; }
  .bs-filters__actions .button { flex: 1; }
  .bs-results__heading { align-items: flex-start; flex-direction: column; gap: 8px; padding: 18px 16px 14px; }
  .bs-results__meta { text-align: left; }
  .bs-alert { grid-template-columns: 1fr; margin-inline: 16px; }
  .bs-alert .bs-text-button { justify-self: start; }
  .bs-table-wrap { overflow: visible; border-top: 0; }
  .bs-table { min-width: 0; }
  .bs-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .bs-table,
  .bs-table tbody,
  .bs-table tr,
  .bs-table td { display: block; width: auto; }
  .bs-table tr { margin: 0 16px 9px; border: 1px solid var(--line); border-radius: 14px; }
  .bs-table td { display: grid; grid-template-columns: 105px minmax(0, 1fr); gap: 10px; padding: 11px 13px; border-top: 1px solid var(--line); }
  .bs-table td:first-child { border-top: 0; }
  .bs-table td::before { content: attr(data-label); color: var(--muted); font-size: 10px; }
  .bs-table td > * { min-width: 0; }
  .bs-table td > small { grid-column: 2; margin-top: -5px; }
  .bs-table td > .bs-pill { justify-self: start; }
  .bs-table__action .bs-icon-button { margin-left: auto; }
  .bs-table .bs-table__action { display: block; padding: 8px 13px; text-align: right; }
  .bs-table__action::before { display: none; }
  .bs-customer { max-width: none; }
  .bs-breakdown { max-width: none; }
  .bs-pagination { align-items: flex-start; flex-direction: column; padding-inline: 16px; }
  .bs-pagination > div { width: 100%; }
  .bs-pagination .button { flex: 1; }
  .bs-loading,
  .bs-empty { margin-inline: 16px; }
  .bs-detail-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bs-detail-summary__main { grid-column: 1 / -1; }
  .bs-page dialog { padding: 18px; }
  .bs-dialog__header { gap: 10px; }
  .bs-grant { grid-template-columns: minmax(0, 1fr) auto; }
  .bs-grant small { grid-column: 1 / -1; }
  .bs-ledger__row { grid-template-columns: 1fr auto; }
  .bs-ledger__row strong { grid-row: 2; }
  .bs-ledger__row small { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  .bs-skeleton { animation: none; }
}

/* Search stays in view; occasional filters expand without moving focus. */
.bs-filters { grid-template-columns: minmax(220px,1fr) minmax(150px,.45fr) auto; }
.bs-search,.bs-filters__actions { grid-column: auto; }
.bs-extra { grid-column: 1 / -1; }
.bs-page .bs-extra summary { width: fit-content; font-size: 12px; padding: 4px 0 0; }
.bs-page .bs-extra[open] summary { margin-bottom: 12px; }
.bs-extra__fields { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; }
@media(max-width:700px) {
  .bs-filters { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .bs-search { grid-column: 1 / -1; }
  .bs-filters__actions .button { padding-inline: 10px; }
  .bs-extra__fields { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media(max-width:380px) {
  .bs-filters { grid-template-columns: minmax(0,1fr); }
  .bs-search { grid-column: auto; }
}
.bs-sort-controls { grid-column: 1 / -1; display:flex; gap:12px; padding-top:8px; border-top:1px solid var(--line); }
.bs-sort-controls label { flex:1; max-width:260px; }
.bs-column-sort { background:none; border:0; padding:6px 0; color:inherit; font:inherit; text-transform:inherit; letter-spacing:inherit; cursor:pointer; }
.bs-column-sort:hover,.bs-table th[aria-sort=ascending],.bs-table th[aria-sort=descending] { color:var(--text); }
.bs-column-sort:focus-visible { outline:2px solid var(--accent); outline-offset:4px; border-radius:3px; }

.bs-grant-form { grid-template-columns: repeat(2,minmax(0,1fr)); }
.bs-grant-form label:nth-of-type(5), .bs-grant-form p { grid-column: 1 / -1; }
.bs-grant-form p { margin: 0; color: var(--muted); font-size: 12px; }
@media (max-width: 520px) { .bs-grant-form { grid-template-columns: minmax(0,1fr); } }
