/* ============================================================
   Energy Monitor NL v4 — Herontworpen voor leesbaarheid
   Geen monospace voor bodytekst, ruimere typografie,
   hogere contrastverhoudingen, prettiger op het oog.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300;0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;0,14..32,800;1,14..32,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Variabelen: donker thema (standaard) ── */
:root {
    --em-bg:        #0c111d;
    --em-bg-2:      #111827;
    --em-surface:   #1a2235;
    --em-surface-2: #202d42;
    --em-surface-3: #263350;
    --em-border:    rgba(255,255,255,.08);
    --em-border-2:  rgba(255,255,255,.14);

    --em-text:      #f1f5fb;
    --em-text-2:    #94a8c8;
    --em-muted:     #516080;

    --em-blue:        #3b82f6;
    --em-blue-b:      #60a5fa;
    --em-blue-dim:    rgba(59,130,246,.1);
    --em-green:       #10b981;
    --em-green-b:     #34d399;
    --em-green-dim:   rgba(16,185,129,.1);
    --em-orange:      #f59e0b;
    --em-orange-b:    #fbbf24;
    --em-orange-dim:  rgba(245,158,11,.1);
    --em-teal:        #06b6d4;
    --em-teal-b:      #22d3ee;
    --em-teal-dim:    rgba(6,182,212,.1);
    --em-red:         #ef4444;
    --em-red-b:       #f87171;
    --em-red-dim:     rgba(239,68,68,.1);
    --em-yellow:      #eab308;
    --em-yellow-dim:  rgba(234,179,8,.1);
    --em-purple:      #8b5cf6;
    --em-purple-dim:  rgba(139,92,246,.1);

    --em-shadow:    0 1px 3px rgba(0,0,0,.5);
    --em-shadow-md: 0 6px 24px rgba(0,0,0,.45);
    --em-shadow-lg: 0 20px 60px rgba(0,0,0,.6);
    --em-radius:    12px;
    --em-radius-sm: 8px;
    --em-radius-xs: 6px;
    --em-nav-h:     60px;

    /* Lettertypen: Inter voor alles, JetBrains alleen voor getallen/code */
    --font:      'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ── Licht thema ── */
.em-app.em-light {
    --em-bg:        #f0f4fa;
    --em-bg-2:      #e6ecf5;
    --em-surface:   #ffffff;
    --em-surface-2: #f5f8fd;
    --em-surface-3: #edf1f9;
    --em-border:    rgba(0,0,0,.08);
    --em-border-2:  rgba(0,0,0,.14);

    --em-text:   #0d1526;
    --em-text-2: #374460;
    --em-muted:  #8fa3c0;

    --em-blue:      #1d4ed8;
    --em-blue-b:    #2563eb;
    --em-blue-dim:  rgba(29,78,216,.07);
    --em-green:     #047857;
    --em-green-b:   #059669;
    --em-green-dim: rgba(4,120,87,.07);
    --em-orange:    #b45309;
    --em-orange-b:  #d97706;
    --em-orange-dim:rgba(180,83,9,.07);
    --em-teal:      #0e7490;
    --em-teal-b:    #0891b2;
    --em-teal-dim:  rgba(14,116,144,.07);
    --em-red:       #b91c1c;
    --em-red-b:     #dc2626;
    --em-red-dim:   rgba(185,28,28,.07);
    --em-yellow:    #92400e;
    --em-yellow-dim:rgba(146,64,14,.07);
    --em-purple:    #6d28d9;
    --em-purple-dim:rgba(109,40,217,.07);

    --em-shadow:    0 1px 3px rgba(0,0,0,.06), 0 0 0 1px rgba(0,0,0,.04);
    --em-shadow-md: 0 6px 24px rgba(0,0,0,.08);
    --em-shadow-lg: 0 20px 60px rgba(0,0,0,.12);
}

/* ── Reset ── */
.em-app *, .em-app *::before, .em-app *::after {
    box-sizing: border-box; margin: 0; padding: 0;
}
.em-app {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    color: var(--em-text);
    background: var(--em-bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Topnav ── */
.em-topnav {
    position: sticky; top: 0; z-index: 100;
    height: var(--em-nav-h);
    background: var(--em-bg-2);
    border-bottom: 1px solid var(--em-border);
    display: flex; align-items: center; padding: 0 24px; gap: 6px;
    box-shadow: var(--em-shadow);
}
.em-topnav-brand {
    display: flex; align-items: center; gap: 9px;
    font-weight: 700; font-size: 15px;
    color: var(--em-text); text-decoration: none;
    flex-shrink: 0; margin-right: 16px; letter-spacing: -.02em;
}
.em-topnav-brand-icon {
    width: 32px; height: 32px; border-radius: 9px;
    background: linear-gradient(135deg, var(--em-blue) 0%, var(--em-teal) 100%);
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; flex-shrink: 0;
    box-shadow: 0 0 14px rgba(59,130,246,.4);
}
.em-topnav-nav { display: flex; gap: 2px; flex: 1; }
.em-topnav-nav a {
    display: flex; align-items: center; gap: 5px;
    padding: 6px 12px; border-radius: var(--em-radius-xs);
    font-size: 14px; font-weight: 500; color: var(--em-text-2);
    text-decoration: none; transition: all .15s; white-space: nowrap;
}
.em-topnav-nav a:hover  { background: var(--em-surface-2); color: var(--em-text); }
.em-topnav-nav a.active { background: var(--em-blue-dim); color: var(--em-blue-b); font-weight: 600; }
.em-topnav-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.em-topnav-user { display: flex; align-items: center; gap: 8px; }
.em-topnav-user span { font-size: 13px; color: var(--em-muted); }
.em-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: linear-gradient(135deg, var(--em-blue), var(--em-purple));
    color: #fff; font-size: 12px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.em-theme-btn {
    width: 32px; height: 32px; border-radius: var(--em-radius-xs);
    background: var(--em-surface-2); border: 1px solid var(--em-border-2);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: 14px; transition: background .15s; flex-shrink: 0;
}
.em-theme-btn:hover { background: var(--em-surface-3); }
.em-mobile-menu-btn {
    display: none; background: none; border: none;
    cursor: pointer; font-size: 18px; color: var(--em-text-2); padding: 6px;
}
@media(max-width:900px) {
    .em-topnav-nav {
        display: none; position: absolute; top: var(--em-nav-h); left: 0; right: 0;
        background: var(--em-bg-2); border-bottom: 1px solid var(--em-border);
        flex-direction: column; padding: 8px; box-shadow: var(--em-shadow-md); z-index: 99;
    }
    .em-topnav-nav.open { display: flex; }
    .em-mobile-menu-btn { display: block; }
    .em-topnav-user span { display: none; }
}

/* ── Layout ── */
.em-main { max-width: 1380px; margin: 0 auto; padding: 28px 24px 56px; }
@media(max-width:768px) { .em-main { padding: 16px 16px 40px; } }

/* ── Paginakop ── */
.em-page-header { margin-bottom: 24px; }
.em-page-header h1 {
    font-size: 24px; font-weight: 700; color: var(--em-text);
    letter-spacing: -.03em; line-height: 1.2;
}
.em-page-header p { font-size: 14px; color: var(--em-muted); margin-top: 4px; }

/* ── Grid ── */
.em-grid   { display: grid; gap: 16px; }
.em-cols-4 { grid-template-columns: repeat(4,1fr); }
.em-cols-3 { grid-template-columns: repeat(3,1fr); }
.em-cols-2 { grid-template-columns: repeat(2,1fr); }
.em-span-2 { grid-column: span 2; }
.em-span-3 { grid-column: span 3; }
@media(max-width:1100px) {
    .em-cols-4 { grid-template-columns: repeat(2,1fr); }
    .em-cols-3 { grid-template-columns: repeat(2,1fr); }
    .em-span-3 { grid-column: span 2; }
}
@media(max-width:640px) {
    .em-cols-4,.em-cols-3,.em-cols-2 { grid-template-columns: 1fr; }
    .em-span-2,.em-span-3 { grid-column: span 1; }
}

/* ── Card ── */
.em-card {
    background: var(--em-surface);
    border: 1px solid var(--em-border);
    border-radius: var(--em-radius);
    padding: 20px 22px;
    box-shadow: var(--em-shadow);
}
.em-kpi-card.blue   { border-left: 3px solid var(--em-blue); }
.em-kpi-card.green  { border-left: 3px solid var(--em-green); }
.em-kpi-card.orange { border-left: 3px solid var(--em-orange); }
.em-kpi-card.teal   { border-left: 3px solid var(--em-teal); }

/* ── Sectietitel binnen kaart ── */
.em-card-title {
    font-size: 12px; font-weight: 600; letter-spacing: .06em;
    text-transform: uppercase; color: var(--em-muted);
    margin-bottom: 12px;
}
.em-card-icon {
    width: 36px; height: 36px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; margin-bottom: 12px; flex-shrink: 0;
}
.ic-blue   { background: var(--em-blue-dim); }
.ic-green  { background: var(--em-green-dim); }
.ic-orange { background: var(--em-orange-dim); }
.ic-teal   { background: var(--em-teal-dim); }
.ic-red    { background: var(--em-red-dim); }
.ic-yellow { background: var(--em-yellow-dim); }
.ic-purple { background: var(--em-purple-dim); }

/* ── KPI-waardes ── */
.em-kpi-val {
    font-family: var(--font-mono);
    font-size: 28px; font-weight: 500; line-height: 1.1;
    color: var(--em-text); letter-spacing: -.02em;
}
.em-kpi-unit { font-size: 13px; font-weight: 400; color: var(--em-muted); margin-left: 4px; }
.em-kpi-sub  { font-size: 13px; color: var(--em-muted); margin-top: 6px; }

/* ── Saldo (groot getal) ── */
.em-balance {
    font-family: var(--font-mono);
    font-size: 40px; font-weight: 600;
    line-height: 1; letter-spacing: -.03em;
}
.em-balance.pos { color: var(--em-green-b); }
.em-balance.neg { color: var(--em-red-b); }

/* ── Badges ── */
.em-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px; border-radius: 99px;
    font-size: 12px; font-weight: 600;
}
.em-badge-green  { background: var(--em-green-dim);  color: var(--em-green-b);  border: 1px solid rgba(16,185,129,.2); }
.em-badge-red    { background: var(--em-red-dim);    color: var(--em-red-b);    border: 1px solid rgba(239,68,68,.2); }
.em-badge-yellow { background: var(--em-yellow-dim); color: var(--em-orange-b); border: 1px solid rgba(234,179,8,.2); }
.em-badge-blue   { background: var(--em-blue-dim);   color: var(--em-blue-b);   border: 1px solid rgba(59,130,246,.2); }
.em-badge-orange { background: var(--em-orange-dim); color: var(--em-orange-b); border: 1px solid rgba(245,158,11,.2); }
.em-badge-teal   { background: var(--em-teal-dim);   color: var(--em-teal-b);   border: 1px solid rgba(6,182,212,.2); }
.em-badge-purple { background: var(--em-purple-dim); color: var(--em-purple);   border: 1px solid rgba(139,92,246,.2); }

/* ── Voortgangsbalk ── */
.em-progress-wrap { margin-top: 14px; }
.em-progress-label {
    display: flex; justify-content: space-between;
    font-size: 12px; color: var(--em-muted); margin-bottom: 6px;
}
.em-progress { height: 6px; background: var(--em-border); border-radius: 99px; overflow: hidden; }
.em-progress-fill { height: 100%; border-radius: 99px; transition: width .7s ease; }

/* ── Statrow ── */
.em-stat-row {
    display: grid; grid-template-columns: repeat(3,1fr); gap: 16px;
    padding-top: 14px; border-top: 1px solid var(--em-border); margin-top: 14px;
}
.em-stat-label { font-size: 12px; color: var(--em-muted); font-weight: 500; margin-bottom: 4px; }
.em-stat-val   { font-family: var(--font-mono); font-size: 18px; font-weight: 500; color: var(--em-text); }

/* ── Kostengrid ── */
.em-cost-grid {
    display: grid; grid-template-columns: repeat(4,1fr); gap: 12px;
    padding: 14px 16px; background: var(--em-surface-2);
    border-radius: var(--em-radius-sm); margin-bottom: 14px;
    border: 1px solid var(--em-border);
}
.em-cost-item-label { font-size: 12px; color: var(--em-muted); font-weight: 500; margin-bottom: 4px; }
.em-cost-item-val   { font-family: var(--font-mono); font-size: 17px; font-weight: 500; color: var(--em-text); }

/* ── Grafiekomslag ── */
.em-chart-wrap { position: relative; }
.em-chart-wrap.h240 { height: 240px; }
.em-chart-wrap.h300 { height: 300px; }
.em-chart-wrap.h360 { height: 360px; }

/* ── Tabel ── */
.em-table-wrap { overflow-x: auto; }
.em-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.em-table th {
    text-align: left; padding: 10px 14px;
    font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
    color: var(--em-muted); border-bottom: 1px solid var(--em-border);
    white-space: nowrap; background: var(--em-surface-2);
}
.em-table td {
    padding: 12px 14px; border-bottom: 1px solid var(--em-border);
    color: var(--em-text-2);
}
.em-table td strong { color: var(--em-text); }
.em-table tbody tr:hover td { background: var(--em-surface-2); color: var(--em-text); }
.em-table tfoot td {
    font-weight: 700; border-top: 2px solid var(--em-border-2);
    border-bottom: none; color: var(--em-text); background: var(--em-surface-2);
}
.em-table .num { text-align: right; font-family: var(--font-mono); font-size: 13px; }
.em-table .act { color: var(--em-green-b); font-weight: 600; }
.em-table .fct { color: var(--em-muted); }

/* Seizoensmarkeringen in tabel */
.em-season-winter td:first-child { border-left: 3px solid var(--em-blue); }
.em-season-spring td:first-child { border-left: 3px solid var(--em-green); }
.em-season-summer td:first-child { border-left: 3px solid var(--em-yellow); }
.em-season-autumn td:first-child { border-left: 3px solid var(--em-teal); }
.em-row-current td { background: rgba(59,130,246,.04) !important; }

/* ── Formulieren ── */
.em-form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.em-form-group label { font-size: 13px; font-weight: 600; color: var(--em-text-2); }
.em-form-group small { font-size: 12px; color: var(--em-muted); line-height: 1.5; }
.em-input, .em-select, .em-textarea {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--em-border-2);
    border-radius: var(--em-radius-sm);
    font-size: 14px; color: var(--em-text);
    background: var(--em-bg-2); font-family: var(--font);
    outline: none; transition: border-color .15s, box-shadow .15s;
}
.em-input:focus, .em-select:focus, .em-textarea:focus {
    border-color: var(--em-blue);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.em-input::placeholder { color: var(--em-muted); }
.em-select option { background: var(--em-surface-2); }
.em-textarea { resize: vertical; min-height: 80px; }
.em-form-row { display: grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: 12px; }
@media(max-width:480px) { .em-form-row { grid-template-columns: 1fr; } }

/* ── Knoppen ── */
.em-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px; border-radius: var(--em-radius-sm);
    font-size: 14px; font-weight: 600; font-family: var(--font);
    cursor: pointer; border: 1px solid transparent;
    transition: all .15s; text-decoration: none; white-space: nowrap;
}
.em-btn-primary { background: var(--em-blue); color: #fff; }
.em-btn-primary:hover { opacity: .88; }
.em-btn-success { background: var(--em-green); color: #fff; }
.em-btn-success:hover { opacity: .88; }
.em-btn-outline { background: transparent; color: var(--em-text-2); border-color: var(--em-border-2); }
.em-btn-outline:hover { background: var(--em-surface-2); color: var(--em-text); }
.em-btn-danger  { background: transparent; color: var(--em-red-b); border-color: var(--em-red-dim); }
.em-btn-danger:hover { background: var(--em-red-dim); }
.em-btn-sm   { padding: 5px 12px; font-size: 13px; }
.em-btn-full { width: 100%; justify-content: center; }

/* ── Meldingen ── */
.em-alert {
    padding: 11px 14px; border-radius: var(--em-radius-sm);
    font-size: 14px; margin-bottom: 14px;
    display: flex; align-items: flex-start; gap: 9px; line-height: 1.5;
}
.em-alert-success { background: var(--em-green-dim); color: var(--em-green-b); border: 1px solid rgba(16,185,129,.2); }
.em-alert-error   { background: var(--em-red-dim);   color: var(--em-red-b);   border: 1px solid rgba(239,68,68,.2); }
.em-alert-info    { background: var(--em-blue-dim);  color: var(--em-blue-b);  border: 1px solid rgba(59,130,246,.2); }
.em-alert-warn    { background: var(--em-yellow-dim);color: var(--em-orange-b);border: 1px solid rgba(234,179,8,.2); }

/* ── Inzicht-kaart ── */
.em-insight {
    display: flex; align-items: flex-start; gap: 11px;
    padding: 12px 14px; border-radius: var(--em-radius-sm);
    background: var(--em-blue-dim); border: 1px solid rgba(59,130,246,.15);
    font-size: 13px; color: var(--em-text-2); line-height: 1.6;
    margin-bottom: 10px;
}
.em-insight .icon { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.em-insight.warn  { background: var(--em-yellow-dim); border-color: rgba(234,179,8,.18); }
.em-insight.good  { background: var(--em-green-dim);  border-color: rgba(16,185,129,.18); }

/* ── Salderingsmelding ── */
.em-saldering-notice {
    padding: 10px 14px;
    border-radius: 0 var(--em-radius-sm) var(--em-radius-sm) 0;
    border: 1px solid rgba(234,179,8,.2);
    border-left: 3px solid var(--em-yellow);
    background: var(--em-yellow-dim); color: var(--em-orange-b);
    font-size: 13px; margin-bottom: 18px; line-height: 1.5;
}

/* ── Betrouwbaarheidsbalk ── */
.em-conf-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.em-conf-bar { flex: 1; height: 5px; background: var(--em-border); border-radius: 99px; overflow: hidden; }
.em-conf-fill { height: 100%; border-radius: 99px; transition: width .7s ease; }

/* ── CO₂ ── */
.em-co2-grid { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 12px; }
.em-co2-item .big { font-family: var(--font-mono); font-size: 22px; font-weight: 500; color: var(--em-text); }
.em-co2-item .lbl { font-size: 12px; color: var(--em-muted); margin-top: 1px; }

/* ── Scheider ── */
.em-divider { border: none; border-top: 1px solid var(--em-border); margin: 16px 0; }

/* ── Prognose-legenda ── */
.em-fc-legend {
    display: flex; gap: 14px; font-size: 12px; color: var(--em-muted); align-items: center;
}
.em-fc-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.em-fc-dot.measured { background: var(--em-green-b); }
.em-fc-dot.forecast { background: var(--em-muted); }
.em-fc-dot.current  { background: var(--em-blue-b); }

/* ── Upload zone ── */
.em-upload-zone {
    border: 2px dashed var(--em-border-2); border-radius: var(--em-radius);
    padding: 28px; text-align: center; cursor: pointer;
    transition: border-color .2s, background .2s; background: var(--em-surface-2);
}
.em-upload-zone:hover, .em-upload-zone.dragover {
    border-color: var(--em-blue); background: var(--em-blue-dim);
}
.em-upload-zone input { display: none; }
.em-upload-zone p { font-size: 13px; color: var(--em-muted); }

/* ── Spinner ── */
.em-spinner {
    display: inline-block; width: 13px; height: 13px;
    border: 2px solid rgba(255,255,255,.2); border-top-color: currentColor;
    border-radius: 50%; animation: em-spin .6s linear infinite;
}
@keyframes em-spin { to { transform: rotate(360deg); } }

/* ── Auth ── */
.em-auth-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: var(--em-bg); padding: 24px;
}
.em-auth-card {
    background: var(--em-surface); border: 1px solid var(--em-border);
    border-radius: 16px; padding: 40px; width: 100%; max-width: 400px;
    box-shadow: var(--em-shadow-lg);
}
.em-auth-logo {
    width: 50px; height: 50px; border-radius: 14px;
    background: linear-gradient(135deg, var(--em-blue), var(--em-teal));
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; color: #fff; margin: 0 auto 20px;
}
.em-auth-card h2 { text-align: center; font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.em-auth-card p  { text-align: center; font-size: 13px; color: var(--em-muted); margin-bottom: 24px; }
.em-auth-error {
    background: var(--em-red-dim); color: var(--em-red-b);
    border: 1px solid rgba(239,68,68,.2); border-radius: 8px;
    padding: 10px 14px; font-size: 13px; margin-bottom: 14px; text-align: center;
}
.em-auth-footer { text-align: center; margin-top: 18px; font-size: 12px; color: var(--em-muted); }

/* ── QR/MFA ── */
.em-qr-box {
    border: 1px solid var(--em-border); border-radius: 10px;
    padding: 20px; text-align: center; margin: 14px 0; background: var(--em-bg-2);
}
.em-secret-code {
    font-family: var(--font-mono); font-size: 13px; letter-spacing: .12em;
    background: var(--em-bg); border: 1px solid var(--em-border);
    border-radius: 6px; padding: 8px 14px; display: inline-block;
    user-select: all; word-break: break-all; color: var(--em-teal-b);
}

/* ── Vattenfall schalen tabel ── */
.em-vattenfall-table { width: 100%; font-size: 13px; }
.em-vattenfall-table td, .em-vattenfall-table th { padding: 6px 10px; }
.em-vattenfall-row-active { background: var(--em-blue-dim) !important; font-weight: 600; }
.em-vattenfall-row-active td { color: var(--em-blue-b) !important; }

/* ── Licht-thema aanpassingen ── */
.em-app.em-light .em-input,
.em-app.em-light .em-select,
.em-app.em-light .em-textarea { background: #fff; }
.em-app.em-light .em-table th { background: var(--em-surface-3); }
.em-app.em-light .em-cost-grid { background: var(--em-surface-3); }
.em-app.em-light .em-upload-zone { background: var(--em-surface-3); }
