/* Единая тёмная премиальная оболочка портала. */
.app-sidebar,
.topbar-context,
.topbar-live-indicator,
.topbar-clock {
    display: none;
}

[data-theme="dark"] {
    --bg: #030b16;
    --bg-elevated: #071320;
    --surface: #081827;
    --surface-subtle: #0a1c2c;
    --surface-strong: #0d2234;
    --text: #ecf7ff;
    --text-soft: #9eb2c7;
    --text-muted: #71869b;
    --line: rgba(113, 154, 188, 0.2);
    --line-strong: rgba(112, 174, 212, 0.34);
    --gold: #ffac37;
    --gold-soft: rgba(255, 172, 55, 0.16);
    --wine: #ff5e70;
    --emerald: #16d7b3;
    --emerald-dark: #35f0ca;
    --emerald-soft: rgba(22, 215, 179, 0.13);
    --emerald-pale: rgba(22, 215, 179, 0.07);
    --ink: #ecf7ff;
    --danger: #ff5e62;
    --warning: #ff9f1c;
    --shadow-soft: 0 16px 38px rgba(0, 0, 0, 0.3);
    --shadow-strong: 0 28px 72px rgba(0, 0, 0, 0.46);
    --radius: 8px;
    color-scheme: dark;
}

[data-theme="dark"] html,
[data-theme="dark"] body {
    background: #030b16;
}

[data-theme="dark"] body {
    min-height: 100vh;
    color: var(--text);
    background:
        linear-gradient(rgba(33, 86, 119, 0.055) 1px, transparent 1px) 0 0 / 36px 36px,
        linear-gradient(90deg, rgba(33, 86, 119, 0.055) 1px, transparent 1px) 0 0 / 36px 36px,
        radial-gradient(circle at 78% -12%, rgba(16, 216, 180, 0.08), transparent 30rem),
        #030b16;
}

[data-theme="dark"] .page-shell {
    width: 100%;
    max-width: none;
    min-height: 100vh;
    margin: 0;
    padding: 88px 18px 38px 214px;
}

[data-theme="dark"] .page-shell > main,
[data-theme="dark"] .page-shell > .alerts {
    width: min(100%, 1740px);
    margin-inline: auto;
}

/* Калькулятор результата использует всю доступную ширину на широких экранах. */
[data-theme="dark"] .page-shell.yavka-plan-page > main {
    width: 100%;
    max-width: none;
    margin-inline: 0;
}

/* Контроль УИК также использует всю свободную ширину, чтобы таблица не
   прокручивалась по горизонтали там, где экран уже позволяет показать её целиком. */
[data-theme="dark"] .page-shell.kpi-page > main {
    width: 100%;
    max-width: none;
    margin-inline: 0;
}

[data-theme="dark"] .app-sidebar {
    position: fixed;
    z-index: 100;
    inset: 0 auto 0 0;
    width: 196px;
    display: flex;
    flex-direction: column;
    color: #ccdae8;
    border-right: 1px solid rgba(102, 147, 184, 0.22);
    background: linear-gradient(180deg, #020914 0%, #04101c 60%, #03101a 100%);
    box-shadow: 14px 0 38px rgba(0, 0, 0, 0.22);
}

[data-theme="dark"] .app-sidebar-brand {
    min-height: 80px;
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    color: #f4fbff;
    border-bottom: 1px solid rgba(102, 147, 184, 0.2);
    font-size: 0.86rem;
    font-weight: 650;
    line-height: 1.16;
}

[data-theme="dark"] .app-sidebar-brand .brand-mark {
    width: 56px;
    height: 56px;
    color: var(--emerald);
    box-shadow: none;
}

[data-theme="dark"] .app-sidebar-brand strong {
    color: var(--emerald);
}

[data-theme="dark"] .app-sidebar-nav {
    min-height: 0;
    display: grid;
    align-content: start;
    gap: 4px;
    padding: 14px 10px;
    overflow-y: auto;
}

[data-theme="dark"] .app-sidebar .site-menu-item {
    min-height: 48px;
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    color: #9fb1c4;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    box-shadow: none;
}

[data-theme="dark"] .app-sidebar .site-menu-item:hover {
    color: #edf8ff;
    border-color: rgba(45, 228, 194, 0.16);
    background: rgba(15, 47, 68, 0.58);
}

[data-theme="dark"] .app-sidebar .site-menu-item-active {
    color: #3df1cd;
    border-color: rgba(39, 224, 190, 0.22);
    background: linear-gradient(90deg, rgba(22, 215, 179, 0.18), rgba(12, 43, 62, 0.64));
    box-shadow: inset 3px 0 0 var(--emerald);
}

[data-theme="dark"] .app-sidebar .site-menu-item-icon {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    color: currentColor;
    border-radius: 6px;
    background: transparent;
}

[data-theme="dark"] .app-sidebar .site-menu-item-copy {
    min-width: 0;
}

[data-theme="dark"] .app-sidebar .site-menu-item-copy strong {
    display: block;
    overflow: hidden;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.22;
    text-overflow: ellipsis;
}

[data-theme="dark"] .app-sidebar .site-menu-item-copy small,
[data-theme="dark"] .app-sidebar .site-menu-item-arrow {
    display: none;
}

[data-theme="dark"] .app-sidebar-footer {
    display: grid;
    gap: 9px;
    margin-top: auto;
    padding: 15px;
    color: #758ba0;
    border-top: 1px solid rgba(102, 147, 184, 0.17);
    font-size: 0.68rem;
}

[data-theme="dark"] .app-sidebar-footer a:hover {
    color: var(--emerald);
}

[data-theme="dark"] .app-sidebar-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

[data-theme="dark"] .app-sidebar-status i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #23df88;
    box-shadow: 0 0 12px rgba(35, 223, 136, 0.76);
}

[data-theme="dark"] .topbar {
    position: fixed;
    z-index: 90;
    inset: 0 0 auto 196px;
    min-height: 72px;
    height: 72px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin: 0;
    padding: 0 18px;
    color: #e8f3fb;
    border: 0;
    border-bottom: 1px solid rgba(102, 147, 184, 0.24);
    border-radius: 0;
    background: rgba(2, 10, 20, 0.92);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(18px);
}

[data-theme="dark"] .topbar-brand {
    display: none;
}

[data-theme="dark"] .topbar-context {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--emerald);
}

[data-theme="dark"] .topbar-context-icon {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(22, 215, 179, 0.3);
    border-radius: 7px;
    background: rgba(22, 215, 179, 0.08);
}

[data-theme="dark"] .topbar-context strong {
    overflow: hidden;
    font-size: 1rem;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

[data-theme="dark"] .topbar-actions {
    flex-wrap: nowrap;
}

.logout-form {
    margin: 0;
}

[data-theme="dark"] .topbar-logout-button {
    min-width: 102px;
    min-height: 44px;
    padding-inline: 13px;
    white-space: nowrap;
}

[data-theme="dark"] .topbar-logout-button:hover {
    color: #e9fbf7;
    border-color: rgba(57, 246, 207, 0.52);
    background: #0b2432;
}

[data-theme="dark"] .topbar-logout-button:active {
    transform: translateY(1px);
}

[data-theme="dark"] .topbar-logout-button:focus-visible,
[data-theme="dark"] .logout-form-mobile .mobile-icon-button:focus-visible {
    outline: 3px solid rgba(57, 246, 207, 0.42);
    outline-offset: 3px;
}

[data-theme="dark"] .topbar-live-indicator,
[data-theme="dark"] .topbar-clock {
    display: inline-flex;
}

[data-theme="dark"] .topbar-live-indicator {
    align-items: center;
    gap: 7px;
    padding: 0 14px;
    color: #35e98c;
    border-inline: 1px solid rgba(102, 147, 184, 0.22);
    font-size: 0.74rem;
}

[data-theme="dark"] .topbar-live-indicator > span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #35e98c;
    box-shadow: 0 0 12px rgba(53, 233, 140, 0.78);
}

[data-theme="dark"] .topbar-clock {
    min-width: 102px;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    padding-inline: 4px;
    font-variant-numeric: tabular-nums;
}

[data-theme="dark"] .topbar-clock strong {
    font-size: 0.85rem;
}

[data-theme="dark"] .topbar-clock small {
    color: #8297aa;
    font-size: 0.66rem;
}

[data-theme="dark"] .topbar-actions > .site-menu {
    display: none;
}

[data-theme="dark"] .topbar .button-secondary,
[data-theme="dark"] .topbar .mobile-icon-button {
    color: #aebfd0;
    border-color: rgba(104, 153, 190, 0.28);
    background: #071727;
}

