/* ================================================================
   StratoFi Theme System
   ================================================================
   Part 1: :root dark mode defaults
   Part 2: html[data-theme="light"] light mode variable overrides
   Part 3: Light mode element-level overrides (hardcoded values)
   Part 4: Theme toggle button styles
   ================================================================ */

/* ================================================================
   PART 1: Dark Mode Defaults (:root)
   These must match the existing dark theme values exactly.
   ================================================================ */
:root {
    /* Brand colors */
    --apple-blue: #007AFF;
    --apple-purple: #5E5CE6;
    --midnight-black: #0a0a0a;
    --space-gray: #1c1c1e;
    --primary-color: #667eea;

    /* Surface colors */
    --card-bg: rgba(28, 28, 30, 0.7);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --border-color: rgba(255, 255, 255, 0.1);

    /* Text colors */
    --text-primary: rgba(255, 255, 255, 0.95);
    --text-secondary: rgba(255, 255, 255, 0.6);
    --text-tertiary: rgba(255, 255, 255, 0.4);

    /* Accent colors */
    --accent-green: #38a169;
    --accent-red: #e53e3e;
    --accent-yellow: #d69e2e;
    --accent-orange: #dd6b20;

    /* Semantic colors */
    --success: #4caf50;
    --warning: #ffc107;
    --error: #f44336;
    --info: #007AFF;

    /* Theme-aware colors */
    --body-bg: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #16213e 100%);
    --nav-bg: rgba(10, 10, 10, 0.7);
    --hover-bg: rgba(255, 255, 255, 0.08);
    --hover-bg-strong: rgba(255, 255, 255, 0.12);
    --table-header-bg: rgba(102, 126, 234, 0.1);
    --overlay-bg: rgba(0, 0, 0, 0.7);
    --shadow-color: rgba(0, 0, 0, 0.5);
    --shadow-color-light: rgba(0, 0, 0, 0.3);
    --scrollbar-thumb: rgba(255, 255, 255, 0.2);
    --scrollbar-thumb-hover: rgba(255, 255, 255, 0.3);
    --card-top-border: rgba(255, 255, 255, 0.1);
    --input-bg: rgba(255, 255, 255, 0.05);
    --badge-success-bg: rgba(76, 175, 80, 0.15);
    --badge-error-bg: rgba(244, 67, 54, 0.15);
    --badge-warning-bg: rgba(255, 193, 7, 0.15);
    --tooltip-bg: rgba(28, 28, 30, 0.98);
    --sidebar-bg: rgba(15, 15, 17, 0.98);
    --toast-bg: rgba(0, 0, 0, 0.85);
}


/* ================================================================
   PART 2: Light Mode Variable Overrides
   html[data-theme="light"] has specificity (0,0,1,1), higher than
   :root (0,0,1,0), so it overrides in-page <style> blocks.
   ================================================================ */
html[data-theme="light"] {
    /* Brand - slightly adjusted for light bg */
    --midnight-black: #f5f5f7;
    --space-gray: #ffffff;

    /* Surface colors */
    --card-bg: rgba(255, 255, 255, 0.85);
    --glass-bg: rgba(0, 0, 0, 0.03);
    --border-color: rgba(0, 0, 0, 0.1);

    /* Text colors */
    --text-primary: rgba(0, 0, 0, 0.87);
    --text-secondary: rgba(0, 0, 0, 0.54);
    --text-tertiary: rgba(0, 0, 0, 0.38);

    /* Theme-aware colors */
    --body-bg: #f5f5f7;
    --nav-bg: rgba(255, 255, 255, 0.85);
    --hover-bg: rgba(0, 0, 0, 0.04);
    --hover-bg-strong: rgba(0, 0, 0, 0.08);
    --table-header-bg: rgba(245, 245, 247, 0.95);
    --overlay-bg: rgba(0, 0, 0, 0.4);
    --shadow-color: rgba(0, 0, 0, 0.12);
    --shadow-color-light: rgba(0, 0, 0, 0.08);
    --scrollbar-thumb: rgba(0, 0, 0, 0.2);
    --scrollbar-thumb-hover: rgba(0, 0, 0, 0.35);
    --card-top-border: rgba(0, 0, 0, 0.06);
    --input-bg: rgba(0, 0, 0, 0.04);
    --badge-success-bg: rgba(76, 175, 80, 0.1);
    --badge-error-bg: rgba(244, 67, 54, 0.1);
    --badge-warning-bg: rgba(255, 193, 7, 0.1);
    --tooltip-bg: rgba(255, 255, 255, 0.98);
    --sidebar-bg: rgba(245, 245, 247, 0.98);
    --toast-bg: rgba(50, 50, 50, 0.9);
}


/* ================================================================
   PART 3: Light Mode Element-Level Overrides
   Covers hardcoded dark values in <style> blocks and inline styles.
   Uses html[data-theme="light"] prefix for sufficient specificity.
   ================================================================ */

/* --- Body background --- */
html[data-theme="light"] body {
    background: #f5f5f7 !important;
    color: var(--text-primary);
}

/* --- Navigation --- */
html[data-theme="light"] .glass-nav {
    background: rgba(255, 255, 255, 0.85) !important;
    border-bottom-color: rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* --- Nav menu (index.html) --- */
html[data-theme="light"] .nav-menu {
    background: rgba(0, 0, 0, 0.04) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
}

html[data-theme="light"] .nav-item:hover {
    background: rgba(0, 0, 0, 0.06) !important;
}

/* --- Nav links (alert-center.html) --- */
html[data-theme="light"] .nav-link:hover {
    background: rgba(0, 0, 0, 0.06) !important;
}

/* --- Cards --- */
html[data-theme="light"] .apple-card {
    background: rgba(255, 255, 255, 0.85) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .apple-card::before {
    background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.06), transparent) !important;
}

html[data-theme="light"] .apple-card:hover {
    border-color: rgba(0, 0, 0, 0.15) !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12) !important;
}

