:root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --panel-2: #eef0f3;
    --line: #e3e6eb;
    --text: #1b2330;
    --muted: #6b7480;
    --brand: #ffd23f;
    --brand-2: #3a66f0;
    --ok: #1f9d57;
    --warn: #d98a00;
    --err: #e23b54;
    --radius: 10px;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 244px;
    background: var(--panel);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    padding: 18px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { font-weight: 700; font-size: 18px; letter-spacing: .5px; display: flex; align-items: center; gap: 8px; padding: 6px 10px 18px; overflow: hidden; white-space: nowrap; }
.brand-mark { color: var(--brand); display: inline-flex; }
.brand-light { color: var(--muted); font-weight: 500; }
nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 11px; border-radius: 8px; color: var(--muted);
    font-weight: 500;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--panel-2); color: var(--text); box-shadow: inset 2px 0 0 var(--brand); }
.nav-item svg { flex-shrink: 0; }
.sidebar-foot { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }

.content { flex: 1; padding: 28px 34px; max-width: 1100px; }

/* Subsectie-tabs */
.tabbar { display: flex; flex-direction: row; align-items: center; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 24px; flex-wrap: wrap; }
.tabbar a { padding: 10px 15px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 6px 6px 0 0; }
.tabbar a:hover { color: var(--text); background: var(--panel); text-decoration: none; }
.tabbar a.active { color: var(--text); border-bottom-color: var(--brand-2); }

/* Koppen */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 16px; }
h1 { font-size: 22px; margin: 0 0 2px; }
h2 { font-size: 16px; margin: 26px 0 12px; }
.sub { color: var(--muted); margin: 0; }

/* Kaarten */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stat .num { font-size: 28px; font-weight: 700; }
.stat .lbl { color: var(--muted); display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.stat .lbl svg { color: var(--brand); }

/* Tabellen */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: none; }
.table-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }

/* Knoppen */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 15px; border-radius: 8px; border: 1px solid var(--line);
    background: var(--panel-2); color: var(--text); cursor: pointer;
    font-size: 14px; font-weight: 600; font-family: inherit;
}
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn-primary { background: var(--brand); color: #1a1205; border-color: var(--brand); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-danger { color: var(--err); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-ghost { background: transparent; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* Formulieren */
.field { margin-bottom: 15px; }
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url],
select, textarea {
    width: 100%; padding: 10px 12px; border-radius: 8px;
    border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
    font-family: inherit; font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-2); }
