:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --navy: #17233c;
    --navy-soft: #243454;
    --primary: #4169e1;
    --primary-soft: #eaf0ff;
    --teal: #168b86;
    --text: #172033;
    --muted: #667085;
    --border: #e4e9f2;
    --danger: #c63d4f;
    --shadow: 0 12px 35px rgba(23, 35, 60, 0.08);
    --radius: 18px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; }
button, input { font: inherit; }

.dashboard-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 20px; background: var(--navy); color: #fff; }
.brand { margin-bottom: 36px; }
.brand h1 { margin: 0; font-size: 1.55rem; letter-spacing: -0.04em; }
.brand p { margin: 5px 0 0; color: #aebbd5; font-size: .85rem; }
.nav-list { display: grid; gap: 7px; }
.nav-link { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 12px; color: #ccd5e8; text-decoration: none; }
.nav-link:hover, .nav-link.active { background: var(--navy-soft); color: #fff; }
.nav-link.logout { margin-top: 22px; color: #ffc5cc; }

.dashboard-main { min-width: 0; padding: 32px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 6px; color: var(--primary); font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.page-header h2 { margin: 0; font-size: clamp(1.8rem, 3vw, 2.6rem); letter-spacing: -.045em; }
.page-header .subtitle { margin: 8px 0 0; color: var(--muted); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.upload-panel { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, .75fr); gap: 24px; padding: 24px; margin-bottom: 24px; }
.upload-panel h3, .section-heading h3 { margin: 0; }
.upload-panel p, .section-heading p { color: var(--muted); }
.upload-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.file-control { flex: 1; min-width: 220px; padding: 13px; background: var(--surface-muted); border: 1px dashed #b9c4d8; border-radius: 12px; }
.primary-button, .secondary-button, .icon-button { border: 0; border-radius: 11px; cursor: pointer; font-weight: 700; }
.primary-button { padding: 13px 20px; color: #fff; background: var(--primary); }
.secondary-button { padding: 10px 14px; color: var(--primary); background: var(--primary-soft); }
.icon-button { padding: 9px 11px; background: var(--surface-muted); color: var(--muted); }
.icon-button.danger { color: var(--danger); }

.messages { display: grid; gap: 10px; margin-bottom: 20px; }
.message { padding: 12px 16px; border-radius: 12px; background: #fff4e5; border: 1px solid #f0d5a7; }

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: 1fr;
    align-items: stretch;
    gap: 16px;
    margin-bottom: 24px;
}
.metric-card {
    min-height: 142px;
    height: 100%;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.metric-label { color: var(--muted); font-size: .84rem; }
.metric-value {
    display: block;
    margin-top: 8px;
    font-size: 1.55rem;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: -.03em;
    font-variant-numeric: tabular-nums;
}
.metric-note { margin-top: 5px; color: var(--muted); font-size: .76rem; }

.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 30px 0 14px; }
.section-heading p { margin: 4px 0 0; }
.charts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.chart-card { min-height: 370px; padding: 20px; position: relative; }
.chart-card.wide { grid-column: 1 / -1; min-height: 410px; }
.chart-card h4 { margin: 0 0 18px; }
.chart-wrap { height: 300px; }
.chart-card.wide .chart-wrap { height: 330px; }
.empty-state { display: grid; place-items: center; height: 250px; text-align: center; color: var(--muted); background: var(--surface-muted); border-radius: 14px; padding: 20px; }

.history-panel { padding: 22px; }
.history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.upload-card { padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-muted); }
.upload-card-title { width: 100%; padding: 0; border: 0; background: none; text-align: left; color: var(--text); font-weight: 800; cursor: pointer; }
.upload-meta { display: block; margin: 6px 0 12px; color: var(--muted); font-size: .76rem; }
.upload-actions { display: grid; grid-template-columns: 1fr auto auto; gap: 7px; }
.upload-actions input { min-width: 0; border: 1px solid var(--border); border-radius: 9px; padding: 9px; }

.mapping-panel { padding: 22px; margin-bottom: 24px; }
.mapping-table { width: 100%; border-collapse: collapse; }
.mapping-table th, .mapping-table td { padding: 11px; border-bottom: 1px solid var(--border); text-align: left; }
.mapping-table input { width: 100%; padding: 9px; border: 1px solid var(--border); border-radius: 9px; }
.mapping-actions { margin-top: 16px; }

/* Temporarily hide the validation badge in the 90-day forecast card. */
.forecast-heading .score-pill { display: none; }

@media (max-width: 1080px) {
    .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .upload-panel { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
    .dashboard-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; padding: 18px; }
    .brand { margin-bottom: 14px; }
    .nav-list { display: flex; overflow-x: auto; }
    .nav-link { flex: 0 0 auto; }
    .nav-link.logout { margin-top: 0; }
    .dashboard-main { padding: 20px 14px; }
    .charts-grid { grid-template-columns: 1fr; }
    .chart-card.wide { grid-column: auto; }
}

@media (max-width: 560px) {
    .metrics-grid { grid-template-columns: 1fr; grid-auto-rows: auto; }
    .metric-card { min-height: 0; }
    .page-header { display: block; }
    .chart-card { min-height: 330px; }
    .chart-wrap { height: 260px; }
    .upload-actions { grid-template-columns: 1fr auto; }
    .upload-actions .danger-form { grid-column: 1 / -1; }
}