/* --- Stat cards (index.html) --- */
html[data-theme="light"] .stat-card {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.06) 0%, rgba(118, 75, 162, 0.06) 100%) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
}

html[data-theme="light"] .stat-card:hover {
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.15) !important;
}

/* --- Alert stat cards (alert-center.html) --- */
html[data-theme="light"] .stat-card:not(.stat-card:hover) {
    border-color: rgba(0, 0, 0, 0.1);
}

/* --- Chart container --- */
html[data-theme="light"] .chart-container {
    background: rgba(255, 255, 255, 0.85) !important;
}

/* --- Exchange cards --- */
html[data-theme="light"] .exchange-card {
    background: rgba(255, 255, 255, 0.85) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
}

html[data-theme="light"] .exchange-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1) !important;
}

/* --- Data rows --- */
html[data-theme="light"] .data-row {
    border-bottom-color: rgba(0, 0, 0, 0.06) !important;
}

/* --- Control panel --- */
html[data-theme="light"] .control-panel {
    background: rgba(0, 0, 0, 0.03) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
}

/* --- Input & select (exclude checkbox/radio/range) --- */
html[data-theme="light"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
html[data-theme="light"] select {
    background: rgba(0, 0, 0, 0.04) !important;
    border-color: rgba(0, 0, 0, 0.15) !important;
    color: var(--text-primary) !important;
}

html[data-theme="light"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):focus,
html[data-theme="light"] select:focus {
    background: rgba(0, 0, 0, 0.02) !important;
    border-color: #007AFF !important;
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1) !important;
}

html[data-theme="light"] input::placeholder {
    color: rgba(0, 0, 0, 0.35) !important;
}

/* --- Select options --- */
html[data-theme="light"] select option {
    background: #ffffff !important;
    background-color: #ffffff !important;
    color: var(--text-primary) !important;
}

html[data-theme="light"] select option:hover {
    background: rgba(0, 122, 255, 0.1) !important;
}

html[data-theme="light"] select option:checked {
    background: rgba(0, 122, 255, 0.15) !important;
    background-color: rgba(0, 122, 255, 0.15) !important;
    color: #007AFF !important;
}

html[data-theme="light"] select {
    color-scheme: light !important;
}

/* --- Scanner table --- */
html[data-theme="light"] .scanner-table thead {
    background: rgba(245, 245, 247, 0.95) !important;
}

html[data-theme="light"] .scanner-table th {
    border-bottom-color: rgba(0, 0, 0, 0.1) !important;
}

html[data-theme="light"] .scanner-table th.sortable:hover {
    background: rgba(0, 0, 0, 0.06) !important;
}

html[data-theme="light"] .scanner-table td {
    border-bottom-color: rgba(0, 0, 0, 0.06) !important;
}

html[data-theme="light"] .scanner-table tbody tr:hover {
    background: rgba(0, 0, 0, 0.03) !important;
}

/* --- Scanner table container --- */
html[data-theme="light"] .scanner-table-container {
    background: rgba(255, 255, 255, 0.85) !important;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

/* --- Scanner wrapper --- */
html[data-theme="light"] .scanner-wrapper {
    background: rgba(255, 255, 255, 0.7) !important;
}

/* --- Scanner column sidebar --- */
html[data-theme="light"] .scanner-column-sidebar {
    background: rgba(245, 245, 247, 0.98) !important;
}

html[data-theme="light"] .scanner-sidebar-header {
    background: rgba(0, 0, 0, 0.03) !important;
}

html[data-theme="light"] .scanner-column-option:hover {
    background: rgba(0, 0, 0, 0.04) !important;
}

html[data-theme="light"] .scanner-sidebar-footer button {
    background: rgba(0, 0, 0, 0.04) !important;
}

html[data-theme="light"] .scanner-sidebar-footer button:hover {
    background: rgba(0, 0, 0, 0.08) !important;
}

/* --- Scanner column toggle button ("列") --- */
html[data-theme="light"] .scanner-column-toggle-btn {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.18) !important;
    color: rgba(0, 0, 0, 0.7) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .scanner-column-toggle-btn:hover {
    background: rgba(102, 126, 234, 0.08) !important;
    border-color: rgba(102, 126, 234, 0.4) !important;
    color: #667eea !important;
}

html[data-theme="light"] .scanner-column-toggle-btn.active {
    background: rgba(0, 122, 255, 0.12) !important;
    border-color: #007AFF !important;
    color: #007AFF !important;
}

/* --- Column toggle button (futures page "列") --- */
html[data-theme="light"] .column-toggle-btn {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.18) !important;
    color: rgba(0, 0, 0, 0.7) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .column-toggle-btn:hover {
    background: rgba(102, 126, 234, 0.08) !important;
    border-color: rgba(102, 126, 234, 0.4) !important;
    color: #667eea !important;
}

html[data-theme="light"] .column-toggle-btn.active {
    background: rgba(0, 122, 255, 0.12) !important;
    border-color: #007AFF !important;
    color: #007AFF !important;
}

/* --- Sort buttons ("费率优先" etc.) --- */
html[data-theme="light"] .sort-btn {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.18) !important;
    color: rgba(0, 0, 0, 0.6) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .sort-btn:hover {
    background: rgba(102, 126, 234, 0.08) !important;
    border-color: rgba(102, 126, 234, 0.4) !important;
    color: #667eea !important;
}

html[data-theme="light"] .sort-btn.active {
    background: rgba(0, 122, 255, 0.12) !important;
    border-color: #007AFF !important;
    color: #007AFF !important;
}

/* --- View buttons --- */
html[data-theme="light"] .view-btn {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.15) !important;
    color: rgba(0, 0, 0, 0.6) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

html[data-theme="light"] .view-btn:hover {
    background: rgba(102, 126, 234, 0.06) !important;
    border-color: rgba(102, 126, 234, 0.3) !important;
}

html[data-theme="light"] .view-btn.active {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%) !important;
    border-color: #667eea !important;
    color: #4a3d8f !important;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

/* --- Alert sidebar --- */
html[data-theme="light"] .alert-sidebar {
    background: rgba(255, 255, 255, 0.95) !important;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.1) !important;
}

