/* VanWestreenen-huisstijl — donkergroen #005837, staalblauw #3893ba */
:root {
  --groen: #005837;
  --groen-donker: #00472c;
  --groen-licht: #dce9e4;
  --blauw: #3893ba;
  --blauw-donker: #2c7696;
  --bg: #f4f7f5;
  --card: #ffffff;
  --border: #dfe8e2;
  --text: #16271e;
  --muted: #5c7064;
  --ok: #2e7d32;
  --err: #c62828;
  --schaduw: 0 1px 3px rgba(0, 71, 44, 0.07), 0 6px 18px rgba(0, 71, 44, 0.06);
}

* { box-sizing: border-box; }

/* ── Boot-loader (tot config/modellen geladen zijn) ──── */

.boot-loader {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 50vh;
  color: var(--muted);
  font-size: 14px;
}

body.booting .boot-loader { display: flex; }
body.booting main .view { display: none; }

.boot-spinner {
  width: 38px;
  height: 38px;
  border: 4px solid var(--border);
  border-top-color: var(--groen);
  border-radius: 50%;
  animation: boot-spin 0.8s linear infinite;
}

@keyframes boot-spin { to { transform: rotate(360deg); } }

body {
  margin: 0;
  font-family: "Open Sans", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

/* ── App-shell & sidebar ──────────────────────────────── */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 256px;
  flex-shrink: 0;
  background: var(--groen-donker);
  color: #eaf2ee;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 22px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar-brand .logo { height: 40px; width: auto; filter: brightness(0) invert(1); }
.sidebar-brand .brand-text { display: flex; flex-direction: column; min-width: 0; }
.sidebar-brand strong { font-size: 1rem; font-weight: 800; letter-spacing: -0.01em; }
.sidebar-brand span { font-size: 0.72rem; color: rgba(234, 242, 238, 0.6); }

.side-nav { display: flex; flex-direction: column; gap: 3px; padding: 14px 12px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: transparent;
  color: rgba(234, 242, 238, 0.82);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 11px 14px;
  border-radius: 9px;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-item.actief { background: var(--groen); color: #fff; }
.nav-icon { display: inline-flex; }
.nav-icon svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 16px 22px;
  font-size: 0.72rem;
  color: rgba(234, 242, 238, 0.6);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar-foot .footer-mark { height: 20px; width: auto; filter: brightness(0) invert(1); opacity: 0.7; }

/* ── Content ──────────────────────────────────────────── */

.app-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.content-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 20px 40px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.content-head #page-title { font-size: 1.3rem; font-weight: 800; margin: 0; color: var(--groen); letter-spacing: -0.01em; }
.header-actions { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }

main { width: 100%; margin: 0 auto; padding: 32px 40px 90px; flex: 1 0 auto; }

.card {
  background: var(--card);
  border-radius: 14px;
  padding: 28px 30px;
  box-shadow: var(--schaduw);
}
.view .card + .card { margin-top: 22px; }

.card h2 {
  font-size: 1.02rem;
  font-weight: 700;
  margin: 0 0 18px;
  color: var(--groen);
  display: flex;
  align-items: center;
  gap: 10px;
}

.view { display: none; max-width: 980px; margin: 0 auto; }
.view.actief { display: block; animation: fadein 0.18s ease; }
.view#historie { max-width: 1400px; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card-icon { display: inline-flex; color: var(--groen); }
.card-icon svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.sub-titel {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--groen);
  margin: 26px 0 4px;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 14px 20px;
}

/* ── Formulieren ──────────────────────────────────────── */

label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}
label.full { margin-top: 14px; }
label.checkbox { flex-direction: row; align-items: center; gap: 9px; margin-top: 12px; font-weight: 400; }

input, select, textarea {
  font: inherit;
  font-weight: 400;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--groen);
  box-shadow: 0 0 0 3px rgba(0, 88, 55, 0.12);
}

input[type="checkbox"] { accent-color: var(--groen); width: 16px; height: 16px; }

textarea { width: 100%; resize: vertical; font-family: Consolas, monospace; font-size: 0.83rem; line-height: 1.5; }

/* ── Multiselect ──────────────────────────────────────── */

.multiselect { position: relative; }

.ms-control {
  width: 100%;
  text-align: left;
  font: inherit;
  font-weight: 400;
  padding: 8px 30px 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fff
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%235c7064' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E")
    no-repeat right 12px center;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ms-control:hover { border-color: var(--groen); }
.ms-control:focus { outline: none; border-color: var(--groen); box-shadow: 0 0 0 3px rgba(0, 88, 55, 0.12); }
.ms-control.leeg { color: var(--muted); }

.ms-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--schaduw);
  padding: 4px;
}

.ms-option {
  flex-direction: row;
  align-items: center;
  gap: 9px;
  font-weight: 400;
  color: var(--text);
  padding: 7px 9px;
  border-radius: 6px;
  cursor: pointer;
}
.ms-option:hover { background: var(--groen-licht); }
.ms-option span { font-size: 0.84rem; }

/* ── Knoppen ──────────────────────────────────────────── */

