/*
 * YousoroFinance redesign-web — «Эфир» dark mode: re-maps legacy dark surfaces onto graphite tokens.
 * style.css ships a teal-tinted dark palette (#1c2327, #202a2c, #172e28…) for «Малахит»; every rule
 * here only neutralises one of those leaks inside «Эфир». Palette itself lives in tokens.css.
 * Subscriptions / Founder / package purchase keep their original look on purpose (product decision).
 */

/* Modal bodies: the surface belongs to .modal-content */
:root body.yf-redesign.yf-dashboard-auth.dark-theme .modal-body {
    border-color: var(--rd-line) !important;
    background: transparent !important;
    color: var(--rd-ink-2) !important;
}

/* Grouped panels inside modals and account settings */
:root body.yf-redesign.yf-dashboard-auth.dark-theme :is(.yf-balance-form, .yf-transaction-history, .yf-saved-links, .yf-subscription-status > div) {
    border-color: var(--rd-line) !important;
    background: var(--rd-surface-grouped) !important;
    color: var(--rd-ink) !important;
}
:root body.yf-redesign.yf-dashboard-auth.dark-theme :is(.yf-modal-table th, .yf-modal-table td) {
    border-color: var(--rd-line-soft) !important;
    background: transparent !important;
    color: var(--rd-ink-2) !important;
}

/* Finance tables and their empty states */
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-dashboard-shell .main-table { background: transparent !important; }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .main-table td.text-muted { background: var(--rd-surface) !important; color: var(--rd-muted) !important; }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-table-empty {
    border-color: var(--rd-line) !important;
    background: rgba(23, 24, 27, .94) !important;
}

/* Income KPI completion card and donut */
:root body.yf-redesign.yf-dashboard-auth.dark-theme :is(.yf-income-kpi__completion, .yf-income-kpi__metric, .yf-income-kpi__detail-grid > div) {
    border-color: var(--rd-line-soft);
    background: var(--rd-surface-grouped);
}
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-income-kpi__donut {
    background:
        radial-gradient(circle closest-side, var(--rd-surface-grouped) 70%, transparent 72%),
        conic-gradient(var(--rd-positive) var(--income-kpi-progress, 0%), var(--rd-fill) 0);
}
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-income-kpi__rows > div { border-bottom-color: var(--rd-line-soft); }

