/* ===== Custom Select (cs-select) ===== */
.cs-select {
  position: relative;
  display: inline-block;
  width: 100%;
}
.cs-trigger {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.cs-trigger:hover { border-color: var(--ink-mute); }
.cs-trigger.open,
.cs-trigger:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}
.cs-trigger-content {
  display: flex; align-items: center; gap: 8px;
  flex: 1; min-width: 0;
}
.cs-trigger-label {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1;
}
.cs-trigger-placeholder { color: var(--ink-mute); font-style: italic; }
.cs-chevron {
  flex-shrink: 0;
  color: var(--ink-mute);
  transition: transform 0.18s ease;
}
.cs-trigger.open .cs-chevron { transform: rotate(180deg); color: var(--accent); }

/* Chip-style trigger (for filter bars) */
.cs-select.chip { width: auto; }
.cs-select.chip .cs-trigger {
  padding: 7px 10px 7px 12px;
  border-radius: 999px;
  background: var(--white);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(37,25,19,0.04);
  width: auto;
}
.cs-select.chip .cs-trigger-content { flex: 0 1 auto; }
.cs-select.chip .cs-trigger-label { flex: 0 1 auto; max-width: 180px; }
.cs-select.chip .cs-trigger:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.cs-select.chip.has-value .cs-trigger {
  background: var(--accent-soft);
  border-color: rgba(180, 83, 9, 0.28);
  color: var(--accent);
}
.cs-select.chip .cs-trigger-prefix {
  color: var(--ink-mute);
  font-weight: 500;
}
.cs-select.chip.has-value .cs-trigger-prefix { color: var(--accent); opacity: 0.8; }

/* Visual leading indicators */
.cs-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.04);
}
.cs-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg-cream);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10.5px;
  font-weight: 600;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.cs-avatar.muted {
  background: var(--bg-warm);
  color: var(--ink-mute);
}

