/* ============================================================
   WHALE TRACKER - Modern Design System
   ============================================================ */

/* ==================== DARK THEME (Default) ==================== */
:root {
    /* Backgrounds */
    --bg-dark: #0f172a;
    --bg-panel: #1e293b;
    --bg-hover: #334155;
    --bg-elevated: #1e293b;
    
    /* Text Colors */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-disabled: #64748b;
    
    /* Brand Colors */
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.4);
    --accent-color: #10b981;
    --accent-hover: #059669;
    --accent-glow: rgba(16, 185, 129, 0.4);
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --danger-glow: rgba(239, 68, 68, 0.4);
    --warning-color: #f59e0b;
    --warning-hover: #d97706;
    --warning-glow: rgba(245, 158, 11, 0.4);
    
    /* Category Colors */
    --cat-main: #60a5fa;
    --cat-satellite: #fbbf24;
    --cat-sharing: #94a3b8;
    --tag-bg: rgba(71, 85, 105, 0.4);
    
    /* Borders & Shadows */
    --border-color: #334155;
    --border-light: rgba(51, 65, 85, 0.5);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-glow-primary: 0 0 20px rgba(59, 130, 246, 0.3);
    --shadow-glow-accent: 0 0 20px rgba(16, 185, 129, 0.3);
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;
}

/* ==================== LIGHT THEME ==================== */
body[data-theme="light"] {
    --bg-dark: #f1f5f9;
    --bg-panel: #ffffff;
    --bg-hover: #e2e8f0;
    --bg-elevated: #ffffff;

    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-disabled: #94a3b8;

    --border-color: #e2e8f0;
    --border-light: rgba(226, 232, 240, 0.8);

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.15);

    --cat-main: #2563eb;
    --cat-satellite: #d97706;
    --cat-sharing: #64748b;
    --tag-bg: rgba(0, 0, 0, 0.04);
}

/* Light mode overrides for buttons with low contrast */
body[data-theme="light"] .btn-help {
    color: #2563eb;
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.2);
}
body[data-theme="light"] .btn-export {
    color: #059669;
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
}
body[data-theme="light"] #mobileCloseActions {
    color: var(--text-main);
}


/* Light mode scrollbar - higher contrast */
body[data-theme="light"] ::-webkit-scrollbar-track {
    background: #e2e8f0;
}

body[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: #94a3b8;
}

body[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* ==================== GLOBAL STYLES ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

*::selection {
    background: var(--primary-color);
    color: white;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-display: swap;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ==================== LAYOUT ==================== */
.app-container {
    display: flex;
    height: 100%;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: 200px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.brand {
    padding: 24px 28px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--border-color);
}

.brand-icon {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px var(--primary-glow);
    transition: all var(--transition-base);
}

.brand-icon svg {
    width: 26px;
    height: 26px;
    stroke: currentColor;
}

.brand:hover .brand-icon {
    box-shadow: 0 6px 20px var(--primary-glow);
    transform: translateY(-2px) scale(1.05);
}

.brand h1 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.nav-menu {
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-grow: 1;
}

.nav-item {
    background: transparent;
    border: none;
    color: var(--text-muted);
    text-align: left;
    padding: 11px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: var(--primary-color);
    transform: scaleY(0);
    transition: transform var(--transition-base);
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-main);
    transform: translateX(6px);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.12) 0%, transparent 100%);
    color: var(--primary-color);
    font-weight: 600;
}

.nav-item.active::before {
    transform: scaleY(1);
}

.sidebar-footer {
    padding: 20px;
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-dark);
    margin-left: 200px;
    width: calc(100% - 200px);
}

.top-header {
    height: 68px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-panel);
    backdrop-filter: blur(10px);
}

.search-module {
    position: relative;
    display: flex;
    align-items: center;
}

.search-module input {
    width: 400px;
    padding: 10px 40px 10px 16px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: var(--bg-dark);
    color: var(--text-main);
    font-size: 13px;
    outline: none;
    transition: all var(--transition-base);
}

.search-module input::placeholder {
    color: var(--text-muted);
}

.search-module input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: var(--bg-panel);
}

.search-clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition-base);
}

.search-clear-btn:hover {
    background: var(--bg-hover);
    color: var(--danger-color);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.period-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-dark);
}

