/* =====================================================
   NIYATABOOK APP — DESIGN SYSTEM + STYLES
   Fluid trading journal UI (Linear / Stripe-adjacent polish)
   ===================================================== */

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

/* ─── Design Tokens — Night (default) ─── */
:root,
html[data-theme="night"] {
    color-scheme: dark;
    /* Colors — deep navy with soft ambient */
    --bg-base: #070A10;
    --bg-surface: #0C1018;
    --bg-elevated: #121826;
    --bg-card: rgba(22, 28, 44, 0.72);
    --bg-card-solid: #141B2C;
    --bg-hover: rgba(255,255,255,0.04);
    --border: rgba(255,255,255,0.07);
    --border-soft: rgba(255,255,255,0.04);
    --border-active: rgba(18,209,142,0.35);

    /* Text */
    --text-primary: #EEF2F8;
    --text-secondary: #91A0B8;
    --text-muted: #5A6578;
    --text-inverse: #070A10;

    /* Accents */
    --green: #12D18E;
    --green-dim: rgba(18,209,142,0.12);
    --green-glow: rgba(18,209,142,0.22);
    --red: #FF5C5C;
    --red-dim: rgba(255,92,92,0.12);
    --gold: #F0B429;
    --gold-dim: rgba(240,180,41,0.12);
    --blue: #4F9CF9;
    --blue-dim: rgba(79,156,249,0.12);
    --purple: #A78BFA;
    --purple-dim: rgba(167,139,250,0.12);

    /* Chart / embed */
    --chart-bg: #0B0F1A;
    --chart-grid: rgba(255, 255, 255, 0.06);
    --chart-crosshair: rgba(255, 255, 255, 0.3);
    --chart-label-bg: #1E2536;
    --chart-border: rgba(255, 255, 255, 0.08);
    --scrollbar-thumb: rgba(255,255,255,0.1);
    --scrollbar-thumb-hover: rgba(255,255,255,0.2);
    --overlay-scrim: rgba(0,0,0,0.5);
    --ambient-a: rgba(18,209,142,0.07);
    --ambient-b: rgba(79,156,249,0.06);

    /* Layout — fluid */
    --sidebar-width: 240px;
    --sidebar-collapsed: 64px;
    --topbar-height: 60px;
    --page-pad: clamp(1rem, 2.2vw, 1.75rem);
    --section-gap: clamp(1rem, 1.8vw, 1.5rem);
    --content-max: 1400px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.35);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.35);
    --shadow-lg: 0 16px 48px rgba(0,0,0,0.45);
    --shadow-glow-green: 0 0 24px rgba(18,209,142,0.15);

    /* Motion */
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --transition: 0.22s var(--ease-out);
    --transition-slow: 0.4s var(--ease-out);

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 22px;
    --radius-full: 9999px;

    /* Typography */
    --font-display: 'Outfit', system-ui, sans-serif;
    --font-body: 'Outfit', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

/* ─── Design Tokens — Day ─── */
html[data-theme="day"] {
    color-scheme: light;
    --bg-base: #E8EDF5;
    --bg-surface: #F3F6FB;
    --bg-elevated: #FFFFFF;
    --bg-card: rgba(255, 255, 255, 0.88);
    --bg-card-solid: #FFFFFF;
    --bg-hover: rgba(15, 23, 42, 0.04);
    --border: rgba(15, 23, 42, 0.1);
    --border-soft: rgba(15, 23, 42, 0.06);
    --border-active: rgba(16, 185, 129, 0.45);

    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #64748B;
    --text-inverse: #F8FAFC;

    --green: #059669;
    --green-dim: rgba(5, 150, 105, 0.12);
    --green-glow: rgba(5, 150, 105, 0.2);
    --red: #DC2626;
    --red-dim: rgba(220, 38, 38, 0.1);
    --gold: #D97706;
    --gold-dim: rgba(217, 119, 6, 0.12);
    --blue: #2563EB;
    --blue-dim: rgba(37, 99, 235, 0.1);
    --purple: #7C3AED;
    --purple-dim: rgba(124, 58, 237, 0.1);

    --chart-bg: #FFFFFF;
    --chart-grid: rgba(15, 23, 42, 0.07);
    --chart-crosshair: rgba(15, 23, 42, 0.35);
    --chart-label-bg: #E2E8F0;
    --chart-border: rgba(15, 23, 42, 0.1);
    --scrollbar-thumb: rgba(15, 23, 42, 0.18);
    --scrollbar-thumb-hover: rgba(15, 23, 42, 0.3);
    --overlay-scrim: rgba(15, 23, 42, 0.35);
    --ambient-a: rgba(5, 150, 105, 0.08);
    --ambient-b: rgba(37, 99, 235, 0.07);

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 16px 48px rgba(15, 23, 42, 0.12);
    --shadow-glow-green: 0 0 24px rgba(5, 150, 105, 0.12);
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: var(--font-body);
    background:
        radial-gradient(1200px 600px at 12% -10%, var(--ambient-a), transparent 55%),
        radial-gradient(900px 500px at 90% 0%, var(--ambient-b), transparent 50%),
        var(--bg-base);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.55;
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    transition: background-color var(--transition-slow), color var(--transition);
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

/* ─── Auth Gate ─── */
#auth-gate {
    position: fixed; inset: 0;
    background: var(--bg-base);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    flex-direction: column;
    gap: 1rem;
}
.auth-demo-btn {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 1001;
    font-family: var(--font-body);
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-active);
    background: var(--bg-elevated);
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.auth-demo-btn:hover {
    background: var(--green-dim);
    border-color: var(--green);
    color: var(--green);
}
.topbar-chip.demo {
    color: var(--gold);
    border-color: var(--gold);
    background: rgba(240, 180, 41, 0.12);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.6875rem;
}
#auth-gate .auth-gate-logo {
    display: flex; align-items: center; gap: 10px;
    font-family: var(--font-display);
    font-size: 1.75rem; font-weight: 700;
    margin-bottom: 1rem;
}
#auth-gate .auth-gate-logo .logo-accent { color: var(--green); }
#auth-gate .auth-gate-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    width: 100%; max-width: 400px;
    text-align: center;
}
#auth-gate h2 {
    font-family: var(--font-display);
    font-size: 1.5rem; font-weight: 700;
    margin-bottom: 0.5rem;
}
#auth-gate p { color: var(--text-secondary); margin-bottom: 1.5rem; }
.auth-gate-spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

/* ─── App Shell ─── */
#app-shell { display: none; height: 100vh; overflow: hidden; }
#app-shell.ready { display: flex; }

/* ─── Sidebar ─── */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    position: fixed; left: 0; top: 0;
    z-index: 100;
    transition: width var(--transition-slow);
    overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-header {
    height: var(--topbar-height);
    display: flex; align-items: center;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--border);
    gap: 10px;
    flex-shrink: 0;
}
.sidebar-logo-icon svg { flex-shrink: 0; }
.sidebar-logo-text {
    font-family: var(--font-display);
    font-size: 1.1rem; font-weight: 700;
    white-space: nowrap;
    transition: opacity var(--transition), width var(--transition);
}
.sidebar-logo-text .accent { color: var(--green); }
.sidebar.collapsed .sidebar-logo-text { opacity: 0; width: 0; overflow: hidden; }

.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; overflow-x: hidden; }
.nav-section-label {
    font-size: 0.6875rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0.5rem 1.25rem 0.25rem;
    white-space: nowrap;
    transition: opacity var(--transition);
}
.sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.625rem 1.25rem;
    border-radius: 0;
    color: var(--text-secondary);
    font-size: 0.9rem; font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
    position: relative;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { color: var(--green); background: var(--green-dim); }
.nav-item.active::before {
    content: '';
    position: absolute; left: 0; top: 0; bottom: 0;
    width: 3px; background: var(--green); border-radius: 0 2px 2px 0;
}
.nav-item svg { flex-shrink: 0; width: 20px; height: 20px; }
.nav-item-label {
    transition: opacity var(--transition), width var(--transition);
    white-space: nowrap;
}
.sidebar.collapsed .nav-item-label { opacity: 0; width: 0; overflow: hidden; }
.nav-badge {
    margin-left: auto;
    background: var(--green-dim); color: var(--green);
    font-size: 0.7rem; font-weight: 600;
    padding: 1px 7px; border-radius: var(--radius-full);
    flex-shrink: 0;
}
.sidebar.collapsed .nav-badge { display: none; }

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.sidebar-user {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.5rem; border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition);
}
.sidebar-user:hover { background: var(--bg-hover); }
.user-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--green-dim);
    border: 1.5px solid var(--green);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: var(--green);
    font-size: 0.875rem; flex-shrink: 0;
    overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-info { flex: 1; min-width: 0; }
.user-name {
    font-size: 0.8125rem; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-plan {
    font-size: 0.6875rem; color: var(--gold);
    font-weight: 500;
}
.sidebar.collapsed .user-info { display: none; }

/* ─── Topbar ─── */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky; top: 0;
    z-index: 50;
}
.topbar-toggle {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
}
.topbar-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }
.topbar-title {
    font-family: var(--font-display);
    font-size: 1.125rem; font-weight: 700;
    flex: 1;
}
.topbar-right { display: flex; align-items: center; gap: 0.75rem; margin-left: auto; }
.topbar-chip {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.375rem 0.875rem;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.8125rem; color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}
.topbar-chip:hover { border-color: var(--border-active); }
.topbar-chip.green { color: var(--green); border-color: var(--green-dim); background: var(--green-dim); }
.topbar-chip.red { color: var(--red); border-color: var(--red-dim); background: var(--red-dim); }

