/* === DIT Coaching — PowerBI-style SaaS Dashboard === */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
    --ds-primary: #086859;
    --ds-primary-light: #0a7d6b;
    --ds-primary-container: #308172;
    --ds-teal-accent: #3a8a7a;
    --ds-green: #10b981;
    --ds-green-bg: rgba(16, 185, 129, 0.08);
    --ds-red: #ef4444;
    --ds-red-bg: rgba(239, 68, 68, 0.08);
    --ds-amber: #f59e0b;
    --ds-amber-bg: rgba(245, 158, 11, 0.08);
    --ds-surface: #f8fafc;
    --ds-surface-low: #f1f5f9;
    --ds-surface-card: #ffffff;
    --ds-on-surface: #0f172a;
    --ds-on-surface-variant: #334155;
    --ds-outline: #cbd5e1;
    --ds-outline-variant: #e2e8f0;
    --ds-slate-300: #cbd5e1;
    --ds-slate-400: #94a3b8;
    --ds-slate-500: #64748b;
    --ds-slate-600: #475569;
    --ds-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --ds-radius: 12px;
    --ds-radius-sm: 8px;
    --ds-radius-card: 10px;
    --ds-shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --ds-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --ds-shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --ds-transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Global --- */

*, *::before, *::after { box-sizing: border-box; }

body {
    background-color: var(--ds-surface);
    font-family: var(--ds-font);
    color: var(--ds-on-surface);
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--ds-primary); text-decoration: none; }
a:hover { color: var(--ds-primary-light); }

/* --- Sidebar Nav --- */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 220px;
    height: 100vh;
    background: #0f172a;
    display: flex;
    flex-direction: column;
    z-index: 100;
    padding: 0;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand img {
    height: 28px;
    opacity: 0.95;
}

.sidebar-nav {
    list-style: none;
    padding: 0.75rem 0;
    margin: 0;
    flex: 1;
}

.sidebar-nav li { margin: 0; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 1.25rem;
    color: rgba(255,255,255,0.55);
    font-size: 0.8125rem;
    font-weight: 500;
    transition: all var(--ds-transition);
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    color: rgba(255,255,255,0.85);
    background: rgba(255,255,255,0.04);
}

.sidebar-nav a.active {
    color: #fff;
    background: rgba(8, 104, 89, 0.2);
    border-left-color: var(--ds-primary);
    font-weight: 600;
}

.sidebar-nav a i {
    font-size: 1rem;
    width: 1.25rem;
    text-align: center;
    opacity: 0.7;
}

.sidebar-nav a.active i { opacity: 1; }

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-footer a {
    color: rgba(255,255,255,0.45);
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-footer a:hover { color: rgba(255,255,255,0.7); }

/* --- Main Content Area --- */

.main-content-area {
    min-height: calc(100vh - 56px);
}

.main-content {
    margin-left: 220px;
    min-height: 100vh;
}

/* --- Top Bar --- */

.topbar {
    background: var(--ds-surface-card);
    border-bottom: 1px solid var(--ds-outline-variant);
    padding: 0 2rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.topbar-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--ds-slate-500);
    border-radius: 6px;
    transition: all var(--ds-transition);
    text-decoration: none;
}

.topbar-nav-link:hover {
    color: var(--ds-primary);
    background: rgba(8, 104, 89, 0.05);
}

.topbar-nav-link.active {
    color: var(--ds-primary);
    background: rgba(8, 104, 89, 0.08);
    font-weight: 600;
}

.topbar-nav-link i {
    font-size: 0.875rem;
}

/* --- Sub-navigation tabs (Data page, etc.) --- */
.nav-tabs {
    border-bottom: 1px solid var(--ds-outline-variant);
    gap: 0.125rem;
}
.nav-tabs .nav-item { margin-bottom: 0; }
.nav-tabs .nav-link {
    display: inline-flex;
    align-items: center;
    color: var(--ds-slate-600);
    font-size: 0.8125rem;
    font-weight: 500;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: var(--ds-radius-sm) var(--ds-radius-sm) 0 0;
    padding: 0.45rem 0.85rem;
    margin-bottom: -1px;
    background: transparent;
    transition: color var(--ds-transition), background var(--ds-transition), border-color var(--ds-transition);
}
.nav-tabs .nav-link:hover {
    color: var(--ds-primary);
    background: rgba(8, 104, 89, 0.05);
    border-color: transparent;
    isolation: isolate;
}
.nav-tabs .nav-link.active {
    color: var(--ds-primary);
    font-weight: 600;
    background: transparent;
    border-color: transparent;
    border-bottom: 2px solid var(--ds-primary);
}

