/* ═══════════════════════════════════════════════════════
   HL_BOT — TradingView-inspired Dashboard
   Dark default, warm navy tones, blue accents
   Sidebar nav, compact tables, flat KPIs
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;500;600;700&display=swap');

/* ── THEME TOKENS ── */

[data-theme="dark"], :root {
    --font-ui: -apple-system, BlinkMacSystemFont, 'Trebuchet MS', 'Segoe UI', sans-serif;
    --font-mono: 'Roboto Mono', 'SF Mono', monospace;

    --bg-body: #131722;
    --bg-card: #1e222d;
    --bg-elevated: #242832;
    --bg-hover: #2a2e39;
    --bg-input: #1a1e2a;

    --border: #2a2e39;
    --border-hover: #363a45;

    --text-1: #d1d4dc;
    --text-2: #848e9c;
    --text-3: #5d6673;
    --text-muted: #434651;

    --blue: #2962FF;
    --blue-bg: rgba(41,98,255,0.12);
    --green: #26a69a;
    --green-bg: rgba(38,166,154,0.12);
    --green-bright: #4dd0c0;
    --red: #ef5350;
    --red-bg: rgba(239,83,80,0.12);
    --amber: #ff9800;
    --amber-bg: rgba(255,152,0,0.12);

    --chart-grid: rgba(255,255,255,0.04);
    --chart-tick: #5d6673;
    --chart-tooltip-bg: #1e222d;
    --chart-tooltip-border: #2a2e39;
    --chart-tooltip-text-1: #d1d4dc;
    --chart-tooltip-text-2: #848e9c;
    --chart-line-up: #26a69a;
    --chart-fill-up: rgba(38,166,154,0.08);
    --chart-line-down: #ef5350;
    --chart-fill-down: rgba(239,83,80,0.08);

    --modal-overlay: rgba(0,0,0,0.55);
    --shadow: 0 4px 24px rgba(0,0,0,0.3);

    --sidebar-w: 56px;
    --theme-sun: block;
    --theme-moon: none;
}

[data-theme="light"] {
    --bg-body: #f0f3fa;
    --bg-card: #ffffff;
    --bg-elevated: #f8f9fd;
    --bg-hover: #eef1f8;
    --bg-input: #f4f5f9;

    --border: #e0e3eb;
    --border-hover: #c8ccd8;

    --text-1: #131722;
    --text-2: #5d606b;
    --text-3: #9598a1;
    --text-muted: #c5c8d2;

    --blue: #2962FF;
    --blue-bg: rgba(41,98,255,0.08);
    --green: #089981;
    --green-bg: rgba(8,153,129,0.08);
    --green-bright: #089981;
    --red: #f23645;
    --red-bg: rgba(242,54,69,0.08);
    --amber: #f57c00;
    --amber-bg: rgba(245,124,0,0.08);

    --chart-grid: rgba(0,0,0,0.04);
    --chart-tick: #9598a1;
    --chart-tooltip-bg: #ffffff;
    --chart-tooltip-border: #e0e3eb;
    --chart-tooltip-text-1: #131722;
    --chart-tooltip-text-2: #5d606b;
    --chart-line-up: #089981;
    --chart-fill-up: rgba(8,153,129,0.06);
    --chart-line-down: #f23645;
    --chart-fill-down: rgba(242,54,69,0.06);

    --modal-overlay: rgba(0,0,0,0.2);
    --shadow: 0 2px 12px rgba(0,0,0,0.08);

    --theme-sun: none;
    --theme-moon: block;
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
[x-cloak] { display: none !important; }

html, body { height: 100%; }
body {
    font-family: var(--font-ui);
    font-size: 13px;
    background: var(--bg-body);
    color: var(--text-1);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
    transition: background 0.2s, color 0.2s;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── LAYOUT: Sidebar + Main ── */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    gap: 2px;
    flex-shrink: 0;
    transition: background 0.2s;
    z-index: 10;
}
.sidebar-logo {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-2);
    margin-bottom: 16px;
    letter-spacing: -0.02em;
}
.sidebar-logo span { color: var(--blue); }