/* Popup */
.cs-popup {
  position: fixed;
  min-width: 220px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(37,25,19,.14), 0 2px 6px rgba(37,25,19,.06);
  z-index: 1500;
  padding: 6px;
  display: none;
  scrollbar-width: thin;
}
.cs-popup.open {
  display: block;
  animation: csFade 0.12s ease-out;
}
@keyframes csFade {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.cs-popup::-webkit-scrollbar { width: 8px; }
.cs-popup::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

.cs-option {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.08s;
  min-height: 32px;
  box-sizing: border-box;
}
.cs-option:hover,
.cs-option.focused { background: var(--bg-cream); }
.cs-option.selected {
  background: var(--accent-soft);
  color: var(--accent);
}
.cs-option.selected .cs-option-label { font-weight: 600; }
.cs-option-label {
  flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cs-option-sub {
  font-size: 11.5px;
  color: var(--ink-mute);
  margin-left: 6px;
}
.cs-option-check {
  margin-left: auto;
  color: var(--accent);
  opacity: 0;
  flex-shrink: 0;
}
.cs-option.selected .cs-option-check { opacity: 1; }

.cs-popup-empty {
  padding: 14px 12px;
  color: var(--ink-mute);
  font-size: 13px;
  text-align: center;
}

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(37, 25, 19, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.15s ease-out;
}
.modal-backdrop.open { display: flex; }
/* Confirm dialog must sit above any manager overlay (stage manager, template manager = z-index 1000). */
#confirm-modal { z-index: 2000; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.modal {
  background: var(--bg-cream);
  border-radius: 14px;
  width: 540px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.2s ease-out;
}
.modal-header {
  padding: 22px 26px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--success);
  background: #d1fae5;
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 10px;
}
.modal-title {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.modal-sub {
  color: var(--ink-mute);
  font-size: 13px;
  margin-top: 4px;
}

.modal-body {
  padding: 20px 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-label {
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  transition: border 0.12s, box-shadow 0.12s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-textarea { min-height: 80px; resize: vertical; font-family: inherit; }
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a7a6e' stroke-width='2.5'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* Baseline voor ALLE native selects in de app: zelfde uitstraling als de
   custom .cs-trigger dropdown (rand, padding, chevron, hover/focus-ring), zodat
   elke dropdown in de CRM er hetzelfde en verzorgd uitziet. Specifiekere
   class-regels winnen gewoon van deze basis. */
select {
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background-color: var(--white);
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a7a6e' stroke-width='2.5'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding: 8px 30px 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}
select:hover { border-color: var(--ink-mute); }
select:focus, select:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}
select:disabled { opacity: 0.55; cursor: not-allowed; background-color: var(--bg-warm); }

/* Date/tijd-inputs: consistent met de rest van de formulieren */
input[type="date"], input[type="time"], input[type="datetime-local"] {
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input[type="date"]:hover, input[type="time"]:hover, input[type="datetime-local"]:hover { border-color: var(--ink-mute); }
input[type="date"]:focus, input[type="time"]:focus, input[type="datetime-local"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="date"]:disabled, input[type="time"]:disabled, input[type="datetime-local"]:disabled {
  opacity: 0.55; cursor: not-allowed; background: var(--bg-warm);
}
/* Branded picker icon (Chromium): a calendar for date/datetime, a clock for time,
   in the CRM's warm-grey — replaces the plain default browser glyph. */
/* Date fields use our own CRM-styled calendar popup: hide the native indicator
   and show the calendar icon on the field itself. */
input[type="date"] {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a7a6e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3crect x='3' y='4' width='18' height='18' rx='2'/%3e%3cline x1='16' y1='2' x2='16' y2='6'/%3e%3cline x1='8' y1='2' x2='8' y2='6'/%3e%3cline x1='3' y1='10' x2='21' y2='10'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 15px 15px;
  padding-right: 32px;
  cursor: pointer;
}
input[type="date"]::-webkit-calendar-picker-indicator { display: none; }
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a7a6e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3crect x='3' y='4' width='18' height='18' rx='2'/%3e%3cline x1='16' y1='2' x2='16' y2='6'/%3e%3cline x1='8' y1='2' x2='8' y2='6'/%3e%3cline x1='3' y1='10' x2='21' y2='10'/%3e%3c/svg%3e");
  background-size: 15px 15px; background-repeat: no-repeat; background-position: center;
  width: 16px; height: 16px; cursor: pointer; opacity: 0.75; transition: opacity 0.12s;
}
/* Time fields use our own CRM-styled time popup: hide the native indicator and
   show the clock icon on the field itself. */
input[type="time"] {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a7a6e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3ccircle cx='12' cy='12' r='9'/%3e%3cpolyline points='12 7 12 12 15 14'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 15px 15px;
  padding-right: 32px;
  cursor: pointer;
}
input[type="time"]::-webkit-calendar-picker-indicator { display: none; }
input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover,
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }

/* ===== Custom calendar popup (CRM style) ===== */
.cscal-pop {
  position: fixed; z-index: 2200; display: none;
  width: 260px; background: var(--white);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.16); padding: 10px;
  font-size: 13px; color: var(--ink);
}
.cscal-pop.open { display: block; }
.cscal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cscal-title { font-weight: 600; font-size: 13.5px; text-transform: capitalize; }
.cscal-nav { width: 28px; height: 28px; border-radius: 7px; border: none; background: none; color: var(--ink-soft); cursor: pointer; font-size: 17px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.cscal-nav:hover { background: var(--bg-warm); color: var(--ink); }
.cscal-dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 2px; }
.cscal-dow span { text-align: center; font-size: 10.5px; font-weight: 600; color: var(--ink-mute); text-transform: uppercase; padding: 3px 0; }
.cscal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cscal-day { height: 32px; border: none; background: none; border-radius: 7px; cursor: pointer; font-size: 12.5px; color: var(--ink); display: flex; align-items: center; justify-content: center; font-family: inherit; transition: background .1s; }
.cscal-day.empty { visibility: hidden; cursor: default; }
.cscal-day:hover:not(.dis):not(.sel) { background: var(--bg-warm); }
.cscal-day.today { font-weight: 700; color: var(--accent); }
.cscal-day.sel { background: var(--accent); color: #fff; font-weight: 600; }
.cscal-day.sel.today { color: #fff; }
.cscal-day.dis { color: var(--ink-mute); opacity: .4; cursor: not-allowed; }
.cscal-foot { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border-soft); }
.cscal-foot-btn { border: none; background: none; color: var(--accent); font-size: 12px; font-weight: 600; cursor: pointer; padding: 4px 8px; border-radius: 6px; font-family: inherit; }
.cscal-foot-btn:hover { background: var(--accent-soft); }

/* ===== Custom color picker popup (CRM style) ===== */
.cscol-pop {
  position: fixed; z-index: 2200; display: none;
  width: 212px; background: var(--white);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.16); padding: 10px;
}
.cscol-pop.open { display: block; }
.cscol-sv { position: relative; width: 100%; height: 122px; border-radius: 8px; cursor: crosshair; border: 1px solid rgba(0,0,0,.1); touch-action: none; }
.cscol-sv-handle { position: absolute; width: 13px; height: 13px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.35); transform: translate(-50%, -50%); pointer-events: none; }
.cscol-hue { position: relative; width: 100%; height: 12px; border-radius: 999px; cursor: pointer; margin-top: 10px; touch-action: none; background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%); }
.cscol-hue-handle { position: absolute; top: 50%; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.35); transform: translate(-50%, -50%); pointer-events: none; }
.cscol-hex { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.cscol-prev { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border); flex-shrink: 0; }
.cscol-hex > span:nth-child(2) { font-size: 13px; font-weight: 600; }
.cscol-input { flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 7px; padding: 6px 8px; font-size: 13px; font-family: ui-monospace, monospace; text-transform: lowercase; outline: none; color: var(--ink); }
.cscol-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cscol-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border-soft); }
.cscol-sw { width: 100%; aspect-ratio: 1; border-radius: 6px; border: 1px solid rgba(0,0,0,.12); cursor: pointer; padding: 0; transition: transform .1s; }
.cscol-sw:hover { transform: scale(1.15); border-color: var(--ink-mute); }
.cscol-sw.sel { box-shadow: 0 0 0 2px var(--white), 0 0 0 4px var(--accent); }