.topbar-subtitle {
    font-size: 0.8125rem;
    color: var(--ds-slate-400);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* --- Dashboard Container --- */

.dashboard-container {
    padding: clamp(0.75rem, 1vw, 1.5rem) clamp(1rem, 1.5vw, 2rem) 3rem;
    max-width: 1600px;
    margin: 0 auto;
}

/* --- Single-screen dashboard (legacy) --- */

.ds-page {
    padding: 0.5rem 1rem 0.5rem;
    max-width: 1600px;
    margin: 0 auto;
    height: calc(100vh - 56px);
    display: grid;
    grid-template-rows: auto auto 1fr 1fr;
    gap: 0.375rem;
    overflow: hidden;
}

/* --- Scrollable dashboard (pacing-first layout) --- */

.ds-page-scroll {
    padding: 0.75rem 1.25rem 2rem;
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ds-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.ds-grid-3col {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.625rem;
}

/* Chart cells — equal height row, bar charts fill available space */
.ds-chart-cell {
    overflow: hidden;
    position: relative;
    min-width: 0;
}

.ds-grid-3col.ds-chart-row {
    align-items: stretch;
    height: 300px;
    grid-template-columns: minmax(200px, 1fr) minmax(200px, 1.2fr) minmax(200px, 1.2fr);
}

.ds-grid-3col.ds-chart-row > .ds-chart-cell {
    height: 100%;
}

.ds-grid-3col.ds-chart-row > .ds-chart-cell > .chart-card {
    overflow: hidden;
}

/* Chart cards inside cells fill height; bar chart scroll area takes remaining space */
.ds-chart-cell > .chart-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.ds-chart-cell > .chart-card > .chart-scroll-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* Inner scrollable chart wrappers (care-type + gemeente bar charts) */
.chart-scroll-area {
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
}

.ds-collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: var(--ds-surface-low);
    border: 1px solid var(--ds-outline-variant);
    border-radius: var(--ds-radius-sm);
    padding: 0.5rem 0.875rem;
    font-family: var(--ds-font);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--ds-slate-600);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: all var(--ds-transition);
}

.ds-collapsible-header:hover {
    background: var(--ds-surface-card);
    border-color: var(--ds-outline);
}

.ds-collapsible-header i { font-size: 0.875rem; }

/* --- Pacing bars --- */

.pacing-bar-container {
    width: 60px;
    height: 6px;
    background: var(--ds-outline-variant);
    border-radius: 3px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
}

.pacing-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.pacing-bar-period {
    background: var(--ds-slate-400);
}

.pacing-bar-label {
    font-size: 0.625rem;
    color: var(--ds-slate-500);
    margin-left: 0.25rem;
}

.pacing-status-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.5625rem;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* --- Pacing track chart --- */

.pacing-viz {
    min-width: 180px;
    padding: 0.125rem 0;
}

.pacing-track {
    display: flex;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
}

/* Left part: the "expected" portion of the budget */
.pacing-track-expected {
    flex: 7;
    background: var(--ds-slate-300);
    border-radius: 5px 0 0 5px;
    overflow: hidden;
}

/* Right part: remaining budget beyond expected */
.pacing-track-rest {
    flex: 3;
    background: var(--ds-outline-variant);
    border-radius: 0 5px 5px 0;
}

/* The actual fill (werkelijk) inside the expected track */
.pacing-track-fill {
    height: 100%;
    border-radius: 5px 0 0 5px;
    transition: width 0.3s ease;
}

.pacing-track-labels {
    display: flex;
    justify-content: space-between;
    font-size: clamp(0.5625rem, 0.7vw, 0.6875rem);
    margin-top: 2px;
    line-height: 1;
}

.pacing-dates {
    display: flex;
    justify-content: space-between;
    font-size: clamp(0.5625rem, 0.5vw, 0.625rem);
    color: var(--ds-slate-400);
    margin-top: 1px;
}

/* --- Pacing legend --- */

.pacing-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--ds-surface-low);
    border: 1px solid var(--ds-outline-variant);
    border-radius: var(--ds-radius-sm);
    font-size: 0.6875rem;
    color: var(--ds-slate-600);
    margin-bottom: 0.5rem;
}

/* --- WMO / JW type badges --- */

.pacing-type-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.5625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.pacing-type-wmo {
    background: #dbeafe;
    color: #1e40af;
}

.pacing-type-jw {
    background: #fef3c7;
    color: #92400e;
}

.pacing-legend-swatch {
    display: inline-block;
    width: 12px;
    height: 8px;
    border-radius: 2px;
    vertical-align: middle;
    margin-right: 3px;
}

.pacing-legend-swatch--fill {
    background: var(--ds-primary);
}

