:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #0f1520;
    --bg-card: #111827;
    --bg-card-hover: #1a2332;
    --bg-input: #0f1520;
    --border: #1e293b;
    --accent: #2962ff;
    --accent-hover: #1e4fd6;
    --accent-red: #ff1744;
    --accent-orange: #ff9100;
    --accent-blue: #2962ff;
    --accent-green: #00c853;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #475569;
    --sidebar-width: 240px;
    --topbar-height: 56px;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg-primary); color: var(--text-primary); min-height: 100vh; overflow-x: hidden; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; }
.hidden { display: none !important; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== SIDEBAR ===== */
#sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-width);
    background: var(--bg-secondary); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; z-index: 100; transition: transform 0.3s ease;
}
.sidebar-logo {
    padding: 20px; display: flex; align-items: center; gap: 10px;
    font-size: 1.2rem; font-weight: 700; color: var(--accent); border-bottom: 1px solid var(--border);
}
.sidebar-logo i { font-size: 1.5rem; }
#sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-link {
    display: flex; align-items: center; gap: 12px; padding: 12px 20px;
    color: var(--text-secondary); transition: all var(--transition); font-size: 0.95rem; border-left: 3px solid transparent;
}
.nav-link:hover { color: var(--text-primary); background: var(--bg-card); }
.nav-link.active { color: var(--accent); border-left-color: var(--accent); background: rgba(41,98,255,0.05); }
.nav-link i { width: 20px; text-align: center; font-size: 1.05rem; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); }

/* ===== MAIN AREA ===== */
.main-area { margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; }
#topbar {
    height: var(--topbar-height); background: var(--bg-secondary); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 20px; gap: 16px; position: sticky; top: 0; z-index: 90;
}
.hamburger { display: none; background: none; border: none; color: var(--text-primary); font-size: 1.3rem; cursor: pointer; padding: 8px; }
.ticker-bar { flex: 1; display: flex; gap: 20px; overflow-x: auto; padding: 4px 0; }
.ticker-bar::-webkit-scrollbar { height: 0; }
.ticker-item { display: flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 0.85rem; }
.ticker-symbol { color: var(--text-primary); font-weight: 600; }
.ticker-price { color: var(--text-secondary); }
.ticker-change { font-weight: 600; font-size: 0.8rem; }
.ticker-change.positive { color: var(--accent-green); }
.ticker-change.negative { color: var(--accent-red); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.notification-bell { position: relative; cursor: pointer; padding: 8px; color: var(--text-secondary); transition: color var(--transition); }
.notification-bell:hover { color: var(--text-primary); }
.notif-count {
    position: absolute; top: 2px; right: 2px; background: var(--accent-red); color: #fff;
    font-size: 0.65rem; width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.user-menu { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.user-menu .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; }
.user-menu .user-name { color: var(--text-secondary); font-size: 0.85rem; }

#page-root { flex: 1; padding: 24px; max-width: 1400px; width: 100%; }

/* ===== MODE BADGE ===== */
.mode-badge {
    display: inline-block; padding: 4px 12px; border-radius: 4px; font-size: 0.75rem;
    font-weight: 700; letter-spacing: 1px; text-align: center;
}
.mode-badge.live, .badge-live { background: rgba(41,98,255,0.15); color: var(--accent); border: 1px solid var(--accent); }
.mode-badge.paper, .badge-paper { background: rgba(255,145,0,0.15); color: var(--accent-orange); border: 1px solid var(--accent-orange); }

/* ===== CARDS ===== */
.card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    overflow: hidden; transition: all var(--transition);
}
.card:hover { border-color: rgba(41,98,255,0.2); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 20px; }

.stat-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 20px; transition: all var(--transition); cursor: default;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: rgba(41,98,255,0.2); }
.stat-card .stat-icon { font-size: 1.5rem; margin-bottom: 12px; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; margin-bottom: 4px; }
.stat-card .stat-label { color: var(--text-secondary); font-size: 0.85rem; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }

/* ===== TABLES ===== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    text-align: left; padding: 12px 16px; color: var(--text-secondary); font-weight: 600;
    font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg-card);
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid rgba(30,41,59,0.5); font-size: 0.9rem; }
.data-table tr:hover td { background: var(--bg-card-hover); }
.data-table .symbol { font-weight: 700; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; margin-bottom: 6px; color: var(--text-secondary); font-size: 0.85rem; font-weight: 500; }
.form-input, .form-select {
    width: 100%; padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text-primary); font-size: 0.9rem; outline: none; transition: border var(--transition);
}
.form-input:focus, .form-select:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-muted); }
.form-select option { background: var(--bg-card); }

.form-toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.form-toggle input { opacity: 0; width: 0; height: 0; }
.form-toggle .slider {
    position: absolute; inset: 0; background: var(--border); border-radius: 24px; cursor: pointer; transition: var(--transition);
}
.form-toggle .slider::before {
    content: ''; position: absolute; width: 18px; height: 18px; left: 3px; bottom: 3px;
    background: var(--text-secondary); border-radius: 50%; transition: var(--transition);
}
.form-toggle input:checked + .slider { background: var(--accent); }
.form-toggle input:checked + .slider::before { transform: translateX(20px); background: #fff; }

.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 20px; border: none; border-radius: var(--radius); font-size: 0.9rem;
    font-weight: 600; cursor: pointer; transition: all var(--transition); white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }
.btn-danger { background: var(--accent-red); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: 0.9; }
.btn-secondary { background: var(--bg-card-hover); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); }
.btn-outline { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-outline:hover:not(:disabled) { background: rgba(41,98,255,0.1); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-google { background: #fff; color: #333; font-weight: 500; border: 1px solid #ddd; }
.btn-google:hover { background: #f5f5f5; }
.btn-google i { color: #4285f4; }

/* ===== BADGES ===== */
.badge {
    display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 4px;
    font-size: 0.75rem; font-weight: 700; letter-spacing: 0.5px;
}
.badge-long { background: rgba(41,98,255,0.15); color: var(--accent); }
.badge-short { background: rgba(255,23,68,0.15); color: var(--accent-red); }
.badge-active { background: rgba(41,98,255,0.15); color: var(--accent); }
.badge-closed { background: rgba(148,163,184,0.15); color: var(--text-secondary); }
.badge-exchange { background: var(--bg-card-hover); color: var(--text-secondary); border: 1px solid var(--border); }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center;
    justify-content: center; z-index: 1000; backdrop-filter: blur(4px); animation: fadeIn 0.2s;
}
.modal-content {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    max-width: 600px; width: 90%; max-height: 85vh; overflow-y: auto; animation: slideUp 0.3s;
}
.modal-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex;
    align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 1.1rem; }
.modal-close { background: none; border: none; color: var(--text-secondary); font-size: 1.3rem; cursor: pointer; padding: 4px 8px; }
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.modal-chart { max-width: 900px; width: 95%; }
.modal-chart .modal-body { padding: 0; }

/* ===== TOAST ===== */
#toast-root { position: fixed; top: 16px; right: 16px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
    display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--radius);
    background: var(--bg-card); border: 1px solid var(--border); min-width: 280px; max-width: 400px;
    box-shadow: var(--shadow); transform: translateX(120%); transition: all 0.3s ease; font-size: 0.9rem;
}
.toast.show { transform: translateX(0); }
.toast.hide { transform: translateX(120%); opacity: 0; }
.toast-success { border-left: 3px solid var(--accent); }
.toast-success i { color: var(--accent); }
.toast-error { border-left: 3px solid var(--accent-red); }
.toast-error i { color: var(--accent-red); }
.toast-warning { border-left: 3px solid var(--accent-orange); }
.toast-warning i { color: var(--accent-orange); }
.toast-info { border-left: 3px solid var(--accent-blue); }
.toast-info i { color: var(--accent-blue); }
.toast-close { background: none; border: none; color: var(--text-muted); cursor: pointer; margin-left: auto; font-size: 1.1rem; }

