.app-return-btn {
    min-height: 40px;
    padding: 0 20px;
    border: 0;
    border-radius: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #6c757d;
    color: #fff;
    cursor: pointer;
    font: 600 14px "Segoe UI", Tahoma, sans-serif;
    text-decoration: none;
    transition: background .2s ease;
}
.app-return-btn:hover { background:#5a6268; }

.theme-toggle {
    position: fixed;
    right: max(18px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 9999;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 1px solid #c8d5e6;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    color: #17356f;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .18);
    cursor: pointer;
    font: 700 24px/1 "Segoe UI Symbol", "Segoe UI", sans-serif;
    transition: transform .16s ease, background .16s ease, border-color .16s ease, color .16s ease;
}
.theme-toggle:hover { transform: translateY(-2px); background:#f4f8fd; border-color:#91acd0; }
.theme-toggle:focus-visible { outline:3px solid rgba(18,103,179,.32); outline-offset:3px; }

html[data-theme="dark"] {
    color-scheme: dark;
    --app-navy: #d9e6fb;
    --app-blue: #62a9e8;
    --app-green: #52c58a;
    --app-red: #f0767f;
    --app-ink: #e6edf7;
    --app-muted: #9fb0c5;
    --app-bg: #0b1220;
    --app-line: #2b3c54;
    --app-panel: #111c2e;
}
html[data-theme="dark"] body { background:#0b1220 !important; color:#e6edf7 !important; }
html[data-theme="dark"] .theme-toggle { background:#18263b; border-color:#3a506d; color:#ffd66b; box-shadow:0 8px 26px rgba(0,0,0,.42); }
html[data-theme="dark"] .theme-toggle:hover { background:#22324a; border-color:#607998; }

html[data-theme="dark"] .main-container,
html[data-theme="dark"] .login-container,
html[data-theme="dark"] .login-form,
html[data-theme="dark"] .signup-popup,
html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .sidebar-header,
html[data-theme="dark"] .sidebar-content,
html[data-theme="dark"] .results-panel,
html[data-theme="dark"] .results-header,
html[data-theme="dark"] .app-panel,
html[data-theme="dark"] .mixer-panel,
html[data-theme="dark"] .calc-sidebar,
html[data-theme="dark"] .calc-results-panel,
html[data-theme="dark"] .calc-sidebar-header,
html[data-theme="dark"] .calc-results-header,
html[data-theme="dark"] .calc-sidebar-footer,
html[data-theme="dark"] .calc-results-footer,
html[data-theme="dark"] .calc-modal,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .section,
html[data-theme="dark"] .card,
html[data-theme="dark"] .product-option,
html[data-theme="dark"] .entry-card,
html[data-theme="dark"] .entry-card .card-header,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .chart-panel,
html[data-theme="dark"] .chart-legend-box,
html[data-theme="dark"] .op-point-card,
html[data-theme="dark"] .summary-card,
html[data-theme="dark"] .diagram-container,
html[data-theme="dark"] .desc-box,
html[data-theme="dark"] .filter-container,
html[data-theme="dark"] .filters,
html[data-theme="dark"] .multi-select-dropdown,
html[data-theme="dark"] .notice,
html[data-theme="dark"] .empty,
html[data-theme="dark"] .summary-box,
html[data-theme="dark"] .multi-quote-bar,
html[data-theme="dark"] #info_lastTenLoginsList,
html[data-theme="dark"] #reducerControlBlock,
html[data-theme="dark"] .column,
html[data-theme="dark"] .result,
html[data-theme="dark"] .mixer-result-card,
html[data-theme="dark"] .mixer-type-card,
html[data-theme="dark"] .quotation-line,
html[data-theme="dark"] .form-section {
    background:#111c2e !important;
    color:#e6edf7 !important;
    border-color:#2b3c54 !important;
    box-shadow:none;
}

html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .multi-select-display,
html[data-theme="dark"] .dropdown-search-input {
    background:#0d1727 !important;
    color:#e6edf7 !important;
    border-color:#3a4d67 !important;
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color:#71839a !important; opacity:1; }
html[data-theme="dark"] input:disabled,
html[data-theme="dark"] select:disabled,
html[data-theme="dark"] textarea:disabled { background:#172337 !important; color:#8293a9 !important; }
html[data-theme="dark"] option { background:#111c2e; color:#e6edf7; }

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] .app-title,
html[data-theme="dark"] .sidebar-title,
html[data-theme="dark"] .res-title,
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .mixer-type-name,
html[data-theme="dark"] .section-title,
html[data-theme="dark"] .summary-value,
html[data-theme="dark"] .chart-title,
html[data-theme="dark"] .chart-legend-box h4,
html[data-theme="dark"] .op-point-card strong,
html[data-theme="dark"] .desc-title,
html[data-theme="dark"] .model,
html[data-theme="dark"] dt,
html[data-theme="dark"] label { color:#dbe8fb !important; }
html[data-theme="dark"] .switch-label,
html[data-theme="dark"] .active-check,
html[data-theme="dark"] .form-row label,
html[data-theme="dark"] .data-group label,
html[data-theme="dark"] .column strong { color:#cbd9eb !important; }
html[data-theme="dark"] .mixer-step { color:#9fb0c5 !important; border-color:#40526a !important; }
html[data-theme="dark"] .mixer-step.is-active { color:#82bff0 !important; border-color:#62a9e8 !important; }
html[data-theme="dark"] .mixer-type-card:has(input:checked) .mixer-type-name { color:#eef6ff !important; }
html[data-theme="dark"] p,
html[data-theme="dark"] .app-subtitle,
html[data-theme="dark"] .subtitle,
html[data-theme="dark"] .res-sub,
html[data-theme="dark"] .summary-label,
html[data-theme="dark"] .summary-sub,
html[data-theme="dark"] .data-label,
html[data-theme="dark"] .chart-sub,
html[data-theme="dark"] .chart-note,
html[data-theme="dark"] .metric,
html[data-theme="dark"] small { color:#9fb0c5 !important; }
html[data-theme="dark"] .data-value,
html[data-theme="dark"] .highlight-value,
html[data-theme="dark"] .val-rpm,
html[data-theme="dark"] .val-kw,
html[data-theme="dark"] .column span,
html[data-theme="dark"] dd,
html[data-theme="dark"] td { color:#e0e8f3 !important; }

html[data-theme="dark"] table { color:#e6edf7; }
html[data-theme="dark"] th { background:#1d3b72 !important; color:#fff !important; border-color:#36517a !important; }
html[data-theme="dark"] td { background:#111c2e !important; border-color:#293a51 !important; }
html[data-theme="dark"] tr:nth-child(even) td { background:#142136 !important; }
html[data-theme="dark"] tr:hover td { background:#1a2a42 !important; }
html[data-theme="dark"] .tech-table tbody th { background:#172337 !important; color:#b7c6da !important; }
html[data-theme="dark"] .row-highlight td { background:#17304b !important; color:#eaf4ff !important; }

html[data-theme="dark"] .summary-card,
html[data-theme="dark"] .chart-legend-box,
html[data-theme="dark"] .op-point-card { background:#142136 !important; }
html[data-theme="dark"] .summary dt,
html[data-theme="dark"] dl dt,
html[data-theme="dark"] .mixer-summary dt { background:#172337 !important; }
html[data-theme="dark"] .selection-detail-item dt { background:transparent !important; }
html[data-theme="dark"] .footer-actions { background:#101a2b !important; border-color:#2b3c54 !important; }
html[data-theme="dark"] .modal-header { border-color:#40526a !important; }
html[data-theme="dark"] .table-area,
html[data-theme="dark"] .sidebar-footer { background:#101a2b !important; border-color:#2b3c54 !important; }
html[data-theme="dark"] .entry-card.disabled { background:#142033 !important; }
html[data-theme="dark"] .entry-card.active .card-header { border-color:#2b3c54 !important; }
html[data-theme="dark"] .toggle-btn:hover,
html[data-theme="dark"] .number-spinner button:hover { background:#263852 !important; color:#e6edf7 !important; }
html[data-theme="dark"] .number-spinner { background:#172337 !important; border-color:#3a4d67 !important; }
html[data-theme="dark"] .slider { background:#40526a !important; }
html[data-theme="dark"] input:checked + .slider { background:#397eb7 !important; }
html[data-theme="dark"] .readonly { background:#172b43 !important; color:#dce9fa !important; }
html[data-theme="dark"] .code-header-cell { background:#172b47 !important; color:#e8f0fb !important; border-color:#345274 !important; }
html[data-theme="dark"] .line-vertical,
html[data-theme="dark"] .line-corner,
html[data-theme="dark"] .line-horizontal { border-color:#7890ad !important; }
html[data-theme="dark"] .filter-title { color:#e6edf7 !important; }
html[data-theme="dark"] .options-list label:hover { background:#1a2a42 !important; }
html[data-theme="dark"] .options-list label { color:#d7e2f0 !important; }
html[data-theme="dark"] .selection-nav button.is-active,
html[data-theme="dark"] .mixer-type-card:has(input:checked) { background:#18304d !important; border-color:#62a9e8 !important; }
html[data-theme="dark"] .product-badge { background:#1b3554 !important; color:#bcd9f5 !important; }
html[data-theme="dark"] .app-btn-secondary,
html[data-theme="dark"] .mixer-secondary,
html[data-theme="dark"] .button.secondary,
html[data-theme="dark"] .btn.ghost { background:#172337 !important; color:#dce9fa !important; border-color:#3b506b !important; }
html[data-theme="dark"] .app-btn-secondary:hover,
html[data-theme="dark"] .mixer-secondary:hover { background:#21314a !important; }
html[data-theme="dark"] a:not(.app-btn):not(.app-return-btn):not(.btn):not(.button):not(.action-link):not(.detail-btn) { color:#7dbcf0; }
html[data-theme="dark"] hr { border-color:#2b3c54; }
html[data-theme="dark"] .chart-legend-marker { background:#111c2e !important; }
html[data-theme="dark"] .flash-messages li { background:#172b43 !important; color:#c9e3fb !important; border-color:#315478 !important; }
html[data-theme="dark"] .message { box-shadow:0 8px 24px rgba(0,0,0,.44); }
html[data-theme="dark"] .notes-box { background:#351b29 !important; border-color:#623047 !important; color:#ffafc2 !important; }
html[data-theme="dark"] .revision-banner { background:#352e18 !important; border-color:#6e5b25 !important; color:#ffe59a !important; }
html[data-theme="dark"] .product-revision-banner { background:#352e18 !important; border-color:#6e5b25 !important; color:#ffe59a !important; }
html[data-theme="dark"] .product-revision-banner strong { color:#ffd978 !important; }
html[data-theme="dark"] .product-revision-code { background:#473b1b !important; border-color:#806b2d !important; color:#fff1b5 !important; }
html[data-theme="dark"] .summary-box strong,
html[data-theme="dark"] .totals,
html[data-theme="dark"] .panel-head h2 { color:#dbe8fb !important; }
html[data-theme="dark"] .cards .card strong { color:#e8f2ff !important; }
html[data-theme="dark"] .summary-box { background:#142136 !important; border-color:#2b3c54 !important; color:#e0e8f3 !important; }
html[data-theme="dark"] .source-model { color:#edf5ff !important; }
html[data-theme="dark"] .source-meta,
html[data-theme="dark"] .source-count { color:#9fb0c5 !important; }
html[data-theme="dark"] .source-type { background:#183b5c !important; color:#bfe0fb !important; }
html[data-theme="dark"] .source-empty { color:#9fb0c5 !important; border-color:#40526a !important; background:#101a2b !important; }
html[data-theme="dark"] .source-add-btn:disabled { background:#26364c !important; color:#91a2b8 !important; }
html[data-theme="dark"] #directMotorControlBlock {
    background:#101c2e !important;
    border-color:#36506f !important;
    box-shadow:inset 0 1px 0 rgba(255,255,255,.03);
}
html[data-theme="dark"] #directMotorControlBlock .motor-pole-option {
    background:#17263b !important;
    border-color:#3a506d !important;
    color:#c8d6e9 !important;
}
html[data-theme="dark"] #directMotorControlBlock .motor-pole-option:hover {
    background:#20334d !important;
    border-color:#577392 !important;
}
html[data-theme="dark"] #directMotorControlBlock .motor-pole-option:has(input:checked) {
    background:#183b5c !important;
    border-color:#62a9e8 !important;
    color:#f0f7ff !important;
}
html[data-theme="dark"] #directMotorControlBlock #directMotorSelect {
    background:#0d1929 !important;
    border-color:#47617f !important;
    color:#eef5ff !important;
}

.message + .theme-toggle { bottom:76px; }

@media (max-width:760px) {
    .theme-toggle { right:14px; bottom:14px; width:44px; height:44px; }
}

@media print {
    .theme-toggle { display:none !important; }
    html { color-scheme:light !important; }
    html[data-theme="dark"] body,
    html[data-theme="dark"] .main-container,
    html[data-theme="dark"] .app-panel,
    html[data-theme="dark"] .section,
    html[data-theme="dark"] .card,
    html[data-theme="dark"] td { background:#fff !important; color:#111 !important; }
}
