        * { margin: 0; padding: 0; box-sizing: border-box; }
        
        :root {
            --primary: #4a90d9;
            --primary-dark: #2a5a8a;
            --accent: #d99040;
            --success: #40d990;
            --danger: #c0392b;
            --bg-dark: #1a1a1a;
            --bg-panel: #252525;
            --bg-toolbar: #2d2d2d;
            --border: #444;
            --text: #e0e0e0;
            --text-muted: #888;
            --toolbar-height: 56px;
            --toolbar2-height: 46px;
            --status-height: 36px;
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background: var(--bg-dark);
            color: var(--text);
            font-size: 14px;
            overflow: hidden;
            touch-action: manipulation;
            -webkit-tap-highlight-color: transparent;
        }
        
        .app-container {
            width: 100%;
            height: 100vh;
            height: 100dvh;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }
        
        .toolbar {
            background: linear-gradient(to bottom, #3a3a3a, var(--bg-toolbar));
            border-bottom: 1px solid var(--border);
            padding: 6px;
            display: flex;
            align-items: center;
            gap: 6px;
            flex-shrink: 0;
            min-height: var(--toolbar-height);
            height: auto;
            flex-wrap: wrap;
            overflow-x: visible;
            overflow-y: visible;
        }
        
        .toolbar::-webkit-scrollbar { display: none; }

        .toolbar.toolbar-row2 {
            background: linear-gradient(to bottom, #353535, #2a2a2a);
            min-height: 38px;
            padding: 4px 6px;
            border-top: none;
        }

        .logo-mds {
            display: flex;
            align-items: center;
            padding: 0 8px 0 4px;
            flex-shrink: 0;
        }
        .logo-mds img { height: 28px; width: auto; }

        .toolbar-spacer { flex: 1; }

        .logo-gssi {
            display: flex;
            align-items: center;
            padding: 0 4px 0 8px;
            flex-shrink: 0;
            height: 100%;
        }
        .logo-gssi img { height: 24px; max-height: 24px; width: auto; max-width: 60px; object-fit: contain; }

        .toolbar-btn {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 4px 8px;
            min-width: 48px;
            min-height: 44px;
            background: linear-gradient(to bottom, #404040, #333);
            border: 1px solid #555;
            border-radius: 6px;
            cursor: pointer;
            color: #ddd;
            flex-shrink: 0;
            transition: all 0.15s;
        }
        
        .toolbar-btn:active { transform: scale(0.95); background: linear-gradient(to bottom, #4a6a8a, #3a5a7a); }
        .toolbar-btn.active { background: linear-gradient(to bottom, #2a5a8a, #1a4a7a); border-color: var(--primary); color: #fff; }
        .toolbar-btn .icon { font-size: 18px; line-height: 1; }
        .toolbar-btn .label { font-size: 9px; margin-top: 2px; white-space: nowrap; }
        .toolbar-btn:disabled { opacity: 0.4; pointer-events: none; }
        
        .toolbar-btn.calibrating, .toolbar-btn.measuring {
            background: linear-gradient(to bottom, #8a5a2a, #7a4a1a) !important;
            border-color: var(--accent) !important;
            animation: pulse 1s ease-in-out infinite;
        }
        
        .toolbar-btn.picking {
            background: linear-gradient(to bottom, #2a8a5a, #1a7a4a) !important;
            border-color: var(--success) !important;
            animation: pulse 1s ease-in-out infinite;
        }
        
        @keyframes pulse {
            0%, 100% { box-shadow: 0 0 5px currentColor; }
            50% { box-shadow: 0 0 15px currentColor; }
        }
        
        .cursor-display {
            background: var(--bg-dark);
            border: 2px solid var(--primary);
            border-radius: 6px;
            padding: 5px 10px;
            font-size: 11px;
            font-weight: bold;
            color: var(--primary);
            font-family: 'SF Mono', Monaco, monospace;
            white-space: nowrap;
            flex-shrink: 0;
            min-width: 140px;
            text-align: center;
        }
        
        .toolbar-spacer { flex: 1; min-width: 10px; }
        
        .toolbar2 {
            background: var(--bg-toolbar);
            border-bottom: 1px solid var(--border);
            padding: 4px 6px;
            display: flex;
            align-items: center;
            gap: 6px;
            flex-shrink: 0;
            height: var(--toolbar2-height);
            overflow-x: auto;
            overflow-y: hidden;
            -webkit-overflow-scrolling: touch;
            scrollbar-width: none;
        }
        
        .toolbar2::-webkit-scrollbar { display: none; }
        
        .toolbar-group {
            display: flex;
            align-items: center;
            gap: 4px;
            padding: 0 6px;
            border-left: 1px solid var(--border);
            flex-shrink: 0;
        }
        
        .toolbar-group:first-child { border-left: none; }
        .toolbar-group label { font-size: 10px; color: var(--text-muted); white-space: nowrap; }

        /* Palette selector */
        .palette-selector {
            position: relative;
        }
        .palette-current {
            width: 60px;
            height: 20px;
            border-radius: 4px;
            border: 2px solid var(--border);
            cursor: pointer;
            background: linear-gradient(to right, #000, #fff);
            transition: border-color 0.2s;
        }
        .palette-current:hover {
            border-color: var(--primary);
        }
        .palette-dropdown {
            display: none;
            position: absolute;
            top: 100%;
            left: 50%;
            transform: translateX(-50%);
            margin-top: 8px;
            background: var(--bg-panel);
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 8px;
            z-index: 1000;
            box-shadow: 0 4px 12px rgba(0,0,0,0.4);
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 6px;
            display: none;
        }
        .palette-dropdown.open {
            display: grid;
        }
        .palette-option {
            cursor: pointer;
            border-radius: 4px;
            padding: 2px;
            border: 2px solid transparent;
            transition: all 0.15s;
        }
        .palette-option:hover {
            border-color: var(--primary);
            transform: scale(1.05);
        }
        .palette-option.active {
            border-color: var(--accent);
        }
        .palette-preview {
            width: 50px;
            height: 16px;
            border-radius: 3px;
        }

        /* Surface detection group - visual grouping of Surface button with threshold controls */
        .surface-group {
            background: rgba(100, 150, 200, 0.15);
            border-radius: 8px;
            padding: 4px 8px;
            border: 1px solid rgba(100, 150, 200, 0.3);
            margin: 0 4px;
            position: relative;
        }

        .surface-group .threshold-label {
            position: absolute;
            top: -8px;
            right: 8px;
            font-size: 9px;
            color: var(--text-muted);
            background: var(--bg);
            padding: 0 4px;
        }

        .surface-group .toolbar-btn {
            margin-right: 6px;
        }

        .pm-btn {
            width: 32px;
            height: 32px;
            border: 1px solid var(--primary);
            border-radius: 6px;
            background: linear-gradient(to bottom, #3a5a7a, #2a4a6a);
            color: #fff;
            font-size: 18px;
            font-weight: bold;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
        }
        
        .pm-btn:active { transform: scale(0.95); background: linear-gradient(to bottom, #2a4a6a, #1a3a5a); }
        
        .value-display, .value-input {
            background: var(--bg-dark);
            border: 2px solid var(--primary);
            border-radius: 5px;
            padding: 5px 8px;
            font-size: 12px;
            font-weight: bold;
            color: var(--primary);
            font-family: 'SF Mono', Monaco, monospace;
            min-width: 44px;
            text-align: center;
        }
        
        .value-input { width: 52px; -moz-appearance: textfield; }
        .value-input::-webkit-outer-spin-button, .value-input::-webkit-inner-spin-button { -webkit-appearance: none; }
        
        .bg-btn, .xzoom-btn, .voie-btn {
            padding: 6px 10px;
            background: #404040;
            border: 1px solid #555;
            border-radius: 5px;
            color: #ddd;
            font-size: 11px;
            font-weight: 500;
            min-height: 32px;
            cursor: pointer;
        }
        
        .bg-btn:active, .xzoom-btn:active, .voie-btn:active { transform: scale(0.95); }
        .bg-btn.active, .xzoom-btn.active, .voie-btn.active { background: var(--primary-dark); border-color: var(--primary); color: #fff; }
        .voie-btn:disabled { background: #2a2a2a; border-color: #3a3a3a; color: #555; pointer-events: none; }
        
        .main-container {
            display: flex;
            flex: 1;
            min-height: 0;
            gap: 0;
            background: #1e1e1e;
            overflow: hidden;
            position: relative;
            flex-direction: row;
        }
        
        .file-list-panel {
            position: fixed;
            top: 0; left: 0; bottom: 0;
            width: 280px;
            max-width: 85vw;
            background: #2a2a2a;
            border-right: 2px solid var(--primary);
            display: flex;
            flex-direction: column;
            overflow: hidden;
            z-index: 100;
            transform: translateX(-100%);
            transition: transform 0.3s ease;
        }
        
        .file-list-panel.open { transform: translateX(0); }
        
        .file-list-header {
            background: linear-gradient(to bottom, #3a3a3a, var(--bg-toolbar));
            padding: 12px;
            font-size: 14px;
            font-weight: bold;
            border-bottom: 1px solid var(--border);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        
        .file-list-close { width: 36px; height: 36px; border: none; background: transparent; color: #888; font-size: 28px; cursor: pointer; }
        .file-list { flex: 1; overflow-y: auto; padding: 8px; -webkit-overflow-scrolling: touch; }
        
        .file-drop-zone {
            padding: 20px 12px;
            margin: 8px 0;
            border: 2px dashed var(--primary);
            border-radius: 8px;
            text-align: center;
            font-size: 13px;
            font-weight: bold;
            color: var(--primary);
            cursor: pointer;
            background: rgba(74, 144, 217, 0.05);
        }
        
        .file-drop-zone:active { background: rgba(74, 144, 217, 0.15); }

        .sample-files-hint {
            margin-top: 8px;
            padding-top: 8px;
            border-top: 1px dashed rgba(255, 193, 7, 0.3);
            font-size: 11px;
            color: #888;
        }
        .sample-files-hint a {
            color: #f0a500;
            text-decoration: none;
            font-weight: 600;
        }
        .sample-files-hint a:hover {
            text-decoration: underline;
            color: #ffbb33;
        }
        .sample-files-hint .hint-icon {
            margin-right: 3px;
        }

        .file-item {
            padding: 12px;
            margin: 6px 0;
            background: #333;
            border: 1px solid var(--border);
            border-radius: 8px;
            cursor: pointer;
            font-size: 13px;
            color: #bbb;
            position: relative;
        }
        
        .file-item-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 28px; font-weight: 500; }
        .file-item-info { display: flex; gap: 8px; margin-top: 6px; font-size: 11px; color: #888; align-items: center; }
        .file-item-device { background: #8a5a2a; padding: 2px 6px; border-radius: 4px; color: #ddd; }
        .file-item-loading { animation: file-spin 1s linear infinite; font-size: 12px; }
        .file-item-loaded { color: #2ecc71; font-size: 12px; margin-right: 2px; }
        @keyframes file-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
        
        .file-item-delete {
            position: absolute;
            top: 8px; right: 8px;
            width: 28px; height: 28px;
            border: none;
            background: transparent;
            color: #666;
            font-size: 20px;
            cursor: pointer;
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        .file-item-delete:active { background: var(--danger); color: #fff; }
        .file-item:active { background: #3a4a5a; border-color: #5a8aba; }
        .file-item.active { background: var(--primary-dark); border-color: var(--primary); color: #fff; }
        .file-item.active .file-item-device { background: var(--accent); }
        
        .radargram-panel { flex: 1; display: flex; flex-direction: column; background: #2a2a2a; min-width: 0; overflow: hidden; position: relative; }
        .scale-toggle { position: absolute; top: 0; left: 0; width: 35px; height: 22px; background: #222; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 5; font-size: 8px; color: #aaa; user-select: none; }
        .scale-toggle:hover { background: #444; color: #fff; }
        .scale-toggle:active { background: #555; }
        .axis-x { height: 22px; background: #333; border-bottom: 1px solid var(--border); margin-left: 35px; overflow-x: auto; overflow-y: hidden; flex-shrink: 0; scrollbar-width: none; }
        .axis-x::-webkit-scrollbar { display: none; }
        .radargram-area { display: flex; flex: 1; overflow: auto; min-height: 0; background: var(--bg-dark); -webkit-overflow-scrolling: touch; }
        .axis-y { width: 35px; background: #333; border-right: 1px solid var(--border); flex-shrink: 0; position: sticky; left: 0; z-index: 2; }
        .canvas-wrapper { flex-shrink: 0; }
        #radargramCanvas { display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
        
        .oscope-panel {
            position: fixed;
            top: 0; right: 0; bottom: 0;
            width: 260px;
            max-width: 85vw;
            background: #2a2a2a;
            border-left: 2px solid var(--primary);
            display: flex;
            flex-direction: column;
            overflow: hidden;
            z-index: 100;
            transform: translateX(100%);
            transition: transform 0.3s ease;
        }
        
        .oscope-panel.open { transform: translateX(0); }
        
        .oscope-header {
            display: none;
        }
        
        .oscope-top-bar {
            background: #333;
            height: 22px;
            padding: 0 8px;
            font-size: 10px;
            border-bottom: 1px solid var(--border);
            display: flex;
            align-items: center;
            justify-content: space-between;
            flex-shrink: 0;
            color: #aaa;
        }
        
        .oscope-close { width: 20px; height: 20px; border: none; background: transparent; color: #888; font-size: 16px; cursor: pointer; padding: 0; }
        .oscope-content { flex: 1; display: flex; min-height: 0; background: var(--bg-dark); overflow-y: auto; overflow-x: hidden; }
        .oscope-y-axis { width: 30px; background: #2a2a2a; flex-shrink: 0; }
        .oscope-canvas-wrapper { flex: 1; display: flex; flex-direction: column; min-width: 0; }
        #oscopeCanvas { background: var(--bg-dark); display: block; }
        .oscope-x-axis { height: 22px; background: #2a2a2a; flex-shrink: 0; }
        
        .status-bar {
            background: var(--bg-toolbar);
            border-top: 1px solid var(--border);
            padding: 6px 10px;
            font-size: 11px;
            display: flex;
            gap: 10px;
            color: var(--text-muted);
            flex-shrink: 0;
            height: var(--status-height);
            overflow-x: auto;
            white-space: nowrap;
            -webkit-overflow-scrolling: touch;
        }
        
        .status-bar::-webkit-scrollbar { display: none; }
        .status-bar span:first-child { color: #aaa; font-weight: 500; }
        
        .mobile-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.5); z-index: 90; }
        .mobile-overlay.visible { display: block; }
        
        .upload-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(20,20,20,0.95); display: flex; align-items: center; justify-content: center; z-index: 200; }
        .upload-overlay.hidden { display: none; }
        .upload-box { text-align: center; padding: 30px 20px; border: 3px dashed var(--primary); border-radius: 16px; cursor: pointer; background: var(--bg-panel); max-width: 90%; }
        .upload-box:active { background: #2a3a4a; }
        .upload-box .icon { font-size: 48px; color: var(--primary); }
        .upload-box p { margin-top: 15px; color: #aaa; font-size: 14px; }
        #fileInput { display: none; }
        
        .modal-panel {
            display: none;
            position: fixed;
            left: 10px; right: 10px; bottom: 50px;
            background: #2a2a2a;
            border-radius: 12px;
            padding: 14px;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
            z-index: 150;
            max-height: 70vh;
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
        }
        
        .modal-panel.visible { display: block; }
        .modal-panel h3 { margin: 0 0 10px 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
        
        .picking-panel { border: 2px solid var(--success); min-width: 450px; max-width: 550px; left: 50%; right: auto; transform: translateX(-50%); max-height: 75vh; }
        .picking-panel h3 { color: var(--success); }
        .picking-stats { background: var(--bg-dark); border-radius: 8px; padding: 10px; margin-bottom: 10px; }
        .picking-stats-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 12px; border-bottom: 1px solid #333; }
        .picking-stats-row:last-child { border-bottom: none; }
        .picking-stats-label { color: var(--text-muted); }
        .picking-stats-value { color: var(--primary); font-weight: bold; font-family: monospace; }
        .picking-mode-selector { margin-bottom: 10px; padding: 8px; background: #333; border-radius: 6px; }
        .picking-mode-selector label { font-size: 11px; color: #aaa; display: block; margin-bottom: 6px; }
        .picking-mode-buttons { display: flex; gap: 6px; }
        .picking-mode-btn { flex: 1; padding: 6px 10px; background: #404040; border: 1px solid #555; border-radius: 4px; color: #ccc; font-size: 11px; cursor: pointer; transition: all 0.15s; }
        .picking-mode-btn:hover { background: #505050; }
        .picking-mode-btn.active { background: var(--success); border-color: var(--success); color: #fff; }
        .picking-points-list { max-height: 120px; overflow-y: auto; margin-bottom: 10px; }
        .picking-point-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: #333; border-radius: 5px; margin-bottom: 4px; font-size: 11px; }
        .picking-point-color { width: 12px; height: 12px; border-radius: 50%; background: #ff6b6b; flex-shrink: 0; }
        .picking-point-color-v2 { width: 12px; height: 12px; border-radius: 50%; background: #2ecc71; flex-shrink: 0; }
        .picking-point-info { flex: 1; }
        .picking-point-delete { background: transparent; border: none; color: #666; font-size: 18px; padding: 4px 8px; cursor: pointer; }
        .picking-point-delete:active { background: var(--danger); color: #fff; border-radius: 4px; }
        .picking-empty { text-align: center; color: #666; padding: 16px; font-size: 12px; }
        
        .btn-group { display: flex; gap: 8px; }
        .btn { flex: 1; padding: 10px 12px; border: none; border-radius: 6px; font-size: 13px; font-weight: bold; cursor: pointer; min-height: 44px; }
        .btn-danger { background: var(--danger); color: #fff; }
        .btn-danger:active { background: #e74c3c; }
        .btn-danger.confirming { background: #e74c3c; animation: blink 0.5s ease-in-out infinite; }
        @keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
        .btn-secondary { background: #444; color: #ccc; }
        .btn-secondary:active { background: #555; }
        .btn-primary { background: var(--primary); color: #fff; }
        .btn-primary:active { background: var(--primary-dark); }
        
        .calibration-modal { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.7); z-index: 200; justify-content: center; align-items: center; padding: 20px; }
        .calibration-modal.visible { display: flex; }
        .calibration-dialog { background: #2a2a2a; border: 2px solid var(--accent); border-radius: 12px; padding: 20px; width: 100%; max-width: 320px; }
        .calibration-dialog h3 { color: var(--accent); margin: 0 0 16px 0; font-size: 18px; text-align: center; }
        .calibration-info { background: var(--bg-dark); border-radius: 8px; padding: 12px; margin-bottom: 16px; font-size: 13px; }
        .calibration-info .value { color: var(--primary); font-weight: bold; font-family: monospace; }
        .export-option-section { margin-bottom: 12px; }
        .export-option-section:last-child { margin-bottom: 0; }
        .export-option-label { display: block; font-size: 12px; color: #aaa; margin-bottom: 6px; }
        .export-toggle-buttons { display: flex; gap: 8px; }
        .export-toggle-btn { flex: 1; padding: 10px 12px; background: #404040; border: 2px solid #555; border-radius: 6px; color: #999; font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.15s; }
        .export-toggle-btn:hover { background: #505050; border-color: #666; }
        .export-toggle-btn.active { background: var(--success); border-color: var(--success); color: #fff; }
        .export-toggle-btn.active[data-value="false"] { background: #666; border-color: #666; }
        .calibration-input-group { margin-bottom: 16px; }
        .calibration-input-group label { display: block; color: #ccc; margin-bottom: 8px; font-size: 14px; }
        .calibration-input { width: 100%; padding: 14px; font-size: 18px; background: var(--bg-dark); border: 2px solid #555; border-radius: 8px; color: #fff; text-align: center; font-family: monospace; }
        .calibration-input:focus { outline: none; border-color: var(--accent); }
        .calibration-result { margin-top: 12px; padding: 12px; background: #1a3a1a; border: 1px solid #3a6a3a; border-radius: 8px; color: #7aba7a; text-align: center; display: none; }
        .calibration-result.visible { display: block; }
        
        .measure-panel { position: fixed; bottom: 50px; left: 10px; right: 10px; background: #2a2a2a; border: 2px solid var(--accent); border-radius: 10px; padding: 12px; z-index: 150; display: none; }
        .measure-panel.visible { display: flex; align-items: center; gap: 12px; justify-content: center; }
        .measure-info { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
        .measure-btn-clear { padding: 6px 12px; background: #c0392b; border: none; border-radius: 4px; color: #fff; cursor: pointer; font-size: 11px; flex-shrink: 0; }
        .measure-btn-clear:hover { background: #e74c3c; }
        .measure-value { display: flex; align-items: center; gap: 6px; }
        .measure-value .label { color: var(--text-muted); font-size: 11px; }
        .measure-value .val { color: var(--accent); font-weight: bold; font-family: monospace; font-size: 13px; }
        
        .calibration-mode, .calibration-mode canvas, .picking-mode, .picking-mode canvas, .measure-mode, .measure-mode canvas { cursor: crosshair !important; }
        .cut-mode, .cut-mode canvas { cursor: crosshair !important; }

        .toolbar-btn.cutting {
            background: linear-gradient(to bottom, #8a2a5a, #7a1a4a) !important;
            border-color: #d94090 !important;
            animation: pulse 1s ease-in-out infinite;
        }

        /* Draggable panel styles */
        .modal-panel.draggable { cursor: move; }
        .modal-panel.draggable h3 { cursor: move; user-select: none; }
        .modal-panel.dragging { opacity: 0.9; }

        /* Cross-section and histogram views in picking panel */
        .picking-views { display: flex; gap: 6px; margin-bottom: 10px; }
        .picking-view-btn { flex: 1; padding: 8px; background: #404040; border: 1px solid #555; border-radius: 5px; color: #ddd; font-size: 11px; cursor: pointer; text-align: center; }
        .picking-view-btn:active { transform: scale(0.95); }
        .picking-view-btn.active { background: var(--primary-dark); border-color: var(--primary); color: #fff; }

        /* Cross-section chart modal */
        .section-chart-container { width: 100%; height: 250px; background: var(--bg-dark); border-radius: 8px; padding: 10px; margin-bottom: 10px; position: relative; }
        .section-chart-container canvas { width: 100%; height: 100%; }

        /* Circular section view */
        .circular-container { width: 100%; background: var(--bg-dark); border-radius: 8px; padding: 10px; margin-bottom: 10px; }
        .circular-controls { display: flex; gap: 8px; margin-bottom: 10px; }
        .circular-control { display: flex; flex-direction: column; gap: 2px; }
        .circular-control label { font-size: 10px; color: var(--text-muted); }
        .circular-control input { width: 80px; padding: 4px 6px; background: #333; border: 1px solid #555; border-radius: 4px; color: #fff; font-size: 12px; }
        .circular-chart { width: 100%; height: 280px; display: flex; justify-content: center; align-items: center; }
        .circular-chart canvas { max-width: 100%; max-height: 100%; }
        .circular-legend { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; padding: 8px; background: #252525; border-radius: 6px; }
        .circular-legend-item { display: flex; align-items: center; gap: 4px; font-size: 10px; color: #ccc; }
        .circular-legend-color { width: 12px; height: 12px; border-radius: 50%; }

        /* Histogram chart */
        .histogram-container { width: 100%; background: var(--bg-dark); border-radius: 8px; padding: 10px; margin-bottom: 10px; }
        .histogram-controls { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; align-items: flex-end; }
        .histogram-control { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 70px; }
        .histogram-control label { font-size: 10px; color: var(--text-muted); }
        .histogram-control input[type="number"] { width: 100%; padding: 4px 6px; background: #333; border: 1px solid #555; border-radius: 4px; color: #fff; font-size: 12px; }
        .histogram-control.checkbox-control { flex-direction: row; align-items: center; gap: 6px; min-width: auto; flex: 0; }
        .histogram-control.checkbox-control label { font-size: 11px; white-space: nowrap; }
        .histogram-control.checkbox-control input[type="checkbox"] { width: 16px; height: 16px; margin: 0; }
        .histogram-chart { height: 280px; position: relative; padding: 25px 15px 60px 40px; box-sizing: border-box; }
        .histogram-chart-area { position: relative; width: 100%; height: 100%; border-left: 1px solid #666; border-bottom: 1px solid #666; }
        .histogram-bar { position: absolute; bottom: 0; border-radius: 2px 2px 0 0; min-width: 15px; }
        .histogram-bar.below-front { background: #e74c3c; }
        .histogram-bar.above-front { background: #2ecc71; }
        .histogram-y-label { position: absolute; left: -30px; font-size: 9px; color: #888; transform: translateY(50%); }
        .histogram-x-label { position: absolute; bottom: -15px; font-size: 9px; color: #888; transform: translateX(-50%); }
        .histogram-percent-label { position: absolute; top: -20px; font-size: 11px; font-weight: bold; }
        .histogram-percent-label.below { color: #e74c3c; }
        .histogram-percent-label.above { color: #2ecc71; }
        .histogram-total { text-align: center; font-size: 11px; color: #888; margin-top: 8px; }
        .histogram-axis-title { position: absolute; bottom: -35px; left: 50%; transform: translateX(-50%); font-size: 10px; color: #aaa; }
        .histogram-front-line { position: absolute; top: 0; bottom: 0; border-left: 2px dashed #e74c3c; z-index: 10; }
        .histogram-front-label { position: absolute; top: 50%; right: 5px; font-size: 9px; color: #e74c3c; transform: translateY(-50%); white-space: nowrap; }

        ::-webkit-scrollbar { width: 6px; height: 6px; }
        ::-webkit-scrollbar-track { background: #2a2a2a; }
        ::-webkit-scrollbar-thumb { background: #555; border-radius: 3px; }
        
        @media (min-width: 900px) {
            .app-container { max-width: 1400px; margin: 0 auto; box-shadow: 0 0 30px rgba(0,0,0,0.5); }
            .file-list-panel { position: relative !important; transform: none !important; width: 200px; min-width: 200px; flex-shrink: 0; z-index: 1; border-right: 1px solid var(--border); border-radius: 0; overflow: hidden; }
            .file-list-close { display: none; }
            #filesMenuBtn { display: none; }
            .mobile-overlay { display: none !important; }
            .toolbar { flex-wrap: wrap; overflow-x: visible; }
            .toolbar-btn { min-width: 70px; }
            .toolbar-btn .label { display: block; }
            .oscope-panel { position: relative !important; transform: none !important; width: 0; height: auto; flex-shrink: 0; border-radius: 0; bottom: auto; left: auto; border: none; overflow: hidden; transition: width 0.3s; }
            .oscope-panel.open { width: 200px; border-left: 1px solid var(--border); display: flex !important; }
            .oscope-close { display: none; }
            .radargram-panel { flex: 1; }
            .cursor-display { min-width: 220px; }
            .pm-btn { width: 32px; height: 32px; }
            .toolbar-group label { display: inline; }
        }
        
        @media (max-width: 360px) {
            .toolbar-btn { min-width: 42px; padding: 3px 6px; }
            .toolbar-btn .label { display: none; }
            .toolbar-btn .icon { font-size: 20px; }
            .toolbar-group label { display: none; }
            .cursor-display { min-width: 110px; font-size: 9px; }
        }
        
        @media (max-height: 450px) and (orientation: landscape) {
            :root { --toolbar-height: 44px; --toolbar2-height: 38px; --status-height: 28px; }
            .toolbar-btn { min-height: 36px; padding: 3px 6px; }
            .toolbar-btn .label { display: none; }
            .pm-btn { width: 28px; height: 28px; }
            .modal-panel { max-height: 55vh; }
        }

        /* Auth Screen Styles */
        .auth-screen {
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 10000;
        }
        .auth-screen.hidden { display: none; }
        .auth-container {
            background: var(--bg-panel);
            border-radius: 16px;
            padding: 32px;
            width: 90%;
            max-width: 420px;
            box-shadow: 0 20px 60px rgba(0,0,0,0.5);
            border: 1px solid var(--border);
            position: relative;
        }
        .auth-lang-selector {
            position: absolute;
            top: 12px;
            right: 12px;
            display: flex;
            gap: 6px;
        }
        .auth-lang-btn {
            background: var(--bg-dark);
            border: 2px solid transparent;
            border-radius: 6px;
            padding: 4px 6px;
            cursor: pointer;
            opacity: 0.6;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .auth-lang-btn:hover {
            opacity: 1;
            background: var(--bg-hover);
        }
        .auth-lang-btn.active {
            opacity: 1;
            border-color: var(--primary);
            background: var(--bg-hover);
        }
        .auth-logo {
            text-align: center;
            margin-bottom: 24px;
        }
        .auth-logo img { height: 50px; }
        .auth-title {
            text-align: center;
            font-size: 24px;
            font-weight: 600;
            margin-bottom: 8px;
            color: var(--text);
        }
        .auth-subtitle {
            text-align: center;
            color: var(--text-muted);
            margin-bottom: 24px;
            font-size: 14px;
        }
        .auth-tabs {
            display: flex;
            margin-bottom: 24px;
            border-radius: 8px;
            overflow: hidden;
            border: 1px solid var(--border);
        }
        .auth-tab {
            flex: 1;
            padding: 12px;
            text-align: center;
            background: var(--bg-dark);
            color: var(--text-muted);
            cursor: pointer;
            border: none;
            font-size: 14px;
            transition: all 0.2s;
        }
        .auth-tab.active {
            background: var(--primary);
            color: white;
        }
        .auth-form { display: none; }
        .auth-form.active { display: block; }
        .auth-field {
            margin-bottom: 16px;
        }
        .auth-field label {
            display: block;
            margin-bottom: 6px;
            font-size: 13px;
            color: var(--text-muted);
        }
        .auth-field input {
            width: 100%;
            padding: 12px 14px;
            border: 1px solid var(--border);
            border-radius: 8px;
            background: var(--bg-dark);
            color: var(--text);
            font-size: 14px;
            transition: border-color 0.2s;
        }
        .auth-field input:focus {
            outline: none;
            border-color: var(--primary);
        }
        .auth-field-row {
            display: flex;
            gap: 12px;
        }
        .auth-field-row .auth-field { flex: 1; }
        .auth-btn {
            width: 100%;
            padding: 14px;
            border: none;
            border-radius: 8px;
            background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
            color: white;
            font-size: 15px;
            font-weight: 600;
            cursor: pointer;
            transition: transform 0.2s, box-shadow 0.2s;
            margin-top: 8px;
        }
        .auth-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(74, 144, 217, 0.4);
        }
        .auth-btn:disabled {
            opacity: 0.6;
            cursor: not-allowed;
            transform: none;
        }
        .auth-link {
            text-align: center;
            margin-top: 16px;
            font-size: 13px;
            color: var(--text-muted);
        }
        .auth-link a {
            color: var(--primary);
            text-decoration: none;
            cursor: pointer;
        }
        .auth-link a:hover { text-decoration: underline; }

        /* Checkbox fields for registration */
        .auth-checkbox {
            display: flex;
            align-items: flex-start;
            gap: 10px;
            margin: 12px 0;
            font-size: 13px;
            color: var(--text-muted);
        }
        .auth-checkbox input[type="checkbox"] {
            width: 18px;
            height: 18px;
            margin-top: 2px;
            accent-color: var(--primary);
            cursor: pointer;
            flex-shrink: 0;
        }
        .auth-checkbox label {
            cursor: pointer;
            line-height: 1.4;
        }
        .auth-checkbox a {
            color: var(--primary);
            text-decoration: underline;
            cursor: pointer;
        }
        .auth-checkbox.disabled {
            opacity: 0.6;
        }
        .auth-checkbox.disabled input[type="checkbox"] {
            cursor: not-allowed;
        }
        .auth-checkbox .required-star {
            color: var(--danger);
        }

        /* Terms Modal */
        .terms-modal-overlay {
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.9);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 40000;
            padding: 20px;
        }
        .terms-modal-overlay.visible { display: flex; }
        .terms-modal {
            background: var(--bg-panel);
            border-radius: 12px;
            width: 100%;
            max-width: 800px;
            max-height: 90vh;
            display: flex;
            flex-direction: column;
            box-shadow: 0 20px 60px rgba(0,0,0,0.5);
        }
        .terms-modal-header {
            padding: 20px 24px;
            border-bottom: 1px solid var(--border);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .terms-modal-header h2 {
            color: var(--text);
            font-size: 20px;
            margin: 0;
        }
        .terms-modal-close {
            background: none;
            border: none;
            color: var(--text-muted);
            font-size: 24px;
            cursor: pointer;
            padding: 5px;
        }
        .terms-modal-close:hover { color: var(--text); }
        .terms-modal-content {
            padding: 24px;
            overflow-y: auto;
            flex: 1;
            color: var(--text);
            font-size: 14px;
            line-height: 1.6;
        }
        .terms-modal-content h3 {
            color: var(--accent);
            margin-top: 24px;
            margin-bottom: 12px;
            font-size: 16px;
        }
        .terms-modal-content h3:first-child {
            margin-top: 0;
        }
        .terms-modal-content p {
            margin-bottom: 12px;
        }
        .terms-modal-content ul {
            margin: 12px 0;
            padding-left: 24px;
        }
        .terms-modal-content li {
            margin-bottom: 8px;
        }

        /* Data Warning Modal (first connection) */
        .warning-modal-overlay {
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.9);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 45000;
            padding: 20px;
        }
        .warning-modal-overlay.visible { display: flex; }
        .warning-modal {
            background: var(--bg-panel);
            border-radius: 12px;
            width: 100%;
            max-width: 500px;
            box-shadow: 0 20px 60px rgba(0,0,0,0.5);
            border: 2px solid var(--warning, #f39c12);
        }
        .warning-modal-header {
            padding: 20px 24px;
            border-bottom: 1px solid var(--border);
            text-align: center;
        }
        .warning-modal-header h2 {
            color: var(--warning, #f39c12);
            font-size: 20px;
            margin: 0;
        }
        .warning-modal-body {
            padding: 24px;
            text-align: center;
        }
        .warning-modal-icon {
            font-size: 48px;
            margin-bottom: 16px;
        }
        .warning-modal-text {
            color: var(--text);
            font-size: 15px;
            line-height: 1.6;
            margin-bottom: 24px;
        }
        .warning-modal-btn {
            background: var(--warning, #f39c12);
            color: #000;
            border: none;
            padding: 14px 32px;
            border-radius: 8px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
        }
        .warning-modal-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 20px rgba(243, 156, 18, 0.4);
        }

        /* Disconnect modal specific styles */
        .disconnect-modal {
            border-color: var(--danger, #e74c3c);
        }
        .disconnect-modal .warning-modal-header h2 {
            color: var(--danger, #e74c3c);
        }
        .disconnect-icon {
            color: var(--danger, #e74c3c);
        }
        .disconnect-btn {
            background: var(--danger, #e74c3c);
            color: #fff;
        }
        .disconnect-btn:hover {
            box-shadow: 0 5px 20px rgba(231, 76, 60, 0.4);
        }

        /* License Conflict Modal specific styles */
        .license-conflict-modal {
            border-color: var(--accent, #3498db);
            max-width: 480px;
        }
        .license-conflict-modal .warning-modal-header h2 {
            color: var(--accent, #3498db);
        }
        .license-icon {
            color: var(--accent, #3498db);
        }
        .license-session-info {
            background: rgba(52, 152, 219, 0.1);
            border: 1px solid rgba(52, 152, 219, 0.3);
            border-radius: 8px;
            padding: 16px;
            margin: 16px 0;
        }
        .session-device {
            font-size: 18px;
            font-weight: 600;
            color: var(--text);
            margin-bottom: 4px;
        }
        .session-time {
            font-size: 14px;
            color: var(--text-muted);
        }
        .license-conflict-question {
            font-size: 14px;
            color: var(--text-muted);
            margin-top: 16px;
        }
        .license-conflict-buttons {
            display: flex;
            gap: 12px;
            justify-content: center;
        }
        .license-cancel-btn {
            background: var(--bg-secondary, #2a2a2a);
            color: var(--text);
            border: 1px solid var(--border);
        }
        .license-cancel-btn:hover {
            background: var(--bg-hover, #333);
            box-shadow: none;
        }
        .license-takeover-btn {
            background: var(--accent, #3498db);
            color: #fff;
        }
        .license-takeover-btn:hover {
            box-shadow: 0 5px 20px rgba(52, 152, 219, 0.4);
        }

        /* Connection Attempt Notification (for first user) */
        .connection-attempt-notification {
            position: fixed;
            top: 20px;
            right: 20px;
            background: var(--bg-panel);
            border: 2px solid var(--warning, #f39c12);
            border-radius: 12px;
            padding: 16px 20px;
            display: none;
            align-items: flex-start;
            gap: 12px;
            max-width: 380px;
            box-shadow: 0 10px 40px rgba(0,0,0,0.4);
            z-index: 50000;
            animation: slideInRight 0.3s ease-out;
        }
        .connection-attempt-notification.visible {
            display: flex;
        }
        @keyframes slideInRight {
            from {
                transform: translateX(100%);
                opacity: 0;
            }
            to {
                transform: translateX(0);
                opacity: 1;
            }
        }
        .connection-attempt-notification .notification-icon {
            font-size: 28px;
            flex-shrink: 0;
        }
        .connection-attempt-notification .notification-content {
            flex: 1;
        }
        .connection-attempt-notification .notification-title {
            font-weight: 600;
            color: var(--warning, #f39c12);
            margin-bottom: 4px;
        }
        .connection-attempt-notification .notification-text {
            font-size: 13px;
            color: var(--text);
            line-height: 1.5;
        }
        .connection-attempt-notification .notification-close {
            background: none;
            border: none;
            color: var(--text-muted);
            font-size: 20px;
            cursor: pointer;
            padding: 0;
            line-height: 1;
        }
        .connection-attempt-notification .notification-close:hover {
            color: var(--text);
        }

        .auth-error {
            background: rgba(192, 57, 43, 0.2);
            border: 1px solid var(--danger);
            color: #e74c3c;
            padding: 12px;
            border-radius: 8px;
            margin-bottom: 16px;
            font-size: 13px;
            display: none;
        }
        .auth-error.visible { display: block; }
        .auth-success {
            background: rgba(64, 217, 144, 0.2);
            border: 1px solid var(--success);
            color: var(--success);
            padding: 12px;
            border-radius: 8px;
            margin-bottom: 16px;
            font-size: 13px;
            display: none;
        }
        .auth-success.visible { display: block; }
        .auth-back {
            background: none;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            font-size: 13px;
            margin-bottom: 16px;
            display: flex;
            align-items: center;
            gap: 6px;
        }
        .auth-back:hover { color: var(--text); }
        .user-menu-fixed {
            position: fixed;
            top: 8px;
            right: 10px;
            z-index: 9999;
        }
        .user-btn {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 8px 14px;
            background: linear-gradient(to bottom, #404040, #333);
            border: 1px solid var(--border);
            border-radius: 6px;
            color: var(--text);
            cursor: pointer;
            font-size: 13px;
            font-weight: 500;
        }
        .user-btn:hover {
            background: linear-gradient(to bottom, #4a4a4a, #3a3a3a);
        }
        .user-dropdown {
            position: fixed;
            top: calc(var(--toolbar-height) + 4px);
            right: 10px;
            background: var(--bg-panel);
            border: 1px solid var(--border);
            border-radius: 10px;
            min-width: 200px;
            box-shadow: 0 10px 40px rgba(0,0,0,0.6);
            display: none;
            z-index: 10001;
            overflow: hidden;
        }
        .user-dropdown.visible { display: block; }
        .user-dropdown-header {
            padding: 14px 16px;
            background: linear-gradient(to bottom, #3a3a3a, #2d2d2d);
            border-bottom: 1px solid var(--border);
            font-size: 12px;
            color: var(--text-muted);
        }
        .user-dropdown-header strong {
            display: block;
            color: var(--text);
            font-size: 14px;
            margin-bottom: 2px;
        }
        .user-dropdown-item {
            padding: 14px 16px;
            cursor: pointer;
            font-size: 14px;
            color: var(--text);
            border-bottom: 1px solid var(--border);
            display: flex;
            align-items: center;
            gap: 10px;
            transition: background 0.15s;
        }
        .user-dropdown-item:last-child { border-bottom: none; }
        .user-dropdown-item:hover { background: var(--bg-dark); }
        .user-dropdown-item.danger { color: #e74c3c; }
        .user-dropdown-item.danger:hover { background: rgba(231, 76, 60, 0.15); }

        /* Profile Modal */
        .profile-modal-overlay {
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.7);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 20000;
        }
        .profile-modal-overlay.visible { display: flex; }
        .profile-modal {
            background: var(--bg-panel);
            border-radius: 16px;
            width: 90%;
            max-width: 450px;
            box-shadow: 0 20px 60px rgba(0,0,0,0.5);
            border: 1px solid var(--border);
            overflow: hidden;
        }
        .profile-modal-header {
            background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
            padding: 20px 24px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .profile-modal-header h2 {
            margin: 0;
            font-size: 18px;
            color: white;
        }
        .profile-modal-close {
            background: none;
            border: none;
            color: white;
            font-size: 24px;
            cursor: pointer;
            opacity: 0.8;
        }
        .profile-modal-close:hover { opacity: 1; }
        .profile-modal-body {
            padding: 24px;
        }
        .profile-field {
            margin-bottom: 16px;
        }
        .profile-field label {
            display: block;
            margin-bottom: 6px;
            font-size: 13px;
            color: var(--text-muted);
        }
        .profile-field input {
            width: 100%;
            padding: 12px 14px;
            border: 1px solid var(--border);
            border-radius: 8px;
            background: var(--bg-dark);
            color: var(--text);
            font-size: 14px;
        }
        .profile-field input:focus {
            outline: none;
            border-color: var(--primary);
        }
        .profile-field input:disabled {
            opacity: 0.6;
            cursor: not-allowed;
        }
        .profile-field-row {
            display: flex;
            gap: 12px;
        }
        .profile-field-row .profile-field { flex: 1; }
        .profile-btn {
            width: 100%;
            padding: 14px;
            border: none;
            border-radius: 8px;
            background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
            color: white;
            font-size: 15px;
            font-weight: 600;
            cursor: pointer;
            margin-top: 8px;
        }
        .profile-btn:hover {
            opacity: 0.9;
        }
        .profile-btn:disabled {
            opacity: 0.6;
            cursor: not-allowed;
        }
        .profile-message {
            padding: 12px;
            border-radius: 8px;
            margin-bottom: 16px;
            font-size: 13px;
            display: none;
        }
        .profile-message.success {
            background: rgba(64, 217, 144, 0.2);
            border: 1px solid var(--success);
            color: var(--success);
            display: block;
        }
        .profile-message.error {
            background: rgba(192, 57, 43, 0.2);
            border: 1px solid var(--danger);
            color: #e74c3c;
            display: block;
        }

        /* IA Detection Button */
        .ia-detect-btn {
            background: linear-gradient(to bottom, #2a8a5a, #1a6a4a) !important;
            border-color: #3aa06a !important;
        }
        .ia-detect-btn:hover {
            background: linear-gradient(to bottom, #3a9a6a, #2a7a5a) !important;
        }
        .ia-detect-btn.loading {
            opacity: 0.7;
            pointer-events: none;
        }

        /* IA Detection Settings Panel */
        .ia-detect-panel {
            position: absolute;
            top: 100%;
            right: 0;
            background: rgba(30, 30, 40, 0.98);
            border: 1px solid rgba(255,255,255,0.2);
            border-radius: 8px;
            padding: 15px;
            min-width: 220px;
            display: none;
            z-index: 1000;
            box-shadow: 0 4px 20px rgba(0,0,0,0.5);
        }
        .ia-detect-panel.visible {
            display: block;
        }
        .ia-detect-panel h4 {
            color: #4CAF50;
            margin-bottom: 12px;
            font-size: 14px;
        }
        .ia-detect-modes {
            border: 1px solid rgba(255,255,255,0.1);
            border-radius: 5px;
            padding: 8px;
            margin-bottom: 10px;
            background: rgba(0,0,0,0.2);
        }
        .ia-detect-option {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px 0;
            cursor: pointer;
            color: #ccc;
            transition: color 0.2s;
        }
        .ia-detect-option:hover {
            color: #fff;
        }
        .ia-detect-option input[type="radio"] {
            accent-color: #4CAF50;
        }
        .ia-detect-option.selected {
            color: #4CAF50;
        }
        .ia-detect-run {
            width: 100%;
            margin-top: 12px;
            padding: 10px;
            background: linear-gradient(to bottom, #4CAF50, #388E3C);
            border: none;
            border-radius: 5px;
            color: white;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.2s;
        }
        .ia-detect-run:hover {
            background: linear-gradient(to bottom, #5CBF60, #43A047);
        }
        .ia-detect-run:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }
        .ia-detect-status {
            font-size: 11px;
            color: #888;
            margin-top: 8px;
            text-align: center;
        }

        /* Admin Panel Styles */
        .admin-btn {
            background: linear-gradient(to bottom, #8a2a5a, #6a1a4a) !important;
            border-color: #a03a6a !important;
        }
        .admin-btn:hover {
            background: linear-gradient(to bottom, #9a3a6a, #7a2a5a) !important;
        }
        .admin-panel-overlay {
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.85);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 30000;
            padding: 20px;
        }
        .admin-panel-overlay.visible { display: flex; }
        .admin-panel {
            background: var(--bg-panel);
            border-radius: 16px;
            width: 95%;
            max-width: 1400px;
            max-height: 90vh;
            box-shadow: 0 20px 60px rgba(0,0,0,0.5);
            border: 2px solid #a03a6a;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }
        .admin-panel-header {
            background: linear-gradient(135deg, #8a2a5a 0%, #6a1a4a 100%);
            padding: 16px 24px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-shrink: 0;
        }
        .admin-panel-header h2 {
            margin: 0;
            font-size: 18px;
            color: white;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .admin-panel-close {
            background: none;
            border: none;
            color: white;
            font-size: 28px;
            cursor: pointer;
            opacity: 0.8;
            line-height: 1;
        }
        .admin-panel-close:hover { opacity: 1; }
        .admin-panel-toolbar {
            background: var(--bg-toolbar);
            padding: 12px 16px;
            display: flex;
            gap: 12px;
            align-items: center;
            flex-wrap: wrap;
            border-bottom: 1px solid var(--border);
            flex-shrink: 0;
        }
        .admin-panel-toolbar .admin-stat {
            background: var(--bg-dark);
            padding: 8px 14px;
            border-radius: 6px;
            font-size: 13px;
            color: var(--text-muted);
        }
        .admin-panel-toolbar .admin-stat strong {
            color: var(--primary);
            font-size: 16px;
        }
        .admin-download-btn {
            padding: 10px 16px;
            background: linear-gradient(135deg, var(--success) 0%, #2a8a5a 100%);
            border: none;
            border-radius: 6px;
            color: white;
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 8px;
            margin-left: auto;
        }
        .admin-download-btn:hover {
            opacity: 0.9;
        }
        .admin-email-pref {
            display: flex;
            align-items: center;
            margin-left: 12px;
        }
        .admin-checkbox-label {
            display: flex;
            align-items: center;
            gap: 8px;
            cursor: pointer;
            padding: 8px 14px;
            background: var(--bg-dark);
            border-radius: 6px;
            font-size: 13px;
            color: var(--text-muted);
            transition: all 0.2s;
        }
        .admin-checkbox-label:hover {
            background: var(--bg-secondary);
        }
        .admin-checkbox-label input[type="checkbox"] {
            width: 16px;
            height: 16px;
            cursor: pointer;
            accent-color: var(--primary);
        }
        .admin-checkbox-label span {
            white-space: nowrap;
        }
        .admin-panel-body {
            flex: 1;
            overflow-y: auto;
            padding: 0;
        }
        .admin-users-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 13px;
            table-layout: fixed;
        }
        .admin-users-table th {
            background: var(--bg-toolbar);
            padding: 12px 10px;
            text-align: left;
            font-weight: 600;
            color: var(--text);
            border-bottom: 2px solid var(--border);
            position: sticky;
            top: 0;
            z-index: 1;
            cursor: pointer;
            user-select: none;
            white-space: nowrap;
        }
        .admin-users-table th:hover {
            background: var(--bg-hover);
        }
        .admin-users-table th .sort-icon {
            margin-left: 5px;
            opacity: 0.3;
        }
        .admin-users-table th.sorted .sort-icon {
            opacity: 1;
        }
        .admin-users-table th.sorted.asc .sort-icon::after {
            content: '▲';
        }
        .admin-users-table th.sorted.desc .sort-icon::after {
            content: '▼';
        }
        .admin-users-table th:not(.sorted) .sort-icon::after {
            content: '⇅';
        }
        .admin-users-table td {
            padding: 12px 10px;
            border-bottom: 1px solid var(--border);
            color: var(--text);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 200px;
        }
        .admin-users-table tr:hover td {
            background: rgba(74, 144, 217, 0.1);
        }
        .admin-users-table .user-email {
            color: var(--primary);
            font-weight: 500;
            max-width: 220px;
        }
        .admin-users-table .user-date {
            color: var(--text-muted);
            font-size: 12px;
            max-width: 130px;
        }
        .admin-badge {
            display: inline-block;
            padding: 3px 8px;
            border-radius: 4px;
            font-size: 11px;
            font-weight: 600;
        }
        .admin-badge.admin {
            background: rgba(138, 42, 90, 0.3);
            color: #d070a0;
        }
        .admin-badge.user {
            background: rgba(74, 144, 217, 0.2);
            color: var(--primary);
        }
        .admin-loading {
            text-align: center;
            padding: 40px;
            color: var(--text-muted);
        }
        .admin-error {
            text-align: center;
            padding: 40px;
            color: var(--danger);
        }
        @media (max-width: 600px) {
            .admin-panel {
                width: 100%;
                max-height: 100vh;
                border-radius: 0;
            }
            .admin-users-table th, .admin-users-table td {
                padding: 10px 8px;
                font-size: 12px;
            }
            .admin-panel-toolbar {
                flex-direction: column;
                align-items: stretch;
            }
            .admin-download-btn {
                margin-left: 0;
                justify-content: center;
            }
        }

        /* ============== ADMIN DASHBOARD ============== */
        .admin-tabs {
            display: flex;
            background: var(--bg-toolbar);
            border-bottom: 2px solid var(--border);
            flex-shrink: 0;
        }
        .admin-tab {
            padding: 12px 24px;
            background: none;
            border: none;
            color: var(--text-muted);
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s;
            border-bottom: 3px solid transparent;
            margin-bottom: -2px;
        }
        .admin-tab:hover {
            color: var(--text);
            background: var(--bg-hover);
        }
        .admin-tab.active {
            color: #d070a0;
            border-bottom-color: #a03a6a;
            background: var(--bg-dark);
        }
        .admin-tab-content {
            display: none;
            flex: 1;
            overflow-y: auto;
            padding: 20px;
        }
        .admin-tab-content.active {
            display: block;
        }

        /* Stats Grid */
        .admin-stats-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 16px;
            margin-bottom: 24px;
        }
        .admin-stat-card {
            background: var(--bg-dark);
            border-radius: 12px;
            padding: 20px;
            text-align: center;
            border: 1px solid var(--border);
            transition: transform 0.2s, box-shadow 0.2s;
        }
        .admin-stat-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 20px rgba(0,0,0,0.3);
        }
        .admin-stat-card.online {
            border-color: #2ecc71;
            background: linear-gradient(135deg, rgba(46, 204, 113, 0.1), transparent);
        }
        .admin-stat-card.pro {
            border-color: #f39c12;
            background: linear-gradient(135deg, rgba(243, 156, 18, 0.1), transparent);
        }
        .admin-stat-card.new {
            border-color: #9b59b6;
            background: linear-gradient(135deg, rgba(155, 89, 182, 0.1), transparent);
        }
        .admin-stat-icon {
            font-size: 28px;
            margin-bottom: 8px;
        }
        .admin-stat-value {
            font-size: 36px;
            font-weight: 700;
            color: var(--text);
            line-height: 1.2;
        }
        .admin-stat-label {
            font-size: 13px;
            color: var(--text-muted);
            margin-top: 4px;
        }
        .admin-stat-change {
            font-size: 12px;
            color: var(--text-muted);
            margin-top: 8px;
        }
        .admin-stat-change.positive {
            color: #2ecc71;
        }

        /* Online Dot Animation */
        .online-dot {
            display: inline-block;
            width: 12px;
            height: 12px;
            background: #2ecc71;
            border-radius: 50%;
            animation: pulse-online 2s infinite;
        }
        @keyframes pulse-online {
            0%, 100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7); }
            50% { box-shadow: 0 0 0 10px rgba(46, 204, 113, 0); }
        }

        /* Admin Section */
        .admin-section {
            background: var(--bg-dark);
            border-radius: 12px;
            border: 1px solid var(--border);
            margin-bottom: 24px;
            overflow: hidden;
        }
        .admin-section-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 16px 20px;
            background: var(--bg-toolbar);
            border-bottom: 1px solid var(--border);
        }
        .admin-section-header h3 {
            margin: 0;
            font-size: 15px;
            color: var(--text);
        }
        .admin-section-count {
            background: #2ecc71;
            color: white;
            padding: 4px 12px;
            border-radius: 20px;
            font-size: 13px;
            font-weight: 600;
        }

        /* Online Users List */
        .admin-online-list {
            max-height: 300px;
            overflow-y: auto;
        }
        .admin-online-item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px 20px;
            border-bottom: 1px solid var(--border);
            transition: background 0.2s;
        }
        .admin-online-item:last-child {
            border-bottom: none;
        }
        .admin-online-item:hover {
            background: var(--bg-hover);
        }
        .admin-online-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: linear-gradient(135deg, #8a2a5a, #a03a6a);
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: 600;
            font-size: 14px;
            flex-shrink: 0;
        }
        .admin-online-info {
            flex: 1;
            min-width: 0;
        }
        .admin-online-name {
            font-weight: 500;
            color: var(--text);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .admin-online-company {
            font-weight: 400;
            color: var(--text-muted);
            font-size: 13px;
        }
        .admin-online-email {
            font-size: 12px;
            color: var(--text-muted);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .admin-online-device {
            font-size: 12px;
            color: var(--text-muted);
            text-align: right;
            white-space: nowrap;
        }
        .admin-online-duration {
            font-size: 12px;
            color: #2ecc71;
            font-weight: 500;
        }
        .admin-online-empty {
            padding: 40px;
            text-align: center;
            color: var(--text-muted);
        }

        /* Admin Section */
        .admin-section {
            margin-bottom: 24px;
        }
        .admin-section h3 {
            margin: 0 0 16px 0;
            font-size: 16px;
            font-weight: 600;
            color: var(--text);
        }

        /* Charts Row */
        .admin-charts-row {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 20px;
        }
        .admin-charts-row.two-cols {
            grid-template-columns: 2fr 1fr;
        }
        .admin-chart-container {
            background: var(--bg-dark);
            border-radius: 12px;
            border: 1px solid var(--border);
            padding: 20px;
        }
        .admin-chart-container h3 {
            margin: 0 0 16px 0;
            font-size: 14px;
            color: var(--text-muted);
        }
        .admin-chart-container canvas {
            max-height: 200px;
        }

        /* Top Users Table Ranking */
        .admin-users-table .rank-badge {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 28px;
            height: 28px;
            border-radius: 50%;
            font-weight: bold;
            font-size: 13px;
        }
        .admin-users-table .rank-1 {
            background: linear-gradient(135deg, #FFD700, #FFA500);
            color: #000;
        }
        .admin-users-table .rank-2 {
            background: linear-gradient(135deg, #C0C0C0, #A0A0A0);
            color: #000;
        }
        .admin-users-table .rank-3 {
            background: linear-gradient(135deg, #CD7F32, #8B4513);
            color: #fff;
        }
        .admin-users-table .rank-other {
            background: var(--bg-lighter);
            color: var(--text-muted);
        }

        @media (max-width: 900px) {
            .admin-charts-row {
                grid-template-columns: 1fr;
            }
        }

        /* Alerts */
        .admin-alerts {
            display: flex;
            flex-direction: column;
            gap: 12px;
            margin-bottom: 20px;
        }
        .admin-alert {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px 16px;
            border-radius: 8px;
            font-size: 14px;
        }
        .admin-alert.warning {
            background: rgba(243, 156, 18, 0.15);
            border: 1px solid rgba(243, 156, 18, 0.3);
            color: #f39c12;
        }
        .admin-alert.danger {
            background: rgba(231, 76, 60, 0.15);
            border: 1px solid rgba(231, 76, 60, 0.3);
            color: #e74c3c;
        }
        .admin-alert.critical {
            background: rgba(231, 76, 60, 0.25);
            border: 1px solid rgba(231, 76, 60, 0.5);
            color: #ff6b6b;
            animation: pulse-alert 1s infinite;
        }
        @keyframes pulse-alert {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.7; }
        }

        /* Filters */
        .admin-filters select {
            padding: 8px 12px;
            background: var(--bg-dark);
            border: 1px solid var(--border);
            border-radius: 6px;
            color: var(--text);
            font-size: 13px;
            cursor: pointer;
        }
        .admin-filters select:focus {
            outline: none;
            border-color: var(--primary);
        }

        /* Status Badge in Table */
        .status-online {
            display: inline-flex;
            align-items: center;
            gap: 6px;
        }
        .status-online::before {
            content: '';
            width: 8px;
            height: 8px;
            background: #2ecc71;
            border-radius: 50%;
            animation: pulse-online 2s infinite;
        }
        .status-offline::before {
            content: '';
            width: 8px;
            height: 8px;
            background: var(--text-muted);
            border-radius: 50%;
            opacity: 0.5;
        }

        /* Subscription Status Badges */
        .admin-badge.pro {
            background: rgba(243, 156, 18, 0.2);
            color: #f39c12;
        }
        .admin-badge.free {
            background: rgba(127, 140, 141, 0.2);
            color: #95a5a6;
        }
        .admin-badge.active {
            background: rgba(46, 204, 113, 0.2);
            color: #2ecc71;
        }
        .admin-badge.inactive {
            background: rgba(231, 76, 60, 0.2);
            color: #e74c3c;
        }
        .admin-badge.expiring {
            background: rgba(243, 156, 18, 0.2);
            color: #f39c12;
        }

        /* Responsive Admin Dashboard */
        @media (max-width: 900px) {
            .admin-stats-grid {
                grid-template-columns: repeat(2, 1fr);
            }
            .admin-charts-row {
                grid-template-columns: 1fr;
            }
        }
        @media (max-width: 600px) {
            .admin-stats-grid {
                grid-template-columns: 1fr;
            }
            .admin-tab {
                padding: 10px 16px;
                font-size: 13px;
            }
            .admin-tab-content {
                padding: 12px;
            }
        }

        /* ============== IA-ADMIN MODULE ============== */
        .ia-admin-overlay {
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.95);
            display: none;
            z-index: 40000;
            flex-direction: column;
        }
        .ia-admin-overlay.visible { display: flex; }
        .ia-admin-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 12px 20px;
            background: linear-gradient(135deg, #1a3a5c 0%, #0d1f30 100%);
            border-bottom: 2px solid #2a5a8a;
        }
        .ia-admin-header h2 {
            margin: 0;
            font-size: 18px;
            color: #fff;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .ia-admin-header .model-version {
            font-size: 12px;
            background: #2a5a8a;
            padding: 3px 8px;
            border-radius: 4px;
            color: #8cf;
        }
        .ia-admin-close {
            background: none;
            border: none;
            color: #fff;
            font-size: 28px;
            cursor: pointer;
            opacity: 0.7;
            padding: 0 10px;
        }
        .ia-admin-close:hover { opacity: 1; }
        .ia-admin-toolbar {
            display: flex;
            gap: 15px;
            padding: 10px 20px;
            background: #1a1a1a;
            border-bottom: 1px solid #333;
            flex-wrap: wrap;
            align-items: center;
        }
        .ia-admin-toolbar .ia-stat {
            display: flex;
            flex-direction: column;
            font-size: 11px;
            color: #888;
        }
        .ia-admin-toolbar .ia-stat strong {
            font-size: 16px;
            color: #4a90d9;
        }
        .ia-admin-toolbar .ia-stat.success strong { color: #2ecc71; }
        .ia-admin-toolbar .ia-stat.warning strong { color: #f1c40f; }
        .ia-admin-toolbar .ia-stat.danger strong { color: #e74c3c; }
        .ia-admin-btn {
            padding: 8px 15px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 12px;
            font-weight: 600;
            transition: all 0.2s;
        }
        .ia-admin-btn.primary { background: #4a90d9; color: #fff; }
        .ia-admin-btn.primary:hover { background: #5aa0e9; }
        .ia-admin-btn.success { background: #27ae60; color: #fff; }
        .ia-admin-btn.success:hover { background: #2ecc71; }
        .ia-admin-btn.secondary { background: #444; color: #ddd; }
        .ia-admin-btn.secondary:hover { background: #555; }
        .ia-admin-content {
            flex: 1;
            display: flex;
            overflow: hidden;
        }
        .ia-admin-main {
            flex: 1;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }
        .ia-triple-view {
            flex: 1;
            display: flex;
            flex-direction: column;
            gap: 10px;
            padding: 10px;
            overflow-y: auto;
        }
        .ia-view-panel {
            background: #1a1a1a;
            border-radius: 8px;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            border: 2px solid #333;
            min-height: 400px;
            flex-shrink: 0;
        }
        .ia-view-panel.expert { border-color: #4a90d9; }
        .ia-view-panel.yolo { border-color: #e67e22; }
        .ia-view-panel.unet { border-color: #9b59b6; }
        .ia-view-header {
            padding: 8px 12px;
            font-weight: 600;
            font-size: 13px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .ia-view-panel.expert .ia-view-header { background: rgba(74, 144, 217, 0.2); color: #4a90d9; }
        .ia-view-panel.yolo .ia-view-header { background: rgba(230, 126, 34, 0.2); color: #e67e22; }
        .ia-view-panel.unet .ia-view-header { background: rgba(155, 89, 182, 0.2); color: #9b59b6; }
        .ia-view-canvas-container {
            flex: 1;
            position: relative;
            overflow: hidden;
            background: #0a0a0a;
        }
        .ia-view-canvas-container canvas {
            position: absolute;
            top: 0; left: 0;
            width: 100%;
            height: 100%;
            object-fit: contain;
        }
        .ia-view-info {
            padding: 6px 12px;
            font-size: 11px;
            color: #888;
            background: #111;
            display: flex;
            justify-content: space-between;
        }
        .ia-sidebar {
            width: 280px;
            background: #1e1e1e;
            border-left: 1px solid #333;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }
        .ia-sidebar-section {
            border-bottom: 1px solid #333;
        }
        .ia-sidebar-title {
            padding: 10px 15px;
            font-weight: 600;
            font-size: 12px;
            color: #aaa;
            background: #252525;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .ia-sidebar-content {
            padding: 10px 15px;
        }
        .ia-param-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 8px;
            font-size: 12px;
        }
        .ia-param-row label { color: #888; }
        .ia-param-row input, .ia-param-row select {
            width: 80px;
            padding: 4px 8px;
            background: #333;
            border: 1px solid #444;
            border-radius: 4px;
            color: #fff;
            font-size: 12px;
        }
        .ia-annotations-list {
            flex: 1;
            overflow-y: auto;
            padding: 10px 15px;
        }
        .ia-annotation-item {
            background: #252525;
            border-radius: 5px;
            padding: 8px 10px;
            margin-bottom: 6px;
            font-size: 11px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-left: 3px solid #4a90d9;
        }
        .ia-annotation-item .coords { color: #aaa; }
        .ia-annotation-item .velocity { color: #4a90d9; font-weight: 600; }
        .ia-annotation-item .delete-btn {
            background: none;
            border: none;
            color: #e74c3c;
            cursor: pointer;
            font-size: 14px;
            padding: 0 5px;
        }
        .ia-progress-bar {
            height: 8px;
            background: #333;
            border-radius: 4px;
            overflow: hidden;
            margin: 8px 0;
        }
        .ia-progress-fill {
            height: 100%;
            background: linear-gradient(90deg, #e74c3c, #f1c40f, #2ecc71);
            transition: width 0.3s;
        }
        @media (max-width: 768px) {
            .ia-sidebar { width: 100%; max-height: 200px; }
            .ia-admin-content { flex-direction: column; }
        }
        .ia-admin-sidebar {
            width: 280px;
            background: #1e1e1e;
            border-right: 1px solid #333;
            display: flex;
            flex-direction: column;
            overflow-y: auto;
        }
        .ia-admin-sidebar h3 {
            padding: 12px 15px;
            margin: 0;
            font-size: 13px;
            color: #aaa;
            background: #252525;
            border-bottom: 1px solid #333;
        }
        .ia-file-list, .ia-annotations-list, .ia-controls {
            border-bottom: 1px solid #333;
        }
        .ia-file-items, .ia-annotations {
            padding: 10px;
            max-height: 150px;
            overflow-y: auto;
        }
        .ia-file-empty, .ia-annotation-empty {
            color: #666;
            font-size: 12px;
            text-align: center;
            padding: 10px;
        }
        .ia-file-item {
            background: #252525;
            border-radius: 5px;
            padding: 8px 10px;
            margin-bottom: 6px;
            font-size: 11px;
            cursor: pointer;
            transition: background 0.2s;
        }
        .ia-file-item:hover { background: #333; }
        .ia-file-item.selected { background: #3a5a8a; border-left: 3px solid #4a90d9; }
        .ia-control-group {
            padding: 8px 15px;
        }
        .ia-control-group label {
            display: block;
            font-size: 11px;
            color: #888;
            margin-bottom: 4px;
        }
        .ia-control-group input {
            width: 100%;
            padding: 6px 8px;
            background: #333;
            border: 1px solid #444;
            border-radius: 4px;
            color: #fff;
            font-size: 12px;
        }
        .ia-class-select {
            padding: 4px 8px;
            background: #333;
            border: 1px solid #444;
            border-radius: 4px;
            color: #fff;
            font-size: 11px;
            margin-left: 5px;
        }
        .ia-progress-section {
            padding: 15px;
            background: #1e1e1e;
            border-top: 1px solid #333;
        }
        .ia-progress-text {
            font-size: 12px;
            color: #888;
        }
        .ia-view-canvas-wrapper {
            flex: 1;
            background: #0a0a0a;
            min-height: 300px;
            max-height: 500px;
            overflow: auto;
            position: relative;
        }
        .ia-view-canvas-wrapper canvas:first-child {
            display: block;
        }
        .ia-overlay-canvas {
            position: absolute;
            top: 0;
            left: 0;
            pointer-events: auto;
            cursor: crosshair;
        }
        .ia-view-tools {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 12px;
            background: #1a1a1a;
            border-top: 1px solid #333;
        }
        .ia-tool-btn {
            width: 32px;
            height: 32px;
            border: 1px solid #444;
            border-radius: 6px;
            background: #2a2a2a;
            color: #fff;
            font-size: 16px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
        }
        .ia-tool-btn:hover {
            background: #3a3a3a;
            border-color: #666;
        }
        .ia-tool-btn.active {
            background: #4a90d9;
            border-color: #5aa0e9;
        }
        .ia-view-panel.yolo .ia-tool-btn.active {
            background: #e67e22;
            border-color: #f39c12;
        }
        .ia-view-panel.unet .ia-tool-btn.active {
            background: #9b59b6;
            border-color: #a66bbe;
        }
        .ia-view-tools input[type="range"] {
            width: 80px;
            accent-color: #9b59b6;
        }

        /* ============== TRAINING PAGE ============== */
        .training-overlay {
            display: none;
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.98);
            z-index: 50000;
            overflow: auto;
        }
        .training-overlay.visible { display: block; }
        .training-container {
            max-width: 1400px;
            margin: 20px auto;
            background: #1a1a1a;
            border-radius: 12px;
            overflow: hidden;
        }
        .training-header {
            background: linear-gradient(135deg, #9b59b6, #8e44ad);
            padding: 20px 30px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .training-header h2 {
            margin: 0;
            color: #fff;
            font-size: 24px;
        }
        .training-close {
            background: rgba(255,255,255,0.2);
            border: none;
            color: #fff;
            font-size: 28px;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            cursor: pointer;
        }
        .training-close:hover { background: rgba(255,255,255,0.3); }
        .training-content {
            display: flex;
            min-height: 600px;
        }
        .training-sidebar {
            width: 300px;
            background: #222;
            border-right: 1px solid #333;
            padding: 20px;
        }
        .training-sidebar h3 {
            color: #9b59b6;
            font-size: 14px;
            margin: 0 0 15px 0;
            padding-bottom: 10px;
            border-bottom: 1px solid #333;
        }
        .train-stat-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 10px;
            margin-bottom: 20px;
        }
        .train-stat-item {
            background: #2a2a2a;
            padding: 12px;
            border-radius: 8px;
            text-align: center;
        }
        .train-stat-item span {
            display: block;
            font-size: 11px;
            color: #888;
            margin-bottom: 4px;
        }
        .train-stat-item strong {
            font-size: 24px;
            color: #9b59b6;
        }
        .train-class-list, .train-images-list {
            max-height: 150px;
            overflow-y: auto;
            margin-bottom: 20px;
        }
        .train-class-item, .train-image-item {
            display: flex;
            justify-content: space-between;
            padding: 8px 12px;
            background: #2a2a2a;
            border-radius: 5px;
            margin-bottom: 5px;
            font-size: 12px;
        }
        .train-class-item strong { color: #e67e22; }
        .train-image-item small { color: #666; }
        .train-image-item .delete-btn {
            background: #e74c3c;
            color: white;
            border: none;
            border-radius: 3px;
            padding: 2px 6px;
            cursor: pointer;
            font-size: 10px;
            margin-left: 8px;
        }
        .train-image-item .delete-btn:hover {
            background: #c0392b;
        }
        .train-empty {
            color: #666;
            font-size: 12px;
            text-align: center;
            padding: 20px;
        }
        .training-main {
            flex: 1;
            padding: 25px;
        }
        .training-section {
            background: #252525;
            border-radius: 10px;
            padding: 20px;
            margin-bottom: 20px;
        }
        .training-section h3 {
            color: #fff;
            margin: 0 0 10px 0;
            font-size: 16px;
        }
        .training-section p {
            color: #888;
            font-size: 13px;
            margin: 0 0 15px 0;
        }
        .training-buttons {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
        }
        .train-btn {
            padding: 10px 20px;
            border: none;
            border-radius: 6px;
            font-size: 13px;
            cursor: pointer;
            background: #3a3a3a;
            color: #fff;
            transition: all 0.2s;
        }
        .train-btn:hover { background: #4a4a4a; }
        .train-btn:disabled { opacity: 0.5; cursor: not-allowed; }
        .train-btn.primary { background: #9b59b6; }
        .train-btn.primary:hover { background: #a66bbe; }
        .train-btn.secondary { background: #34495e; }
        .train-btn.secondary:hover { background: #4a6278; }
        .train-btn.success { background: #27ae60; }
        .train-btn.success:hover { background: #2ecc71; }
        .code-block {
            background: #1a1a1a;
            border: 1px solid #333;
            border-radius: 6px;
            padding: 15px;
            margin-bottom: 15px;
            overflow-x: auto;
        }
        .code-block code {
            font-family: 'Monaco', 'Consolas', monospace;
            font-size: 12px;
            color: #2ecc71;
            white-space: pre;
        }
        .model-upload {
            display: flex;
            align-items: center;
            gap: 15px;
        }
        .model-upload span {
            color: #888;
            font-size: 12px;
        }
        .training-history {
            max-height: 150px;
            overflow-y: auto;
        }

        /* ============== SUBSCRIPTION / PREMIUM ============== */
        .toolbar-btn.premium-locked {
            position: relative;
            opacity: 0.6;
        }
        .toolbar-btn.premium-locked::after, .toolbar-btn.premium-feature::after {
            content: '👑';
            position: absolute;
            top: 2px;
            right: 2px;
            font-size: 10px;
        }
        .toolbar-btn.premium-feature { position: relative; }
        .toolbar-btn.premium-locked:hover {
            background: linear-gradient(to bottom, #8a6a2a, #6a5a1a) !important;
        }
        .voie-btn.premium-locked {
            position: relative;
            opacity: 0.6;
        }
        .voie-btn.premium-locked::after, .voie-btn.premium-feature::after {
            content: '👑';
            position: absolute;
            top: -5px;
            right: -5px;
            font-size: 8px;
        }
        .voie-btn.premium-feature { position: relative; }

        /* Bannière essai gratuit */
        .trial-banner {
            position: fixed;
            bottom: 30px;
            left: 50%;
            transform: translateX(-50%);
            background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
            color: #fff;
            padding: 10px 20px;
            border-radius: 8px;
            font-size: 13px;
            font-weight: 500;
            box-shadow: 0 4px 15px rgba(46, 204, 113, 0.4);
            z-index: 1000;
            display: none;
            text-align: center;
            max-width: 90%;
        }
        .trial-banner.visible { display: block; }
        .trial-banner-close {
            position: absolute;
            top: 4px;
            right: 8px;
            background: none;
            border: none;
            color: #fff;
            font-size: 16px;
            cursor: pointer;
            opacity: 0.7;
        }
        .trial-banner-close:hover { opacity: 1; }

        /* Modal Upgrade */
        .upgrade-modal-overlay {
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.85);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 35000;
            padding: 20px;
        }
        .upgrade-modal-overlay.visible { display: flex; }
        .upgrade-modal {
            background: var(--bg-panel);
            border-radius: 16px;
            width: 100%;
            max-width: 500px;
            box-shadow: 0 20px 60px rgba(0,0,0,0.5);
            border: 2px solid var(--accent);
            overflow: hidden;
        }
        .upgrade-modal-header {
            background: linear-gradient(135deg, #d99040 0%, #b87030 100%);
            padding: 20px 24px;
            text-align: center;
        }
        .upgrade-modal-header h2 {
            color: white;
            font-size: 24px;
            margin-bottom: 5px;
        }
        .upgrade-modal-header p {
            color: rgba(255,255,255,0.9);
            font-size: 14px;
        }
        .upgrade-modal-body {
            padding: 24px;
        }
        .upgrade-feature-list {
            list-style: none;
            margin-bottom: 20px;
        }
        .upgrade-feature-list li {
            padding: 10px 0;
            border-bottom: 1px solid var(--border);
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .upgrade-feature-list li:last-child {
            border-bottom: none;
        }
        .upgrade-feature-list .icon {
            font-size: 20px;
        }
        .upgrade-price {
            text-align: center;
            margin: 20px 0;
            padding: 15px;
            background: rgba(217, 144, 64, 0.1);
            border-radius: 8px;
            border: 1px solid var(--accent);
        }
        .upgrade-price .amount {
            font-size: 36px;
            font-weight: 700;
            color: var(--accent);
        }
        .upgrade-price .period {
            color: var(--text-muted);
            font-size: 14px;
        }
        .upgrade-modal-actions {
            display: flex;
            gap: 10px;
            margin-top: 20px;
        }
        .upgrade-btn {
            flex: 1;
            padding: 14px 20px;
            border: none;
            border-radius: 8px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
        }
        .upgrade-btn.primary {
            background: linear-gradient(135deg, #d99040 0%, #b87030 100%);
            color: white;
        }
        .upgrade-btn.primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 20px rgba(217, 144, 64, 0.4);
        }
        .upgrade-btn.secondary {
            background: var(--bg-toolbar);
            color: var(--text);
            border: 1px solid var(--border);
        }
        .upgrade-btn.secondary:hover {
            background: var(--bg-hover);
        }
        .upgrade-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            transform: none !important;
            box-shadow: none !important;
        }

        /* Plans selection */
        .upgrade-plans-container {
            margin-bottom: 20px;
        }
        .upgrade-plans-loading {
            text-align: center;
            padding: 20px;
            color: var(--text-muted);
        }
        .upgrade-plans-grid {
            display: flex;
            gap: 12px;
            flex-wrap: wrap;
        }
        .upgrade-plan-card {
            flex: 1;
            min-width: 200px;
            border: 2px solid var(--border);
            border-radius: 12px;
            padding: 16px;
            cursor: pointer;
            transition: all 0.2s;
            background: var(--bg-toolbar);
        }
        .upgrade-plan-card:hover {
            border-color: var(--accent);
            background: rgba(217, 144, 64, 0.05);
        }
        .upgrade-plan-card.selected {
            border-color: var(--accent);
            background: rgba(217, 144, 64, 0.1);
            box-shadow: 0 0 0 3px rgba(217, 144, 64, 0.2);
        }
        .upgrade-plan-card .plan-name {
            font-weight: 600;
            font-size: 16px;
            margin-bottom: 8px;
            color: var(--text);
        }
        .upgrade-plan-card .plan-price {
            font-size: 28px;
            font-weight: 700;
            color: var(--accent);
        }
        .upgrade-plan-card .plan-price-period {
            font-size: 14px;
            color: var(--text-muted);
            font-weight: normal;
        }
        .upgrade-plan-card .plan-description {
            font-size: 12px;
            color: var(--text-muted);
            margin-top: 8px;
        }
        .upgrade-plans-error {
            text-align: center;
            padding: 20px;
            color: #e74c3c;
            background: rgba(231, 76, 60, 0.1);
            border-radius: 8px;
        }

        /* Subscription status in user menu */
        .subscription-status {
            padding: 10px 15px;
            margin: 10px 15px;
            border-radius: 8px;
            font-size: 12px;
            text-align: center;
        }
        .subscription-status.free {
            background: rgba(100, 100, 100, 0.2);
            border: 1px solid var(--border);
            color: var(--text-muted);
        }
        .subscription-status.pro {
            background: rgba(217, 144, 64, 0.2);
            border: 1px solid var(--accent);
            color: var(--accent);
        }
        .subscription-status .plan-name {
            font-weight: 600;
            font-size: 14px;
        }
        .manage-subscription-btn {
            display: block;
            margin: 10px 15px;
            padding: 10px;
            background: transparent;
            border: 1px solid var(--border);
            border-radius: 6px;
            color: var(--text);
            font-size: 13px;
            cursor: pointer;
            text-align: center;
            transition: all 0.2s;
        }
        .manage-subscription-btn:hover {
            background: var(--bg-hover);
            border-color: var(--accent);
        }

        /* ============== REALTIME NOTIFICATIONS ============== */
        .notification-container {
            position: fixed;
            top: 70px;
            right: 20px;
            z-index: 10000;
            display: flex;
            flex-direction: column;
            gap: 10px;
            max-width: 350px;
        }
        .notification-toast {
            background: var(--bg-panel);
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 12px 16px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.3);
            animation: slideIn 0.3s ease-out;
            display: flex;
            align-items: flex-start;
            gap: 10px;
        }
        .notification-toast.success { border-left: 4px solid var(--success); }
        .notification-toast.warning { border-left: 4px solid var(--accent); }
        .notification-toast.error { border-left: 4px solid var(--danger); }
        .notification-toast.info { border-left: 4px solid var(--primary); }
        .notification-toast .icon { font-size: 20px; }
        .notification-toast .content { flex: 1; }
        .notification-toast .title { font-weight: bold; font-size: 13px; margin-bottom: 4px; }
        .notification-toast .message { font-size: 12px; color: var(--text-muted); }
        .notification-toast .close-btn {
            background: none;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            font-size: 16px;
            padding: 0;
        }
        @keyframes slideIn {
            from { transform: translateX(100%); opacity: 0; }
            to { transform: translateX(0); opacity: 1; }
        }
        @keyframes slideOut {
            from { transform: translateX(0); opacity: 1; }
            to { transform: translateX(100%); opacity: 0; }
        }

        /* Progress bar for parsing/IA */
        .progress-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0,0,0,0.7);
            z-index: 9999;
            display: none;
            justify-content: center;
            align-items: center;
        }
        .progress-overlay.visible { display: flex; }
        .progress-box {
            background: var(--bg-panel);
            border-radius: 12px;
            padding: 30px 40px;
            text-align: center;
            min-width: 300px;
        }
        .progress-box .title { font-size: 16px; font-weight: bold; margin-bottom: 15px; }
        .progress-box .progress-bar {
            height: 8px;
            background: var(--bg-dark);
            border-radius: 4px;
            overflow: hidden;
            margin-bottom: 10px;
        }
        .progress-box .progress-fill {
            height: 100%;
            background: linear-gradient(90deg, var(--primary), var(--accent));
            border-radius: 4px;
            transition: width 0.3s ease;
            width: 0%;
        }
        .progress-box .progress-text { font-size: 12px; color: var(--text-muted); }

        /* ================================================
           DRAWING TOOL PANEL
           ================================================ */
        .toolbar-btn.drawing {
            background: linear-gradient(to bottom, #8a2a6a, #7a1a5a) !important;
            border-color: #c060a0 !important;
            animation: pulse 1s ease-in-out infinite;
        }

        .drawing-panel.modal-panel {
            position: fixed;
            border: 2px solid #9b59b6;
            min-width: 240px;
            max-width: 280px;
            top: 150px;
            right: 20px;
            left: auto;
            bottom: auto;
            z-index: 300;
        }
        .drawing-panel h3 {
            color: #9b59b6;
            cursor: move;
            margin: 0 0 12px 0;
            font-size: 14px;
            padding: 8px;
            margin: -14px -14px 12px -14px;
            background: rgba(155, 89, 182, 0.2);
            border-radius: 10px 10px 0 0;
            user-select: none;
        }

        .drawing-tools {
            display: flex;
            gap: 6px;
            margin-bottom: 12px;
            padding-bottom: 10px;
            border-bottom: 1px solid #444;
        }

        .drawing-tool-btn {
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: #404040;
            border: 1px solid #555;
            border-radius: 6px;
            cursor: pointer;
            color: #ddd;
            font-size: 18px;
            transition: all 0.15s;
        }

        .drawing-tool-btn:hover {
            background: #505050;
            border-color: #666;
        }

        .drawing-tool-btn.active {
            background: linear-gradient(to bottom, #2a5a8a, #1a4a7a);
            border-color: var(--primary);
            color: #fff;
        }

        .drawing-options {
            display: flex;
            flex-direction: column;
            gap: 10px;
            margin-bottom: 12px;
            padding-bottom: 10px;
            border-bottom: 1px solid #444;
        }

        .drawing-option-row {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .drawing-option-row label {
            font-size: 11px;
            color: #ccc;
            width: 60px;
        }

        .drawing-option-row input[type="color"] {
            width: 36px;
            height: 28px;
            padding: 0;
            border: 1px solid #555;
            border-radius: 4px;
            cursor: pointer;
            background: transparent;
        }

        .drawing-option-row input[type="range"] {
            flex: 1;
            height: 6px;
            background: #404040;
            border-radius: 3px;
            -webkit-appearance: none;
            appearance: none;
        }

        .drawing-option-row input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 16px;
            height: 16px;
            background: var(--primary);
            border-radius: 50%;
            cursor: pointer;
        }

        .drawing-option-row span {
            font-size: 11px;
            color: var(--primary);
            font-weight: bold;
            min-width: 16px;
            text-align: center;
        }

        .line-style-btns {
            display: flex;
            gap: 6px;
        }

        .line-style-btn {
            padding: 4px 10px;
            background: #353535;
            border: 1px solid #555;
            border-radius: 4px;
            color: #aaa;
            font-size: 11px;
            cursor: pointer;
            transition: all 0.15s;
        }

        .line-style-btn:hover {
            background: #454545;
            border-color: #666;
        }

        .line-style-btn.active {
            background: linear-gradient(to bottom, #2a5a8a, #1a4a7a);
            border-color: var(--primary);
            color: #fff;
        }

        #lineStyleRow {
            display: none;
        }

        #lineStyleRow.visible {
            display: flex;
        }

        .drawing-actions {
            display: flex;
            gap: 8px;
        }

        .drawing-actions .btn {
            flex: 1;
            padding: 8px;
            font-size: 11px;
        }

        /* Drawing mode cursor - bright red crosshair for visibility */
        .drawing-mode, .drawing-mode canvas {
            cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Cpath d='M16 0v32M0 16h32' stroke='white' stroke-width='4'/%3E%3Cpath d='M16 0v32M0 16h32' stroke='%23ff0000' stroke-width='2'/%3E%3Ccircle cx='16' cy='16' r='5' fill='none' stroke='white' stroke-width='3'/%3E%3Ccircle cx='16' cy='16' r='5' fill='none' stroke='%23ff0000' stroke-width='1.5'/%3E%3C/svg%3E") 16 16, crosshair !important;
        }

        .drawing-mode.text-tool, .drawing-mode.text-tool canvas {
            cursor: text !important;
        }

        /* Text input overlay for drawing text */
        .drawing-text-input {
            position: absolute;
            background: rgba(0,0,0,0.8);
            border: 2px solid var(--primary);
            border-radius: 4px;
            padding: 8px;
            z-index: 300;
        }

        .drawing-text-input input {
            background: transparent;
            border: none;
            color: #fff;
            font-size: 14px;
            outline: none;
            min-width: 150px;
        }

        .drawing-text-input-buttons {
            display: flex;
            gap: 6px;
            margin-top: 6px;
        }

        .drawing-text-input-buttons button {
            flex: 1;
            padding: 4px 8px;
            font-size: 11px;
            border-radius: 4px;
            cursor: pointer;
        }

        .drawing-text-input-buttons .confirm {
            background: var(--primary);
            border: none;
            color: #fff;
        }

        .drawing-text-input-buttons .cancel {
            background: transparent;
            border: 1px solid #555;
            color: #ccc;
        }