[data-theme="dark"] .topbar .button-primary {
    color: #04130f;
    border-color: rgba(57, 246, 207, 0.42);
    background: linear-gradient(135deg, #3cf2cc, #14cda9);
    box-shadow: 0 0 24px rgba(22, 215, 179, 0.2);
}

[data-theme="dark"] .topbar .button-primary:hover {
    box-shadow: 0 0 28px rgba(22, 215, 179, 0.34);
}

[data-theme="dark"] .hero,
[data-theme="dark"] .table-card,
[data-theme="dark"] .metric-card,
[data-theme="dark"] .import-card,
[data-theme="dark"] .alert,
[data-theme="dark"] .results-controls,
[data-theme="dark"] .results-leaderboard,
[data-theme="dark"] .reconcile-card,
[data-theme="dark"] .reconcile-progress-card,
[data-theme="dark"] .sections-hero,
[data-theme="dark"] .sections-directory,
[data-theme="dark"] .eg-hero,
[data-theme="dark"] .kpi-intro,
[data-theme="dark"] .kpi-filter-card,
[data-theme="dark"] .kpi-panel,
[data-theme="dark"] .kpi-empty,
[data-theme="dark"] .kpi-message {
    color: var(--text);
    border-color: rgba(83, 137, 176, 0.24);
    background: linear-gradient(145deg, rgba(9, 27, 43, 0.96), rgba(6, 20, 33, 0.98));
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(184, 224, 255, 0.025);
}

[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] .hero h1,
[data-theme="dark"] .hero h2,
[data-theme="dark"] .kpi-intro h1,
[data-theme="dark"] .kpi-section-heading h2,
[data-theme="dark"] .yavka-plan-heading h1,
[data-theme="dark"] .results-section-heading h2,
[data-theme="dark"] .reconcile-heading h1 {
    color: #eef9ff;
}

[data-theme="dark"] p,
[data-theme="dark"] small,
[data-theme="dark"] .small-text,
[data-theme="dark"] .hero-text,
[data-theme="dark"] .table-header p,
[data-theme="dark"] .kpi-filter-note,
[data-theme="dark"] .kpi-section-heading p:not(.eyebrow),
[data-theme="dark"] .yavka-plan-heading > p {
    color: var(--text-soft);
}

[data-theme="dark"] .eyebrow,
[data-theme="dark"] .hero-label,
[data-theme="dark"] .meta-caption {
    color: var(--emerald);
}

[data-theme="dark"] .hero,
[data-theme="dark"] .eg-hero,
[data-theme="dark"] .kpi-intro,
[data-theme="dark"] .sections-hero {
    background:
        radial-gradient(circle at 92% -20%, rgba(24, 216, 180, 0.15), transparent 36%),
        linear-gradient(135deg, #071c2c, #061522);
}

[data-theme="dark"] .hero-meta,
[data-theme="dark"] .eg-freshness,
[data-theme="dark"] .kpi-live-state {
    color: #dbeaf5;
    border-color: rgba(78, 146, 188, 0.24);
    background: rgba(8, 30, 47, 0.72);
}

[data-theme="dark"] .hero-ticker,
[data-theme="dark"] .turnout-election-tabs {
    border-color: rgba(36, 210, 178, 0.19);
    background: rgba(4, 20, 33, 0.76);
}

[data-theme="dark"] .hero-ticker-item {
    color: #b8c9d8;
}

[data-theme="dark"] .hero-ticker-item::before {
    background: var(--emerald);
    box-shadow: 0 0 12px rgba(22, 215, 179, 0.66);
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea,
[data-theme="dark"] .search-form input,
[data-theme="dark"] .results-filter-form input,
[data-theme="dark"] .results-filter-form select,
[data-theme="dark"] .kpi-filters select,
[data-theme="dark"] .kpi-filters input {
    color: #e9f5fd;
    border-color: rgba(93, 150, 189, 0.3);
    background: #071727;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: #637a8e;
}

[data-theme="dark"] .search-form {
    border-color: rgba(82, 145, 184, 0.3);
    background: linear-gradient(145deg, rgba(9, 29, 46, 0.98), rgba(6, 20, 34, 0.98));
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(184, 224, 255, 0.035);
}

[data-theme="dark"] .search-form-icon {
    color: #35f0ca;
}

[data-theme="dark"] .search-form input[type="text"] {
    border-color: rgba(89, 153, 193, 0.34);
    background: #061625;
    box-shadow: inset 0 1px 0 rgba(184, 224, 255, 0.025);
}

[data-theme="dark"] .search-form input[type="text"]::placeholder {
    color: #8198ac;
    opacity: 1;
}

[data-theme="dark"] .search-form input[type="text"]:focus {
    outline-color: rgba(53, 240, 202, 0.24);
    border-color: rgba(53, 240, 202, 0.66);
    box-shadow: 0 0 0 3px rgba(22, 215, 179, 0.08);
}

[data-theme="dark"] select option {
    color: #edf8ff;
    background: #071727;
}

[data-theme="dark"] .button,
[data-theme="dark"] .mode-pill,
[data-theme="dark"] .turnout-election-tab {
    border-color: rgba(90, 145, 184, 0.28);
}

[data-theme="dark"] .button-ghost,
[data-theme="dark"] .button-secondary,
[data-theme="dark"] .mode-pill,
[data-theme="dark"] .turnout-election-tab {
    color: #b9cad8;
    background: #081a29;
}

[data-theme="dark"] .button-primary,
[data-theme="dark"] .button-excel,
[data-theme="dark"] .mode-pill-active,
[data-theme="dark"] .turnout-election-tab.is-active {
    color: #031712;
    border-color: rgba(56, 239, 201, 0.45);
    background: linear-gradient(135deg, #3af0c9, #13c7a5);
    box-shadow: 0 0 22px rgba(22, 215, 179, 0.18);
}

[data-theme="dark"] .mode-pill-active,
[data-theme="dark"] .turnout-election-tab.is-active strong {
    color: #031712;
}

[data-theme="dark"] .segmented-switch {
    border-color: rgba(88, 143, 181, 0.24);
    background: #061523;
}

[data-theme="dark"] .table-header {
    border-bottom-color: rgba(82, 145, 184, 0.24);
    background:
        linear-gradient(90deg, rgba(22, 215, 179, 0.1), transparent 46%),
        linear-gradient(145deg, #091d2d, #061522);
}

[data-theme="dark"] .table-header h3 {
    color: #eef9ff;
}

[data-theme="dark"] .table-header p {
    color: #a8bdcf;
}

[data-theme="dark"] .table-wrapper,
[data-theme="dark"] .results-table-wrapper,
[data-theme="dark"] .kpi-table-wrap {
    scrollbar-color: #22516a #071622;
}

[data-theme="dark"] .data-table,
[data-theme="dark"] .kpi-table {
    color: #cfdeea;
}

[data-theme="dark"] .data-table th,
[data-theme="dark"] .kpi-table th {
    color: #83a2b8;
    border-color: rgba(80, 132, 168, 0.22);
    background: #0b2132;
}

[data-theme="dark"] .data-table td,
[data-theme="dark"] .kpi-table td {
    color: #ccdae5;
    border-color: rgba(69, 115, 148, 0.18);
    background: #071727;
}

[data-theme="dark"] .data-table tbody tr:nth-child(even) td,
[data-theme="dark"] .kpi-table tbody tr:nth-child(even) td {
    background: #081b2b;
}

[data-theme="dark"] .data-table tbody tr:hover td,
[data-theme="dark"] .kpi-table tbody tr:hover td {
    background: #0b2638;
}

[data-theme="dark"] .total-row td,
[data-theme="dark"] .data-table .total-row td,
[data-theme="dark"] .kpi-table .total-row td {
    color: #dffbf5;
    border-top-color: rgba(53, 240, 202, 0.42);
    border-bottom-color: rgba(53, 240, 202, 0.22);
    background: linear-gradient(145deg, rgba(14, 74, 69, 0.72), rgba(8, 38, 48, 0.96));
}

[data-theme="dark"] .total-row td strong,
[data-theme="dark"] .total-row .tik-name,
[data-theme="dark"] .total-row .cell-title {
    color: #42f0ce;
}

[data-theme="dark"] .district-child-row > td {
    border-bottom-color: rgba(53, 240, 202, 0.18);
    background: #061522;
}

[data-theme="dark"] .district-panel {
    border-left-color: #22ddba;
    background:
        linear-gradient(90deg, rgba(22, 215, 179, 0.1), transparent 52%),
        linear-gradient(145deg, #081d2c, #061522);
}

[data-theme="dark"] .district-panel-header strong {
    color: #eef9ff;
}

[data-theme="dark"] .district-panel-header span {
    color: #9eb2c7;
}

[data-theme="dark"] .district-table {
    color: #cfdeea;
    background: #071727;
}

[data-theme="dark"] .district-table th {
    color: #83a2b8;
    border-color: rgba(80, 132, 168, 0.22);
    background: #0b2132;
}

[data-theme="dark"] .district-table td {
    color: #ccdae5;
    border-color: rgba(69, 115, 148, 0.18);
    background: #071727;
}

[data-theme="dark"] .district-table tbody tr:nth-child(even) td {
    background: #081b2b;
}

[data-theme="dark"] .district-table tbody tr:hover td {
    background: #0b2638;
}

[data-theme="dark"] .collapsible-card {
    color: #dbe8f1;
    border-color: rgba(77, 132, 169, 0.24);
    background: linear-gradient(145deg, #091d2d, #071624);
}

[data-theme="dark"] .data-table strong,
[data-theme="dark"] .kpi-table strong,
[data-theme="dark"] .cell-title,
[data-theme="dark"] .rank-badge {
    color: #eff8ff;
}

[data-theme="dark"] .rank-badge,
[data-theme="dark"] .uik-chip {
    color: var(--emerald);
    background: rgba(22, 215, 179, 0.11);
}

[data-theme="dark"] .progress-track,
[data-theme="dark"] .kpi-progress,
[data-theme="dark"] .kpi-cell-progress,
[data-theme="dark"] .reconcile-progress-track {
    background: rgba(87, 139, 174, 0.17);
}

[data-theme="dark"] .progress-track > span,
[data-theme="dark"] .kpi-progress > span,
[data-theme="dark"] .kpi-cell-progress > span,
[data-theme="dark"] .reconcile-progress-track > span {
    background: linear-gradient(90deg, #13cda9, #3df3cc);
    box-shadow: 0 0 14px rgba(22, 215, 179, 0.35);
}

[data-theme="dark"] .site-menu-panel {
    color: #d9e7f2;
    border-color: rgba(84, 143, 181, 0.32);
    background: #071625;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .site-menu-heading,
[data-theme="dark"] .site-menu-item {
    border-color: rgba(77, 125, 159, 0.2);
}

[data-theme="dark"] .site-menu-panel .site-menu-item:hover,
[data-theme="dark"] .site-menu-panel .site-menu-item-active {
    color: #edfbff;
    background: #0b2537;
}

[data-theme="dark"] .sections-directory .section-card {
    color: #e8f5fc;
    border-color: rgba(82, 142, 180, 0.24);
    background: linear-gradient(145deg, #091d2d, #071624);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.24);
}

[data-theme="dark"] .sections-directory .section-card:hover {
    border-color: rgba(35, 223, 188, 0.48);
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.3), 0 0 24px rgba(22, 215, 179, 0.08);
}

[data-theme="dark"] .sections-directory .site-menu-item-icon {
    color: var(--emerald);
    background: rgba(22, 215, 179, 0.1);
}

[data-theme="dark"] .election-countdown > span,
[data-theme="dark"] .election-countdown-grid > span {
    color: #eefaff;
    border-color: rgba(51, 230, 195, 0.18);
    background: rgba(7, 29, 45, 0.78);
}

[data-theme="dark"] .kpi-metric,
[data-theme="dark"] .kpi-trend-metric,
[data-theme="dark"] .kpi-level-tab,
[data-theme="dark"] .kpi-trend-day,
[data-theme="dark"] .kpi-count-cell,
[data-theme="dark"] .kpi-value-cell,
[data-theme="dark"] .kpi-ballot-input-wrap {
    color: #d5e4ee;
    border-color: rgba(78, 132, 170, 0.24);
    background: #081a29;
}

[data-theme="dark"] .kpi-metric-primary,
[data-theme="dark"] .kpi-level-tab.is-active,
[data-theme="dark"] .kpi-trend-metric.is-active {
    border-color: rgba(38, 228, 191, 0.42);
    background: linear-gradient(145deg, rgba(16, 101, 91, 0.5), rgba(7, 30, 45, 0.96));
}

[data-theme="dark"] .kpi-metric-value,
[data-theme="dark"] .kpi-trend-metric strong,
[data-theme="dark"] .kpi-value-cell strong,
[data-theme="dark"] .kpi-count-cell strong {
    color: #effaff;
}

[data-theme="dark"] .kpi-level-tabs {
    border-color: rgba(82, 145, 184, 0.26);
    background: #061523;
}

[data-theme="dark"] .kpi-trend-definition {
    border-color: rgba(255, 172, 55, 0.28);
    background: rgba(82, 55, 15, 0.42);
}

[data-theme="dark"] .kpi-trend-plan {
    color: #ffc05c !important;
}

[data-theme="dark"] .kpi-control-cell,
[data-theme="dark"] .kpi-ballot-cell {
    color: #cbdce7;
    border-color: rgba(80, 137, 174, 0.25);
    background: #081a29;
}

[data-theme="dark"] .kpi-control-cell.is-match {
    border-color: rgba(38, 225, 189, 0.4);
    background: rgba(12, 84, 74, 0.42);
}

[data-theme="dark"] .kpi-control-cell.is-mismatch,
[data-theme="dark"] .kpi-ballot-cell.is-mismatch,
[data-theme="dark"] .kpi-table tbody tr.is-missing td {
    border-color: rgba(255, 94, 112, 0.42);
    background: rgba(79, 20, 31, 0.66);
}

[data-theme="dark"] .kpi-control-cell.is-mismatch {
    box-shadow: inset 3px 0 0 #ff5e70;
}

[data-theme="dark"] .kpi-control-cell.is-pending,
[data-theme="dark"] .kpi-table tbody tr.is-extra td {
    border-color: rgba(255, 172, 55, 0.34);
    background: rgba(82, 55, 15, 0.48);
}

[data-theme="dark"] .kpi-control-cell.is-mismatch strong,
[data-theme="dark"] .kpi-control-cell.is-mismatch .kpi-control-reason,
[data-theme="dark"] .kpi-ballot-cell.is-mismatch strong,
[data-theme="dark"] .kpi-ballot-cell.is-mismatch .kpi-ballot-result {
    color: #ff9aa6;
}

[data-theme="dark"] .kpi-control-cell.is-match .kpi-control-reason {
    color: #53e7c5;
}

[data-theme="dark"] .kpi-daily-plan > span {
    border-color: rgba(82, 145, 184, 0.25);
    background: rgba(25, 75, 100, 0.32);
}

[data-theme="dark"] .kpi-daily-plan > span strong {
    color: #effaff;
}

[data-theme="dark"] .kpi-table tbody td:first-child {
    background: #071727;
    box-shadow: 8px 0 16px -16px rgba(0, 0, 0, 0.78);
}

[data-theme="dark"] .kpi-table tbody tr:nth-child(even) td:first-child {
    background: #081b2b;
}

[data-theme="dark"] .kpi-table tbody tr:hover td:first-child {
    background: #0b2638;
}

[data-theme="dark"] .kpi-table tbody tr.kpi-total-row td,
[data-theme="dark"] .kpi-table tbody tr.kpi-total-row td:first-child,
[data-theme="dark"] .kpi-table tbody tr.kpi-total-row:hover td {
    color: #dffbf5;
    border-bottom-color: rgba(53, 240, 202, 0.36);
    background: linear-gradient(145deg, rgba(14, 74, 69, 0.78), rgba(8, 38, 48, 0.98));
}

[data-theme="dark"] .kpi-total-row .kpi-uik-cell > strong {
    color: #42f0ce;
}

[data-theme="dark"] .kpi-status {
    color: #54e3c2;
    background: rgba(22, 215, 179, 0.13);
}

[data-theme="dark"] .kpi-status.is-missing,
[data-theme="dark"] .kpi-status.is-rejected {
    color: #ff9aa6;
    background: rgba(255, 94, 112, 0.14);
}

[data-theme="dark"] .kpi-status.is-late,
[data-theme="dark"] .kpi-status.is-draft,
[data-theme="dark"] .kpi-status.is-extra {
    color: #ffc063;
    background: rgba(255, 172, 55, 0.14);
}

[data-theme="dark"] .kpi-message-error,
[data-theme="dark"] .alert-danger,
[data-theme="dark"] .reconcile-error {
    color: #ffb5bc;
    border-color: rgba(255, 87, 99, 0.36);
    background: rgba(78, 17, 28, 0.55);
}

[data-theme="dark"] .leader-card,
[data-theme="dark"] .result-card,
[data-theme="dark"] .results-card,
[data-theme="dark"] .contest-card {
    color: #dbe8f1;
    border-color: rgba(77, 132, 169, 0.24);
    background: #081a29;
}

[data-theme="dark"] .leader-card-top {
    border-color: rgba(38, 225, 189, 0.45);
    background: linear-gradient(145deg, rgba(12, 101, 88, 0.38), #081a29);
}

[data-theme="dark"] .reconcile-file-drop {
    color: #b8cad9;
    border-color: rgba(77, 155, 190, 0.38);
    background: rgba(7, 26, 41, 0.82);
}

[data-theme="dark"] .reconcile-file-name {
    color: #e9f5fd;
}

[data-theme="dark"] .reconcile-file-drop input[type="file"] {
    color: #dbe8f1;
    color-scheme: dark;
}

[data-theme="dark"] .reconcile-file-drop input[type="file"]::file-selector-button {
    min-height: 44px;
    margin-right: 8px;
    padding: 0 12px;
    color: #e9f5fd;
    border: 1px solid rgba(77, 155, 190, 0.5);
    border-radius: 8px;
    background: #0a2435;
    cursor: pointer;
    font-weight: 750;
    transition: color 140ms ease, border-color 140ms ease, background-color 140ms ease, transform 100ms ease;
}

[data-theme="dark"] .reconcile-file-drop input[type="file"]:hover::file-selector-button {
    color: #031712;
    border-color: #42f0ce;
    background: #42e7c3;
}

[data-theme="dark"] .reconcile-file-drop input[type="file"]:active::file-selector-button {
    transform: translateY(1px);
}

[data-theme="dark"] .empty-state,
[data-theme="dark"] .eg-empty-note,
[data-theme="dark"] .results-empty,
[data-theme="dark"] .mobile-empty-state {
    color: var(--text-soft);
    border-color: rgba(80, 134, 170, 0.24);
    background: #081a29;
}

[data-theme="dark"] .login-body {
    --login-copy: #f4fbff;
    --login-copy-soft: rgba(203, 220, 231, 0.59);
    --login-field: rgba(3, 14, 23, 0.78);
    --login-overlay-left: rgba(0, 6, 11, 0.42);
    --login-overlay-right: rgba(0, 5, 9, 0.26);
    background: #01070d;
}

[data-theme="dark"] .login-backdrop-image {
    opacity: 0.86;
}

[data-theme] .login-body .login-submit {
    color: #031510;
    border-color: rgba(92, 255, 219, 0.35);
    background: linear-gradient(100deg, #36d7b7 0%, #19bc9d 48%, #16a985 100%);
    box-shadow: 0 16px 34px rgba(15, 153, 124, 0.25), 0 0 26px rgba(38, 221, 182, 0.08);
}

[data-theme] .login-body .login-submit:hover,
[data-theme] .login-body .login-submit:focus-visible {
    border-color: rgba(125, 255, 228, 0.62);
    box-shadow: 0 20px 42px rgba(15, 153, 124, 0.34), 0 0 32px rgba(38, 221, 182, 0.14);
}

[data-theme] .login-copy .eyebrow {
    color: #d9aa61;
}

/* Калькулятор результата */
[data-theme="dark"] .turnout-plan-root {
    --ink: #e8f5fc;
    --ink-2: #bfd3e1;
    --text: #c6d7e3;
    --muted: #8499aa;
    --paper: #06131f;
    --surface: #081a29;
    --line: rgba(82, 137, 174, 0.25);
    --teal: #16d7b3;
    --teal-dark: #35efca;
    --teal-soft: rgba(22, 215, 179, 0.11);
    --blue: #40a6ff;
    --blue-soft: rgba(64, 166, 255, 0.12);
    --amber: #ffac37;
    --amber-soft: rgba(255, 172, 55, 0.12);
    --danger: #ff6570;
    --danger-soft: rgba(255, 101, 112, 0.12);
    border-color: rgba(82, 141, 179, 0.28);
    background: #06131f;
    box-shadow: 0 20px 58px rgba(0, 0, 0, 0.34);
}

[data-theme="dark"] .calc-app {
    --calc-ink: #eef9ff;
    --calc-text: #cbdbe6;
    --calc-muted: #8297aa;
    --calc-line: rgba(82, 137, 174, 0.23);
    --calc-line-strong: rgba(89, 154, 194, 0.36);
    --calc-green: #18d9b5;
    --calc-green-dark: #11b896;
    --calc-green-soft: rgba(24, 217, 181, 0.11);
    --calc-mint: rgba(24, 217, 181, 0.15);
    --calc-paper: #081a29;
    --calc-surface: #071725;
    --calc-amber: #ffac37;
    --calc-amber-soft: rgba(255, 172, 55, 0.12);
    --calc-red: #ff6874;
    --calc-red-soft: rgba(255, 104, 116, 0.12);
    color: var(--calc-text);
    background: #06131f;
}

[data-theme="dark"] .calc-sidebar,
[data-theme="dark"] .turnout-plan-root .projects-sidebar {
    border-color: var(--calc-line, var(--line));
    background: linear-gradient(180deg, #071b2a, #061420);
}

[data-theme="dark"] .calc-main,
[data-theme="dark"] .turnout-plan-root .workspace,
[data-theme="dark"] .turnout-plan-root .dashboard-page,
[data-theme="dark"] .turnout-plan-root .dashboard-shell {
    background: #06131f;
}

[data-theme="dark"] .calc-project.is-active,
[data-theme="dark"] .calc-metric,
[data-theme="dark"] .calc-results-panel,
[data-theme="dark"] .calc-history-panel,
[data-theme="dark"] .calc-version,
[data-theme="dark"] .calc-option-summary article,
[data-theme="dark"] .calc-modal,
[data-theme="dark"] .calc-field,
[data-theme="dark"] .calc-icon-button,
[data-theme="dark"] .calc-button-secondary,
[data-theme="dark"] .calc-button-ghost,
[data-theme="dark"] .turnout-plan-root .panel,
[data-theme="dark"] .turnout-plan-root .metrics-grid article,
[data-theme="dark"] .turnout-plan-root .version-banner,
[data-theme="dark"] .turnout-plan-root .project-item.is-active,
[data-theme="dark"] .turnout-plan-root .modal-card,
[data-theme="dark"] .turnout-plan-root .text-input,
[data-theme="dark"] .turnout-plan-root .secondary-button {
    color: #d5e4ed;
    border-color: rgba(82, 137, 174, 0.27);
    background: #081a29;
}

[data-theme="dark"] .calc-project:hover:not(.is-active) {
    border-color: rgba(66, 240, 206, 0.32);
    background: #0b2638;
}

[data-theme="dark"] .calc-project-header h2,
[data-theme="dark"] .calc-results-heading h3,
[data-theme="dark"] .calc-results-table-heading h4,
[data-theme="dark"] .calc-section-title h3,
[data-theme="dark"] .calc-modal-header h2,
[data-theme="dark"] .calc-empty h2,
[data-theme="dark"] .turnout-plan-root h1,
[data-theme="dark"] .turnout-plan-root h2,
[data-theme="dark"] .turnout-plan-root h3,
[data-theme="dark"] .turnout-plan-root strong {
    color: #eef9ff;
}

[data-theme="dark"] .calc-results-table th,
[data-theme="dark"] .calc-daily-plan-table thead th,
[data-theme="dark"] .turnout-plan-root .data-table th {
    color: #8da6b8;
    border-color: rgba(78, 128, 164, 0.24);
    background: #0b2233;
}

[data-theme="dark"] .calc-results-table td,
[data-theme="dark"] .calc-daily-plan-table td,
[data-theme="dark"] .calc-daily-plan-table tbody th,
[data-theme="dark"] .turnout-plan-root .data-table td {
    color: #c6d7e2;
    border-color: rgba(70, 118, 151, 0.18);
    background: #071827;
}

[data-theme="dark"] .calc-results-table tbody tr:nth-child(even) td,
[data-theme="dark"] .calc-daily-plan-table tbody tr:nth-child(even) td,
[data-theme="dark"] .calc-daily-plan-table tbody tr:nth-child(even) th,
[data-theme="dark"] .turnout-plan-root .data-table tbody tr:nth-child(even) td {
    background: #081b2a;
}

[data-theme="dark"] .calc-results-table tbody tr.calc-total-row td {
    color: #dffbf5;
    border-top-color: rgba(53, 240, 202, 0.42);
    border-bottom-color: rgba(53, 240, 202, 0.28);
    background: linear-gradient(145deg, rgba(14, 74, 69, 0.78), rgba(8, 38, 48, 0.98));
}

[data-theme="dark"] .turnout-plan-root .data-table tbody tr.table-total-row > :is(th, td) {
    color: #dffbf5;
    border-bottom-color: rgba(53, 240, 202, 0.36);
    background: linear-gradient(145deg, rgba(14, 74, 69, 0.78), rgba(8, 38, 48, 0.98));
}

[data-theme="dark"] .turnout-plan-root .table-total-label,
[data-theme="dark"] .turnout-plan-root .table-total-label strong {
    color: #42f0ce;
}

[data-theme="dark"] .calc-daily-plan-panel,
[data-theme="dark"] .calc-daily-plan-cards details,
[data-theme="dark"] .calc-daily-plan-cards section,
[data-theme="dark"] .calc-daily-plan-days > span {
    color: #cbdbe6;
    border-color: rgba(82, 137, 174, 0.24);
    background: #071827;
}

[data-theme="dark"] .calc-daily-plan-table .calc-daily-plan-summary td,
[data-theme="dark"] .calc-daily-plan-table .calc-daily-plan-summary th {
    color: #dffbf5;
    background: linear-gradient(145deg, rgba(14, 74, 69, 0.78), rgba(8, 38, 48, 0.98));
}

[data-theme="dark"] .calc-editor-table .calc-editor-total-row td,
[data-theme="dark"] .calc-editor-table .calc-editor-total-row td:first-child {
    color: #dffbf5;
    border-bottom-color: rgba(53, 240, 202, 0.36);
    background: linear-gradient(145deg, rgba(14, 74, 69, 0.78), rgba(8, 38, 48, 0.98));
}

[data-theme="dark"] .calc-daily-plan-total {
    color: #42f0ce;
    background: rgba(22, 215, 179, 0.12);
}

[data-theme="dark"] .calc-results-table tbody tr.calc-total-row td:first-child,
[data-theme="dark"] .calc-results-table tbody tr.calc-total-row td.is-priority {
    color: #42f0ce;
    background: linear-gradient(145deg, rgba(13, 90, 78, 0.82), rgba(8, 42, 50, 0.98)) !important;
}

[data-theme="dark"] .calc-results-table tbody tr.calc-total-row td strong {
    color: #42f0ce;
}

[data-theme="dark"] .calc-results-table tbody tr.calc-total-row td small {
    color: #91afbf;
}

[data-theme="dark"] .calc-results-table td.is-priority,
[data-theme="dark"] .calc-option-summary article.is-priority {
    background: rgba(22, 215, 179, 0.08) !important;
}

[data-theme="dark"] .calc-results-table td small.calc-quality-deviation,
[data-theme="dark"] .calc-results-table td small.calc-quality-deviation-badge {
    color: #ff9aa3;
}

[data-theme="dark"] .calc-results-table td small.calc-quality-deviation-badge {
    background: rgba(255, 104, 116, 0.14);
}

[data-theme="dark"] .calc-results-table tbody tr.calc-quality-deviation-row td:first-child,
[data-theme="dark"] .calc-results-table td.calc-quality-deviation-cell,
[data-theme="dark"] .calc-results-table tbody tr.calc-total-row td.calc-quality-deviation-cell {
    color: #ffd6da;
    background: linear-gradient(145deg, rgba(100, 25, 38, 0.62), rgba(49, 19, 33, 0.96)) !important;
    box-shadow: inset 0 0 0 1px rgba(255, 104, 116, 0.34);
}

[data-theme="dark"] .calc-results-table tbody tr.calc-quality-deviation-row td:first-child {
    box-shadow: inset 4px 0 0 #ff6874;
}

[data-theme="dark"] .calc-level-tabs,
[data-theme="dark"] .calc-contest-tabs {
    border-color: rgba(82, 137, 174, 0.27);
    background: #061523;
}

[data-theme="dark"] .calc-level-tabs button.is-active,
[data-theme="dark"] .calc-contest-tabs button.is-active {
    color: #42f0ce;
    background: rgba(22, 215, 179, 0.13);
    box-shadow: inset 0 0 0 1px rgba(53, 240, 202, 0.17), 0 5px 15px rgba(0, 0, 0, 0.18);
}

[data-theme="dark"] .calc-table-footnote {
    color: #8fa6b8;
    border-top: 1px solid rgba(82, 137, 174, 0.2);
    background: #061522;
}

[data-theme="dark"] .calc-version-main em {
    color: #42f0ce;
    background: rgba(22, 215, 179, 0.12);
}

[data-theme="dark"] .calc-version.is-active {
    border-color: rgba(66, 240, 206, 0.48);
    background: linear-gradient(145deg, rgba(14, 74, 69, 0.58), #081f2d);
}

[data-theme="dark"] .calc-version-main:hover:not(:disabled) {
    background: rgba(22, 215, 179, 0.07);
}

[data-theme="dark"] .calc-modal-backdrop,
[data-theme="dark"] .turnout-plan-root .modal-backdrop {
    background: rgba(0, 4, 10, 0.78);
}

[data-theme="dark"] .calc-overlay-loading {
    color: var(--calc-green);
    background: rgba(5, 18, 29, 0.8);
}

/* Встроенный калькулятор явки использует собственный набор классов. */
[data-theme="dark"] .turnout-plan-root .login-page,
[data-theme="dark"] .turnout-plan-root .app-loading {
    color: #c9d9e4;
    background:
        linear-gradient(rgba(56, 115, 151, 0.055) 1px, transparent 1px) 0 0 / 38px 38px,
        linear-gradient(90deg, rgba(56, 115, 151, 0.055) 1px, transparent 1px) 0 0 / 38px 38px,
        radial-gradient(circle at 18% 15%, rgba(22, 215, 179, 0.11), transparent 24rem),
        #06131f !important;
}

[data-theme="dark"] .turnout-plan-root .login-card {
    color: #dceaf3;
    border-color: rgba(84, 144, 182, 0.34);
    background: rgba(8, 26, 41, 0.96);
    box-shadow: 0 28px 78px rgba(0, 0, 0, 0.52);
}

[data-theme="dark"] .turnout-plan-root .login-card h1,
[data-theme="dark"] .turnout-plan-root .login-card .brand,
[data-theme="dark"] .turnout-plan-root .login-card strong {
    color: #eff9ff;
}

[data-theme="dark"] .turnout-plan-root .login-lock,
[data-theme="dark"] .turnout-plan-root .brand-mark {
    color: var(--emerald);
    border-color: rgba(35, 222, 187, 0.26);
    background: rgba(22, 215, 179, 0.1);
}

[data-theme="dark"] .turnout-plan-root .text-input,
[data-theme="dark"] .turnout-plan-root .cutoff-picker select,
[data-theme="dark"] .turnout-plan-root .search-box,
[data-theme="dark"] .turnout-plan-root .upload-zone {
    color: #e6f3fb;
    border-color: rgba(84, 144, 182, 0.3);
    background: #071827;
}

[data-theme="dark"] .turnout-plan-root .new-project-button {
    color: #42f0ce;
    border-color: rgba(66, 240, 206, 0.38);
    background: rgba(7, 24, 39, 0.88);
}

[data-theme="dark"] .turnout-plan-root .new-project-button:hover:not(:disabled),
[data-theme="dark"] .turnout-plan-root .project-item:hover:not(.is-active),
[data-theme="dark"] .turnout-plan-root .ghost-button:hover:not(:disabled),
[data-theme="dark"] .turnout-plan-root .upload-zone:hover:not(:disabled) {
    color: #dffbf5;
    border-color: rgba(66, 240, 206, 0.52);
    background: #0b2638;
}

[data-theme="dark"] .turnout-plan-root .history-actions > button {
    color: #ff9aa3;
    border-color: rgba(255, 104, 116, 0.34);
    background: rgba(255, 104, 116, 0.11);
}

[data-theme="dark"] .turnout-plan-root .history-actions > button:hover:not(:disabled),
[data-theme="dark"] .turnout-plan-root .version-delete:hover:not(:disabled) {
    color: #ffd6da;
    border-color: rgba(255, 104, 116, 0.5);
    background: rgba(255, 104, 116, 0.2);
}

[data-theme="dark"] .turnout-plan-root .mini-progress,
[data-theme="dark"] .turnout-plan-root .day-track,
[data-theme="dark"] .turnout-plan-root .turnout-cell::before {
    background: rgba(111, 158, 188, 0.22);
}

[data-theme="dark"] .turnout-plan-root .day-number {
    color: #e9f8ff;
    background: rgba(22, 215, 179, 0.13);
    box-shadow: inset 0 0 0 1px rgba(66, 240, 206, 0.2);
}

[data-theme="dark"] .turnout-plan-root .version-row {
    border-color: rgba(82, 137, 174, 0.27);
    background: #071827;
}

[data-theme="dark"] .turnout-plan-root .version-open {
    color: #d5e4ed;
    background: #071827;
}

[data-theme="dark"] .turnout-plan-root .version-open:hover,
[data-theme="dark"] .turnout-plan-root .version-open.is-current {
    color: #eef9ff;
    background: linear-gradient(145deg, rgba(14, 74, 69, 0.7), #0a2635);
}

[data-theme="dark"] .turnout-plan-root .version-open.is-current {
    box-shadow: inset 3px 0 0 #42e7c3;
}

[data-theme="dark"] .turnout-plan-root .version-open small {
    color: #a8bdcd;
}

[data-theme="dark"] .turnout-plan-root .detail-summary span {
    color: #9eb4c5;
    border-color: rgba(82, 137, 174, 0.28);
    background: #071827;
}

[data-theme="dark"] .turnout-plan-root .point-chart {
    background-image: repeating-linear-gradient(
        0deg,
        transparent 0,
        transparent 39px,
        rgba(93, 150, 189, 0.18) 40px
    );
}

[data-theme="dark"] .turnout-plan-root .data-table tbody tr.is-selected,
[data-theme="dark"] .turnout-plan-root .data-table tbody tr.is-selected td {
    background: #0b2638;
}

@media (max-width: 1080px) {
    [data-theme="dark"] .page-shell {
        padding-left: 18px;
    }

    [data-theme="dark"] .app-sidebar {
        display: none;
    }

    [data-theme="dark"] .topbar {
        left: 0;
    }

    [data-theme="dark"] .topbar-actions > .site-menu {
        display: block;
    }
}

@media (max-width: 720px) {
    [data-theme="dark"] .page-shell {
        padding: 74px 10px 28px;
    }

    [data-theme="dark"] .topbar {
        min-height: 62px;
        height: 62px;
        padding: 0 10px;
    }

    [data-theme="dark"] .topbar-context {
        gap: 8px;
    }

    [data-theme="dark"] .topbar-context-icon {
        width: 31px;
        height: 31px;
    }

    [data-theme="dark"] .topbar-context strong {
        max-width: 42vw;
        font-size: 0.82rem;
    }

    [data-theme="dark"] .topbar-actions {
        display: none;
    }

    [data-theme="dark"] .mobile-top-actions {
        display: flex;
    }

    [data-theme="dark"] .sections-directory .section-card {
        min-height: 92px;
    }
}

/* Этап 1: единая оболочка и командная строка рабочего раздела. */
.skip-link {
    position: fixed;
    z-index: 1000;
    top: 10px;
    left: 50%;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 10px 16px;
    color: #031510;
    border-radius: 10px;
    background: #45f1ce;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42);
    transform: translate(-50%, -160%);
    transition: transform 0.16s ease;
}

.skip-link:focus {
    transform: translate(-50%, 0);
}

[data-theme="dark"] .topbar-context-copy {
    min-width: 0;
    flex: 1 1 auto;
    display: grid;
    gap: 1px;
}

[data-theme="dark"] .topbar-context-copy small {
    color: #8299ad;
    font-size: 0.66rem;
    font-weight: 650;
    line-height: 1.2;
}

[data-theme="dark"] .topbar-context-copy strong {
    display: block;
}

.site-menu-backdrop,
.site-menu-close {
    border: 0;
    appearance: none;
}

.site-menu-backdrop {
    display: none;
}

[data-theme="dark"] .site-menu-heading {
    grid-template-columns: minmax(0, 1fr) 44px;
    align-items: center;
    gap: 12px;
}

[data-theme="dark"] .site-menu-heading > span {
    min-width: 0;
    display: grid;
    gap: 2px;
}

[data-theme="dark"] .site-menu-close {
    width: 44px;
    height: 44px;
    display: inline-grid;
    place-items: center;
    color: #c9d8e6;
    border: 1px solid rgba(104, 153, 190, 0.28);
    border-radius: 9px;
    background: #071727;
    font: 500 1.45rem/1 Inter, sans-serif;
    cursor: pointer;
}

[data-theme="dark"] .site-menu-close:hover {
    color: #ffffff;
    border-color: rgba(69, 241, 206, 0.48);
    background: rgba(22, 215, 179, 0.12);
}

.workspace-commandbar {
    position: relative;
    isolation: isolate;
    min-height: 104px;
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    align-items: center;
    gap: 20px;
    margin-bottom: 16px;
    padding: 18px 20px;
    overflow: visible;
    color: var(--text);
    border: 1px solid rgba(83, 137, 176, 0.28);
    border-radius: 12px;
    background:
        radial-gradient(circle at 100% 0%, rgba(22, 215, 179, 0.12), transparent 34%),
        linear-gradient(135deg, rgba(9, 29, 45, 0.98), rgba(6, 19, 31, 0.99));
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.3);
}

.workspace-commandbar::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: 0 auto 0 0;
    width: 3px;
    border-radius: 12px 0 0 12px;
    background: linear-gradient(180deg, #45f1ce, rgba(69, 241, 206, 0.1));
}

.workspace-commandbar-copy {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.workspace-commandbar-copy h1 {
    margin: 0;
    color: #f2f9ff;
    font-size: clamp(1.38rem, 1.1rem + 0.7vw, 2rem);
    line-height: 1.08;
    letter-spacing: -0.025em;
}

.workspace-commandbar-copy > p:not(.eyebrow) {
    max-width: 740px;
    margin: 0;
    color: #a9bdd0;
    font-size: 0.8rem;
    line-height: 1.42;
}

.workspace-commandbar-rail {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.workspace-freshness {
    min-height: 50px;
    max-width: 360px;
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr);
    align-items: center;
    gap: 9px;
    padding: 8px 12px;
    color: #c5d6e5;
    border: 1px solid rgba(104, 153, 190, 0.26);
    border-radius: 10px;
    background: rgba(4, 17, 29, 0.72);
}

.workspace-freshness-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #8297aa;
    box-shadow: 0 0 0 4px rgba(130, 151, 170, 0.1);
}

.workspace-freshness.is-live .workspace-freshness-dot {
    background: #28e59a;
    box-shadow: 0 0 14px rgba(40, 229, 154, 0.68);
}

.workspace-freshness.is-loading .workspace-freshness-dot {
    background: var(--warning);
    box-shadow: 0 0 14px rgba(255, 159, 28, 0.56);
}

.workspace-freshness.is-error .workspace-freshness-dot {
    background: var(--danger);
    box-shadow: 0 0 14px rgba(255, 94, 98, 0.62);
}

.workspace-freshness > span:last-child {
    min-width: 0;
    display: grid;
    gap: 1px;
}

.workspace-freshness small {
    color: #8299ad;
    font-size: 0.66rem;
    font-weight: 650;
    line-height: 1.25;
}

.workspace-freshness strong {
    overflow: hidden;
    color: #e8f3fb;
    font-size: 0.76rem;
    font-weight: 650;
    line-height: 1.3;
    text-overflow: ellipsis;
}

.workspace-commandbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.workspace-commandbar-actions form {
    display: contents;
}

.workspace-commandbar-actions .button,
.workspace-commandbar-actions .ld-control-button,
.workspace-commandbar-actions .ld-icon-button {
    min-height: 44px;
}

.workspace-commandbar.ld-commandbar,
.workspace-commandbar.kpi-intro {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    align-items: center;
    gap: 20px;
    min-height: 104px;
    padding: 18px 20px;
}

.workspace-commandbar.ld-commandbar .ld-commandbar-rail {
    position: static;
}

.workspace-commandbar.ld-commandbar .ld-filter-disclosure {
    position: relative;
}

.workspace-commandbar.kpi-intro .kpi-live-state {
    width: auto;
    justify-content: initial;
}

.workspace-commandbar.kpi-intro .kpi-live-dot {
    margin: 0;
}

.eg-kpi-strip {
    min-height: auto;
    grid-template-columns: 1fr;
    padding: 8px;
}

.reconcile-section-heading {
    display: grid;
    gap: 4px;
    margin-bottom: 16px;
}

.reconcile-section-heading h2,
.reconcile-section-heading p {
    margin: 0;
}

.reconcile-section-heading p {
    color: var(--text-soft);
    font-size: 0.8rem;
}

@media (max-width: 1080px) {
    [data-theme="dark"] .topbar-actions > .site-menu {
        display: block;
    }

    [data-theme="dark"] .topbar-actions .site-menu-panel {
        max-height: calc(100dvh - 88px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

@media (max-width: 720px) {
    html.site-menu-open,
    html.site-menu-open body {
        overflow: hidden;
    }

    [data-theme="dark"] .topbar {
        grid-template-columns: minmax(0, 1fr) 102px;
        gap: 10px;
        min-height: 64px;
        height: 64px;
        padding: max(8px, env(safe-area-inset-top)) 10px 8px;
    }

    [data-theme="dark"] .page-shell {
        padding-top: 76px;
    }

    [data-theme="dark"] .topbar-context {
        min-width: 0;
    }

    [data-theme="dark"] .topbar-context-icon {
        width: 36px;
        height: 36px;
        flex: 0 0 36px;
    }

    [data-theme="dark"] .topbar-context-copy small {
        overflow: hidden;
        font-size: 0.6rem;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    [data-theme="dark"] .topbar-context-copy strong {
        max-width: none;
        font-size: 0.78rem;
        line-height: 1.2;
    }

    [data-theme="dark"] .mobile-top-actions {
        width: 102px;
        flex: 0 0 102px;
        gap: 6px;
    }

    [data-theme="dark"] .mobile-top-actions > .logout-form,
    [data-theme="dark"] .mobile-top-actions > .site-menu,
    [data-theme="dark"] .mobile-top-actions .mobile-icon-button {
        width: 48px;
        flex: 0 0 48px;
    }

    [data-theme="dark"] .mobile-top-actions .mobile-icon-button {
        height: 48px;
    }

    .site-menu-mobile .site-menu-backdrop {
        position: fixed;
        z-index: 198;
        inset: 0;
        width: 100vw;
        height: 100dvh;
        display: block;
        padding: 0;
        background: rgba(0, 5, 10, 0.78);
        backdrop-filter: blur(5px);
    }

    .site-menu-mobile:not([open]) .site-menu-backdrop {
        display: none;
    }

    [data-theme="dark"] .site-menu-mobile .site-menu-panel {
        position: fixed;
        z-index: 199;
        inset: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
        width: auto;
        max-height: none;
        display: grid;
        grid-template-rows: auto minmax(0, 1fr);
        padding: 10px;
        border-radius: 16px;
        background: linear-gradient(160deg, rgba(8, 27, 43, 0.99), rgba(3, 13, 23, 0.995));
        box-shadow: 0 28px 84px rgba(0, 0, 0, 0.64);
    }

    [data-theme="dark"] .site-menu-mobile .site-menu-heading {
        padding: 8px 8px 12px;
    }

    [data-theme="dark"] .site-menu-mobile .site-menu-list {
        min-height: 0;
        align-content: start;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 8px 2px 2px;
    }

    [data-theme="dark"] .site-menu-mobile .site-menu-item {
        min-height: 58px;
        padding: 8px 10px;
    }

    .workspace-commandbar,
    .workspace-commandbar.ld-commandbar,
    .workspace-commandbar.kpi-intro {
        grid-template-columns: minmax(0, 1fr);
        gap: 14px;
        min-height: 0;
        margin-bottom: 12px;
        padding: 16px;
        border-radius: 12px;
    }

    .workspace-commandbar-copy h1 {
        font-size: clamp(1.45rem, 8vw, 2rem);
    }

    .workspace-commandbar-copy > p:not(.eyebrow) {
        font-size: 0.8rem;
    }

    .workspace-commandbar-rail {
        width: 100%;
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        justify-items: stretch;
    }

    .workspace-freshness {
        width: 100%;
        max-width: none;
    }

    .workspace-commandbar-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
    }

    .workspace-commandbar-actions > *,
    .workspace-commandbar-actions .button,
    .workspace-commandbar-actions .ld-control-button,
    .workspace-commandbar-actions .ld-icon-button {
        width: 100%;
    }

    .workspace-commandbar-actions .ld-icon-button {
        min-width: 44px;
    }

    .workspace-commandbar.ld-commandbar .ld-filter-disclosure {
        width: 100%;
    }

    .workspace-commandbar.ld-commandbar .ld-filter-panel {
        right: auto;
        left: 0;
        width: min(340px, calc(100vw - 52px));
    }

    .eg-kpi-strip {
        padding: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    [data-theme="dark"] .app-sidebar .site-menu-item {
        transition: none;
    }
}

/* Этап 4: доступные popover-подсказки, читаемый мелкий текст и статические KPI. */
[data-theme="dark"] {
    --text-muted: #8298ac;
}

[data-theme="dark"] .live-dashboard-page {
    --ld-gray: #8298ac;
}

[data-theme="dark"] :where(input, textarea)::placeholder {
    color: #879db1;
    opacity: 1;
}

[data-theme="dark"] :is(
    .app-sidebar-footer,
    .topbar-context-copy small,
    .topbar-clock small,
    .workspace-freshness small,
    .ld-commandbar-title small,
    .ld-status-stat span,
    .ld-events-panel > footer,
    .ld-structure-row small,
    .ld-event-row span,
    .kpi-ballot-cell small,
    .calc-version-main small,
    .calc-editor-tabs button > span
) {
    color: #9eb2c7;
}

[data-theme="dark"] .reconcile-file-title {
    color: #a9bed1;
}

[data-theme="dark"] .kpi-ballot-save {
    color: #031712;
}

[data-theme="dark"] :is(.calc-option-summary article p em, .calc-results-table td small.calc-deficit-allocation) {
    color: #ffc66f;
}

[data-theme="dark"] :is(.calc-warning-panel, .calc-history-banner) {
    color: #ffd08a;
    border-color: rgba(255, 192, 99, 0.42);
    background: rgba(255, 172, 55, 0.12);
}

[data-theme="dark"] :is(.calc-alert-danger, .calc-projection-warning-critical) {
    color: #ffb5bc;
    border-color: rgba(255, 104, 116, 0.42);
    background: rgba(255, 104, 116, 0.12);
}

[data-theme="dark"] .calc-empty-rules {
    color: #a9bed1;
}

[data-theme="dark"] .eg-sort-indicator::before {
    opacity: 0.8;
}

[data-theme="dark"] .mobile-rank {
    color: #031712;
}

[data-theme="dark"] .eg-mobile-sort-controls:not([hidden]) {
    border-color: rgba(82, 137, 174, 0.27);
    background: #071827;
}

[data-theme="dark"] .eg-mobile-sort-controls > label {
    color: #a9bed1;
}

[data-theme="dark"] .eg-mobile-sort-row select,
[data-theme="dark"] .eg-mobile-sort-direction {
    color: #e9f5fd;
    border-color: rgba(82, 137, 174, 0.36);
    background: #0a2233;
}

[data-theme="dark"] .eg-mobile-sort-controls .eg-mobile-sort-row .eg-mobile-sort-direction {
    width: auto;
    min-width: 112px;
}

[data-theme="dark"] .eg-mobile-sort-direction:hover:not(:disabled) {
    color: #031712;
    border-color: #42f0ce;
    background: #42e7c3;
}

[data-theme="dark"] .eg-mobile-sort-arrow {
    color: #42e7c3;
}

[data-theme="dark"] .eg-mobile-sort-direction:hover:not(:disabled) .eg-mobile-sort-arrow {
    color: currentColor;
}

[data-theme="dark"] .calc-sidebar-heading > span,
[data-theme="dark"] .calc-version-number {
    color: #031712;
    border-color: rgba(90, 247, 214, 0.54);
    background: #48e7c5;
}

/* Редактор калькулятора: вложенные поверхности не возвращаются к светлой палитре. */
[data-theme="dark"] :is(
    .calc-modal-header,
    .calc-modal-body,
    .calc-editor-tabs,
    .calc-modal-footer,
    .calc-record-toolbar,
    .calc-contest-editor,
    .calc-option-row
) {
    color: #d5e4ed;
    border-color: rgba(82, 137, 174, 0.27);
    background: #081a29;
}

[data-theme="dark"] .calc-modal-basics {
    color: #d5e4ed;
    background: #071725;
}

[data-theme="dark"] :is(.calc-municipality-card, .calc-turnout-source-card) {
    color: #d5e4ed;
    border-color: rgba(82, 137, 174, 0.3);
    background: linear-gradient(135deg, #0a2233, #071725);
}

[data-theme="dark"] :is(
    .calc-modal-basics label > span,
    .calc-spread-range > span,
    .calc-municipality-grid label > span,
    .calc-turnout-source-grid label > span,
    .calc-municipality-heading > span,
    .calc-turnout-source-heading > span,
    .calc-option-labels
) {
    color: #a9bed1;
}

[data-theme="dark"] :is(.calc-basics-note, .calc-turnout-source-empty) {
    color: #a9bed1;
    border-color: rgba(82, 137, 174, 0.27);
    background: #0a2031;
}

[data-theme="dark"] :is(.calc-municipality-summary, .calc-turnout-source-summary) {
    color: #9eb2c7;
    border-color: rgba(82, 137, 174, 0.24);
}

[data-theme="dark"] :is(
    .calc-municipality-heading h3,
    .calc-turnout-source-heading h3,
    .calc-contest-heading h4,
    .calc-municipality-summary strong,
    .calc-turnout-source-summary strong
) {
    color: #eef9ff;
}

[data-theme="dark"] .calc-editor-tabs button {
    color: #a9bed1;
}

[data-theme="dark"] .calc-editor-tabs button > span,
[data-theme="dark"] .calc-editor-tabs button small {
    color: #c7d9e5;
    background: #102b3e;
}

[data-theme="dark"] .calc-editor-tabs button.is-active {
    color: #48e7c5;
}

[data-theme="dark"] .calc-editor-tabs button.is-active > span {
    color: #031712;
    background: #48e7c5;
}

[data-theme="dark"] .calc-editor-table-wrap {
    border-color: rgba(82, 137, 174, 0.27);
    background: #071827;
}

[data-theme="dark"] .calc-editor-table th {
    color: #a9bed1;
    border-color: rgba(82, 137, 174, 0.28);
    background: #0d2234;
}

[data-theme="dark"] .calc-editor-table td {
    color: #d5e4ed;
    border-color: rgba(82, 137, 174, 0.2);
    background: #071827;
}

[data-theme="dark"] .calc-editor-table input {
    color: #e6f3fb;
    border-color: rgba(84, 144, 182, 0.36);
    background: #0a2031;
}

[data-theme="dark"] .calc-priority-radio span {
    border-color: #7998aa;
    background: #0a2031;
}

[data-theme="dark"] .calc-priority-radio input:checked + span {
    border-color: #48e7c5;
    background: #081a29;
}

/* Сводная таблица результатов: все закреплённые и групповые ячейки остаются тёмными. */
[data-theme="dark"] .results-pivot-table .results-candidate-head {
    color: #dceaf4;
    border-left-color: rgba(66, 231, 181, 0.38);
    border-right-color: rgba(92, 143, 177, 0.24);
    background: #0b2233;
}

[data-theme="dark"] .results-pivot-table .results-candidate-head-alt {
    background: #091d2d;
}

[data-theme="dark"] .results-pivot-table tbody .results-candidate-alt {
    background: #071827;
}

[data-theme="dark"] .results-pivot-table tbody .results-candidate-winner {
    color: #dffbf5;
    background: rgba(17, 104, 87, 0.42) !important;
    box-shadow: inset 0 1px 0 rgba(66, 231, 181, 0.2), inset 0 -1px 0 rgba(66, 231, 181, 0.2);
}

[data-theme="dark"] .results-pivot-table tbody tr:hover :is(
    .results-candidate-alt,
    .results-candidate-votes,
    .results-candidate-percent
) {
    background: #0b2638;
}

[data-theme="dark"] .results-pivot-table tbody tr:hover .results-candidate-winner {
    background: rgba(20, 124, 103, 0.48) !important;
}

[data-theme="dark"] .results-pivot-table thead .results-subhead th,
[data-theme="dark"] .results-pivot-table thead .results-sticky-col,
[data-theme="dark"] .results-pivot-table thead .results-sticky-col-2 {
    color: #a9bed1;
    border-color: rgba(82, 137, 174, 0.28);
    background: #0d2234;
}

[data-theme="dark"] .results-pivot-table tbody :is(.results-sticky-col, .results-sticky-col-2) {
    color: #d4e2ec;
    background: #081a29;
}

[data-theme="dark"] .results-pivot-table tbody .results-total-row td,
[data-theme="dark"] .results-pivot-table tbody .results-total-row :is(.results-sticky-col, .results-sticky-col-2, .results-candidate-alt) {
    color: #dffbf5;
    background: linear-gradient(145deg, rgba(14, 74, 69, 0.78), rgba(8, 38, 48, 0.98));
}

[data-theme="dark"] .results-pivot-table tbody tr:hover :is(.results-sticky-col, .results-sticky-col-2) {
    background: #0b2638;
}

.ui-popover {
    position: fixed;
    z-index: 420;
    width: max-content;
    max-width: min(340px, calc(100vw - 24px));
    padding: 11px 13px;
    color: #eef9ff;
    border: 1px solid rgba(90, 247, 214, 0.42);
    border-radius: var(--radius-card, 12px);
    background: #0d2234;
    box-shadow: var(--shadow-overlay, 0 28px 84px rgba(0, 0, 0, 0.58));
    font-family: var(--font-ui, Inter, "Segoe UI", Arial, sans-serif);
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1.42;
    overflow-wrap: anywhere;
    pointer-events: auto;
}

.ui-popover[hidden] {
    display: none;
}

[data-theme="dark"] .ui-tooltip-trigger {
    min-width: 44px;
    min-height: 44px;
    color: inherit;
    border: 0;
    background: transparent;
    font: inherit;
    font-weight: inherit;
    cursor: help;
}

[data-theme="dark"] .ui-tooltip-trigger-table {
    width: 100%;
    justify-content: inherit;
    padding: 7px 4px;
    text-align: inherit;
    white-space: inherit;
    overflow: hidden;
    text-overflow: ellipsis;
}

[data-theme="dark"] .results-candidate-head .ui-tooltip-trigger-table {
    justify-content: center;
    text-align: center;
}

[data-theme="dark"] .eg-department-name .ui-tooltip-trigger-table {
    justify-content: flex-start;
    text-align: left;
}

[data-theme="dark"] .ld-info {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    color: var(--text-soft);
    border: 0;
    background: transparent;
    cursor: help;
}

[data-theme="dark"] .ld-info > span {
    width: 20px;
    height: 20px;
    display: inline-grid;
    place-items: center;
    border: 1px solid currentColor;
    border-radius: 50%;
    font-size: 0.68rem;
    font-weight: 700;
}

@media (hover: hover) and (pointer: fine) {
    [data-theme="dark"] :is(.ui-tooltip-trigger, .ld-info):hover {
        color: var(--focus-color);
        background: rgba(90, 247, 214, 0.08);
    }
}

[data-theme="dark"] :is(.ui-tooltip-trigger, .ld-info)[aria-expanded="true"] {
    color: var(--focus-color);
    background: rgba(90, 247, 214, 0.11);
}

[data-theme="dark"] .hero-ticker {
    width: 100%;
    height: auto;
    min-height: 0;
    padding: var(--space-2);
    overflow: visible;
}

[data-theme="dark"] .hero.desktop-dashboard .hero-ticker {
    height: auto;
    min-height: 0;
}

[data-theme="dark"] :is(.hero-ticker-track, .eg-hero-ticker .hero-ticker-track) {
    width: 100%;
    min-width: 0;
    display: block;
    animation: none !important;
    transform: none !important;
}

[data-theme="dark"] :is(.hero-ticker-group, .eg-hero-ticker-group) {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-2);
}

[data-theme="dark"] :is(.hero-ticker-group, .eg-hero-ticker-group)[aria-hidden="true"],
[data-theme="dark"] .hero-ticker-item[aria-hidden="true"] {
    display: none !important;
}

[data-theme="dark"] .hero-ticker-item:not([aria-hidden="true"]) {
    min-width: 0;
    min-height: 46px;
    display: flex;
    align-items: center;
    padding: 9px 11px;
    color: #dceaf4;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    background: rgba(7, 27, 43, 0.88);
    white-space: normal;
    line-height: 1.3;
}

[data-theme="dark"] .ld-ticker {
    align-items: center;
}

[data-theme="dark"] .ld-ticker-window {
    overflow: hidden;
}

[data-theme="dark"] .ld-ticker-track {
    width: 100%;
    min-width: 0;
    display: block;
    animation: none !important;
    transform: none !important;
}

[data-theme="dark"] .ld-ticker-sequence {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 4px clamp(14px, 2vw, 30px);
}

[data-theme="dark"] .ld-ticker-sequence[aria-hidden="true"] {
    display: none !important;
}

[data-theme="dark"] .ld-ticker-track span[aria-hidden="true"] {
    display: none !important;
}

[data-theme="dark"] .ld-ticker-track span {
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    padding: 0;
    color: #dceaf4;
    border: 0;
    border-radius: 0;
    background: transparent;
    white-space: normal;
    line-height: 1.25;
}

[data-theme="dark"] .ld-ticker-track .ld-ticker-item.is-normal { color: var(--ld-teal); }
[data-theme="dark"] .ld-ticker-track .ld-ticker-item.is-warning { color: var(--ld-orange); }
[data-theme="dark"] .ld-ticker-track .ld-ticker-item.is-critical { color: var(--ld-red); }

@media (max-width: 1080px) {
    [data-theme="dark"] .hero-ticker {
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        scroll-snap-type: x proximity;
        scrollbar-width: thin;
    }

    [data-theme="dark"] :is(.hero-ticker-track, .eg-hero-ticker .hero-ticker-track) {
        width: max-content;
        min-width: 100%;
    }

    [data-theme="dark"] :is(.hero-ticker-group, .eg-hero-ticker-group) {
        width: max-content;
        min-width: 100%;
        display: flex;
        flex-wrap: nowrap;
    }

    [data-theme="dark"] .hero-ticker-item:not([aria-hidden="true"]) {
        flex: 0 0 min(78vw, 280px);
        scroll-snap-align: start;
    }
}

/* Единый читаемый масштаб: мелкие подписи остаются компактными, но не теряются на экране. */
html {
    font-size: clamp(17px, calc(15.2px + 0.12vw), 18px);
}

body {
    line-height: 1.46;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
    font-size: max(0.84rem, 14px);
}

.eyebrow,
.hero-label,
.meta-caption {
    font-size: 0.78rem;
}

.data-table th {
    font-size: 0.84rem;
}

.district-table th,
.results-filter-form label > span,
.reconcile-file-title {
    font-size: 0.78rem;
}

.status-badge,
.district-count,
.rank-badge-small {
    font-size: 0.8rem;
}

.mobile-update-card span:not(.mobile-update-icon),
.mobile-signal span:not(.mobile-signal-icon),
.mobile-row-metrics span,
.mobile-row-metrics small,
.mobile-child-metrics span,
.election-countdown-grid small {
    font-size: 0.74rem;
}

@media (min-width: 1081px) {
    [data-theme="dark"] .app-sidebar {
        width: 220px;
    }

    [data-theme="dark"] .page-shell {
        padding-left: 240px;
    }

    [data-theme="dark"] .topbar {
        left: 220px;
    }
}

[data-theme="dark"] .app-sidebar-brand {
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 11px;
    padding-inline: 15px;
    font-size: 0.92rem;
}

[data-theme="dark"] .app-sidebar .site-menu-item {
    min-height: 52px;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 10px;
    padding: 9px 11px;
}

[data-theme="dark"] .app-sidebar .site-menu-item-copy strong {
    font-size: 0.86rem;
    line-height: 1.28;
}

[data-theme="dark"] .app-sidebar-footer {
    font-size: 0.75rem;
    line-height: 1.4;
}

[data-theme="dark"] .topbar-context strong {
    font-size: 1.06rem;
}

[data-theme="dark"] .topbar-live-indicator {
    font-size: 0.8rem;
}

[data-theme="dark"] .topbar-clock strong {
    font-size: 0.94rem;
}

[data-theme="dark"] .topbar-clock small {
    font-size: 0.72rem;
}

/* Ситуационный центр. */
.ld-commandbar-title strong {
    font-size: 0.92rem;
}

.ld-commandbar-title small {
    font-size: 0.75rem;
}

.ld-control-button,
.ld-icon-button {
    font-size: 0.8rem;
}

.ld-filter-panel label > span {
    font-size: 0.74rem;
}

.ld-kpi-card header {
    font-size: 0.92rem;
}

.ld-info {
    width: 18px;
    height: 18px;
    font-size: 0.68rem;
}

.ld-kpi-card > p,
.ld-report-layout p,
.ld-attention-layout p {
    font-size: 0.78rem;
    line-height: 1.35;
}

.ld-mini-donut b {
    font-size: 0.82rem;
}

.ld-panel-heading h2 {
    font-size: 1.06rem;
}

.ld-panel-heading p,
.ld-chart-legend,
.ld-status-legend {
    font-size: 0.74rem;
    line-height: 1.35;
}

.ld-uik-tile {
    font-size: 0.86rem;
}

.ld-status-stat span {
    font-size: 0.68rem;
}

.ld-status-stat strong {
    font-size: 0.98rem;
}

.ld-segmented button {
    font-size: 0.74rem;
}

.ld-large-donut span,
.ld-structure-panel > footer,
.ld-lagging-panel > footer,
.ld-events-panel > footer {
    font-size: 0.72rem;
}

.ld-structure-row {
    font-size: 0.76rem;
    line-height: 1.3;
}

.ld-structure-row small {
    font-size: 0.7rem;
}

.ld-uik-badge,
.ld-lagging-copy strong,
.ld-lagging-delta {
    font-size: 0.76rem;
}

.ld-lagging-copy small,
.ld-event-row,
.ld-event-row strong,
.ld-event-row span {
    font-size: 0.7rem;
}

.ld-empty-list {
    font-size: 0.78rem;
}

.ld-ticker {
    min-height: 42px;
}

.ld-ticker-track {
    font-size: 0.76rem;
}

/* Контроль УИК. */
.kpi-live-state,
.kpi-section-heading p:not(.eyebrow),
.kpi-filter-note,
.kpi-level-tab span {
    font-size: 0.84rem;
}

.kpi-filters label > span,
.kpi-metric-label,
.kpi-metric-hint,
.kpi-trend-definition strong,
.kpi-table thead th {
    font-size: 0.78rem;
}

.kpi-metric-breakdown,
.kpi-trend-metric span,
.kpi-trend-metric small,
.kpi-trend-definition span,
.kpi-trend-day-label span,
.kpi-trend-item small,
.kpi-legend,
.kpi-uik-cell small,
.kpi-value-cell small,
.kpi-count-cell small,
.kpi-control-cell small,
.kpi-ballot-cell small {
    font-size: 0.74rem;
}

.kpi-status,
.kpi-ballot-form label,
.kpi-ballot-save {
    font-size: 0.72rem;
}

/* Калькулятор результата: операционные показатели и результаты прокручиваются независимо. */
.calc-results-table {
    font-size: 0.82rem;
}

.calc-results-operational-table {
    min-width: 1180px;
}

.calc-results-contest-table {
    min-width: max(720px, 100%);
}

.calc-results-table th button,
.calc-metric-label,
.calc-option-summary article p,
.calc-table-footnote,
.calc-modal-basics label > span,
.calc-spread-range > span,
.calc-municipality-grid label > span,
.calc-turnout-source-grid label > span,
.calc-editor-table th,
.calc-option-labels {
    font-size: 0.72rem;
}

.calc-results-table th small,
.calc-results-table td small.calc-quality-deviation-badge,
.calc-option-summary article small,
.calc-version-main em,
.calc-editor-tabs button small {
    font-size: 0.66rem;
}

.calc-results-table td small,
.calc-option-summary article p em,
.calc-version-main small,
.calc-editor-tabs button > span {
    font-size: 0.7rem;
}

/* Калькулятор явки содержит часть фиксированных пиксельных размеров из прежней версии. */
.turnout-plan-root .eyebrow,
.turnout-plan-root .login-note,
.turnout-plan-root .download-progress,
.turnout-plan-root .version-banner > div span,
.turnout-plan-root .version-banner p,
.turnout-plan-root .version-date,
.turnout-plan-root .metrics-grid small,
.turnout-plan-root .panel-badge,
.turnout-plan-root .day-number,
.turnout-plan-root .day-copy > div:first-child,
.turnout-plan-root .version-list strong,
.turnout-plan-root .search-box input,
.turnout-plan-root .detail-summary strong,
.turnout-plan-root .template-link {
    font-size: 12px;
}

.turnout-plan-root .sidebar-heading span,
.turnout-plan-root .project-item-copy small,
.turnout-plan-root .panel-heading > div > span,
.turnout-plan-root .day-copy small,
.turnout-plan-root .history-actions > button,
.turnout-plan-root .version-list small,
.turnout-plan-root .data-table th,
.turnout-plan-root .detail-summary span,
.turnout-plan-root .point-column small,
.turnout-plan-root .chart-legend,
.turnout-plan-root .cutoff-picker label > span,
.turnout-plan-root .cutoff-rule,
.turnout-plan-root .upload-zone span,
.turnout-plan-root .parsed-preview span,
.turnout-plan-root .warning-box {
    font-size: 11px;
}

.turnout-plan-root .primary-button,
.turnout-plan-root .secondary-button,
.turnout-plan-root .ghost-button,
.turnout-plan-root .icon-text-button,
.turnout-plan-root .new-project-button,
.turnout-plan-root .project-item-copy strong,
.turnout-plan-root .content-placeholder,
.turnout-plan-root .version-banner > div strong,
.turnout-plan-root .modal-lead,
.turnout-plan-root .upload-zone strong {
    font-size: 14px;
}

.turnout-plan-root .field-label,
.turnout-plan-root .form-field > span,
.turnout-plan-root .inline-error,
.turnout-plan-root .workspace-error,
.turnout-plan-root .sidebar-empty p,
.turnout-plan-root .workspace-topline > div:first-child > p:last-child,
.turnout-plan-root .day-share,
.turnout-plan-root .data-table,
.turnout-plan-root .parsed-preview strong,
.turnout-plan-root .saved-pill {
    font-size: 13px;
}

.turnout-plan-root .version-list b {
    font-size: 10px;
}

@media (max-width: 720px) {
    [data-theme="dark"] .topbar-context strong {
        font-size: 0.9rem;
    }

    .ld-kpi-card header,
    .ld-panel-heading h2 {
        font-size: 1rem;
    }

    .ld-status-stat span {
        white-space: normal;
    }

    [data-theme="dark"] .topbar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 102px;
        align-items: center;
        background: #020b15;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    .workspace-commandbar-actions .ld-control-button span {
        display: inline;
    }

    .workspace-commandbar-actions > :last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }
}

/* Этап 3: единые токены, геометрия и состояния интерактивных элементов. */
[data-theme="dark"] {
    --font-ui: Inter, "Segoe UI", Arial, sans-serif;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --radius-control: 10px;
    --radius-card: 12px;
    --radius-panel: 14px;
    --radius-overlay: 18px;
    --shadow-card: 0 12px 30px rgba(0, 0, 0, 0.26);
    --shadow-panel: 0 18px 46px rgba(0, 0, 0, 0.32);
    --shadow-overlay: 0 28px 84px rgba(0, 0, 0, 0.58);
    --motion-fast: 140ms;
    --motion-base: 200ms;
    --ease-standard: cubic-bezier(0.2, 0, 0, 1);
    --focus-color: #5af7d6;
    --focus-ring: 0 0 0 3px rgba(90, 247, 214, 0.24);
    --state-success: #42e7b5;
    --state-success-soft: rgba(34, 205, 154, 0.14);
    --state-error: #ff7a86;
    --state-error-soft: rgba(255, 94, 112, 0.14);
    --state-disabled: #6f8395;
    --radius: var(--radius-control);
}

[data-theme="dark"] body,
[data-theme="dark"] button,
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    font-family: var(--font-ui);
}

[data-theme="dark"] :where(h1, h2, h3, h4) {
    font-family: var(--font-ui);
    font-weight: 700;
    line-height: 1.16;
    letter-spacing: -0.018em;
}

[data-theme="dark"] :where(.eyebrow, .hero-label, .meta-caption) {
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: 0.075em;
}

[data-theme="dark"] :is(
    .workspace-commandbar,
    .hero,
    .table-card,
    .results-controls,
    .results-leaderboard,
    .reconcile-card,
    .reconcile-progress-card,
    .sections-hero,
    .sections-directory,
    .eg-hero,
    .kpi-intro,
    .kpi-filter-card,
    .kpi-panel,
    .ld-panel
) {
    border-radius: var(--radius-panel);
    box-shadow: var(--shadow-panel);
}

[data-theme="dark"] :is(
    .metric-card,
    .import-card,
    .leader-card,
    .result-card,
    .results-card,
    .contest-card,
    .section-card,
    .ld-kpi-card,
    .kpi-metric,
    .kpi-trend-metric,
    .kpi-trend-day,
    .kpi-mobile-card,
    .results-mobile-card,
    .results-mobile-filter-panel
) {
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
}

[data-theme="dark"] :is(.site-menu-panel, .ld-filter-panel, .calc-modal, .turnout-plan-root .modal-card) {
    border-radius: var(--radius-overlay);
    box-shadow: var(--shadow-overlay);
}

/* Основной мобильный дашборд также остаётся полностью в тёмной теме. */
[data-theme="dark"] .mobile-dashboard :is(
    .mobile-summary-hero,
    .mobile-control-panel,
    .mobile-list-section,
    .mobile-row-card,
    .mobile-metric-card
) {
    color: var(--text);
    border-color: var(--line);
    border-radius: var(--radius-card);
    background: linear-gradient(180deg, rgba(10, 28, 44, 0.98), rgba(6, 20, 33, 0.98));
    box-shadow: var(--shadow-card);
}

[data-theme="dark"] .mobile-dashboard .mobile-summary-hero {
    border-color: rgba(45, 214, 182, 0.32);
    background:
        linear-gradient(90deg, rgba(22, 215, 179, 0.12), transparent 42%),
        linear-gradient(180deg, rgba(10, 31, 47, 0.99), rgba(6, 20, 33, 0.99));
}

[data-theme="dark"] .mobile-dashboard .mobile-summary-copy h2,
[data-theme="dark"] .mobile-dashboard :is(.mobile-metric-card, .mobile-signal, .mobile-row-title, .mobile-row-metrics, .mobile-child-metrics) strong,
[data-theme="dark"] .mobile-dashboard .mobile-list-title h3,
[data-theme="dark"] .mobile-dashboard .mobile-child-name {
    color: var(--text);
}

[data-theme="dark"] .mobile-dashboard .mobile-update-card {
    color: var(--text);
    border-color: rgba(255, 172, 55, 0.34);
    background: linear-gradient(180deg, rgba(255, 172, 55, 0.13), rgba(8, 24, 39, 0.98));
}

[data-theme="dark"] .mobile-dashboard .mobile-update-card span:not(.mobile-update-icon),
[data-theme="dark"] .mobile-dashboard .mobile-update-icon {
    color: #ffc66f;
}

[data-theme="dark"] .mobile-dashboard .mobile-update-card strong {
    color: #fff2df;
}

[data-theme="dark"] .mobile-dashboard .mobile-note {
    color: #ffd99e;
    border-color: rgba(255, 172, 55, 0.32);
    background: rgba(255, 172, 55, 0.1);
}

[data-theme="dark"] .mobile-dashboard .mobile-metric-icon {
    color: var(--emerald-dark);
    background: rgba(22, 215, 179, 0.12);
}

[data-theme="dark"] .mobile-dashboard :is(.mobile-metric-label, .mobile-row-side, .mobile-row-metrics span, .mobile-row-metrics small, .mobile-child-row, .mobile-child-metrics span) {
    color: #a9bed1;
}

[data-theme="dark"] .mobile-dashboard .mobile-signal-good {
    color: #54f1d0;
    border-color: rgba(22, 215, 179, 0.28);
    background: linear-gradient(135deg, rgba(22, 215, 179, 0.2), rgba(6, 21, 34, 0.98));
}

[data-theme="dark"] .mobile-dashboard .mobile-signal-bad {
    color: #ff8793;
    border-color: rgba(255, 94, 112, 0.3);
    background: linear-gradient(135deg, rgba(255, 94, 112, 0.17), rgba(6, 21, 34, 0.98));
}

[data-theme="dark"] .mobile-dashboard .mobile-search-form {
    border-color: var(--line-strong);
    background: #061624;
}

[data-theme="dark"] .mobile-dashboard .mobile-search-form input[type="text"] {
    color: var(--text);
}

[data-theme="dark"] .mobile-dashboard .mobile-search-form input[type="text"]::placeholder,
[data-theme="dark"] .mobile-dashboard .mobile-search-icon {
    color: #8fa8bd;
}

[data-theme="dark"] .mobile-dashboard :is(.mobile-pill, .mobile-filter-button) {
    color: #b7c9d9;
    border-color: var(--line);
    background: #091b2a;
    box-shadow: none;
}

[data-theme="dark"] .mobile-dashboard .mobile-segment-group {
    border-color: var(--line);
    background: rgba(2, 11, 22, 0.62);
}

[data-theme="dark"] .mobile-dashboard :is(.mobile-pill-active, .mobile-segment-group .mobile-pill-active) {
    color: #03120f;
    border-color: rgba(71, 241, 207, 0.62);
    background: var(--emerald);
    box-shadow: 0 8px 22px rgba(22, 215, 179, 0.16);
}

[data-theme="dark"] .mobile-dashboard .mobile-excel-link {
    color: #55f0d0;
    border-color: rgba(22, 215, 179, 0.3);
    background: linear-gradient(180deg, rgba(22, 215, 179, 0.1), rgba(7, 22, 35, 0.98));
}

[data-theme="dark"] .mobile-dashboard .mobile-row-best {
    border-color: rgba(22, 215, 179, 0.28);
}

[data-theme="dark"] .mobile-dashboard .mobile-row-worst {
    border-color: rgba(255, 94, 112, 0.28);
}

[data-theme="dark"] .mobile-dashboard :is(.mobile-row-metrics, .mobile-row-details, .mobile-child-row) {
    border-color: var(--line);
}

[data-theme="dark"] .mobile-dashboard .mobile-row-metrics div,
[data-theme="dark"] .mobile-dashboard .mobile-child-metrics div:nth-child(2n) {
    border-color: var(--line);
}

[data-theme="dark"] .mobile-dashboard .mobile-row-side a,
[data-theme="dark"] .mobile-dashboard .mobile-row-details summary {
    color: #55f0d0;
}

[data-theme="dark"] .mobile-dashboard .mobile-row-details summary::after {
    border-color: currentColor;
}

[data-theme="dark"] .mobile-dashboard .mobile-child-metrics {
    border-color: var(--line);
    background: #061624;
}

[data-theme="dark"] .mobile-dashboard .mobile-child-metrics div {
    border-color: var(--line);
}

[data-theme="dark"] .mobile-dashboard .mobile-child-metrics div[aria-hidden="true"] {
    background: rgba(22, 215, 179, 0.05);
}

[data-theme="dark"] :is(.results-filter-form, .reconcile-upload-form, .kpi-filters, .ld-filter-panel) {
    gap: var(--space-3);
}

[data-theme="dark"] :where(
    .segmented-switch,
    .kpi-level-tabs,
    .turnout-election-tabs,
    .ld-structure-tabs
) {
    gap: var(--space-1);
    padding: var(--space-1);
    border-radius: var(--radius-card);
}

[data-theme="dark"] :where(
    button,
    summary,
    .button,
    .mode-pill,
    .mobile-pill,
    .mobile-excel-link,
    .mobile-icon-button,
    .text-link,
    .table-sort-link,
    .app-sidebar-footer-link,
    .mobile-row-open-link,
    .site-menu-item,
    .site-menu-close,
    .ld-control-button,
    .ld-icon-button,
    .turnout-election-tab,
    .results-mobile-card-action,
    .results-mobile-child-list a
) {
    min-height: 44px;
    border-radius: var(--radius-control);
    transition:
        color var(--motion-fast) var(--ease-standard),
        border-color var(--motion-fast) var(--ease-standard),
        background-color var(--motion-fast) var(--ease-standard),
        box-shadow var(--motion-base) var(--ease-standard),
        filter var(--motion-fast) var(--ease-standard),
        opacity var(--motion-fast) var(--ease-standard),
        transform var(--motion-fast) var(--ease-standard);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    font-weight: 700;
}

[data-theme="dark"] :where(.text-link, .table-sort-link, .app-sidebar-footer-link, .mobile-row-open-link, .mobile-excel-link, .results-mobile-card-action, .results-mobile-child-list a) {
    display: inline-flex;
    align-items: center;
}

[data-theme="dark"] .data-table th:has(> .table-sort-link) {
    padding-block: 7px;
}

[data-theme="dark"] .data-table th > .table-sort-link {
    min-height: 44px;
}

[data-theme="dark"] :where(
    input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
    select,
    textarea
) {
    min-height: 44px;
    border-radius: var(--radius-control);
    transition:
        color var(--motion-fast) var(--ease-standard),
        border-color var(--motion-fast) var(--ease-standard),
        background-color var(--motion-fast) var(--ease-standard),
        box-shadow var(--motion-base) var(--ease-standard),
        opacity var(--motion-fast) var(--ease-standard);
}

[data-theme="dark"] input[type="file"] {
    min-height: 52px;
    padding: var(--space-2);
}

[data-theme="dark"] :where(input, select, textarea) {
    font-weight: 500;
}

[data-theme="dark"] :is(
    .ld-icon-button,
    .mobile-icon-button,
    .site-menu-close,
    .eg-mobile-sort-direction,
    .calc-icon-button,
    .turnout-plan-root .icon-button
) {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
}

[data-theme="dark"] :is(
    .ld-segmented button,
    .calc-level-tabs button,
    .calc-contest-tabs button,
    .calc-editor-tabs button,
    .calc-editor-table input,
    .calc-version-main,
    .calc-priority-radio,
    .turnout-plan-root .history-actions > button
) {
    min-height: 44px;
}

[data-theme="dark"] :is(.ld-segmented button, .calc-level-tabs button, .calc-contest-tabs button) {
    min-width: 44px;
}

[data-theme="dark"] :is(
    .turnout-plan-root .square-button,
    .turnout-plan-root .version-delete
) {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
}

[data-theme="dark"] .turnout-plan-root .cutoff-picker select {
    min-height: 44px;
}

[data-theme="dark"] input[type="file"]::file-selector-button {
    min-width: 44px;
    min-height: 44px;
    margin-inline-end: var(--space-3);
    padding: var(--space-2) var(--space-4);
    color: #06131d;
    font: inherit;
    font-weight: 700;
    border: 1px solid rgba(90, 247, 214, 0.36);
    border-radius: var(--radius-control);
    background: #42e7c3;
    cursor: pointer;
    transition:
        filter var(--motion-fast) var(--ease-standard),
        transform var(--motion-fast) var(--ease-standard),
        opacity var(--motion-fast) var(--ease-standard);
}

[data-theme="dark"] .calc-priority-radio {
    min-width: 44px;
}

[data-theme="dark"] .mobile-search-form button {
    width: 1px;
    min-width: 1px;
    height: 1px;
    min-height: 1px;
    padding: 0;
    border-radius: 0;
}

@media (hover: hover) and (pointer: fine) {
    [data-theme="dark"] :where(
        button,
        summary,
        .button,
        .mode-pill,
        .mobile-pill,
        .mobile-excel-link,
        .mobile-icon-button,
        .text-link,
        .table-sort-link,
        .app-sidebar-footer-link,
        .mobile-row-open-link,
        .site-menu-item,
        .site-menu-close,
        .ld-control-button,
        .ld-icon-button,
        .turnout-election-tab,
        .results-mobile-card-action,
        .results-mobile-child-list a
    ):hover:not(:disabled):not([aria-disabled="true"]) {
        border-color: rgba(90, 247, 214, 0.54);
        filter: brightness(1.07);
    }

    [data-theme="dark"] :where(input, select, textarea):hover:not(:disabled) {
        border-color: rgba(119, 178, 213, 0.52);
    }

    [data-theme="dark"] input[type="file"]:not(:disabled)::file-selector-button:hover {
        filter: brightness(1.07);
    }
}

[data-theme="dark"] :where(
    a[href],
    button,
    input,
    select,
    textarea,
    summary,
    [tabindex]:not([tabindex="-1"])
):focus-visible {
    outline: 3px solid var(--focus-color);
    outline-offset: 3px;
    box-shadow: var(--focus-ring);
}

[data-theme="dark"] :where(
    button,
    summary,
    .button,
    .mode-pill,
    .mobile-pill,
    .mobile-excel-link,
    .mobile-icon-button,
    .text-link,
    .table-sort-link,
    .app-sidebar-footer-link,
    .mobile-row-open-link,
    .site-menu-item,
    .ld-control-button,
    .ld-icon-button,
    .turnout-election-tab,
    .results-mobile-card-action,
    .results-mobile-child-list a
):active:not(:disabled):not([aria-disabled="true"]) {
    filter: brightness(0.96);
    transform: translateY(1px) scale(0.99);
}

[data-theme="dark"] :where(button, input, select, textarea):disabled,
[data-theme="dark"] :where(
    a[href],
    .button,
    .mode-pill,
    .mobile-pill,
    .text-link,
    summary,
    [role="button"],
    [role="tab"]
)[aria-disabled="true"] {
    color: var(--state-disabled);
    border-color: rgba(111, 131, 149, 0.2);
    background-color: rgba(70, 89, 105, 0.14);
    box-shadow: none;
    filter: saturate(0.62);
    opacity: 0.56;
    cursor: not-allowed;
}

[data-theme="dark"] input[type="file"]:active:not(:disabled)::file-selector-button {
    filter: brightness(0.96);
    transform: translateY(1px) scale(0.99);
}

[data-theme="dark"] input[type="file"]:disabled::file-selector-button {
    color: var(--state-disabled);
    background: rgba(70, 89, 105, 0.14);
    filter: saturate(0.62);
    opacity: 0.56;
    cursor: not-allowed;
}

[data-theme="dark"] :where(button, .button, .ld-control-button, .ld-icon-button)[aria-busy="true"],
[data-theme="dark"] form[aria-busy="true"] :where(button[type="submit"], input[type="submit"]) {
    position: relative;
    padding-inline-end: 42px;
    cursor: progress;
}

[data-theme="dark"] :where(
    a[href],
    button,
    summary,
    input,
    select,
    textarea,
    [role="button"],
    [role="tab"]
)[data-ui-state="loading"] {
    cursor: progress;
    opacity: 0.76;
}

[data-theme="dark"] :where(button, .button, .ld-control-button, .ld-icon-button)[aria-busy="true"]::after,
[data-theme="dark"] form[aria-busy="true"] button[type="submit"]::after {
    content: "";
    position: absolute;
    top: 50%;
    inset-inline-end: 14px;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: ui-state-spin 0.75s linear infinite;
}

[data-theme="dark"] :where(button, .button, input, select, textarea)[data-ui-state="success"],
[data-theme="dark"] :where(a[href], summary, [role="button"], [role="tab"])[data-ui-state="success"],
[data-theme="dark"] :where(button, .button, input, select, textarea).is-success {
    border-color: rgba(66, 231, 181, 0.66);
    background-color: var(--state-success-soft);
    box-shadow: 0 0 0 3px rgba(66, 231, 181, 0.1);
}

[data-theme="dark"] :is(.reconcile-progress-card, .kpi-ballot-form)[data-ui-state="loading"] {
    border-color: rgba(255, 172, 55, 0.46);
    box-shadow: var(--shadow-panel), inset 3px 0 0 var(--warning);
}

[data-theme="dark"] :is(.reconcile-progress-card, .kpi-ballot-form)[data-ui-state="success"] {
    border-color: rgba(66, 231, 181, 0.56);
    box-shadow: var(--shadow-panel), inset 3px 0 0 var(--state-success);
}

[data-theme="dark"] :is(.reconcile-progress-card, .kpi-ballot-form)[data-ui-state="error"] {
    border-color: rgba(255, 122, 134, 0.62);
    box-shadow: var(--shadow-panel), inset 3px 0 0 var(--state-error);
}

[data-theme="dark"] .alert-success {
    color: var(--state-success);
    border-color: rgba(66, 231, 181, 0.38);
    background: var(--state-success-soft);
}

[data-theme="dark"] :is(.alert-danger, .reconcile-error, .kpi-message-error) {
    color: var(--state-error);
}

[data-theme="dark"] :where(button, .button, input, select, textarea)[data-ui-state="error"],
[data-theme="dark"] :where(a[href], summary, [role="button"], [role="tab"])[data-ui-state="error"],
[data-theme="dark"] :where(button, .button, input, select, textarea).is-error,
[data-theme="dark"] :where(input, select, textarea)[aria-invalid="true"] {
    border-color: rgba(255, 122, 134, 0.78);
    background-color: var(--state-error-soft);
    box-shadow: 0 0 0 3px rgba(255, 94, 112, 0.1);
}

[data-theme="dark"] :where(button, [role="tab"])[aria-pressed="true"],
[data-theme="dark"] :where(button, [role="tab"])[aria-selected="true"] {
    border-color: rgba(66, 231, 181, 0.52);
    box-shadow: inset 0 0 0 1px rgba(66, 231, 181, 0.16);
}

@keyframes ui-state-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    [data-theme="dark"] *,
    [data-theme="dark"] *::before,
    [data-theme="dark"] *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    [data-theme="dark"] :where(button, .button, .ld-control-button, .ld-icon-button)[aria-busy="true"]::after,
    [data-theme="dark"] form[aria-busy="true"] button[type="submit"]::after {
        animation: none;
    }

    [data-theme="dark"] :is(
        .calc-sidebar-loading svg,
        .calc-file-progress svg,
        .calc-button svg.lucide-loader-circle,
        .calc-overlay-loading svg
    ) {
        animation: none !important;
    }
}

@media (prefers-contrast: more) {
    [data-theme="dark"] {
        --text-soft: #c5d5e2;
        --text-muted: #b4c7d6;
        --line: rgba(196, 225, 244, 0.44);
        --line-strong: rgba(211, 236, 250, 0.72);
        --focus-color: #8bffe8;
        --focus-ring: 0 0 0 4px rgba(139, 255, 232, 0.34);
        --state-disabled: #acbdca;
        --ld-gray: #b4c7d6;
    }

    [data-theme="dark"] :where(
        a[href],
        button,
        input,
        select,
        textarea,
        summary,
        [tabindex]:not([tabindex="-1"])
    ):focus-visible {
        outline-width: 4px;
    }

    [data-theme="dark"] :where(button, input, select, textarea):disabled,
    [data-theme="dark"] :where(
        a[href],
        .button,
        summary,
        [role="button"],
        [role="tab"]
    )[aria-disabled="true"] {
        filter: none;
        opacity: 0.82;
    }
}

@media (forced-colors: active) {
    [data-theme="dark"] :where(
        button,
        input,
        select,
        textarea,
        summary,
        .button,
        [role="button"],
        [role="tab"]
    ) {
        box-shadow: none !important;
    }

    [data-theme="dark"] :where(
        a[href],
        button,
        input,
        select,
        textarea,
        summary,
        [tabindex]:not([tabindex="-1"])
    ):focus-visible {
        outline: 3px solid Highlight !important;
        outline-offset: 3px !important;
        box-shadow: none !important;
    }

    [data-theme="dark"] :is(
        [aria-current="page"],
        [aria-selected="true"],
        [aria-pressed="true"],
        .mode-pill-active,
        .app-sidebar .site-menu-item-active,
        .site-menu-panel .site-menu-item-active,
        .calc-project.is-active,
        .calc-level-tabs button.is-active,
        .calc-contest-tabs button.is-active,
        .calc-editor-tabs button.is-active,
        .calc-version.is-active .calc-version-main,
        .turnout-plan-root .project-item.is-active,
        .turnout-plan-root .version-open.is-current
    ) {
        forced-color-adjust: none;
        color: HighlightText !important;
        border-color: Highlight !important;
        background: Highlight !important;
        box-shadow: none !important;
    }

    [data-theme="dark"] :is(
        [aria-current="page"],
        [aria-selected="true"],
        [aria-pressed="true"],
        .mode-pill-active,
        .app-sidebar .site-menu-item-active,
        .site-menu-panel .site-menu-item-active,
        .calc-project.is-active,
        .calc-level-tabs button.is-active,
        .calc-contest-tabs button.is-active,
        .calc-editor-tabs button.is-active,
        .calc-version.is-active .calc-version-main,
        .turnout-plan-root .project-item.is-active,
        .turnout-plan-root .version-open.is-current
    ) :where(span, strong, small, svg) {
        color: HighlightText !important;
        background: transparent !important;
    }

    [data-theme="dark"] :is(
        [data-ui-state="error"],
        .is-error,
        .alert-danger,
        .reconcile-error,
        .kpi-message-error,
        .kpi-control-cell.is-mismatch,
        .kpi-ballot-cell.is-mismatch,
        .kpi-status.is-missing,
        .kpi-status.is-rejected
    ),
    [data-theme="dark"] :where(input, select, textarea)[aria-invalid="true"],
    [data-theme="dark"] .kpi-table tbody tr.is-missing > td {
        border: 3px double CanvasText !important;
        box-shadow: none !important;
    }

    [data-theme="dark"] :is(
        [data-ui-state="success"],
        .is-success,
        .alert-success,
        .kpi-control-cell.is-match,
        .kpi-ballot-result.is-ok
    ) {
        border: 3px solid CanvasText !important;
        box-shadow: none !important;
    }

    [data-theme="dark"] :is(
        [data-ui-state="loading"],
        [aria-busy="true"],
        .is-loading,
        .kpi-control-cell.is-pending,
        .kpi-status.is-late,
        .kpi-status.is-draft,
        .kpi-status.is-extra
    ),
    [data-theme="dark"] .kpi-table tbody tr.is-extra > td {
        border: 2px dashed CanvasText !important;
        box-shadow: none !important;
    }

    [data-theme="dark"] :where(button, input, select, textarea):disabled,
    [data-theme="dark"] :where(
        a[href],
        .button,
        summary,
        [role="button"],
        [role="tab"]
    )[aria-disabled="true"] {
        color: GrayText !important;
        border-color: GrayText !important;
        filter: none !important;
        opacity: 1 !important;
    }

    [data-theme="dark"] :is(.workspace-freshness, .kpi-live-state).is-live {
        border: 2px solid CanvasText !important;
    }

    [data-theme="dark"] :is(.workspace-freshness, .kpi-live-state).is-loading {
        border: 2px dashed CanvasText !important;
    }

    [data-theme="dark"] :is(.workspace-freshness, .kpi-live-state).is-error {
        border: 3px double CanvasText !important;
    }

    [data-theme="dark"] :is(.workspace-freshness-dot, .kpi-live-dot, .ld-live-dot) {
        forced-color-adjust: none;
        border: 1px solid CanvasText !important;
        background: CanvasText !important;
        box-shadow: none !important;
    }

    [data-theme="dark"] :is(
        .progress-track,
        .kpi-progress,
        .kpi-cell-progress,
        .reconcile-progress-track,
        .kpi-trend-bar
    ) {
        border: 1px solid CanvasText !important;
        background: Canvas !important;
        box-shadow: none !important;
    }

    [data-theme="dark"] :is(
        .progress-track > span,
        .kpi-progress > span,
        .kpi-cell-progress > span,
        .reconcile-progress-track > span,
        .kpi-trend-bar > span
    ) {
        forced-color-adjust: none;
        background: Highlight !important;
        box-shadow: none !important;
    }

    [data-theme="dark"] .kpi-trend-item.is-current .kpi-trend-bar {
        outline: 2px solid Highlight !important;
        outline-offset: 2px !important;
    }

    [data-theme="dark"] .kpi-trend-target {
        border-top: 2px dashed CanvasText !important;
        filter: none !important;
    }

    [data-theme="dark"] .ld-uik-tile {
        forced-color-adjust: none;
        color: CanvasText !important;
        border: 2px solid CanvasText !important;
        background: Canvas !important;
        box-shadow: none !important;
    }

    [data-theme="dark"] .ld-uik-tile.is-attention {
        border-style: dashed !important;
    }

    [data-theme="dark"] .ld-uik-tile.is-critical {
        color: HighlightText !important;
        border: 3px double HighlightText !important;
        background: Highlight !important;
    }

    [data-theme="dark"] .ld-uik-tile.is-no-data {
        color: GrayText !important;
        border-color: GrayText !important;
        border-style: dotted !important;
    }

    [data-theme="dark"] :is(.ld-chart-legend .is-plan, .ld-chart-legend .is-plan-gd, .ld-chart-legend .is-plan-mod) {
        border-top: 2px dashed CanvasText !important;
        background: transparent !important;
    }

    [data-theme="dark"] .ld-help-progress,
    [data-theme="dark"] .ld-help-days > span {
        border: 1px solid CanvasText !important;
        background: Canvas !important;
    }

    [data-theme="dark"] .ld-help-progress > span {
        forced-color-adjust: none;
        background: Highlight !important;
    }

    [data-theme="dark"] .ld-chart-legend .is-gd {
        forced-color-adjust: none;
        background: Highlight !important;
    }

    [data-theme="dark"] .ld-chart-legend .is-mod {
        border-top: 2px dotted CanvasText !important;
        background: transparent !important;
    }

    [data-theme="dark"] .ld-status-legend .is-normal,
    [data-theme="dark"] .kpi-legend .is-good {
        background: CanvasText !important;
    }

    [data-theme="dark"] .ld-status-legend .is-attention,
    [data-theme="dark"] .kpi-legend .is-progress {
        border: 2px dashed CanvasText !important;
        background: Canvas !important;
    }

    [data-theme="dark"] .ld-status-legend .is-critical,
    [data-theme="dark"] .kpi-legend .is-missing {
        forced-color-adjust: none;
        background: Highlight !important;
    }

    [data-theme="dark"] .ld-status-legend .is-no-data {
        border: 2px dotted GrayText !important;
        background: Canvas !important;
    }

    [data-theme="dark"] .ui-popover {
        color: CanvasText !important;
        border: 1px solid CanvasText !important;
        background: Canvas !important;
        box-shadow: none !important;
    }
}