.period-selector-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 700;
    margin-right: 4px;
}

.period-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 7px 12px;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    transition: all var(--transition-base);
}

.period-chip:hover {
    color: var(--text-main);
    border-color: var(--primary-color);
}

.period-chip.active {
    background: rgba(59, 130, 246, 0.12);
    color: var(--primary-color);
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.15);
}

.period-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.dataset-mode-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 14px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(245, 158, 11, 0.25);
    background: rgba(245, 158, 11, 0.08);
    color: var(--warning-color);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

/* ==================== BUTTONS ==================== */
.btn-help {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(59, 130, 246, 0.08) 100%);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #60a5fa;
    padding: 9px 16px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-base);
    height: 38px;
}

.btn-help:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.25) 0%, rgba(59, 130, 246, 0.15) 100%);
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 4px 12px var(--primary-glow);
    transform: translateY(-1px);
}

.btn-export {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(16, 185, 129, 0.08) 100%);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
    padding: 9px 16px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-base);
    height: 38px;
}

.btn-export:hover {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.25) 0%, rgba(16, 185, 129, 0.15) 100%);
    border-color: var(--accent-color);
    color: var(--accent-color);
    box-shadow: 0 4px 12px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-analyze {
    background: linear-gradient(135deg, var(--primary-color) 0%, #2563eb 100%);
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-analyze:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 6px 15px rgba(37, 99, 235, 0.4);
    transform: translateY(-1px);
}

.btn-analyze:active {
    transform: translateY(0);
}

.page-btn {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 7px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all var(--transition-base);
}

.page-btn:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-main);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px var(--primary-glow);
}

/* ==================== FILTER CONTROLS ==================== */
.filter-toolbar {
    background: var(--bg-panel);
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 18px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.filter-label {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.filter-select {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    min-width: 130px;
    transition: all var(--transition-base);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 36px;
}

.filter-select:hover {
    border-color: var(--text-muted);
}

.filter-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ==================== CONTENT BODY ==================== */
@keyframes fadeInSlideUp {
    from { 
        opacity: 0; 
        transform: translateY(12px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.content-body {
    padding: 24px 32px;
    overflow-y: auto;
    flex-grow: 1;
    animation: fadeInSlideUp 0.35s ease-out forwards;
}

/* ==================== KPI GRID ==================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-box {
    background: var(--bg-panel);
    padding: 22px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-slow);
    position: relative;
    overflow: hidden;
}

.kpi-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), transparent);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.kpi-box:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-xl), var(--shadow-glow-primary);
    border-color: rgba(59, 130, 246, 0.4);
}

.kpi-box:hover::before {
    opacity: 1;
}

.kpi-title {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.kpi-box h2 {
    font-size: 34px;
    margin-top: 10px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

/* ==================== DATA PANELS ==================== */
.data-panel {
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.panel-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-elevated);
}

.panel-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

.panel-header p {
    color: var(--text-muted);
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.5;
}

/* ==================== CARDS ==================== */
.group-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 14px;
    overflow: hidden;
    transition: all var(--transition-slow);
    position: relative;
}

.group-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    pointer-events: none;
    transition: all var(--transition-base);
}

.group-card:hover {
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.group-card:hover::before {
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: inset 0 0 20px rgba(59, 130, 246, 0.05);
}

.group-card.open {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg), var(--shadow-glow-primary);
}

.group-card.open::before {
    border-color: var(--primary-color);
    box-shadow: inset 0 0 30px rgba(59, 130, 246, 0.08);
}

.card-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.06);
    transition: background var(--transition-base);
}

.card-header:hover {
    background: rgba(255, 255, 255, 0.03);
}

.card-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.card-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.chevron {
    width: 18px;
    height: 18px;
    transition: transform var(--transition-base);
    color: var(--text-muted);
}

.group-card.open .chevron {
    transform: rotate(180deg);
    color: var(--primary-color);
}

.card-body {
    display: none;
    border-top: 1px solid var(--border-color);
    overflow-x: auto;
}