/* ─── Main Content ─── */
#main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1; height: 100vh;
    display: flex; flex-direction: column;
    overflow: hidden;
    transition: margin-left var(--transition-slow);
}
#main-wrapper.sidebar-collapsed { margin-left: var(--sidebar-collapsed); }
#page-content {
    flex: 1; overflow-y: auto;
    padding: var(--page-pad);
    display: flex; flex-direction: column;
    gap: var(--section-gap);
    max-width: var(--content-max);
    width: 100%;
    margin: 0 auto;
    animation: pageIn 0.45s var(--ease-out) both;
}
#page-content > * {
    flex-shrink: 0;
}
@keyframes pageIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* ─── Page Header ─── */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 1rem;
}
.page-title {
    font-family: var(--font-display);
    font-size: clamp(1.35rem, 2.2vw, 1.75rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.03em;
}
.page-subtitle { color: var(--text-secondary); font-size: 0.875rem; margin-top: 0.3rem; font-weight: 400; }
.page-header-right { display: flex; gap: 0.75rem; align-items: center; }

/* ─── KPI Cards Grid ─── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 168px), 1fr));
    gap: clamp(0.75rem, 1.4vw, 1rem);
}
.kpi-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: clamp(1rem, 1.5vw, 1.25rem);
    position: relative;
    overflow: hidden;
    transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
    animation: fadeInUp 0.5s var(--ease-out) both;
    box-shadow: var(--shadow-sm);
}
.kpi-card:nth-child(1) { animation-delay: 0.02s; }
.kpi-card:nth-child(2) { animation-delay: 0.04s; }
.kpi-card:nth-child(3) { animation-delay: 0.06s; }
.kpi-card:nth-child(4) { animation-delay: 0.08s; }
.kpi-card:nth-child(5) { animation-delay: 0.1s; }
.kpi-card:nth-child(6) { animation-delay: 0.12s; }
.kpi-card:nth-child(7) { animation-delay: 0.14s; }
.kpi-card:nth-child(8) { animation-delay: 0.16s; }
.kpi-card:hover {
    border-color: rgba(255,255,255,0.12);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}
.kpi-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-color, var(--green)), transparent 80%);
    opacity: 0.75;
}
.kpi-card.red-accent { --accent-color: var(--red); }
.kpi-card.gold-accent { --accent-color: var(--gold); }
.kpi-card.blue-accent { --accent-color: var(--blue); }
.kpi-card.purple-accent { --accent-color: var(--purple); }
.kpi-label {
    font-size: 0.75rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-muted); margin-bottom: 0.5rem;
}
.kpi-value {
    font-family: var(--font-mono);
    font-size: clamp(1.25rem, 2vw, 1.55rem);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}
.kpi-value.positive { color: var(--green); }
.kpi-value.negative { color: var(--red); }
.kpi-sub {
    font-size: 0.75rem;
    margin-top: 0.375rem;
    color: var(--text-muted);
}
.kpi-delta {
    font-size: 0.75rem; margin-top: 0.375rem;
    display: flex; align-items: center; gap: 0.25rem;
    color: var(--text-muted);
}
.kpi-delta.up { color: var(--green); }
.kpi-delta.down { color: var(--red); }
.kpi-icon {
    position: absolute; top: 1rem; right: 1rem;
    width: 36px; height: 36px;
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.125rem;
    background: var(--icon-bg, var(--green-dim));
}
.kpi-card.red-accent .kpi-icon { --icon-bg: var(--red-dim); }
.kpi-card.gold-accent .kpi-icon { --icon-bg: var(--gold-dim); }
.kpi-card.blue-accent .kpi-icon { --icon-bg: var(--blue-dim); }
.kpi-card.purple-accent .kpi-icon { --icon-bg: var(--purple-dim); }

/* ─── Chart Cards ─── */
.chart-card {
    background: var(--bg-card);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    flex-shrink: 0;
    min-height: min-content;
    animation: fadeInUp 0.55s var(--ease-out) both;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.chart-card:hover {
    border-color: rgba(255,255,255,0.1);
    box-shadow: var(--shadow-md);
}
.chart-card-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-soft);
}
.chart-card-title {
    font-family: var(--font-display);
    font-size: 0.9375rem; font-weight: 650;
    letter-spacing: -0.02em;
}
.chart-card-sub {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    font-weight: 500;
}
.chart-card-body { padding: 1.15rem 1.25rem 1.25rem; overflow: hidden; }
.chart-legend {
    display: flex;
    gap: 0.9rem;
    margin-top: 0.45rem;
}
.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-muted);
}
.legend-swatch {
    display: inline-block;
    border-radius: 2px;
}
.legend-candle {
    width: 8px;
    height: 11px;
    background: linear-gradient(180deg, #12D18E 0 50%, #FF5C5C 50% 100%);
}
.legend-line {
    width: 16px;
    height: 3px;
    border-radius: 3px;
    background: linear-gradient(90deg, #4F9CF9, #A78BFA, #F0B429);
    box-shadow: 0 0 6px rgba(79, 156, 249, 0.5);
}
.legend-market {
    width: 14px;
    height: 3px;
    border-radius: 3px;
}
.legend-profit-bar,
.legend-loss-bar {
    width: 13px;
    height: 6px;
}
.legend-profit-bar { background: var(--green); }
.legend-loss-bar { background: var(--red); }
.filter-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-right: 0.2rem;
    vertical-align: middle;
}
.chart-card-actions { display: flex; gap: 0.5rem; }

/* Period chips */
.period-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.3rem;
    background: rgba(255,255,255,0.03);
    padding: 3px;
    border-radius: var(--radius-lg);
}
.period-chip {
    padding: 0.3rem 0.7rem;
    font-size: 0.72rem; font-weight: 600;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-muted);
    border: none;
    cursor: pointer;
    transition: color var(--transition), background var(--transition);
}
.period-chip:hover { color: var(--text-secondary); }
.period-chip.active { background: var(--green-dim); color: var(--green); }
.custom-range {
    display: flex;
    align-items: end;
    justify-content: flex-end;
    gap: 0.65rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    background: rgba(255,255,255,0.015);
}
.custom-range[hidden] { display: none; }
.custom-range label {
    display: grid;
    gap: 0.25rem;
    font-size: 0.6875rem;
    color: var(--text-muted);
}
.custom-range input {
    min-height: 34px;
    padding: 0.35rem 0.55rem;
    color: var(--text-primary);
    color-scheme: dark;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font: 0.75rem var(--font-mono);
}
.chart-filter-panel {
    display: grid;
    gap: 0.55rem;
    padding: 0.7rem 1.25rem;
    border-top: 1px solid var(--border);
    background: rgba(255,255,255,0.01);
}
.chart-filter-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
}
.chart-filter-label {
    width: 48px;
    flex: 0 0 48px;
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.chart-filter-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.55rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.025);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 600;
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.chart-filter-chip:hover {
    color: var(--text-secondary);
    border-color: var(--border-hover);
}
.chart-filter-chip.active {
    color: var(--blue);
    background: rgba(79,156,249,0.12);
    border-color: rgba(79,156,249,0.35);
}
.chart-filter-chip.is-disabled,
.chart-filter-chip:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}
.chart-filter-chip.is-disabled:hover,
.chart-filter-chip:disabled:hover {
    color: var(--text-muted);
    border-color: var(--border);
}

@media (max-width: 720px) {
    .chart-card-header { align-items: flex-start; }
    .period-chips { justify-content: flex-start; width: 100%; }
    .custom-range { align-items: stretch; flex-wrap: wrap; justify-content: flex-start; }
    .chart-filter-label { width: 100%; flex-basis: 100%; }
}

/* ─── Canvas Charts ─── */
canvas { display: block; width: 100% !important; }

/* ─── Data Table ─── */
.data-table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    animation: fadeInUp 0.4s ease both;
}
.data-table-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.125rem 1.25rem;
    border-bottom: 1px solid var(--border);
    gap: 1rem; flex-wrap: wrap;
}
.data-table-title {
    font-family: var(--font-display);
    font-size: 0.9375rem; font-weight: 700;
}
.table-filters { display: flex; gap: 0.625rem; flex-wrap: wrap; }
.filter-input {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.4rem 0.75rem;
    color: var(--text-primary);
    font-size: 0.8125rem;
    outline: none;
    transition: border-color var(--transition);
}
.filter-input:focus { border-color: var(--border-active); }
.filter-input::placeholder { color: var(--text-muted); }
.filter-select {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.4rem 0.75rem;
    color: var(--text-primary);
    font-size: 0.8125rem;
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition);
    -webkit-appearance: none;
}
.filter-select:focus { border-color: var(--border-active); }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.data-table th {
    text-align: left; padding: 0.625rem 1rem;
    font-size: 0.6875rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-muted);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: color var(--transition);
}
.data-table th:hover { color: var(--text-secondary); }
.data-table th.sorted { color: var(--green); }
.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    vertical-align: middle;
}
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }
.holdings-scrip-row { cursor: pointer; }
.holdings-scrip-row.active { background: rgba(79, 156, 249, 0.12); }
.holdings-scrip-link { color: var(--blue); }
.holdings-scrip-row:hover .holdings-scrip-link { text-decoration: underline; }

/* Table cell types */
.td-symbol {
    font-family: var(--font-mono);
    font-weight: 600; font-size: 0.875rem;
}
.td-price { font-family: var(--font-mono); color: var(--text-secondary); }
.td-pnl { font-family: var(--font-mono); font-weight: 700; }
.td-pnl.positive { color: var(--green); }
.td-pnl.negative { color: var(--red); }
.badge {
    display: inline-flex; align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.6875rem; font-weight: 600;
    letter-spacing: 0.03em;
}
.badge-buy { background: var(--green-dim); color: var(--green); }
.badge-sell { background: var(--red-dim); color: var(--red); }
.badge-eq { background: var(--blue-dim); color: var(--blue); }
.badge-fo { background: var(--purple-dim); color: var(--purple); }
.badge-tag {
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
    margin-right: 3px;
}

