/* ===== BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0e0f11;
  --surface: #16181c;
  --surface2: #1e2128;
  --surface3: #252830;
  --border: #2e3138;
  --accent: #e8a045;
  --accent2: #5b8dee;
  --accent3: #4ecb8d;
  --danger: #e05c5c;
  --warn: #e8a045;
  --text: #e8eaf0;
  --text2: #9aa0b0;
  --text3: #5a6070;
  --font: 'DM Sans', sans-serif;
  --mono: 'DM Mono', monospace;
  --radius: 8px;
  --radius-lg: 14px;
  --shadow: 0 2px 16px rgba(0,0,0,0.4);
}

body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.6; }
.hidden { display: none !important; }

/* ===== LOGIN ===== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 48px 40px; width: 380px; box-shadow: var(--shadow);
}
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.logo-icon { font-size: 22px; color: var(--accent); }
.logo-text { font-size: 18px; font-weight: 600; letter-spacing: -0.3px; }
.login-box h2 { font-size: 20px; font-weight: 500; margin-bottom: 24px; color: var(--text); }

/* ===== LAYOUT ===== */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 0;
}
.sidebar-header {
  display: flex; align-items: center; gap: 10px; padding: 20px 18px 18px;
  border-bottom: 1px solid var(--border);
}
.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius);
  color: var(--text2); text-decoration: none; font-size: 13.5px; font-weight: 500; transition: all 0.15s;
  cursor: pointer;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(232,160,69,0.12); color: var(--accent); }
.nav-icon { font-size: 13px; width: 18px; text-align: center; display: inline-block; }
.sidebar-footer { padding: 12px 8px 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.user-info { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #000;
  font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text3); text-transform: capitalize; }
.btn-logout {
  background: none; border: 1px solid var(--border); color: var(--text3); border-radius: var(--radius);
  padding: 7px 12px; cursor: pointer; font-size: 12px; transition: all 0.15s; text-align: left;
}
.btn-logout:hover { background: var(--surface2); color: var(--text); }

/* ===== MAIN ===== */
.main-content { flex: 1; overflow-y: auto; padding: 20px 32px; }
.page { display: none; }
.page.active { display: block; }

/* ===== PAGE HEADER ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 32px; font-weight: 600; letter-spacing: -0.3px; color: var(--accent); margin-top: -6px; }
.page-subtitle { color: var(--text2); font-size: 13px; margin-top: 2px; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
input, select, textarea {
  width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); padding: 9px 12px; font-family: var(--font); font-size: 13.5px; transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }
select option { background: var(--surface2); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: var(--radius);
  font-family: var(--font); font-size: 13.5px; font-weight: 500; cursor: pointer; border: none; transition: all 0.15s;
}
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: #f0b055; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface3); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #cc4a4a; }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-icon { padding: 7px 9px; font-size: 13px; }

/* ===== CARDS ===== */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px 22px;
}
.card-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text2); margin-bottom: 8px; }
.card-value { font-size: 28px; font-weight: 600; }
.card-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }

