:root {
    --bg-dark: #080b12;
    --sidebar-bg: rgba(13, 17, 28, 0.8);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --primary-gradient: linear-gradient(135deg, #3e63ff 0%, #7c4dff 100%);
    --accent-cyan: #00f2ff;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --success: #00e676;
    --warning: #ff9800;
    --danger: #ff5252;
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body.dark-theme {
    background: var(--bg-dark);
    color: var(--text-main);
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(62, 99, 255, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(124, 77, 255, 0.05) 0%, transparent 40%);
    background-attachment: fixed;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 3rem;
}

.logo-icon {
    font-size: 1.8rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.sidebar nav ul {
    list-style: none;
}

.sidebar nav li {
    padding: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
}

.sidebar nav li .icon {
    font-size: 1.2rem;
}

.sidebar nav li:hover {
    background: var(--glass-bg);
    color: var(--text-main);
    transform: translateX(5px);
}

.sidebar nav li.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(62, 99, 255, 0.3);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 2rem;
}

#sidebar-prediction-target {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.status-badge {
    background: rgba(0, 230, 118, 0.1);
    color: var(--success);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    display: inline-block;
    border: 1px solid rgba(0, 230, 118, 0.2);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem 3rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 3rem;
    animation: fadeInDown 0.8s ease-out;
}

.header-info h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

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

/* Buttons */
.action-btn {
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s;
}

.action-btn.primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(62, 99, 255, 0.3);
}

.action-btn.secondary {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
}

.action-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.filter-controls {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.filter-select {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.3s;
    min-width: 150px;
}

.filter-select option {
    background: #1a1f2e;
    color: white;
}

.filter-select:focus {
    border-color: var(--accent-cyan);
}

.target-badge {
    background: var(--primary-gradient);
    padding: 0.6rem 1.2rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(62, 99, 255, 0.3);
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 1.8rem;
    box-shadow: var(--card-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: fadeInUp 0.8s ease-out backwards;
}

.glass:hover {
    transform: translateY(-5px);
    border-color: rgba(62, 99, 255, 0.3);
}

.glow-blue {
    box-shadow: 0 0 20px rgba(62, 99, 255, 0.15);
}

.glow-purple {
    box-shadow: 0 0 20px rgba(124, 77, 255, 0.15);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.8rem;
}

.stat-card h3 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

/* Insights Panel */
.insights-panel {
    margin-bottom: 2rem;
    animation: fadeInUp 0.8s ease-out 0.2s backwards;
}

.insights-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.insights-header .icon {
    font-size: 1.5rem;
    color: var(--warning);
}

.insights-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.insights-list li {
    padding: 0.8rem 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    font-size: 0.9rem;
    color: var(--text-main);
    border-left: 3px solid var(--accent-cyan);
}

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.chart-container {
    min-height: 400px;
    height: auto;
    position: relative;
    display: flex;
    flex-direction: column;
}

.chart-container canvas {
    flex: 1;
    max-height: 320px;
}

.chart-container h4 {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
}

/* Overlay & Loader */
.overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loader-content {
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--glass-border);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Table Style */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 1.2rem;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--glass-border);
}

td {
    padding: 1.2rem;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.9rem;
}

.trend-badge {
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
}

.trend-up { background: rgba(0, 230, 118, 0.1); color: var(--success); }
.trend-down { background: rgba(255, 82, 82, 0.1); color: var(--danger); }

/* Allocation Grid */
.allocation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
}

.allocation-card {
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.allocation-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 4px; height: 100%;
    background: var(--primary-gradient);
}

.alloc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.alloc-dealer-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.dealer-icon {
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.alloc-id {
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: -0.5px;
}

.priority-badge {
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.priority-High { 
    background: rgba(255, 82, 82, 0.1); 
    color: var(--danger); 
    border: 1px solid rgba(255, 82, 82, 0.2);
    box-shadow: 0 0 10px rgba(255, 82, 82, 0.1);
}

.priority-Medium { 
    background: rgba(255, 152, 0, 0.1); 
    color: var(--warning); 
    border: 1px solid rgba(255, 152, 0, 0.2);
}

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

.metric-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.metric-group label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-val {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-main);
}

.metric-val.highlight {
    color: var(--accent-cyan);
    text-shadow: 0 0 10px rgba(0, 242, 255, 0.2);
}

.alloc-footer {
    border-top: 1px solid var(--glass-border);
    padding-top: 1.5rem;
}

.alloc-action {
    width: 100%;
    padding: 1rem;
    border-radius: 14px;
    border: none;
    background: var(--primary-gradient);
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(62, 99, 255, 0.2);
}

.alloc-action:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(62, 99, 255, 0.4);
}

/* Matrix View Styling */
.matrix-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 1.5rem;
    height: 700px;
}

.matrix-quadrant {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.quad-label {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 1px;
    padding: 0.4rem 0.8rem;
    border-radius: 12px;
}

.matrix-quadrant.star { border-top: 5px solid #ffd700; box-shadow: inset 0 10px 30px rgba(255, 215, 0, 0.05); }
.matrix-quadrant.question { border-top: 5px solid #7c4dff; box-shadow: inset 0 10px 30px rgba(124, 77, 255, 0.05); }
.matrix-quadrant.cash { border-top: 5px solid #00f2ff; box-shadow: inset 0 10px 30px rgba(0, 242, 255, 0.05); }
.matrix-quadrant.dog { border-top: 5px solid #ff5252; box-shadow: inset 0 10px 30px rgba(255, 82, 82, 0.05); }

.star .quad-label { background: rgba(255, 215, 0, 0.1); color: #ffd700; }
.question .quad-label { background: rgba(124, 77, 255, 0.1); color: #7c4dff; }
.cash .quad-label { background: rgba(0, 242, 255, 0.1); color: #00f2ff; }
.dog .quad-label { background: rgba(255, 82, 82, 0.1); color: #ff5252; }

.matrix-item {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 14px;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid transparent;
    transition: all 0.3s;
}

.matrix-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--glass-border);
    transform: translateX(5px);
}

.matrix-item-info strong {
    display: block;
    font-size: 1rem;
    margin-bottom: 0.2rem;
}

.matrix-item-info span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.matrix-item-val {
    font-weight: 700;
    font-size: 1.1rem;
}

/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.dashboard-view { display: none; }
.dashboard-view.active { display: block; animation: fadeIn 0.5s ease; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

#forecast-search {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.8rem 1.2rem;
    border-radius: 12px;
    width: 100%;
    outline: none;
    transition: border-color 0.3s;
}

#forecast-search:focus { border-color: var(--accent-cyan); }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
