/* ─── Theme variables ─── */
:root, [data-theme="light"] {
    --bg: #f0f2f5;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-nav: #ffffff;
    --bg-table-header: #f5f6f8;
    --bg-hover: #f0f4ff;
    --text: #1a1a2e;
    --text-secondary: #555;
    --text-muted: #999;
    --border: #e2e5ea;
    --border-light: #eef0f3;
    --accent: #3b82f6;
    --green: #16a34a;
    --green-bg: #ecfdf5;
    --red: #dc2626;
    --red-bg: #fef2f2;
    --koop-bg: #ecfdf5;
    --verkoop-bg: #fef2f2;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
}

[data-theme="dark"] {
    --bg: #0c0e14;
    --bg-card: #151822;
    --bg-sidebar: #111318;
    --bg-nav: #111318;
    --bg-table-header: #1a1e2a;
    --bg-hover: #1e2436;
    --text: #e8eaed;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --border: #252a36;
    --border-light: #1e222e;
    --accent: #60a5fa;
    --green: #4ade80;
    --green-bg: rgba(22,163,74,0.12);
    --red: #f87171;
    --red-bg: rgba(220,38,38,0.12);
    --koop-bg: rgba(22,163,74,0.08);
    --verkoop-bg: rgba(220,38,38,0.08);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -2px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5), 0 4px 6px -4px rgba(0,0,0,0.4);
}

/* ─── Reset ─── */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Top nav ─── */
.topnav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    height: 52px;
    background: var(--bg-nav);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-left { display: flex; align-items: center; gap: 28px; }
.logo { font-weight: 800; font-size: 15px; letter-spacing: -0.3px; }
.theme-toggle {
    background: var(--bg-table-header);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 16px;
    cursor: pointer;
    color: var(--text);
    transition: all 0.15s;
}
.theme-toggle:hover { background: var(--bg-hover); }

/* ─── Subnav (two-tier) ─── */
.subnav {
    background: var(--bg-nav);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
}
.subnav-countries {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border-light);
}
.country-tab {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    transition: all 0.12s;
}
.country-tab:hover { color: var(--text); text-decoration: none; }
.country-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.subnav-pages {
    display: flex;
    gap: 2px;
}
.page-tab {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: all 0.12s;
}
.page-tab:hover { color: var(--text-secondary); text-decoration: none; }
.page-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ─── Layout ─── */
.layout {
    display: flex;
    min-height: calc(100vh - 120px);
}
.sidebar {
    width: 230px;
    min-width: 230px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    padding: 16px;
    overflow-y: auto;
}
.content {
    flex: 1;
    padding: 20px 24px;
    overflow-x: auto;
}

/* ─── Sidebar ─── */
.sidebar-search {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    background: var(--bg-card);
    color: var(--text);
    margin-bottom: 18px;
    transition: border-color 0.15s;
}
.sidebar-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }

.filter-section { margin-bottom: 20px; }
.filter-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.8px;
    margin-bottom: 6px;
    padding-left: 4px;
}
.filter-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.12s;
}
.filter-item:hover { background: var(--bg-hover); text-decoration: none; color: var(--text); }
.filter-item.active {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}
.filter-item.active .filter-count { background: rgba(255,255,255,0.25); color: #fff; }
.filter-count {
    font-size: 10px;
    font-weight: 700;
    background: var(--bg-table-header);
    color: var(--text-muted);
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
}

.filter-input-group { margin-bottom: 10px; }
.filter-input-group label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    padding-left: 4px;
}
.filter-input-group input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    background: var(--bg-card);
    color: var(--text);
    transition: border-color 0.15s;
}
.filter-input-group input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }

.filter-bedrijven { max-height: 200px; overflow-y: auto; }

/* ─── KPI cards ─── */
.kpi-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.kpi {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    transition: transform 0.15s, box-shadow 0.15s;
}
.kpi:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.kpi-value { font-size: 32px; font-weight: 800; letter-spacing: -1px; }
.kpi-label { font-size: 11px; color: var(--text-secondary); margin-top: 4px; text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px; }
.kpi.green .kpi-value { color: var(--green); }
.kpi.red .kpi-value { color: var(--red); }

/* ─── Charts row ─── */
.charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.chart-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 18px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
}
.chart-card h3 { font-size: 12px; margin-bottom: 14px; color: var(--text-secondary); text-transform: uppercase; font-weight: 700; letter-spacing: 0.5px; }
.bar-chart { display: flex; flex-direction: column; gap: 7px; }
.bar-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.bar-label { width: 120px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; flex-shrink: 0; color: var(--text-secondary); }
.bar-track { flex: 1; height: 20px; background: var(--bg-table-header); border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; transition: width 0.4s ease; }
.bar-fill.blue { background: linear-gradient(90deg, var(--accent), #818cf8); }
.bar-fill.green { background: linear-gradient(90deg, var(--green), #4ade80); }
.bar-fill.red { background: linear-gradient(90deg, var(--red), #f87171); }
.bar-count { width: 30px; text-align: right; font-size: 11px; color: var(--text-secondary); font-weight: 600; }

/* ─── Table ─── */
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.table-header h2 { font-size: 15px; font-weight: 700; }
.table-info { font-size: 12px; color: var(--text-secondary); }
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
}
.data-table th {
    background: var(--bg-table-header);
    padding: 10px 12px;
    text-align: left;
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background 0.1s;
}
.data-table th:hover { background: var(--bg-hover); }
.data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    font-size: 12.5px;
}
.data-table tr:hover td { background: var(--bg-hover); }
.data-table tr.koop td { background: var(--koop-bg); }
.data-table tr.verkoop td { background: var(--verkoop-bg); }
.data-table tr.dim td { color: var(--text-muted); }

/* Color classes */
.text-green { color: var(--green); font-weight: 700; }
.text-red { color: var(--red); font-weight: 700; }
.text-muted { color: var(--text-muted); }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
}
.badge-koop { background: var(--koop-bg); color: var(--green); }
.badge-verkoop { background: var(--verkoop-bg); color: var(--red); }
.badge-overig { background: var(--bg-table-header); color: var(--text-secondary); }

.link-cell { text-align: center; }
.link-cell a { font-size: 14px; opacity: 0.5; transition: opacity 0.15s; }
.link-cell a:hover { opacity: 1; }

/* ─── Pagination ─── */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-top: 18px;
}
.pagination a, .pagination span {
    padding: 7px 13px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.12s;
}
.pagination a:hover { background: var(--bg-hover); text-decoration: none; }
.pagination .active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
.pagination .disabled { opacity: 0.4; pointer-events: none; }

/* ─── Donut chart ─── */
.donut-container { display: flex; align-items: center; gap: 20px; }
.donut {
    width: 100px; height: 100px;
    border-radius: 50%;
    position: relative;
    box-shadow: var(--shadow-sm);
}
.donut-legend { font-size: 12px; }
.donut-legend-item { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-weight: 500; }
.donut-swatch { width: 12px; height: 12px; border-radius: 3px; }
