/* ==========================================================================
   Design System & Variables
   ========================================================================== */
:root {
    /* Color Palette - Premium Institutional Dark Mode */
    --bg-base: #0A0E17;
    --bg-card: #121826;
    --bg-card-hover: #161d2d;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-highlight: rgba(255, 255, 255, 0.15);

    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --text-dark: #cbd5e1;

    --accent-blue: #3B82F6;
    --accent-blue-glow: rgba(59, 130, 246, 0.2);
    --accent-indigo: #6366F1;
    --accent-emerald: #10B981;
    --accent-emerald-glow: rgba(16, 185, 129, 0.15);
    --accent-rose: #F43F5E;
    --accent-rose-glow: rgba(244, 63, 94, 0.15);

    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);

    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --transition-fast: 0.2s ease;
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Base Styles
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    /* Global UI downscale by 20% */
    zoom: 0.8;
}

/* ==========================================================================
   Layout
   ========================================================================== */
.dashboard-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 20px;
    position: fixed;
    height: 100vh;
    z-index: 10;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px 40px;
    max-width: 1400px;
}

/* ==========================================================================
   Sidebar Elements
   ========================================================================== */
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    padding-left: 8px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
    border-radius: 8px;
    box-shadow: var(--shadow-glow);
}

.brand h2 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition-fast);
}

.nav-item:hover {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.03);
}

.nav-item.active {
    color: var(--accent-blue);
    background-color: var(--accent-blue-glow);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.system-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-indicator.live {
    background-color: var(--accent-emerald);
    box-shadow: 0 0 8px var(--accent-emerald);
    animation: pulse-emerald 2s infinite;
}

@keyframes pulse-emerald {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* ==========================================================================
   Header Content
   ========================================================================== */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 32px;
}

.page-title {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.last-updated {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.last-updated span {
    color: var(--accent-emerald);
}

.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: inherit;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-highlight);
}

/* ==========================================================================
   Cards General
   ========================================================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: var(--transition-smooth);
    background-clip: padding-box;
}

.card:hover {
    border-color: var(--border-highlight);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.6);
}

/* ==========================================================================
   KPI Cards Grid
   ========================================================================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.hp-card-main {
    grid-column: 1 / -1;
    padding: 32px 32px !important;
    border-color: var(--border-highlight);
    background: linear-gradient(145deg, var(--bg-card), rgba(255, 255, 255, 0.02));
}

.hp-bar-large {
    height: 20px !important;
    margin: 24px 0 16px 0 !important;
    border-radius: 10px !important;
}

.hp-bar-large .hp-bar-fill,
.hp-bar-large .hp-bar-damage {
    border-radius: 10px 0 0 10px !important;
}

.hp-bar-large .hp-bar-damage {
    border-radius: 0 10px 10px 0 !important;
}

.kpi-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.kpi-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.icon-wrapper {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-wrapper.blue {
    background: var(--accent-blue-glow);
    color: var(--accent-blue);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.icon-wrapper.emerald {
    background: var(--accent-emerald-glow);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.icon-wrapper.rose {
    background: var(--accent-rose-glow);
    color: var(--accent-rose);
    border: 1px solid rgba(244, 63, 94, 0.2);
}

.icon-wrapper.indigo {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-indigo);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.01em;
}

.kpi-trend {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 500;
}

.kpi-trend.positive {
    color: var(--accent-emerald);
}

.kpi-trend.negative {
    color: var(--accent-rose);
}

.kpi-trend.neutral {
    color: var(--text-muted);
}

/* ==========================================================================
   Charts Section
   ========================================================================== */
.charts-section {
    display: grid;
    grid-template-columns: 1fr 2fr;
    /* Equity Curve 1/3, Calendar 2/3 */
    gap: 20px;
}

.bottom-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    /* Yearly Performance 2/3, Exposure 1/3 */
    gap: 20px;
    margin-top: 24px;
}

.chart-card {
    padding: 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
}

.chart-filters {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 2px;
}

