/* ==========================================================================
   stijl.css — opmaak van Omgeving

   Opbouw (volgt index.html):
     1. Algemeen          basis, formulierelementen, knoppen, labels
     2. Pagina-indeling   kolommen en scheidingslijnen
     3. Linkerkolom       modus-tabs, Modelleren, Videometen, Project
     4. Diagrammen        kolom 2
     5. Spreadsheet       kolom 3
     6. Dialogen          in de volgorde van index.html

   Let op: diagram.css wordt ná dit bestand geladen en wint bij gelijke
   specificiteit. Kleurcode: modelleren = rood, videometen = blauw, rest neutraal.
   ========================================================================== */


/* ==========================================================================
   1. ALGEMEEN
   ========================================================================== */

[hidden] { display: none !important; }
body:not(.geavanceerd) .alleen-geavanceerd { display: none !important; }

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-y: auto;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.4;
    background-color: #f0f2f5;
}
@media (min-width: 1000px) {
    html, body { overflow: hidden; }
}

/* ---- Fieldset en legend ---- */
fieldset {
    border: 1px solid #d1d1d1;
    border-radius: 6px;
    background: white;
    margin-bottom: 12px;
    padding: 8px 12px;
    position: relative;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
legend {
    font-size: 0.95rem;
    font-weight: 700;
    color: #444;
    padding: 0 5px;
    min-width: 100px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
legend > span:first-child {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ---- Dialoog (basis; per dialoog verfijnd in sectie 6) ---- */
dialog {
    border: 1px solid #d1d1d1;
    border-radius: 8px;
    padding: 0;
    background: #fff;
    max-width: 450px;
    width: 90%;
    margin: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    overflow: hidden;
    will-change: transform;                  /* soepel verplaatsen via de legend */
}
dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
dialog fieldset {
    margin: 0;
    border: none;
    box-shadow: none;
    padding: 15px;
}
dialog legend {                              /* de legend is het sleephandvat (zie project.js) */
    user-select: none;
    cursor: move;
}

/* ---- Labels en invoervelden ---- */
label {
    display: block;
    margin-top: 4px;
    margin-bottom: 2px;
    font-weight: 600;
    font-size: 0.8rem;
    color: #666;
    letter-spacing: 0.02em;
}
input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 6px 8px;
    margin-top: 2px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 14px;
    color: #333;
    background-color: #fff;
}
select { height: 32px; }
input:focus, select:focus {
    border-color: #007bff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.1);
}
input:focus::placeholder { color: transparent; }

/* ---- Knoppen ---- */
button.dialog-btn {
    width: 100%;
    padding: 8px;
    background-color: #f8f9fa;
    color: #666;
    border: 1px dashed #bbb;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
button.dialog-btn:hover {
    background-color: #e9ecef;
    border-color: #999;
    color: #333;
}
button.dialog-btn:disabled { opacity: 0.45; cursor: default; }
button.dialog-btn:disabled:hover {
    background-color: #f8f9fa;
    border-color: #bbb;
    color: #666;
}
button.dialog-btn.met-icoon {                /* knop met icoon + tekst */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
button.dialog-btn.met-icoon svg { flex: 0 0 auto; }
button.dialog-btn.actief {                   /* actief (stap of geopend venster): lichtblauw */
    background-color: #e3f2fd;
    color: #0b5cad;
    border-color: #90caf9;
    font-weight: 700;
}
button.dialog-btn.actief:hover:not(:disabled) {
    background-color: #d0e7fb;
    border-color: #0077bb;
    color: #064a8c;
}

button.formsubmit {
    width: 100%;
    padding: 10px;
    background-color: #f1f3f5;
    color: #333;
    border: 1px dashed #bbb;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 750;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 10px;
}
button.formsubmit:hover { background-color: #e2e6ea; border-color: #999; color: #111; }

.button-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}
.button-group button {
    flex: 1;
    margin: 0;
    width: auto;
}

.dg-rechts { margin-left: auto; }            /* duwt een knop naar rechts in een werkbalk */

/* ---- Kleine hulpklassen ---- */
.remove-icon {
    font-size: 18px;
    color: #bbb;
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s ease;
    padding-left: 10px;
}
.remove-icon:hover { color: #d9534f; }

.fieldset-link {
    display: inline-block;
    margin-top: -4px;
    font-size: 0.9rem;
    font-style: italic;
    color: #007bff;
    text-decoration: none;
    cursor: pointer;
}
.fieldset-link:hover { text-decoration: underline; }

.figuur-overzicht {
    font-size: 0.85rem;
    color: #555;
    line-height: 1.6;
    margin: 5px 0 12px 0;
}

.model-melding {                             /* waarschuwing/foutmelding (ook buiten Modelleren) */
    font-size: 0.8rem;
    color: #7a5b00;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 4px;
    padding: 4px 8px;
    margin: 6px 0;
}

.placeholder {
    flex: 1;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 0.85rem;
    font-style: italic;
    border: 1px dashed #ccc;
    border-radius: 4px;
    background: #fafafa;
}

.dialog-ruimte { height: 10px; }

/* Herkomstlabels (model / video / ƒx) in spreadsheet en dialogen */
.kol-bron {
    display: inline-block;
    padding: 0 5px;
    border-radius: 3px;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: 0.02em;
    vertical-align: baseline;
}
.kol-bron.bron-model { background: #fbe9e7; color: #b71c1c; border: 1px solid #f5c6cb; }
.kol-bron.bron-video { background: #e3f2fd; color: #0b5cad; border: 1px solid #b6d4fe; }
.kol-bron.bron-fx    { background: #f3e8ff; color: #6b21a8; border: 1px solid #d8b4fe; font-style: italic; }


/* ==========================================================================
   2. PAGINA-INDELING
   ========================================================================== */

.main-container {
    box-sizing: border-box;
    max-width: 100%;
    display: block;                          /* mobiel: alles onder elkaar */
    padding: 10px;                           /* layout.js rekent met deze 10 px */
}
@media (min-width: 1000px) {
    .main-container {
        display: flex;                       /* desktop: kolommen naast elkaar */
        height: 100vh;
        gap: 15px;
        overflow: hidden;
    }
}

.kolom {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.kolom > fieldset {
    margin-bottom: 12px;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.kolom > fieldset:last-child { margin-bottom: 0; }
.vul { flex: 1 1 0; }

#kolom-model      { flex: 0 0 500px; overflow-y: auto; }
#kolom-diagrammen { flex: 1 1 0; }
#kolom-sheet      { flex: 0 0 40%; }

@media (min-width: 1000px) {
    #kolom-model { min-width: 500px; }       /* vier knoppen naast elkaar moeten passen */
    #kolom-model, #kolom-sheet { max-width: 50%; }
}
@media (max-width: 999px) {
    .kolom { flex: none !important; margin-bottom: 12px; }
    .kolom > fieldset.vul { flex: none !important; }
    .placeholder { min-height: 220px; }
}

/* ---- Scheidingslijnen (verticaal: kolommen; horizontaal: diagram 1/2) ---- */
.scheiding { position: relative; z-index: 5; touch-action: none; }
.scheiding::after {
    content: "";
    position: absolute;
    background: #d1d1d1;
    border-radius: 2px;
    transition: background .15s;
}
.scheiding:hover::after,
.scheiding:focus-visible::after,
.scheiding.actief::after { background: #007bff; }
.scheiding:focus-visible { outline: none; }

#scheiding-v, #scheiding-m {
    flex: 0 0 8px;
    margin: 0 -4px;
    cursor: col-resize;
    display: none;                           /* alleen op desktop */
}
#scheiding-v::after, #scheiding-m::after { top: 0; bottom: 12px; left: 3px; width: 2px; }
#scheiding-h { flex: 0 0 12px; cursor: row-resize; }
#scheiding-h::after { left: 0; right: 0; top: 5px; height: 2px; }

@media (min-width: 1000px) {
    #scheiding-v, #scheiding-m { display: block; }
}
@media (max-width: 999px) {
    #scheiding-h { display: none; }
}

body.slepen-v { cursor: col-resize; user-select: none; }
body.slepen-h { cursor: row-resize; user-select: none; }


/* ==========================================================================
   3. LINKERKOLOM
   ========================================================================== */

/* ---- 3a. Modus-tabs en schakelaar 'Alle instellingen tonen' ---- */
#modus-balk { margin-bottom: 8px; flex: 0 0 auto; }
#modus-balk .modus-tab { border-color: #d1d1d1; font-size: 0.85rem; }
#modus-balk .modus-tab[data-modus="model"].actief { background: #fbe9e7; border-color: #d62728; color: #b71c1c; }
#modus-balk .modus-tab[data-modus="video"].actief { background: #e3f2fd; border-color: #0077bb; color: #0b5cad; }

.niveau-schakelaar {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex: 0 0 auto;
    margin: 0 0 0 auto;
    white-space: nowrap;
    font-size: 0.8rem;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    user-select: none;
}
.niveau-schakelaar input { position: absolute; opacity: 0; width: 0; height: 0; }
.niveau-schakelaar .schuif {
    position: relative;
    flex: 0 0 auto;
    width: 30px;
    height: 17px;
    border-radius: 17px;
    background: #ccc;
    transition: background .2s;
}
.niveau-schakelaar .schuif::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #fff;
    transition: transform .2s;
}
.niveau-schakelaar input:checked + .schuif { background: #444; }
.niveau-schakelaar input:checked + .schuif::before { transform: translateX(13px); }
.niveau-schakelaar input:focus-visible + .schuif { outline: 2px solid #007bff; outline-offset: 2px; }

/* Panelen krimpen nooit onder hun inhoud */
#paneel-model, #paneel-video, #paneel-project { flex: 0 0 auto; }

/* ---- 3b. Paneel Modelleren (rood) ---- */
#paneel-model > legend::before,
#paneel-video > legend::before {             /* kleurpuntje voor de titel; verwijder dit blok om het uit te zetten */
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}
#paneel-model > legend::before { background: #d62728; }
#paneel-video > legend::before { background: #0077bb; }

.model-velden { display: flex; gap: 10px; }
.model-veld { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
.model-veld label { margin: 0 0 4px; font-size: 0.85rem; }
.model-veld textarea {
    width: 100%;
    box-sizing: border-box;
    height: 300px;
    min-height: 120px;
    resize: vertical;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.4;
    color: #333;
    background: #fff;
    tab-size: 2;
    white-space: pre;                        /* geen regelafbreking: inspringing blijft zichtbaar */
    overflow: auto;
}
.model-veld textarea:focus {
    border-color: #007bff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.1);
}
@media (min-width: 1000px) {
    .model-veld textarea { height: 46vh; }
}

.model-knoppen { margin-top: 10px; margin-bottom: 0; }
.model-knoppen .formsubmit { flex: 2; font-size: 0.9rem; }
.model-status { font-size: 0.8rem; color: #666; margin-top: 8px; }

#model-run { background-color: #fbe9e7; color: #b71c1c; border-color: #f0b4ae; }
#model-run:hover { background-color: #f8d7d2; border-color: #d62728; color: #8e1212; }
#model-run svg { display: block; margin: 0 auto; }
#model-run .ring-voortgang { transition: stroke-dashoffset .1s linear; }

/* De Instellingen-knop van het model is rood (de knoppen van video zijn blauw, zie sectie 1) */
#paneel-model button.dialog-btn.actief { background-color: #fbe9e7; color: #b71c1c; border-color: #f0b4ae; }
#paneel-model button.dialog-btn.actief:hover:not(:disabled) { background-color: #f8d7d2; border-color: #d62728; color: #8e1212; }

/* Tijdens het rekenen: interface geblokkeerd (attribuut inert), run-knop wordt voortgangsring */
body.model-bezig { cursor: progress; }
body.model-bezig [inert] { opacity: .55; transition: opacity .15s; }
body.model-bezig #model-run { cursor: pointer; }

/* ---- 3c. Paneel Videometen (blauw) ---- */
.vid-statusregel { font-size: 0.78rem; color: #666; margin: 0 0 4px; min-height: 1.3em; }
.vid-statusregel .dg-info { margin-left: 0; font-size: inherit; }

.vid-vlak {
    position: relative;
    width: 100%;
    aspect-ratio: var(--vid-ar, 16 / 9);
    max-height: 30vh;
    border: 1px solid #e3e3e3;
    border-radius: 4px;
    background: #111;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.vid-vlak .placeholder {
    width: 100%;
    height: 100%;
    min-height: 0;
    border: none;
    border-radius: 0;
}
.vid-vlak video,
.vid-vlak svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.vid-vlak video { object-fit: contain; pointer-events: none; }
.vid-vlak svg { cursor: default; touch-action: none; user-select: none; }
.vid-vlak.meet-actief,
.vid-vlak.meet-actief svg { cursor: crosshair; }
.vid-handvat { cursor: grab; }
.vid-handvat:active,
.vid-vlak.sleept,
.vid-vlak.sleept svg,
.vid-vlak.sleept .vid-handvat { cursor: grabbing; }

.vid-loep-canvas {
    position: absolute;
    z-index: 4;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.45);
    pointer-events: none;
    background: #111;
}

.vid-placeholder-box {                       /* getoond bij een geïmporteerd project zonder gekoppelde video */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px;
    max-width: 340px;
    text-align: center;
    font-style: normal;
    color: #444;
}
.vid-placeholder-box strong { color: #111; word-break: break-all; }
.vid-placeholder-sub { font-size: 0.78rem; color: #666; line-height: 1.35; }
.vid-placeholder-box button.dialog-btn { width: auto; margin-top: 4px; padding: 6px 14px; border-style: solid; }

.vid-tijdbalk-groep {
    flex: 0 0 auto;
    margin-top: 6px;
    border: 1px solid #d9dee3;
    border-radius: 4px;
    background: #f8f9fa;
    overflow: hidden;
}
#vid-tijdbalk {
    display: block;
    width: 100%;
    height: 48px;
    cursor: pointer;
    touch-action: none;
    user-select: none;
}

/* Objectknoppen (kolom en losgekoppeld venster) */
.vm-obj-groep { display: inline-flex; align-items: center; gap: 4px; }
.vm-obj-knop { width: auto; padding: 0 9px; border-color: #d1d1d1; font-size: 0.78rem; }
.vm-obj-knop.obj-1 { color: #0077bb; }
.vm-obj-knop.obj-1.actief { background: #e3f2fd; border-color: #0077bb; color: #005588; }
.vm-obj-knop.obj-2 { color: #2e7d32; }
.vm-obj-knop.obj-2.actief { background: #e8f5e9; border-color: #2e7d32; color: #1b5e20; }

/* Vier hoofdknoppen onder de video: Video · Voorbereiden · Instellingen · Meten */
#paneel-video .vid-knoppen {
    margin-top: 8px;
    margin-bottom: 0;
    gap: 6px;
    flex-wrap: nowrap;
}
#paneel-video .vid-knoppen button {
    flex: 1 1 auto;
    min-width: 0;
    padding: 8px 6px;
    font-size: 0.82rem;
    white-space: nowrap;
}

/* ---- 3d. Paneel Project ---- */
#paneel-project { overflow-y: auto; }
.project-rij { display: flex; align-items: center; gap: 8px; }
.project-rij input[type="text"] { flex: 1 1 0; width: auto; min-width: 0; margin: 0; }
.project-rij button.dialog-btn { flex: 0 0 auto; width: auto; padding: 7px 10px; font-size: 0.82rem; margin: 0; }
.project-status { margin-top: 6px; font-size: 0.78rem; color: #777; }


/* ==========================================================================
   4. DIAGRAMMEN (kolom 2)
   Werkbalk, tekenvlak en dialogen: zie ook diagram.css
   ========================================================================== */

.open-rij { margin: 2px 4px 8px; }
.open-rij:last-child { margin: 8px 4px 0; }
#kolom-diagrammen > fieldset { margin-bottom: 0; }

/* Slotje voor de askoppeling, midden op de horizontale scheidingslijn */
.koppel-zoom-knop {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 6;
    width: 26px;
    height: 20px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    color: #666;
    border: 1px solid #d1d1d1;
    border-radius: 10px;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.koppel-zoom-knop:hover { background: #eef3f8; border-color: #999; color: #333; }
.koppel-zoom-knop:focus-visible { outline: 2px solid #007bff; }
.koppel-zoom-knop.actief { background: #e3f0fd; border-color: #2b7bd6; color: #0b5cad; }

/* Diagram links, verticale run-knopjes rechts */
.dg-inhoud { flex: 1 1 0; min-height: 0; display: flex; gap: 6px; align-items: stretch; }
@media (max-width: 999px) { .dg-inhoud { flex: none; } }

.dg-runs {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    overflow-y: auto;
    padding: 1px 0;
}
.dg-runs-sep { width: 16px; height: 1px; background: #d1d1d1; margin: 1px 0; flex: 0 0 auto; }

.dg-run-knop {
    width: 24px;
    height: 24px;
    padding: 0;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    color: #666;
    border: 1px solid #d1d1d1;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.dg-run-knop:hover { background: #eef3f8; border-color: #999; color: #333; }
.dg-run-knop:focus-visible { outline: 2px solid #007bff; }
.dg-run-knop.actief { background: #d6dce2; border-color: #7d8792; color: #111; }
.dg-run-knop.actief:hover { background: #cad1d8; border-color: #5f6973; }

/* Kleur per bron: uit = zacht getint, aan = sterker getint */
.dg-run-knop[data-run-soort="model"] { background: #fdf1ef; border-color: #f0c4c0; color: #b71c1c; }
.dg-run-knop[data-run-soort="model"]:hover { background: #fbe0dc; border-color: #d62728; }
.dg-run-knop[data-run-soort="model"].actief { background: #f8cfca; border-color: #d62728; color: #8e1212; }
.dg-run-knop[data-run-soort="model"].actief:hover { background: #f4bbb4; }
.dg-run-knop[data-run-soort="video"] { background: #eef6fd; border-color: #b6d4fe; color: #0b5cad; }
.dg-run-knop[data-run-soort="video"]:hover { background: #d7eafb; border-color: #0077bb; }
.dg-run-knop[data-run-soort="video"].actief { background: #bddcf7; border-color: #0077bb; color: #064a8c; }
.dg-run-knop[data-run-soort="video"].actief:hover { background: #a9d0f3; }

/* Werkbalkknoppen: hover per bron; 'meetpunten tonen' is rood als hij aan staat */
.dg-knop[data-act="opmaak"]:hover { background: #e3f2fd; border-color: #0077bb; }
.dg-knop[data-act="lijn"]:hover,
.dg-knop[data-act="punten"]:hover { background: #fbe9e7; border-color: #d62728; }
.dg-knop[data-act="punten"].actief { background: #fbe9e7; border-color: #d62728; color: #b71c1c; }


/* ==========================================================================
   5. SPREADSHEET (kolom 3)
   ========================================================================== */

.sheet-balk {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 10px;
    margin-bottom: 8px;
}
.sheet-balk select { width: auto; min-width: 150px; margin-top: 0; }
.berekening-knoppen { flex-wrap: wrap; }
.fx-knop-tekst { font-style: italic; font-weight: 800; font-size: 0.85rem; letter-spacing: -0.03em; }

/* Knoppen: neutraal; hover lichtgrijs; verwijderknoppen hover lichtrood */
#kolom-sheet .dg-knop:hover:not(:disabled) { background: #e9ecef; border-color: #999; }
#kolom-sheet .dg-knop.actief { background: #e9ecef; border-color: #999; color: #333; }
#kolom-sheet :is(#bew-deze, #bew-oudere, #bew-alles, #sel-del-kol, #sel-del-rij):hover:not(:disabled) {
    background: #fbe9e7;
    border-color: #d62728;
    color: #b71c1c;
}

.zoom-groep { display: flex; align-items: center; gap: 4px; }
.zoom-groep button {
    width: 30px;
    height: 30px;
    padding: 0;
    background: #f8f9fa;
    color: #666;
    border: 1px dashed #bbb;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .2s;
}
.zoom-groep button:hover { background: #e9ecef; border-color: #999; color: #333; }
.zoom-groep #zoom-waarde { width: auto; min-width: 48px; font-size: 0.8rem; font-weight: 600; border: none; background: none; }

.sheet-scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
    overflow-anchor: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
}
.sheet-scroll:focus { outline: none; border-color: #8bb9fe; }
@media (max-width: 999px) {
    .sheet-scroll { height: 360px; flex: none; }
}

/* ---- Tabel (vaste kolommen; alleen zichtbare rijen staan in de DOM) ---- */
#sheet {
    --zoom: 1;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: calc(13px * var(--zoom));
    color: #333;
    user-select: none;
    -webkit-user-select: none;
}
#sheet col.c-kop  { width: 2.5em; }
#sheet col.c-data { width: 9em; }
#sheet th, #sheet td {
    border: 1px solid #e3e3e3;
    padding: 0.25em 0.5em;
    min-width: 5.5em;
    height: 1.6em;
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Kopregel */
#sheet thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f1f3f5;
    color: #666;
    font-weight: 600;
    text-align: center;
    vertical-align: top;
}
#sheet thead th:first-child { left: 0; z-index: 3; min-width: 2.5em; }
#sheet thead th .kol-naam {
    display: block;
    font-size: 1.1em;
    font-weight: 700;
    color: #333;
    max-width: 12em;
    overflow: hidden;
    text-overflow: ellipsis;
}
#sheet thead th small {
    display: block;
    font-size: 0.75em;
    font-weight: 400;
    color: #888;
    max-width: 12em;
    overflow: hidden;
    text-overflow: ellipsis;
}
#sheet thead th .kol-bron { font-size: 0.85em; padding: 0 0.35em; }
#sheet thead th.bron-kop-model { box-shadow: inset 0 2px 0 #d62728; }
#sheet thead th.bron-kop-video { box-shadow: inset 0 2px 0 #0077bb; }

/* Rijkoppen en lege tussenrijen */
#sheet tbody th {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #f1f3f5;
    color: #666;
    font-weight: 600;
    min-width: 2.5em;
    text-align: center;
}
#sheet tr.sp td { padding: 0; border: 0; height: auto; min-width: 0; background: none; }
#sheet tr.sp td:hover { background: none; }

/* Cursors en hover */
#sheet thead th[data-kol],
#sheet thead th[data-hoek],
#sheet tbody th[data-rij] { cursor: pointer; }
#sheet td[data-c] { cursor: cell; }
#sheet td:hover { background: #eef3f8; }

/* Celselectie (de randen worden per cel via --st/--sb/--sl/--sr gezet door spreadsheet.js) */
#sheet thead th.kop-sel,
#sheet tbody th.kop-sel { background: #dbeafe; color: #0b5cad; }
#sheet td.sel {
    background: rgba(11, 92, 173, 0.11);
    box-shadow:
        inset 0 calc(var(--st, 0) * 1.5px) 0 var(--sk, #0b5cad),
        inset 0 calc(var(--sb, 0) * -1.5px) 0 var(--sk, #0b5cad),
        inset calc(var(--sl, 0) * 1.5px) 0 0 var(--sk, #0b5cad),
        inset calc(var(--sr, 0) * -1.5px) 0 0 var(--sk, #0b5cad);
}
#sheet td.sel:hover { background: rgba(11, 92, 173, 0.16); }
#sheet.gekopieerd td.sel { background: #e8f5e9; --sk: #2e7d32; }


/* ==========================================================================
   6. DIALOGEN (volgorde van index.html)
   ========================================================================== */

/* ---- Losgekoppeld diagram (modaal) ---- */
.dg-los-run { font-size: 0.78rem; font-weight: 600; color: #444; padding: 0 4px; white-space: nowrap; }

#diagram-los-dialog[open] {
    width: min(80vw, 1000px);
    height: min(86vh, 760px);
    min-width: 420px;
    min-height: 320px;
    max-width: 96vw;
    max-height: 94vh;
    resize: both;
    overflow: hidden;
    border-radius: 8px 8px 2px 8px;
    display: flex;
    flex-direction: column;
}
#diagram-los-dialog fieldset {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 10px 14px 14px;
}
#diagram-los-dialog legend { width: 100%; box-sizing: border-box; margin-bottom: 4px; }
#diagram-los-dialog .dg-balk { flex: 0 0 auto; }
#diagram-los-dialog .dg-inhoud,
#diagram-los-dialog .dg-vlak { flex: 1 1 0; min-height: 0; aspect-ratio: auto; }

/* ---- Instellingen model (rood) ---- */
#instellingen-dialog button.formsubmit { background-color: #fbe9e7; color: #b71c1c; border-color: #f0b4ae; }
#instellingen-dialog button.formsubmit:hover { background-color: #f8d7d2; border-color: #d62728; color: #8e1212; }

/* ---- Regressie ----
   LET OP: deze twee regels (grijs i.p.v. groen) hebben nu geen effect: diagram.css wordt later
   geladen met dezelfde specificiteit en zet de gekozen optie weer op groen. */
.reg-optie.actief { background: #e9ecef; border-color: #888; }
.reg-optie.actief .reg-naam { color: #111; }
.reg-optie-links input[type="radio"] { accent-color: #555; }

/* ---- Instellingen videometen, Opmaak meetpunten, Groot videovenster: blauw ---- */
#video-instellingen-dialog button.formsubmit,
#opmaak-dialog button.formsubmit,
#video-meet-dialog button.formsubmit { background-color: #e3f2fd; color: #0b5cad; border-color: #90caf9; }
#video-instellingen-dialog button.formsubmit:hover,
#opmaak-dialog button.formsubmit:hover,
#video-meet-dialog button.formsubmit:hover { background-color: #d0e7fb; border-color: #0077bb; color: #064a8c; }

/* ---- Losgekoppeld videovenster (niet-modaal, verplaatsbaar via legend, schaalbaar rechtsonder) ---- */
#video-meet-dialog[open] {
    position: fixed;
    top: 4vh;
    left: 12px;
    margin: 0;
    width: min(62vw, 980px);
    height: 88vh;
    min-width: 380px;
    min-height: 300px;
    max-width: 96vw;
    max-height: 94vh;
    resize: both;
    overflow: hidden;
    z-index: 40;
    border-radius: 8px 8px 2px 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.28);
    display: flex;
    flex-direction: column;
}
#video-meet-dialog fieldset {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 10px 14px 14px;
}
#video-meet-dialog legend { width: 100%; box-sizing: border-box; margin-bottom: 4px; }
.vid-meet-balk { flex: 0 0 auto; }
.vm-klaar {
    width: auto !important;
    padding: 6px 14px !important;
    margin: 0 0 0 8px !important;
    font-size: 0.85rem !important;
}
.vid-dialog-houder { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
.vid-vlak.in-venster { flex: 1 1 0; min-height: 0; max-height: none; aspect-ratio: auto; }

/* ---- Kolommen kiezen ---- */
.kol-groep {
    border: 1px solid #e3e3e3;
    border-radius: 5px;
    padding: 8px 10px;
    margin-bottom: 8px;
    background: #fafafa;
}
.kol-groep-kop {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #444;
}
.kol-groep-acties { display: inline-flex; gap: 8px; font-weight: 400; }
.kol-groep-acties a { font-size: 0.76rem; color: #007bff; text-decoration: none; cursor: pointer; }
.kol-groep-acties a:hover { text-decoration: underline; }
.kol-lijst {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
    gap: 4px 8px;
    max-height: 36vh;
    overflow-y: auto;
}
.kol-keuze {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 3px 6px;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    background: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    user-select: none;
}
.kol-keuze:hover { background: #eef3f8; border-color: #bbb; }
.kol-keuze input { margin: 0; cursor: pointer; }

/* ---- Kolom berekenen (ƒx); kleur volgt data-soort (gezet door spreadsheet.js) ---- */
#formule-dialog { max-width: 560px; max-height: 90vh; }
#formule-dialog fieldset { max-height: 90vh; overflow-y: auto; box-sizing: border-box; }

.fm-bron-balk { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 0.82rem; color: #555; }
.fm-bron-knop {
    padding: 4px 10px;
    border: 1px solid #d1d1d1;
    border-radius: 4px;
    background: #f8f9fa;
    font-size: 0.8rem;
    font-weight: 600;
    color: #555;
    cursor: pointer;
}
.fm-bron-knop:hover { background: #eef3f8; border-color: #999; }
.fm-bron-knop.actief { background: #e8f5e9; border-color: #81c784; color: #1b5e20; font-weight: 700; }
.fm-bron-knop[data-fm-soort="model"].actief { background: #fbe9e7; border-color: #d62728; color: #b71c1c; }
.fm-bron-knop[data-fm-soort="video"].actief { background: #e3f2fd; border-color: #0077bb; color: #0b5cad; }

.fm-lijst { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 10px; max-height: 22vh; overflow-y: auto; }
.fm-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fafafa;
    font-size: 0.83rem;
    cursor: pointer;
}
.fm-item:hover { background: #eef3f8; border-color: #aaa; }
.fm-item.actief { background: #e8f5e9; border-color: #81c784; }
.fm-item code { font-family: Consolas, "Courier New", monospace; font-size: 0.82rem; color: #333; }
#formule-dialog[data-soort="model"] .fm-item.actief { background: #fbe9e7; border-color: #e57373; }
#formule-dialog[data-soort="video"] .fm-item.actief { background: #e3f2fd; border-color: #64b5f6; }

.fm-invoer-blok {
    border: 1px solid #e3e3e3;
    border-radius: 5px;
    padding: 8px 10px;
    background: #fafafa;
    margin-bottom: 8px;
}
.fm-kop { font-size: 0.8rem; font-weight: 700; color: #444; margin-bottom: 4px; }
.fm-invoer-rij { display: flex; align-items: flex-end; gap: 6px; }
.fm-veld-naam { flex: 0 0 115px; }
.fm-veld-expr { flex: 1 1 0; min-width: 0; }
.fm-veld-naam input, .fm-veld-expr input { font-family: Consolas, "Courier New", monospace; }
.fm-is { padding-bottom: 6px; font-weight: 700; color: #555; font-size: 1rem; }

.fm-chips-blok { margin-top: 7px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.fm-chips-label { font-size: 0.75rem; color: #666; }
.fm-chips { display: flex; flex-wrap: wrap; gap: 4px; }
button.fm-chip {
    padding: 2px 7px;
    border: 1px solid #ced4da;
    border-radius: 3px;
    background: #fff;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.76rem;
    font-weight: 600;
    color: #333;
    cursor: pointer;
}
button.fm-chip:hover { background: #e3f0fd; border-color: #2b7bd6; color: #0b5cad; }
button.fm-chip.chip-const { background: #fff8e1; border-color: #ffe082; color: #6d4c00; }
button.fm-chip.chip-const:hover { background: #ffecb3; border-color: #ffb300; }

.fm-knoppen { margin-top: 8px; margin-bottom: 8px; }
#formule-dialog[data-soort="model"] #fm-opslaan { background-color: #fbe9e7; color: #b71c1c; border-color: #f0b4ae; }
#formule-dialog[data-soort="model"] #fm-opslaan:hover { background-color: #f8d7d2; border-color: #d62728; color: #8e1212; }
#formule-dialog[data-soort="video"] #fm-opslaan { background-color: #e3f2fd; color: #0b5cad; border-color: #90caf9; }
#formule-dialog[data-soort="video"] #fm-opslaan:hover { background-color: #d0e7fb; border-color: #0077bb; color: #064a8c; }

.fm-uitleg {
    border: 1px solid #e3e3e3;
    border-radius: 5px;
    background: #fcfcfc;
    padding: 6px 10px;
    font-size: 0.78rem;
    color: #444;
}
.fm-uitleg summary { cursor: pointer; font-weight: 600; color: #0b5cad; user-select: none; }
.fm-uitleg-inhoud { margin-top: 8px; line-height: 1.45; }
.fm-uitleg-inhoud p { margin: 0 0 6px; }
.fm-uitleg-inhoud code {
    background: #eef1f4;
    padding: 1px 4px;
    border-radius: 3px;
    font-family: Consolas, monospace;
    font-size: 0.76rem;
}
.fm-tabel { width: 100%; border-collapse: collapse; margin: 6px 0; }
.fm-tabel td { padding: 3px 6px; border-top: 1px solid #eaecef; vertical-align: top; }
.fm-tabel td:first-child { white-space: nowrap; width: 38%; }
.fm-voorbeelden { color: #555; margin-bottom: 0 !important; }
