/* =====================================================================================================================
   Budgets > Rebalance (BudgetRebalanceDialog): the "This period only / From now on" switch, the summary card (what moves,
   lines running over before and after, the total that stays), one row per line with before and after bars, the expected
   need as a tick, the share of the move, Chip In Intelligence's note and a lock; the lines a rebalance never moves under
   "Not included". Built on the dialog frame of budgets-area.css (bg-dlg) and the Reports tones (--rp-*). Phone first.
   ===================================================================================================================== */

.rb-dialog .e-dlg-content { height: auto; }
.rb-chip-icon { background: var(--bg-icon-bg); color: var(--bg-icon); }
.rb-head-pill { margin-left: auto; align-self: center; }
.rb-head-pill + .rc-icon-btn { margin-left: 0; }
.rb-body { display: flex; flex-direction: column; gap: 14px; padding-top: 6px; }

/* ---- Mode switch ------------------------------------------------------------------------------------------------ */
.rb-mode { display: flex; flex-direction: column; gap: 6px; }
.rb-mode-seg { width: 100%; }
.rb-mode-caption { display: flex; align-items: flex-start; gap: 6px; margin: 0; font-size: 12.5px; line-height: 1.45; }
.rb-mode-caption .tx-glyph, .rb-mode-caption i { margin-top: 2px; color: var(--bg-icon); }

/* ---- Thinking and skeleton -------------------------------------------------------------------------------------- */
.rb-thinking { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 14px; background: var(--bg-ai-soft); border: 1px solid var(--bg-glass-border); }
.rb-thinking-copy { display: flex; flex-direction: column; min-width: 0; }
.rb-thinking-copy strong { font-size: 14px; color: var(--rp-text); }
.rb-thinking-copy span { font-size: 12.5px; color: var(--rp-muted); }
.rb-orb { display: inline-grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; border-radius: 12px; background: var(--rp-ai-grad); color: #FFFFFF; font-size: 15px; }
.rb-thinking .rb-orb { animation: rb-pulse 1.6s ease-in-out infinite; }
@keyframes rb-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.94); opacity: .82; } }
.rb-skeleton { display: grid; gap: 10px; }
.rb-bone { display: block; height: 72px; border-radius: 14px; }

.rb-error { align-items: center; }
.rb-retry { margin-left: auto; white-space: nowrap; }
.rb-notice { display: flex; align-items: flex-start; gap: 8px; margin: 0; padding: 10px 12px; border-radius: 12px; background: var(--rp-caution-soft); color: var(--rp-caution); font-size: 13px; line-height: 1.4; }
.rb-upsell { margin-top: 2px; }

