:root, [data-theme="dark"] {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #020617 100%);
    --card-bg: rgba(30, 41, 59, 0.4);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --success: #10b981;
    --error: #ef4444;
    --header-bg: rgba(15, 23, 42, 0.9);
}

[data-theme="light"] {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #475569;
    --header-bg: rgba(255, 255, 255, 0.9);
}

[data-theme="indigo"] {
    --primary: #818cf8;
    --primary-hover: #a5b4fc;
    --bg-gradient: linear-gradient(135deg, #1e1b4b 0%, #0f1133 100%);
    --card-bg: rgba(30, 27, 75, 0.6);
    --card-border: rgba(129, 140, 248, 0.15);
    --text-main: #e0e7ff;
    --text-muted: #94a3b8;
    --header-bg: rgba(30, 27, 75, 0.9);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.4;
    font-size: 0.9rem; /* Slightly smaller default */
}

.container {
    max-width: 1400px; /* Wider for more data */
    margin: 0 auto;
    padding: 15px;
}

header {
    background: var(--header-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--card-border);
    padding: 10px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

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

.logo {
    font-size: 1.3rem; /* Compact logo */
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -1px;
    text-decoration: none;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.theme-selector {
    background: var(--card-bg);
    border: 1px solid var(--primary);
    color: var(--text-main);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
}

.theme-selector option {
    background: #1e293b;
    color: #fff;
}

[data-theme="light"] .theme-selector option {
    background: #fff;
    color: #000;
}

.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 20px; /* Reduced padding */
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.3);
    margin-bottom: 15px; /* Reduced margin */
    animation: fadeIn 0.4s ease forwards;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
}

.stat-icon {
    font-size: 1.4rem;
    margin-bottom: 8px;
    color: var(--primary);
}

.stat-info .value {
    font-size: 1.5rem;
    font-weight: 800;
}

/* Forms & Inputs */
input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    margin: 5px 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.85rem;
}

[data-theme="light"] input, [data-theme="light"] select, [data-theme="light"] textarea {
    background: #fff;
    color: #0f172a;
    border: 1px solid #cbd5e1;
}

button, .btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
    font-size: 0.85rem;
}

.btn-danger {
    background: var(--error);
    color: white !important;
}

.btn-danger:hover {
    background: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-success {
    background: var(--success);
    color: white !important;
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: 12px;
}

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

th {
    text-align: left;
    padding: 10px 15px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--card-border);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 8px 15px;
    border-bottom: 1px solid var(--card-border);
    font-size: 0.85rem;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 15px;
}

/* Active Filters Bar */
.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.filter-tag {
    background: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-tag .remove {
    cursor: pointer;
    background: rgba(255,255,255,0.2);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

/* Dashboard Controls */
.dash-controls {
    display: flex;
    flex-wrap: nowrap;
    overflow: hidden;
    border-left: 4px solid var(--success);
}

.selection-chip {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.selection-chip strong {
    color: var(--text-muted);
    font-weight: 500;
}

.selection-chip span {
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    margin-top: -2px;
}

.selection-chip:hover {
    background: rgba(16, 185, 129, 0.25);
}

.btn-sm {
    padding: 4px 12px;
    font-size: 0.75rem;
    border-radius: 6px;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text-muted);
}

.btn-outline:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-main);
    border-color: var(--primary);
}

/* Professional BI Dashboard UI */
.dashboard-header {
    border-bottom: 1px solid var(--card-border);
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
}

.compact-filters {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 0.75rem 1.25rem !important;
    background: rgba(255, 255, 255, 0.02) !important;
    border-radius: 99px !important;
    margin-bottom: 25px;
}

.compact-filters .form-group {
    margin: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.compact-filters label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap;
}

.compact-filters input {
    background: transparent !important;
    border: none !important;
    padding: 5px !important;
    font-weight: 600;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.kpi-card {
    padding: 1.5rem !important;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    border-left: 4px solid var(--primary);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.kpi-data .label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.kpi-data .value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
}

.dash-controls {
    background: rgba(16, 185, 129, 0.05);
    border: 1px solid rgba(16, 185, 129, 0.1);
    border-left: 4px solid var(--success);
    margin-bottom: 25px;
    animation: slideDown 0.3s ease;
}

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

/* Launchpad (User Dashboard) UI */
.launchpad-hero {
    margin-bottom: 2.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--card-border);
}