html[data-theme="light"] .alert-sidebar-overlay {
    background: rgba(0, 0, 0, 0.3) !important;
}

html[data-theme="light"] .alert-sidebar-header {
    background: rgba(0, 0, 0, 0.03) !important;
}

html[data-theme="light"] .alert-sidebar-submit {
    background: rgba(0, 0, 0, 0.03) !important;
}

html[data-theme="light"] .alert-sidebar-close {
    background: rgba(0, 0, 0, 0.04) !important;
}

html[data-theme="light"] .alert-sidebar-close:hover {
    background: rgba(0, 0, 0, 0.08) !important;
}

/* --- Sidebar rule items --- */
html[data-theme="light"] .sidebar-rule-item {
    background: rgba(0, 0, 0, 0.02) !important;
}

html[data-theme="light"] .sidebar-rule-item:hover {
    background: rgba(0, 0, 0, 0.04) !important;
}

html[data-theme="light"] .sidebar-rule-actions button {
    background: rgba(0, 0, 0, 0.04) !important;
}

html[data-theme="light"] .sidebar-rule-actions button:hover {
    background: rgba(0, 0, 0, 0.08) !important;
}

/* --- Scanner alert styles --- */
html[data-theme="light"] .scanner-alert-rule {
    background: rgba(0, 0, 0, 0.03) !important;
}

html[data-theme="light"] .scanner-alert-toggle {
    background: rgba(0, 0, 0, 0.03) !important;
}

/* --- Toggle switch --- */
html[data-theme="light"] .scanner-alert-toggle .slider,
html[data-theme="light"] .toggle-slider {
    background: rgba(0, 0, 0, 0.12) !important;
    border-color: rgba(0, 0, 0, 0.15) !important;
}

html[data-theme="light"] .scanner-alert-toggle input:checked + .slider,
html[data-theme="light"] .toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    border-color: transparent !important;
}

/* --- Modal --- */
html[data-theme="light"] .modal {
    background: rgba(0, 0, 0, 0.4) !important;
}

html[data-theme="light"] .modal-content {
    background: rgba(255, 255, 255, 0.95) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15) !important;
}

html[data-theme="light"] .modal-close:hover {
    background: rgba(0, 0, 0, 0.06) !important;
}

/* --- Tab buttons --- */
html[data-theme="light"] .tab-btn {
    background: rgba(0, 0, 0, 0.04) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
}

html[data-theme="light"] .tab-btn:hover {
    background: rgba(0, 0, 0, 0.06) !important;
}

html[data-theme="light"] .tab-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border-color: transparent !important;
}

/* --- Sort condition items --- */
html[data-theme="light"] .sort-condition-item {
    background: rgba(0, 0, 0, 0.03) !important;
}

html[data-theme="light"] .sort-condition-item:hover {
    background: rgba(0, 0, 0, 0.05) !important;
}

html[data-theme="light"] .sort-condition-select select {
    background: rgba(0, 0, 0, 0.04) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
}

html[data-theme="light"] .sort-condition-select select:hover {
    background: rgba(0, 0, 0, 0.06) !important;
}

html[data-theme="light"] .sort-action-btn {
    background: rgba(0, 0, 0, 0.04) !important;
}

html[data-theme="light"] .sort-action-btn:hover {
    background: rgba(0, 0, 0, 0.08) !important;
}

/* --- Feature cards --- */
html[data-theme="light"] .feature-card {
    background: rgba(255, 255, 255, 0.85) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
}

html[data-theme="light"] .feature-card:hover {
    box-shadow: 0 16px 40px rgba(102, 126, 234, 0.15) !important;
}

/* --- Checkbox items --- */
html[data-theme="light"] .checkbox-item {
    background: rgba(0, 0, 0, 0.03) !important;
}

html[data-theme="light"] .checkbox-item:hover {
    background: rgba(0, 0, 0, 0.05) !important;
}

/* --- Apple button (gradient buttons like 预警规则, 开始扫描) --- */
html[data-theme="light"] .apple-button {
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.25);
}

html[data-theme="light"] .apple-button:hover {
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.35) !important;
}

/* --- Filter buttons (exchange filters) --- */
html[data-theme="light"] .filter-btn {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.15) !important;
    color: rgba(0, 0, 0, 0.6) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

html[data-theme="light"] .filter-btn:hover {
    background: rgba(0, 0, 0, 0.04) !important;
}

html[data-theme="light"] .filter-btn.active {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.12) 0%, rgba(118, 75, 162, 0.12) 100%) !important;
    border-color: var(--apple-purple) !important;
    color: rgba(0, 0, 0, 0.8) !important;
}

/* --- Time buttons (futures page) --- */
html[data-theme="light"] .time-btn {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.15) !important;
    color: rgba(0, 0, 0, 0.6) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

html[data-theme="light"] .time-btn:hover {
    background: rgba(0, 0, 0, 0.04) !important;
    color: rgba(0, 0, 0, 0.8) !important;
}

html[data-theme="light"] .time-btn.active {
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.25);
}

/* --- Apple button disabled --- */
html[data-theme="light"] .apple-button:disabled {
    background: rgba(0, 0, 0, 0.08) !important;
    color: rgba(0, 0, 0, 0.35) !important;
}

/* --- Orderbook --- */
html[data-theme="light"] .orderbook-side {
    background: rgba(0, 0, 0, 0.02) !important;
    border-color: rgba(0, 0, 0, 0.06) !important;
}

/* --- About card list item border --- */
html[data-theme="light"] .about-card li {
    border-bottom-color: rgba(0, 0, 0, 0.06) !important;
}

/* --- Highlight box --- */
html[data-theme="light"] .highlight-box {
    background: rgba(102, 126, 234, 0.05) !important;
}

/* --- Code inline --- */
html[data-theme="light"] .code-inline {
    background: rgba(0, 0, 0, 0.06) !important;
}

