/* Shared theme controls. Page-specific typography and layout are preserved. */
html[data-theme="light"] { color-scheme:light; }
html[data-theme="dark"] {
    color-scheme:dark;
    --theme-text:#e7edf3;
    --theme-muted:#adbdca;
    --theme-surface:#162531;
    --theme-alt:#1c2e3c;
    --theme-hover:#243b4b;
    --theme-border:#344957;
    --theme-field:#101f2b;
    --theme-accent:#ff947f;
    --theme-success:#a6dfbc;
    --theme-success-bg:#183c32;
    --theme-error:#ffc3b7;
    --theme-error-bg:#422922;
    --theme-selected:#dfeaf3;
    --theme-selected-text:#142a39;
    --dt-html-background:var(--theme-surface);
    --dt-row-stripe:255,255,255;
    --dt-row-hover:255,255,255;
    --dt-column-ordering:255,255,255;
}
.bm .bm-theme-toggle {
    display:inline-flex; align-items:center; justify-content:center; gap:9px;
    flex-shrink:0; min-height:44px; padding:10px 13px; border:1px solid var(--line);
    border-radius:5px; color:var(--ink); background:transparent; font-size:16px; cursor:pointer;
}
.bm .bm-theme-toggle[hidden] { display:none; }
.bm-theme-toggle .fa { font-size:18px; }
.bm .bm-theme-toggle:hover { background:#edf2f5; }
.bm .bm-theme-toggle[aria-pressed="true"] { border-color:#788e9e; }
@media(min-width:801px) and (max-width:1100px) {
    .bm .bm-header-inner { gap:18px; }
    .bm .bm-navigation { gap:16px; }
    .bm .bm-navigation a { font-size:16px; }
    .bm .bm-header-cta { display:none; }
}
@media(max-width:800px) {
    .bm-theme-toggle { order:2; }
}
@media(max-width:520px) {
    .bm .bm-header-inner { gap:8px; }
    .bm .bm-theme-toggle { width:44px; padding:0; margin-left:auto; }
    .bm-theme-toggle>span,.bm-menu-toggle>span { display:none; }
    .bm .bm-menu-toggle { width:44px; min-height:44px; padding:0; margin-left:0; justify-content:center; }
}
html[data-theme="dark"] .bm {
    --ink:var(--theme-text); --muted:var(--theme-muted); --line:var(--theme-border);
    --paper:#0e1923; --red:var(--theme-accent);
}
/* Canvas, cards and navigation. */
html[data-theme="dark"] .bm :is(.bm-header,.bm-navigation,.bm-values,.bm-event,.block_cup_list_item,.zero-block,.br-card,.br-filter,.ar-filters,.ar-year-links a,.ar-event,.bc-toolbar,.bc-cups a,.bc-season-form,.bc-info-card,.bz-navigation,.bz-search,.bz-table,.bz-about,.bz-criteria-grid>div,.bz-empty,.ar-empty,.br-no-participants,.br-search-empty) {
    background:var(--theme-surface); border-color:var(--theme-border);
}
html[data-theme="dark"] .bm :is(.bm-community,.ar-next,.bz-next,.br-count) { background:var(--theme-alt); }
html[data-theme="dark"] .bm .list-view .empty { background:transparent; border-color:var(--theme-border); }
html[data-theme="dark"] .bm .partner-list .item { background:var(--theme-surface); border-color:var(--theme-border); }
html[data-theme="dark"] .bm .bm-community-target { border-color:#526b7a; }
html[data-theme="dark"] .bm .bm-community-target:before { border-color:#526b7a; }
html[data-theme="dark"] .bm .bm-community-target i { box-shadow:0 0 0 10px var(--theme-alt); }
html[data-theme="dark"] .bm :is(.bm-header-cta:hover,.bm-theme-toggle:hover,.br-choice:hover) { background:var(--theme-hover); }
html[data-theme="dark"] .bm .bm-event-top { border-color:var(--theme-border); }
html[data-theme="dark"] .bm .bm-event-meta>span { color:#8197a7; }
html[data-theme="dark"] .bm :is(.bm-navigation a[aria-current],.bm-navigation a:hover,.bc-cups a[aria-current],.bz-navigation a[aria-current],.bm a.bm-text-link:hover) { color:var(--theme-accent); }
html[data-theme="dark"] .bm .bc-cups a[aria-current] { background:#392b2b; border-color:#805149; }
html[data-theme="dark"] .bm .bm-skip { background:var(--theme-surface); }
/* Muted text needs lighter colors on dark surfaces. */
html[data-theme="dark"] .bm :is(.bm-event-description,.bm-event-meta,.bm-event-year,.bm-section-description,.bm-community p,.br-description,.br-change,.br-form-hint,.br-document small,.br-checklist li,.br-back,.ar-description,.ar-location,.ar-full-date,.ar-action,.ar-next p,.ar-stats span,.bc-intro,.bc-athlete-region,.bc-detail-meta,.bc-detail-date,.bc-table-note,.bc-season-form label,.bz-intro,.bz-filter-count,.bz-stage-label,.bz-criteria-grid p,.bz-next p,.text-muted) { color:var(--theme-muted)!important; }
html[data-theme="dark"] .bm :is(.ar-result-status,.bm-status-0,.br-selected-athlete) { color:var(--theme-success); }
html[data-theme="dark"] .bm .ar-result-status.is-pending { color:#edc88f; }
html[data-theme="dark"] .bm .bm-status-0 i { background:var(--theme-success); }
html[data-theme="dark"] .bm :is(.br-choice,.br-choice:first-child) { background:var(--theme-field); border-color:var(--theme-border); }
html[data-theme="dark"] .bm .br-choice:first-child { border-color:#a96659; }
html[data-theme="dark"] .bm .br-choice-icon { background:var(--theme-alt); color:#c4d7e5; }
html[data-theme="dark"] .bm .br-choice:first-child .br-choice-icon { background:#422d29; color:var(--theme-accent); }
html[data-theme="dark"] .bm :is(.br-choice>span:not(.br-choice-icon),.br-form-hint,.br-fee-note,.br-lead,.br-deadline>span,.br-document small) { color:var(--theme-muted); }
html[data-theme="dark"] .bm .br-fee-note { border-color:var(--theme-border); }
/* Buttons and selected filters. */
html[data-theme="dark"] .bm :is(a,button).bm-button-red { background:#bc3b30; color:#fff; }
html[data-theme="dark"] .bm :is(a,button).bm-button-red:hover { background:#cc493d; }
html[data-theme="dark"] .bm :is(a,button).bm-button-dark { background:var(--theme-selected); color:var(--theme-selected-text); }
html[data-theme="dark"] .bm :is(a,button).bm-button-dark:hover { background:#c8dbe9; }
html[data-theme="dark"] .bm .ar-year-links a>span { color:var(--theme-muted); }
html[data-theme="dark"] .bm .ar-year-links a[aria-current] { background:var(--theme-selected); border-color:var(--theme-selected); color:var(--theme-selected-text); }
html[data-theme="dark"] .bm .ar-year-links a[aria-current]>span { color:#4d6372; }
html[data-theme="dark"] .bm .ar-protocol { color:var(--theme-accent)!important; background:#342923; border-color:#815248; }
html[data-theme="dark"] .bm .ar-protocol:hover { background:#483128; }
html[data-theme="dark"] .bm .bc-season-form select { background:var(--theme-surface); color:var(--theme-text); }
html[data-theme="dark"] .bm .bc-season-form button { color:var(--theme-accent); }
html[data-theme="dark"] .bm .bc-info-tabs>li>a { color:var(--theme-muted); }
html[data-theme="dark"] .bm .bc-info-tabs>li.active>a { color:var(--theme-accent); }
html[data-theme="dark"] .bm .age_wrapper .nav>li>a { background:var(--theme-surface); color:var(--theme-muted); border-color:var(--theme-border); }
html[data-theme="dark"] .bm .age_wrapper .nav>li.active>a { background:var(--theme-selected); color:var(--theme-selected-text); border-color:var(--theme-selected); }
html[data-theme="dark"] .bm .bz-navigation a { color:var(--theme-muted); }
html[data-theme="dark"] .bm .bz-navigation a[aria-current] { color:var(--theme-accent); }
html[data-theme="dark"] .bm .bz-navigation a>span { color:var(--theme-muted); background:var(--theme-alt); }
html[data-theme="dark"] .bm .bz-stage-label { color:var(--theme-muted); background:var(--theme-surface); border-color:var(--theme-border); }
/* Inputs, validation and dynamically loaded forms. */
html[data-theme="dark"] .bm :is(.ar-search,.ar-year-select,.br-filter,.bz-search) { background:var(--theme-field); border-color:var(--theme-border); color:var(--theme-muted); }
html[data-theme="dark"] .bm :is(.ar-search input,.ar-year-select select,.br-filter input,.bz-search input) { color:var(--theme-text); background:transparent; }
html[data-theme="dark"] .bm :is(input,textarea)::placeholder { color:#a3b3c0; opacity:1; }
html[data-theme="dark"] .bm .requestForm .control-label { color:#c7d6e1; }
html[data-theme="dark"] .bm .requestForm .form-control { background:var(--theme-field)!important; border-color:#526b7c!important; color:var(--theme-text); }
html[data-theme="dark"] .bm .requestForm .form-control:focus { background:var(--theme-surface)!important; border-color:#96b8ce!important; outline-color:#5e7f96; }
html[data-theme="dark"] .bm .requestForm .form-control.error { background:var(--theme-error-bg)!important; border-color:#ba7768!important; }
html[data-theme="dark"] .bm select option { background:var(--theme-surface); color:var(--theme-text); }
html[data-theme="dark"] .bm .br-check-row input[type=checkbox]+label { color:var(--theme-text); }
html[data-theme="dark"] .bm .br-check-row input[type=checkbox] { accent-color:#e36f5b; }
html[data-theme="dark"] .bm :is(.br-form-status,.ar-error,.alert-danger) { color:var(--theme-error); background:var(--theme-error-bg); border-color:#8a5a4e; }
html[data-theme="dark"] .bm .alert-success { color:var(--theme-success); background:var(--theme-success-bg); border-color:#477461; }
html[data-theme="dark"] .bm .form_auto #empty-message { color:var(--theme-error); }
html[data-theme="dark"] .br-autocomplete.ui-menu { background:var(--theme-surface); border-color:var(--theme-border); }
html[data-theme="dark"] .br-autocomplete.ui-menu .ui-menu-item a { color:var(--theme-text); }
html[data-theme="dark"] .br-autocomplete.ui-menu :is(.ui-state-focus,.ui-state-hover) { background:var(--theme-hover); border-color:#628298; }
html[data-theme="dark"] #ui-datepicker-div { background:var(--theme-surface); border-color:var(--theme-border); }
html[data-theme="dark"] #ui-datepicker-div * { color:var(--theme-text); }
html[data-theme="dark"] #ui-datepicker-div :is(.ui-widget-header,.ui-state-default,select) { background:var(--theme-alt); border-color:var(--theme-border); }
html[data-theme="dark"] #ui-datepicker-div :is(.ui-state-hover,.ui-state-active) { background:var(--theme-hover); border-color:#8ba8bc; }
/* Tables: ranks, shooting details, participants and authored Zero lists. */
html[data-theme="dark"] .bm :is(.table-responsive,.sportsmen_requests-list) { background:var(--theme-surface); border-color:var(--theme-border); }
html[data-theme="dark"] .bm .table { color:var(--theme-text); border-color:var(--theme-border); }
html[data-theme="dark"] .bm .table th { background:var(--theme-alt); color:#bacdd9; border-color:var(--theme-border); }
html[data-theme="dark"] .bm .table td { border-color:var(--theme-border); color:var(--theme-text); }
html[data-theme="dark"] .bm .table tr:nth-child(odd)>td { background:transparent; }
html[data-theme="dark"] .bm .table tr:hover>td { background:var(--theme-hover); }
html[data-theme="dark"] .bm .table :is(.text-center,.text-right) { color:var(--theme-text); }
html[data-theme="dark"] .bm .bm-request .sportsmen_requests-list :is(th,td) { border-color:var(--theme-border); }
html[data-theme="dark"] .bm .bm-request .sportsmen_requests-list th { background:var(--theme-alt); color:#bacdd9; }
html[data-theme="dark"] .bm .bm-request .sportsmen_requests-list td { color:var(--theme-muted); }
html[data-theme="dark"] .bm .bm-request .sportsmen_requests-list td:first-child { color:var(--theme-text); }
html[data-theme="dark"] .bm .bm-request .sportsmen_requests-list tr:hover td { background:var(--theme-hover); }
html[data-theme="dark"] .bm .bm-cup .new_cup_table .table th { background:var(--theme-alt)!important; color:#bacdd9; border-color:var(--theme-border); }
html[data-theme="dark"] .bm .bm-cup .new_cup_table .table td { color:var(--theme-text); border-color:var(--theme-border); }
html[data-theme="dark"] .bm .bm-cup .new_cup_table .table tr:nth-child(odd)>td { background:transparent; }
html[data-theme="dark"] .bm .bm-cup .new_cup_table .table tr:hover>td { background:var(--theme-hover); }
html[data-theme="dark"] .bm .bm-cup .new_cup_table .table tr>td.success { background:var(--theme-success-bg)!important; color:var(--theme-success)!important; }
html[data-theme="dark"] .bm .bm-cup .new_cup_table .table tr>td.skipped_points { background:#442e27!important; color:#ffb59e!important; }
html[data-theme="dark"] .bm .bc-points-key:before { background:#442e27; border-color:#98664d; }
html[data-theme="dark"] .bm .bm-cup .accuracy-details .table td:first-child { color:var(--theme-text); }
html[data-theme="dark"] .bm .bm-cup .accuracy-details .breadcrumb { background:var(--theme-alt); }
html[data-theme="dark"] .bm .bm-cup .accuracy-details .breadcrumb a { color:var(--theme-accent); }
html[data-theme="dark"] .bm .bm-cup .accuracy-details-trigger { background:var(--theme-field); color:#c0d8e8; border-color:#587180; }
html[data-theme="dark"] .bm .bm-cup .bc-calendar :is(th,td) { border-color:var(--theme-border); }
html[data-theme="dark"] .bm .bm-cup .bc-calendar th { background:var(--theme-alt); color:#bacdd9; }
html[data-theme="dark"] .bm .bm-zero .bz-table table th { background:var(--theme-alt); color:#bacdd9; border-color:var(--theme-border); }
html[data-theme="dark"] .bm .bm-zero .bz-table table td { color:var(--theme-text); border-color:var(--theme-border); }
html[data-theme="dark"] .bm .bz-group-alt { background:#1b2d3a; }
html[data-theme="dark"] .bm .bm-zero .bz-table table .bz-number { color:var(--theme-accent); }
html[data-theme="dark"] .bm .bm-zero .bz-table table .bz-athlete .text-muted { color:var(--theme-muted); }
html[data-theme="dark"] .bm .bm-archive .list-view .yiiPager li a { background:var(--theme-surface); color:var(--theme-text); border-color:var(--theme-border); }
html[data-theme="dark"] .bm .bm-archive .list-view .yiiPager li.selected a { background:var(--theme-selected); color:var(--theme-selected-text); border-color:var(--theme-selected); }
html[data-theme="dark"] .bm :is(.bc-rules,.bz-about) [style*="color"] { color:inherit!important; }
html[data-theme="dark"] body { background:#0e1923; color:var(--theme-text); }
/* Bootstrap 3 also colors the row itself; transparent cells must not expose a light stripe. */
html[data-theme="dark"] .bm .table-striped>tbody>tr { background:transparent; }
html[data-theme="dark"] .bm .table-striped>tbody>tr:nth-child(odd) { background:var(--theme-alt); }
html[data-theme="dark"] .bm .table tr.success>td { background:var(--theme-success-bg); color:var(--theme-success); }
html[data-theme="dark"] .bm .bm-cup .table td.sorting_1 { background:var(--theme-alt); }
html[data-theme="dark"] .bm-request .br-onboarding-result {
    background:var(--theme-error-bg);
    border-color:#8a5a4e;
    color:var(--theme-error);
}
html[data-theme="dark"] .bm-request .br-onboarding-result h3 { color:var(--theme-text); }
html[data-theme="dark"] .bm .br-onboarding-label { color:var(--theme-accent); }
html[data-theme="dark"] .bm .br-onboarding-icon,
html[data-theme="dark"] .bm .br-onboarding-steps li:before {
    background:#61372e;
    color:var(--theme-error);
}
html[data-theme="dark"] .bm .br-onboarding-steps { border-color:#85584d; }