.pacing-legend-formula {
    font-family: monospace;
    font-size: 0.625rem;
    color: var(--ds-slate-500);
    border-left: 1px solid var(--ds-outline-variant);
    padding-left: 0.75rem;
}

.ds-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ds-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ds-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--ds-on-surface);
    letter-spacing: -0.02em;
    margin: 0;
}

.ds-grid-top {
    display: grid;
    grid-template-columns: 3fr 5fr 3fr;
    gap: 0.375rem;
    min-height: 0;
}

.ds-grid-top > * {
    min-height: 0;
    min-width: 0;
}

.ds-grid-top > * > .chart-card,
.ds-grid-top > .chart-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.ds-stack {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    min-height: 0;
}

.ds-stack > .chart-card { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.ds-grid-bottom {
    display: grid;
    grid-template-columns: 5fr 3fr 4fr;
    gap: 0.375rem;
    min-height: 0;
}

.ds-grid-bottom > * {
    min-height: 0;
    min-width: 0;
}

.ds-grid-bottom > * > .chart-card,
.ds-grid-bottom > .chart-card,
.ds-grid-bottom > div > .chart-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
}

.ds-grid-bottom .chart-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.ds-grid-bottom .compact-table { font-size: 0.6875rem; }
.ds-grid-bottom .compact-table td { padding: 0.3125rem 0.375rem; }
.ds-grid-bottom .compact-table thead th { padding: 0.3125rem 0.375rem; font-size: 0.5625rem; }
.ds-grid-bottom .compact-table td:first-child { padding-left: 0.625rem; }
.ds-grid-bottom .compact-table thead th:first-child { padding-left: 0.625rem; }

/* --- Dashboard Header --- */

.dashboard-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.dashboard-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--ds-on-surface);
    letter-spacing: -0.02em;
    margin: 0;
    line-height: 1.3;
}

.dashboard-subtitle {
    font-size: 0.8125rem;
    color: var(--ds-slate-400);
    font-weight: 500;
    margin: 0.125rem 0 0;
}

/* --- Filter Bar --- */

.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.ds-page .filter-select { width: 180px; height: 28px; font-size: 0.6875rem; }
.ds-page .date-pill { font-size: 0.625rem; padding: 0.1875rem 0.5rem; }
.ds-page .reset-link { font-size: 0.5625rem; padding: 0.1875rem 0.375rem; }
.ds-page .kpi-grid { gap: 0.375rem; margin-bottom: 0; }
.ds-page .kpi-card { padding: 0.4375rem 0.75rem; border-radius: 8px; }
.ds-page .kpi-label { font-size: 0.5rem; margin-bottom: 0.0625rem; }
.ds-page .kpi-value { font-size: 1.125rem; line-height: 1.2; }
.ds-page .kpi-subtitle { font-size: 0.5625rem; margin-top: 0.0625rem; }
.ds-page .chart-card { padding: 0.5rem 0.75rem; border-radius: 8px; }
.ds-page .chart-header { margin-bottom: 0.25rem; }
.ds-page .section-header { font-size: 0.5rem; margin-bottom: 0; }
.ds-page .section-subtitle { font-size: 0.75rem; }
.ds-page .chart-legend { font-size: 0.5625rem; }
.ds-page .urgency-card { padding: 0.375rem 0.625rem; }
.ds-page .urgency-card .kpi-label { font-size: 0.5rem; }
.ds-page .urgency-card .kpi-value { font-size: 1.125rem; }
.ds-page .urgency-badge { font-size: 0.5rem; padding: 0.0625rem 0.375rem; }
.ds-page .urgency-grid { gap: 0.25rem; }
.ds-page .trend-summary { padding: 0.25rem 0.625rem; margin-top: 0.25rem; }
.ds-page .trend-summary-label { font-size: 0.5rem; }
.ds-page .trend-summary-value { font-size: 0.8125rem; }
.ds-page .donut-legend { font-size: 0.5625rem; margin-top: 0.125rem; gap: 0.375rem; }
.ds-page .empty-state { padding: 0.75rem 0.5rem; font-size: 0.6875rem; }
.ds-page .empty-state i { font-size: 1rem; }