/* Pagination */
.pagination {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--border);
    font-size: 0.8125rem; color: var(--text-muted);
}
.pagination-controls { display: flex; gap: 0.25rem; }
.page-btn {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem; font-weight: 600;
    color: var(--text-secondary);
    transition: background var(--transition), color var(--transition);
}
.page-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.page-btn.active { background: var(--green-dim); color: var(--green); }
.page-btn:disabled { opacity: 0.3; pointer-events: none; }

/* ─── Forms ─── */
.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    animation: fadeInUp 0.4s ease both;
}
.form-section-title {
    font-family: var(--font-display);
    font-size: 0.9375rem; font-weight: 700;
    margin-bottom: 1.25rem;
    display: flex; align-items: center; gap: 0.5rem;
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.375rem; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); letter-spacing: 0.04em; }
.form-control {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.6rem 0.875rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    width: 100%;
}
.form-control:focus { border-color: var(--border-active); box-shadow: 0 0 0 3px var(--green-glow); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; -webkit-appearance: none; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* Tag selector */
.tag-selector { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag-option {
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem; font-weight: 600;
    border: 1px solid var(--border);
    background: transparent; color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}
.tag-option:hover { border-color: rgba(255,255,255,0.2); color: var(--text-secondary); }
.tag-option.selected { border-color: var(--green); background: var(--green-dim); color: var(--green); }
.tag-option.emotion-tag.selected { border-color: var(--gold); background: var(--gold-dim); color: var(--gold); }
.tag-option.mistake-tag.selected { border-color: var(--red); background: var(--red-dim); color: var(--red); }

/* Discipline Score Slider */
.discipline-slider-wrap { position: relative; padding: 0.5rem 0; }
.discipline-slider {
    width: 100%; -webkit-appearance: none;
    height: 6px; border-radius: 3px;
    background: linear-gradient(to right, var(--red) 0%, var(--gold) 50%, var(--green) 100%);
    outline: none; cursor: pointer;
}
.discipline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--text-primary);
    border: 2px solid var(--bg-base);
    box-shadow: var(--shadow-md);
    cursor: pointer;
}
.discipline-score-display {
    text-align: center; margin-top: 0.5rem;
    font-family: var(--font-mono); font-size: 1.5rem; font-weight: 700;
}

/* CSV Drop Zone */
.csv-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}
.csv-dropzone:hover, .csv-dropzone.drag-over {
    border-color: var(--green);
    background: var(--green-dim);
}
.csv-dropzone-icon { font-size: 3rem; margin-bottom: 1rem; }
.csv-dropzone-title { font-weight: 600; margin-bottom: 0.25rem; }
.csv-dropzone-subtitle { color: var(--text-muted); font-size: 0.875rem; }

/* Zerodha CSV processing screen */
.csv-process {
    min-height: min(70vh, 560px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2.5rem 1.5rem;
    gap: 0.75rem;
    position: relative;
}
.csv-process-orb {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 3px solid var(--border);
    border-top-color: var(--green);
    animation: csv-spin 0.9s linear infinite;
    margin-bottom: 0.5rem;
}
@keyframes csv-spin { to { transform: rotate(360deg); } }
.csv-process-title {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}
.csv-process-file {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--text-muted);
}
.csv-process-witty {
    min-height: 1.5em;
    max-width: 28rem;
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.35s var(--ease-out), transform 0.35s var(--ease-out);
}
.csv-process-witty.is-swap {
    opacity: 0;
    transform: translateY(6px);
}
.csv-process-bar {
    width: min(360px, 86vw);
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--bg-hover);
    border: 1px solid var(--border);
    overflow: hidden;
    margin-top: 0.75rem;
}
.csv-process-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--green), var(--blue));
    border-radius: var(--radius-full);
    transition: width 0.45s var(--ease-out);
}
.csv-process-status {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* CSV Preview Table */
.csv-preview-wrapper {
    max-height: 300px; overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

/* ─── Tabs ─── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); }
.tab-btn {
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem; font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition);
}
.tab-btn:hover { color: var(--text-secondary); }
.tab-btn.active { color: var(--green); border-bottom-color: var(--green); }
.tab-panel { display: none; padding-top: 1.25rem; }
.tab-panel.active { display: block; }

/* ─── Heatmap Calendar (week rows + date column) ─── */
.heatmap-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    overflow-x: auto;
}
.heatmap-header-row,
.heatmap-row {
    display: grid;
    grid-template-columns: 58px 1fr;
    gap: 0.5rem;
    align-items: center;
    min-width: 220px;
}
.heatmap-date-col {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    white-space: nowrap;
}
.heatmap-date-head {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.625rem;
    color: var(--text-muted);
}
.heatmap-days-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}
.heatmap-rows {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.heatmap-cell {
    width: 100%;
    aspect-ratio: 1;
    max-width: 18px;
    max-height: 18px;
    margin: 0 auto;
    border-radius: 3px;
    background: var(--bg-elevated);
    position: relative;
    cursor: pointer;
    transition: transform 0.18s var(--ease-out), box-shadow 0.18s var(--ease-out), opacity 0.18s;
}
.heatmap-cell:hover {
    transform: scale(1.35);
    z-index: 10;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.25);
}
.heatmap-cell.clickable { cursor: pointer; }
.heatmap-cell.clickable:hover {
    outline: 1px solid rgba(255,255,255,0.35);
}

.day-back-btn { margin-bottom: 0.35rem; padding-left: 0; }
.day-nav-btns { display: flex; gap: 0.5rem; }
.day-snapshot { display: flex; flex-direction: column; gap: 0.75rem; }
.day-snap-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}
.day-snap-row strong { font-family: var(--font-mono); color: var(--text-primary); }
.day-snap-row strong.positive { color: var(--green); }
.day-snap-row strong.negative { color: var(--red); }

/* ─── Holding rankings (tabs + top/bottom split) ─── */
.rankings-header {
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    align-items: flex-start;
}
.rankings-range {
    flex-shrink: 0;
    margin-left: auto;
}
.rankings-filters {
    margin: 0 1rem 0.75rem;
}
.hold-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding: 0 0.5rem;
}
.hold-tabs .tab-btn {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 0.65rem 0.9rem;
    font-size: 0.8125rem;
}
.hold-tab-body { padding-top: 0.75rem; }
.hold-tab-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}
.hold-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.hold-split-title {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}
.hold-sides { display: flex; flex-direction: column; gap: 1.25rem; }
.hold-side-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    background: var(--bg-elevated, transparent);
}
.hold-side-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
}
@media (max-width: 800px) {
    .hold-split { grid-template-columns: 1fr; }
}

/* ─── Dashboard plan: insight, highlights, rules, edges ─── */
.insight-card {
    display: flex;
    gap: 1rem;
    padding: 1rem 1.25rem;
    margin-bottom: var(--section-gap);
    background: linear-gradient(135deg, rgba(79,156,249,0.12), rgba(167,139,250,0.08));
    border: 1px solid rgba(79,156,249,0.25);
    border-radius: var(--radius-md);
}
.insight-icon { font-size: 1.5rem; flex-shrink: 0; }
.insight-title { font-weight: 700; font-size: 0.875rem; margin-bottom: 0.35rem; }
.insight-text { font-size: 0.875rem; color: var(--text-secondary); margin: 0.25rem 0 0; line-height: 1.5; }
.trade-highlight {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}
.trade-highlight--win { border-color: rgba(18,209,142,0.35); background: rgba(18,209,142,0.06); }
.trade-highlight--loss { border-color: rgba(255,92,92,0.35); background: rgba(255,92,92,0.06); }
.trade-highlight-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; color: var(--text-muted); }
.trade-highlight-main { display: flex; gap: 0.75rem; align-items: center; margin-top: 0.35rem; }
.trade-highlight-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.35rem; }
.rules-list { display: flex; flex-direction: column; gap: 0.65rem; }
.rule-row { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.65rem 0.85rem; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.rule-pass { background: rgba(18,209,142,0.06); }
.rule-fail { background: rgba(255,92,92,0.06); border-color: rgba(255,92,92,0.25); }
.rule-detail { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.15rem; }
.kpi-clickable { cursor: pointer; transition: border-color var(--transition), transform var(--transition); }
.kpi-clickable:hover { border-color: var(--green); transform: translateY(-1px); }
.kpi-sparkline { display: block; margin-top: 0.5rem; width: 100%; max-width: 120px; opacity: 0.85; }
.edge-list { display: flex; flex-direction: column; gap: 0.65rem; }
.edge-row { padding: 0.65rem 0.85rem; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.8125rem; }
.edge-row strong { display: block; margin-bottom: 0.25rem; }
.edge-meta { font-size: 0.75rem; color: var(--text-muted); }
.journal-highlight { outline: 2px solid var(--green); box-shadow: 0 0 0 4px rgba(18,209,142,0.15); }
.dash-global-range { margin-right: 0.5rem; }
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeSlideIn 0.35s ease both; }
.kpi-grid .kpi-card:nth-child(1) { animation-delay: 0ms; }
.kpi-grid .kpi-card:nth-child(2) { animation-delay: 40ms; }
.kpi-grid .kpi-card:nth-child(3) { animation-delay: 80ms; }
.chart-card.animate-in { animation-delay: 60ms; }