/* --- Alert rules list refresh button --- */
html[data-theme="light"] .alert-rules-list-title .refresh-btn {
    background: rgba(0, 0, 0, 0.04) !important;
}

html[data-theme="light"] .alert-rules-list-title .refresh-btn:hover {
    background: rgba(0, 0, 0, 0.08) !important;
}

/* --- Scanner control --- */
html[data-theme="light"] .scanner-control {
    background: rgba(0, 0, 0, 0.03) !important;
}

/* --- Login container --- */
html[data-theme="light"] .login-container {
    background: rgba(255, 255, 255, 0.9) !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1) !important;
}

/* --- Login tabs --- */
html[data-theme="light"] .tabs {
    background: rgba(0, 0, 0, 0.04) !important;
}

html[data-theme="light"] .tab.active {
    background: rgba(0, 0, 0, 0.08) !important;
}

/* --- Login form input --- */
html[data-theme="light"] .form-input {
    background: rgba(0, 0, 0, 0.04) !important;
    border-color: rgba(0, 0, 0, 0.15) !important;
}

html[data-theme="light"] .form-input:focus {
    background: rgba(0, 0, 0, 0.02) !important;
}

/* --- Scrollbar --- */
html[data-theme="light"] ::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03) !important;
}

html[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2) !important;
}

html[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.35) !important;
}

/* --- Loading spinner --- */
html[data-theme="light"] .loading:before {
    border-color: rgba(102, 126, 234, 0.2) !important;
    border-top-color: #667eea !important;
}

/* --- Status badges --- */
html[data-theme="light"] .status {
    background: rgba(255, 193, 7, 0.08) !important;
}

html[data-theme="light"] .status.connected {
    background: rgba(76, 175, 80, 0.08) !important;
}

html[data-theme="light"] .status.error {
    background: rgba(244, 67, 54, 0.08) !important;
}

/* --- Toast notification --- */
html[data-theme="light"] #toast,
html[data-theme="light"] #copyToast {
    background-color: rgba(50, 50, 50, 0.9) !important;
    color: white !important;
}


/* ================================================================
   PART 3B: Futures-Arbitrage Specific Overrides
   ================================================================ */

/* --- Tooltip --- */
html[data-theme="light"] .tooltip-content {
    background: rgba(255, 255, 255, 0.98) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12) !important;
    color: var(--text-primary) !important;
}

html[data-theme="light"] .tooltip-content::after {
    border-top-color: rgba(255, 255, 255, 0.98) !important;
}

html[data-theme="light"] .tooltip-content.tooltip-bottom::after {
    border-bottom-color: rgba(255, 255, 255, 0.98) !important;
}

/* --- Modal overlay --- */
html[data-theme="light"] .modal-overlay {
    background: rgba(0, 0, 0, 0.4) !important;
}

html[data-theme="light"] .modal-overlay .modal,
html[data-theme="light"] .modal-overlay > div:not(.modal-overlay) {
    background: #ffffff !important;
    color: var(--text-primary) !important;
}

/* --- Merged table header --- */
html[data-theme="light"] #merged-table th {
    background: rgba(245, 245, 247, 0.98) !important;
    color: var(--text-primary) !important;
}

/* --- Column sidebar (futures-arbitrage) --- */
html[data-theme="light"] .column-sidebar {
    background: rgba(245, 245, 247, 0.98) !important;
}

/* --- Merged column panel --- */
html[data-theme="light"] .merged-column-panel {
    background: #ffffff !important;
}

/* --- Funding history --- */
html[data-theme="light"] .funding-history-scroll {
    background: rgba(0, 0, 0, 0.02) !important;
}

/* --- Sort button --- */
html[data-theme="light"] .sort-btn {
    color: rgba(0, 0, 0, 0.5) !important;
}

/* --- Timer badge --- */
html[data-theme="light"] .timer-badge {
    background: rgba(56, 161, 105, 0.1) !important;
}

/* --- User info --- */
html[data-theme="light"] .user-info {
    background: rgba(94, 92, 230, 0.06) !important;
    border-color: rgba(94, 92, 230, 0.2) !important;
}

/* --- View slider --- */
html[data-theme="light"] .view-slider {
    background: rgba(0, 0, 0, 0.06) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
}

/* --- Apple button secondary --- */
html[data-theme="light"] .apple-button.secondary {
    background: rgba(0, 0, 0, 0.06) !important;
    color: var(--text-primary) !important;
}

html[data-theme="light"] .apple-button.secondary:hover {
    background: rgba(0, 0, 0, 0.1) !important;
}

/* --- Funding history hints --- */
html[data-theme="light"] .funding-history-hint.short {
    color: #c53030 !important;
    background: rgba(229, 62, 62, 0.1) !important;
}

html[data-theme="light"] .funding-history-hint.long {
    color: #276749 !important;
    background: rgba(56, 161, 105, 0.1) !important;
}


/* ================================================================
   PART 3C: Alert Center Specific Overrides
   ================================================================ */

/* --- Tabs container --- */
html[data-theme="light"] .tabs-container {
    background: rgba(255, 255, 255, 0.85) !important;
}

/* --- Tab buttons (alert center) --- */
html[data-theme="light"] .tab-button:hover {
    background: rgba(0, 0, 0, 0.04) !important;
}

html[data-theme="light"] .tab-button.active {
    background: rgba(0, 0, 0, 0.06) !important;
}

/* --- Rule items --- */
html[data-theme="light"] .rule-item {
    background: rgba(0, 0, 0, 0.02) !important;
}

html[data-theme="light"] .rule-item:hover {
    background: rgba(0, 0, 0, 0.04) !important;
    border-color: rgba(0, 0, 0, 0.15) !important;
}

/* --- Action buttons --- */
html[data-theme="light"] .action-button {
    background: rgba(0, 0, 0, 0.06) !important;
}

html[data-theme="light"] .action-button:hover {
    background: rgba(0, 0, 0, 0.1) !important;
}

