:root {
  --navy: #073889;
  --navy-dark: #052765;
  --navy-light: #0a4aad;
  --oranje: #f46015;
  --oranje-dark: #d64f0a;
  --sky: #009cdc;
  --bg: #f5f7fa;
  --card: #ffffff;
  --border: #e3e8f0;
  --text: #1a2b42;
  --text-muted: #6b7789;
  --success: #22a55a;
  --warn: #f5a623;
  --danger: #e44b4b;
  --purple: #7c4dcc;
  --shadow-sm: 0 1px 2px rgba(10, 30, 70, 0.06);
  --shadow: 0 2px 8px rgba(10, 30, 70, 0.08);
  --shadow-lg: 0 12px 40px rgba(10, 30, 70, 0.18);
  --radius: 8px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-family: 'Exo', 'Source Sans 3', sans-serif;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: -0.01em;
}

.hidden { display: none !important; }

a { color: inherit; text-decoration: none; }

button { font-family: inherit; cursor: pointer; }

input, select, textarea {
  font-family: inherit;
  font-size: 15px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(7, 56, 137, 0.12);
}

textarea { resize: vertical; min-height: 80px; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  background: #fff;
  color: var(--text);
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); }

.btn-secondary { background: var(--oranje); color: #fff; }
.btn-secondary:hover { background: var(--oranje-dark); }

.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: #f0f3f8; }

.btn-small { padding: 7px 12px; font-size: 13px; }

.btn-danger { background: var(--danger); color: #fff; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 28px;
  padding: 4px 10px;
  border-radius: var(--radius);
  line-height: 1;
}
.icon-btn:hover { background: rgba(0,0,0,0.06); color: var(--text); }

/* ============ Login ============ */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 50%, var(--sky) 100%);
  z-index: 100;
}