/* ─── Rulebook ─── */
.rb-scorecard .chart-card-header { align-items: center; }
.rb-compliance-ring {
    width: 56px; height: 56px; border-radius: 50%;
    display: grid; place-items: center;
    background: conic-gradient(var(--green) calc(var(--pct) * 1%), rgba(255,255,255,0.08) 0);
    font-family: var(--font-mono); font-weight: 700; font-size: 0.8125rem;
    position: relative;
}
.rb-compliance-ring::before {
    content: ''; position: absolute; inset: 5px; border-radius: 50%;
    background: var(--bg-card-solid, var(--bg-card));
}
.rb-compliance-ring span { position: relative; z-index: 1; }
.rb-compliance-ring--sm { width: 44px; height: 44px; font-size: 0.75rem; }
.rb-score-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.5rem;
}
.rb-score-grid--compact { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.rb-score-chip {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.5rem 0.65rem; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: transparent;
    color: var(--text-secondary); font-size: 0.75rem; font-weight: 600;
    cursor: pointer; text-align: left;
}
.rb-score-chip.status-pass { border-color: rgba(18,209,142,0.35); background: rgba(18,209,142,0.06); }
.rb-score-chip.status-fail { border-color: rgba(255,92,92,0.35); background: rgba(255,92,92,0.06); }
.rb-score-chip.status-warn { border-color: rgba(240,180,41,0.4); background: rgba(240,180,41,0.08); }
.rb-score-chip.is-disabled,
.rb-score-chip:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}
.rb-rule-open:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.rb-score-detail {
    margin-top: 1rem; padding: 0.85rem 1rem;
    border: 1px solid var(--border); border-radius: var(--radius-md);
    font-size: 0.875rem;
}
.rb-detail-quote {
    margin: 0.5rem 0; padding-left: 0.75rem;
    border-left: 2px solid var(--purple);
    color: var(--text-muted); font-style: italic;
}
.rb-library { display: flex; flex-direction: column; gap: 1.5rem; }
.rb-cat-title {
    font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em;
    text-transform: uppercase; color: var(--text-muted); margin-bottom: 0.75rem;
}
.rb-rule-card {
    border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 1rem 1.1rem; margin-bottom: 0.75rem; opacity: 0.72;
}
.rb-rule-card.is-on { opacity: 1; border-color: rgba(18,209,142,0.3); }
.rb-rule-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.rb-rule-name { font-weight: 700; font-size: 0.9375rem; }
.rb-rule-book { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.2rem; }
.rb-rule-quote { font-size: 0.8125rem; color: var(--text-secondary); font-style: italic; margin: 0.65rem 0; }
.rb-params { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 0.65rem; font-size: 0.75rem; color: var(--text-muted); }
.rb-rule-stats {
    display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center;
    font-size: 0.75rem; color: var(--text-muted);
}
.rb-rule-status { margin-left: auto; max-width: 55%; text-align: right; }
.rb-violation-feed { display: flex; flex-direction: column; gap: 0.65rem; max-height: 280px; overflow-y: auto; }
.rb-violation-row {
    padding: 0.65rem 0.85rem; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 0.8125rem;
}
.rb-violation-click { cursor: pointer; transition: border-color var(--transition), background var(--transition); }
.rb-violation-click:hover { border-color: var(--blue); background: rgba(79, 156, 249, 0.06); }
.rb-detail-meta {
    display: flex; flex-wrap: wrap; gap: 1rem;
    font-size: 0.8125rem; color: var(--text-muted);
}
.rb-rule-open { margin-left: auto; }
.rb-viol-top { display: flex; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.25rem; }
.rb-viol-date { font-size: 0.75rem; color: var(--text-muted); }
.rb-viol-msg { color: var(--text-secondary); }
.rb-viol-sym { font-family: var(--font-mono); font-size: 0.75rem; margin-top: 0.25rem; color: var(--blue); }
.rb-bookshelf {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.85rem;
}
.rb-book-card {
    display: flex; gap: 0.75rem; border: 1px solid var(--border);
    border-radius: var(--radius-md); overflow: hidden; min-height: 110px;
}
.rb-book-spine {
    width: 42px; writing-mode: vertical-rl; transform: rotate(180deg);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.65rem; font-weight: 700; letter-spacing: 0.04em;
    background: var(--book-accent); color: #0b1020; padding: 0.5rem 0;
}
.rb-book-meta { padding: 0.75rem 0.85rem 0.75rem 0; flex: 1; min-width: 0; }
.rb-book-author { font-size: 0.75rem; color: var(--text-muted); margin: 0.15rem 0 0.35rem; }
.rb-book-rules { font-size: 0.6875rem; color: var(--text-secondary); margin-bottom: 0.35rem; }
.rb-book-quote { font-size: 0.75rem; font-style: italic; color: var(--text-muted); }
.rb-dash-widget { cursor: pointer; transition: border-color var(--transition); }
.rb-dash-widget:hover { border-color: var(--green); }
.rb-dash-fail { margin-top: 0.75rem; font-size: 0.8125rem; color: var(--text-muted); }
@media (max-width: 768px) {
    .rb-score-grid { grid-template-columns: 1fr 1fr; }
    .rb-bookshelf { grid-template-columns: 1fr; }
    .rb-rule-status { max-width: 100%; text-align: left; margin-left: 0; }
}
.heatmap-cell.profit-high { background: var(--green); }
.heatmap-cell.profit-med { background: rgba(18,209,142,0.55); }
.heatmap-cell.profit-low { background: rgba(18,209,142,0.28); }
.heatmap-cell.loss-high { background: var(--red); }
.heatmap-cell.loss-med { background: rgba(255,92,92,0.55); }
.heatmap-cell.loss-low { background: rgba(255,92,92,0.28); }
.heatmap-cell.no-trade { background: rgba(255,255,255,0.045); }
.heatmap-day-label {
    text-align: center;
    font-size: 0.625rem;
    color: var(--text-muted);
    font-weight: 600;
}
.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.85rem;
    font-size: 0.6875rem;
    color: var(--text-muted);
}
.heatmap-legend-swatches {
    display: flex;
    gap: 3px;
}
.heatmap-legend-swatches .heatmap-cell {
    width: 12px;
    height: 12px;
    max-width: 12px;
    max-height: 12px;
    cursor: default;
}
.heatmap-legend-swatches .heatmap-cell:hover { transform: none; box-shadow: none; }
.heatmap-tooltip {
    position: fixed; z-index: 100;
    background: var(--bg-card-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    pointer-events: none;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.15s;
    box-shadow: var(--shadow-md);
}
.heatmap-tooltip.visible { opacity: 1; }

/* ─── FY select + month calendar slider ─── */
.period-fy-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.15rem 0.35rem 0.15rem 0.55rem;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
}
.period-fy-label {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}
.period-fy-select {
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    padding: 0.25rem 0.15rem;
    cursor: pointer;
    max-width: 7.5rem;
}
.period-fy-select.is-active { color: var(--green); }
.heatmap-slider-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}
.heatmap-slider-meta {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}
.heatmap-slider-meta strong {
    font-size: 0.875rem;
    text-align: center;
}
.heatmap-slider-meta input[type="range"] {
    width: 100%;
    accent-color: var(--green);
}
/* FY year calendar — 12 month tiles */
.cal-year-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}
.cal-year-tile,
.cal-year-tile.heatmap-cell {
    width: 100%;
    max-width: none;
    max-height: none;
    aspect-ratio: auto;
    margin: 0;
    min-height: 118px;
    border-radius: var(--radius-md);
    padding: 0.85rem 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    border: 1px solid var(--border);
    box-sizing: border-box;
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: inherit;
    background: var(--bg-elevated);
}
.cal-year-tile:hover,
.cal-year-tile.heatmap-cell:hover {
    transform: none;
    scale: none;
    border-color: var(--border-active);
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}
.cal-year-name {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
}
.cal-year-pnl {
    font-size: 1.05rem;
    font-family: var(--font-mono);
    font-weight: 700;
    line-height: 1.2;
    margin-top: 0.2rem;
    color: var(--text-primary);
}
.cal-year-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.3;
    font-weight: 500;
}
.cal-year-tile.profit-high .cal-year-pnl,
.cal-year-tile.profit-med .cal-year-pnl,
.cal-year-tile.profit-low .cal-year-pnl { color: var(--green); }
.cal-year-tile.loss-high .cal-year-pnl,
.cal-year-tile.loss-med .cal-year-pnl,
.cal-year-tile.loss-low .cal-year-pnl { color: var(--red); }
.cal-year-tile.no-trade .cal-year-pnl,
.cal-year-tile.no-trade .cal-year-meta { color: var(--text-muted); }

@media (max-width: 900px) {
    .cal-year-grid { grid-template-columns: repeat(2, 1fr); gap: 0.55rem; }
    .cal-year-tile,
    .cal-year-tile.heatmap-cell { min-height: 96px; padding: 0.65rem 0.7rem; }
    .cal-year-pnl { font-size: 0.9375rem; }
}
@media (max-width: 480px) {
    .cal-year-grid { grid-template-columns: 1fr 1fr; }
}