/* ===== STAT GRID ===== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 28px; }

/* ===== TABLE ===== */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--surface2); padding: 11px 14px; text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text3); }
td { padding: 11px 14px; border-top: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
tr:hover td { background: rgba(255,255,255,0.02); }
tr.clickable-row { cursor: pointer; }
tr.clickable-row:hover td { background: rgba(255,255,255,0.045); }

/* ===== REGEL-PICKER SUGGESTIES ===== */
.picker-suggesties {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  max-height: 280px;
  overflow-y: auto;
  z-index: 9999;
}
.picker-item {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
}
.picker-item:last-child { border-bottom: none; }
.picker-item:hover { background: var(--surface2); }

/* ===== BADGES ===== */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.badge-lead { background: rgba(90,96,112,0.3); color: var(--text2); }
.badge-gecontacteerd { background: rgba(91,141,238,0.2); color: var(--accent2); }
.badge-inkoop { background: rgba(232,160,69,0.2); color: var(--accent); }
.badge-geoffreerd { background: rgba(150,100,238,0.2); color: #a67fe8; }
.badge-gesloten { background: rgba(78,203,141,0.2); color: var(--accent3); }
.badge-open { background: rgba(90,96,112,0.3); color: var(--text2); }
.badge-in_uitvoering { background: rgba(232,160,69,0.2); color: var(--accent); }
.badge-afgerond { background: rgba(78,203,141,0.2); color: var(--accent3); }
.badge-actief { background: rgba(78,203,141,0.2); color: var(--accent3); }
.badge-inactief { background: rgba(90,96,112,0.3); color: var(--text2); }
.badge-geblokkeerd { background: rgba(224,92,92,0.2); color: var(--danger); }
.badge-laag { background: rgba(90,96,112,0.3); color: var(--text2); }
.badge-normaal { background: rgba(91,141,238,0.2); color: var(--accent2); }
.badge-hoog { background: rgba(224,92,92,0.2); color: var(--danger); }

/* ===== STARS ===== */
.stars { color: var(--accent); letter-spacing: 1px; font-size: 13px; }
.stars-empty { color: var(--surface3); }

/* ===== SEARCH BAR ===== */
.search-bar { display: flex; gap: 10px; margin-bottom: 18px; align-items: center; }
.search-bar input { max-width: 280px; }

/* ===== PIPELINE BOARD ===== */
.pipeline-board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.pipeline-col {
  min-width: 230px; max-width: 260px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); flex-shrink: 0;
}
.pipeline-col-header { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.pipeline-col-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.pipeline-col-count { background: var(--surface2); border-radius: 20px; padding: 1px 8px; font-size: 11px; font-family: var(--mono); }
.pipeline-cards { padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 80px; }
.deal-card {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 13px; cursor: pointer; transition: all 0.15s;
}
.deal-card:hover { border-color: var(--accent); background: var(--surface3); }
.deal-card-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.deal-card-sub { font-size: 11.5px; color: var(--text2); }
.deal-card-footer { display: flex; justify-content: space-between; margin-top: 8px; font-size: 11px; }
.deal-card.dragging { opacity: 0.5; }
.pipeline-col.drag-over { border-color: var(--accent); background: rgba(232,160,69,0.05); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  width: 100%; max-width: 820px; max-height: 90vh; overflow-y: auto; box-shadow: 0 8px 48px rgba(0,0,0,0.6);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1;
  cursor: grab; user-select: none;
}
.modal-header:active { cursor: grabbing; }
.modal-box.dragging { transition: none !important; }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 18px; padding: 2px 6px; }
.modal-close:hover { color: var(--text); }
#modal-body { padding: 22px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ===== ALERTS ===== */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 14px; }
.alert-error { background: rgba(224,92,92,0.15); border: 1px solid rgba(224,92,92,0.3); color: #f08080; }
.alert-success { background: rgba(78,203,141,0.15); border: 1px solid rgba(78,203,141,0.3); color: var(--accent3); }

/* ===== TABS ===== */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 9px 18px; background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text2); cursor: pointer; font-family: var(--font); font-size: 13.5px; font-weight: 500;
  margin-bottom: -1px; transition: all 0.15s;
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-btn:hover:not(.active) { color: var(--text); }

/* ===== NOTES ===== */
.note-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.note-item:last-child { border-bottom: none; }
.note-meta { font-size: 11px; color: var(--text3); margin-bottom: 5px; }
.note-type { display: inline-block; padding: 1px 8px; border-radius: 20px; background: var(--surface2); font-size: 10px; font-weight: 600; text-transform: uppercase; margin-right: 6px; }
.note-content { font-size: 13.5px; white-space: pre-wrap; }

/* ===== SCORE DISPLAY ===== */
.score-display { display: flex; align-items: center; gap: 8px; }
.score-bar { height: 5px; border-radius: 3px; background: var(--surface3); flex: 1; overflow: hidden; }
.score-fill { height: 100%; border-radius: 3px; background: var(--accent); }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text3); }
.empty-state .icon { font-size: 36px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; }

/* ===== DASHBOARD GRID ===== */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 20px; }
.dash-grid .card { overflow: hidden; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

/* ===== ACTION ROW ===== */
.action-row { display: flex; gap: 8px; }

/* ===== DETAIL PANEL ===== */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; margin-bottom: 16px; }
.detail-label { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; }
.detail-value { font-size: 13.5px; color: var(--text); margin-top: 2px; }

/* ===== LIGHT THEME ===== */
[data-theme="light"] {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface2: #f5f7fa;
  --surface3: #eaecef;
  --border: #dde1e7;
  --accent: #c87d2a;
  --accent2: #3a6fd4;
  --accent3: #2a9e68;
  --danger: #cc4444;
  --text: #1a1d23;
  --text2: #4a5060;
  --text3: #8a909f;
}

/* Theme toggle knop */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: var(--radius);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
  margin: 0 8px 8px;
  width: calc(100% - 16px);
  text-align: left;
}
.theme-toggle:hover { background: var(--surface2); color: var(--text); }