.filter-select {
    background-color: var(--ds-surface-card);
    border: 1px solid var(--ds-outline-variant);
    border-radius: var(--ds-radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: var(--ds-font);
    height: 36px;
    padding: 0 1.75rem 0 0.75rem;
    width: auto;
    min-width: 120px;
    max-width: 200px;
    transition: all var(--ds-transition);
    color: var(--ds-on-surface);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    cursor: pointer;
}

.filter-select:hover {
    border-color: var(--ds-primary);
    box-shadow: 0 0 0 3px rgba(8, 104, 89, 0.06);
}

.filter-select:focus {
    border-color: var(--ds-primary);
    box-shadow: 0 0 0 3px rgba(8, 104, 89, 0.1);
    outline: none;
}

.reset-link {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--ds-slate-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.375rem 0.625rem;
    border-radius: 6px;
    transition: all var(--ds-transition);
}

.reset-link:hover {
    color: var(--ds-primary);
    background-color: rgba(8, 104, 89, 0.05);
}

.date-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ds-slate-600);
    background: var(--ds-surface-low);
    padding: 0.375rem 0.875rem;
    border-radius: 9999px;
    border: 1px solid var(--ds-outline-variant);
}

/* --- KPI Cards --- */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.kpi-card {
    background: var(--ds-surface-card);
    border: 1px solid var(--ds-outline-variant);
    border-radius: var(--ds-radius);
    padding: 1rem 1.25rem;
    position: relative;
    overflow: hidden;
    transition: all var(--ds-transition);
    cursor: pointer;
}

.kpi-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
}

.kpi-card:hover {
    box-shadow: var(--ds-shadow);
    border-color: var(--ds-outline);
}

.kpi-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    margin-bottom: 0.875rem;
}

.kpi-label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--ds-slate-400);
    text-transform: uppercase;
    margin-bottom: 0.25rem;
    line-height: 1;
}

.kpi-value {
    font-size: 1.875rem;
    font-weight: 800;
    color: var(--ds-on-surface);
    line-height: 1.15;
    letter-spacing: -0.03em;
}

.kpi-subtitle {
    font-size: 0.75rem;
    color: var(--ds-slate-400);
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.kpi-subtitle .trend-up { color: var(--ds-green); }
.kpi-subtitle .trend-down { color: var(--ds-red); }

/* --- Chart Cards --- */

.chart-card {
    background: var(--ds-surface-card);
    border: 1px solid var(--ds-outline-variant);
    border-radius: var(--ds-radius-card);
    padding: clamp(0.625rem, 0.8vw, 1rem) clamp(0.75rem, 1vw, 1.25rem);
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    transition: all var(--ds-transition);
}

.chart-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.chart-header-left { flex: 1; }

.section-header {
    font-size: clamp(0.5625rem, 0.6vw, 0.6875rem);
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ds-slate-400);
    margin-bottom: 0.125rem;
}

.section-subtitle {
    font-size: clamp(0.75rem, 0.9vw, 0.9375rem);
    font-weight: 700;
    color: var(--ds-on-surface);
    letter-spacing: -0.01em;
    margin: 0;
    white-space: nowrap;
}

.chart-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.125rem 0.375rem;
    font-size: 0.5625rem;
    color: var(--ds-slate-500);
}

.chart-legend-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 2px;
}

/* --- Urgency Section --- */

.urgency-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.urgency-card {
    border-radius: var(--ds-radius-sm);
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid transparent;
    transition: all var(--ds-transition);
}

.urgency-card:hover { transform: translateY(-1px); }

.urgency-card-red {
    background: var(--ds-red-bg);
    border-color: rgba(239, 68, 68, 0.12);
}

.urgency-card-amber {
    background: var(--ds-amber-bg);
    border-color: rgba(245, 158, 11, 0.12);
}

.urgency-card-green {
    background: var(--ds-green-bg);
    border-color: rgba(16, 185, 129, 0.12);
}

.urgency-card .kpi-label { margin-bottom: 0.125rem; }

.urgency-card .kpi-value {
    font-size: 1.75rem;
    font-weight: 800;
    margin-top: 0.125rem;
}

