:root {
    /* Colors */
    --bg-color: #f1f5f9;
    --sidebar-bg: #0f172a;
    --sidebar-text: #f8fafc;
    --sidebar-muted: #94a3b8;
    --sidebar-border: #1e293b;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --hover-bg: #f8fafc;
    
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    
    /* Risk Colors */
    --risk-high: #ef4444;
    --risk-high-bg: #fef2f2;
    --risk-medium: #f59e0b;
    --risk-medium-bg: #fffbeb;
    --risk-low: #10b981;
    --risk-low-bg: #ecfdf5;

    /* Shadows & Radii */
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-lg: 12px;
    --radius-md: 8px;
}

[data-theme="dark"] {
    --bg-color: #020617;
    --sidebar-bg: #0f172a;
    --card-bg: #0f172a;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #1e293b;
    --hover-bg: #1e293b;
    --risk-high-bg: rgba(239, 68, 68, 0.15);
    --risk-medium-bg: rgba(245, 158, 11, 0.15);
    --risk-low-bg: rgba(16, 185, 129, 0.15);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
}

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

/* Sidebar */
.sidebar {
    width: 320px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    padding: 32px 24px;
    color: var(--sidebar-text);
}

.sidebar-header {
    margin-bottom: 40px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--primary);
    margin-bottom: 4px;
}

.logo h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--sidebar-text);
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 13px;
    color: var(--sidebar-muted);
}

.sidebar-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.step-card h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--sidebar-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.step-card p {
    font-size: 13px;
    color: var(--sidebar-muted);
    margin-bottom: 16px;
    line-height: 1.6;
}

/* Buttons & Inputs */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

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

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

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

.btn-secondary:hover {
    background-color: var(--hover-bg);
    color: var(--text-main);
}

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

.btn-sidebar-outline:hover {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: var(--sidebar-muted);
}

.file-upload-wrapper {
    display: block;
    margin-bottom: 12px;
    cursor: pointer;
}

.file-upload-wrapper input[type="file"] {
    display: none;
}

.upload-area {
    border: 2px dashed var(--sidebar-border);
    border-radius: var(--radius-md);
    padding: 32px 16px;
    text-align: center;
    color: var(--sidebar-muted);
    font-size: 13px;
    transition: all 0.2s;
    background-color: rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--primary);
}

.sidebar-footer {
    font-size: 12px;
    color: var(--sidebar-muted);
    text-align: center;
    padding-top: 24px;
    border-top: 1px solid var(--sidebar-border);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 32px 48px;
    overflow-y: auto;
    height: 100vh;
}

.hidden {
    display: none !important;
}

/* States */
.empty-state, .loading-state {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
}

.empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    color: var(--primary);
}

.empty-state h2 {
    color: var(--text-main);
    font-size: 20px;
    margin-bottom: 8px;
}

.spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Dashboard */
.dashboard {
    display: flex;
    flex-direction: column;
    gap: 24px;
    animation: fadeIn 0.4s ease-out;
}

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

/* Summary Bar */
.summary-bar {
    display: flex;
    gap: 16px;
}

.summary-item {
    flex: 1;
    background-color: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.summary-value {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 4px;
    line-height: 1;
}

.summary-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.summary-item.risk-high .summary-value { color: var(--risk-high); }
.summary-item.risk-medium .summary-value { color: var(--risk-medium); }
.summary-item.risk-low .summary-value { color: var(--risk-low); }

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    align-items: start;
}

.charts-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.card-header p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Table */
.table-container {
    max-height: 600px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    position: sticky;
    top: 0;
    background-color: var(--bg-color);
    padding: 12px 24px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable:hover {
    color: var(--text-main);
}

td {
    padding: 16px 24px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

tbody tr {
    transition: background-color 0.15s ease;
}

tbody tr:hover {
    background-color: var(--hover-bg);
    cursor: pointer;
}

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

.font-medium {
    font-weight: 500;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
}

.badge-high {
    background-color: var(--risk-high-bg);
    color: var(--risk-high);
}

.badge-medium {
    background-color: var(--risk-medium-bg);
    color: var(--risk-medium);
}

.badge-low {
    background-color: var(--risk-low-bg);
    color: var(--risk-low);
}

/* Chart Containers */
.chart-container {
    padding: 20px;
    position: relative;
    height: 250px;
    width: 100%;
}

/* Append to end of existing styles */

/* Summary Icons */
.summary-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    border-top: 4px solid var(--border-color); /* subtle gradient accent placeholder */
}

.summary-item.total { border-top-color: var(--primary); }
.summary-item.risk-high { border-top-color: var(--risk-high); }
.summary-item.risk-medium { border-top-color: var(--risk-medium); }
.summary-item.risk-low { border-top-color: var(--risk-low); }

.summary-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    background-color: rgba(59, 130, 246, 0.1);
}

.icon-red { color: var(--risk-high); background-color: var(--risk-high-bg); }
.icon-yellow { color: var(--risk-medium); background-color: var(--risk-medium-bg); }
.icon-green { color: var(--risk-low); background-color: var(--risk-low-bg); }

/* Staged Loading */
.loading-content {
    margin-top: 24px;
    text-align: left;
}

.loading-content h2 {
    font-size: 18px;
    margin-bottom: 16px;
    color: var(--text-main);
}

.loading-steps {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.step {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.step-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    display: inline-block;
}

.step.active {
    color: var(--primary);
    font-weight: 500;
}
.step.active .step-icon {
    border-color: var(--primary);
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

.step.done {
    color: var(--text-main);
}
.step.done .step-icon {
    border-color: var(--risk-low);
    background-color: var(--risk-low);
    position: relative;
}
.step.done .step-icon::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Side Drawer */
.drawer-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 40;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.drawer-overlay.visible {
    opacity: 1;
}

.side-drawer {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 400px;
    background-color: var(--bg-color);
    box-shadow: -10px 0 15px -3px rgb(0 0 0 / 0.1);
    z-index: 50;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.side-drawer.open {
    transform: translateX(0);
}

.drawer-header {
    padding: 24px;
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.drawer-header h2 { font-size: 18px; }

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    padding: 4px;
}
.icon-btn:hover { background-color: var(--bg-color); color: var(--text-main); }

.drawer-content {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.drawer-content h3 {
    font-size: 14px;
    color: var(--text-muted);
    margin: 24px 0 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.drawer-risk-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 9999px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.action-card {
    background-color: var(--bg-color);
    padding: 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary);
    box-shadow: var(--shadow-sm);
    font-size: 14px;
    line-height: 1.5;
}

.metrics-comparison {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.metric-row {
    background-color: var(--card-bg);
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.metric-name {
    font-weight: 500;
    font-size: 14px;
}

.metric-vals {
    display: flex;
    gap: 16px;
    font-size: 13px;
    text-align: right;
}

.metric-vals .val-customer {
    font-weight: 700;
    font-size: 16px;
}

.metric-vals .val-avg {
    color: var(--text-muted);
}

tbody tr { cursor: pointer; }