/* --- Filter select --- */
html[data-theme="light"] .filter-select {
    background: rgba(0, 0, 0, 0.04) !important;
}

/* --- Timeline items --- */
html[data-theme="light"] .timeline-item {
    background: rgba(0, 0, 0, 0.02) !important;
}

html[data-theme="light"] .timeline-item:hover {
    background: rgba(0, 0, 0, 0.04) !important;
    border-color: rgba(0, 0, 0, 0.15) !important;
}

/* --- Global switch --- */
html[data-theme="light"] .global-switch {
    background: rgba(56, 161, 105, 0.1) !important;
}

html[data-theme="light"] .global-switch.disabled {
    background: rgba(229, 62, 62, 0.1) !important;
}

/* --- Stat icon --- */
html[data-theme="light"] .stat-icon {
    background: rgba(0, 0, 0, 0.04) !important;
}


/* ================================================================
   PART 3D: Inline Style Overrides (need !important)
   These cover JS-generated elements with hardcoded inline styles
   ================================================================ */

/* --- Elements with hardcoded white-on-dark text (#fff / color: #fff) --- */
/* Exclude buttons with gradient backgrounds (they keep white text) */
html[data-theme="light"] [style*="color: #fff"]:not([style*="linear-gradient"]),
html[data-theme="light"] [style*="color:#fff"]:not([style*="linear-gradient"]) {
    color: var(--text-primary) !important;
}

/* --- Per-row action buttons ("预警", "屏蔽" etc.) with dark inline styles --- */
html[data-theme="light"] button[style*="background: rgba(255, 255, 255, 0.08)"][style*="color: white"] {
    background: #ffffff !important;
    color: rgba(0, 0, 0, 0.7) !important;
    border: 1px solid rgba(0, 0, 0, 0.18) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] button[style*="background: rgba(255, 255, 255, 0.08)"][style*="color: white"]:hover {
    background: rgba(102, 126, 234, 0.08) !important;
    border-color: rgba(102, 126, 234, 0.4) !important;
    color: #667eea !important;
}

/* --- Elements with hardcoded #8e8e93 text color --- */
html[data-theme="light"] [style*="color: #8e8e93"],
html[data-theme="light"] [style*="color:#8e8e93"] {
    color: var(--text-secondary) !important;
}

/* --- Elements with hardcoded #666 text color --- */
html[data-theme="light"] [style*="color:#666"],
html[data-theme="light"] [style*="color: #666"] {
    color: var(--text-tertiary) !important;
}

/* --- Elements with rgba(255,255,255,0.05) background --- */
html[data-theme="light"] [style*="background: rgba(255, 255, 255, 0.05)"],
html[data-theme="light"] [style*="background:rgba(255,255,255,0.05)"],
html[data-theme="light"] [style*="background: rgba(255,255,255,0.05)"] {
    background: rgba(0, 0, 0, 0.04) !important;
}

/* --- Elements with rgba(255,255,255,0.03) background --- */
html[data-theme="light"] [style*="background: rgba(255, 255, 255, 0.03)"],
html[data-theme="light"] [style*="background:rgba(255,255,255,0.03)"],
html[data-theme="light"] [style*="background: rgba(255,255,255,0.03)"] {
    background: rgba(0, 0, 0, 0.03) !important;
}

/* --- Elements with rgba(255,255,255,0.08) background --- */
html[data-theme="light"] [style*="background: rgba(255, 255, 255, 0.08)"],
html[data-theme="light"] [style*="background:rgba(255,255,255,0.08)"] {
    background: rgba(0, 0, 0, 0.05) !important;
}

/* --- Elements with rgba(255,255,255,0.1) background --- */
html[data-theme="light"] [style*="background: rgba(255, 255, 255, 0.1)"],
html[data-theme="light"] [style*="background:rgba(255,255,255,0.1)"] {
    background: rgba(0, 0, 0, 0.06) !important;
}

/* --- Elements with rgba(255,255,255,0.02) background --- */
html[data-theme="light"] [style*="background: rgba(255, 255, 255, 0.02)"],
html[data-theme="light"] [style*="background:rgba(255,255,255,0.02)"] {
    background: rgba(0, 0, 0, 0.02) !important;
}

/* --- Elements with border: rgba(255,255,255,0.1) --- */
html[data-theme="light"] [style*="border: 1px solid rgba(255, 255, 255, 0.1)"],
html[data-theme="light"] [style*="border:1px solid rgba(255,255,255,0.1)"],
html[data-theme="light"] [style*="border: 1px solid rgba(255,255,255,0.1)"] {
    border-color: rgba(0, 0, 0, 0.1) !important;
}

/* --- Elements with border: rgba(255,255,255,0.12) --- */
html[data-theme="light"] [style*="border: 1px solid rgba(255,255,255,0.12)"],
html[data-theme="light"] [style*="border: 1px solid rgba(255, 255, 255, 0.12)"] {
    border-color: rgba(0, 0, 0, 0.1) !important;
}

/* --- Elements with border: rgba(255,255,255,0.06) --- */
html[data-theme="light"] [style*="border: 1px solid rgba(255,255,255,0.06)"],
html[data-theme="light"] [style*="border: 1px solid rgba(255, 255, 255, 0.06)"] {
    border-color: rgba(0, 0, 0, 0.06) !important;
}

/* --- Elements with border: rgba(255,255,255,0.2) --- */
html[data-theme="light"] [style*="border: 1px solid rgba(255,255,255,0.2)"],
html[data-theme="light"] [style*="border: 1px solid rgba(255, 255, 255, 0.2)"] {
    border-color: rgba(0, 0, 0, 0.12) !important;
}

/* --- Status config dialog (#1c1c1e background) --- */
html[data-theme="light"] #status-config-dialog > div[style*="background: #1c1c1e"],
html[data-theme="light"] [style*="background: #1c1c1e"] {
    background: #ffffff !important;
    color: var(--text-primary) !important;
}