.group-card.open .card-body {
    display: block;
    animation: slideDown 0.25s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card-stats {
    display: flex;
    gap: 24px;
    padding: 16px 20px;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.stat-item {
    font-size: 11px;
    color: var(--text-muted);
}

.stat-item span {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    margin-top: 4px;
}

/* ==================== TABLES ==================== */
.card-table {
    width: 100%;
    border-collapse: collapse;
}

.card-table th,
.card-table td {
    padding: 12px 18px;
    font-size: 12px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.card-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(0, 0, 0, 0.08);
}

.card-table tr {
    transition: all var(--transition-base);
}

.card-table tr:hover {
    background: rgba(59, 130, 246, 0.04);
}

.card-table tr:last-child td {
    border-bottom: none;
}

/* ==================== BADGES & TAGS ==================== */
.badge-ticker {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    padding: 4px 9px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.02em;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
    transition: all var(--transition-base);
}

.badge-ticker:hover {
    box-shadow: 0 4px 10px var(--primary-glow);
    transform: translateY(-1px);
}

.type-tag {
    display: inline-block;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    background: var(--tag-bg);
    border: 1px solid var(--border-color);
    font-weight: 500;
    color: var(--text-main);
    transition: all var(--transition-base);
    text-align: center;
}

.type-tag.cp {
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.3);
}

.type-tag.id {
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.3);
}

.entity-name {
    font-weight: 600;
    color: var(--text-main);
    transition: color var(--transition-base);
}

.entity-name:hover {
    color: var(--primary-color);
}

.issuer-name {
    color: var(--text-muted);
    font-size: 12px;
    max-width: 240px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
}

/* ==================== PROGRESS BARS ==================== */
.progress-container {
    width: 100px;
    height: 6px;
    background: var(--bg-dark);
    border-radius: var(--radius-full);
    display: inline-block;
    margin-left: 8px;
    overflow: hidden;
    vertical-align: middle;
    border: 1px solid var(--border-color);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color) 0%, #34d399 100%);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

/* ==================== DEMOGRAPHICS BAR ==================== */
.demo-bar-container {
    display: flex;
    height: 7px;
    width: 140px;
    border-radius: var(--radius-full);
    overflow: hidden;
    background: var(--bg-dark);
    margin-top: 8px;
    border: 1px solid var(--border-color);
}

.demo-bar-segment {
    height: 100%;
    transition: width var(--transition-slow);
}

/* ==================== PORTFOLIO DONUT ==================== */
.portfolio-viz {
    display: flex;
    align-items: center;
    gap: 14px;
}

.mini-donut {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.mini-donut::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    background: var(--bg-dark);
    border-radius: 50%;
}

.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.donut-legend-item {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 7px;
}

.donut-legend-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ==================== CHARTS ==================== */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.chart-container {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    height: 360px;
    display: flex;
    flex-direction: column;
    transition: all var(--transition-slow);
}

.chart-container:hover {
    transform: translateY(-3px);
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: var(--shadow-lg);
}

.chart-container h3 {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 14px;
    text-align: center;
    font-weight: 600;
    flex-shrink: 0;
}

.chart-container canvas {
    flex-grow: 1;
    max-height: 100%;
}

.chart-container[style*="grid-column"] {
    height: 420px;
}

/* ==================== MODAL ==================== */
@keyframes backdropFade {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(8px);
    }
}

@keyframes modalScaleIn {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(15px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: backdropFade 0.3s ease-out forwards;
}

.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    height: 85%;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: modalScaleIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-elevated);
}

.modal-header h3 {
    font-size: 15px;
    color: var(--primary-color);
    font-weight: 700;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
}

.modal-close:hover {
    color: var(--danger-color);
    background: rgba(239, 68, 68, 0.1);
}

.modal-body {
    flex-grow: 1;
    position: relative;
    background: var(--bg-dark);
}

.graph-tooltip {
    position: absolute;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    pointer-events: none;
    font-size: 12px;
    color: var(--text-main);
    z-index: 1100;
    box-shadow: var(--shadow-xl);
}

/* ==================== THEME TOGGLE ==================== */
.theme-fab {
    position: fixed;
    bottom: 26px;
    right: 26px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px var(--primary-glow);
    cursor: pointer;
    border: none;
    z-index: 100;
    transition: all var(--transition-base);
}

.theme-fab:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 8px 28px var(--primary-glow);
}

.theme-fab:active {
    transform: scale(0.95);
}

/* ==================== SAWERIA BUTTON ==================== */
.saweria-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #faae2b 0%, #fbbd5c 100%);
    color: #000 !important;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 14px;
    transition: all var(--transition-base);
    width: 100%;
    box-shadow: 0 4px 12px rgba(250, 174, 43, 0.3);
}