.urgency-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.urgency-badge-red { background-color: rgba(239, 68, 68, 0.12); color: #dc2626; }
.urgency-badge-amber { background-color: rgba(245, 158, 11, 0.12); color: #d97706; }
.urgency-badge-green { background-color: rgba(16, 185, 129, 0.12); color: #059669; }

/* --- Dashboard Grid Layout --- */

.dash-row {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.dash-row > * > .chart-card { height: 100%; display: flex; flex-direction: column; }
.dash-row > .chart-card { height: 100%; display: flex; flex-direction: column; }

.dash-row-3 { grid-template-columns: 3fr 5fr 3fr; }
.dash-row-1 { grid-template-columns: 1fr; }
.dash-row-2 { grid-template-columns: 1fr 1fr; }

/* --- Compact Tables --- */

.compact-table {
    font-size: 0.8125rem;
    font-family: var(--ds-font);
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

.compact-table thead th {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ds-slate-500);
    padding: 0.625rem 0.625rem;
    background-color: var(--ds-surface-low);
    border: none;
    white-space: nowrap;
}

.compact-table thead th:first-child {
    border-radius: 6px 0 0 6px;
    padding-left: 1rem;
}

.compact-table thead th:last-child {
    border-radius: 0 6px 6px 0;
    padding-right: 1rem;
}

.compact-table td {
    padding: 0.75rem 0.625rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--ds-outline-variant);
    color: var(--ds-on-surface-variant);
    font-weight: 400;
}

.compact-table td:first-child {
    font-weight: 600;
    color: var(--ds-on-surface);
    padding-left: 1rem;
}

.compact-table td:last-child { padding-right: 1rem; }

.compact-table tbody tr {
    transition: background-color var(--ds-transition);
}

.compact-table tbody tr:hover {
    background-color: var(--ds-surface-low);
}

.compact-table tbody tr:last-child td {
    border-bottom: none;
}

/* --- Utilization Badge --- */

.util-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    padding: 0.1875rem 0.5rem;
    border-radius: 6px;
    color: #fff;
    font-weight: 700;
    font-size: 0.6875rem;
    letter-spacing: 0.01em;
}

/* --- Trend Summary --- */

.trend-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--ds-surface-low);
    padding: 0.625rem 1rem;
    border-radius: var(--ds-radius-sm);
    margin-top: 0.75rem;
    border: 1px solid var(--ds-outline-variant);
}

.trend-summary-label {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ds-slate-500);
}

.trend-summary-value {
    font-size: 1.125rem;
    font-weight: 800;
    color: var(--ds-primary);
    letter-spacing: -0.02em;
}

/* --- HTMX Loading --- */

.htmx-indicator { opacity: 0; transition: opacity 200ms; }
.htmx-request .htmx-indicator { opacity: 1; }

/* Skeleton pulse for HTMX swaps */
.htmx-swapping { opacity: 0.6; transition: opacity 150ms; }

/* --- Buttons --- */

.btn-primary { background-color: var(--ds-primary); border-color: var(--ds-primary); }
.btn-primary:hover { background-color: var(--ds-primary-light); border-color: var(--ds-primary-light); }
.btn-outline-primary { color: var(--ds-primary); border-color: var(--ds-primary); }
.btn-outline-primary:hover { background-color: var(--ds-primary); border-color: var(--ds-primary); color: #fff; }

/* --- Canvas Animation --- */

canvas {
    animation: chartFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes chartFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- Donut Wrapper --- */

.donut-wrapper {
    position: relative;
    width: min(130px, 65%);
    aspect-ratio: 1;
    margin: 0 auto;
}

/* --- Donut Center --- */

.donut-center {
    position: absolute;
    top: 42%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.donut-center-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--ds-on-surface);
    line-height: 1.1;
}

.donut-center-label {
    font-size: 0.6875rem;
    color: var(--ds-slate-500);
    font-weight: 500;
}

.donut-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.125rem 0.375rem;
    margin-top: 0.25rem;
    font-size: 0.5625rem;
    color: var(--ds-slate-500);
}

/* --- Login Page --- */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 56px);
    padding: 2rem;
}

.login-card {
    background: var(--ds-surface-card);
    border: 1px solid var(--ds-outline-variant);
    border-radius: var(--ds-radius);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--ds-shadow-md);
}

.login-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--ds-on-surface);
    text-align: center;
    margin-bottom: 1.5rem;
    letter-spacing: -0.02em;
}

.login-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--ds-on-surface-variant);
    margin-bottom: 0.25rem;
}

.login-input {
    font-family: var(--ds-font);
    font-size: 0.875rem;
    border: 1px solid var(--ds-outline-variant);
    border-radius: var(--ds-radius-sm);
    padding: 0.625rem 0.75rem;
    transition: all var(--ds-transition);
}

.login-input:focus {
    border-color: var(--ds-primary);
    box-shadow: 0 0 0 3px rgba(8, 104, 89, 0.1);
}

.login-input::placeholder {
    color: var(--ds-slate-300);
    font-weight: 400;
}

.login-btn {
    font-family: var(--ds-font);
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.625rem;
    border-radius: var(--ds-radius-sm);
    margin-top: 0.5rem;
}

.login-page .form-check-input:checked {
    background-color: var(--ds-primary);
    border-color: var(--ds-primary);
}

.login-page .form-check-label {
    font-size: 0.8125rem;
    margin-bottom: 0;
}

/* --- Scrollbar --- */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ds-outline-variant); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ds-outline); }

/* --- Empty State --- */

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--ds-slate-400);
    font-size: 0.875rem;
}

.empty-state i { font-size: 2rem; margin-bottom: 0.5rem; display: block; }

/* --- More link --- */