/* --- Status config dialog overlay --- */
html[data-theme="light"] #status-config-dialog[style*="background: rgba(0,0,0,0.7)"] {
    background: rgba(0, 0, 0, 0.4) !important;
}

/* --- Weight config modal & similar modals --- */
html[data-theme="light"] #weight-config-modal .modal,
html[data-theme="light"] #push-config-modal .modal,
html[data-theme="light"] #premium-modal .modal,
html[data-theme="light"] #spread-chart-modal .modal,
html[data-theme="light"] #funding-history-modal .modal {
    background: #ffffff !important;
}

/* --- Global metric alert modal --- */
html[data-theme="light"] #globalMetricAlertModal .modal-content {
    background: #ffffff !important;
}

/* --- JS-generated inline styles: background with rgba(255,255,255,0.1/0.2) on inputs --- */
html[data-theme="light"] input[style*="background: rgba(255,255,255,0.1)"],
html[data-theme="light"] input[style*="background:rgba(255,255,255,0.1)"],
html[data-theme="light"] select[style*="background: rgba(255,255,255,0.1)"],
html[data-theme="light"] select[style*="background:rgba(255,255,255,0.1)"] {
    background: rgba(0, 0, 0, 0.04) !important;
    border-color: rgba(0, 0, 0, 0.15) !important;
}

/* --- Enabled/disabled rule cards from JS --- */
html[data-theme="light"] [style*="background: rgba(102,126,234,0.08)"] {
    background: rgba(102, 126, 234, 0.06) !important;
}

html[data-theme="light"] [style*="background: rgba(255,255,255,0.02)"] {
    background: rgba(0, 0, 0, 0.02) !important;
}

html[data-theme="light"] [style*="border: 1px solid rgba(102,126,234,0.3)"] {
    border-color: rgba(102, 126, 234, 0.3) !important;
}

/* --- Rule buttons with border rgba(255,255,255,0.12) --- */
html[data-theme="light"] button[style*="border: 1px solid rgba(255,255,255,0.12)"] {
    border-color: rgba(0, 0, 0, 0.12) !important;
}

/* --- Weight config buttons --- */
html[data-theme="light"] button[style*="background:rgba(255,255,255,0.05)"],
html[data-theme="light"] button[style*="background: rgba(255,255,255,0.05)"] {
    background: rgba(0, 0, 0, 0.06) !important;
    color: var(--text-secondary) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
}

/* --- Elements with background: rgba(0,0,0,0.7) overlay --- */
html[data-theme="light"] [style*="background: rgba(0,0,0,0.7)"] {
    background: rgba(0, 0, 0, 0.4) !important;
}

/* --- Range inputs in status/weight config --- */
html[data-theme="light"] input[type="range"] {
    accent-color: #007AFF;
}

/* --- Checkbox accent --- */
html[data-theme="light"] input[type="checkbox"] {
    accent-color: #007AFF;
}

/* --- Radio accent --- */
html[data-theme="light"] input[type="radio"] {
    accent-color: #007AFF;
}


/* ================================================================
   PART 3E: Enhanced Checkbox & Form Controls (Light Mode)
   ================================================================ */

/* --- Custom appearance:none checkboxes (futures-arbitrage global style) --- */
html[data-theme="light"] input[type="checkbox"] {
    background: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.25) !important;
}

html[data-theme="light"] input[type="checkbox"]:hover {
    border-color: rgba(0, 122, 255, 0.5) !important;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.08);
}

html[data-theme="light"] input[type="checkbox"]:checked {
    background: #007AFF !important;
    border-color: #007AFF !important;
}

html[data-theme="light"] input[type="checkbox"]:checked:hover {
    background: #0066dd !important;
    border-color: #0066dd !important;
}

html[data-theme="light"] input[type="checkbox"]:disabled {
    background: rgba(0, 0, 0, 0.06) !important;
    border-color: rgba(0, 0, 0, 0.12) !important;
    opacity: 0.6;
}

/* --- Scanner exchange filter container (index.html) --- */
html[data-theme="light"] .scanner-exchange-filter {
    background: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

/* --- Exchange chip labels (index.html - inline gradient backgrounds) --- */
html[data-theme="light"] .exchange-chip,
html[data-theme="light"] label.exchange-chip {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.12) !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

html[data-theme="light"] .exchange-chip:hover,
html[data-theme="light"] label.exchange-chip:hover {
    background: rgba(0, 122, 255, 0.04) !important;
    border-color: rgba(0, 122, 255, 0.3) !important;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.1);
}

/* --- Exchange chip inline-styled labels (index.html uses inline gradient bg) --- */
html[data-theme="light"] label[style*="linear-gradient(135deg, rgba(247, 147, 26"] {
    background: #ffffff !important;
    border-color: rgba(247, 147, 26, 0.25) !important;
}

html[data-theme="light"] label[style*="linear-gradient(135deg, rgba(246, 190, 0"] {
    background: #ffffff !important;
    border-color: rgba(246, 190, 0, 0.25) !important;
}

html[data-theme="light"] label[style*="linear-gradient(135deg, rgba(255, 255, 255"] {
    background: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.15) !important;
}

html[data-theme="light"] label[style*="linear-gradient(135deg, rgba(0, 240, 224"] {
    background: #ffffff !important;
    border-color: rgba(0, 240, 224, 0.3) !important;
}

html[data-theme="light"] label[style*="linear-gradient(135deg, rgba(235, 68, 90"] {
    background: #ffffff !important;
    border-color: rgba(235, 68, 90, 0.25) !important;
}

/* --- Exchange chip text color fix for light mode --- */
html[data-theme="light"] .exchange-chip span,
html[data-theme="light"] label[style*="linear-gradient"] > span[style*="color: #f7931a"] {
    color: #c77a10 !important;
}

html[data-theme="light"] label[style*="linear-gradient"] > span[style*="color: #f6be00"] {
    color: #b08a00 !important;
}

html[data-theme="light"] label[style*="linear-gradient"] > span[style*="color: #fff"] {
    color: rgba(0, 0, 0, 0.7) !important;
}