.saweria-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(250, 174, 43, 0.4);
}

.saweria-btn svg {
    stroke: #000;
}

/* ==================== ECOSYSTEM INFO BOX ==================== */
.info-box {
    background: rgba(59, 130, 246, 0.08);
    border-left: 3px solid var(--primary-color);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 24px;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1400px) {
    .kpi-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1200px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
}



@media (max-width: 768px) {
    html, body {
        height: auto;
        overflow: auto;
    }
    
    .app-container {
        flex-direction: column;
        min-height: 100vh;
    }

    .sidebar {
        width: 100%;
        height: 60px;
        position: fixed;
        bottom: 0;
        top: auto;
        left: 0;
        z-index: 1000;
        border-right: none;
        border-top: 1px solid var(--border-color);
        background: var(--bg-panel);
        padding: 0;
        display: flex;
        flex-direction: row;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
    }

    .brand { display: none; }

    .nav-menu {
        flex-direction: row;
        width: 100%;
        justify-content: space-around;
        align-items: center;
        padding: 0 4px;
        margin: 0;
        gap: 0;
        overflow: visible;
        background: transparent;
        border: none;
    }

    .nav-item {
        flex-direction: column;
        padding: 8px 4px;
        font-size: 10px;
        text-align: center;
        gap: 4px;
        border-radius: 8px;
        background: transparent;
        border: none;
        color: var(--text-muted);
        white-space: nowrap;
        width: 20%;
    }

    .nav-item svg { width: 20px; height: 20px; margin: 0 auto; }
    .nav-item::before { display: none; }

    .nav-item.active {
        color: var(--primary-color);
        background: transparent;
        font-weight: 700;
    }
    
    .nav-item.active svg { stroke-width: 2.5; }

    .sidebar-footer { display: none; }

    .main-content {
        margin-left: 0;
        width: 100%;
        height: auto;
        min-height: 100vh;
        overflow: visible;
        padding-bottom: 80px;
    }

    .top-header {
        position: sticky;
        top: 0;
        z-index: 101;
        flex-direction: column;
        padding: 12px 16px;
        height: auto;
        gap: 12px;
        align-items: stretch;
        background: var(--bg-panel);
        backdrop-filter: blur(8px);
    }

    .header-actions {
        justify-content: space-between;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .period-selector {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .dataset-mode-badge {
        width: 100%;
        justify-content: center;
    }

    .btn-export { padding: 6px 10px; font-size: 11px; }

    .content-body {
        padding: 16px;
        overflow-y: visible;
    }

    .kpi-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .kpi-box { padding: 16px; }
    .kpi-box h2 { font-size: 22px; }
    
    .kpi-box:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }

    .charts-grid { grid-template-columns: 1fr; gap: 16px; }
    .chart-container { height: 300px; padding: 12px; }
    .chart-container[style*="grid-column"] { grid-column: span 1 !important; height: 350px !important; }

    .filter-toolbar {
        position: relative;
        top: 0;
        padding: 12px 16px;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 12px;
        scrollbar-width: none;
    }
    .filter-toolbar::-webkit-scrollbar { display: none; }
    
    .filter-group {
        flex-direction: column;
        width: auto;
        min-width: 120px;
        flex-shrink: 0;
        align-items: flex-start;
    }
    .filter-select { width: 100%; min-width: unset; }

    .sector-intel-wrapper {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 14px 16px;
    }
    
    .card-header-left {
        width: 100%;
        flex-wrap: wrap;
        gap: 10px;
    }

    .card-header-left > div {
        flex: 1 1 100%;
    }

    .card-header-right {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 8px;
    }

    .issuer-name {
        max-width: 100%;
        white-space: normal;
        display: block;
        margin-top: 4px;
        margin-bottom: 8px;
    }

    .card-table { display: block; width: 100%; }
    .card-table thead { display: none; }
    .card-table tbody { display: block; width: 100%; }
    
    .card-table tr {
        display: flex;
        flex-direction: column;
        gap: 6px;
        padding: 14px;
        background: var(--bg-dark);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-sm);
        margin-bottom: 10px;
        position: relative;
    }
    
    .card-table td {
        padding: 0;
        border: none;
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 6px;
        font-size: 12px;
        color: var(--text-muted);
    }
    
    /* Let the entity name be prominent (usually column 1 or 2) */
    .card-table td:nth-child(1),
    .card-table td:nth-child(2) {
        color: var(--text-main);
    }
    
    /* Make the last column (always percentage/holding) stand out */
    .card-table td:last-child {
        width: 100%;
        justify-content: space-between;
        background: rgba(0,0,0,0.1);
        padding: 8px;
        border-radius: 6px;
        margin-top: 4px;
        color: var(--text-main);
        font-weight: 600;
    }

    .modal-content {
        width: 100%;
        height: 100%;
        border-radius: 0;
        max-width: none;
        max-height: none;
    }
    
    .modal-header { position: sticky; top: 0; z-index: 10; background: var(--bg-panel); }
    
    /* Fix theme fab overlapping the bottom nav */
    .theme-fab { bottom: 100px; right: 16px; width: 44px; height: 44px; }
}



