:root {
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #f1f2f4; --list-bg: #f1f2f4; --text: #172b4d; --muted: #626f86;
  --border: #dcdfe4; --primary: #0c66e4; --primary-hover: #0055cc; --danger: #c9372c; --warn-bg: #fff7d6; --warn: #7f5f01;
  --error-bg: #ffeceb; --ok: #1f845a; --shadow: 0 1px 1px #091e4240, 0 0 1px #091e424f; --topbar: #1d2125;
  --board-color: #0079bf; --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d2125; --surface: #22272b; --surface-2: #2c333a; --list-bg: #101204; --text: #dee4ea; --muted: #9fadbc;
    --border: #3b444c; --primary: #579dff; --primary-hover: #85b8ff; --danger: #f87168; --warn-bg: #533f04; --warn: #f8e6a0;
    --error-bg: #5d1f1a; --ok: #4bce97; --shadow: 0 1px 1px #03040480, 0 0 1px #03040480; --topbar: #161a1d;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 15px; margin: 0; }
pre { white-space: pre-wrap; word-break: break-word; margin: 0; font-size: 12px; }
code { background: var(--surface-2); padding: 1px 4px; border-radius: 3px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; width: 100%; }
[hidden] { display: none !important; }

button, .button, input, select, textarea { font: inherit; color: inherit; }
button, .button {
  background: var(--surface-2); border: 0; border-radius: 4px; padding: 6px 12px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; line-height: 20px;
}
button:hover, .button:hover { filter: brightness(0.95); }
button.primary, .button.primary { background: var(--primary); color: #fff; }
@media (prefers-color-scheme: dark) { button.primary, .button.primary { color: #1d2125; } }
button.primary:hover { background: var(--primary-hover); }
button:disabled { opacity: .6; cursor: default; }
button.link { background: none; padding: 0; color: var(--primary); }
button.link:hover { text-decoration: underline; filter: none; }
.danger, button.link.danger { color: var(--danger); }
button.icon { background: none; padding: 2px 8px; font-size: 16px; color: var(--muted); }
button.icon:hover { background: #091e4224; }
button.round { width: 32px; height: 32px; padding: 0; justify-content: center; border-radius: 50%; }
button.small, .small { font-size: 12px; }
.tiny { font-size: 11px; }
input, select, textarea { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 6px 8px; width: 100%; }
input[type=checkbox] { width: auto; accent-color: var(--primary); margin: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
textarea { resize: vertical; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
label input, label select, label textarea { font-weight: 400; font-size: 14px; color: var(--text); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; font-size: 14px; color: var(--text); cursor: pointer; }
.label-text { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.warn-text { color: var(--warn); }
.notice { background: var(--warn-bg); color: var(--warn); padding: 8px 12px; border-radius: 4px; margin: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.small-gap { gap: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.boxed { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.pill { background: var(--surface-2); border-radius: 12px; padding: 2px 10px; font-size: 12px; display: inline-flex; gap: 6px; align-items: center; }
.pill.warn, .pill.skipped { background: var(--warn-bg); color: var(--warn); }
.pill.sent { background: #dcfff1; color: #216e4e; }
.pill.failed { background: var(--error-bg); color: var(--danger); }

/* Topbalk */
.topbar { display: flex; align-items: center; gap: 16px; height: 48px; padding: 0 16px; background: var(--topbar); color: #fff; position: sticky; top: 0; z-index: 10; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { color: #c7d1db; text-decoration: none; padding: 6px 10px; border-radius: 4px; }
.topbar nav a:hover, .topbar nav a.active { background: #ffffff22; color: #fff; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; font-size: 16px; text-decoration: none; }
.brand-mark { width: 20px; height: 20px; border-radius: 4px; background: linear-gradient(90deg, #fff 0 40%, transparent 40% 55%, #fff 55%) , var(--primary); background-size: 100% 70%, 100%; background-repeat: no-repeat; background-position: center; border: 3px solid var(--primary); }
.brand.big { color: var(--text); font-size: 22px; justify-content: center; margin-bottom: 8px; }
.user-btn { background: none; color: #fff; }

.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 700; flex: none; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.md { width: 32px; height: 32px; font-size: 12px; }

/* Pagina's */
.page { max-width: 1000px; margin: 0 auto; padding: 24px 16px; }
.page.wide { max-width: 1300px; }
.empty { background: var(--surface); padding: 24px; border-radius: var(--radius); }
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.board-tile { height: 100px; border-radius: var(--radius); color: #fff; padding: 12px; text-decoration: none; display: flex; flex-direction: column; justify-content: space-between; font-size: 16px; box-shadow: var(--shadow); }
.board-tile span { font-size: 12px; opacity: .9; }
.board-tile:hover { filter: brightness(.92); }
.board-tile.new { background: var(--surface-2); color: var(--text); justify-content: center; align-items: center; font-size: 14px; }
.archived-boards { margin-top: 24px; }

/* Inlog */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--surface); padding: 32px; border-radius: 12px; box-shadow: var(--shadow); width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login-card .error { margin: 0; min-height: 1em; }

/* Bord */
.board-page { background: var(--board-color); height: calc(100vh - 48px); display: flex; flex-direction: column; overflow: hidden; }
.board-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #0000003d; color: #fff; flex-wrap: wrap; }
.board-title { font-size: 18px; margin: 0; }
.board-title .editable { padding: 2px 6px; border-radius: 4px; }
.board-title .edit-input { font-size: 18px; font-weight: 700; width: 260px; }
.hdr-btn { background: #ffffff33; color: #fff; }
.hdr-btn.on { background: #fff; color: #172b4d; }
.search { width: 200px; background: #ffffff33; border: 0; color: #fff; }
.search::placeholder { color: #ffffffb3; }
.search:focus { background: var(--surface); color: var(--text); }
.lists { flex: 1; display: flex; align-items: flex-start; gap: 12px; padding: 12px; overflow-x: auto; overflow-y: hidden; }
.list { width: 272px; flex: none; background: var(--list-bg); border-radius: 12px; max-height: 100%; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.list-head { display: flex; align-items: center; gap: 4px; padding: 8px 8px 4px 12px; cursor: grab; }
.list-name { flex: 1; font-weight: 600; padding: 4px; border-radius: 4px; min-width: 0; overflow-wrap: anywhere; }
.list-head .edit-input { font-weight: 600; }
.count { color: var(--muted); font-size: 12px; }
.cards { flex: 1; overflow-y: auto; padding: 4px 8px; display: flex; flex-direction: column; gap: 8px; min-height: 8px; }
.card-tile { background: var(--surface); border-radius: var(--radius); padding: 8px 10px; box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; gap: 6px; outline-offset: 1px; }
.card-tile:hover { outline: 2px solid var(--primary); }
.card-tile.ghost { opacity: .4; }
.tile-labels { display: flex; flex-wrap: wrap; gap: 4px; }
.tile-label { font-size: 11px; font-weight: 600; border-radius: 3px; padding: 0 6px; min-width: 40px; min-height: 16px; color: #172b4d; display: inline-block; line-height: 16px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-label.big { font-size: 13px; padding: 4px 10px; line-height: 18px; min-height: 26px; }
.tile-title { overflow-wrap: anywhere; }
.tile-fields { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); }
.tile-badges { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-size: 12px; color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 2px; border-radius: 3px; padding: 0 3px; }
.badge.num { opacity: .7; }
.badge.due.overdue { background: var(--danger); color: #fff; }
.badge.due.soon { background: #f5cd47; color: #172b4d; }
.badge.due.done, .badge.ok { background: #1f845a; color: #fff; }
.badge.missing { background: var(--error-bg); color: var(--danger); font-weight: 600; }
.tile-members { display: flex; gap: 2px; }
.composer { padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 6px; }
.add-card { background: none; color: var(--muted); width: 100%; justify-content: flex-start; }
.add-card:hover { background: #091e4224; color: var(--text); }
.add-list { background: #ffffff3d; padding: 8px; gap: 6px; box-shadow: none; }
.add-list-btn { background: none; color: #fff; width: 100%; justify-content: flex-start; }
.add-list-btn:hover { background: #ffffff33; }
.editable { cursor: pointer; min-height: 1.4em; }
.editable:hover { background: #091e420f; }

/* Modals & popovers */
body:has(#modal-root > .overlay) { overflow: hidden; }
.overlay { position: fixed; inset: 0; background: #000000a0; display: flex; justify-content: center; align-items: flex-start; overflow-y: auto; padding: 48px 16px; z-index: 50; }
.modal { background: var(--bg); border-radius: 12px; padding: 24px; width: min(480px, 100%); min-width: 0; position: relative; box-shadow: 0 8px 32px #0006; }
.modal.wide { width: min(820px, 100%); }
.modal-close { position: absolute; top: 10px; right: 10px; background: none; font-size: 22px; width: 36px; height: 36px; justify-content: center; border-radius: 50%; padding: 0; color: var(--muted); }
.modal-close:hover { background: var(--surface-2); }
.popover { position: fixed; z-index: 60; background: var(--surface); border-radius: var(--radius); box-shadow: 0 8px 24px #091e4240, 0 0 1px #091e424f; padding: 12px; max-height: 70vh; overflow-y: auto; }
.popover-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; color: var(--muted); margin-bottom: 8px; text-align: center; }
.popover-head .link { color: var(--muted); font-size: 18px; }
.menu { display: flex; flex-direction: column; gap: 2px; }
.menu button { background: none; justify-content: flex-start; text-align: left; width: 100%; }
.menu button:hover { background: var(--surface-2); filter: none; }
.menu button.on { font-weight: 600; }
.label-choice { gap: 8px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 40px; height: 28px; padding: 0; border-radius: 4px; }
.swatches.small .swatch { width: 44px; height: 24px; }
.swatch.sel { outline: 3px solid var(--text); outline-offset: 1px; }

/* Kaart-detail */
.card-modal { display: flex; flex-direction: column; gap: 16px; }
.card-head { padding-right: 32px; }
.card-title { font-size: 20px; }
.card-title .edit-input { font-size: 20px; font-weight: 700; }
.card-body { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 24px; }
.card-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.card-side { display: flex; flex-direction: column; gap: 6px; }
.card-side button { justify-content: flex-start; width: 100%; }
.card-side .label-text { margin-top: 8px; }
.banner { padding: 10px 14px; border-radius: var(--radius); display: flex; align-items: center; gap: 12px; margin-right: 32px; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.error { background: var(--error-bg); color: var(--danger); font-weight: 600; }
.meta-row { display: flex; flex-wrap: wrap; gap: 16px 24px; }
.meta.missing, .field.missing, .card-section.missing { outline: 2px solid var(--danger); outline-offset: 4px; border-radius: 4px; }
.req { color: var(--danger); font-size: 12px; font-weight: 600; }
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; justify-content: space-between; flex-wrap: wrap; }
.placeholder { width: 100%; min-height: 56px; justify-content: flex-start; align-items: flex-start; color: var(--muted); }
.desc { cursor: pointer; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 8px; }
.md img { max-width: 100%; }
.desc-edit { min-height: 140px; }
.fields-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 16px; }
.field .label-text { margin-bottom: 4px; }
.due-overdue { background: var(--danger); color: #fff; }
.due-done { background: #1f845a; color: #fff; }
.due-soon { background: #f5cd47; color: #172b4d; }
.progress { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.progress .bar { flex: 1; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.progress .bar div { height: 100%; background: var(--primary); }
.check-items { display: flex; flex-direction: column; }
.check-item { display: flex; align-items: center; gap: 10px; padding: 4px 6px; border-radius: 4px; }
.check-item:hover { background: var(--surface-2); }
.check-item .editable { flex: 1; }
.check-item .editable.done { text-decoration: line-through; color: var(--muted); }
.hover-only { visibility: hidden; }
.check-item:hover .hover-only { visibility: visible; }
.add-item { margin-top: 6px; }
.attachment { display: flex; gap: 12px; align-items: flex-start; }
.thumb { width: 96px; height: 64px; border-radius: 4px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; flex: none; overflow: hidden; text-decoration: none; font-weight: 700; color: var(--muted); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.tabs { display: flex; gap: 4px; }
.tabs button, .tabs a { background: none; padding: 4px 10px; border-radius: 4px; text-decoration: none; color: var(--muted); }
.tabs .on { background: var(--surface-2); color: var(--text); font-weight: 600; }
.tabs.big { margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.comment-new, .comment { display: flex; gap: 10px; margin-bottom: 14px; }
.comment-new textarea { margin-bottom: 6px; }
.comment-text { background: var(--surface); border-radius: var(--radius); padding: 8px 12px; margin: 4px 0; box-shadow: var(--shadow); }
.comment .row button { font-size: 12px; }

/* Historie */
.history { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.history li { border-left: 3px solid var(--border); padding: 2px 0 2px 12px; }
.history li.act-mail { border-color: #9f8fef; }
.history li.act-card { border-color: var(--primary); }
.history li.act-comment { border-color: #4bce97; }
.changes { border-collapse: collapse; margin-top: 4px; font-size: 12px; }
.changes th { text-align: left; color: var(--muted); font-weight: 600; padding: 2px 10px 2px 0; vertical-align: top; }
.changes td { padding: 2px 6px; vertical-align: top; }
.changes td.old { color: var(--danger); text-decoration: line-through; }
.changes td.new { color: var(--ok); }
.diff { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.diff .old pre { background: var(--error-bg); padding: 6px; border-radius: 4px; }
.diff .new pre { background: #dcfff155; padding: 6px; border-radius: 4px; }
blockquote { margin: 4px 0; padding-left: 8px; border-left: 2px solid var(--border); color: var(--muted); }

/* Logboek en beheer */
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-bottom: 16px; }
.log-results { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; }
.log-row { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.log-row:last-child { border-bottom: 0; }
.log-time { color: var(--muted); font-size: 12px; }
.log-row .history li { border: 0; padding: 0; }
table.data { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.data th, table.data td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data th { font-size: 12px; color: var(--muted); }
table.data tr.inactive { opacity: .6; }
.fields-table { width: 100%; border-collapse: collapse; }
.fields-table th, .fields-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.fields-table th { font-size: 12px; color: var(--muted); }
.req-lists { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.req-lists label.check { font-size: 13px; }
.rule { background: var(--surface); padding: 10px 12px; border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; }
.label-row { display: flex; align-items: center; gap: 12px; }
.label-row .tile-label { flex: 1; }
.archive-row { flex-wrap: wrap; padding: 4px 0; border-bottom: 1px solid var(--border); }
.steps li { margin-bottom: 4px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: #172b4d; color: #fff; padding: 10px 16px; border-radius: 6px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 100; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.error { background: var(--danger); color: #fff; }

@media (max-width: 700px) {
  .hide-sm { display: none; }
  .topbar { gap: 4px; padding: 0 8px; }
  .topbar nav a { padding: 6px 7px; }
  .brand-text { display: none; }
  .user-btn { padding: 4px; }
  .card-body { grid-template-columns: minmax(0, 1fr); }
  .card-side button { min-width: 0; }
  .card-side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-side .label-text { grid-column: 1 / -1; }
  .grid2 { grid-template-columns: 1fr; }
  .search { width: 100%; order: 10; }
  .lists { scroll-snap-type: x mandatory; }
  .list { width: calc(100vw - 48px); scroll-snap-align: center; }
  .log-row { grid-template-columns: 1fr; gap: 2px; }
  .overlay { padding: 0; }
  .modal { border-radius: 0; min-height: 100%; padding: 20px 16px; }
  .diff { grid-template-columns: 1fr; }
  .fields-table, .fields-table tbody, .fields-table tr, .fields-table td { display: block; }
  .fields-table thead { display: none; }
  .fields-table tr { border-bottom: 1px solid var(--border); padding: 8px 0; }
  .fields-table td { border: 0; padding: 2px 0; }
  table.data { display: block; overflow-x: auto; }
}