.launchpad-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.launchpad-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-decoration: none;
    min-height: 220px;
    padding: 1.75rem !important;
    border-top: 4px solid transparent;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.launchpad-card:hover {
    transform: translateY(-8px) !important;
    border-top-color: var(--primary);
    box-shadow: 0 20px 50px -15px rgba(0, 0, 0, 0.4);
    background: rgba(255, 255, 255, 0.05);
}

.launchpad-icon-box {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 1.25rem;
    transition: all 0.3s;
}

.launchpad-card:hover .launchpad-icon-box {
    background: var(--primary);
    color: white;
    transform: rotate(-5deg) scale(1.1);
}

.launchpad-card h3 {
    color: var(--text-main);
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
}

.launchpad-card .desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 1.5rem;
}

.launchpad-card .cta {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    gap: 8px;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.launchpad-card:hover .cta {
    opacity: 1;
}

/* Tab Navigation */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

.tab-btn {
    background: none;
    border: none;
    padding: 12px 24px;
    cursor: pointer;
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
    font-weight: 700;
    font-size: 0.95rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(255,255,255,0.02);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Modal System (Drill-through) */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(2, 6, 23, 0.85);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: none;
    align-items: center; justify-content: center;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    width: 100%;
    max-width: 1100px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    position: relative;
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--card-border);
    display: flex; justify-content: space-between; align-items: center;
}

.modal-body {
    padding: 0;
    overflow-y: auto;
    flex: 1;
}

/* TV / Presentation Mode Controls */
.tv-hidden { display: block; } /* Visible by default */
body.tv-mode .tv-hidden { display: none !important; } /* Hidden ONLY in TV Mode */

body.tv-mode {
    background: #020617;
    padding: 0 !important;
}

body.tv-mode .container {
    max-width: 100% !important;
    padding: 2rem !important;
}

body.tv-mode .charts-grid {
    grid-template-columns: repeat(auto-fit, minmax(600px, 1fr)) !important;
    gap: 2rem;
}

/* Chart Box Toolbar */
.chart-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--primary);
    padding-left: 12px;
}

.chart-toolbar {
    display: flex; gap: 8px; opacity: 0.3; transition: opacity 0.3s;
}

.chart-box:hover .chart-toolbar { opacity: 1; }

.toolbar-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--card-border);
    color: var(--text-muted); padding: 4px 8px; border-radius: 6px;
    font-size: 0.75rem; cursor: pointer; transition: all 0.2s;
}

.toolbar-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }

/* Modal System (Drill-through) */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(2, 6, 23, 0.85);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: none;
    align-items: center; justify-content: center;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    width: 100%;
    max-width: 1100px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    position: relative;
    color: var(--text-main);
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--card-border);
    display: flex; justify-content: space-between; align-items: center;
}

.modal-body {
    padding: 0;
    flex: 1;
}

body.tv-mode .charts-grid {
    grid-template-columns: repeat(auto-fit, minmax(600px, 1fr)) !important;
    gap: 2rem;
}

/* Chart Box Toolbar */
.chart-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--primary);
    padding-left: 12px;
}

.chart-toolbar {
    display: flex; gap: 8px; opacity: 0.3; transition: opacity 0.3s;
}

.chart-box:hover .chart-toolbar { opacity: 1; }

.toolbar-btn {
    background: rgba(128,128,128,0.1);
    border: 1px solid var(--card-border);
    color: var(--text-main); padding: 4px 8px; border-radius: 6px;
    font-size: 0.75rem; cursor: pointer; transition: all 0.2s;
}

.toolbar-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Enhanced Chart UI */
.chart-box {
    display: flex;
    flex-direction: column;
    min-height: 520px;
    height: 100%;
    overflow: hidden;
    padding: 0 !important;
}

.chart-header {
    padding: 1.25rem 1.75rem !important;
    border-bottom: 1px solid var(--card-border);
    margin-bottom: 0 !important;
}

.chart-footer {
    padding: 1rem 1.75rem;
    border-top: 1px solid var(--card-border);
    background: rgba(255,255,255,0.03);
    margin-top: auto;
}

.btn-detail {
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-detail:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 30px rgba(99, 102, 241, 0.4);
    filter: brightness(1.2);
}

.btn-detail i {
    font-size: 1.2rem;
    transition: transform 0.3s;
}

.btn-detail:hover i {
    transform: translateX(3px);
}