/* ===== CHART ===== */
.chart-container { width: 100%; height: 450px; border-radius: var(--radius); overflow: hidden; background: var(--bg-card); }
.chart-toolbar { display: flex; gap: 4px; padding: 8px 12px; background: var(--bg-secondary); border-bottom: 1px solid var(--border); }
.chart-toolbar .tf-btn {
    padding: 4px 10px; border: none; border-radius: 4px; font-size: 0.8rem; font-weight: 600;
    color: var(--text-secondary); background: transparent; cursor: pointer; transition: all var(--transition);
}
.chart-toolbar .tf-btn:hover { color: var(--text-primary); }
.chart-toolbar .tf-btn.active { color: var(--accent); background: rgba(41,98,255,0.1); }

/* ===== TABS ===== */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
    padding: 10px 20px; color: var(--text-secondary); cursor: pointer; font-weight: 500;
    border-bottom: 2px solid transparent; transition: all var(--transition);
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ===== SPINNER ===== */
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-page { display: flex; align-items: center; justify-content: center; min-height: 300px; flex-direction: column; gap: 12px; }
.loading-page .spinner { margin: 0; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i { font-size: 3rem; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 0.9rem; }

/* ===== PNL COLORS ===== */
.pnl-positive { color: var(--accent-green) !important; }
.pnl-negative { color: var(--accent-red) !important; }

/* ===== CHANNEL CARD ===== */
.channel-card { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); transition: background var(--transition); cursor: pointer; }
.channel-card:hover { background: var(--bg-card-hover); }
.channel-info { display: flex; align-items: center; gap: 12px; }
.channel-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--bg-card-hover); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; color: var(--accent); }
.channel-name { font-weight: 600; }
.channel-meta { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }
.channel-actions { display: flex; align-items: center; gap: 12px; }

/* ===== SETTINGS SECTIONS ===== */
.settings-section { margin-bottom: 32px; }
.settings-section h3 { font-size: 1rem; font-weight: 600; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.settings-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }

/* ===== AUTH PAGES ===== */
.auth-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-primary); }
.auth-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 40px; max-width: 420px; width: 90%; }
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo i { font-size: 2.5rem; color: var(--accent); }
.auth-logo h2 { margin-top: 8px; font-size: 1.3rem; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--text-muted); font-size: 0.85rem; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-footer { text-align: center; margin-top: 20px; color: var(--text-secondary); font-size: 0.85rem; }

/* ===== POSITION CARD ===== */
.position-card { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.position-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.position-symbol { font-weight: 700; font-size: 1.05rem; }
.position-details { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.position-detail-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; }
.position-detail-value { font-size: 0.95rem; font-weight: 600; margin-top: 2px; }

/* ===== PROGRESS ===== */
.progress-bar { width: 100%; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.5s ease; }

/* ===== DROPDOWN ===== */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; top: 100%; right: 0; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); min-width: 180px; box-shadow: var(--shadow); z-index: 200; display: none;
}
.dropdown-menu.show { display: block; }
.dropdown-item { padding: 10px 16px; cursor: pointer; font-size: 0.9rem; transition: background var(--transition); display: flex; align-items: center; gap: 8px; }
.dropdown-item:hover { background: var(--bg-card-hover); }

/* ===== PAGE HEADER ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-header h2 { font-size: 1.4rem; font-weight: 700; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .settings-grid { grid-template-columns: 1fr; }
    .position-details { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    #sidebar { transform: translateX(-100%); }
    #sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
    .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99; display: none; }
    .sidebar-overlay.show { display: block; }
    .main-area { margin-left: 0; }
    .hamburger { display: block; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    #page-root { padding: 16px; }
    .modal-chart { max-width: 100%; width: 100%; }
    .modal-content { width: 95%; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .position-details { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .auth-card { padding: 24px; }
    .topbar-right .user-name { display: none; }
}