:root {
    /* --- Light Theme (Mapped to Design Tokens) --- */
    --bg-deep: var(--ct-bg-main);
    --bg-glass: rgba(255, 255, 255, 0.95);
    /* Custom glass for light mode */
    --bg-glass-heavy: rgba(255, 255, 255, 0.98);

    --glass-border: 1px solid var(--ct-border-color);
    --glass-shine: none;

    --text-main: var(--ct-text-primary);
    --text-muted: var(--ct-text-secondary);
    --text-dim: var(--ct-text-tertiary);

    --surface: var(--ct-bg-surface);
    --surface-hover: var(--ct-bg-surface-elevated);

    /* Semantic Status - Use Tokens where possible */
    --up: var(--ct-danger);
    /* KRW Market Red */
    --down: var(--ct-primary);
    /* KRW Market Blue */
    --neutral: var(--ct-text-tertiary);

    /* Neon/Accents */
    --neon-trend: var(--ct-primary);
    --neon-trend-glow: var(--ct-shadow-neon);
    --neon-pattern: #d946ef;
    /* Keep specific pattern color */
    --neon-pattern-glow: 0 4px 12px rgba(217, 70, 239, 0.3);

    /* Metrics */
    --radius-xl: var(--ct-radius-lg);
    --radius-lg: 16px;
    --radius-md: var(--ct-radius-md);

    /* Layout */
    --header-height: 70px;
    --sidebar-width: 280px;
}

/* Dark Mode Override (Deep Space) */
/* Dark Mode Override (Deep Space) */
[data-theme="dark"] {
    --bg-deep: #050507;
    --bg-glass: rgba(20, 20, 25, 0.7);
    --bg-glass-heavy: rgba(10, 10, 12, 0.85);

    --glass-border: 1px solid rgba(255, 255, 255, 0.08);
    --glass-shine: linear-gradient(145deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0) 100%);

    --text-main: #ffffff;
    --text-muted: #9ca3af;
    --text-dim: #4b5563;

    --surface: #101015;
    --surface-hover: #1a1a20;

    --neon-trend: #00f2ff;
    --neon-trend-glow: 0 0 20px rgba(0, 242, 255, 0.3);

    --neon-pattern: #d946ef;
    --neon-pattern-glow: 0 0 20px rgba(217, 70, 239, 0.3);
}

/* Core Reset & Typography */
body {
    background-color: var(--bg-deep);
    color: var(--text-main);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    margin: 0;
    min-height: 100vh;
}

/* --- Layout Structure (Recovered & Modernized) --- */

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    padding: 24px;
    display: flex;
    flex-direction: column;
    z-index: 1050;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Dark mode sidebar */
/* Dark mode sidebar */
[data-theme="dark"] .sidebar {
    background: var(--ct-bg-surface);
    /* Was rgba(10, 10, 12, 0.9) */
    border-right: 1px solid var(--ct-border-color);
}

.sidebar-brand {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    padding: 0 12px;
    text-decoration: none;
    letter-spacing: -0.03em;
}

.sidebar-brand i {
    color: var(--neon-trend);
    text-shadow: var(--neon-trend-glow);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: var(--text-dim);
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
    margin-bottom: 4px;
}

[data-theme="dark"] .nav-link {
    color: var(--text-muted);
}

.nav-link:hover {
    background-color: rgba(0, 0, 0, 0.04);
    color: var(--text-main);
}

[data-theme="dark"] .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    background-color: rgba(0, 242, 255, 0.1);
    color: var(--neon-trend);
    font-weight: 600;
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.1);
}

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 24px;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
}

/* Mobile Header */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-deep);
    border-bottom: var(--glass-border);
    z-index: 1040;
    padding: 0 20px;
    align-items: center;
    justify-content: space-between;
}

.mobile-header-btn {
    background: none;
    border: none;
    color: var(--ct-text-primary);
    font-size: 1.5rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding-top: 80px;
    }

    .mobile-header {
        display: flex;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1045;
        backdrop-filter: blur(4px);
    }

    .sidebar-overlay.show {
        display: block;
    }
}

/* Typography Enhancements */
.nums {
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

/* --- Ticker Marquee (Restored) --- */
.ticker-wrap {
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    box-sizing: border-box;
    height: 48px;
    display: flex;
    align-items: center;
    background: #ffffff;
    /* Clean white background */
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: 24px;
    border-radius: 12px;
    /* Soft rounding */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .ticker-wrap {
    background: var(--bg-deep);
    border-bottom: var(--glass-border);
}

.ticker {
    display: flex;
    padding-left: 0;
    animation: ticker 40s linear infinite;
}

.ticker__item {
    display: inline-flex;
    align-items: center;
    padding: 0 1.5rem;
    font-size: 0.9rem;
    color: var(--text-dim);
    font-weight: 500;
}

@keyframes ticker {
    0% {
        transform: translate3d(0, 0, 0);
    }

    100% {
        transform: translate3d(-50%, 0, 0);
    }
}

/* --- Glassmorphism 2.0 Components (Adaptive) --- */

/* 
   RESTORATION: "Toss Card" Style for Light Mode 
   - Solid White Background
   - Distinct Shadow
   - 24px Rounded Corners
*/
.glass-panel {
    background: #ffffff;
    border: none;
    border-radius: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    /* Distinct Shadow */

    position: relative;
    overflow: hidden;
    transition: transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);

    /* Reset Glass Effects for Light Mode */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

[data-theme="dark"] .glass-panel {
    background: var(--bg-glass);
    border: var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.glass-panel::after {
    content: none;
}

[data-theme="dark"] .glass-panel::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--glass-shine);
    pointer-events: none;
    z-index: 1;
}

.glass-panel:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] .glass-panel:hover {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

/* Text Utility Overrides for adaptability */
.text-white {
    color: #191f28 !important;
}

[data-theme="dark"] .text-white {
    color: #ffffff !important;
}

.text-real-white {
    color: #ffffff !important;
}

/* --- Reactive Neon Accents --- */
.mode-trend {
    border-top: 4px solid var(--neon-trend);
    /* Thicker for visibility */
}

[data-theme="dark"] .mode-trend {
    border-top: 2px solid var(--neon-trend);
    box-shadow: var(--neon-trend-glow);
}

.mode-pattern {
    border-top: 4px solid var(--neon-pattern);
}

[data-theme="dark"] .mode-pattern {
    border-top: 2px solid var(--neon-pattern);
    box-shadow: var(--neon-pattern-glow);
}

.mode-pattern {
    border-top: 2px solid var(--neon-pattern);
    box-shadow: var(--neon-pattern-glow);
}

/* --- Bento Grid Layout System --- */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: minmax(180px, auto);
    /* Minimum row height */
    gap: 24px;
    padding: 24px;
    max-width: 1600px;
    margin: 0 auto;
}

