﻿        :root { --primary: #2c3e50; --accent: #3498db; --success: #2ecc71; --danger: #E60005; --warning: #f39c12; --master: #8e44ad; }
        
        /* MOBILE FIX: Added 100dvh for modern browsers */
        *, *::before, *::after { box-sizing: border-box; }
        body, button, input, select, textarea, a { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
        body.auth-pending { opacity: 0; }
        body { transition: opacity 0.15s ease; }

        body {
            margin: 0;
            display: flex;
            height: 100vh;
            height: 100dvh;
            background: radial-gradient(circle at top left, rgba(84, 140, 255, 0.14), transparent 28%),
                        linear-gradient(180deg, #f5f8fc 0%, #e7edf4 100%);
            overflow: hidden;
            color: #12213d;
        }
        
        #mobile-header { display: none; background: var(--primary); color: white; padding: 15px 20px; justify-content: space-between; align-items: center; box-shadow: 0 2px 5px rgba(0,0,0,0.1); z-index: 100; }
        .hamburger { background: none; border: none; color: white; font-size: 1.8rem; cursor: pointer; padding: 0; }
        
        /* WIDER SIDEBAR: Increased width to 300px */
        #sidebar { width: 300px; background: var(--primary); color: white; padding: 20px; display: flex; flex-direction: column; box-shadow: 2px 0 5px rgba(0,0,0,0.1); flex-shrink: 0; z-index: 1000; transition: transform 0.3s ease; box-sizing: border-box; }
        #sidebar-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 999; }
        
        .brand-container { text-align: center; margin: 0 0 30px 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
        .pilot-logo { max-width: 160px; height: auto; margin-bottom: 10px; }
        .by-line { display: flex; align-items: center; gap: 8px; justify-content: center; }
        .by-text { font-size: 0.75rem; color: white; font-style: italic; opacity: 0.8; }
        .axion-logo { max-width: 100px; height: auto; }
        
        #sidebar ul { list-style: none; padding: 0; flex-grow: 1; overflow-y: auto; }
        #sidebar ul li { margin-bottom: 8px; }
        
        /* ELLIPSIS TRUNCATION FIX: Flexbox to protect icons, ellipsis for text */
        #sidebar ul li a { 
            color: #bdc3c7; text-decoration: none; padding: 10px; border-radius: 4px; transition: 0.2s; 
            display: flex; align-items: center; justify-content: space-between;
        }
        #sidebar ul li a:hover, .active-nav { background: #34495e; color: white; }
        
        .tpl-name-span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-grow: 1; margin-right: 5px; }
        .tpl-icon-span { flex-shrink: 0; }
        
        .sidebar-nav-btn { color: #bdc3c7; text-decoration: none; font-weight: bold; display: flex; align-items: center; gap: 10px; margin-bottom: 15px; padding: 12px; background: rgba(255,255,255,0.05); border-radius: 6px; transition: 0.2s; }
        .sidebar-nav-btn:hover { background: rgba(255,255,255,0.1); color: white; }
        .sidebar-nav-btn i { font-size: 1.3rem; }

        .sidebar-bottom-menu-container { position: relative; margin-top: auto; border-top: 1px solid #34495e; padding-top: 15px; }
        
        .account-trigger-btn { width: 100%; background: #1a252f; border: 1px solid #2c3e50; padding: 10px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; transition: 0.2s; }
        .account-trigger-btn:hover { background: #2c3e50; }
        
        #settings-dropdown { position: absolute; bottom: calc(100% + 10px); left: 0; width: 100%; background: #34495e; border-radius: 8px; padding: 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.4); border: 1px solid #465c71; z-index: 1000; display: none; flex-direction: column; gap: 2px; box-sizing: border-box; }
        
        .menu-item { background: transparent; color: #ecf0f1; border: none; padding: 10px 12px; text-align: left; width: 100%; cursor: pointer; border-radius: 6px; font-size: 0.9rem; font-weight: 600; transition: 0.2s; display: flex; align-items: center; gap: 10px;}
        .menu-item:hover { background: rgba(255,255,255,0.1); color: white; }
        .menu-item i { font-size: 1.2rem; }
        .approval-count-badge { margin-left: auto; background: var(--warning); color: #2c1a00; border-radius: 999px; padding: 1px 8px; font-size: 0.72rem; font-weight: 800; line-height: 1.6; flex-shrink: 0; }

        #main-panel { flex-grow: 1; padding: 40px; overflow-y: auto; height: 100vh; box-sizing: border-box; position: relative;}
        
        #sub-warning { background: var(--danger); color: white; padding: 15px; border-radius: 8px; margin-bottom: 20px; font-weight: bold; text-align: center; box-shadow: 0 2px 8px rgba(230,0,5,0.2); }

        .view-section { background: rgba(255,255,255,0.92); padding: 30px; border-radius: 18px; border: 1px solid rgba(15,23,42,0.08); box-shadow: 0 8px 20px rgba(15,23,42,0.05); position: relative; backdrop-filter: blur(10px); }
        .hidden { display: none !important; }
        
        .btn { padding: 10px 20px; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; color: white; transition: 0.2s;}
        .btn:hover { opacity: 0.9; }
        .btn:disabled { opacity: 0.5; cursor: not-allowed; }
        .btn-primary { background: var(--accent); }
        .btn-success { background: var(--success); }
        .btn-warning { background: var(--warning); }
        .btn-info { background: #1abc9c; } 
        .btn-danger { background: var(--danger); }
        .btn-sm { padding: 5px 10px; font-size: 0.85rem; margin-right: 5px; margin-bottom: 5px;}

        .action-bar { display: flex; gap: 10px; flex-wrap: wrap; }
        .action-btn { width: 140px; height: 42px; display: flex; align-items: center; justify-content: center; font-weight: 600; border: none; border-radius: 4px; cursor: pointer; color: white; text-decoration: none; box-sizing: border-box; transition: 0.2s; font-size: 0.9rem;}
        .action-btn:hover { opacity: 0.9; }
        
        .form-group { margin-bottom: 20px; padding: 15px; border: 1px solid #eee; border-radius: 6px; }
        .form-row { display: flex; gap: 15px; }
        .form-row .form-group { flex: 1; }
        label { display: block; margin-bottom: 8px; font-weight: bold; color: #444; }
        input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="file"], input[type="date"], input[type="time"], input[type="color"], input[type="url"], textarea, select { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 4px; box-sizing: border-box; font-family: inherit; }
        input[type="color"] { padding: 5px; height: 45px; cursor: pointer; }
        
        .table-responsive { overflow-x: auto; width: 100%; margin-top: 25px; }
        table { width: 100%; border-collapse: collapse; min-width: 600px; }
        th { text-align: left; background: #f8f9fa; padding: 15px; border-bottom: 2px solid #eee; color: #666; }
        th:hover { background: #eef0f2; }
        td { padding: 15px; border-bottom: 1px solid #eee; vertical-align: middle; }
        
        .status-pill { padding: 6px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: bold; text-transform: uppercase; border: none; cursor: pointer; transition: 0.2s; color: white; white-space: nowrap;}
        .status-pill:hover { opacity: 0.8; box-shadow: 0 2px 5px rgba(0,0,0,0.2); }

        .location-checkbox { display: inline-flex; align-items: center; margin-right: 15px; margin-bottom: 10px; background: #f8f9fa; padding: 8px 12px; border-radius: 4px; border: 1px solid #ddd;}
        .location-checkbox input { width: auto; margin-right: 8px; }

        /* ── Dashboard ── */
        .dash-hero { margin-bottom: 28px; display: grid; gap: 14px; }
        .dash-hero-top { display: flex; align-items: center; justify-content: space-between; gap: 30px; flex-wrap: nowrap; }
        .dash-hero-top > div:first-child { flex: 1; min-width: 0; }
        .dash-welcome { margin: 0 0 8px; font-size: 2.5rem; font-weight: 800; color: #121d3a; line-height: 1.05; }
        .dash-role-badge { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; background: rgba(52, 152, 219, 0.10); border: 1px solid rgba(52, 152, 219, 0.18); border-radius: 999px; color: #2e5c9b; font-size: 0.92rem; font-weight: 700; width: fit-content; }
        .dash-subtitle { margin: 0; color: #5e6d84; font-size: 1rem; max-width: 760px; }
        .dash-feed-pill { display:flex; align-items:center; justify-content:space-between; gap:12px; background:#f4fbff; border:1px solid rgba(52, 152, 219, 0.18); border-radius:18px; padding:12px 16px; margin:0; flex-shrink:0; white-space:nowrap; }
        .dash-feed-title { font-weight:700; color:#1b5c96; font-size:0.98rem; display:flex; align-items:center; gap:10px; margin-bottom:6px; }
        .dash-feed-sub { font-size:0.88rem; color:#5e6d84; }

        .dash-stats { display:grid; grid-template-columns:repeat(3,minmax(280px,1fr)); gap:24px; margin-bottom:24px; }
        .dash-stat { display:flex; align-items:center; gap:18px; min-height: 130px; background: rgba(255,255,255,0.90); border: 1px solid rgba(15,23,42,0.08); border-radius: 24px; padding: 28px; box-shadow: 0 6px 18px rgba(15,23,42,0.05); transition: transform 0.18s, box-shadow 0.18s; backdrop-filter: blur(10px); }
        .dash-stat:hover { transform:none; box-shadow:0 8px 24px rgba(15,23,42,0.06); }
        .dash-stat-icon { width:54px; height:54px; border-radius:16px; display:flex; align-items:center; justify-content:center; font-size:24px; flex-shrink:0; }
        .dash-stat[data-color="accent"]  .dash-stat-icon { background:rgba(52,152,219,.12); color:var(--accent); }
        .dash-stat[data-color="success"] .dash-stat-icon { background:rgba(46,204,113,.12); color:var(--success); }
        .dash-stat[data-color="purple"]  .dash-stat-icon { background:rgba(142,68,173,.12); color:#8e44ad; }
        .dash-stat[data-color="indigo"]  .dash-stat-icon { background:rgba(155,89,182,.12); color:#9b59b6; }
        .dash-stat[data-color="orange"]  .dash-stat-icon { background:rgba(230,126,34,.12); color:#e67e22; }
        .dash-stat[data-color="warning"]  .dash-stat-icon { background:rgba(241,196,15,.12); color:#f1c40f; }
        .dash-stat[data-color="danger"]  .dash-stat-icon { background:rgba(230,0,5,.09);   color:var(--danger); }
        .dash-stat-label { font-size:0.72rem; font-weight:700; text-transform:uppercase; letter-spacing:0.6px; color:#a0aab8; margin-bottom:5px; }
        .dash-stat-val { font-size:2rem; font-weight:700; color:#1a2332; line-height:1; }
        .dash-stat-val-sm { font-size:1.25rem; font-weight:700; color:#1a2332; line-height:1; padding-top:3px; }

        .dash-charts { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:20px; margin-top:24px; }
        .dash-chart-card { background: rgba(255,255,255,0.90); border:1px solid rgba(15,23,42,0.08); border-radius: 24px; box-shadow:0 6px 18px rgba(15,23,42,0.05); padding: 22px; min-height: 320px; display: flex; flex-direction: column; }
        .dash-chart-header { display:flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 10px; }
        .dash-chart-header span { font-weight: 700; color: #1a2332; }
        .dash-chart-value { color: #5e6d84; font-size: 0.95rem; }
        .dash-chart-range { display:flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
        .dash-chart-range button { border: 1px solid rgba(52,152,219,0.18); background: rgba(52,152,219,0.08); color: #2a4a6b; padding: 9px 14px; border-radius: 999px; font-size: 0.82rem; font-weight:700; cursor:pointer; transition: all 0.2s ease; }
        .dash-chart-range button.active { background: #3498db; border-color: #3498db; color: #fff; box-shadow: 0 10px 24px rgba(52,152,219,0.18); }
        .dash-chart-range button:hover { background: rgba(52,152,219,0.14); }
        .dash-chart-canvas { flex: 1; min-height: 260px; position: relative; }
        .chart-placeholder { display:flex; align-items:center; justify-content:center; text-align:center; color:#6b778c; font-size:0.95rem; height:100%; padding:20px; }

        .dash-support { display:flex; gap:28px; align-items:stretch; background: rgba(255,255,255,0.92); border:1px solid rgba(15,23,42,0.08); border-radius:22px; overflow:hidden; margin-top:20px; box-shadow:0 8px 24px rgba(15,23,42,0.05); }
        .dash-support-brand { background: linear-gradient(180deg, #d60008 0%, #bf0021 100%); display:flex; flex-direction:column; align-items:center; justify-content:center; padding:26px 30px; flex-shrink:0; gap:10px; min-width:200px; }
        .dash-support-brand img { width:130px; filter:brightness(0) invert(1); }
        .dash-support-tagline { color:rgba(255,255,255,0.85); font-size:0.72rem; font-style:italic; text-align:center; line-height:1.4; letter-spacing:0.2px; }
        .dash-support-body { padding:22px 24px; display:flex; flex-direction:column; justify-content:center; }
        .dash-support-title { font-size:1rem; font-weight:700; color:#1a2332; margin-bottom:6px; }
        .dash-support-text { font-size:0.88rem; color:#8a94a6; line-height:1.55; margin-bottom:4px; }
        .dash-support-address { font-size:0.8rem; color:#aab0bc; margin-top:4px; margin-bottom:10px; display:flex; align-items:center; gap:5px; }
        .dash-support-links { display:flex; gap:20px; margin-top:8px; flex-wrap:wrap; }
        .dash-support-links a { color:#E60005; font-weight:600; text-decoration:none; font-size:0.88rem; display:flex; align-items:center; gap:6px; }
        .dash-support-links a:hover { text-decoration:underline; }

        /* dark mode dashboard */
        body.dark-mode .dash-welcome { color:#d4d4f0; }
        body.dark-mode .dash-subtitle { color:#6868a0; }
        body.dark-mode .dash-feed-pill { background:#172030; border-color:#253548; }
        body.dark-mode .dash-feed-title { color:#5ba3d9; }
        body.dark-mode .dash-feed-sub { color:#6868a0; }
        body.dark-mode .dash-stat { background:#1e1e30; border-color:#2e2e45; box-shadow:0 1px 4px rgba(0,0,0,0.25); }
        body.dark-mode .dash-stat:hover { box-shadow:0 6px 20px rgba(0,0,0,0.4); }
        body.dark-mode .dash-stat-label { color:#5a5a88; }
        body.dark-mode .dash-stat-val,
        body.dark-mode .dash-stat-val-sm { color:#d4d4f0; }
        body.dark-mode .dash-support { background:#1e1e30; border-color:#2e2e45; }
        body.dark-mode .dash-support-brand { background:#B00004; }
        .trend-chart { display:flex; align-items:flex-end; justify-content:space-between; gap:8px; height: 180px; padding: 14px 10px 12px; background: rgba(52,152,219,0.08); border-radius: 18px; }
        .trend-segment { flex:1; min-width: 14px; border-radius: 12px 12px 0 0; transition: background 0.2s; }
        .trend-empty { color: #5e6d84; font-size: 0.92rem; margin: auto; }
        .health-chart { display: flex; height: 34px; border-radius: 999px; overflow: hidden; background: rgba(15,23,42,0.05); margin-bottom: 14px; }
        .health-bar { display:flex; align-items:center; justify-content:center; color:#fff; font-size: 0.92rem; min-width: 30px; padding: 0 8px; }
        .health-bar.online { background: #2ecc71; }
        .health-bar.offline { background: #e74c3c; }
        .health-legend { display:flex; gap: 18px; align-items:center; flex-wrap:wrap; color: #5e6d84; font-size: 0.92rem; }
        .health-legend span { display:flex; align-items:center; gap: 8px; }
        .online-dot, .offline-dot { width: 10px; height: 10px; border-radius: 50%; display:inline-block; }
        .online-dot { background: #2ecc71; }
        .offline-dot { background: #e74c3c; }

        body.dark-mode .dash-chart-card { background: #1c1c2e; border-color: #2e2e45; box-shadow:0 18px 40px rgba(0,0,0,0.35); }
        body.dark-mode .dash-chart-header span { color: #d4d4f0; }
        body.dark-mode .dash-chart-value { color: #8686a2; }
        body.dark-mode .trend-chart { background: rgba(255,255,255,0.08); }
        body.dark-mode .trend-empty { color: #8a8eb5; }
        body.dark-mode .health-legend { color: #8686a2; }
        body.dark-mode .dash-role-badge { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.14); color: #e4e8ff; }
        body.dark-mode .dash-support-title { color:#d4d4f0; }
        body.dark-mode .dash-support-text { color:#6868a0; }
        body.dark-mode .dash-support-address { color:#4a4a6a; }

        /* Legacy — stats-grid replaced by dash-stats */
        .stats-grid { display:none; }

        .field-row { display: flex; gap: 15px; background: #f8f9fa; padding: 15px; border: 1px solid #e1e4e8; border-radius: 6px; margin-bottom: 15px; align-items: center; flex-wrap: wrap; position: relative; }
        .f-label { flex: 1; min-width: 150px; }
        .f-name { flex: 1; min-width: 100px; background: #eee; cursor: not-allowed; }
        .f-type { width: 150px; }
        .btn-danger-circle { background: var(--danger); color: white; border: none; position: absolute; right: -10px; top: -10px; border-radius: 50%; width: 25px; height: 25px; padding: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; font-weight: bold; font-size: 0.8rem;}
        .opts-div { display: flex; gap: 10px; border-left: 2px solid #ccc; padding-left: 15px; align-items: center; flex-wrap: wrap;}
        .move-controls { display: flex; flex-direction: column; gap: 4px; }
        .btn-move { background: #ecf0f1; border: 1px solid #bdc3c7; border-radius: 3px; cursor: pointer; padding: 4px 6px; font-size: 0.7rem; color: #7f8c8d; }
        
        .hover-title { color: var(--primary); text-decoration: none; transition: color 0.2s; cursor: pointer;}
        .hover-title:hover { color: var(--accent); }

        .settings-container { background: white; padding: 25px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); border: 1px solid #e1e4e8; margin-bottom: 30px; }
        .settings-container h3 { margin: 0 0 10px 0; color: #2c3e50; font-size: 1.2rem; border-left: 4px solid var(--accent); padding-left: 10px; display:flex; align-items:center; gap:8px;}
        .acc-tabs { display:flex; gap:4px; background:#f4f7f6; border-radius:8px; padding:4px; margin-bottom:24px; }
        .acc-tab-btn { flex:1; padding:10px 16px; border:none; background:transparent; border-radius:6px; font-size:0.95rem; font-weight:600; color:#7f8c8d; cursor:pointer; transition:0.2s; }
        .acc-tab-btn.active { background:#fff; color:var(--primary); box-shadow:0 1px 4px rgba(0,0,0,0.1); }
        .acc-tab-btn:hover:not(.active) { color:var(--primary); }

        body.dark-mode .acc-tabs { background: #181823; }
        body.dark-mode .acc-tab-btn { color: #a8aacb; }
        body.dark-mode .acc-tab-btn.active { background: #1a1a2e; color: #d4d4f0; box-shadow: 0 1px 4px rgba(0,0,0,0.35); }
        .acc-tab-panel { display:none; }
        .acc-tab-panel.active { display:block; }

        #preview-container { display: flex; align-items: center; gap: 15px; border: 1px dashed #ddd; padding: 10px; border-radius: 4px;}
        #acc-logo-preview { max-height: 80px; border-radius: 4px; border: 1px solid #eee; padding: 3px; background: #fff;}
        .remove-logo-btn { background: #95a5a6; color: white; border: none; padding: 5px 10px; border-radius: 4px; cursor: pointer; font-size: 0.8rem;}

        .template-card { border: 1px solid #ddd; border-radius: 8px; overflow: hidden; background: white; transition: 0.2s; position: relative; display: flex; flex-direction: column; }
        .template-card:hover { box-shadow: 0 8px 25px rgba(0,0,0,0.1); transform: translateY(-3px); }
        .template-card-img { width: 100%; height: 160px; background-size: cover; background-position: center; display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,0.4); font-size: 4rem; font-weight: bold; text-shadow: 0 2px 10px rgba(0,0,0,0.3); border-bottom: 1px solid #eee;}
        .template-card-body { padding: 15px; display: flex; flex-direction: column; flex-grow: 1; }
        .template-card-title { font-weight: bold; font-size: 1.1rem; margin: 0 0 10px 0; color: #2c3e50; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
        .template-card-toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; margin: 0; }
        .active-card { border: 2px solid var(--success); box-shadow: 0 0 15px rgba(46, 204, 113, 0.2); }

        .media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 15px; margin-top: 20px; }
        .media-item { position: relative; border-radius: 8px; overflow: hidden; background: #eee; border: 1px solid #ddd; aspect-ratio: 1; display:flex; align-items:center; justify-content:center;}
        .media-item img, .media-item video { width: 100%; height: 100%; object-fit: cover; pointer-events: none;}
        .media-item .del-media { position: absolute; top: 5px; right: 5px; background: rgba(231,76,60,0.9); color: white; border: none; border-radius: 50%; width: 25px; height: 25px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 12px; pointer-events: auto;}

        #media-modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.8); z-index: 10000; align-items: center; justify-content: center; }
        #media-modal { background: white; width: 90%; max-width: 1000px; height: 80%; border-radius: 8px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,0.5);}
        .modal-header { padding: 20px; background: #f8f9fa; border-bottom: 1px solid #ddd; display: flex; justify-content: space-between; align-items: center; }
        .modal-body { padding: 20px; overflow-y: auto; flex-grow: 1; }
        .selectable-media { cursor: pointer; transition: 0.2s; border: 4px solid transparent; }
        .selectable-media:hover { border-color: var(--accent); transform: scale(1.02); }

        /* =================== DARK MODE =================== */
        body.dark-mode { background: #12121e; color: #d4d4f0; }
        body.dark-mode #main-panel { color: #d4d4f0; }
        body.dark-mode .view-section { background: #1c1c2e; box-shadow: 0 2px 10px rgba(0,0,0,0.4); }
        body.dark-mode .settings-container { background: #1c1c2e; border-color: #3a3a4e; }
        body.dark-mode .settings-container h3 { color: #d4d4f0; }
        body.dark-mode label { color: #b0b0cc; }
        body.dark-mode input[type="text"], body.dark-mode input[type="password"], body.dark-mode input[type="email"],
        body.dark-mode input[type="number"], body.dark-mode input[type="date"], body.dark-mode input[type="time"],
        body.dark-mode input[type="url"], body.dark-mode textarea, body.dark-mode select {
            background: #252535; border-color: #3a3a4e; color: #d4d4f0;
        }
        body.dark-mode input[type="file"] { background: #252535; border-color: #3a3a4e; color: #b0b0cc; }
        body.dark-mode .form-group { border-color: #3a3a4e; background: #1c1c2e; }
        body.dark-mode th { background: #252535; border-bottom-color: #3a3a4e; color: #9090b8; }
        body.dark-mode th:hover { background: #2e2e45; }
        body.dark-mode td { border-bottom-color: #2a2a40; color: #d4d4f0; }
        body.dark-mode .stat-card { background: #252535; border-color: #3a3a4e; }
        body.dark-mode .stat-card h3 { color: #8888aa; }
        body.dark-mode .stat-card .num { color: #d4d4f0; }
        body.dark-mode .field-row { background: #252535; border-color: #3a3a4e; }
        body.dark-mode .f-name { background: #1a1a2e; color: #8888aa; }
        body.dark-mode .btn-move { background: #3a3a4e; border-color: #4a4a5e; color: #9090b8; }
        body.dark-mode .location-checkbox { background: #252535; border-color: #3a3a4e; color: #d4d4f0; }
        body.dark-mode .template-card { background: #1c1c2e; border-color: #3a3a4e; }
        body.dark-mode .template-card-title { color: #d4d4f0; }
        body.dark-mode .template-card-img { border-bottom-color: #3a3a4e; }
        body.dark-mode .media-item { background: #252535; border-color: #3a3a4e; }
        body.dark-mode #media-modal { background: #1c1c2e; }
        body.dark-mode .modal-header { background: #252535; border-bottom-color: #3a3a4e; }
        body.dark-mode .modal-header h3 { color: #d4d4f0; }
        body.dark-mode .hover-title { color: #7ea7d8; }
        body.dark-mode .hover-title:hover { color: var(--accent); }
        body.dark-mode #preview-container { border-color: #3a3a4e; background: #252535; }
        body.dark-mode #acc-logo-preview { background: #1c1c2e; border-color: #3a3a4e; }

        /* --- Inline-style overrides (require !important) --- */
        /* ID-targeted boxes */
        body.dark-mode #super-admin-global-box { background: #1a2e28 !important; border-color: #2a4a3e !important; }
        body.dark-mode #super-admin-global-box label { color: #4dbb9a !important; }
        body.dark-mode #super-admin-global-box div { border-color: #2a4a3e !important; }
        body.dark-mode #super-admin-global-box input[type="file"] { background: #252535 !important; border-color: #3a3a4e !important; color: #b0b0cc !important; }
        body.dark-mode #super-admin-client-box { background: #2a1e10 !important; border-color: #4a3020 !important; }
        body.dark-mode #super-admin-client-box label { color: #e07030 !important; }
        body.dark-mode #builder-fields-container-wrapper { background: #252535 !important; border-color: #3a3a4e !important; }
        body.dark-mode #builder-fields-container-wrapper h3 { color: #9090b8 !important; }
        body.dark-mode #builder-fields-container-wrapper p { color: #6868aa !important; }
        body.dark-mode #apply-all-box { background: #2a1e10 !important; border-color: #4a3020 !important; color: #d4d4f0 !important; }
        body.dark-mode #em-fields-container { background: #252535 !important; border-color: #3a3a4e !important; }
        body.dark-mode #master-feed-container { background: #152030 !important; border-color: #2a4050 !important; }
        body.dark-mode #master-feed-container h3 { color: #5aabdd !important; }

        /* Generic inline background overrides */
        body.dark-mode [style*="background: #fdf2e9"],
        body.dark-mode [style*="background:#fdf2e9"] { background: #1e1408 !important; }
        body.dark-mode [style*="background: #f8f9fa"],
        body.dark-mode [style*="background:#f8f9fa"] { background: #252535 !important; }
        body.dark-mode [style*="background: white"],
        body.dark-mode [style*="background:white"] { background: #1c1c2e !important; }
        body.dark-mode [style*="background: #fff"],
        body.dark-mode [style*="background:#fff"] { background: #1c1c2e !important; }
        body.dark-mode [style*="background: #eaf2f8"],
        body.dark-mode [style*="background:#eaf2f8"] { background: #152030 !important; }

        /* Generic dark-text-on-light-bg overrides */
        body.dark-mode [style*="color: #2c3e50"],
        body.dark-mode [style*="color:#2c3e50"] { color: #c8c8e8 !important; }
        body.dark-mode [style*="color: #34495e"],
        body.dark-mode [style*="color:#34495e"] { color: #9090b8 !important; }
        body.dark-mode [style*="color: #555"] { color: #a0a0c0 !important; }
        /* ================================================== */

        @media (max-width: 768px) {
            body { flex-direction: column; overflow: auto; }
            #mobile-header { display: flex; }
            #main-panel { height: auto; padding: 16px; overflow-y: visible; }

            /* ── Sidebar: full-height slide-over, 82vw wide ── */
            #sidebar {
                position: fixed; top: 0; left: 0;
                width: 82vw; max-width: 300px;
                height: 100vh; height: 100dvh; height: -webkit-fill-available;
                padding: 14px 14px 0 14px;
                transform: translateX(-100%);
                transition: transform 0.3s ease;
                overflow: hidden;
                display: flex; flex-direction: column;
            }
            #sidebar.open { transform: translateX(0); }

            /* Compact brand area */
            .brand-container { flex-direction: row; justify-content: flex-start; align-items: center; gap: 10px; margin: 0 0 10px 0; }
            .pilot-logo { max-width: 80px; margin-bottom: 0; }
            .by-line { flex-direction: row; gap: 5px; }
            .by-text { font-size: 0.7rem; }
            .axion-logo { max-width: 65px; }

            /* Compact Emergency Alert */
            #emergency-btn-container .btn { padding: 8px 10px; font-size: 0.8rem; margin-bottom: 10px; letter-spacing: 0.5px; }
            #emergency-btn-container .btn i { font-size: 1rem; }

            /* Compact Home button */
            .sidebar-nav-btn { padding: 8px 10px; margin-bottom: 8px; font-size: 0.88rem; }
            .sidebar-nav-btn i { font-size: 1.1rem; }

            /* Section label above templates */
            #sidebar-tpl-label { margin: 4px 0 4px 6px !important; }

            /* Template list: tight items, fills remaining space, scrolls */
            #sidebar ul { overflow-y: auto; flex: 1 1 0; min-height: 0; padding-bottom: 4px; }
            #sidebar ul li { margin-bottom: 2px; }
            #sidebar ul li a { padding: 7px 8px; font-size: 0.84rem; }

            /* Settings trigger: always pinned at bottom */
            .sidebar-bottom-menu-container { flex-shrink: 0; padding: 10px 0 max(env(safe-area-inset-bottom, 0px), 12px); }
            .account-trigger-btn { padding: 8px 10px; }

            /* Settings dropdown: cap height and scroll if needed */
            #settings-dropdown { max-height: 65vh; overflow-y: auto; }
            .menu-item { padding: 9px 10px; font-size: 0.87rem; }

            /* ── Main panel ── */
            .view-section { padding: 16px; }

            /* Compact dashboard welcome — stack vertically on mobile */
            .dash-welcome { font-size: 1.6rem; }
            .dash-hero-top { flex-direction: column; align-items: flex-start; gap: 10px; }
            .dash-feed-pill { width: 100%; box-sizing: border-box; padding: 9px 12px; }
            .dash-feed-title { font-size: 0.88rem; }
            .dash-feed-sub { font-size: 0.8rem; }

            /* Stats: 2 columns on mobile */
            .dash-stats { grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
            .dash-stat { min-height: auto; padding: 16px; gap: 12px; border-radius: 16px; }
            .dash-stat-icon { width: 42px; height: 42px; font-size: 18px; border-radius: 12px; }
            .dash-stat-val { font-size: 1.5rem; }
            .dash-stat-val-sm { font-size: 1.05rem; }

            /* Charts: single column */
            .dash-charts { grid-template-columns: 1fr; gap: 14px; }
            .dash-chart-card { min-height: 260px; padding: 16px; border-radius: 16px; }

            /* Support block: stack vertically */
            .dash-support { flex-direction: column; }
            .dash-support-brand { min-width: unset; padding: 18px 20px; flex-direction: row; justify-content: flex-start; gap: 14px; }

            /* General form fixes */
            .form-row { flex-direction: column; gap: 0; }
            .action-bar { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
            .action-btn { width: 100%; margin-bottom: 0; font-size: 0.85rem; }
            #xml-feed-btn { grid-column: span 2; }
            .field-row { flex-direction: column; align-items: stretch; padding-top: 25px; }
            .opts-div { border-left: none; padding-left: 0; padding-top: 10px; border-top: 1px solid #ddd; margin-top: 10px; }
            .f-type { width: 100%; }
            #acc-logo-preview { max-height: 80px; max-width: 80%; border-radius: 4px; border: 1px solid #eee; padding: 3px; background: #fff; }
        }