.cal-month-grid { width: 100%; }
.cal-dow {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.45rem;
    margin-bottom: 0.45rem;
}
.cal-dow span {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}
.cal-cells {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.45rem;
}
/* Override tiny .heatmap-cell (18px) used for week chips */
.cal-cell,
.cal-cell.heatmap-cell {
    width: 100%;
    max-width: none;
    max-height: none;
    aspect-ratio: auto;
    margin: 0;
    min-height: 96px;
    border-radius: var(--radius-md);
    padding: 0.5rem 0.55rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    border: 1px solid var(--border);
    box-sizing: border-box;
    cursor: default;
}
.cal-cell.is-empty,
.cal-cell.is-empty.heatmap-cell {
    background: transparent;
    border-color: transparent;
    min-height: 96px;
    box-shadow: none;
}
.cal-cell.clickable,
.cal-cell.heatmap-cell.clickable { cursor: pointer; }
.cal-cell.clickable:hover,
.cal-cell.heatmap-cell.clickable:hover,
.cal-cell.heatmap-cell:hover {
    transform: none;
    scale: none;
    z-index: 1;
    border-color: var(--border-active);
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
    outline: none;
}
.cal-daynum {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-primary);
}
.cal-pnl {
    font-size: 0.8125rem;
    font-family: var(--font-mono);
    font-weight: 700;
    line-height: 1.25;
    margin-top: 0.15rem;
    color: var(--text-primary);
}
.cal-meta {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    line-height: 1.25;
    font-weight: 500;
}
.cal-meta.muted { opacity: 1; color: var(--text-muted); }
.cal-month-grid--verbose .cal-cell,
.cal-month-grid--verbose .cal-cell.heatmap-cell {
    min-height: 112px;
    padding: 0.55rem 0.6rem;
}
.cal-month-grid--verbose .cal-pnl { font-size: 0.875rem; }
.cal-month-grid--verbose .cal-meta { font-size: 0.75rem; }

/* Profit / loss fills — readable in day + night */
.cal-cell.profit-high,
.cal-cell.heatmap-cell.profit-high {
    background: var(--green-dim);
    border-color: rgba(5, 150, 105, 0.45);
    box-shadow: inset 3px 0 0 var(--green);
}
.cal-cell.profit-med,
.cal-cell.heatmap-cell.profit-med {
    background: rgba(5, 150, 105, 0.1);
    border-color: rgba(5, 150, 105, 0.35);
    box-shadow: inset 3px 0 0 rgba(5, 150, 105, 0.75);
}
.cal-cell.profit-low,
.cal-cell.heatmap-cell.profit-low {
    background: rgba(5, 150, 105, 0.07);
    border-color: rgba(5, 150, 105, 0.28);
    box-shadow: inset 3px 0 0 rgba(5, 150, 105, 0.55);
}
.cal-cell.loss-high,
.cal-cell.heatmap-cell.loss-high {
    background: var(--red-dim);
    border-color: rgba(220, 38, 38, 0.45);
    box-shadow: inset 3px 0 0 var(--red);
}
.cal-cell.loss-med,
.cal-cell.heatmap-cell.loss-med {
    background: rgba(220, 38, 38, 0.1);
    border-color: rgba(220, 38, 38, 0.35);
    box-shadow: inset 3px 0 0 rgba(220, 38, 38, 0.75);
}
.cal-cell.loss-low,
.cal-cell.heatmap-cell.loss-low {
    background: rgba(220, 38, 38, 0.07);
    border-color: rgba(220, 38, 38, 0.28);
    box-shadow: inset 3px 0 0 rgba(220, 38, 38, 0.55);
}
.cal-cell.no-trade,
.cal-cell.heatmap-cell.no-trade {
    background: var(--bg-elevated);
    border-color: var(--border);
    box-shadow: none;
}
.cal-cell.no-trade .cal-daynum { color: var(--text-secondary); }
.cal-cell.no-trade .cal-meta { color: var(--text-muted); }

.cal-cell.profit-high .cal-pnl,
.cal-cell.profit-med .cal-pnl,
.cal-cell.profit-low .cal-pnl { color: var(--green); }
.cal-cell.loss-high .cal-pnl,
.cal-cell.loss-med .cal-pnl,
.cal-cell.loss-low .cal-pnl { color: var(--red); }

.cal-cell.profit-high .cal-daynum,
.cal-cell.profit-med .cal-daynum,
.cal-cell.profit-low .cal-daynum,
.cal-cell.loss-high .cal-daynum,
.cal-cell.loss-med .cal-daynum,
.cal-cell.loss-low .cal-daynum { color: var(--text-primary); }

.cal-cell.profit-high .cal-meta,
.cal-cell.profit-med .cal-meta,
.cal-cell.profit-low .cal-meta,
.cal-cell.loss-high .cal-meta,
.cal-cell.loss-med .cal-meta,
.cal-cell.loss-low .cal-meta { color: var(--text-secondary); }

