.sidebar-footer-stack {
  border-top: 1px solid var(--sia-line, #d7e8ee);
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
  min-width: 0;
  order: 90;
  padding-top: 14px;
  width: 100%;
}

@media (min-width: 901px) {
  .sidebar {
    overflow: hidden !important;
  }

  .sidebar > .sidebar-navigation-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
  }
}

.sia-credit-wallet {
  align-items: center;
  background: var(--sia-teal-soft, #e7f7f6);
  border: 1px solid var(--sia-line-strong, #c9dfe4);
  border-radius: 14px;
  color: var(--sia-teal-dark, #0f8585);
  display: flex;
  gap: 10px;
  margin: 0 8px;
  min-height: 44px;
  padding: 8px 12px;
}

.sia-credit-wallet-icon { align-items: center; display: grid; flex: 0 0 22px; font-size: 1.05rem; font-weight: 900; height: 22px; line-height: 1; place-items: center; width: 22px; }
.sia-credit-wallet-copy { display: flex; flex: 1; flex-direction: column; line-height: 1.15; min-width: 0; }
.sia-credit-wallet-copy span { color: var(--sia-muted, #71849f); font-size: .68rem; font-weight: 750; }
.sia-credit-wallet-copy strong { color: var(--sia-heading, #0d2343); font-size: .88rem; font-variant-numeric: tabular-nums; font-weight: 850; }
.sia-credit-wallet-copy [data-sia-credit-balance] { color: inherit; font-size: inherit; font-weight: inherit; }
.sidebar-footer-stack > .sidebar-user {
  border-top: 0 !important;
  margin-top: 0 !important;
  padding-top: 0 !important;
}

[data-credit-cost]::after {
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 999px;
  content: attr(data-credit-cost) " \2726";
  flex: 0 0 auto;
  font-size: .66rem;
  font-weight: 850;
  line-height: 1;
  margin-left: 3px;
  padding: 5px 7px;
  white-space: nowrap;
}

[data-credit-tone="secondary"]::after,
.button.secondary[data-credit-cost]::after,
.script-expand-button[data-credit-cost]::after {
  background: var(--sia-teal-soft, #e7f7f6);
  border-color: var(--sia-line-strong, #c9dfe4);
  color: var(--sia-teal-dark, #0f8585);
}

.sia-credit-modal-root { inset: 0; position: fixed; z-index: 10000; }
.sia-credit-modal-backdrop { background: rgba(10, 28, 43, .62); inset: 0; position: absolute; }
.sia-credit-modal {
  background: var(--sia-surface, #fff);
  border: 1px solid var(--sia-line, #d7e8ee);
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(8, 27, 42, .24);
  left: 50%;
  max-width: calc(100% - 32px);
  overflow: hidden;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 510px;
}
.sia-credit-modal-head { align-items: flex-start; border-bottom: 1px solid var(--sia-line, #d7e8ee); display: flex; gap: 16px; justify-content: space-between; padding: 24px 26px 20px; }
.sia-credit-modal-icon { align-items: center; background: var(--sia-teal-soft, #e7f7f6); border-radius: 14px; color: var(--sia-teal-dark, #0f8585); display: flex; flex: 0 0 48px; height: 48px; justify-content: center; }
.sia-credit-modal-icon svg { fill: none; height: 24px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; width: 24px; }
.sia-credit-modal-heading { flex: 1; min-width: 0; }
.sia-credit-modal-heading h2 { color: var(--sia-heading, #0d2343); font-size: 1.25rem; font-weight: 850; letter-spacing: 0; margin: 1px 0 5px; }
.sia-credit-modal-heading p { color: var(--sia-muted, #71849f); font-size: .86rem; line-height: 1.45; margin: 0; }
.sia-credit-modal-close { align-items: center; background: transparent; border: 1px solid var(--sia-line, #d7e8ee); border-radius: 50%; color: var(--sia-muted, #71849f); cursor: pointer; display: flex; flex: 0 0 38px; font-size: 1.35rem; height: 38px; justify-content: center; }
.sia-credit-modal-body { padding: 22px 26px; }
.sia-credit-summary { background: var(--sia-surface-soft, #f6fbfc); border: 1px solid var(--sia-line, #d7e8ee); border-radius: 16px; overflow: hidden; }
.sia-credit-summary-row { align-items: center; display: flex; justify-content: space-between; min-height: 48px; padding: 0 16px; }
.sia-credit-summary-row + .sia-credit-summary-row { border-top: 1px solid var(--sia-line, #d7e8ee); }
.sia-credit-summary-row span { color: var(--sia-muted, #71849f); font-size: .82rem; font-weight: 700; }
.sia-credit-summary-row strong { color: var(--sia-heading, #0d2343); font-size: .9rem; font-variant-numeric: tabular-nums; font-weight: 850; }
.sia-credit-summary-row.is-cost strong { color: var(--sia-teal-dark, #0f8585); }
.sia-credit-summary-row.is-insufficient strong { color: var(--sia-danger, #d95454); }
.sia-credit-modal-note { color: var(--sia-muted, #71849f); font-size: .72rem; line-height: 1.45; margin: 13px 2px 0; }
.sia-credit-modal-error { background: var(--sia-danger-soft, #fff5f3); border: 1px solid rgba(217, 84, 84, .25); border-radius: 12px; color: var(--sia-danger, #d95454); font-size: .78rem; font-weight: 750; margin-top: 12px; padding: 10px 12px; }
.sia-credit-modal-actions { border-top: 1px solid var(--sia-line, #d7e8ee); display: flex; gap: 10px; justify-content: flex-end; padding: 18px 26px 22px; }
.sia-credit-modal-actions button { border-radius: 12px; cursor: pointer; font: inherit; font-size: .84rem; font-weight: 850; min-height: 44px; padding: 0 18px; }
.sia-credit-cancel { background: var(--sia-surface, #fff); border: 1px solid var(--sia-line-strong, #c9dfe4); color: var(--sia-heading, #0d2343); }
.sia-credit-confirm { background: var(--sia-teal-dark, #0f8585); border: 1px solid var(--sia-teal-dark, #0f8585); color: #fff; }
.sia-credit-confirm:disabled { cursor: not-allowed; opacity: .48; }
.sia-credit-toast { align-items: center; background: var(--sia-heading, #0d2343); border: 1px solid var(--sia-line, #d7e8ee); border-radius: 14px; bottom: 22px; box-shadow: 0 14px 34px rgba(8, 27, 42, .2); color: #fff; display: flex; font-size: .8rem; font-weight: 750; gap: 9px; left: 50%; max-width: calc(100% - 32px); padding: 12px 16px; position: fixed; transform: translate(-50%, 20px); transition: opacity .2s ease, transform .2s ease; z-index: 10020; }
.sia-credit-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.sia-credit-toast:not(.is-visible) { opacity: 0; pointer-events: none; }

html[data-theme="dark"] .sia-credit-wallet { background: #173b39; border-color: #2d5c59; }
html[data-theme="dark"] .sia-credit-wallet-copy strong { color: #f2f7f8; }
html[data-theme="dark"] .sia-credit-modal-icon { background: #173b39; color: #80d8d2; }
html[data-theme="dark"] [data-credit-cost]::after { background: rgba(9, 21, 28, .22); border-color: rgba(255, 255, 255, .18); }
html[data-theme="dark"] [data-credit-tone="secondary"]::after,
html[data-theme="dark"] .button.secondary[data-credit-cost]::after,
html[data-theme="dark"] .script-expand-button[data-credit-cost]::after { background: #173b39; border-color: #2d5c59; color: #80d8d2; }

@media (max-width: 900px) {
  .sia-credit-wallet { flex: 0 0 auto; margin: 0; min-width: 138px; }
  .sidebar-footer-stack { border-top: 0; display: none; margin: 0; padding: 0; }
}

@media (max-width: 560px) {
  [data-credit-cost]::after { font-size: .62rem; padding: 4px 6px; }
  .sia-credit-modal-head { padding: 20px 18px 16px; }
  .sia-credit-modal-icon { display: none; }
  .sia-credit-modal-body { padding: 18px; }
  .sia-credit-modal-actions { display: grid; grid-template-columns: 1fr; padding: 16px 18px 18px; }
  .sia-credit-confirm { grid-row: 1; }
}