/* Grid Spans */
.col-span-12 {
    grid-column: span 12;
}

.col-span-8 {
    grid-column: span 8;
}

.col-span-6 {
    grid-column: span 6;
}

.col-span-4 {
    grid-column: span 4;
}

.col-span-3 {
    grid-column: span 3;
}

.row-span-2 {
    grid-row: span 2;
}

/* Responsive Grid (lg = 992px+) - Bootstrap-compatible naming */
@media (min-width: 992px) {
    .col-lg-8 {
        grid-column: span 8;
    }

    .col-lg-4 {
        grid-column: span 4;
    }

    .col-lg-6 {
        grid-column: span 6;
    }

    .col-lg-3 {
        grid-column: span 3;
    }
}

/* Mobile Responsiveness */
@media (max-width: 1024px) {
    .bento-grid {
        display: flex;
        /* Stack on mobile */
        flex-direction: column;
        padding: 16px;
        gap: 16px;
    }

    .desktop-only {
        display: none !important;
    }
}

/* --- Animations --- */
@keyframes pulse-glow {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
        filter: brightness(1.2);
    }
}

.animate-pulse-slow {
    animation: pulse-glow 3s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Skeleton Enhancements */
.skeleton {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.03) 25%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.03) 75%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
    border-radius: 4px;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Native Dialog Polish */
dialog {
    background: transparent;
    border: none;
    padding: 0;
    max-width: 100vw;
    max-height: 100vh;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
}

/* ============================================ */
/* --- Toss Dashboard Layout System --- */
/* ============================================ */

/* Main Dashboard Grid: 2 columns (main:sidebar = 2:1) */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0;
    /* base.html handles main padding */
}

.dashboard-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0;
    /* base.html handles main padding */
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.dashboard-main {
    display: flex;
    flex-direction: column;
}

.dashboard-sidebar {
    display: flex;
    flex-direction: column;
}

.toss-row {
    display: flex;
    gap: 20px;
    width: 100%;
}

.toss-row-2col>.toss-card {
    flex: 1;
    min-width: 0;
}

/* Toss Card Style - Refined for Density */
.toss-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(0, 0, 0, 0.05);
    /* Softer border */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    /* Lighter shadow */
    padding: 20px;
    /* Reduced from 24px for tighter feel */
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.toss-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

.toss-card-title {
    font-size: 0.75rem;
    font-weight: 700;
    /* Bolder for contrast */
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    /* Tighter spacing */
}

/* Thinner Progress Bars */
.progress {
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 99px;
    /* Pill shape */
    height: 6px !important;
    /* Force thin styled bars */
    overflow: hidden;
}

/* Table Density Polish */
.table td,
.table th {
    padding: 10px 12px;
    /* Tighter cell padding */
    font-size: 0.95rem;
}

.table th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* Floating Ticker - Blended Style */
.ticker-wrap {
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    height: 48px;
    display: flex;
    align-items: center;
    background: transparent;
    /* Remove boxy background */
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
    /* Removed shadow for cleaner look */
}

[data-theme="dark"] .ticker-wrap {
    border-color: rgba(255, 255, 255, 0.05);
}

/* Toss Stat Row (Label + Value) */
.toss-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.toss-stat-row:last-child {
    border-bottom: none;
}

/* Toss Stat Box (Mini Card) */
.toss-stat-box {
    background: var(--bg-deep);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
}

/* Toss Dialog */
.toss-dialog {
    background: var(--surface);
    border-radius: var(--radius-xl);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    width: 600px;
    max-width: 90vw;
}

/* Dark Mode Adaptations */
[data-theme="dark"] .toss-card {
    background: var(--bg-glass);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .toss-stat-row {
    border-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .toss-stat-box {
    background: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .toss-dialog {
    background: var(--bg-glass-heavy);
    border-color: rgba(255, 255, 255, 0.1);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .dashboard-container {
        padding: 16px;
        gap: 16px;
    }

    /* Stack grid on mobile */
    .dashboard-grid {
        display: flex;
        flex-direction: column;
        padding: 16px;
        gap: 16px;
    }

    .toss-row {
        flex-direction: column;
    }

    .toss-row-2col>.toss-card {
        flex: none;
        width: 100%;
    }

    .toss-card {
        padding: 20px;
    }
}