/* Root Variables targeting SaaS Aesthetic */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --border-color: #e2e8f0;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --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);
    --sidebar-width: 260px;
}

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

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

/* Typography */
h1, h2, h3 { font-weight: 600; color: var(--text-primary); }

.hidden { display: none !important; }

/* Upload Overlay Modal matching Reference */
.upload-overlay {
    position: fixed; top:0; left:0; width:100%; height:100%;
    background: linear-gradient(135deg, #f0f4ff 0%, #e5e7eb 100%);
    display: flex; justify-content: center; align-items: center; z-index: 2000;
}
.upload-modal {
    background: var(--surface-color);
    padding: 40px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    text-align: center;
}
.upload-icon-container {
    width: 80px; height: 80px;
    background: #eff6ff;
    color: var(--primary-color);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 20px;
}
.upload-form { display: flex; flex-direction: column; gap: 15px; margin-top: 30px; }
.input-field {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 15px;
    outline: none; transition: border 0.2s;
}
.input-field:focus { border-color: var(--primary-color); }

.status-msg { margin-top: 15px; font-size: 14px; }

/* Buttons */
.btn {
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-weight: 500; font-size: 14px;
    cursor: pointer; transition: all 0.2s;
    border: none;
}
.btn-primary { background-color: var(--primary-color); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-outline { background-color: transparent; border: 1px solid var(--border-color); color: var(--text-primary); }
.btn-outline:hover { background-color: #f1f5f9; }
.btn-block { width: 100%; padding: 12px; font-size: 16px; }

.status-msg { margin-top: 15px; font-size: 14px; color: var(--text-secondary); }

/* SaaS Layout */
.dashboard-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex; flex-direction: column;
}
.sidebar-header {
    height: 70px;
    padding: 0 24px;
    display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 700; font-size: 18px; color: var(--primary-color);
}
.sidebar-nav { padding: 24px 12px; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500; cursor: pointer;
    margin-bottom: 8px; transition: all 0.2s;
}
.nav-item:hover { background: #f8fafc; color: var(--text-primary); }
.nav-item.active { background: #eff6ff; color: var(--primary-color); }
.sidebar-footer { padding: 24px; border-top: 1px solid var(--border-color); }

/* Main Workspace */
.main-workspace {
    flex: 1;
    overflow-y: auto;
    padding: 30px 40px;
    background: var(--bg-color);
}

/* Global Filter */
.global-filter-bar {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--surface-color); padding: 16px 24px;
    border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); border: 1px solid var(--border-color);
    margin-bottom: 30px;
}
.filter-left { display: flex; gap: 16px; align-items: center; }
.input-field-sm { padding: 8px 12px; border: 1px solid var(--border-color); border-radius: var(--radius-md); outline: none; }

/* Header Meta */
.metadata-header {
    display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 30px;
    background: var(--surface-color); padding: 20px; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); border: 1px solid var(--border-color);
}
.meta-item {
    flex: 1; min-width: 150px; display: flex; flex-direction: column; gap: 4px;
}
.meta-item span { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; font-weight: 600; }
.meta-item strong { font-size: 14px; color: var(--text-primary); }

/* Tabs */
.tab-content { animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Cards & Grid */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 30px; }
.kpi-card {
    background: var(--surface-color); padding: 20px; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm); border: 1px solid var(--border-color);
}
.kpi-card h3 { font-size: 13px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; }
.kpi-value { font-size: 24px; font-weight: 700; }
.kpi-value.brand { color: var(--primary-color); }
.kpi-value.green { color: var(--success-color); }
.kpi-value.red { color: var(--danger-color); }
.kpi-value.warning { color: var(--warning-color); }

/* FOIR Specific */
.foir-container { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; }
.foir-percent { font-size: 24px; font-weight: 700; color: var(--text-primary); }
.foir-stars { display: flex; gap: 2px; }
.foir-stars svg { width: 16px; height: 16px; fill: #cbd5e1; }
.foir-stars.green svg { fill: var(--success-color); }
.foir-stars.warning svg { fill: var(--warning-color); }
.foir-stars.red svg { fill: var(--danger-color); }
.foir-message { font-size: 13px; color: var(--text-secondary); font-weight: 500; }

/* Table View */
.table-card {
    background: var(--surface-color); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); overflow: hidden;
}
.table-card h3 { font-size: 16px; padding: 20px; border-bottom: 1px solid var(--border-color); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; padding: 12px 20px; background: #f8fafc; font-size: 12px; color: var(--text-secondary); text-transform: uppercase; border-bottom: 1px solid var(--border-color); }
.data-table td { padding: 14px 20px; font-size: 14px; border-bottom: 1px solid var(--border-color); }
.clickable-row { cursor: pointer; transition: background 0.15s; }
.clickable-row:hover { background: #f1f5f9; }
.mt-4 { margin-top: 24px; }

/* Badges */
.badge { padding: 4px 8px; border-radius: 4px; font-size: 12px; background: #f1f5f9; color: #475569; font-weight: 500; }
.badge.alert { background: #fee2e2; color: #dc2626; }
.badge.good { background: #dcfce7; color: #16a34a; }

.pagination-container { padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border-color); background: var(--surface-color); border-bottom-left-radius: var(--radius-lg); border-bottom-right-radius: var(--radius-lg); }

/* Charts */
.dashboard-charts { display: flex; gap: 24px; margin-bottom: 30px; }
.chart-card { background: var(--surface-color); padding: 20px; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); flex: 1; }
.chart-container { position: relative; height: 350px; width: 100%; margin-top: 20px; }

/* Modals */
.modal { position: fixed; z-index: 3000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(15, 23, 42, 0.4); backdrop-filter: blur(4px); display: flex; justify-content: center; align-items: center; }
.modal-content { background-color: var(--surface-color); border-radius: var(--radius-lg); width: 90%; max-width: 600px; box-shadow: var(--shadow-lg); }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { font-size: 18px; }
.close-btn { font-size: 28px; color: var(--text-secondary); cursor: pointer; line-height: 1; }
.modal-body { padding: 24px; }