.nav-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s;
    position: relative;
}
.nav-btn:hover { background: var(--bg-hover); color: var(--text-2); }
.nav-btn.active { background: var(--blue-bg); color: var(--blue); }
.nav-btn svg { width: 18px; height: 18px; }

.sidebar-spacer { flex: 1; }

.sidebar-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

/* ── MAIN CONTENT ── */
.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 20px 60px;
}

/* ── TOPBAR ── */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-right { display: flex; align-items: center; gap: 6px; }

.page-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-1);
    text-transform: capitalize;
}

/* ── BADGES ── */
.badge {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.04em;
}
.badge-paper { background: var(--green-bg); color: var(--green); }
.badge-live { background: var(--red-bg); color: var(--red); animation: pulse-red 2s ease-in-out infinite; }
@keyframes pulse-red { 50% { box-shadow: 0 0 8px var(--red-bg); } }

.live-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--green); animation: blink 2s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: 0.3; } }

/* ── TYPOGRAPHY ── */
.mono { font-family: var(--font-mono); }
.val-xl { font-family: var(--font-mono); font-size: 22px; font-weight: 700; letter-spacing: -0.03em; }
.val-lg { font-family: var(--font-mono); font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }
.val-sm { font-family: var(--font-mono); font-size: 12px; }
.label { font-size: 11px; color: var(--text-3); margin-bottom: 2px; }
.up { color: var(--green); }
.down { color: var(--red); }

/* ── CARDS ── */
.card {
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: background 0.2s, border 0.2s;
}

/* ── KPI ROW ── */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1px;
    background: var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
}
.kpi-cell {
    background: var(--bg-card);
    padding: 14px 16px;
}
.kpi-cell:first-child { border-radius: 8px 0 0 8px; }
.kpi-cell:last-child { border-radius: 0 8px 8px 0; }

/* ── TABLES ── */
.tv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.tv-table th {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-3);
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.tv-table th.r { text-align: right; }
.tv-table td {
    padding: 6px 10px;
    color: var(--text-2);
    white-space: nowrap;
}
.tv-table tbody tr { transition: background 0.08s; }
.tv-table tbody tr:hover { background: var(--bg-hover); }
.tv-table td.bright { color: var(--text-1); font-weight: 500; }
.tv-table td.r { text-align: right; }

/* ── BUTTONS ── */
.btn {
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.12s;
    min-height: 32px;
}
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-1); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { opacity: 0.85; }
.btn-red { background: var(--red-bg); color: var(--red); }
.btn-red:hover { background: var(--red); color: #fff; }
.btn-sm { font-size: 11px; padding: 3px 8px; min-height: 24px; }

/* ── KILL SWITCH ── */
.kill-btn {
    background: var(--red-bg);
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--red);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.15s;
    width: 100%;
    min-height: 70px;
}
.kill-btn:hover { background: var(--red); color: #fff; }
.kill-btn.active { animation: kill-pulse 1.5s ease-in-out infinite; }
@keyframes kill-pulse { 50% { border-color: var(--red); } }

/* ── INPUTS ── */
.input {
    font-family: var(--font-mono);
    font-size: 13px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-1);
    padding: 10px 12px;
    outline: none;
    width: 100%;
    transition: border 0.15s;
}
.input:focus { border-color: var(--blue); }
.input::placeholder { color: var(--text-muted); }

/* ── TOGGLE ── */
.toggle { width: 34px; height: 18px; border-radius: 9px; background: var(--bg-input); border: 1px solid var(--border); position: relative; cursor: pointer; transition: all 0.15s; }
.toggle.on { background: var(--green-bg); border-color: var(--green); }
.toggle-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--text-3); position: absolute; top: 2px; left: 2px; transition: all 0.15s; }
.toggle.on .toggle-dot { transform: translateX(16px); background: var(--green); }

/* ── SIDE BADGES ── */
.side-up { color: var(--green); background: var(--green-bg); padding: 1px 6px; border-radius: 3px; font-family: var(--font-mono); font-size: 11px; font-weight: 600; }
.side-dn { color: var(--red); background: var(--red-bg); padding: 1px 6px; border-radius: 3px; font-family: var(--font-mono); font-size: 11px; font-weight: 600; }
.tag-pass { color: var(--green); background: var(--green-bg); padding: 1px 6px; border-radius: 3px; font-size: 11px; }
.tag-reject { color: var(--amber); background: var(--amber-bg); padding: 1px 6px; border-radius: 3px; font-size: 11px; }