/* Night: slightly stronger tint so cards read on dark bg */
html[data-theme="night"] .cal-cell.profit-high,
html[data-theme="night"] .cal-cell.heatmap-cell.profit-high {
    background: rgba(18, 209, 142, 0.2);
    border-color: rgba(18, 209, 142, 0.5);
}
html[data-theme="night"] .cal-cell.profit-med,
html[data-theme="night"] .cal-cell.heatmap-cell.profit-med {
    background: rgba(18, 209, 142, 0.14);
}
html[data-theme="night"] .cal-cell.profit-low,
html[data-theme="night"] .cal-cell.heatmap-cell.profit-low {
    background: rgba(18, 209, 142, 0.1);
}
html[data-theme="night"] .cal-cell.loss-high,
html[data-theme="night"] .cal-cell.heatmap-cell.loss-high {
    background: rgba(255, 92, 92, 0.2);
    border-color: rgba(255, 92, 92, 0.5);
}
html[data-theme="night"] .cal-cell.loss-med,
html[data-theme="night"] .cal-cell.heatmap-cell.loss-med {
    background: rgba(255, 92, 92, 0.14);
}
html[data-theme="night"] .cal-cell.loss-low,
html[data-theme="night"] .cal-cell.heatmap-cell.loss-low {
    background: rgba(255, 92, 92, 0.1);
}
html[data-theme="night"] .cal-cell.no-trade,
html[data-theme="night"] .cal-cell.heatmap-cell.no-trade {
    background: rgba(255, 255, 255, 0.04);
}
html[data-theme="night"] .cal-cell.profit-high .cal-pnl,
html[data-theme="night"] .cal-cell.profit-med .cal-pnl,
html[data-theme="night"] .cal-cell.profit-low .cal-pnl { color: #5EEAD4; }
html[data-theme="night"] .cal-cell.loss-high .cal-pnl,
html[data-theme="night"] .cal-cell.loss-med .cal-pnl,
html[data-theme="night"] .cal-cell.loss-low .cal-pnl { color: #FCA5A5; }

/* Day: solid pastels + dark ink (fixes washed white-on-mint) */
html[data-theme="day"] .cal-cell.profit-high,
html[data-theme="day"] .cal-cell.heatmap-cell.profit-high {
    background: #BBF7D0;
    border-color: #34D399;
}
html[data-theme="day"] .cal-cell.profit-med,
html[data-theme="day"] .cal-cell.heatmap-cell.profit-med {
    background: #D1FAE5;
    border-color: #6EE7B7;
}
html[data-theme="day"] .cal-cell.profit-low,
html[data-theme="day"] .cal-cell.heatmap-cell.profit-low {
    background: #ECFDF5;
    border-color: #A7F3D0;
}
html[data-theme="day"] .cal-cell.loss-high,
html[data-theme="day"] .cal-cell.heatmap-cell.loss-high {
    background: #FECACA;
    border-color: #F87171;
}
html[data-theme="day"] .cal-cell.loss-med,
html[data-theme="day"] .cal-cell.heatmap-cell.loss-med {
    background: #FEE2E2;
    border-color: #FCA5A5;
}
html[data-theme="day"] .cal-cell.loss-low,
html[data-theme="day"] .cal-cell.heatmap-cell.loss-low {
    background: #FEF2F2;
    border-color: #FECACA;
}
html[data-theme="day"] .cal-cell.profit-high .cal-pnl,
html[data-theme="day"] .cal-cell.profit-med .cal-pnl,
html[data-theme="day"] .cal-cell.profit-low .cal-pnl { color: #047857; }
html[data-theme="day"] .cal-cell.loss-high .cal-pnl,
html[data-theme="day"] .cal-cell.loss-med .cal-pnl,
html[data-theme="day"] .cal-cell.loss-low .cal-pnl { color: #B91C1C; }
html[data-theme="day"] .cal-cell.profit-high .cal-daynum,
html[data-theme="day"] .cal-cell.profit-med .cal-daynum,
html[data-theme="day"] .cal-cell.profit-low .cal-daynum { color: #064E3B; }
html[data-theme="day"] .cal-cell.loss-high .cal-daynum,
html[data-theme="day"] .cal-cell.loss-med .cal-daynum,
html[data-theme="day"] .cal-cell.loss-low .cal-daynum { color: #7F1D1D; }
html[data-theme="day"] .cal-cell.profit-high .cal-meta,
html[data-theme="day"] .cal-cell.profit-med .cal-meta,
html[data-theme="day"] .cal-cell.profit-low .cal-meta { color: #065F46; }
html[data-theme="day"] .cal-cell.loss-high .cal-meta,
html[data-theme="day"] .cal-cell.loss-med .cal-meta,
html[data-theme="day"] .cal-cell.loss-low .cal-meta { color: #991B1B; }

/* Year tiles share same contrast rules */
.cal-year-name { color: var(--text-primary); }
.cal-year-pnl { color: var(--text-primary); }
.cal-year-meta { color: var(--text-secondary); }
.cal-year-tile.profit-high .cal-year-pnl,
.cal-year-tile.profit-med .cal-year-pnl,
.cal-year-tile.profit-low .cal-year-pnl { color: var(--green); }
.cal-year-tile.loss-high .cal-year-pnl,
.cal-year-tile.loss-med .cal-year-pnl,
.cal-year-tile.loss-low .cal-year-pnl { color: var(--red); }
.cal-year-tile.no-trade .cal-year-pnl,
.cal-year-tile.no-trade .cal-year-meta { color: var(--text-muted); }
html[data-theme="day"] .cal-year-tile.profit-high { background: #BBF7D0; border-color: #34D399; }
html[data-theme="day"] .cal-year-tile.profit-med { background: #D1FAE5; border-color: #6EE7B7; }
html[data-theme="day"] .cal-year-tile.profit-low { background: #ECFDF5; border-color: #A7F3D0; }
html[data-theme="day"] .cal-year-tile.loss-high { background: #FECACA; border-color: #F87171; }
html[data-theme="day"] .cal-year-tile.loss-med { background: #FEE2E2; border-color: #FCA5A5; }
html[data-theme="day"] .cal-year-tile.loss-low { background: #FEF2F2; border-color: #FECACA; }
html[data-theme="day"] .cal-year-tile.profit-high .cal-year-pnl,
html[data-theme="day"] .cal-year-tile.profit-med .cal-year-pnl,
html[data-theme="day"] .cal-year-tile.profit-low .cal-year-pnl { color: #047857; }
html[data-theme="day"] .cal-year-tile.loss-high .cal-year-pnl,
html[data-theme="day"] .cal-year-tile.loss-med .cal-year-pnl,
html[data-theme="day"] .cal-year-tile.loss-low .cal-year-pnl { color: #B91C1C; }
html[data-theme="night"] .cal-year-tile.profit-high .cal-year-pnl,
html[data-theme="night"] .cal-year-tile.profit-med .cal-year-pnl,
html[data-theme="night"] .cal-year-tile.profit-low .cal-year-pnl { color: #5EEAD4; }
html[data-theme="night"] .cal-year-tile.loss-high .cal-year-pnl,
html[data-theme="night"] .cal-year-tile.loss-med .cal-year-pnl,
html[data-theme="night"] .cal-year-tile.loss-low .cal-year-pnl { color: #FCA5A5; }

@media (max-width: 900px) {
    .cal-cell,
    .cal-cell.heatmap-cell {
        min-height: 72px;
        padding: 0.35rem;
    }
    .cal-month-grid--verbose .cal-cell,
    .cal-month-grid--verbose .cal-cell.heatmap-cell { min-height: 84px; }
    .cal-pnl { font-size: 0.6875rem; }
    .cal-meta { font-size: 0.625rem; }
}
.text-link { color: var(--green); text-decoration: none; font-weight: 600; }
.text-link:hover { text-decoration: underline; }

.nb-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1rem;
}
.nb-modal {
    background: var(--bg-card, var(--bg-elevated));
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.35rem;
    max-width: min(460px, calc(100vw - 2rem));
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0,0,0,0.35);
}
.nb-modal h3 {
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
}
.nb-modal p {
    margin: 0 0 0.65rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.45;
}
.nb-modal-hint {
    font-size: 0.8125rem !important;
    color: var(--text-muted) !important;
}
.nb-modal-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
    width: 100%;
    box-sizing: border-box;
}
.nb-modal-actions .btn {
    flex: 0 1 auto;
    max-width: 100%;
}
.nb-modal-actions .btn[data-act="later"] {
    margin-right: auto;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* Legacy aliases kept for analytics/other pages */
.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}
.heatmap-day-labels {
    display: grid; grid-template-columns: repeat(7, 1fr);
    gap: 3px; margin-bottom: 4px;
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem; font-weight: 600;
    cursor: pointer; border: none;
    transition: all var(--transition);
    white-space: nowrap;
    font-family: var(--font-body);
}
.btn-primary {
    background: var(--green);
    color: #000;
}
.btn-primary:hover { background: #0fbf81; box-shadow: var(--shadow-glow-green); transform: translateY(-1px); }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}
.btn-outline:hover { border-color: rgba(255,255,255,0.2); background: var(--bg-hover); }
.btn-ghost {
    background: transparent; color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger {
    background: var(--red-dim); color: var(--red);
    border: 1px solid var(--red-dim);
}
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 0.375rem 0.875rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 0.9375rem; }
.btn-icon {
    width: 36px; height: 36px; padding: 0;
    border-radius: var(--radius-md);
}
.btn:disabled { opacity: 0.4; pointer-events: none; }

/* ─── Grid Layouts ─── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.two-thirds-third { display: grid; grid-template-columns: 2fr 1fr; gap: var(--section-gap); align-items: start; }
.two-thirds-third > * { min-width: 0; }

/* ─── Empty State ─── */
.empty-state {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 0.75rem; padding: 3rem;
    text-align: center;
}
.empty-state-icon { font-size: 3rem; opacity: 0.5; }
.empty-state-title { font-family: var(--font-display); font-size: 1.125rem; font-weight: 700; }
.empty-state-sub { color: var(--text-secondary); font-size: 0.875rem; max-width: 300px; }

/* ─── Loading / Skeleton ─── */
.skeleton {
    background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
    background-size: 200% 100%;
    animation: skeleton-wave 1.5s infinite;
    border-radius: var(--radius-sm);
}
@keyframes skeleton-wave {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─── Toasts ─── */
#toast-container {
    position: fixed; bottom: 1.5rem; right: 1.5rem;
    z-index: 999; display: flex; flex-direction: column; gap: 0.5rem;
}
.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    display: flex; align-items: center; gap: 0.75rem;
    min-width: 280px; max-width: 360px;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--blue); }
.toast-icon { font-size: 1.125rem; flex-shrink: 0; }
.toast-msg { flex: 1; }
@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ─── Modal ─── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 200;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
    opacity: 0; pointer-events: none;
    transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 100%; max-width: 520px;
    max-height: 90vh; overflow-y: auto;
    transform: scale(0.95);
    transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.modal-title {
    font-family: var(--font-display);
    font-size: 1.125rem; font-weight: 700;
}
.modal-body { padding: 1.5rem; }
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 0.75rem;
}

/* ─── Analytics Specific ─── */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}
.insight-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    animation: fadeInUp 0.4s ease both;
}
.insight-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.25rem; }
.insight-value { font-family: var(--font-mono); font-size: 2rem; font-weight: 800; line-height: 1; }
.insight-sub { font-size: 0.8125rem; color: var(--text-secondary); margin-top: 0.375rem; }

/* Bar chart horizontal */
.h-bar-list { display: flex; flex-direction: column; gap: 0.625rem; }
.h-bar-item { display: flex; align-items: center; gap: 0.75rem; }
.h-bar-label { font-size: 0.8125rem; width: 80px; flex-shrink: 0; color: var(--text-secondary); }
.h-bar-track { flex: 1; height: 8px; background: var(--bg-elevated); border-radius: 4px; overflow: hidden; }
.h-bar-fill { height: 100%; border-radius: 4px; transition: width 0.6s ease; }
.h-bar-fill.green { background: var(--green); }
.h-bar-fill.red { background: var(--red); }
.h-bar-val { font-family: var(--font-mono); font-size: 0.8125rem; width: 70px; text-align: right; flex-shrink: 0; }

/* ─── Journal ─── */
.journal-entry {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color var(--transition);
    animation: fadeInUp 0.3s ease both;
}
.journal-entry:hover { border-color: rgba(255,255,255,0.1); }
.journal-entry-header {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.journal-entry-symbol {
    font-family: var(--font-mono); font-weight: 700; font-size: 1rem;
}
.journal-entry-date { font-size: 0.8125rem; color: var(--text-muted); margin-left: auto; }
.journal-entry-body { padding: 1rem 1.25rem; }
.emotion-display { display: flex; gap: 0.375rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.journal-note { font-size: 0.875rem; color: var(--text-secondary); font-style: italic; line-height: 1.5; }
.discipline-mini {
    display: flex; align-items: center; gap: 0.5rem;
    margin-top: 0.75rem;
}
.discipline-mini-bar { flex: 1; height: 4px; background: var(--bg-elevated); border-radius: 2px; overflow: hidden; }
.discipline-mini-fill { height: 100%; border-radius: 2px; }

/* ─── Settings ─── */
.settings-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1rem;
}
.settings-section-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-display);
    font-size: 0.9375rem; font-weight: 700;
}
.settings-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    gap: 1rem;
}
.settings-row:last-child { border-bottom: none; }
.settings-row-label { font-size: 0.875rem; font-weight: 500; }
.settings-row-sub { font-size: 0.8125rem; color: var(--text-muted); margin-top: 0.125rem; }

/* Toggle switch */
.toggle {
    position: relative; width: 40px; height: 22px;
    flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0;
    background: var(--bg-elevated); border-radius: 11px;
    cursor: pointer;
    transition: background var(--transition);
}
.toggle-slider::before {
    content: '';
    position: absolute; left: 3px; top: 3px;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform var(--transition), background var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--green-dim); }
.toggle input:checked + .toggle-slider::before {
    transform: translateX(18px);
    background: var(--green);
}

/* ─── Animations ─── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes pulse-dot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.7; }
}
.pulse-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--green);
    animation: pulse-dot 2s infinite;
    display: inline-block;
}
.spinner {
    animation: spin 0.8s linear infinite;
}

/* ─── Responsive ─── */
@media (max-width: 1024px) {
    .two-col { grid-template-columns: 1fr; }
    .two-thirds-third { grid-template-columns: 1fr; }
    .three-col { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 300;
        width: var(--sidebar-width) !important;
    }
    .sidebar.mobile-open { transform: translateX(0); }
    #main-wrapper { margin-left: 0 !important; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .three-col { grid-template-columns: 1fr; }
    #page-content { padding: 1rem; }
    .data-table { font-size: 0.75rem; }
    .data-table th, .data-table td { padding: 0.5rem 0.75rem; }
}
@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
}

/* ─── Utility ─── */
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-gold { color: var(--gold); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.font-mono { font-family: var(--font-mono); }
.font-display { font-family: var(--font-display); }
.fw-700 { font-weight: 700; }
.fw-600 { font-weight: 600; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.mt-sm { margin-top: 0.5rem; }
.mt-md { margin-top: 1rem; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.gradient-text {
    background: linear-gradient(135deg, var(--green) 0%, #0EB07A 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ─── Emotion Detection ─── */
.emo-mood-badge {
    font-size: 0.875rem; font-weight: 700; padding: 0.4rem 0.85rem;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.mood-clean { background: rgba(18, 209, 142, 0.12); color: var(--green); border-color: rgba(18, 209, 142, 0.35); }
.mood-warning { background: rgba(240, 180, 41, 0.12); color: var(--gold); border-color: rgba(240, 180, 41, 0.35); }
.mood-deteriorating { background: rgba(255, 138, 92, 0.15); color: #FF8A5C; border-color: rgba(255, 138, 92, 0.4); }
.mood-critical { background: rgba(255, 92, 92, 0.15); color: var(--red); border-color: rgba(255, 92, 92, 0.4); }
.emo-dash-widget { cursor: pointer; }
.emo-dash-widget:hover { border-color: var(--gold); }
.emo-clickable { cursor: pointer; }
.emo-clickable:hover { filter: brightness(1.08); }
.emo-pattern-card.emo-clickable:hover, .emo-coach.emo-clickable:hover {
    border-color: var(--blue);
    background: rgba(79, 156, 249, 0.06);
}
.emo-open-hint {
    display: block; margin-top: 0.35rem;
    font-size: 0.6875rem; color: var(--blue); font-weight: 600;
}
.trade-highlight, .day-trade-row.trade-highlight {
    outline: 2px solid var(--blue);
    background: rgba(79, 156, 249, 0.1) !important;
}
.emo-dash-hits { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.emo-badge-row { display: flex; flex-wrap: wrap; gap: 0.25rem; align-items: center; }
.emo-badge {
    display: inline-flex; align-items: center; gap: 0.2rem;
    font-size: 0.6875rem; padding: 0.15rem 0.45rem;
    border-radius: 999px; border: 1px solid var(--border);
    background: var(--bg-elevated); color: var(--text-secondary); white-space: nowrap;
}
.emo-badge.sev-critical, .emo-badge.sev-high {
    border-color: rgba(255, 92, 92, 0.45); color: var(--red);
    background: rgba(255, 92, 92, 0.1);
}
.emo-badge.sev-critical { animation: emo-pulse 1.6s ease-in-out infinite; }
.emo-badge.sev-medium { border-color: rgba(240, 180, 41, 0.45); color: var(--gold); background: rgba(240, 180, 41, 0.1); }
.emo-badge.sev-low, .emo-badge.sev-clean { border-color: rgba(18, 209, 142, 0.35); color: var(--green); background: rgba(18, 209, 142, 0.08); }
@keyframes emo-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 92, 92, 0.35); }
    50% { box-shadow: 0 0 0 4px rgba(255, 92, 92, 0); }
}
.emo-row-hot { background: rgba(255, 92, 92, 0.04); }
.emo-row-warn { background: rgba(240, 180, 41, 0.04); }
.emo-row-clean { background: rgba(18, 209, 142, 0.03); }
.emo-timeline { margin-bottom: 1rem; }
.emo-timeline-axis {
    display: flex; justify-content: space-between;
    font-size: 0.6875rem; color: var(--text-muted); margin-bottom: 0.35rem;
}
.emo-timeline-track {
    position: relative; height: 28px;
    border-radius: 999px; background: var(--bg-elevated);
    border: 1px solid var(--border);
}
.emo-dot {
    position: absolute; top: 50%; transform: translate(-50%, -50%);
    width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--bg-card);
    cursor: pointer; padding: 0; background: var(--green);
}
.emo-dot.sev-medium { background: var(--gold); }
.emo-dot.sev-high, .emo-dot.sev-critical { background: var(--red); }
.emo-dot.sev-low, .emo-dot.sev-clean { background: var(--green); }
.emo-today-list { display: flex; flex-direction: column; gap: 0.55rem; }
.emo-coach {
    padding: 0.75rem 0.9rem; border-radius: var(--radius-sm);
    border: 1px solid var(--border); border-left-width: 3px;
    font-size: 0.8125rem;
}
.emo-coach p { margin: 0.35rem 0 0; color: var(--text-secondary); line-height: 1.45; }
.emo-coach.sev-critical, .emo-coach.sev-high { border-left-color: var(--red); }
.emo-coach.sev-medium { border-left-color: var(--gold); }
.emo-coach.sev-low { border-left-color: var(--blue); }
.emo-pattern-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.85rem;
}
.emo-pattern-card {
    padding: 0.9rem 1rem; border: 1px solid var(--border);
    border-radius: var(--radius-md); border-left-width: 3px;
}
.emo-pattern-card.sev-critical, .emo-pattern-card.sev-high { border-left-color: var(--red); }
.emo-pattern-card.sev-medium { border-left-color: var(--gold); }
.emo-pattern-card.sev-low { border-left-color: var(--blue); }
.emo-pattern-head { display: flex; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.4rem; font-size: 0.8125rem; }
.emo-pattern-head span { color: var(--text-muted); font-size: 0.75rem; }
.emo-pattern-msg { font-size: 0.8125rem; color: var(--text-secondary); margin: 0 0 0.55rem; line-height: 1.4; }
.emo-pattern-meta { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.75rem; color: var(--text-muted); }
.emo-source { font-style: italic; }
.emo-worst { margin-top: 0.45rem; font-size: 0.75rem; color: var(--text-muted); }
@media (max-width: 768px) {
    .emo-pattern-grid { grid-template-columns: 1fr; }
}

/* ─── Market path / TradingView ─── */
.trade-path-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 1rem;
    align-items: start;
}
@media (max-width: 980px) {
    .trade-path-grid { grid-template-columns: 1fr; }
}
.trade-tv-card .chart-card-body { overflow: hidden; }
.tv-wrap { background: var(--bg-elevated); }
.tv-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    gap: 0.75rem; padding: 0.55rem 0.85rem;
    border-bottom: 1px solid var(--border); font-size: 0.75rem;
    flex-wrap: wrap;
}
.ohlc-toolbar { gap: 0.5rem; }
.ohlc-tf {
    display: inline-flex; gap: 0.2rem; flex-wrap: wrap;
    align-items: center;
}
.ohlc-tf-btn, .ohlc-ind-btn {
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.28rem 0.55rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
}
.ohlc-tf-btn:hover, .ohlc-ind-btn:hover {
    border-color: var(--blue);
    color: var(--text-primary);
}
.ohlc-tf-btn.active {
    background: rgba(79, 156, 249, 0.15);
    border-color: var(--blue);
    color: var(--text-primary);
}
.ohlc-ind-wrap { position: relative; }
.ohlc-ind-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 20;
    min-width: 150px;
    padding: 0.45rem 0.55rem;
    background: var(--bg-card, #151b24);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.ohlc-ind-menu[hidden] { display: none !important; }
.ohlc-ind-menu label {
    display: flex; align-items: center; gap: 0.45rem;
    color: var(--text-secondary); font-size: 0.72rem; cursor: pointer;
    white-space: nowrap;
}
.ohlc-ind-menu label:hover { color: var(--text-primary); }
.ohlc-toolbar .tv-hint { margin-left: auto; }
.ohlc-range { margin-left: 0.15rem; padding-left: 0.35rem; border-left: 1px solid var(--border); }
.ohlc-chart-host {
    position: relative;
    touch-action: none;
    overscroll-behavior: contain;
}
.ohlc-chart-host table,
.ohlc-chart-host canvas {
    touch-action: none;
}
.ohlc-tz-note {
    padding: 0.2rem 0.85rem 0;
    font-size: 0.65rem;
    color: var(--text-muted);
}
.ohlc-nav {
    position: absolute;
    left: 50%;
    bottom: 1.75rem;
    transform: translateX(-50%);
    z-index: 5;
    display: inline-flex;
    gap: 0.2rem;
    padding: 0.28rem 0.35rem;
    background: rgba(15, 20, 28, 0.92);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}
.ohlc-nav button {
    width: 1.7rem;
    height: 1.7rem;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    font-family: inherit;
}
.ohlc-nav button:hover {
    background: rgba(79, 156, 249, 0.2);
    color: var(--text-primary);
}
.tv-symbol { font-family: var(--font-mono); font-weight: 700; color: var(--text-primary); }
.tv-hint { color: var(--text-muted); }
.chart-embed-frame {
    width: 100%;
    border: 0;
    display: block;
    background: var(--chart-bg);
}
.tv-host, .investing-host { padding: 0; overflow: hidden; }
.tv-adv-wrap {
    background: var(--bg-elevated);
    display: flex;
    flex-direction: column;
}
.tv-adv-host {
    width: 100%;
    min-height: 420px;
    background: var(--chart-bg);
}
.tv-adv-host iframe {
    width: 100% !important;
}
.tv-nse-fallback {
    padding: 1rem 1.1rem 1.25rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.45;
}
.tv-nse-fallback strong { color: var(--text-primary); }
.tv-nse-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}
.inv-attribution {
    padding: 0.35rem 0.75rem 0.55rem;
    font-size: 0.6875rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}
.inv-attribution a { color: var(--blue); }
.tv-hint.tv-warn { color: var(--gold); max-width: 16rem; text-align: right; }
.chart-provider-wrap { display: flex; flex-direction: column; }
.chart-provider-tabs {
    display: flex; gap: 0.35rem; padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border); background: var(--bg-elevated);
    flex-wrap: wrap;
}
.chart-tab {
    border: 1px solid var(--border); background: transparent;
    color: var(--text-secondary); font-size: 0.75rem; font-weight: 600;
    padding: 0.35rem 0.7rem; border-radius: var(--radius-sm); cursor: pointer;
}
.chart-tab:hover { border-color: var(--blue); color: var(--text-primary); }
.chart-tab.active {
    background: rgba(79, 156, 249, 0.12); border-color: var(--blue); color: var(--blue);
}
.chart-provider-body { min-height: 200px; }
.path-candle-wrap { background: var(--bg-elevated); }
.path-candle-canvas { width: 100%; display: block; background: var(--bg-card); }

.tv-fallback { padding: 2rem; text-align: center; color: var(--text-secondary); }

.path-panel { display: flex; flex-direction: column; gap: 0.85rem; }
.path-panel.path-loading, .path-panel.path-error {
    padding: 1.25rem; color: var(--text-muted); font-size: 0.875rem;
}
.path-panel-head {
    display: flex; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap;
}
.path-panel-title { font-weight: 700; font-size: 0.9375rem; }
.path-panel-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.15rem; }
.path-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.path-tag {
    font-size: 0.6875rem; padding: 0.15rem 0.45rem;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--bg-elevated); color: var(--text-secondary);
}
.path-tip {
    position: relative;
    cursor: help;
    border-bottom: 1px dotted rgba(255,255,255,0.28);
}
.path-tag.path-tip { border-bottom: none; }
.path-metric.path-tip { border-bottom: none; cursor: help; }
.path-tip-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 0.9rem; height: 0.9rem; margin-left: 0.15rem;
    border-radius: 50%; border: 1px solid var(--border);
    font-size: 0.6rem; font-weight: 700; color: var(--text-muted);
    vertical-align: middle;
}
.path-tip[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    width: max-content;
    max-width: min(280px, 70vw);
    padding: 0.55rem 0.7rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.4;
    text-align: left;
    white-space: normal;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    opacity: 0;
    pointer-events: none;
    z-index: 40;
    transition: opacity 0.12s ease;
}
.path-tip[data-tip]::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: calc(100% + 2px);
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--border);
    opacity: 0;
    pointer-events: none;
    z-index: 41;
}
.path-tip[data-tip]:hover::after,
.path-tip[data-tip]:focus::after,
.path-tip[data-tip]:focus-visible::after,
.path-tip[data-tip]:hover::before,
.path-tip[data-tip]:focus::before,
.path-tip[data-tip]:focus-visible::before { opacity: 1; }
.path-metrics {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.55rem;
}
@media (max-width: 640px) {
    .path-metrics { grid-template-columns: repeat(2, 1fr); }
}
.path-metric {
    padding: 0.55rem 0.65rem; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: var(--bg-elevated);
}
.path-metric-label {
    display: block; font-size: 0.6875rem; color: var(--text-muted); margin-bottom: 0.2rem;
}
.path-metric-val {
    font-family: var(--font-mono); font-weight: 700; font-size: 0.9375rem;
}
.path-metric-val.positive { color: var(--green); }
.path-metric-val.negative { color: var(--red); }
.path-metric-sub { display: block; font-size: 0.6875rem; color: var(--text-muted); margin-top: 0.15rem; }
.path-spark { height: 48px; }
.path-spark-svg { width: 100%; height: 48px; display: block; }
.path-comments { display: flex; flex-direction: column; gap: 0.5rem; }
.path-comment {
    padding: 0.7rem 0.85rem; border-radius: var(--radius-sm);
    border: 1px solid var(--border); border-left-width: 3px;
    font-size: 0.8125rem;
}
.path-comment p { margin: 0.3rem 0 0; color: var(--text-secondary); line-height: 1.45; }
.path-comment.sev-ok { border-left-color: var(--green); }
.path-comment.sev-info { border-left-color: var(--blue); }
.path-comment.sev-warn { border-left-color: var(--gold); }
.path-comment.sev-bad { border-left-color: var(--red); }

.journal-path-actions { margin-top: 1rem; }
.journal-path-slot { margin-top: 0.85rem; }
.journal-path-layout {
    display: grid; grid-template-columns: 1.2fr 1fr; gap: 0.75rem;
}
@media (max-width: 900px) {
    .journal-path-layout { grid-template-columns: 1fr; }
}
.journal-tv-mount, .journal-path-mount {
    border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden;
    background: var(--bg-card);
}
.journal-path-mount { padding: 0.85rem; }
.trade-meta-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem;
}
.trade-meta-grid .meta-label {
    font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.25rem; font-weight: 600;
}
.trade-meta-grid .muted { color: var(--text-muted); font-style: italic; font-size: 0.8125rem; }

