:root {
    /* Market Watch World-Class Theme - Institutional Palette */
    --bg-app: #f8fafc;
    --bg-panel: rgba(255, 255, 255, 0.9);
    --bg-sidebar: rgba(255, 255, 255, 0.98);

    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;

    --accent: #2563eb;
    /* Royal Blue */
    --accent-gradient: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    --accent-glow: rgba(37, 99, 235, 0.15);

    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    --border: 1px solid #e2e8f0;
    --glass-border: 1px solid rgba(255, 255, 255, 0.6);

    --radius-sm: 6px;
    --radius: 12px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.05);

    --header-height: 64px;
    --anim-speed: 0.3s;
}

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}

ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

button {
    font-family: inherit;
    cursor: pointer;
}

/* --- ANIMATIONS --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-in {
    animation: fadeInUp var(--anim-speed) ease-out forwards;
    opacity: 0;
}

.delay-1 {
    animation-delay: 0.1s;
}

.delay-2 {
    animation-delay: 0.2s;
}

.delay-3 {
    animation-delay: 0.3s;
}

/* --- LAYOUT --- */
.app-layout {
    display: flex;
    min-height: 100vh;
    max-width: 1920px;
    margin: 0 auto;
}

/* Sidebar Nav */
.sidebar-nav {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: var(--border);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
    z-index: 50;
    box-sizing: border-box;
}

/* Sidebar Context (Right) */
.sidebar-context {
    width: 320px;
    border-left: var(--border);
    padding: 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
    background: var(--bg-sidebar);
    overflow-y: auto;
    box-sizing: border-box;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 3rem 4rem;
    max-width: 100%;
    /* Allow expansion */
    width: 0;
    /* Flex fix */
    box-sizing: border-box;
}

/* Mobile Header */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-bottom: var(--border);
    padding: 0 1.5rem;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
}

.mobile-menu-toggle {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-primary);
}

/* --- COMPONENTS --- */

/* Brand - Matched to market-watch.xyz */
.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 16px;
    color: #0f172a;
    letter-spacing: 0.02em;
    margin-bottom: 2rem;
}

.brand img {
    height: 32px;
    width: 32px;
}

/* Navigation */
.nav-section {
    margin-bottom: 2rem;
}

.nav-title {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    padding-left: 12px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
}

.nav-link:hover {
    background: #f1f5f9;
    color: var(--text-primary);
}

.nav-link.active {
    background: #eff6ff;
    color: var(--accent);
    font-weight: 600;
}

.nav-link i {
    width: 24px;
    margin-right: 10px;
    font-size: 1em;
    text-align: center;
}

/* Cards */
.mw-card {
    background: var(--bg-panel);
    border: var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.mw-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 0.75rem;
}

.mw-card-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

/* Tables - Institutional Style */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    font-size: 0.85rem;
    border: 1px solid #e2e8f0;
}

.data-table th {
    text-align: left;
    padding: 10px 14px;
    background: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid #cbd5e1;
    white-space: nowrap;
}

.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #e2e8f0;
    color: var(--text-primary);
    background: white;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: #f8fafc;
}

/* Typography */
h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0 0 1rem 0;
    line-height: 1.2;
    color: var(--text-primary);
}

h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 3rem 0 1.5rem 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

h2::before {
    content: '';
    display: block;
    width: 4px;
    height: 24px;
    background: var(--accent);
    margin-right: 12px;
    border-radius: 2px;
}

h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
}

p {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    color: var(--text-secondary);
}

.header-meta {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.lead {
    font-size: 1.15rem;
    color: var(--text-secondary);
    max-width: 65ch;
    line-height: 1.6;
}

/* Utilities */
.text-green {
    color: var(--success);
    font-weight: 600;
}

.text-red {
    color: var(--danger);
    font-weight: 600;
}

.text-blue {
    color: var(--accent);
    font-weight: 600;
}

.text-warning {
    color: var(--warning);
    font-weight: 600;
}

.text-muted {
    color: var(--text-muted);
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.badge {
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    background: #f1f5f9;
    color: var(--text-secondary);
}

.badge-blue {
    background: #eff6ff;
    color: var(--accent);
}

/* Level Selector */
.level-selector {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 8px;
    margin-top: auto;
}

.level-btn {
    flex: 1;
    text-align: center;
    padding: 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
}

.level-btn:hover {
    color: var(--text-primary);
}

.level-btn.active {
    background: white;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* --- RESPONSIVE --- */
@media (max-width: 1200px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar-nav {
        display: none;
    }

    /* Handled by mobile header toggle usually */
    .sidebar-context {
        width: 100%;
        height: auto;
        position: static;
        border-left: none;
        border-top: var(--border);
        padding: 2rem;
        order: 3;
    }

    .main-content {
        width: 100%;
        padding: 2rem 1.5rem;
    }
}

@media (max-width: 900px) {
    .app-layout {
        padding-top: var(--header-height);
    }

    .mobile-header {
        display: flex;
    }

    .sidebar-nav {
        display: flex;
        position: fixed;
        left: -100%;
        top: var(--header-height);
        bottom: 0;
        width: 100%;
        height: auto;
        transition: left 0.3s ease;
        border-right: none;
        background: white;
        padding-top: 1rem;
    }

    .sidebar-nav.open {
        left: 0;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.25rem;
    }
}