@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
}
/* ==================== NETWORK ANIMATION ==================== */
.network-link-pulse {
    stroke-dasharray: 6 50;
    stroke-linecap: round;
    animation: flowPulse 1s linear infinite;
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.4));
}

@keyframes flowPulse {
    from {
        stroke-dashoffset: 56;
    }
    to {
        stroke-dashoffset: 0;
    }
}

/* ==================== COMPARE FEATURE ==================== */
.compare-checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid var(--text-disabled); /* Gunakan warna yang lebih kontras dari border biasa */
    border-radius: 6px;
    cursor: pointer;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    background: rgba(0, 0, 0, 0.1);
}

body[data-theme="light"] .compare-checkbox {
    border-color: #b1bccd; /* Warna yang lebih gelap untuk light mode */
    background: #ffffff;
}

body[data-theme="light"] .compare-checkbox.checked {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.main-content.compare-mode .compare-checkbox {
    display: flex; /* Show only in compare mode */
}

.compare-checkbox.checked {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.compare-checkbox svg {
    width: 14px;
    height: 14px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.compare-checkbox.checked svg {
    opacity: 1;
}

.group-card.compare-selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px var(--primary-color), var(--shadow-glow-primary);
}

.compare-banner {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xl);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    z-index: 1000;
    animation: slideUpCenter 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(8px);
}

@keyframes slideUpCenter {
    from { transform: translate(-50%, 100px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

.compare-banner-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.compare-tags-container {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.compare-tag {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.compare-tag span {
    cursor: pointer;
    opacity: 0.6;
    font-size: 14px;
    line-height: 1;
}

.compare-tag span:hover {
    opacity: 1;
}

.compare-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 9px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.compare-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

@keyframes slideUp {
    from { transform: translateY(100px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.compare-card {
    transition: transform 0.2s;
}

.compare-card:hover {
    transform: translateY(-2px);
}

/* Compare modal - horizontal scroll for cards container */
#compareColsContainer {
    overflow-x: auto;
    padding-bottom: 8px;
}

/* Compare modal - overlap section */
#compareOverlapContainer {
    width: 100%;
    min-width: 0;
}

.compare-overlap-section {
    margin-top: 32px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    width: 100%;
}

.compare-section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 14px;
    display: block;
}

.compare-overlap-table {
    width: 100%;
    border-collapse: collapse;
}

.compare-overlap-table th, 
.compare-overlap-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    text-align: left;
}

.compare-overlap-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(0,0,0,0.1);
}

.compare-overlap-table tr:hover {
    background: rgba(255,255,255,0.02);
}

.compare-overlap-table td.pct-cell {
    font-weight: 600;
    color: var(--primary-color);
}

/* Sector Intelligence Cards */
.sector-intel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.sector-intel-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.sector-intel-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg), var(--shadow-glow-primary);
    background: var(--bg-elevated);
}

.sector-intel-card .card-rank-badge {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary-color);
    padding: 4px 10px;
    border-radius: var(--radius-md);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.sector-intel-card .stat-box {
    background: var(--bg-dark);
    padding: 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    transition: all var(--transition-base);
}

.sector-intel-card:hover .stat-box {
    border-color: var(--border-color);
    background: var(--bg-panel);
}

.sector-intel-card .stat-label {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
    font-weight: 600;
}

.sector-intel-card .stat-value {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.sector-intel-card .progress-track {
    height: 6px;
    background: var(--bg-dark);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-top: 6px;
    border: 1px solid var(--border-light);
}

.sector-intel-card .progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--warning-color), #fbbf24);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

body[data-theme="light"] .sector-intel-card {
    background: #ffffff;
    border-color: #e2e8f0;
}

body[data-theme="light"] .sector-intel-card .stat-box {
    background: #f8fafc;
    border-color: #f1f5f9;
}

.sector-intel-card:hover {
    background: var(--bg-elevated);
    border-color: var(--primary-color);
    box-shadow: 0 10px 25px -5px rgba(59, 130, 246, 0.15);
}

.delta-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    border: 1px solid transparent;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.delta-chip.positive {
    color: var(--accent-color);
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.2);
}

.delta-chip.negative {
    color: var(--danger-color);
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.2);
}

