:root {
    color-scheme: light;
    --bg: #f5f7f8;
    --panel: #ffffff;
    --line: #d9e0e4;
    --text: #182126;
    --muted: #65737c;
    --accent: #009739;
    --accent-dark: #009739;
    --danger: #9d2d25;
    --ok: #009739;
    --warn: #a56416;
}
html { height: 100%; overflow: hidden; }

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    height: 100vh;
    overflow: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    padding: 0 14px;
    font: inherit;
    cursor: pointer;
}

button:hover, .button:hover { background: var(--accent-dark); text-decoration: none; }
button.secondary, .button.secondary { background: #fff; color: var(--accent); }
button.danger, .button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.danger:hover, .button.danger:hover { background: #7f211a; }

input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

textarea { resize: vertical; }
label { display: grid; gap: 5px; color: #2d3a41; font-weight: 600; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
fieldset:disabled { opacity: .72; }

main { padding: 22px; overflow: hidden; }
body:has(.workspace) main { padding-top: 12px; }

.topbar {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    background: #172329;
    color: #fff;
}

.brand { color: #fff; font-weight: 800; font-size: 18px; }
.topbar-left {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 16px;
}
.topbar-mission {
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 10px;
    color: #e8f2f2;
    white-space: nowrap;
}
.topbar-mission strong {
    max-width: 34vw;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 16px;
}
.topbar-mission span {
    color: #aebdc3;
    font-size: 13px;
}
.topbar nav { display: flex; gap: 16px; align-items: center; flex-shrink: 0; }
.topbar nav a { color: #e8f2f2; }
.topbar form { margin: 0; }
.topbar button { min-height: 32px; background: transparent; border-color: #5f777e; }
.topbar-toggle { color: #fff; white-space: nowrap; }
.topbar-toggle[aria-pressed="true"] { background: #24363e; border-color: #8aa2a9; }

.flash-stack { display: grid; gap: 8px; margin-bottom: 16px; }
.flash { padding: 10px 12px; border-radius: 6px; background: #e8f3f4; border: 1px solid #c5dfe1; }
.flash.error { background: #fff0ee; border-color: #e5bbb6; color: var(--danger); }
.flash.success { background: #edf8f0; border-color: #bfe2c8; color: var(--ok); }

.page-head, .mission-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

h1, h2, h3 { margin: 0 0 8px; line-height: 1.15; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
p { margin: 0 0 10px; }

.muted { color: var(--muted); }
.padded { padding: 14px; }
.empty, .login-panel, .split > div, .export-page {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.login-panel { max-width: 380px; margin: 8vh auto; }
.login-panel form, .stack-form { display: grid; gap: 12px; }

.split {
    display: grid;
    grid-template-columns: minmax(280px, 420px) 1fr;
    gap: 18px;
}

.mission-list { display: grid; gap: 8px; }
.mission-filters {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(130px, 160px) minmax(130px, 160px);
    gap: 10px;
    margin: 8px 0 12px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.discussion-filters {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(130px, 170px);
    gap: 10px;
    margin: 8px 0 12px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.mission-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
}
.mission-row small { display: block; color: var(--muted); margin-top: 3px; }
.discussion-list {
    display: grid;
    gap: 8px;
}
.discussion-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
}
.discussion-row:hover {
    border-color: #b8c7cc;
    background: #fbfcfc;
    text-decoration: none;
}
.discussion-row strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.discussion-row small {
    color: var(--muted);
    white-space: nowrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 700;
    background: #e9eef1;
    color: #41515a;
    white-space: nowrap;
}
.badge.open, .badge.ja { background: #e6f5eb; color: var(--ok); }
.badge.gesloten, .badge.nee { background: #fff0ee; color: var(--danger); }
.badge.onbeslist { background: #fff5e7; color: var(--warn); }
.badge.neutral { background: #edf1f3; color: #4d5b63; }

.actions, .upload-strip, .filter-row, .pdf-tools, .two-cols {
    display: flex;
    gap: 10px;
    align-items: center;
}

.upload-strip {
    align-items: end;
    margin-bottom: 16px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.upload-strip form { display: grid; grid-template-columns: minmax(260px, 1fr) auto; gap: 6px 10px; align-items: end; flex: 1; }
.upload-strip form small { grid-column: 1 / -1; }
.upload-strip form.is-uploading button { pointer-events: none; opacity: .86; }
.loading-dots { display: none; align-items: center; gap: 3px; margin-left: 8px; }
.loading-dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: loading-wave 900ms infinite ease-in-out; }
.loading-dots i:nth-child(2) { animation-delay: 120ms; }
.loading-dots i:nth-child(3) { animation-delay: 240ms; }
.is-uploading .loading-dots { display: inline-flex; }
@keyframes loading-wave {
    0%, 70%, 100% { transform: translateY(0); opacity: .45; }
    35% { transform: translateY(-4px); opacity: 1; }
}

.source-strip {
    margin-bottom: 16px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.source-strip h2 { font-size: 16px; margin-bottom: 10px; }
.source-list { display: grid; gap: 8px; }
.source-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f9fbfb;
}
.source-row small {
    display: block;
    color: var(--muted);
    margin-top: 3px;
}

.workspace {
    --workspace-left: 310px;
    --workspace-right: minmax(260px, 42vw);
    display: grid;
    grid-template-columns: var(--workspace-left) 8px minmax(300px, 1fr) 8px var(--workspace-right);
    height: calc(100vh - 90px);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.item-list, .item-detail, .pdf-pane { min-width: 0; }
.item-list { grid-column: 1; grid-row: 1; background: #f9fbfb; overflow-y: scroll; height: 100%; }
.item-detail { grid-column: 3; grid-row: 1; overflow-y: scroll; height: 100%; }
.pdf-pane { grid-column: 5; grid-row: 1; overflow-y: auto; overflow-x: hidden; height: 100%; }
.column-resizer {
    grid-row: 1;
    position: relative;
    z-index: 2;
    cursor: col-resize;
    touch-action: none;
    background: #eef2f3;
    border-inline: 1px solid var(--line);
}
.column-resizer::after {
    content: "";
    position: absolute;
    inset: 0 3px;
    border-left: 1px solid #b8c7cc;
    border-right: 1px solid #b8c7cc;
    opacity: .7;
}
.column-resizer:hover,
.column-resizer:focus-visible,
.workspace.is-resizing .column-resizer { background: #dce9eb; }
.workspace.is-resizing,
.workspace.is-resizing * { user-select: none; }
.workspace.pdf-collapsed { grid-template-columns: var(--workspace-left) 8px minmax(300px, 1fr) 0 0; }
.workspace.pdf-collapsed .pdf-pane,
.workspace.pdf-collapsed [data-resize-column="right"] { display: none; }

.workspace.agenda-collapsed { grid-template-columns: 0 0 minmax(300px, 1fr) 8px var(--workspace-right); }
.workspace.agenda-collapsed .item-list,
.workspace.agenda-collapsed [data-resize-column="left"] { display: none; }
.filter-row { padding: 10px; border-bottom: 1px solid var(--line); }
.item-filters { display: grid; align-items: stretch; gap: 6px; }
.item-filters > div { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-row a { padding: 6px 9px; border-radius: 6px; color: var(--muted); }
.filter-row a.active { background: #dbeaec; color: var(--accent-dark); font-weight: 700; }

.item-card {
    display: grid;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--line);
    color: var(--text);
}
.item-card:hover, .item-card.selected { background: #eef6f7; text-decoration: none; }
.item-card strong { font-size: 14px; }

.item-detail { padding: 18px; overflow: auto; }
.item-detail dl { display: grid; gap: 6px; margin: 12px 0 18px; }
.item-detail dt { font-weight: 800; }
.item-detail dd { margin: 0 0 8px; color: #34434b; }
.note-line { padding: 8px 10px; background: #f2f5f6; border-radius: 6px; color: #3f5058; }
.page-link-preview { padding: 7px 9px; background: #f2f5f6; border: 1px solid var(--line); border-radius: 6px; color: #3f5058; font-size: 13px; }


.reader-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 10px 0 8px;
    color: var(--muted);
    font-size: 13px;
}
.reader-summary-main {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.reader-summary strong {
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.discussion-toggle-form {
    flex-shrink: 0;
    margin: 0;
}
.discussion-toggle {
    display: flex;
    grid-template-columns: none;
    align-items: center;
    gap: 7px;
    color: #2d3a41;
    font-weight: 700;
    white-space: nowrap;
}
.discussion-toggle input {
    width: auto;
    margin: 0;
}
.proposal-block,
.incoming-block {
    display: grid;
    gap: 6px;
    margin: 8px 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f9fbfb;
}
.proposal-block h3,
.incoming-block h3 { margin: 0; }
.proposal-block p,
.incoming-block p { margin: 0; color: #34434b; }
.proposal-review {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, 220px);
    gap: 12px;
    align-items: start;
}
.proposal-review select { width: 100%; }
.incoming-block ul {
    margin: 0;
    padding-left: 20px;
    display: grid;
    gap: 5px;
}
.incoming-block li { color: #34434b; }

.detail-action-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 2px; }
.detail-action-row h3 { margin: 0; }
.detail-action-row button,
button.compact { min-height: 28px; padding: 0 9px; font-size: 13px; }
.comments { margin-top: 4px; display: grid; gap: 8px; }
.comments article { border-top: 1px solid var(--line); padding-top: 8px; }
.comments time { color: var(--muted); font-size: 12px; margin-left: 8px; }
.comments form { display: grid; gap: 8px; }
.comment-head { display: flex; align-items: center; justify-content: flex-start; gap: 10px; }
.form-actions { display: flex; justify-content: flex-end; }
.form-actions button { min-height: 30px; padding: 0 10px; font-size: 13px; }
.viewer-tips {
    display: grid;
    gap: 6px;
    margin-top: 14px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: #3f5058;
    font-size: 13px;
}
.viewer-tips p { margin: 0; }
[hidden] { display: none !important; }

.pdf-pane { background: #f0f3f4; display: block; overflow-y: auto; overflow-x: hidden; }
.pdf-tools { justify-content: space-between; padding: 10px; border-bottom: 1px solid var(--line); background: #fff; }
.pdf-tools button { min-height: 30px; font-size: 13px; }
.pdf-pane iframe { width: 100%; height: 100%; border: 0; background: #d8dee1; }
.pdf-page-viewer {
    min-height: 0;
    overflow: auto;
    display: grid;
    grid-template-rows: auto auto auto auto auto;
    background: #d8dee1;
}
.pdf-page-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #f9fbfb;
    border-bottom: 1px solid var(--line);
}
.pdf-page-controls label {
    width: auto;
    display: flex;
    grid-template-columns: none;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}
.pdf-page-controls input { width: 76px; padding: 4px 7px; }
.pdf-page-controls select { width: 92px; padding: 4px 7px; }
.strike-button s { text-decoration-thickness: 2px; }
.strike-button:disabled {
    border-color: #b8c7cc;
    color: #8b989f;
    background: #f3f5f6;
    cursor: default;
}
.pdf-single-page {
    min-height: 0;
    padding: 14px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}
.pdf-single-page img {
    max-width: 100%;
    height: auto;
    background: #fff;
    border: 1px solid #b8c7cc;
    box-shadow: 0 2px 8px rgba(24, 33, 38, .14);
}

.pdfjs-page-viewer {
    min-height: 0;
    overflow: visible;
    display: grid;
    grid-template-rows: auto auto auto auto auto;
    background: #d8dee1;
}
.pdfjs-safari-note {
    padding: 7px 10px;
    border-bottom: 1px solid var(--line);
    background: #fff8e8;
    color: #6f4b12;
    font-size: 13px;
}
.pdfjs-stage {
    min-height: 0;
    overflow: visible;
    padding: 14px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}
.pdfjs-page {
    position: relative;
    overflow: hidden;
    flex: 0 0 auto;
    background: #fff;
    border: 1px solid #b8c7cc;
    box-shadow: 0 2px 8px rgba(24, 33, 38, .14);
}
.pdfjs-page canvas {
    position: relative;
    z-index: 0;
    display: block;
    background: #fff;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}
.pdfjs-page .textLayer {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: auto;
    user-select: text;
    -webkit-user-select: text;
    cursor: text;
}
.pdfjs-page .textLayer span {
    user-select: text;
    -webkit-user-select: text;
}
.pdfjs-highlight-layer {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}
.pdfjs-highlight-mark {
    position: absolute;
    border-radius: 2px;
    background: rgba(255, 245, 157, .55);
}
.pdfjs-page-viewer.is-safari .textLayer {
    display: none;
}
.pdfjs-text-fallback span {
    position: absolute;
    color: transparent;
    white-space: pre;
    transform-origin: 0 0;
}

.highlight-status {
    min-height: 28px;
    padding: 6px 10px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
}
.pdf-text-layer, .highlight-list {
    background: #fff;
    border-top: 1px solid var(--line);
    padding: 10px;
}
.pdfjs-highlight-list {
    overflow: visible;
    background: #fff;
    border-top: 1px solid var(--line);
    padding: 10px;
}
.pdf-text-layer {
    max-height: 42vh;
    overflow: auto;
    cursor: text;
    user-select: text;
}
.pdf-text-head {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 6px;
    text-transform: uppercase;
    user-select: none;
}
.pdf-text-block {
    margin: 0 0 8px;
    padding: 7px 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    color: #27343b;
    line-height: 1.45;
    white-space: pre-wrap;
    user-select: text;
    cursor: text;
}
.pdf-text-block:hover { border-color: var(--line); background: #f9fbfb; }
.document-highlight {
    background: #fff176;
    border-radius: 2px;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}
.highlight-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 0;
    border-top: 1px solid var(--line);
    font-size: 13px;
}
.highlight-row:first-child { border-top: 0; }
.highlight-row mark { background: #fff176; color: inherit; }

.inline-preview-item {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.inline-preview-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.inline-preview-form {
    display: grid;
    gap: 12px;
}
.empty-state {
    display: grid;
    align-content: start;
    gap: 6px;
    padding: 14px;
    color: var(--muted);
}

.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }

.export-page { max-width: 960px; margin: 0 auto; }
.export-item { border-top: 1px solid var(--line); padding: 16px 0; }

@media print {
    .topbar, .print-hide { display: none; }
    body { background: #fff; }
    main { padding: 0; }
    .export-page { border: 0; }
}

@media (max-width: 1100px) {
    .workspace { grid-template-columns: 280px 1fr; height: calc(100vh - 90px); }
    .column-resizer { display: none; }
    .item-list { grid-column: 1; grid-row: 1; overflow-y: scroll; height: 100%; }
    .item-detail { grid-column: 2; grid-row: 1; overflow-y: scroll; height: 100%; }
    .pdf-pane { grid-column: 1 / -1; grid-row: 1; overflow-y: auto; overflow-x: hidden; height: 100%; border-top: 1px solid var(--line); }
    .workspace.pdf-collapsed { grid-template-columns: 280px 1fr; }
    .workspace.agenda-collapsed { grid-template-columns: 0 1fr; }
    .workspace.agenda-collapsed .item-list { display: none; }
    .upload-strip { display: grid; }
}

.incoming-piece-list {
    display: grid;
    gap: 8px;
}
.incoming-piece {
    display: grid;
    gap: 4px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
}
.incoming-piece:hover, .incoming-piece.selected {
    background: #eef6f7;
    border-color: #b9d4d7;
    text-decoration: none;
}
.incoming-piece small {
    color: var(--muted);
}
.piece-meta {
    margin: 0 0 16px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.piece-meta h3 { margin-bottom: 8px; }
.piece-meta dl { margin: 0; }

.attachment-list {
    display: grid;
    gap: 8px;
}
.attachment-list h4 {
    margin: 0;
    font-size: 14px;
}
.attachment-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f9fbfb;
    color: var(--text);
}
.attachment-link:hover {
    background: #eef6f7;
    border-color: #b9d4d7;
    text-decoration: none;
}
.attachment-link small {
    color: var(--muted);
    white-space: nowrap;
}


.mission-open-action { flex-shrink: 0; }
.mission-summary {
    flex: 1;
    min-width: 0;
    color: var(--text);
}
.mission-row-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

@media (max-width: 760px) {
    .proposal-review { grid-template-columns: 1fr; }
    .mission-filters, .discussion-filters { grid-template-columns: 1fr; }
    .mission-row { align-items: flex-start; }
    .mission-row-actions { flex-direction: column; align-items: flex-end; }
    .discussion-row { grid-template-columns: 1fr; }
    .discussion-row strong { white-space: normal; }
}


.assignment-panel, .assignment-table {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 16px;
}
.assignment-bulk {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) minmax(180px, 260px) auto;
    gap: 10px;
    align-items: end;
}
.assignment-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.assignment-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(190px, 260px);
    gap: 14px;
    align-items: start;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}
.assignment-row small { display: block; color: var(--muted); margin-top: 4px; }
@media (max-width: 900px) {
    .assignment-bulk, .assignment-row { grid-template-columns: 1fr; }
}


.user-list { display: grid; gap: 12px; }
.user-row {
    display: grid;
    gap: 10px;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.user-edit-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(150px, 1fr)) minmax(110px, auto);
    gap: 10px;
    align-items: end;
}
.user-actions {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
}
.user-delete-form { display: none; }
@media (max-width: 1100px) {
    .user-edit-form { grid-template-columns: 1fr; }
    .user-actions { justify-content: flex-start; }
}