.more-link {
    text-align: center;
    font-size: 0.75rem;
    color: var(--ds-slate-500);
    padding: 0.625rem;
    border-top: 1px solid var(--ds-outline-variant);
    margin-top: 0.5rem;
}

/* --- Chart container for coaches (extracted from inline style) --- */

.coach-chart-container {
    position: relative;
    height: 350px;
}

/* --- Narrow filter variant (date pickers, small selects) --- */

.filter-select--narrow {
    width: 160px;
}

/* --- Responsive: Laptop screens --- */

@media (max-width: 1599.98px) {
    /* Layout & spacing */
    .ds-page-scroll { padding: 0.5rem 1rem 1.5rem; }

    /* Topbar */
    .topbar { padding: 0 1.25rem; height: 48px; }
    .topbar-nav-link { font-size: 0.75rem; padding: 0.3rem 0.5rem; }
    .topbar-subtitle { font-size: 0.75rem; }

    /* Header row + KPI strip */
    .coach-header-row { gap: 0.5rem; margin-bottom: 0.5rem; }
    .coach-kpi { padding: 0.375rem 0.625rem; }
    .coach-kpi-sub { font-size: 0.6875rem; }

    /* Title & filters */
    .ds-title { font-size: 0.875rem; }
    .filter-select { height: 32px; font-size: 0.75rem; }
    .filter-select--narrow { width: 140px; }
    .date-pill { font-size: 0.6875rem; padding: 0.25rem 0.625rem; }
    .reset-link { font-size: 0.625rem; }

    /* Dashboard charts grid */
    .ds-grid-3col.ds-chart-row { height: 260px; }

    /* Chart cards */
    .chart-header { margin-bottom: 0.5rem; }
    .coach-chart-container { height: 280px; }

    /* KPI cards */
    .kpi-grid { gap: 0.5rem; margin-bottom: 0.5rem; }
    .kpi-card { padding: 0.75rem 1rem; }
    .kpi-label { font-size: 0.625rem; }
    .kpi-value { font-size: 1.5rem; }
    .kpi-subtitle { font-size: 0.6875rem; margin-top: 0.375rem; }
    .kpi-icon { width: 30px; height: 30px; font-size: 0.875rem; margin-bottom: 0.625rem; }

    /* Urgency cards */
    .urgency-card { padding: 0.75rem 1rem; }
    .urgency-card .kpi-value { font-size: 1.375rem; }

    /* Tables */
    .compact-table { font-size: 0.75rem; }
    .compact-table thead th { font-size: 0.625rem; padding: 0.5rem 0.5rem; }
    .compact-table td { padding: 0.5rem 0.5rem; }

    /* Donuts */
    .donut-center-value { font-size: 1.125rem; }
    .donut-center-label { font-size: 0.5625rem; }
    .donut-legend { font-size: 0.625rem; gap: 0.5rem; }

    /* Pacing */
    .pacing-legend { font-size: 0.625rem; padding: 0.375rem 0.625rem; }
    .pacing-legend-formula { font-size: 0.5625rem; }

    /* Dashboard header & titles */
    .dashboard-title { font-size: 1.25rem; }
    .dashboard-subtitle { font-size: 0.75rem; }

    /* Beschikking list */
    .filter-bar { gap: 0.5rem; }

    /* Util badge */
    .util-badge { font-size: 0.625rem; min-width: 36px; padding: 0.125rem 0.375rem; }

    /* Chart headers compact mode inside chart cells */
    .ds-chart-cell .chart-header { margin-bottom: 0.375rem; }
    .ds-chart-cell .section-header { display: inline; margin-right: 0.375rem; }
    .ds-chart-cell .section-subtitle { display: inline; }
}

@media (max-width: 1399.98px) {
    .ds-grid-3col.ds-chart-row { height: 240px; }
    .coach-kpi { padding: 0.3rem 0.5rem; }
    .coach-chart-container { height: 240px; }
    .kpi-value { font-size: 1.25rem; }
    .kpi-card { padding: 0.625rem 0.875rem; }
    .filter-select { height: 28px; font-size: 0.6875rem; }
    .filter-select--narrow { width: 110px; }

    /* Tables — tighter for many-column pages like beschikkingen */
    .compact-table { font-size: 0.6875rem; }
    .compact-table thead th { font-size: 0.5625rem; padding: 0.375rem 0.3125rem; }
    .compact-table td { padding: 0.375rem 0.3125rem; }
    .compact-table thead th:first-child { padding-left: 0.625rem; }
    .compact-table td:first-child { padding-left: 0.625rem; }

    /* Donuts */
    .donut-center-value { font-size: 0.875rem; }
    .donut-legend { font-size: 0.625rem; gap: 0.25rem; }

    /* Page headers */
    .dashboard-title { font-size: 1.125rem; }
    .dashboard-header { margin-bottom: 0.75rem; }
    .dashboard-subtitle { font-size: 0.6875rem; }
    .filter-bar { gap: 0.375rem; margin-bottom: 1rem; }
}