.tv-lw-attr {
    text-align: right;
    padding: 2px 8px 4px;
    font-size: 10px;
    color: #4A5568;
    opacity: 0.7;
}
.tv-lw-attr a {
    color: #4F9CF9;
    text-decoration: none;
}

/* ApexCharts theme tweaks */
.apexcharts-tooltip {
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-md) !important;
}
.apexcharts-tooltip-title {
    background: var(--bg-elevated) !important;
    border-bottom-color: var(--border) !important;
}
.apexcharts-canvas { cursor: crosshair; }

/* Theme toggle */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.theme-toggle:hover {
    color: var(--text-primary);
    border-color: var(--border-active);
}
.theme-toggle .icon-sun,
.theme-toggle .icon-moon { display: none; }
html[data-theme="night"] .theme-toggle .icon-sun { display: block; }
html[data-theme="day"] .theme-toggle .icon-moon { display: block; }
.theme-seg {
    display: inline-flex;
    gap: 0.25rem;
    padding: 0.2rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--bg-surface);
}
.theme-seg button {
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}
.theme-seg button.active {
    background: var(--bg-elevated);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* ─── Prep & EOD Checklist ─── */
.cl-header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}
.cl-date-input {
    padding: 0.4rem 0.65rem;
    border-radius: var(--radius-md, 8px);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 0.8125rem;
}
.cl-mode-toggle {
    display: inline-flex;
    padding: 0.2rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    gap: 0.15rem;
}
.cl-mode-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
}
.cl-mode-btn.active {
    background: var(--blue, #4F9CF9);
    color: #fff;
}
.cl-progress-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.cl-progress-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg, 12px);
    padding: 1rem 1.15rem;
}
.cl-progress-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.25rem;
}
.cl-progress-label {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--blue, #4F9CF9);
}
.cl-progress-post .cl-progress-label { color: var(--green, #12D18E); }
.cl-progress-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.cl-progress-pct {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: 0.65rem;
}
.cl-progress-bar {
    height: 6px;
    border-radius: 999px;
    background: var(--bg-surface);
    overflow: hidden;
}
.cl-progress-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--blue, #4F9CF9);
    transition: width 0.25s ease;
}
.cl-progress-post .cl-progress-fill { background: var(--green, #12D18E); }
.cl-columns,
.cl-notes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: start;
}
.cl-add-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--blue, #4F9CF9);
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    font-weight: 600;
}
.cl-accent-green .cl-add-btn { color: var(--green, #12D18E); }
.cl-list-body {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding-top: 0.25rem !important;
}
.cl-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}
.cl-item:hover { background: var(--bg-surface); }
.cl-item.is-done .cl-item-text {
    text-decoration: line-through;
    color: var(--text-muted);
}
.cl-check {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    accent-color: var(--blue, #4F9CF9);
}
.cl-accent-green .cl-check { accent-color: var(--green, #12D18E); }
.cl-item-text {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-primary);
    line-height: 1.35;
}
.cl-tag {
    flex-shrink: 0;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--blue, #4F9CF9) 15%, transparent);
    color: var(--blue, #4F9CF9);
}
.cl-tag-green {
    background: color-mix(in srgb, var(--green, #12D18E) 15%, transparent);
    color: var(--green, #12D18E);
}
.cl-item-del {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
}
.cl-item-del:hover { color: var(--red, #FF5C5C); }
.cl-notes-body {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}
.cl-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.cl-field-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}
.cl-input,
.cl-textarea {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    resize: vertical;
}
.cl-input:focus,
.cl-textarea:focus {
    outline: none;
    border-color: var(--blue, #4F9CF9);
}
.cl-notes-save-row {
    margin-top: 0.75rem;
    text-align: right;
}
.cl-save-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}
@media (max-width: 900px) {
    .cl-progress-row,
    .cl-columns,
    .cl-notes-grid {
        grid-template-columns: 1fr;
    }
}

/* ─── Connect Brokers ─── */
.cb-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: start;
}
.cb-card .chart-card-header {
    align-items: flex-start;
}
.cb-pill {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    background: var(--bg-surface);
    color: var(--text-muted);
    white-space: nowrap;
}
.cb-pill.is-ok {
    background: color-mix(in srgb, var(--green, #12D18E) 18%, transparent);
    color: var(--green, #12D18E);
}
.cb-pill.is-bad {
    background: color-mix(in srgb, var(--red, #FF5C5C) 15%, transparent);
    color: var(--red, #FF5C5C);
}
.cb-pill-muted {
    color: var(--text-muted);
}
.cb-help {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin: 0 0 0.85rem;
    line-height: 1.45;
}
.cb-help code {
    font-size: 0.75rem;
    word-break: break-all;
}
.cb-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.65rem;
}
.cb-sec-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.45;
    margin: 0.75rem 0 0;
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-surface);
}
.cb-card-muted {
    opacity: 0.92;
}
@media (max-width: 900px) {
    .cb-grid { grid-template-columns: 1fr; }
}

/* ─── Mobile Overlay ─── */
#sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: var(--overlay-scrim);
    z-index: 200;
}
#sidebar-overlay.visible { display: block; }
