:root {
  --brand: #205375;
  --brand-dark: #133a54;
  --brand-darker: #0d2b40;
  --brand-50: #eef4f8;
  --brand-100: #d7e5ee;
  --accent: #f79c41;
  --accent-dark: #e0832a;
  --accent-50: #fef3e7;

  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1b2733;
  --muted: #64748b;
  --border: #e3e8ef;
  --border-strong: #cfd7e2;

  --green: #1f9d6b;
  --green-50: #e6f6ef;
  --red: #d64545;
  --red-50: #fdecec;
  --amber: #c98012;
  --amber-50: #fdf4e3;
  --grey-50: #eef1f5;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 38, 58, .05), 0 1px 3px rgba(16, 38, 58, .06);
  --shadow-lg: 0 20px 50px rgba(13, 43, 64, .22);
  --sidebar: 248px;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 { margin: 0; line-height: 1.25; }

button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Login ---------- */

.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}

.login-brand {
  background: radial-gradient(circle at 20% 15%, #2a6890 0%, var(--brand-dark) 45%, var(--brand-darker) 100%);
  color: #fff;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.login-brand::after {
  content: "";
  position: absolute;
  right: -120px;
  bottom: -120px;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  border: 48px solid rgba(247, 156, 65, .14);
}

.login-brand img { width: 190px; height: auto; }

.login-brand h1 { font-size: 34px; font-weight: 700; max-width: 440px; letter-spacing: -.02em; }
.login-brand h1 span { color: var(--accent); }
.login-brand p { color: rgba(255, 255, 255, .72); max-width: 420px; font-size: 15px; margin: 16px 0 0; }
.login-brand small { color: rgba(255, 255, 255, .5); }

.login-form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 24px; letter-spacing: -.01em; }
.login-card .sub { color: var(--muted); margin: 6px 0 28px; }
.login-card form { display: grid; gap: 16px; }
.login-card .btn { width: 100%; justify-content: center; padding: 11px 16px; }
.login-hint {
  margin-top: 24px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--brand-50);
  color: var(--brand-dark);
  font-size: 13px;
}

.form-error {
  background: var(--red-50);
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
}

/* ---------- Shell ---------- */

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

.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--brand-dark) 0%, var(--brand-darker) 100%);
  color: rgba(255, 255, 255, .78);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  transition: transform .2s ease;
}

.sidebar-logo { padding: 26px 24px 22px; }
.sidebar-logo img { width: 150px; height: auto; display: block; }
.sidebar-logo span {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .45);
}

.nav { padding: 8px 12px; display: grid; gap: 2px; }
.nav-label {
  padding: 16px 12px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255, 255, 255, .38);
}