textarea { min-height: 120px; resize: vertical; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checkbox input { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin: 0 0 15px; }
legend { padding: 0 8px; color: var(--muted); font-weight: 600; }
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Flash */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; font-weight: 500; }
.flash-success { background: rgba(31,157,87,.10); border-color: var(--ok); color: #157f4a; }
.flash-error { background: rgba(226,59,84,.10); border-color: var(--err); color: #c42a43; }
.flash-info { background: rgba(58,102,240,.10); border-color: var(--brand-2); color: #2e54c4; }

/* Badges */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-ok { background: rgba(31,157,87,.14); color: #157f4a; }
.badge-muted { background: var(--panel-2); color: var(--muted); }
.badge-warn { background: rgba(217,138,0,.16); color: #9a6a00; }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.flex { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.muted { color: var(--muted); }
.mt { margin-top: 16px; }
.inline-form { display: inline; }

/* Auth-schermen */
.auth-wrap { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 30px; }
.auth-card .brand { justify-content: center; padding-bottom: 8px; }
.auth-card .sub { text-align: center; margin-bottom: 22px; }

.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.qr { background: #fff; padding: 14px; border-radius: 8px; display: inline-block; }
code.token { display: block; background: var(--panel-2); padding: 12px; border-radius: 8px; word-break: break-all; border: 1px solid var(--line); }

@media (max-width: 720px) {
    .sidebar { width: 64px; }
    .nav-item span, .brand-light, .brand span:not(.brand-mark) { display: none; }
    .content { padding: 18px; }
    .perm-grid { grid-template-columns: 1fr; }
}

/* ---- Section-builder (pagina-editor) ---- */
.sb-add { display: flex; gap: 8px; align-items: center; }
.sb-list { display: flex; flex-direction: column; gap: 14px; }
.sb-section { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); overflow: hidden; }
.sb-shead { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.sb-shead strong { flex: 1; }
.sb-sbody { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.sb-field { display: flex; flex-direction: column; gap: 5px; }
.sb-flabel { font-size: 12.5px; color: var(--muted); }
.sb-rich { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.sb-img-row { display: flex; gap: 8px; align-items: center; }
.sb-img-row input { flex: 1; }
.sb-img-prev { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.sb-list-box { display: flex; flex-direction: column; gap: 10px; border-left: 2px solid var(--line); padding-left: 12px; }
.sb-list-item { display: flex; gap: 8px; align-items: flex-start; }
.sb-list-item .sb-img-row { flex: 1; }
.sb-subcard { flex-direction: column; border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: var(--panel); }
.sb-subhead { display: flex; align-items: center; gap: 6px; }
.sb-subhead span { flex: 1; color: var(--muted); font-size: 12.5px; }

/* Media-picker modal (backend) */
.sb-modal { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; }
.sb-modal[hidden] { display: none; }
.sb-modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: min(720px, 92vw); max-height: 82vh; display: flex; flex-direction: column; overflow: hidden; }
.sb-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.sb-modal-upload { display: flex; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.sb-modal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; padding: 16px 18px; overflow: auto; }
.sb-thumb { padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; cursor: pointer; background: var(--panel-2); }
.sb-thumb:hover { border-color: var(--brand-2); }
.sb-thumb img { width: 100%; height: 96px; object-fit: cover; display: block; }

/* ---- E-learning ---- */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.course-card { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; }
.course-card:hover { border-color: var(--brand-2); transform: translateY(-2px); }
.course-cover { height: 130px; background: var(--panel-2) center/cover no-repeat; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.course-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.course-body h3 { margin: 0; font-size: 1.05rem; }
.course-body p { margin: 0; font-size: 13px; }
.course-meta { display: flex; gap: 10px; align-items: center; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.course-hero { width: 100%; max-height: 240px; object-fit: cover; border-radius: 8px; margin-bottom: 14px; }

.progress { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--ok); border-radius: 99px; }
.progress-label { font-size: 12px; color: var(--muted); }

.lesson-list { list-style: none; padding: 0; margin: 0; counter-reset: les; }
.lesson-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.lesson-list li:last-child { border-bottom: 0; }
.lesson-title { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.lesson-title:hover { color: var(--brand-2); }
.lesson-check { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; color: #fff; flex: none; }
.lesson-check.is-done { background: var(--ok); border-color: var(--ok); }
.lesson-list.compact li { padding: 8px 0; }
.lesson-list.compact li.is-current > a { color: var(--brand-2); font-weight: 600; }

.lesson-layout { display: grid; grid-template-columns: 1fr 280px; gap: 18px; align-items: start; }
.lesson-content { min-width: 0; }
.lesson-side h3 { margin-top: 0; }
.lesson-video { position: relative; padding-top: 56.25%; margin-bottom: 16px; border-radius: 8px; overflow: hidden; background: #000; }
.lesson-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.lesson-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }

.rich { line-height: 1.65; }
.rich h2 { font-size: 1.4rem; margin: 1.2em 0 .4em; }
.rich h3 { font-size: 1.15rem; margin: 1.1em 0 .4em; }
.rich p { margin: 0 0 .9em; }
.rich ul, .rich ol { margin: 0 0 .9em 1.2em; }
.rich img { max-width: 100%; border-radius: 8px; }
.rich a { color: var(--brand-2); }
.rich blockquote { margin: 0 0 .9em; padding: 8px 16px; border-left: 3px solid var(--brand-2); color: var(--muted); }
.rich pre { background: var(--panel-2); padding: 12px; border-radius: 8px; overflow: auto; }

@media (max-width: 760px) {
    .lesson-layout { grid-template-columns: 1fr; }
}