html[data-theme="light"] label[style*="linear-gradient"] > span[style*="color: #00f0e0"] {
    color: #00a89c !important;
}

html[data-theme="light"] label[style*="linear-gradient"] > span[style*="color: #eb445a"] {
    color: #c73545 !important;
}

/* --- Exchange inline checkbox accent colors (light mode - slightly deeper) --- */
html[data-theme="light"] input[type="checkbox"][style*="accent-color: #f7931a"] {
    accent-color: #d4790f !important;
}

html[data-theme="light"] input[type="checkbox"][style*="accent-color: #f6be00"] {
    accent-color: #c49800 !important;
}

html[data-theme="light"] input[type="checkbox"][style*="accent-color: #fff"] {
    accent-color: #007AFF !important;
}

html[data-theme="light"] input[type="checkbox"][style*="accent-color:#007AFF"] {
    accent-color: #007AFF !important;
}

/* --- Input group labels (futures-arbitrage exchange filters) --- */
html[data-theme="light"] .input-group label[style*="inline-flex"] {
    background: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.12) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

html[data-theme="light"] .input-group label[style*="inline-flex"]:hover {
    background: rgba(0, 122, 255, 0.04) !important;
    border-color: rgba(0, 122, 255, 0.35) !important;
}

/* --- Scanner column options (index.html sidebar) --- */
html[data-theme="light"] .scanner-column-option {
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

html[data-theme="light"] .scanner-column-option:hover {
    background: rgba(0, 122, 255, 0.04) !important;
}

/* --- Column options (futures-arbitrage sidebar) --- */
html[data-theme="light"] .column-option {
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

html[data-theme="light"] .column-option:hover {
    background: rgba(0, 122, 255, 0.04) !important;
}

/* --- Merged column items (futures-arbitrage column config modal) --- */
html[data-theme="light"] .merged-column-item {
    background: rgba(0, 0, 0, 0.03) !important;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

html[data-theme="light"] .merged-column-item:hover {
    background: rgba(0, 122, 255, 0.05) !important;
    border-color: rgba(0, 122, 255, 0.15);
}

html[data-theme="light"] .merged-column-item.dragging {
    background: rgba(0, 122, 255, 0.12) !important;
}

/* --- Realtime switch visibility --- */
html[data-theme="light"] .realtime-switch {
    color: rgba(0, 0, 0, 0.5) !important;
}

html[data-theme="light"] .realtime-switch input:checked + span {
    color: #276749 !important;
}

/* --- Push action buttons ("正推"/"反推") --- */
html[data-theme="light"] .push-btn {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .push-btn.forward {
    background: linear-gradient(135deg, rgba(56, 161, 105, 0.15), rgba(56, 161, 105, 0.35)) !important;
    border-color: rgba(56, 161, 105, 0.5) !important;
    color: #1a6d42 !important;
}

html[data-theme="light"] .push-btn.reverse {
    background: linear-gradient(135deg, rgba(229, 62, 62, 0.15), rgba(229, 62, 62, 0.35)) !important;
    border-color: rgba(229, 62, 62, 0.5) !important;
    color: #9b2c2c !important;
}

html[data-theme="light"] .push-btn:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12) !important;
}

/* --- Push buttons (generic, e.g. A/B fee history) --- */
html[data-theme="light"] .push-btn:not(.forward):not(.reverse) {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.15) !important;
    color: rgba(0, 0, 0, 0.6) !important;
}

html[data-theme="light"] .push-btn:not(.forward):not(.reverse):hover {
    background: rgba(0, 122, 255, 0.06) !important;
    border-color: rgba(0, 122, 255, 0.3) !important;
    color: #007AFF !important;
}

/* --- Toggle switch slider (futures-arbitrage) --- */
html[data-theme="light"] .toggle-slider {
    background-color: rgba(0, 0, 0, 0.12) !important;
    border-color: rgba(0, 0, 0, 0.18) !important;
}

html[data-theme="light"] .toggle-switch:hover .toggle-slider {
    background-color: rgba(0, 0, 0, 0.18) !important;
}

html[data-theme="light"] .toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, #007AFF 0%, #5E5CE6 100%) !important;
    border-color: transparent !important;
}

html[data-theme="light"] .toggle-switch input:checked:hover + .toggle-slider {
    background: linear-gradient(135deg, #0066dd 0%, #4a4acc 100%) !important;
}

/* --- Checkbox items (index.html scanner exchange filters) --- */
html[data-theme="light"] .checkbox-item {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

html[data-theme="light"] .checkbox-item:hover {
    background: rgba(0, 122, 255, 0.03) !important;
    border-color: rgba(0, 122, 255, 0.25) !important;
}

/* --- Scanner alert toggle container --- */
html[data-theme="light"] .scanner-alert-toggle {
    background: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

/* --- Scanner alert toggle slider --- */
html[data-theme="light"] .scanner-alert-toggle .slider {
    background: rgba(0, 0, 0, 0.12) !important;
    border-color: rgba(0, 0, 0, 0.18) !important;
}

html[data-theme="light"] .scanner-alert-toggle input:checked + .slider {
    background: linear-gradient(135deg, #007AFF 0%, #5E5CE6 100%) !important;
    border-color: transparent !important;
}

/* --- Column sidebar improvements --- */
html[data-theme="light"] .column-sidebar {
    background: #ffffff !important;
    border-left: 1px solid rgba(0, 0, 0, 0.1) !important;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.06) !important;
}

html[data-theme="light"] .sidebar-header,
html[data-theme="light"] .column-sidebar-header {
    background: rgba(0, 0, 0, 0.02) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
}

html[data-theme="light"] .sidebar-footer,
html[data-theme="light"] .column-sidebar-footer {
    background: rgba(0, 0, 0, 0.02) !important;
    border-top: 1px solid rgba(0, 0, 0, 0.08) !important;
}

/* --- Scanner column sidebar improvements --- */
html[data-theme="light"] .scanner-column-sidebar {
    background: #ffffff !important;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.06) !important;
}

html[data-theme="light"] .scanner-sidebar-header {
    background: rgba(0, 0, 0, 0.02) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
}

html[data-theme="light"] .scanner-sidebar-footer {
    background: rgba(0, 0, 0, 0.02) !important;
    border-top: 1px solid rgba(0, 0, 0, 0.08) !important;
}

html[data-theme="light"] .scanner-sidebar-footer button {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.12) !important;
    color: rgba(0, 0, 0, 0.6) !important;
}

html[data-theme="light"] .scanner-sidebar-footer button:hover {
    background: rgba(0, 122, 255, 0.06) !important;
    border-color: rgba(0, 122, 255, 0.3) !important;
    color: #007AFF !important;
}

/* --- Merged column config modal improvements --- */
html[data-theme="light"] #merged-column-modal .modal {
    background: #ffffff !important;
}

html[data-theme="light"] .merged-column-panel {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.06) !important;
}