/* ===== MODAL SHAKE ANIMATIE ===== */
@keyframes modal-shake {
  0%   { margin-left: 0; }
  20%  { margin-left: -12px; }
  40%  { margin-left: 12px; }
  60%  { margin-left: -8px; }
  80%  { margin-left: 8px; }
  100% { margin-left: 0; }
}

/* Modal box flex layout voor sticky footer */
.modal-box {
  display: flex;
  flex-direction: column;
}

#modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
}

/* Sticky modal actions onderin */
.modal-actions {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 22px;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  z-index: 2;
}

/* ===== MODAL KNOPPEN — uniform formaat, geldt voor ALLE modals ===== */
.modal-actions .btn,
.modal-actions .btn.btn-sm,
.modal-actions .btn.btn-icon {
  padding: 9px 18px;
  font-size: 14px;
  min-height: 36px;
}

/* ===== MODAL FADE-IN ===== */
@keyframes modal-fadein {
  from { opacity: 0; transform: scale(0.97) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-overlay:not(.hidden) .modal-box {
  animation: modal-fadein 0.18s ease forwards;
}

/* ===== MOBIEL HAMBURGERMENU ===== */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 16px;
  gap: 14px;
  z-index: 200;
  box-shadow: 0 1px 8px rgba(0,0,0,0.08);
}

.mobile-logo {
  display: flex;
  align-items: center;
}

/* Hamburger knop */
.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius);
  transition: background 0.15s;
}
.hamburger:hover { background: var(--surface2); }
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transform-origin: center;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s ease,
              width 0.3s ease;
}

/* Hamburger → X animatie */
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; width: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Overlay */
.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 299;
  opacity: 0;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(2px);
}
.nav-overlay.visible {
  display: block;
}
.nav-overlay.active {
  opacity: 1;
}

/* Mobiel sidebar als slide-in panel */
@media (max-width: 768px) {
  .mobile-header { display: flex; }

  /* Ruimte voor vaste topbalk */
  #app {
    padding-top: 56px;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    /* Flex column: nav scrollt, footer blijft altijd zichtbaar */
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
  }

  /* Nav scrollbaar — footer nooit afgeknepen */
  .sidebar-nav {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Footer altijd onderaan, ook op 320px */
  .sidebar-footer {
    flex-shrink: 0;
  }

  .main-content {
    width: 100%;
    min-height: calc(100vh - 56px);
    overflow-y: auto;
  }

  /* Pagina content fade-in animatie */
  .page.active {
    animation: page-fadein 0.25s ease forwards;
  }

  @keyframes page-fadein {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}

/* Sidebar divider */
.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 8px;
}

/* ===== SEGMENTED CONTROL (toggle knoppen) ===== */
.btn-group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface2);
}
.btn-group .btn {
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text2);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  position: relative;
}
.btn-group .btn:hover {
  background: var(--surface3);
  color: var(--text);
}
.btn-group .btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.btn-group .btn + .btn {
  border-left: 1px solid var(--border);
}

/* ===== SLIDE TOGGLE SCHAKELAAR ===== */
.toggle-switch {
  position: relative;
  flex-shrink: 0;
  width: 52px;
  height: 28px;
  margin-top: 2px;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 28px;
  cursor: pointer;
  transition: background .25s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 4px;
  top: 4px;
  background: #fff;
  border-radius: 50%;
  transition: transform .25s;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--accent3, #4ecb8d);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(24px);
}

/* ===== NUMBER INPUT — spinners verbergen ===== */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

/* ===== TARIC PICKER RESULTATEN ===== */
.taric-result {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.taric-result:last-child { border-bottom: none; }
.taric-result:hover { background: var(--surface2); }
/* ===== CUSTOM TOOLTIPS (vervangt native title-tooltips, CRM-breed) =====
   Vertraging instelbaar via --tooltip-delay (Instellingen → Weergave). */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%) translateY(3px);
  background: var(--surface3);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
  white-space: nowrap;
  max-width: 320px;
  pointer-events: none;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transition: opacity .12s ease, transform .12s ease, visibility 0s linear .12s;
  z-index: 10000;
}
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  transition-delay: var(--tooltip-delay, 200ms);
}
/* Lange teksten mogen wél wrappen in modals en tabellen */
.modal-body [data-tooltip]::after, td [data-tooltip]::after { white-space: normal; width: max-content; }

/* Tabellen waarin cellen meerdere regels hebben: eerste regel uitlijnen */
table.v-top td { vertical-align: top; }