button {
  font: inherit;
  font-weight: 600;
  padding: 9px 20px;
  border: none;
  border-radius: 8px;
  background: var(--groen-licht);
  color: var(--groen);
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.primary { background: var(--groen); color: #fff; }
button.primary:hover { background: var(--groen-donker); }

button.cta {
  background: var(--groen);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 88, 55, 0.3);
}
button.cta:hover { background: var(--groen-donker); }

button.ghost { background: transparent; color: var(--muted); }
button.ghost:hover { background: var(--bg); color: var(--text); }

button.small { font-size: 0.72rem; padding: 3px 12px; margin-left: 10px; background: var(--groen-licht); }
button.small-add { font-size: 0.8rem; padding: 6px 16px; margin-top: 12px; }
button.small-add:hover { background: var(--groen); color: #fff; }

.save-bar {
  position: fixed;
  right: 28px;
  bottom: 24px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 71, 44, 0.22);
  transform: translateY(160%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s ease, opacity 0.22s ease;
}
body.has-changes .save-bar {
  transform: none;
  opacity: 1;
  pointer-events: auto;
}
.save-bar .hint:empty { display: none; }

/* ── Badges & status ──────────────────────────────────── */

.badge {
  font-size: 0.76rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--groen-licht);
  color: var(--groen);
  white-space: nowrap;
}
.badge.ok { background: #e3f2e5; color: var(--ok); }
.badge.err { background: #fdecea; color: var(--err); }
.badge.busy { background: #e1eff5; color: var(--blauw-donker); }

.hint { font-size: 0.79rem; font-weight: 400; color: var(--muted); line-height: 1.5; }
.hidden { display: none !important; }
.sp-test-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.sp-test-row .hint { margin: 0; }
.sp-folder-nav { display: flex; flex-direction: column; gap: 8px; }
.sp-folder-pad { display: flex; align-items: center; gap: 8px; }
.sp-folder-pad code { flex: 1; }

code {
  background: var(--groen-licht);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--groen-donker);
}

/* ── Tabellen ─────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 700; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; }
#runs-table tbody tr:hover { background: var(--bg); }

#clear-runs { margin-left: auto; }
.run-del { background: none; color: var(--err); font-size: 0.95rem; padding: 4px 8px; }
.run-del:hover { background: #fdecea; }

a { color: var(--blauw-donker); font-weight: 600; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Velden-editor */
#velden-table input, #velden-table select,
#matching-velden-table input, #matching-velden-table select { width: 100%; }
#velden-table td, #matching-velden-table td { padding: 4px 6px; border-bottom: none; }
#velden-table th, #matching-velden-table th { border-bottom: 1px solid var(--border); }
.veld-rij-vast input:disabled {
  background: var(--bg);
  color: var(--tekst-zacht, #6b7280);
  border-color: transparent;
  cursor: default;
}
.veld-vast-icoon {
  display: inline-block;
  padding: 4px 8px;
  font-size: 0.85rem;
  opacity: 0.55;
}
.veld-del {
  background: none;
  color: var(--err);
  font-size: 0.95rem;
  padding: 4px 8px;
}
.veld-del:hover { background: #fdecea; }

/* ── AFAS-koppelingen ─────────────────────────────────── */

.afas-koppeling {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 14px;
}
.afas-kop-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.afas-kop-head .checkbox { margin-top: 0; font-weight: 600; color: var(--groen); }
.kop-del { background: none; color: var(--err); font-size: 0.95rem; padding: 4px 8px; }
.kop-del:hover { background: #fdecea; }
.afas-koppeling .grid select, .afas-koppeling .grid input { width: 100%; }

.match-velden { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); }
.mv-titel { display: block; font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.mv-rij { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.mv-rij .mv-select { flex: 1; }
.mv-del { background: none; color: var(--err); font-size: 0.95rem; padding: 4px 8px; }
.mv-del:hover { background: #fdecea; }

/* ── Log-modal ────────────────────────────────────────── */

.log-lines {
  background: #0c130f;
  color: #e8f0ec;
  font-family: Consolas, monospace;
  font-size: 0.78rem;
  border-radius: 10px;
  max-height: 60vh;
  overflow: auto;
  padding: 8px;
}
.log-lijn {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 2px 8px;
  border-radius: 5px;
}
.log-lijn:hover { background: rgba(255, 255, 255, 0.06); }
.log-tekst { flex: 1; white-space: pre-wrap; word-break: break-word; }
.log-del {
  background: none;
  color: #ff8a8a;
  font-size: 0.78rem;
  padding: 0 6px;
  flex-shrink: 0;
  opacity: 0;
}
.log-lijn:hover .log-del { opacity: 1; }
.log-del:hover { background: rgba(255, 255, 255, 0.12); }
.log-leeg { color: #9fb3a8; padding: 8px; }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: rgba(0, 30, 18, 0.45);
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 30, 18, 0.35);
  width: 100%;
  max-width: 860px;
  padding: 22px 26px 26px;
}
.modal.modal-sm { max-width: 440px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h2 {
  font-size: 1.05rem; font-weight: 700; margin: 0; color: var(--groen);
  display: flex; align-items: center; gap: 10px;
}
.modal-acties { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.login-modal { text-align: center; }
.login-modal .login-logo { max-width: 200px; margin: 6px auto 16px; display: block; }
.login-modal h2 { font-size: 1.1rem; font-weight: 700; color: var(--groen); margin: 0 0 8px; }
.login-modal .modal-acties { justify-content: center; }

/* ── Responsive ───────────────────────────────────────── */

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar-brand { border-bottom: none; padding: 16px 20px; }
  .side-nav { flex-direction: row; flex-wrap: wrap; flex: 1; padding: 12px; }
  .nav-item { width: auto; }
  .sidebar-foot { display: none; }
  .content-head { padding: 16px 20px; }
  main { padding: 22px 18px 80px; }
  .card { padding: 20px; }
}