/* --- Config buttons area (merged header controls) --- */
html[data-theme="light"] .merged-header-controls .sort-btn {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.12) !important;
    color: rgba(0, 0, 0, 0.65) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

html[data-theme="light"] .merged-header-controls .sort-btn:hover {
    background: rgba(0, 122, 255, 0.05) !important;
    border-color: rgba(0, 122, 255, 0.3) !important;
    color: #007AFF !important;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.12);
}

/* --- Merged table row hover --- */
html[data-theme="light"] #merged-table tbody tr:hover {
    background: rgba(0, 122, 255, 0.03) !important;
}

html[data-theme="light"] #merged-table td {
    border-bottom-color: rgba(0, 0, 0, 0.06) !important;
}

/* --- Spread table --- */
html[data-theme="light"] #spread-table th {
    background: rgba(245, 245, 247, 0.98) !important;
}

html[data-theme="light"] #spread-table tbody tr:hover {
    background: rgba(0, 122, 255, 0.03) !important;
}

/* --- Status config inline checkboxes --- */
html[data-theme="light"] #status-config-dialog input[type="checkbox"] {
    background: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.25) !important;
}

html[data-theme="light"] #status-config-dialog input[type="checkbox"]:checked {
    background: #007AFF !important;
    border-color: #007AFF !important;
}

/* --- Funding rate toggle checkbox --- */
html[data-theme="light"] #funding-rate-toggle {
    background: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.25) !important;
}

html[data-theme="light"] #funding-rate-toggle:checked {
    background: #007AFF !important;
    border-color: #007AFF !important;
}

/* --- Standalone checkbox labels (not in containers) --- */
html[data-theme="light"] label[style*="display: inline-flex"] > input[type="checkbox"]:not(:checked) {
    background: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.25) !important;
}

html[data-theme="light"] label[style*="display: inline-flex"] > input[type="checkbox"]:checked {
    background: #007AFF !important;
    border-color: #007AFF !important;
}

/* --- Control buttons group improvements --- */
html[data-theme="light"] .control-group {
    background: rgba(0, 0, 0, 0.02) !important;
}

/* --- Text that was white/light in dark mode on non-gradient backgrounds --- */
html[data-theme="light"] [style*="color: white"]:not([style*="linear-gradient"]):not(.push-btn):not(.apple-button):not(.tab-btn) {
    color: rgba(0, 0, 0, 0.7) !important;
}

/* --- Exchange pairs display section --- */
html[data-theme="light"] .exchange-pair-section {
    background: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
}

/* --- Scanner alert rules container --- */
html[data-theme="light"] .scanner-alert-rule {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* --- Input type number in config dialogs --- */
html[data-theme="light"] input[type="number"] {
    background: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.15) !important;
    color: rgba(0, 0, 0, 0.87) !important;
}

html[data-theme="light"] input[type="number"]:focus {
    border-color: #007AFF !important;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1) !important;
}

/* --- Input type text --- */
html[data-theme="light"] input[type="text"] {
    background: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.15) !important;
    color: rgba(0, 0, 0, 0.87) !important;
}

/* --- Drag handles in light mode --- */
html[data-theme="light"] .drag-handle {
    color: rgba(0, 0, 0, 0.25) !important;
}

html[data-theme="light"] .column-option:hover .drag-handle,
html[data-theme="light"] .merged-column-item:hover .drag-handle {
    color: rgba(0, 0, 0, 0.45) !important;
}


/* ================================================================
   PART 4: Theme Toggle Button Styles
   ================================================================ */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border-radius: 17px;
    border: 1px solid var(--border-color);
    background: var(--glass-bg);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    flex-shrink: 0;
    color: var(--text-secondary);
    white-space: nowrap;
}

.theme-toggle:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
    border-color: rgba(102, 126, 234, 0.4);
}

.theme-toggle:active {
    transform: scale(0.97);
}

/* Light mode: stronger styling for toggle */
html[data-theme="light"] .theme-toggle {
    background: rgba(0, 0, 0, 0.05) !important;
    border-color: rgba(0, 0, 0, 0.15) !important;
    color: rgba(0, 0, 0, 0.6) !important;
}

html[data-theme="light"] .theme-toggle:hover {
    background: rgba(0, 0, 0, 0.08) !important;
    border-color: rgba(102, 126, 234, 0.5) !important;
    color: #667eea !important;
}

/* Icon + label visibility control */
.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    display: none;
    pointer-events: none;
}

/* Dark mode: show sun icon (to switch to light) */
html[data-theme="dark"] .theme-toggle .icon-sun {
    display: inline;
}

/* Light mode: show moon icon (to switch to dark) */
html[data-theme="light"] .theme-toggle .icon-moon {
    display: inline;
}

/* Smooth transition for theme change */
html[data-theme] body,
html[data-theme] .glass-nav,
html[data-theme] .apple-card,
html[data-theme] .modal-content,
html[data-theme] .scanner-table-container,
html[data-theme] input,
html[data-theme] select {
    transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