.delta-chip.neutral {
    color: var(--text-muted);
    background: rgba(148, 163, 184, 0.1);
    border-color: rgba(148, 163, 184, 0.18);
}

.compare-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 9px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid transparent;
    white-space: nowrap;
}

.compare-status-badge.new {
    color: var(--accent-color);
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.2);
}

.compare-status-badge.removed {
    color: var(--danger-color);
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.2);
}

.compare-status-badge.increased {
    color: #34d399;
    background: rgba(52, 211, 153, 0.12);
    border-color: rgba(52, 211, 153, 0.2);
}

.compare-status-badge.decreased {
    color: #fca5a5;
    background: rgba(252, 165, 165, 0.12);
    border-color: rgba(252, 165, 165, 0.2);
}

.compare-status-badge.scripless_shift,
.compare-status-badge.script_shift,
.compare-status-badge.rebalanced {
    color: var(--warning-color);
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.2);
}

.compare-status-badge.unchanged {
    color: var(--text-muted);
    background: rgba(148, 163, 184, 0.1);
    border-color: rgba(148, 163, 184, 0.18);
}

/* KPI Item Highlighting */
.kpi-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    transition: all var(--transition-base);
    cursor: pointer;
    border-radius: var(--radius-sm);
    margin: 0 -4px;
}

.kpi-item:hover {
    background: var(--bg-hover);
    transform: translateX(4px);
    border-color: var(--primary-color);
}

.kpi-item:last-child {
    border-bottom: none;
}

body[data-theme="light"] .kpi-item:hover {
    background: rgba(59, 130, 246, 0.05);
}

/* Balance Post Redesign */
.balance-post-shell {
    background:
        radial-gradient(circle at top right, rgba(59, 130, 246, 0.12), transparent 28%),
        radial-gradient(circle at top left, rgba(245, 158, 11, 0.08), transparent 24%),
        var(--bg-panel);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: relative;
    overflow: hidden;
}

.balance-post-shell::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.015), transparent 35%),
        linear-gradient(0deg, rgba(15, 23, 42, 0.16), transparent 32%);
    pointer-events: none;
}

.balance-post-hero {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    position: relative;
    z-index: 1;
}

.balance-post-kicker {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: var(--radius-full);
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.22);
    color: var(--primary-color);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 12px;
}

.balance-post-hero h2 {
    font-size: 28px;
    color: var(--text-main);
    font-weight: 800;
    letter-spacing: -0.03em;
}

.balance-post-hero p {
    color: var(--text-muted);
    margin-top: 8px;
    max-width: 760px;
    line-height: 1.6;
}

.balance-post-story {
    margin-top: 16px;
    display: inline-flex;
    max-width: 760px;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.35);
    border: 1px solid rgba(148, 163, 184, 0.14);
    color: var(--text-main);
    font-size: 12px;
    line-height: 1.6;
}

.balance-post-context {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.balance-context-pill {
    min-width: 170px;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.16);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.balance-context-label {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.balance-context-pill strong {
    color: var(--text-main);
    font-size: 14px;
    font-weight: 800;
}

.balance-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    position: relative;
    z-index: 1;
}

.balance-summary-card {
    padding: 18px 18px 16px;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 50%),
        rgba(15, 23, 42, 0.48);
    box-shadow: var(--shadow-md);
    min-height: 116px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
}

.balance-summary-card-local {
    border-color: rgba(59, 130, 246, 0.28);
}

