.ap-credits { display: inline-flex; align-items: center; gap: 8px; }
.ap-credits-pill {
    display: inline-flex; align-items: center; gap: 6px;
    height: 30px; padding: 0 12px; border-radius: 999px;
    background: var(--buld-elevated, #E8E8ED); color: var(--buld-ink-1, #1d1d1f);
    border: 1px solid var(--buld-hairline, rgba(0,0,0,.1));
    font-family: inherit; font-size: 13px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums;
    cursor: pointer; transition: transform 120ms ease, border-color 150ms ease;
}
.ap-credits-pill svg { width: 14px; height: 14px; color: var(--buld-cta, #0071E3); }
.ap-credits-pill:hover { transform: translateY(-1px); border-color: var(--buld-cta, #0071E3); }
.ap-credits-pill.is-low { border-color: var(--buld-danger); }
.ap-credits-pill.is-low svg { color: var(--buld-danger); }
/* The separate "+ Recharger" button is gone: the credits chip (.ap-credits-chip, premium.css) carries the "+". */
.ap-credits-pill:focus-visible { outline: 2px solid var(--buld-cta, #0071E3); outline-offset: 2px; }

.ap-bill-backdrop {
    position: fixed; inset: 0; z-index: 10000; display: none;
    align-items: center; justify-content: center; padding: 16px;
    background: rgba(0, 0, 0, .45); backdrop-filter: blur(4px);
}
.ap-bill-backdrop.is-open { display: flex; }
.ap-bill-card {
    width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto;
    background: var(--buld-elevated-2, var(--buld-elevated, #fff)); color: var(--buld-ink-1, #1d1d1f);
    border: 1px solid var(--buld-hairline, rgba(0,0,0,.1)); border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
.ap-bill-body { padding: 22px 24px 24px; }
.ap-bill-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.ap-bill-head h2 { margin: 0; font-size: 19px; font-weight: 700; }
.ap-bill-x { background: none; border: none; color: inherit; font-size: 26px; line-height: 1; cursor: pointer; opacity: .7; }
.ap-bill-x:hover { opacity: 1; }
.ap-bill-body h3 { margin: 20px 0 10px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--buld-ink-3, #6E6E73); }
.ap-bill-balance {
    display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border-radius: 14px;
    background: var(--buld-cta, #0071E3); color: #fff;
}
.ap-bill-balance span, .ap-bill-balance small { opacity: .85; font-size: 13px; }
.ap-bill-balance strong { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ap-bill-balance.is-low { background: var(--buld-danger); }
.ap-bill-balance.is-error { background: var(--buld-ink-4); }
.ap-bill-balance.is-loading { background: var(--buld-ink-3); }
.ap-bill-balance small { line-height: 1.45; }
.ap-bill-retry {
    align-self: flex-start; margin-top: 8px; padding: 7px 16px; border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .55); background: rgba(255, 255, 255, .14); color: #fff;
    font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.ap-bill-retry:hover { background: rgba(255, 255, 255, .24); }
.ap-bill-link {
    border: none; background: none; padding: 0; font: inherit; color: var(--buld-cta, #0071E3);
    text-decoration: underline; cursor: pointer;
}
.ap-credits-pill.is-loading { opacity: .6; }
.ap-credits-pill.is-error { border-color: var(--buld-divider); color: var(--buld-ink-3, #6E6E73); }
.ap-bill-prices, .ap-bill-history { list-style: none; margin: 0; padding: 0; }
.ap-bill-prices li, .ap-bill-history li {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 9px 0; border-bottom: 1px solid var(--buld-hairline, rgba(0,0,0,.1)); font-size: 14px;
}
.ap-bill-prices li:last-child, .ap-bill-history li:last-child { border-bottom: none; }
.ap-bill-packs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.ap-bill-pack {
    display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px;
    border-radius: 12px; border: 1px solid var(--buld-hairline, rgba(0,0,0,.1));
    background: transparent; color: inherit; cursor: pointer; text-align: start;
    transition: border-color 150ms ease, transform 120ms ease;
}
.ap-bill-pack:hover { border-color: var(--buld-cta, #0071E3); transform: translateY(-1px); }
.ap-bill-pack-credits { font-weight: 700; font-size: 15px; }
.ap-bill-pack-price { font-size: 13px; color: var(--buld-ink-3, #6E6E73); }
.ap-bill-notice {
    margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; font-size: 13px; line-height: 1.5;
    background: var(--buld-cta-soft); border: 1px solid var(--buld-cta);
}
.ap-bill-h-reason { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-bill-h-date { font-size: 12px; color: var(--buld-ink-3, #6E6E73); white-space: nowrap; }
.ap-bill-history .is-neg { color: var(--buld-danger); }
.ap-bill-history .is-pos { color: var(--buld-success); }
.ap-bill-muted { color: var(--buld-ink-3, #6E6E73); font-size: 14px; }

@media (max-width: 720px) {
    .ap-credits-pill { padding: 0 10px; }
}

/* Attention is earned: the pulse only runs on a balance that is at or under the low threshold, or on a
   read the server refused. It is a two-second glow on a control already in the layout, so nothing shifts. */
@keyframes apRechargeAttention {
    0%, 100% { box-shadow: 0 0 0 0 var(--buld-cta-soft); }
    50% { box-shadow: 0 0 0 6px transparent; }
}
.ap-credits-chip.needs-attention, .ap-credits-pill.needs-attention { animation: apRechargeAttention 2.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
    .ap-credits-chip.needs-attention, .ap-credits-pill.needs-attention { animation: none; outline: 2px solid var(--buld-cta); outline-offset: 2px; }
}