/* --- Responsive: Header stacks at 1200px --- */

@media (max-width: 1199.98px) {
    .dash-row-3 { grid-template-columns: 1fr 1fr; }
    .dash-row-3 > :nth-child(3) { grid-column: 1 / -1; }
}

@media (max-width: 991.98px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; }
    .urgency-grid { grid-template-columns: 1fr; }
    .dash-row-3 { grid-template-columns: 1fr; }
    .dash-row-2 { grid-template-columns: 1fr; }
    .dashboard-container { padding: 1rem; }
    .topbar-nav { display: none; }
    .ds-page {
        height: auto;
        overflow: auto;
    }
    .ds-grid-top { grid-template-columns: 1fr; }
    .ds-grid-bottom { grid-template-columns: 1fr; }
    .ds-grid-2col { grid-template-columns: 1fr; }
    .ds-grid-3col { grid-template-columns: 1fr; }
}

@media (max-width: 767.98px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .kpi-value { font-size: 1.5rem; }
    .topbar { padding: 0 1rem; height: 48px; }
    .topbar-right { gap: 0.5rem; }
}

/* --- Pagination --- */
.page-item.active .page-link { background-color: var(--ds-primary); border-color: var(--ds-primary); }
.page-link { color: var(--ds-primary); }

/* --- Sortable Table Headers --- */

.sort-link {
    color: var(--ds-slate-500);
    text-decoration: none;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: color var(--ds-transition);
}

.sort-link:hover { color: var(--ds-primary); }
.sort-link.active { color: var(--ds-primary); font-weight: 700; }
.sort-icon-idle { opacity: 0.25; font-size: 0.625rem; }
.sort-link i { font-size: 0.625rem; }

/* --- Chart toggle --- */

.chart-toggle-btn {
    font-family: var(--ds-font);
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.25rem 0.625rem;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--ds-slate-500);
    cursor: pointer;
    transition: all var(--ds-transition);
}

.chart-toggle-btn:hover { color: var(--ds-primary); }
.chart-toggle-btn.active {
    background: var(--ds-surface-card);
    color: var(--ds-primary);
    box-shadow: var(--ds-shadow-sm);
}

/* --- Coach header row with inline KPIs --- */

.coach-header-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.coach-header-left {
    flex-shrink: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.coach-kpi-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    flex: 1 1 0;
    min-width: 0;
}

.coach-kpi {
    background: var(--ds-surface-card);
    border: 1px solid var(--ds-outline-variant);
    border-radius: var(--ds-radius-card);
    padding: 0.5rem 0.875rem;
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-width: 100px;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.coach-kpi-label {
    font-size: clamp(0.5625rem, 0.6vw, 0.6875rem);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ds-slate-400);
    line-height: 1;
    margin-bottom: 0.1875rem;
}

.coach-kpi-value {
    font-size: clamp(1rem, 1.3vw, 1.5rem);
    font-weight: 800;
    color: var(--ds-on-surface);
    line-height: 1.15;
    letter-spacing: -0.03em;
}