/* ---- Summary ---------------------------------------------------------------------------------------------------- */
.rb-summary { display: flex; flex-direction: column; gap: 12px; padding: 14px; border-radius: var(--bg-radius, 16px); border: 1px solid var(--bg-hero-border); background: var(--bg-hero-bg); }
.rb-summary.is-balanced .rb-orb { background: var(--rp-positive-soft); color: var(--rp-positive); }
.rb-summary-head { display: flex; align-items: flex-start; gap: 12px; }
.rb-summary-copy { min-width: 0; }
.rb-summary-copy h3 { margin: 0 0 2px; font-size: 16px; font-weight: 700; line-height: 1.3; color: var(--bg-hero-text); }
.rb-summary-copy p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--bg-hero-muted); }
.rb-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.rb-stat { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 12px; background: var(--bg-glass); border: 1px solid var(--bg-glass-border); min-width: 0; }
.rb-stat small { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--bg-hero-muted); }
.rb-stat b { font-size: 16px; font-weight: 700; color: var(--bg-hero-text); white-space: nowrap; }
.rb-stat b i { font-style: normal; color: var(--bg-hero-muted); font-weight: 500; }
.rb-stat em { font-style: normal; font-size: 11px; color: var(--rp-positive); }
.rb-ai-line { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; font-size: 12px; color: var(--bg-hero-muted); }
.rb-ai-line:empty { display: none; }
.rb-ai-line > span { display: inline-flex; align-items: center; gap: 6px; }
.rb-ai-line .tx-glyph, .rb-ai-line i { color: var(--bg-icon); }
@media (min-width: 640px) {
    .rb-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---- Lines ------------------------------------------------------------------------------------------------------ */
.rb-lines { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.rb-line {
    position: relative;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    grid-template-areas: "icon main lock" "icon amounts amounts";
    gap: 4px 10px;
    padding: 12px 12px 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--tx-tile-border, var(--rp-card-border));
    background: var(--rp-card);
    overflow: hidden;
}
.rb-line::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--rb-tone, transparent); }
.rb-line.is-take { --rb-tone: var(--rp-positive); --rb-after: var(--rp-positive); }
.rb-line.is-give { --rb-tone: var(--rp-accent); --rb-after: var(--rp-accent); }
.rb-line.is-keep { --rb-after: var(--rp-muted); }
.rb-line.is-locked { --rb-tone: var(--rp-caution); --rb-after: var(--rp-caution); background: color-mix(in srgb, var(--rp-card) 92%, var(--rp-caution-soft)); }
.rb-line-icon { grid-area: icon; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: color-mix(in srgb, var(--rb-line, var(--bg-icon)) 16%, transparent); color: var(--rb-line, var(--bg-icon)); font-size: 14px; }
.rb-line-main { grid-area: main; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.rb-line-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; }
.rb-line-name { font-size: 14px; font-weight: 650; color: var(--rp-text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rb-role.rp-tone-accent { --rp-tone: var(--rp-accent); --rp-tone-soft: var(--rp-accent-soft); background: var(--rp-accent-soft); color: var(--rp-accent); }
.rb-role.rp-tone-positive { background: var(--rp-positive-soft); color: var(--rp-positive); }
.rb-role.rp-tone-caution { background: var(--rp-caution-soft); color: var(--rp-caution); }
.rb-bars { position: relative; display: flex; flex-direction: column; gap: 3px; padding: 2px 0; }
.rb-bar { display: block; height: 6px; border-radius: 999px; background: var(--rp-track); overflow: hidden; }
.rb-bar > i { display: block; height: 100%; border-radius: inherit; transition: width .35s ease; }
.rb-bar.is-before > i { background: color-mix(in srgb, var(--rp-muted) 45%, transparent); }
.rb-bar.is-after > i { background: var(--rb-after, var(--rp-muted)); }
.rb-pace { position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; border-radius: 2px; background: var(--bg-today); opacity: .75; }
.rb-line-sentence { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--rp-muted); }
.rb-line-ai { display: flex; align-items: flex-start; gap: 6px; margin: 0; padding: 6px 8px; border-radius: 10px; background: var(--bg-ai-soft); font-size: 12.5px; line-height: 1.45; color: var(--rp-text); }
.rb-line-ai .tx-glyph, .rb-line-ai i { margin-top: 2px; color: var(--bg-icon); }
.rb-line-amounts { grid-area: amounts; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.rb-before { font-size: 12.5px; color: var(--rp-muted); }
.rb-after { font-size: 15px; font-weight: 700; color: var(--rp-text); white-space: nowrap; }
.rb-delta { font-size: 12px; font-weight: 650; color: var(--rp-muted); white-space: nowrap; }
.rb-delta.is-up { color: var(--rp-positive); }
.rb-delta.is-down { color: var(--rp-accent); }
.rb-lock { grid-area: lock; align-self: start; }
.rb-lock.is-on { color: var(--rp-caution); border-color: color-mix(in srgb, var(--rp-caution) 45%, transparent); background: var(--rp-caution-soft); }
@media (min-width: 640px) {
    .rb-line { grid-template-columns: 34px minmax(0, 1fr) minmax(112px, auto) auto; grid-template-areas: "icon main amounts lock"; align-items: start; }
    .rb-line-amounts { flex-direction: column; align-items: flex-end; text-align: right; gap: 2px; }
}

/* ---- Not included, tips, method, footer ------------------------------------------------------------------------- */
.rb-excluded { border-radius: 12px; border: 1px dashed var(--tx-border, var(--rp-card-border)); padding: 8px 12px; }
.rb-excluded summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; font-size: 13px; font-weight: 650; color: var(--rp-muted); }
.rb-excluded summary::-webkit-details-marker { display: none; }
.rb-excluded-caret { transition: transform .2s ease; font-size: 11px; }
.rb-excluded[open] .rb-excluded-caret { transform: rotate(90deg); }
.rb-excluded ul { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 2px; padding: 0; list-style: none; }
.rb-excluded li { display: grid; grid-template-columns: 18px auto minmax(0, 1fr); align-items: baseline; gap: 8px; font-size: 12.5px; color: var(--rp-muted); }
.rb-excluded li strong { color: var(--rp-text); font-weight: 600; white-space: nowrap; }
.rb-tips { display: flex; flex-direction: column; gap: 6px; }
.rb-tips p { display: flex; align-items: flex-start; gap: 8px; margin: 0; padding: 8px 10px; border-radius: 10px; background: var(--rp-gold-soft); color: var(--rp-text); font-size: 12.5px; line-height: 1.45; }
.rb-tips p .tx-glyph, .rb-tips p i { margin-top: 2px; color: var(--rp-gold); }
.rb-method { display: flex; align-items: flex-start; gap: 6px; margin: 0; font-size: 12px; line-height: 1.45; }
.rb-foot-note { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.rb-apply:disabled { opacity: .55; }

/* ---- The hub's Rebalance button ---------------------------------------------------------------------------------- */
.bg-rebalance-btn { gap: 6px; }
.bg-rebalance-btn .bg-rebalance-pill { padding: 1px 7px; font-size: 10px; }

@media (prefers-reduced-motion: reduce) {
    .rb-thinking .rb-orb { animation: none; }
    .rb-bar > i, .rb-excluded-caret { transition: none; }
}
