/* ── Google Fonts ────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:        #080c14;
    --bg2:       #0e1420;
    --bg3:       #141c2b;
    --border:    rgba(255,255,255,0.07);
    --text:      #c8d6e8;
    --muted:     #4a5568;
    --subtle:    #2d3748;
    --accent:    #00d4a0;
    --accent2:   #0099ff;
    --red:       #ff4d6d;
    --yellow:    #f6c90e;
    --green:     #00d4a0;
    --radius:    10px;
    --font-mono: 'DM Mono', 'Fira Mono', monospace;
    --font-body: 'DM Sans', 'Segoe UI', sans-serif;
    --sidebar-w: 172px;
    --topbar-h:  56px;
}

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14px;
    min-height: 100vh;
    line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.wrapper { display: flex; min-height: 100vh; }

/* ── Sidebar (desktop) ───────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transition: transform 0.25s ease;
}

.sidebar-logo {
    padding: 20px 14px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}
.sidebar-logo span {
    font-weight: 700;
    font-size: 14px;
    letter-spacing: -0.02em;
    color: #e2e8f0;
}

.sidebar nav { padding: 14px 8px; flex: 1; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
    margin-bottom: 2px;
    white-space: nowrap;
}
.sidebar nav a:hover  { background: var(--bg3); color: var(--text); text-decoration: none; }
.sidebar nav a.active { background: rgba(0,212,160,0.1); color: var(--accent); }
.sidebar nav a .nav-icon { font-size: 14px; width: 16px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid var(--border);
}
.sidebar-footer a {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px;
    color: var(--muted);
    font-size: 13px;
    border-radius: 7px;
    transition: all 0.15s;
    white-space: nowrap;
}
.sidebar-footer a:hover { color: var(--red); background: rgba(255,77,109,0.08); text-decoration: none; }

/* ── Main content ────────────────────────────────────────────────────────── */
.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 32px 36px;
    max-width: 1200px;
    min-width: 0;
}

/* ── Mobile topbar ───────────────────────────────────────────────────────── */
.topbar {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    z-index: 300;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}
.topbar-logo {
    display: flex; align-items: center; gap: 8px;
    font-weight: 700; font-size: 15px; color: #e2e8f0;
    text-decoration: none;
}
.topbar-logo img { width: 28px; height: 28px; border-radius: 6px; }
.topbar-logo:hover { text-decoration: none; }

/* Hamburger button */
.burger {
    background: none; border: none; cursor: pointer;
    display: flex; flex-direction: column; gap: 5px;
    padding: 6px;
}
.burger span {
    display: block; width: 22px; height: 2px;
    background: var(--text); border-radius: 2px;
    transition: all 0.2s;
}
.burger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger.open span:nth-child(2) { opacity: 0; }
.burger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Overlay behind open sidebar on mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 150;
}
.sidebar-overlay.visible { display: block; }