/* ===== Custom time picker popup (CRM style) ===== */
.cstime-pop { position: fixed; z-index: 2200; display: none; background: var(--white); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.16); padding: 8px; }
.cstime-pop.open { display: block; }
.cstime-cols { display: flex; gap: 6px; }
.cstime-col { width: 62px; }
.cstime-col-h { text-align: center; font-size: 10.5px; font-weight: 600; color: var(--ink-mute); text-transform: uppercase; padding: 2px 0 5px; }
.cstime-list { max-height: 188px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.cstime-item { border: none; background: none; border-radius: 7px; padding: 6px 0; font-size: 13px; color: var(--ink); cursor: pointer; font-family: inherit; text-align: center; font-variant-numeric: tabular-nums; }
.cstime-item:hover { background: var(--bg-warm); }
.cstime-item.sel { background: var(--accent); color: #fff; font-weight: 600; }

.type-picker {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.type-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  cursor: pointer;
  font-size: 11px;
  color: var(--ink-soft);
  font-weight: 500;
  text-transform: capitalize;
  transition: all 0.12s;
}
.type-option:hover { border-color: var(--ink-mute); }
.type-option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.type-option svg { width: 16px; height: 16px; }

.modal-footer {
  padding: 16px 26px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.modal-footer-meta { font-size: 12px; color: var(--ink-mute); }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--ink);
  color: var(--bg-cream);
  padding: 11px 18px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  transition: all 0.25s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast svg { color: #6ee7b7; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; border: 2px solid var(--bg-cream); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-mute); }

@keyframes skel-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skel {
  display: inline-block;
  background: linear-gradient(90deg, var(--border) 25%, var(--border-soft) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.4s ease-in-out infinite;
  border-radius: 4px;
  color: transparent !important;
  user-select: none;
}