/* Calendars: legend, day summary, notes */
:root body.yf-redesign.yf-dashboard-auth.dark-theme :is(.yf-income-calendar__legend, .yf-income-calendar-day__summary) {
    border-color: var(--rd-line-soft);
    background: var(--rd-surface-grouped);
}
:root body.yf-redesign.yf-dashboard-auth.dark-theme :is(.yf-income-calendar-day__rows, .yf-income-calendar-day__row) { border-color: var(--rd-line-soft); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-income-calendar-day__note { background: var(--rd-fill-soft); color: var(--rd-muted); }

/* Shared loading skeletons */
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-skeleton { --yf-skeleton-base: rgba(120, 120, 128, .16); --yf-skeleton-highlight: rgba(120, 120, 128, .28); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-skeleton-block {
    background: linear-gradient(90deg, rgba(120, 120, 128, .16) 25%, rgba(120, 120, 128, .28) 50%, rgba(120, 120, 128, .16) 75%);
    background-size: 220% 100%;
}

/* Onboarding tooltip */
:root body.yf-redesign.yf-dashboard-auth.dark-theme .tooltipTutorial {
    border-color: var(--rd-line);
    background: var(--rd-surface-raised);
    color: var(--rd-ink);
    box-shadow: var(--rd-shadow-raised);
}
:root body.yf-redesign.yf-dashboard-auth.dark-theme .tooltipTutorial p { color: var(--rd-muted); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .tooltipTutorial #progressTutorial { background: var(--rd-accent-soft); color: var(--rd-accent-ink); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .tooltipTutorial #close-btn { border-color: var(--rd-line); color: var(--rd-muted); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .tooltipTutorial #close-btn:hover { background: var(--rd-fill); color: var(--rd-ink); }

/* Popovers and menus */
:root body.yf-redesign.yf-dashboard-auth.dark-theme :is(.yf-comment-suggestions, .yf-plan-feature-popover) {
    border-color: var(--rd-line);
    background: var(--rd-menu-bg);
    box-shadow: var(--rd-shadow-raised);
}

/* YouFiHub overlays */
:root body.yf-redesign.yf-dashboard-auth.dark-theme :is(.yf-rewards-settings, .yf-rewards-notice) { background: rgba(0, 0, 0, .5); }

/* Avatar editor */
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-avatar-editor__stage { border-color: var(--rd-line); background: var(--rd-surface-grouped); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-avatar-editor__tools button { border-color: var(--rd-line); background: var(--rd-fill-soft); color: var(--rd-ink-2); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-avatar-editor__tools button:hover { background: var(--rd-fill); color: var(--rd-ink); }

/* Currency picker flag bubble */
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-currency-picker__option > span:first-child { background: var(--rd-fill-soft); }

/* Error report dialog fields (legacy .dark-theme input is slate blue) */
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-error-report__dialog :is(input:not([type="checkbox"], [type="radio"]), textarea) {
    background-color: var(--rd-fill-soft) !important;
    color: var(--rd-ink) !important;
}

/* Install-app (PWA) modal */
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-pwa-modal__header { border-color: var(--rd-line-soft); background: transparent; }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-pwa-platform { border-color: var(--rd-line); background: var(--rd-surface-grouped); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-pwa-platform:hover { border-color: var(--rd-accent-ring); background: var(--rd-row-hover); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-pwa-modal__instructions { border-color: var(--rd-line); background: var(--rd-surface-grouped); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-pwa-modal__safari-transfer code { border-color: var(--rd-line); background: var(--rd-canvas); color: var(--rd-ink-2); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-pwa-modal__note { border-color: var(--rd-line-soft); }

/* Support centre palette */
:root body.yf-redesign.yf-dashboard-auth.dark-theme :is(.yf-support, .yf-support-modal) {
    --support-bg: var(--rd-surface);
    --support-soft: var(--rd-surface-grouped);
    --support-line: var(--rd-line);
    --support-ink: var(--rd-ink);
    --support-muted: var(--rd-muted);
    --support-green: var(--rd-accent-ink);
}

/* «Финансовый ИИ» palette */
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-finance-ai {
    --ai-ink: var(--rd-ink);
    --ai-muted: var(--rd-muted);
    --ai-line: var(--rd-line);
    --ai-surface: var(--rd-surface);
    --ai-soft: var(--rd-surface-grouped);
    --ai-green: var(--rd-accent);
    --ai-green-strong: var(--rd-accent-hover);
    --ai-green-soft: var(--rd-accent-soft);
    --ai-red-soft: var(--rd-negative-soft);
    --ai-amber-soft: var(--rd-warning-soft);
    --ai-blue-soft: var(--rd-info-soft);
}
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-finance-ai :is(input, select, textarea) {
    border-color: var(--rd-line) !important;
    background: var(--rd-surface-grouped) !important;
    color: var(--rd-ink) !important;
}
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-finance-ai__scenario-presets button { border-color: var(--rd-line); background: var(--rd-fill-soft); color: var(--rd-ink-2); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-finance-ai__evidence span { background: var(--rd-fill-soft); color: var(--rd-muted); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-finance-ai__forecast-period button.is-active { background: var(--rd-surface-raised); color: var(--rd-ink); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme :is(.yf-finance-ai__preview > div, .yf-finance-ai__insight, .yf-finance-ai__action, .yf-finance-ai__metric, .yf-finance-ai__history-item) { border-color: var(--rd-line-soft); }

/* Wordmark: white lettering on the graphite bar */
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-authorized-nav .yf-nav-wordmark--dark { display: none; }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-authorized-nav .yf-nav-wordmark--light { display: block; }

/* Income / expense calendars: same structure as «Малахит», graphite surfaces */
:root body.yf-redesign.yf-dashboard-auth.dark-theme :is(.yf-income-calendar-card, .yf-income-calendar-day-cell, .yf-income-calendar-card__nav) {
    border-color: var(--rd-line-soft);
    background: var(--rd-surface-raised);
    color: var(--rd-ink-2);
}
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-income-calendar-card { box-shadow: var(--rd-shadow-hairline); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-income-calendar-card.is-selected {
    border-color: rgba(52, 211, 153, .5);
    background: linear-gradient(180deg, rgba(52, 211, 153, .1), var(--rd-surface-raised) 25%);
    box-shadow: 0 0 0 1px rgba(52, 211, 153, .16), 0 12px 30px -12px rgba(0, 0, 0, .6);
}
:root body.yf-redesign.yf-dashboard-auth.dark-theme :is(.yf-income-calendar-card__header, .yf-income-calendar-card__footer, .yf-income-calendar-card__days) { border-color: var(--rd-line-soft); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme :is(.yf-income-calendar-card__header strong, .yf-income-calendar-day-cell > strong) { color: var(--rd-ink); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme :is(.yf-income-calendar-card.is-selected .yf-income-calendar-card__header strong, .yf-income-calendar-card__footer strong) { color: var(--rd-accent-ink); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-income-calendar-day-cell.has-income { background: linear-gradient(180deg, var(--rd-surface-raised) 45%, rgba(52, 211, 153, .09) 100%); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-income-calendar-day-cell:not(:disabled):is(:hover, :focus-visible) { background: #25262b; }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-income-calendar-day-cell.is-outside { background: #141518 !important; color: var(--rd-subtle) !important; }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-income-calendar-day-cell.is-outside.has-income { background: linear-gradient(180deg, #141518 42%, rgba(52, 211, 153, .06) 100%) !important; }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-income-calendar-day-cell.is-outside > strong { color: var(--rd-subtle) !important; }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-calendar-plan-button { border-color: var(--rd-accent-ring); background: var(--rd-accent-soft); color: var(--rd-accent-ink); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-income-calendar__legend-item { border-color: var(--rd-line); color: var(--rd-ink-2); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-income-calendar-day__edit { border-color: var(--rd-line-soft); background: var(--rd-surface-raised); color: var(--rd-ink-2); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-calendar-skeleton { background: var(--rd-surface-raised); }

/* Empty table cells: the resting dot stays visible on graphite */
:root body.yf-redesign.yf-dashboard-auth.dark-theme .main-table .table-tag-minus::before { background: rgba(255, 255, 255, .18); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .main-table td:hover > .table-tag-minus::before { background: var(--rd-accent-ink); }

/* Preloader: white wordmark on dark frosted glass */
:root body.yf-redesign.yf-dashboard-auth.dark-theme #preloader { background: rgba(12, 13, 15, .38) !important; }
:root body.yf-redesign.yf-dashboard-auth.dark-theme #preloader::before { background-image: var(--yf-preloader-mark, url("../../images/brand/yousoro-text-white.webp")); --rd-brand-dim: .62; filter: opacity(.62); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme #loader { border-color: rgba(255, 255, 255, .12); border-top-color: rgba(255, 255, 255, .62); }

/* Site footer, dark «Эфир» only: deep graphite with a faint emerald glow instead of the forest-green slab */
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-footer.yf-public-footer {
    border-top: 1px solid rgba(255, 255, 255, .06);
    background:
        radial-gradient(900px 320px at 12% 0%, rgba(52, 211, 153, .07), transparent 62%),
        radial-gradient(700px 280px at 92% 100%, rgba(110, 168, 255, .04), transparent 60%),
        #0e0f11;
}
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-footer.yf-public-footer .yf-footer__languages { border-color: rgba(255, 255, 255, .08); background: rgba(255, 255, 255, .03); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-footer.yf-public-footer .yf-footer__languages a:hover,
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-footer.yf-public-footer .yf-footer__languages a[aria-current="page"] { color: #06251b; background: var(--rd-accent-ink); }
:root body.yf-redesign.yf-dashboard-auth.dark-theme .yf-footer__payments { border-top-color: rgba(255, 255, 255, .06); }