.filter-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.filter-btn:hover {
    color: var(--text-main);
}

.filter-btn.active {
    background: var(--bg-card-hover);
    color: var(--text-main);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.chart-wrapper {
    position: relative;
    height: 320px;
    width: 100%;
}

.equity-chart-container .chart-wrapper {
    height: 230px;
    /* Reduced to align with the calendar container height */
}

/* ==========================================================================
   Exposure Section
   ========================================================================== */
.exposure-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.exposure-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.exposure-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.symbol {
    font-weight: 600;
    font-size: 0.95rem;
}

.type {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
}

.type.buy {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-emerald);
}

.type.sell {
    background: rgba(244, 63, 94, 0.1);
    color: var(--accent-rose);
}

.exposure-bar-container {
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
}

.exposure-bar {
    height: 100%;
    border-radius: 3px;
}

.exposure-bar.buy-bar {
    background: var(--accent-emerald);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.exposure-bar.sell-bar {
    background: var(--accent-rose);
    box-shadow: 0 0 8px rgba(244, 63, 94, 0.5);
}

.exposure-value {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: right;
}

/* Margins info */
.margin-info {
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   HP Bar Specifics
   ========================================================================== */
.hp-bar-container {
    height: 12px;
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    overflow: hidden;
    margin: 16px 0 8px 0;
    display: flex;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.hp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #34d399);
    border-radius: 6px 0 0 6px;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.hp-bar-damage {
    height: 100%;
    background: linear-gradient(90deg, #ef4444, #f87171);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Calendar Section Specifics
   ========================================================================== */
.calendar-wrapper {
    margin-top: 16px;
}

.calendar-header-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 8px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

/* Day Container Look & Feel */
.cal-day {
    min-height: 80px;
    background: #1e293b; /* Solid dark Slate background */
    border: 1px solid #475569; /* Solid bright Slate border */
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: var(--transition-fast);
}

.cal-day:hover {
    border-color: #94a3b8; /* Solid bright hover edge */
    background: #334155;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.cal-day.empty {
    background: transparent;
    border: 1px dashed #334155; /* Dashed dark gray outline for empty spaces */
}

.cal-day .d-num {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.cal-day .d-val {
    font-size: 0.85rem;
    font-weight: 600;
    text-align: right;
}

.cal-day.profit .d-val {
    color: var(--accent-emerald);
}

.cal-day.loss .d-val {
    color: var(--accent-rose);
}

/* Yearly Summary */
.yearly-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 8px;
}

.month-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 4px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.month-box.active-month {
    border-color: var(--accent-blue);
    background: var(--accent-blue-glow);
}

.month-box.empty {
    opacity: 0.4;
}

.month-box .m-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.month-box .pos {
    color: var(--accent-emerald);
    font-weight: 600;
    font-size: 0.85rem;
}

.month-box .neg {
    color: var(--accent-rose);
    font-weight: 600;
    font-size: 0.85rem;
}

.margin-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.margin-row .value {
    color: var(--text-main);
    font-weight: 500;
}

.margin-progress {
    height: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    margin-top: 12px;
}

.progress-fill {
    height: 100%;
    background: var(--accent-blue);
    border-radius: 2px;
}

/* ==========================================================================
   Mobile Header
   ========================================================================== */
.mobile-header {
    display: none;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.mobile-header .brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-header .brand h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-dark);
}

.mobile-header .logo-icon {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1024px) {
    .charts-section {
        grid-template-columns: 1fr;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .main-content {
        margin-left: 0;
        padding: 20px;
    }

    .mobile-header {
        display: flex;
    }

    .kpi-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Login Overlay
   ========================================================================== */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 14, 23, 0.95);
    backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.login-card .logo {
    justify-content: center;
    margin-bottom: 24px;
}

.login-form {
    text-align: left;
    margin-top: 24px;
}

.login-form input:focus {
    border-color: var(--accent-blue) !important;
}

.btn-login:hover {
    background: #2563eb !important;
}