.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, .78);
  font-weight: 500;
  position: relative;
}
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(255, 255, 255, .11); color: #fff; }
.nav a.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.nav a.active svg { color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav .count {
  margin-left: auto;
  font-size: 12px;
  color: rgba(255, 255, 255, .5);
}

.sidebar-foot {
  margin-top: auto;
  padding: 16px 20px 20px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  display: grid;
  gap: 12px;
}

.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip .avatar { background: var(--accent); color: var(--brand-darker); }
.user-chip b { display: block; color: #fff; font-weight: 600; font-size: 13px; }
.user-chip small { color: rgba(255, 255, 255, .5); font-size: 12px; }

.sidebar-foot .links { display: flex; gap: 14px; }
.sidebar-foot .links button {
  background: none;
  border: 0;
  padding: 0;
  color: rgba(255, 255, 255, .55);
  font-size: 12px;
  cursor: pointer;
}
.sidebar-foot .links button:hover { color: #fff; }

.main {
  flex: 1;
  margin-left: var(--sidebar);
  min-width: 0;
}

.topbar {
  height: 64px;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.menu-btn {
  display: none;
  background: none;
  border: 0;
  padding: 6px;
  margin-left: -6px;
  cursor: pointer;
  color: var(--text);
}
.menu-btn svg { width: 22px; height: 22px; display: block; }

.crumbs { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; min-width: 0; }
.crumbs b { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs a { color: var(--muted); }

.topbar .search {
  margin-left: auto;
  position: relative;
  width: 280px;
  max-width: 40vw;
}
.topbar .search input { padding-left: 36px; background: var(--bg); border-color: transparent; }
.topbar .search input:focus { background: #fff; }
.topbar .search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  max-height: 360px;
  overflow-y: auto;
}
.search-results a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  color: var(--text);
}
.search-results a:hover, .search-results a:focus { background: var(--brand-50); text-decoration: none; outline: none; }
.search-results small { color: var(--muted); white-space: nowrap; }
.search-results .empty-row { padding: 12px; color: var(--muted); }

.content { padding: 28px 32px 48px; max-width: 1360px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13, 43, 64, .4);
  z-index: 25;
}

/* ---------- Controls ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-accent { background: var(--accent); color: #3b1f02; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-ghost { background: #fff; border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: #fff; border-color: #f1c4c4; color: var(--red); }
.btn-danger:hover { background: var(--red-50); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon {
  background: none;
  border: 0;
  padding: 4px;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
}
.btn-icon:hover { background: var(--bg); color: var(--red); }
.btn-icon svg { width: 15px; height: 15px; }

label.field { display: grid; gap: 6px; }
label.field > span { font-size: 13px; font-weight: 500; color: #334155; }

input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(32, 83, 117, .14);
}
textarea { resize: vertical; min-height: 84px; }

.toolbar {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.toolbar input { max-width: 300px; }
.toolbar select { width: auto; min-width: 160px; }

/* ---------- Cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 15px; font-weight: 600; }
.card-head .meta { color: var(--muted); font-size: 13px; }
.card-body { padding: 20px; }

.grid { display: grid; gap: 20px; }
.grid-kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.grid-dossier { grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); align-items: start; }
.stack { display: grid; gap: 20px; align-content: start; }

.kpi { padding: 20px; position: relative; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.kpi .icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--brand-50);
  color: var(--brand);
  margin-bottom: 14px;
}
.kpi .icon svg { width: 18px; height: 18px; }
.kpi .icon.accent { background: var(--accent-50); color: var(--accent-dark); }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.kpi .value small { font-size: 15px; color: var(--muted); font-weight: 500; }
.kpi .foot { margin-top: 6px; color: var(--muted); font-size: 12.5px; }
.kpi .foot b { color: var(--text); font-weight: 600; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 10px 16px;
  background: #fafbfd;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #f8fafc; }
td.num, th.num { text-align: right; white-space: nowrap; }
td .sub { color: var(--muted); font-size: 12.5px; }
.cell-name { display: flex; align-items: center; gap: 12px; min-width: 200px; }
.cell-name b { font-weight: 600; display: block; }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

/* ---------- Badges, avatars, progress ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--grey-50);
  color: #475569;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.green { background: var(--green-50); color: var(--green); }
.badge.blue { background: var(--brand-50); color: var(--brand); }
.badge.orange { background: var(--accent-50); color: var(--accent-dark); }
.badge.amber { background: var(--amber-50); color: var(--amber); }
.badge.red { background: var(--red-50); color: var(--red); }
.badge.plain::before { display: none; }

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-weight: 700;
  font-size: 13px;
  background: var(--brand-50);
  color: var(--brand);
}
.avatar.round { border-radius: 50%; }
.avatar.lg { width: 56px; height: 56px; font-size: 19px; border-radius: 14px; }
.avatar.lg.round { border-radius: 50%; }

.progress { height: 6px; border-radius: 999px; background: var(--grey-50); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.progress.warn > span { background: var(--accent); }
.progress.over > span { background: var(--red); }
.hours { min-width: 150px; }
.hours .nums { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.hours .nums b { color: var(--text); font-weight: 600; }

/* ---------- Overview ---------- */

.status-bars { display: grid; gap: 14px; }
.status-bar .row { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 13px; }
.status-bar .row b { font-weight: 600; }
.status-bar .track { height: 8px; border-radius: 999px; background: var(--grey-50); overflow: hidden; }
.status-bar .track span { display: block; height: 100%; border-radius: inherit; }

.list { display: grid; }
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.list-item:last-child { border-bottom: 0; }
a.list-item:hover, .list-item.clickable:hover { background: #f8fafc; text-decoration: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .grow b { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .grow small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .right { color: var(--muted); font-size: 12.5px; text-align: right; white-space: nowrap; }

/* ---------- Dossier ---------- */

.dossier-head { padding: 24px; display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.dossier-head .grow { flex: 1; min-width: 220px; }
.dossier-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -.015em; }
.dossier-head .tags { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 13px; }
.dossier-head .actions { display: flex; gap: 8px; }

.dossier-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--border);
}
.dossier-stats div { padding: 14px 24px; border-right: 1px solid var(--border); }
.dossier-stats div:last-child { border-right: 0; }
.dossier-stats small { color: var(--muted); font-size: 12px; display: block; }
.dossier-stats b { font-size: 17px; font-weight: 700; }

dl.details { margin: 0; display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 10px 16px; }
dl.details dt { color: var(--muted); font-size: 13px; }
dl.details dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Timeline ---------- */

.note-form { padding: 16px 20px; border-bottom: 1px solid var(--border); background: #fbfcfd; display: grid; gap: 10px; }
.note-form .row { display: flex; gap: 10px; flex-wrap: wrap; }
.note-form .row select { width: auto; flex: 1; min-width: 140px; }
.note-form .row .btn { margin-left: auto; }
.note-form textarea { min-height: 70px; }

.timeline { list-style: none; margin: 0; padding: 20px 20px 8px; position: relative; }
.timeline li { position: relative; padding: 0 0 22px 44px; }
.timeline li::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 32px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline li:last-child::before { display: none; }
.timeline .dot {
  position: absolute;
  left: 0;
  top: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand-50);
  color: var(--brand);
}
.timeline .dot svg { width: 15px; height: 15px; }
.timeline .dot.t-gesprek { background: var(--accent-50); color: var(--accent-dark); }
.timeline .dot.t-email { background: #ecebfd; color: #5b4fd6; }
.timeline .dot.t-afspraak { background: var(--green-50); color: var(--green); }
.timeline .head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.timeline .head b { font-weight: 600; }
.timeline .head small { color: var(--muted); }
.timeline .head .btn-icon { margin-left: auto; opacity: 0; transition: opacity .15s; }
.timeline li:hover .head .btn-icon, .timeline .head .btn-icon:focus { opacity: 1; }
.timeline .text { margin-top: 4px; white-space: pre-wrap; color: #334155; }
.timeline .by { margin-top: 4px; color: var(--muted); font-size: 12px; }

/* ---------- Modal & toast ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 43, 64, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 7vh 16px 16px;
  z-index: 50;
  overflow-y: auto;
  animation: fade .15s ease;
}
.modal {
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  animation: pop .18s ease;
}
.modal-head { padding: 20px 24px 0; display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { font-size: 18px; }
.modal-head .btn-icon:hover { color: var(--text); }
.modal-head .btn-icon svg { width: 20px; height: 20px; }
.modal-body { padding: 20px 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.modal-body .full { grid-column: 1 / -1; }
.modal-foot {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.modal-foot .btn-danger { margin-right: auto; }

#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 60; display: grid; gap: 8px; }
.toast {
  background: var(--brand-darker);
  color: #fff;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: pop .2s ease;
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-dossier { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-brand { padding: 28px 24px; gap: 32px; }
  .login-brand h1 { font-size: 24px; }

  .sidebar { transform: translateX(-100%); }
  .nav-open .sidebar { transform: none; }
  .nav-open .backdrop { display: block; }
  .main { margin-left: 0; }
  .menu-btn { display: block; }
  .topbar { padding: 0 16px; }
  .topbar .search { width: auto; flex: 1; max-width: none; }
  .crumbs { display: none; }
  .content { padding: 20px 16px 40px; }
  .dossier-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dossier-stats div:nth-child(2) { border-right: 0; }
  .dossier-stats div:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .hide-sm { display: none; }
}

@media (max-width: 520px) {
  .grid-kpi { grid-template-columns: minmax(0, 1fr); }
  .modal-body { grid-template-columns: 1fr; }
  .toolbar input, .toolbar select { max-width: none; width: 100%; }
  dl.details { grid-template-columns: 1fr; gap: 2px; }
  dl.details dd { margin-bottom: 8px; }
}