.balance-summary-card-foreign {
    border-color: rgba(245, 158, 11, 0.28);
}

.balance-summary-label {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.balance-summary-value {
    color: var(--text-main);
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.balance-summary-meta {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
}

.balance-top-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    position: relative;
    z-index: 1;
}

.balance-rank-card {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 42%),
        var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 18px;
    box-shadow: var(--shadow-lg);
}

.balance-rank-card-local {
    border-top: 3px solid rgba(59, 130, 246, 0.9);
}

.balance-rank-card-foreign {
    border-top: 3px solid rgba(245, 158, 11, 0.9);
}

.balance-rank-card__header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    color: var(--text-main);
    font-weight: 800;
    letter-spacing: -0.02em;
}

.balance-rank-card__header p {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.55;
}

.balance-rank-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.balance-rank-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
    transition: all var(--transition-base);
}

.balance-rank-item:hover {
    transform: translateY(-2px);
    border-color: rgba(59, 130, 246, 0.35);
    background: rgba(59, 130, 246, 0.06);
}

.balance-rank-main {
    display: flex;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.balance-rank-number {
    width: 28px;
    height: 28px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(148, 163, 184, 0.12);
    color: var(--text-main);
    font-size: 11px;
    font-weight: 800;
    flex-shrink: 0;
}

.balance-rank-copy {
    min-width: 0;
    flex: 1;
}

.balance-rank-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.balance-rank-ticker {
    color: var(--text-main);
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.balance-rank-company {
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.balance-rank-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.balance-rank-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(148, 163, 184, 0.15);
    background: rgba(148, 163, 184, 0.08);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.balance-rank-chip.is-local {
    color: var(--primary-color);
    border-color: rgba(59, 130, 246, 0.16);
    background: rgba(59, 130, 246, 0.1);
}

.balance-rank-chip.is-foreign {
    color: var(--warning-color);
    border-color: rgba(245, 158, 11, 0.18);
    background: rgba(245, 158, 11, 0.1);
}

.balance-rank-bar {
    height: 7px;
    border-radius: var(--radius-full);
    margin-top: 10px;
    overflow: hidden;
    background: rgba(148, 163, 184, 0.12);
}

.balance-rank-bar span {
    display: block;
    height: 100%;
    border-radius: var(--radius-full);
}

.balance-rank-value {
    min-width: 92px;
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.balance-rank-value strong {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.03em;
    font-family: 'JetBrains Mono', monospace;
}

.balance-rank-value span {
    font-size: 11px;
    color: var(--text-muted);
}

.balance-filter-toolbar {
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    background: var(--bg-panel);
    padding-top: 20px;
    padding-bottom: 16px;
}

.balance-accordion-header {
    display: grid;
    grid-template-columns: 2.7fr 1fr 1.35fr 1.35fr;
    gap: 16px;
    padding: 16px 24px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-bottom: 2px solid var(--primary-color);
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-main);
    font-weight: 800;
    letter-spacing: 0.08em;
    border-radius: 12px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.balance-stock-card {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 42%),
        var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.balance-stock-card__header {
    display: grid;
    grid-template-columns: 2.7fr 1fr 1.35fr 1.35fr;
    gap: 16px;
    padding: 20px 24px;
    align-items: center;
    border: none;
}

.balance-stock-card__identity {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-width: 0;
}

.balance-stock-card__copy {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.balance-stock-card__badges {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.balance-stock-card__company {
    font-size: 14px;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.25;
    text-transform: uppercase;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.balance-stock-card__window {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.balance-market-context {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.balance-market-range {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
}

.balance-flow-summary {
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.balance-flow-summary--local {
    border-color: rgba(59, 130, 246, 0.18);
    background: rgba(59, 130, 246, 0.06);
}

.balance-flow-summary--foreign {
    border-color: rgba(245, 158, 11, 0.2);
    background: rgba(245, 158, 11, 0.06);
}

.balance-flow-tag {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid transparent;
}

.balance-flow-tag--local {
    color: var(--primary-color);
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.2);
}

.balance-flow-tag--foreign {
    color: var(--warning-color);
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.22);
}

.balance-flow-value {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.03em;
    font-family: 'JetBrains Mono', monospace;
}

.balance-flow-meta {
    font-size: 11px;
    color: var(--text-main);
    font-weight: 700;
}

.balance-flow-subtext {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.45;
}

.balance-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border: 1px solid transparent;
}

.balance-chip.positive {
    color: var(--accent-color);
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.2);
}

.balance-chip.negative {
    color: var(--danger-color);
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.2);
}

.balance-chip.neutral {
    color: var(--text-muted);
    background: rgba(148, 163, 184, 0.1);
    border-color: rgba(148, 163, 184, 0.18);
}

body[data-theme="light"] .balance-post-shell {
    background:
        radial-gradient(circle at top right, rgba(59, 130, 246, 0.10), transparent 26%),
        radial-gradient(circle at top left, rgba(245, 158, 11, 0.10), transparent 22%),
        linear-gradient(180deg, rgba(248, 250, 252, 0.98), rgba(255, 255, 255, 1));
    border-color: rgba(226, 232, 240, 0.95);
}

body[data-theme="light"] .balance-post-shell::after {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.42), transparent 42%),
        linear-gradient(0deg, rgba(148, 163, 184, 0.08), transparent 38%);
}

body[data-theme="light"] .balance-post-kicker {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.18);
}

body[data-theme="light"] .balance-post-story {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(148, 163, 184, 0.22);
    box-shadow: 0 14px 30px -24px rgba(15, 23, 42, 0.26);
}

body[data-theme="light"] .balance-context-pill {
    background: rgba(255, 255, 255, 0.94);
    border-color: rgba(148, 163, 184, 0.24);
    box-shadow: 0 14px 28px -24px rgba(15, 23, 42, 0.18);
}

body[data-theme="light"] .balance-summary-card {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.98));
    border-color: rgba(148, 163, 184, 0.22);
    box-shadow: 0 20px 36px -30px rgba(15, 23, 42, 0.26);
}