/* ── STAT GRID ── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1px;
    background: var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.stat-cell {
    background: var(--bg-card);
    padding: 12px 14px;
}
.stat-cell .label { margin-bottom: 4px; }
.stat-cell .val { font-family: var(--font-mono); font-size: 15px; font-weight: 600; color: var(--text-1); }

/* ── MODAL ── */
.overlay { background: var(--modal-overlay); backdrop-filter: blur(4px); }
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

/* ── TOASTS ── */
.toast-wrap { position: fixed; top: 12px; right: 12px; z-index: 200; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { font-size: 12px; font-weight: 500; padding: 8px 14px; border-radius: 6px; pointer-events: auto; animation: toast-in 0.25s ease-out; }
.toast-success { background: var(--green-bg); color: var(--green); }
.toast-danger { background: var(--red-bg); color: var(--red); }
.toast-warning { background: var(--amber-bg); color: var(--amber); }
.toast-info { background: var(--blue-bg); color: var(--blue); }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } }

/* ── PROGRESS BAR ── */
.prog { width: 100%; height: 3px; background: var(--bg-elevated); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.prog-fill { height: 100%; border-radius: 2px; transition: width 0.4s; }
.prog-fill.up { background: var(--green); }
.prog-fill.dn { background: var(--red); }

/* ── PNL TINT ── */
.pnl-tint-up { background: var(--green-bg); border-radius: 3px; padding: 1px 4px; }
.pnl-tint-dn { background: var(--red-bg); border-radius: 3px; padding: 1px 4px; }

/* ── RISK WARNING ── */
.risk-warn { border-color: var(--amber) !important; }
.risk-crit { border-color: var(--red) !important; animation: kill-pulse 1.5s ease-in-out infinite; }

/* ── FILTER CHIPS ── */
.chip { font-size: 11px; padding: 3px 10px; border-radius: 12px; border: 1px solid var(--border); background: transparent; color: var(--text-3); cursor: pointer; transition: all 0.12s; }
.chip:hover { color: var(--text-2); border-color: var(--border-hover); }
.chip.on { background: var(--blue-bg); color: var(--blue); border-color: transparent; }

/* ── SHORTCUTS MODAL ── */
.shortcut-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 12px; color: var(--text-2); }
.key { font-family: var(--font-mono); font-size: 11px; padding: 1px 6px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 4px; color: var(--text-2); }

/* ── PAGINATION ── */
.page-btn { font-family: var(--font-mono); font-size: 11px; padding: 4px 10px; background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text-2); border-radius: 4px; cursor: pointer; transition: all 0.12s; }
.page-btn:hover { background: var(--bg-hover); }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── EMPTY ── */
.empty { font-size: 12px; color: var(--text-muted); text-align: center; padding: 40px 0; }

/* ── LOGIN ── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-body); transition: background 0.2s; }
.login-box { width: 100%; max-width: 360px; padding: 32px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }

/* ── THEME TOGGLE ── */
.theme-btn { width: 32px; height: 32px; border-radius: 6px; border: none; background: transparent; color: var(--text-3); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.12s; }
.theme-btn:hover { background: var(--bg-hover); color: var(--text-2); }
.theme-btn .ico-sun { display: var(--theme-sun); }
.theme-btn .ico-moon { display: var(--theme-moon); }

/* ── ANIMATIONS ── */
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.anim { animation: fade-up 0.25s ease-out both; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── FOCUS ── */
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ── OVERFLOW ── */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .bottom-nav {
        display: flex !important;
        position: fixed; bottom: 0; left: 0; right: 0;
        background: var(--bg-card); border-top: 1px solid var(--border);
        justify-content: space-around; padding: 6px 0; z-index: 50;
    }
    .bottom-nav .nav-btn { width: 44px; height: 44px; }
    .main-content { padding-bottom: 70px; }
    .val-xl { font-size: 18px; }
    .kpi-row { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 769px) {
    .bottom-nav { display: none !important; }
}