/* ── Page Header ─────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 22px; font-weight: 700; color: #e2e8f0; letter-spacing: -0.03em; }
.page-header p  { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
}
.card-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    margin-bottom: 12px;
}

/* ── KPI Grid ────────────────────────────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}
.kpi {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
}
.kpi-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.kpi-value { font-size: 22px; font-weight: 700; font-family: var(--font-mono); color: #e2e8f0; line-height: 1.2; margin-top: 4px; }
.kpi-sub   { font-size: 11px; color: var(--muted); margin-top: 3px; }
.kpi-value.pos { color: var(--green); }
.kpi-value.neg { color: var(--red); }

/* ── Table ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
thead th {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 13px;
    vertical-align: middle;
}
tbody tr:hover td { background: rgba(255,255,255,0.02); }
tbody tr:last-child td { border-bottom: none; }

.mono  { font-family: var(--font-mono); }
.pos   { color: var(--green); }
.neg   { color: var(--red); }
.muted { color: var(--muted); }

/* ── Badge ───────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-mono);
}
.badge-long  { background: rgba(0,212,160,0.12); color: var(--green); }
.badge-short { background: rgba(255,77,109,0.12); color: var(--red); }
.badge-ap    { background: rgba(0,212,160,0.15); color: #00d4a0; }
.badge-a     { background: rgba(104,211,145,0.15); color: #68d391; }
.badge-b     { background: rgba(246,201,14,0.15); color: var(--yellow); }
.badge-c     { background: rgba(246,173,85,0.15); color: #f6ad55; }
.badge-d     { background: rgba(255,77,109,0.15); color: var(--red); }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; }
.form-control {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text);
    padding: 9px 12px;
    font-size: 13px;
    font-family: var(--font-body);
    transition: border-color 0.15s;
    -webkit-appearance: none;
}
.form-control:focus { outline: none; border-color: rgba(0,212,160,0.4); }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; }

.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.btn-primary  { background: var(--accent); color: #0a0e17; }
.btn-primary:hover { background: #00bf8f; color: #0a0e17; text-decoration: none; }
.btn-outline  { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn-danger   { background: rgba(255,77,109,0.12); border: 1px solid rgba(255,77,109,0.2); color: var(--red); }
.btn-danger:hover { background: rgba(255,77,109,0.2); text-decoration: none; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 7px; font-size: 13px; margin-bottom: 16px; }
.alert-success { background: rgba(0,212,160,0.1);  border: 1px solid rgba(0,212,160,0.25); color: var(--green); }
.alert-error   { background: rgba(255,77,109,0.1); border: 1px solid rgba(255,77,109,0.25); color: var(--red); }
.alert-info    { background: rgba(0,153,255,0.1);  border: 1px solid rgba(0,153,255,0.25); color: var(--accent2); }

/* ── Equity Chart ────────────────────────────────────────────────────────── */
.chart-wrap { width: 100%; overflow: hidden; }
.chart-wrap svg { width: 100%; display: block; }

/* ── Strategy table ──────────────────────────────────────────────────────── */
.strat-bar-bg { background: var(--bg3); border-radius: 3px; height: 5px; margin-top: 5px; }
.strat-bar    { height: 5px; border-radius: 3px; background: var(--accent); }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 20px;
}
.login-box {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 40px 36px;
    width: 100%;
    max-width: 380px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 20px; font-weight: 700; color: #e2e8f0; }
.login-logo p  { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ── Misc ────────────────────────────────────────────────────────────────── */
.section-gap  { margin-top: 24px; }
.text-right   { text-align: right; }
.flex         { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.mb-16  { margin-bottom: 16px; }
.mb-24  { margin-bottom: 24px; }
.w-full { width: 100%; }

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

/* ════════════════════════════════════════════════════════════════════════════
   TABLET  ≤ 900px
   ════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    /* Switch to topbar + slide-in sidebar */
    .topbar  { display: flex; }
    .sidebar { transform: translateX(-100%); top: 0; }
    .sidebar.open { transform: translateX(0); }

    .main {
        margin-left: 0;
        padding: 20px 16px;
        padding-top: calc(var(--topbar-h) + 20px);
    }

    /* Two-column grids become single column */
    div[style*="grid-template-columns:1fr 1fr"] {
        display: flex !important;
        flex-direction: column !important;
    }

    .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
    .kpi-value { font-size: 20px; }

    .page-header h1 { font-size: 18px; }
}

/* ════════════════════════════════════════════════════════════════════════════
   PHONE  ≤ 600px
   ════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
    .main { padding: 12px; padding-top: calc(var(--topbar-h) + 12px); }

    .card { padding: 14px 14px; }

    /* KPIs: 2 columns on phone */
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .kpi { padding: 12px 14px; }
    .kpi-value { font-size: 18px; }

    /* Filter form: stack everything */
    .form-grid { grid-template-columns: 1fr !important; }

    /* Tables: make them scroll horizontally with a visible hint */
    .table-wrap { margin: 0 -14px; padding: 0 14px; }

    /* Page header: stack on small screens */
    .page-header { margin-bottom: 16px; }
    .page-header h1 { font-size: 17px; }
    .flex-between { gap: 10px; }

    /* Trade detail 2-col grid */
    div[style*="grid-template-columns:1fr 1fr"] {
        display: flex !important;
        flex-direction: column !important;
    }

    /* Login box: full width with padding */
    .login-box { padding: 28px 20px; }

    /* Buttons: full width where stacked */
    .btn { white-space: nowrap; }

    /* Stats page side-by-side → stacked */
    div[style*="grid-template-columns:1fr 1fr;gap:24px"] {
        display: flex !important;
        flex-direction: column !important;
    }

    /* Calendar: reduce day cell height */
    .cal-day { height: 60px !important; }
}