body[data-theme="light"] .balance-summary-card-local {
    background:
        linear-gradient(180deg, rgba(59, 130, 246, 0.08), rgba(255, 255, 255, 0.98) 55%);
    border-color: rgba(59, 130, 246, 0.24);
}

body[data-theme="light"] .balance-summary-card-foreign {
    background:
        linear-gradient(180deg, rgba(245, 158, 11, 0.10), rgba(255, 255, 255, 0.98) 55%);
    border-color: rgba(245, 158, 11, 0.24);
}

body[data-theme="light"] .balance-rank-card {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.98));
    border-color: rgba(148, 163, 184, 0.2);
    box-shadow: 0 18px 34px -28px rgba(15, 23, 42, 0.24);
}

body[data-theme="light"] .balance-rank-item {
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(148, 163, 184, 0.18);
}

body[data-theme="light"] .balance-rank-item:hover {
    background: rgba(59, 130, 246, 0.05);
    border-color: rgba(59, 130, 246, 0.24);
}

body[data-theme="light"] .balance-rank-number {
    background: #e2e8f0;
    color: #334155;
}

body[data-theme="light"] .balance-rank-chip {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #475569;
}

body[data-theme="light"] .balance-rank-bar {
    background: #e2e8f0;
}

body[data-theme="light"] .balance-stock-card {
    background:
        linear-gradient(180deg, rgba(59, 130, 246, 0.02), rgba(255, 255, 255, 1));
    box-shadow: 0 18px 30px -28px rgba(15, 23, 42, 0.22);
}

body[data-theme="light"] .balance-flow-summary {
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(148, 163, 184, 0.18);
}

body[data-theme="light"] .balance-flow-summary--local {
    background: rgba(59, 130, 246, 0.06);
}

body[data-theme="light"] .balance-flow-summary--foreign {
    background: rgba(245, 158, 11, 0.08);
}

body[data-theme="light"] .balance-chip.neutral {
    color: #475569;
    background: #f1f5f9;
    border-color: #cbd5e1;
}

@media (max-width: 1200px) {
    .balance-post-hero {
        flex-direction: column;
    }

    .balance-summary-grid,
    .balance-top-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 960px) {
    .balance-summary-grid,
    .balance-top-grid {
        grid-template-columns: 1fr;
    }

    .balance-accordion-header {
        display: none;
    }

    .balance-stock-card__header {
        grid-template-columns: 1fr;
    }

    .balance-market-context {
        align-items: flex-start;
        text-align: left;
    }
}
