/* CRM Dispatcher Widget styling */
:root {
  --brand: #1e3a8a;
  --brand-dark: #172554;
  --brand-light: #eff4ff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --red: #dc2626;
  --green: #16a34a;
  --orange: #f59e0b;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--gray-100);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--gray-900);
}

.hdr {
  background: var(--brand);
  color: #fff;
  padding: 14px 20px;
  border-bottom: 4px solid var(--brand-dark);
}
.hdr-title { font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: #cbd5ff; }
.hdr-deal { font-weight: 700; font-size: 18px; margin-top: 2px; }

.wrap { max-width: 880px; margin: 16px auto; padding: 0 16px 40px 16px; }

.card {
  background: #fff;
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  border: 1px solid var(--gray-200);
}
.card-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}
.card-h h3 { margin: 0; font-size: 15px; }
.hint { color: var(--gray-500); font-size: 12px; }

.loan-type-row { display: flex; flex-wrap: wrap; gap: 8px; }
.loan-type-btn {
  padding: 8px 16px;
  border: 1px solid var(--gray-300);
  background: #fff;
  color: var(--gray-700);
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  font-weight: 500;
  transition: all 120ms;
}
.loan-type-btn:hover { background: var(--brand-light); }
.loan-type-btn.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.checklist-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.counter {
  font-size: 12px;
  background: var(--brand);
  color: #fff;
  padding: 2px 9px;
  border-radius: 999px;
  font-weight: 600;
}

.cat {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}
.cat-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--gray-50);
  cursor: pointer;
  user-select: none;
}
.cat-h:hover { background: var(--brand-light); }
.cat-h-l { display: flex; align-items: center; gap: 10px; }
.cat-h h4 { margin: 0; font-size: 14px; }
.cat-count { font-size: 11px; color: var(--gray-500); }
.cat-badge {
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 600;
  display: none;
}
.cat-badge.has-selected { display: inline-block; }
.cat-arrow { transition: transform 200ms; color: var(--gray-500); }
.cat.open .cat-arrow { transform: rotate(90deg); }
.cat-body { display: none; padding: 4px 14px 12px 14px; }
.cat.open .cat-body { display: block; }

.item-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 0;
}
.item-row input[type=checkbox] { margin-top: 3px; }
.item-row label { flex: 1; cursor: pointer; line-height: 1.4; }

.custom-row {
  margin-top: 14px;
  display: flex;
  gap: 8px;
}
.custom-row input { flex: 1; }
.custom-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0 0;
}
.custom-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: var(--brand-light);
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 13px;
}

input[type=text], input[type=email], textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--gray-900);
}
textarea { resize: vertical; min-height: 80px; line-height: 1.55; }
.lbl { display: block; font-size: 12px; font-weight: 600; color: var(--gray-700); margin: 12px 0 4px 0; text-transform: uppercase; letter-spacing: 0.4px; }

.btn { font: inherit; padding: 9px 16px; border-radius: 8px; border: 0; cursor: pointer; font-weight: 600; transition: background 120ms; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { background: var(--gray-300); cursor: not-allowed; }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-link {
  background: transparent;
  color: var(--brand);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
}
.btn-link:hover { background: var(--brand-light); }
.btn-lg { font-size: 15px; padding: 12px 22px; }

.send-card { background: var(--brand-light); border-color: #c7d2fe; }
.send-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.send-help { color: var(--gray-500); font-size: 12px; }

.status-card { background: #f0fdf4; border-color: #bbf7d0; }
.status-summary { display: flex; gap: 18px; margin-bottom: 12px; flex-wrap: wrap; }
.status-summary .pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; }
.pill-needed { background: #fee2e2; color: #991b1b; }
.pill-review { background: #fef3c7; color: #92400e; }
.pill-approved { background: #dcfce7; color: #166534; }

.portal-link-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0 12px 0;}
.portal-link-row input { flex: 1; min-width: 220px; font-size: 12px; background: #fff; }

.mini-list { list-style: none; padding: 0; margin: 0; }
.mini-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  border-top: 1px solid #d1fae5;
  font-size: 13px;
}
.mini-list li:first-child { border-top: 0; }
.mini-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.mini-dot.s-needed   { background: var(--red); }
.mini-dot.s-uploaded { background: var(--orange); }
.mini-dot.s-revision_requested { background: var(--orange); }
.mini-dot.s-approved { background: var(--green); }
.mini-label { flex: 1; }
.mini-cat { color: var(--gray-500); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
.mini-actions a { color: var(--brand); text-decoration: none; font-size: 12px; }

.modal {
  position: fixed; inset: 0; background: rgba(15,23,42,0.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 32px 16px;
  z-index: 100;
  overflow-y: auto;
}
.modal[hidden] { display: none; }
.modal-card { background: #fff; max-width: 720px; width: 100%; border-radius: 14px; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
.modal-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.modal-actions { margin-top: 20px; text-align: right; }
.master-cat { border: 1px solid var(--gray-200); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.master-cat .cat-name-row { display:flex; gap:8px; align-items:center; margin-bottom: 6px; }
.master-cat .cat-name-row input { flex: 1; font-weight: 600; }
.master-item { display:flex; gap: 6px; margin: 4px 0; }
.master-item input { flex: 1; font-size: 13px; }
.master-item .key-input { flex: 0 0 30%; font-family: ui-monospace, monospace; font-size: 12px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--gray-900); color: #fff; padding: 12px 22px; border-radius: 10px;
  font-size: 14px; z-index: 200; box-shadow: 0 10px 30px rgba(0,0,0,.2);
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
