:root {
  --brand: #1d4ed8;
  --brand-dark: #1e3a8a;
  --brand-soft: #e8eefc;
  --accent: #f5b301;
  --accent-soft: #fff6dc;
  --ink: #0f172a;
  --muted: #5b6477;
  --line: #e3e7ef;
  --bg: #f4f6fa;
  --card: #ffffff;
  --ok: #15803d;
  --ok-soft: #e6f6ec;
  --warn: #b45309;
  --warn-soft: #fef3e2;
  --bad: #b91c1c;
  --bad-soft: #fdecec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .05);
  --lvl0: #e3e7ef;
  --lvl1: #93b4f5;
  --lvl2: #5a8bf0;
  --lvl3: #2f66e0;
  --lvl4: #15803d;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; font-weight: 800; }
h2 { font-size: 1.1rem; font-weight: 700; }
h3 { font-size: .95rem; font-weight: 700; }
p { margin: 0; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* ---------- Knoppen & formulieren ---------- */
button { font: inherit; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid transparent; border-radius: 10px;
  padding: .6rem 1rem; font-weight: 600; font-size: .92rem;
  background: var(--brand); color: #fff; transition: background .15s, border-color .15s, color .15s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.secondary { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { border-color: #c5cddb; background: #fafbfd; }
.btn.ghost { background: transparent; color: var(--brand); padding: .45rem .6rem; }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.ok { background: var(--ok); }
.btn.ok:hover { background: #116632; }
.btn.danger { background: var(--card); color: var(--bad); border-color: #f2c4c4; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.sm { padding: .4rem .7rem; font-size: .84rem; border-radius: 8px; }
.btn.block { width: 100%; }

label.field { display: block; margin-bottom: .9rem; }
label.field > span { display: block; font-weight: 600; font-size: .86rem; margin-bottom: .3rem; }
input, select, textarea {
  font: inherit; color: var(--ink); width: 100%;
  border: 1px solid var(--line); border-radius: 10px; padding: .6rem .75rem; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29, 78, 216, .15); }
textarea { resize: vertical; min-height: 70px; }
.row { display: grid; gap: .8rem; grid-template-columns: 1fr 1fr; }
.row3 { display: grid; gap: .8rem; grid-template-columns: 1fr 1fr 1fr; }
.form-error { background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: .6rem .8rem; font-size: .88rem; margin-bottom: .9rem; }
.form-error:empty { display: none; }
.check { display: flex; gap: .5rem; align-items: center; font-size: .88rem; margin-bottom: .9rem; }
.check input { width: auto; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero {
  background: linear-gradient(155deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.auth-hero::after {
  content: ''; position: absolute; right: -80px; bottom: -80px; width: 320px; height: 320px; border-radius: 50%;
  border: 40px solid rgba(255, 255, 255, .07);
}
.auth-hero h1 { font-size: 2.4rem; max-width: 14ch; margin-top: 2rem; }
.auth-hero p { opacity: .85; max-width: 40ch; margin-top: 1rem; font-size: 1.05rem; }
.auth-hero ul { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; gap: .7rem; }
.auth-hero li { display: flex; gap: .7rem; align-items: center; opacity: .95; }
.auth-hero li::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.auth-panel { display: grid; place-items: center; padding: 2rem 1.25rem; }
.auth-card { width: 100%; max-width: 420px; }
.tabs { display: flex; background: #e9edf4; border-radius: 12px; padding: 4px; margin-bottom: 1.5rem; }
.tabs button { flex: 1; border: 0; background: transparent; padding: .55rem; border-radius: 9px; font-weight: 600; color: var(--muted); }
.tabs button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.role-pick { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: 1rem; }
.role-pick button {
  border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: .8rem; text-align: left;
}
.role-pick button strong { display: block; }
.role-pick button span { font-size: .8rem; color: var(--muted); }
.role-pick button.active { border-color: var(--brand); background: var(--brand-soft); }

/* ---------- Logo ---------- */
.logo { display: inline-flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; color: inherit; text-decoration: none; }
.logo img { width: 30px; height: 30px; }
.auth-hero .logo img { background: #fff; border-radius: 9px; padding: 0; }
.logo b { color: var(--accent); font-weight: 800; }
.topbar .logo b { color: var(--brand); }

/* ---------- Layout ---------- */
.topbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1160px; margin: 0 auto; padding: .7rem 1.25rem; display: flex; align-items: center; gap: 1.5rem; }
.nav { display: flex; gap: .25rem; }
.nav a { text-decoration: none; color: var(--muted); font-weight: 600; padding: .45rem .75rem; border-radius: 8px; font-size: .92rem; }
.nav a:hover { color: var(--ink); background: var(--bg); }
.nav a.active { color: var(--brand); background: var(--brand-soft); }
.user-menu { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; }
.user-name { font-weight: 600; font-size: .9rem; line-height: 1.2; }
.user-role { font-size: .76rem; color: var(--muted); }
main { max-width: 1160px; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-head p { margin-top: .35rem; }
.back { display: inline-flex; gap: .3rem; align-items: center; font-weight: 600; font-size: .88rem; text-decoration: none; margin-bottom: .6rem; }

.grid { display: grid; gap: 1.25rem; }
.grid.two { grid-template-columns: 1.4fr 1fr; align-items: start; }
.grid.half { grid-template-columns: 1fr 1fr; align-items: start; }
.stack { display: grid; gap: 1.25rem; align-content: start; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.card-head p { margin-top: .15rem; }

/* ---------- Statistieken ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.stat .label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; margin-top: .2rem; }
.stat .sub { font-size: .8rem; color: var(--muted); }
.stat.hero { background: var(--brand); color: #fff; border-color: var(--brand); }
.stat.hero .label, .stat.hero .sub { color: rgba(255, 255, 255, .8); }
.stat.low .value { color: var(--warn); }
.stat.hero.low { background: var(--warn); border-color: var(--warn); }
.stat.hero.low .value { color: #fff; }

/* ---------- Volgende les ---------- */
.next-lesson { display: flex; gap: 1.1rem; align-items: center; }
.date-badge { flex: none; width: 66px; text-align: center; border-radius: 12px; background: var(--brand-soft); color: var(--brand); padding: .5rem 0; }
.date-badge .d { font-size: 1.6rem; font-weight: 800; line-height: 1; }
.date-badge .m { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.next-lesson .info { flex: 1; min-width: 0; }
.next-lesson .when { font-weight: 700; font-size: 1.05rem; }
.meta { display: flex; flex-wrap: wrap; gap: .3rem 1rem; color: var(--muted); font-size: .86rem; margin-top: .2rem; }
.empty { text-align: center; color: var(--muted); padding: 1.5rem 1rem; font-size: .92rem; }

/* ---------- Voortgang ---------- */
.ring { --p: 0; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--lvl0) 0); }
.ring span { width: 50px; height: 50px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-weight: 800; font-size: .9rem; }
.topics { display: grid; gap: .25rem; }
.topic { display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; padding: .7rem 0; border-top: 1px solid var(--line); align-items: center; }
.topic:first-child { border-top: 0; }
.topic .name { font-weight: 600; font-size: .93rem; }
.topic .hint { font-size: .8rem; color: var(--muted); }
.segbar { display: flex; gap: 3px; width: 140px; }
.segbar i { flex: 1; height: 8px; border-radius: 4px; background: var(--lvl0); }
.segbar.l1 i:nth-child(-n+1) { background: var(--lvl1); }
.segbar.l2 i:nth-child(-n+2) { background: var(--lvl2); }
.segbar.l3 i:nth-child(-n+3) { background: var(--lvl3); }
.segbar.l4 i { background: var(--lvl4); }
.lvl-label { font-size: .78rem; font-weight: 600; color: var(--muted); text-align: right; margin-top: .25rem; }
.lvl-label.l4 { color: var(--ok); }
.topic .note { grid-column: 1 / -1; font-size: .84rem; background: var(--bg); border-radius: 8px; padding: .45rem .65rem; color: #334155; }
.topic .note em { color: var(--muted); font-style: normal; font-size: .76rem; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .76rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: .3rem; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* Instructeur voortgang-editor */
.topic-edit { padding: .8rem 0; border-top: 1px solid var(--line); display: grid; gap: .5rem; }
.topic-edit:first-child { border-top: 0; }
.topic-edit .top { display: flex; justify-content: space-between; gap: 1rem; align-items: center; flex-wrap: wrap; }
.levels { display: flex; gap: 4px; }
.levels button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: .3rem .55rem; font-size: .76rem; font-weight: 600; color: var(--muted); }
.levels button:hover { border-color: var(--lvl2); color: var(--ink); }
.levels button.on { background: var(--lvl3); border-color: var(--lvl3); color: #fff; }
.levels button.on.l4 { background: var(--lvl4); border-color: var(--lvl4); }
.levels button.on.l0 { background: #64748b; border-color: #64748b; }
.topic-edit input { font-size: .86rem; padding: .45rem .65rem; }

/* ---------- Beschikbaarheid ---------- */
.avail-day { display: grid; grid-template-columns: 92px 1fr; gap: .75rem; padding: .55rem 0; border-top: 1px solid var(--line); align-items: start; }
.avail-day:first-child { border-top: 0; }
.avail-day .day { font-weight: 600; font-size: .9rem; padding-top: .4rem; }
.slots { display: grid; gap: .4rem; }
.slot { display: flex; gap: .4rem; align-items: center; }
.slot input { width: auto; padding: .35rem .5rem; font-size: .88rem; }
.slot .dash { color: var(--muted); }
.icon-btn { border: 0; background: transparent; color: var(--muted); width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 1.1rem; }
.icon-btn:hover { background: var(--bad-soft); color: var(--bad); }
.add-slot { justify-self: start; border: 1px dashed #c5cddb; background: transparent; color: var(--muted); border-radius: 8px; padding: .3rem .6rem; font-size: .82rem; font-weight: 600; }
.add-slot:hover { border-color: var(--brand); color: var(--brand); }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { background: var(--brand-soft); color: var(--brand-dark); border-radius: 999px; padding: .15rem .6rem; font-size: .8rem; font-weight: 600; }
.chip.none { background: var(--bg); color: var(--muted); font-weight: 500; }
.avail-view { display: grid; gap: .45rem; }
.avail-view .r { display: grid; grid-template-columns: 80px 1fr; gap: .5rem; align-items: center; font-size: .88rem; }

/* ---------- Lessen ---------- */
.lesson-list { display: grid; }
.lesson { display: grid; grid-template-columns: 58px 1fr auto; gap: 1rem; align-items: center; padding: .8rem 0; border-top: 1px solid var(--line); }
.lesson:first-child { border-top: 0; }
.lesson .date-badge { width: 58px; padding: .35rem 0; }
.lesson .date-badge .d { font-size: 1.25rem; }
.lesson .title { font-weight: 600; font-size: .93rem; }
.lesson .lnote { font-size: .84rem; color: #334155; margin-top: .2rem; }
.lesson .actions { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }
.lesson.past .date-badge { background: var(--bg); color: var(--muted); }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: .12rem .5rem; border-radius: 999px; text-transform: capitalize; }
.badge.gepland { background: var(--brand-soft); color: var(--brand); }
.badge.voltooid { background: var(--ok-soft); color: var(--ok); }
.badge.geannuleerd { background: var(--bad-soft); color: var(--bad); }
.badge.open { background: var(--warn-soft); color: var(--warn); }
.subtabs { display: flex; gap: .25rem; }
.subtabs button { border: 0; background: transparent; padding: .35rem .7rem; border-radius: 8px; font-weight: 600; font-size: .85rem; color: var(--muted); }
.subtabs button.active { background: var(--brand-soft); color: var(--brand); }

/* ---------- Agenda ---------- */
.week-nav { display: flex; align-items: center; gap: .5rem; }
.week-nav .range { font-weight: 700; min-width: 190px; text-align: center; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .6rem; }
.wday { background: var(--card); border: 1px solid var(--line); border-radius: 12px; min-height: 260px; display: flex; flex-direction: column; overflow: hidden; }
.wday.today { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.wday-head { padding: .55rem .7rem; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.wday-head .n { font-weight: 700; font-size: .85rem; }
.wday-head .dt { font-size: .78rem; color: var(--muted); }
.wday.today .wday-head { background: var(--brand-soft); }
.wday-body { padding: .5rem; display: grid; gap: .4rem; align-content: start; flex: 1; }
.wday-add { border: 0; background: transparent; color: var(--muted); font-size: 1.1rem; width: 26px; height: 26px; border-radius: 6px; line-height: 1; }
.wday-add:hover { background: var(--brand); color: #fff; }
.ev { text-align: left; border: 0; border-left: 3px solid var(--brand); background: var(--brand-soft); border-radius: 8px; padding: .45rem .55rem; width: 100%; }
.ev:hover { filter: brightness(.97); }
.ev .t { font-size: .74rem; font-weight: 700; color: var(--brand-dark); }
.ev .s { font-size: .84rem; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev .p { font-size: .72rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev.voltooid { border-left-color: var(--ok); background: var(--ok-soft); }
.ev.voltooid .t { color: var(--ok); }
.ev.geannuleerd { border-left-color: #cbd5e1; background: #f5f6f8; opacity: .7; }
.ev.geannuleerd .s { text-decoration: line-through; }
.ev.open { border-left-color: var(--warn); background: var(--warn-soft); }
.ev.open .t { color: var(--warn); }

/* ---------- Leerlingenlijst ---------- */
.toolbar { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar input { max-width: 300px; }
.students { display: grid; }
.student-row { display: grid; grid-template-columns: 2fr 1fr 1.2fr 1.2fr 24px; gap: 1rem; align-items: center; padding: .85rem .5rem; border-top: 1px solid var(--line); text-decoration: none; color: inherit; border-radius: 10px; }
.student-row:hover { background: var(--bg); }
.student-row.head { font-size: .76rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; border-top: 0; padding-top: 0; }
.student-row.head:hover { background: transparent; }
.who { display: flex; gap: .7rem; align-items: center; min-width: 0; }
.who .nm { font-weight: 600; }
.who .em { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-bar { height: 6px; background: var(--lvl0); border-radius: 3px; overflow: hidden; margin-top: .3rem; }
.mini-bar i { display: block; height: 100%; background: var(--brand); border-radius: 3px; }
.credit-pill { font-weight: 700; }
.credit-pill.low { color: var(--warn); }
.credit-pill.none { color: var(--bad); }
.chev { color: #94a3b8; }

/* ---------- Tegoed ---------- */
.credit-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; text-align: center; margin-bottom: 1rem; }
.credit-grid div { background: var(--bg); border-radius: 10px; padding: .6rem .3rem; }
.credit-grid b { display: block; font-size: 1.35rem; font-weight: 800; }
.credit-grid span { font-size: .74rem; color: var(--muted); font-weight: 600; }
.credit-grid .rem { background: var(--brand-soft); color: var(--brand-dark); }
.credit-actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.credit-actions input { width: 80px; padding: .4rem .5rem; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: .45rem .75rem; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; padding: 1rem; z-index: 50; animation: fade .15s; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 520px; max-height: calc(100vh - 2rem); overflow: auto; box-shadow: 0 20px 60px rgba(15, 23, 42, .25); animation: pop .18s; }
.modal-head { padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: #fff; }
.modal-body { padding: 1.25rem; }
.modal-foot { padding: 1rem 1.25rem; border-top: 1px solid var(--line); display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }
.modal-foot .spacer { flex: 1; }
.close-x { border: 0; background: transparent; font-size: 1.4rem; color: var(--muted); width: 34px; height: 34px; border-radius: 8px; }
.close-x:hover { background: var(--bg); }
.hint-box { background: var(--accent-soft); border-radius: 10px; padding: .7rem .85rem; font-size: .86rem; margin-bottom: .9rem; }
.hint-box b { font-weight: 700; }
.hint-box.warn { background: var(--bad-soft); color: var(--bad); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }

/* ---------- Toasts ---------- */
#toasts { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); display: grid; gap: .5rem; z-index: 100; width: max-content; max-width: calc(100vw - 2rem); }
.toast { background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: 10px; font-size: .9rem; font-weight: 500; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); animation: pop .2s; }
.toast.error { background: var(--bad); }

/* ---------- Responsief ---------- */
@media (max-width: 1000px) {
  .week { grid-template-columns: 1fr; }
  .wday { min-height: 0; }
  .wday-body:empty::after { content: 'Geen lessen'; font-size: .8rem; color: var(--muted); padding: .2rem; }
}
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { padding: 2rem 1.25rem; }
  .auth-hero h1 { font-size: 1.8rem; margin-top: 1.25rem; }
  .auth-hero ul { display: none; }
  .grid.two, .grid.half { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .student-row { grid-template-columns: 1fr auto; }
  .student-row > :nth-child(3), .student-row > :nth-child(4), .student-row > :nth-child(5) { display: none; }
  .student-row.head { display: none; }
}
@media (max-width: 640px) {
  main { padding: 1.25rem 1rem 3rem; }
  .topbar-inner { padding: .6rem 1rem; gap: .75rem; flex-wrap: wrap; }
  .nav { order: 3; width: 100%; }
  .user-name, .user-role { display: none; }
  h1 { font-size: 1.45rem; }
  .row, .row3 { grid-template-columns: 1fr; gap: 0; }
  .lesson { grid-template-columns: 50px 1fr; }
  .lesson .actions { grid-column: 1 / -1; justify-content: flex-start; }
  .topic { grid-template-columns: 1fr; }
  .lvl-label { text-align: left; }
  .segbar { width: 100%; }
  .levels { flex-wrap: wrap; }
  .credit-grid { grid-template-columns: 1fr 1fr; }
  .avail-day { grid-template-columns: 1fr; gap: .3rem; }
  .avail-day .day { padding-top: 0; }
  .week-nav .range { min-width: 0; font-size: .9rem; }
}
