:root {
    --bg-main: #090d16;
    --bg-panel: rgba(15, 23, 42, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-indigo: #6366f1;
    --profit-green: #10b981;
    --loss-red: #f43f5e;
    --warning-amber: #f59e0b;
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius-sm: 8px;
    --radius-md: 12px;
}

/* 🔒 Strict Mobile Lock Fix */
html, body {
    width: 100%;
    max-width: 100vw;
    margin: 0;
    padding: 0;
    overflow-x: hidden !important;
    box-sizing: border-box;
}

*, *:before, *:after {
    box-sizing: inherit;
}

body {
    font-family: var(--font-main);
    background: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    padding-bottom: 30px;
}

/* Compact Header */
.app-header {
    height: 60px;
    padding: 0 12px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
}

.header-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.logo-icon { width: 34px; height: 34px; background: var(--accent-indigo); border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 16px; color: white; flex-shrink: 0; }
.logo-text h1 { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.version-badge { display: none; }

.header-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.status-badge { display: flex; align-items: center; gap: 5px; padding: 4px 8px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border-color); border-radius: 20px; font-size: 10px; font-weight: 600; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; }
.status-dot.connected, .status-dot.running { background-color: var(--profit-green); }
.status-dot.disconnected, .status-dot.stopped { background-color: var(--loss-red); }

.btn { padding: 8px 12px; border-radius: 6px; font-family: var(--font-main); font-size: 12px; font-weight: 600; border: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-primary { background: var(--accent-indigo); color: white; }
.btn-success { background: var(--profit-green); color: white; }
.btn-danger { background: var(--loss-red); color: white; }
.btn-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning-amber); border: 1px solid rgba(245, 158, 11, 0.3); }
.btn-outline { background: rgba(255, 255, 255, 0.05); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-icon { width: 34px; height: 34px; padding: 0; background: rgba(255, 255, 255, 0.06); color: var(--text-primary); border: 1px solid var(--border-color); font-size: 14px; flex-shrink: 0; }

.dashboard-container { padding: 10px; display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 100%; margin: 0; }

/* 2-Column Mobile Stat Grid */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.stat-card { background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 10px 12px; width: 100%; }
.stat-title { font-size: 10px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; }
.stat-value { font-size: 18px; font-weight: 800; font-family: var(--font-mono); margin-top: 4px; }
.stat-footer { font-size: 9px; margin-top: 2px; }

/* Control Bar */
.control-bar { background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 10px; display: flex; flex-direction: column; gap: 8px; width: 100%; }
.control-bar-left { display: flex; gap: 6px; width: 100%; }
.control-bar-left .btn { flex: 1; text-align: center; }
.control-bar-right { display: flex; flex-direction: column; gap: 2px; font-size: 11px; }

.main-content-grid { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.panel-card { background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 10px; width: 100%; display: flex; flex-direction: column; gap: 8px; }
.panel-header h3 { font-size: 13px; font-weight: 700; }

.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 11px; text-align: left; }
.data-table th, .data-table td { padding: 6px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.04); font-family: var(--font-mono); }

.terminal-body { background: #050811; border: 1px solid var(--border-color); border-radius: 6px; padding: 8px; height: 260px; overflow-y: auto; font-family: var(--font-mono); font-size: 10px; }

/* Modal Mobile Fix */
.modal-backdrop { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0, 0, 0, 0.85); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 10px; }
.modal-backdrop.active { display: flex; }
.modal-window { background: #0f172a; border: 1px solid var(--border-color); border-radius: var(--radius-md); width: 100%; max-width: 480px; max-height: 90vh; display: flex; flex-direction: column; }
.modal-header { padding: 12px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { font-size: 14px; font-weight: 700; }
.modal-body { padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.form-grid { display: flex; flex-direction: column; gap: 8px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 11px; font-weight: 600; color: var(--text-secondary); }
.form-group input, .form-group select { background: rgba(0, 0, 0, 0.4); border: 1px solid var(--border-color); border-radius: 6px; padding: 8px; color: var(--text-primary); font-size: 12px; width: 100%; }
.modal-footer { padding: 10px 12px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 6px; }

/* Desktop View */
@media (min-width: 768px) {
    .dashboard-container { padding: 20px; gap: 16px; max-width: 1600px; margin: 0 auto; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; }
    .control-bar { flex-direction: row; justify-content: space-between; padding: 12px 16px; }
    .control-bar-left { width: auto; }
    .main-content-grid { grid-template-columns: 1fr 420px; gap: 16px; }
    .terminal-body { height: 460px; }
    .form-grid { display: grid; grid-template-columns: 1fr 1fr; }
    .version-badge { display: inline-block; }
}