.coach-kpi-sub {
    font-size: 0.75rem;
    color: var(--ds-slate-400);
    margin-top: 0.125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Shared tooltip style (positioned by JS to avoid overflow clipping) */
.hover-tooltip {
    display: none;
    position: fixed;
    background: var(--ds-on-surface, #1e293b);
    color: #e2e8f0;
    font-size: 0.6875rem;
    line-height: 1.6;
    padding: 0.625rem 0.875rem;
    border-radius: 8px;
    width: max-content;
    min-width: 180px;
    max-width: 280px;
    z-index: 9999;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    text-align: left;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 400;
}
.hover-tooltip strong { color: #fff; font-size: 0.75rem; }
.hover-tooltip .tt-muted { color: #94a3b8; }
.kpi-tooltip-title { font-weight: 700; color: #fff; font-size: 0.75rem; margin-bottom: 0.25rem; }
.kpi-tooltip-formula { font-family: monospace; color: #94a3b8; font-size: 0.625rem; }
.kpi-tooltip-divider { border-top: 1px solid #334155; margin: 0.375rem 0; }
.kpi-tooltip-row { display: flex; justify-content: space-between; gap: 1rem; }
.kpi-tooltip-row strong { color: #fff; }
.kpi-tooltip-legend { display: flex; flex-direction: column; gap: 0.125rem; font-size: 0.625rem; }

@media (max-width: 991.98px) {
    .coach-header-row { flex-wrap: wrap; }
    .coach-kpi-strip { flex-wrap: wrap; }
    .coach-kpi { flex: 0 0 auto; min-width: 120px; }
}

/* --- Inline KPI strip (coaches page) --- */

.coach-kpi-inline {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
    margin-left: auto;
    padding: 0.375rem 0.75rem;
    background: var(--ds-surface-card);
    border: 1px solid var(--ds-outline-variant);
    border-radius: var(--ds-radius-card);
    font-size: 0.6875rem;
    color: var(--ds-on-surface);
    white-space: nowrap;
}

.kpi-inline-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.kpi-inline-item strong {
    font-weight: 800;
    font-size: 0.75rem;
}

.kpi-inline-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.kpi-inline-label {
    color: var(--ds-slate-500);
    font-size: 0.5625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.kpi-inline-sub {
    color: var(--ds-slate-400);
    font-size: 0.5625rem;
}

.kpi-inline-sep {
    width: 1px;
    height: 14px;
    background: var(--ds-outline-variant);
    flex-shrink: 0;
}

@media (max-width: 991.98px) {
    .coach-kpi-inline { margin-left: 0; }
}

/* --- Filter group (dashboard header) --- */

.coach-filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
    flex-wrap: wrap;
}

/* --- Pacing table controls --- */

.pacing-table-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* --- Numeric table cells --- */

.td-numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--ds-slate-600);
    font-weight: 600;
}

/* --- HTMX loading states --- */

.htmx-request .coach-kpi-value,
.htmx-request .chart-card canvas {
    opacity: 0.4;
    transition: opacity 150ms;
}

/* Override bootstrap container for dashboard */
.dashboard-page .container { max-width: 100%; padding: 0; }
.dashboard-page .container .alert { margin: 0 2rem; }

/* ── Status page ───────────────────────────────────────────── */

/* Compact overrides for status page density */
.status-page .kpi-grid { gap: 0.375rem; margin-bottom: 0.375rem; }
.status-page .kpi-card { padding: 0.4rem 0.625rem; }
.status-page .kpi-label { font-size: 0.5rem; margin-bottom: 0.0625rem; }
.status-page .kpi-value { font-size: 1rem; line-height: 1.2; }
.status-page .date-pill { font-size: 0.6rem; padding: 0.2rem 0.5rem; }
.status-page .ds-title { font-size: 0.8125rem; }
.status-page .coach-header-row { margin-bottom: 0.375rem; }
.status-page .ds-collapsible-header { padding: 0.2rem 0.5rem; font-size: 0.5625rem; letter-spacing: 0.04em; }
.status-page .ds-collapsible-header i { font-size: 0.4375rem; }
.status-page .compact-table { font-size: 0.6875rem; }
.status-page .compact-table thead th { font-size: 0.5rem; padding: 0.25rem 0.375rem; }
.status-page .compact-table thead th:first-child { padding-left: 0.625rem; }
.status-page .compact-table td { padding: 0.25rem 0.375rem; }
.status-page .compact-table td:first-child { padding-left: 0.625rem; }
.status-page .compact-table td:last-child { padding-right: 0.625rem; }
.status-page .util-badge { font-size: 0.5rem; min-width: 28px; padding: 0.1rem 0.3rem; }
.status-page .status-coach-block { margin-bottom: 0.375rem; }
.status-page .status-copy-btn,
.status-page .status-copy-all-btn { font-size: 0.6rem; padding: 0.2rem 0.4rem; }

.status-coach-block { margin-bottom: 0.5rem; }
.status-copy-btn,
.status-copy-all-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.6875rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--ds-outline-variant);
    border-radius: 6px;
    background: white;
    color: var(--ds-slate-600);
    cursor: pointer;
    transition: all var(--ds-transition);
}
.status-copy-btn:hover,
.status-copy-all-btn:hover {
    background: rgba(8, 104, 89, 0.04);
    border-color: var(--ds-primary);
    color: var(--ds-primary);
}
.status-toast {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    padding: 0.5rem 1rem;
    background: var(--ds-on-surface);
    color: white;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    z-index: 1050;
    opacity: 0;
    transition: opacity 200ms;
}
.status-toast.show { opacity: 1; }

/* Wider container for status page so columns fit on one line */
.status-page.dashboard-container { max-width: 1800px; }
.status-table { width: 100%; table-layout: auto; }
.status-table td, .status-table th { white-space: nowrap; }
.status-table .zorgproduct-cell {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: default;
    position: relative;
}
.status-table .zorgproduct-cell:hover { overflow: visible; white-space: normal; z-index: 10; background: white; }