.login-box {
  background: #fff;
  padding: 48px 44px;
  border-radius: var(--radius-lg);
  width: 380px;
  max-width: calc(100% - 32px);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.login-logo {
  height: 48px;
  margin-bottom: 18px;
}

.login-box h1 {
  font-size: 28px;
  margin-bottom: 6px;
}

.login-sub {
  color: var(--text-muted);
  margin-bottom: 28px;
  font-size: 14px;
}

.btn-login {
  width: 100%;
  padding: 12px;
  font-size: 15px;
}

.login-help {
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ============ App layout ============ */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand img { height: 36px; }
.brand-name { font-family: 'Exo', sans-serif; font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 11px; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.08em; }

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: rgba(255,255,255,0.78);
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 14px;
  position: relative;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: var(--oranje); color: #fff; }

.badge {
  position: absolute;
  right: 10px;
  background: var(--oranje);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}
.nav-item.active .badge {
  background: #fff;
  color: var(--oranje);
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-info {
  display: flex;
  gap: 10px;
  align-items: center;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--oranje);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 14px;
}

.user-details { overflow: hidden; }
.user-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 11px; opacity: 0.7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-footer .btn-ghost {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
  color: #fff;
}
.sidebar-footer .btn-ghost:hover {
  background: rgba(255,255,255,0.15);
}

/* ============ Main ============ */
.main {
  flex: 1;
  padding: 28px 32px;
  overflow-x: hidden;
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.view-header h1 { font-size: 26px; margin-bottom: 2px; }
.view-sub { color: var(--text-muted); font-size: 14px; }

.view-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.view-toggle {
  display: flex;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.toggle-btn {
  padding: 8px 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  transition: all 0.15s;
}
.toggle-btn:hover { color: var(--navy); }
.toggle-btn.active { background: var(--navy); color: #fff; }

/* ============ Dashboard ============ */
.dashboard-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: start;
}

.filters {
  background: #fff;
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.filter-section { display: flex; flex-direction: column; gap: 8px; }

.filter-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.checkbox-group { display: flex; flex-direction: column; gap: 6px; }
.checkbox-group label,
.radio-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  padding: 3px 0;
}

.radio-group { display: flex; flex-direction: column; gap: 8px; }

.checkbox-group input[type="checkbox"],
.radio-group input[type="radio"] {
  width: auto;
  accent-color: var(--navy);
}

.content { min-width: 0; }

.results-info {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 14px;
}

.contacts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}

.contacts-grid.list-mode {
  grid-template-columns: 1fr;
}

.contact-card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.contact-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--navy-light);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.contact-name {
  font-family: 'Exo', sans-serif;
  font-weight: 600;
  color: var(--navy);
  font-size: 16px;
  line-height: 1.2;
}

.contact-employer {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.contact-title {
  color: var(--text-muted);
  font-size: 13px;
}

.contact-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: auto;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.former-owner {
  display: flex;
  align-items: center;
  gap: 4px;
}

.list-mode .contact-card {
  flex-direction: row;
  align-items: center;
  padding: 12px 16px;
}
.list-mode .card-top {
  flex: 1;
  align-items: center;
}
.list-mode .contact-meta,
.list-mode .card-footer {
  border: none;
  padding: 0;
  margin: 0;
  flex-shrink: 0;
}
.list-mode .card-top > div { flex: 1; }

/* ============ Badges ============ */
.badge-sm {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge-heet { background: rgba(244, 96, 21, 0.15); color: var(--oranje-dark); }
.badge-warm { background: rgba(245, 166, 35, 0.18); color: #b37210; }
.badge-lauw { background: rgba(0, 156, 220, 0.14); color: #0070a0; }
.badge-koud { background: rgba(107, 119, 137, 0.18); color: var(--text-muted); }

.badge-status { background: rgba(34, 165, 90, 0.15); color: var(--success); }
.badge-geclaimd { background: rgba(7, 56, 137, 0.12); color: var(--navy); }
.badge-gesprek { background: rgba(124, 77, 204, 0.14); color: var(--purple); }
.badge-niet { background: rgba(107, 119, 137, 0.18); color: var(--text-muted); }

/* ============ Pagination ============ */
.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 24px;
}
.page-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
}
.page-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============ Slide-over ============ */
.slideover-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 40, 0.45);
  z-index: 50;
  animation: fadeIn 0.18s;
}
.slideover {
  position: fixed;
  top: 0;
  right: 0;
  width: 520px;
  max-width: 100%;
  height: 100vh;
  background: #fff;
  z-index: 60;
  display: flex;
  flex-direction: column;
  box-shadow: -12px 0 40px rgba(10, 20, 40, 0.2);
  animation: slideIn 0.22s cubic-bezier(.3,.6,.2,1);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

.slideover-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.slideover-header h2 {
  font-size: 20px;
  flex: 1;
}
.slideover-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.so-section {
  margin-bottom: 24px;
}
.so-section h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.so-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.so-row:last-child { border-bottom: none; }
.so-row-label { color: var(--text-muted); font-size: 14px; flex-shrink: 0; }
.so-row-value { font-weight: 500; text-align: right; }
.so-row-value a { color: var(--navy-light); text-decoration: underline; }

.ai-summary {
  background: linear-gradient(135deg, rgba(7, 56, 137, 0.06), rgba(0, 156, 220, 0.08));
  padding: 14px 16px;
  border-radius: var(--radius);
  border-left: 3px solid var(--navy);
  font-size: 14px;
  margin-bottom: 16px;
  position: relative;
}
.ai-summary::before {
  content: "AI-samenvatting";
  position: absolute;
  top: -10px;
  left: 14px;
  background: var(--navy);
  color: #fff;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.job-change-item {
  padding: 12px 14px;
  background: var(--bg);
  border-radius: var(--radius);
  margin-bottom: 10px;
  font-size: 14px;
  border: 1px solid var(--border);
}
.job-change-item .jc-arrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}
.jc-from, .jc-to { font-weight: 600; }
.jc-from { color: var(--text-muted); text-decoration: line-through; text-decoration-color: rgba(107,119,137,0.4); }
.jc-to { color: var(--navy); }
.jc-date { font-size: 12px; color: var(--text-muted); }

.note-item {
  padding: 10px 14px;
  background: var(--bg);
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 14px;
}
.note-author {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.note-form { display: flex; flex-direction: column; gap: 8px; }

.so-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.status-select {
  margin-bottom: 10px;
}

/* ============ Meldingen ============ */
.meldingen-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.melding-item {
  background: #fff;
  padding: 16px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}
.melding-item:hover { transform: translateX(2px); box-shadow: var(--shadow); }

.melding-unread-dot {
  width: 10px;
  height: 10px;
  background: var(--sky);
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

.melding-content { flex: 1; }

.melding-title {
  font-weight: 600;
  color: var(--navy);
  font-size: 15px;
  font-family: 'Exo', sans-serif;
}
.melding-change {
  font-size: 14px;
  margin: 4px 0;
}
.melding-summary {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}
.melding-date {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ============ Settings ============ */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}
.card {
  background: #fff;
  padding: 22px 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.card h2 { font-size: 17px; margin-bottom: 4px; }
.card-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 14px; }
.card-wide { grid-column: 1 / -1; }
.card-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.action-status {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
}
.action-status.success { background: rgba(34, 165, 90, 0.1); color: #116934; border: 1px solid rgba(34, 165, 90, 0.3); }
.action-status.working { background: rgba(0, 156, 220, 0.1); color: #044e6e; border: 1px solid rgba(0, 156, 220, 0.3); }

.user-add {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 16px;
}
.users-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: var(--radius);
}
.user-row-info { display: flex; flex-direction: column; }
.user-row-name { font-weight: 600; }
.user-row-email { font-size: 12px; color: var(--text-muted); }

/* ============ Toasts ============ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}
.toast {
  background: var(--navy);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 500;
  max-width: 360px;
  animation: toastIn 0.2s;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ============ Empty & loading ============ */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 40px; margin-bottom: 10px; opacity: 0.5; }
.empty h3 { color: var(--navy); margin-bottom: 6px; }

.skeleton {
  background: linear-gradient(90deg, #f0f3f8 25%, #e3e8f0 50%, #f0f3f8 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--radius);
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ============ Responsive ============ */
@media (max-width: 1100px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .filters { position: static; }
}

@media (max-width: 768px) {
  .sidebar {
    width: 80px;
    position: sticky;
  }
  .brand-name, .brand-sub, .nav-item span:not(.badge), .user-details, .sidebar-footer .btn-ghost {
    display: none;
  }
  .sidebar-brand { justify-content: center; padding: 16px 8px; }
  .nav-item { justify-content: center; }
  .main { padding: 20px 16px; }
  .view-header h1 { font-size: 22px; }
  .contacts-grid { grid-template-columns: 1fr; }
  .slideover { width: 100vw; }
  .user-add { grid-template-columns: 1fr; }
}
