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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f0f4f8;
  color: #1a1a2e;
}

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 16px 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header { text-align: center; margin-bottom: 10px; flex: 0 0 auto; }
.header h1 { font-size: 23px; font-weight: 900; letter-spacing: -0.5px; }
.header h1 span { color: #7ab828; }

.status-chip {
  text-align: center;
  font-size: 12.5px;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 6px;
  flex: 0 0 auto;
}

.link-btn {
  display: block;
  width: 100%;
  text-align: center;
  background: none;
  border: none;
  color: #7ab828;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 14px;
  flex: 0 0 auto;
  padding: 2px;
}
.link-btn:hover { text-decoration: underline; }

.client-card { padding: 14px 20px; }
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #94a3b8;
  margin-bottom: 6px;
}
/* searchable client combo */
.combo { position: relative; }
.combo-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 700;
  font-family: inherit;
  color: #1a1a2e;
  background: #fafbfc;
  cursor: pointer;
  text-align: left;
}
.combo-btn:hover { background: #f4f6f8; }
.combo.open .combo-btn { border-color: #8ac43f; box-shadow: 0 0 0 3px rgba(138,196,63,0.12); background: white; }
.combo-btn .combo-caret { color: #94a3b8; font-size: 13px; flex: 0 0 auto; }
#clientComboLabel.placeholder { color: #94a3b8; font-weight: 600; }

.combo-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.18);
  z-index: 30;
  display: flex;
  flex-direction: column;
  max-height: 320px;
  overflow: hidden;
}
.combo-dropdown.hidden { display: none; }

.combo-search {
  margin: 10px 10px 6px;
  padding: 9px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fafbfc;
  flex: 0 0 auto;
}
.combo-search:focus { outline: none; border-color: #8ac43f; box-shadow: 0 0 0 3px rgba(138,196,63,0.12); background: white; }

.combo-list { overflow-y: auto; flex: 1 1 auto; padding: 4px 6px 8px; }
.combo-item {
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: #1a1a2e;
  cursor: pointer;
}
.combo-item:hover, .combo-item.hl { background: #f0f7e6; }
.combo-item.selected { background: #dcf5e6; color: #1a9c5b; font-weight: 800; }
.combo-empty { padding: 14px 10px; color: #94a3b8; font-size: 13px; text-align: center; }

/* pill tabs */
.tabs {
  display: flex;
  gap: 6px;
  background: #e2e8f0;
  padding: 5px;
  border-radius: 16px;
  margin-bottom: 14px;
  flex: 0 0 auto;
}
.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 11px 8px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  color: #64748b;
  transition: all 0.2s;
  user-select: none;
}
.tab input { display: none; }
.tab.active { background: white; color: #1a1a2e; box-shadow: 0 2px 10px rgba(0,0,0,0.10); }

/* cards */
.card {
  background: white;
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.07);
  margin-bottom: 14px;
  flex: 0 0 auto;
}

.plan-search {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  font-size: 14px;
  font-family: inherit;
  color: #1a1a2e;
  background: #fafbfc;
  margin-bottom: 12px;
}
.plan-search:focus { outline: none; border-color: #8ac43f; box-shadow: 0 0 0 3px rgba(138,196,63,0.12); background: white; }

.filter-row { display: flex; gap: 8px; margin-bottom: 12px; }
.field-select {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fafbfc;
  color: #1a1a2e;
}
.chip-btn {
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  white-space: nowrap;
}
.chip-btn:hover { background: #eef2f7; }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.plan-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
  min-height: 36px;
  border: 1.5px solid #e2e8f0;
  background: white;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 800;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
}
.plan-filter-chip:has(input:checked) {
  background: #f0f7e6;
  border-color: #c8e89a;
  color: #3a6a10;
}

/* list card */
.list-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.list-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1.5px solid #f1f5f9;
  font-size: 13px;
  font-weight: 700;
  color: #475569;
}
.select-all { display: flex; align-items: center; gap: 7px; cursor: pointer; }
.select-all .muted { color: #94a3b8; font-weight: 600; }
.sel-count { color: #94a3b8; font-weight: 600; }
.sel-count b { color: #1a1a2e; font-weight: 800; }

.list { max-height: 65vh; min-height: 320px; overflow-y: auto; }

.row {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px 18px;
  border-bottom: 1px solid #f5f6f8;
  cursor: pointer;
}
.row:hover { background: #fafbfc; }
.row input[type="checkbox"] { margin-top: 3px; width: 17px; height: 17px; accent-color: #7ab828; }
.row .main { flex: 1; min-width: 0; }
.row .addr { font-weight: 700; font-size: 13.5px; line-height: 1.35; }
.row .meta { color: #94a3b8; font-size: 12px; margin-top: 3px; font-weight: 600; }

.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 2px 8px;
  border-radius: 6px;
  margin-left: 6px;
  vertical-align: middle;
}
.badge.existing { background: #fef3c7; color: #92400e; }
.badge.inactive { background: #fee2e2; color: #ef4444; }
.badge.called { background: #dcf5e6; color: #1a9c5b; }

.row-fill-btn {
  flex: 0 0 auto;
  align-self: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
  background: #fafbfc;
  font-size: 15px;
  cursor: pointer;
}
.row-fill-btn:hover { background: #f0f7e6; border-color: #c8e89a; }

.row-actions { display: flex; gap: 6px; flex: 0 0 auto; align-self: center; }
.row-smiley-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
  background: #fafbfc;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.row-smiley-btn.good:hover { background: #f0f7e6; border-color: #7ab828; }
.row-smiley-btn.bad:hover { background: #fef2f2; border-color: #ef4444; }
.row-smiley-btn:disabled { opacity: 0.6; cursor: default; }

/* fill results overlay */
.fill-card { max-width: 540px; }
.smiley-row { display: flex; gap: 12px; margin-bottom: 14px; }
.smiley-row.hidden { display: none; }
.smiley-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 10px;
  border: 2px solid #e2e8f0;
  border-radius: 18px;
  background: white;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s;
}
.smiley-emoji { font-size: 34px; line-height: 1; }
.smiley-btn.good { color: #3a6a10; }
.smiley-btn.good:hover { border-color: #7ab828; background: #f0f7e6; }
.smiley-btn.bad { color: #9a2323; }
.smiley-btn.bad:hover { border-color: #ef4444; background: #fef2f2; }

#fillDetails.hidden { display: none; }

.fill-fields-area.hidden { display: none; }
.fill-fields-area { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; max-height: 40vh; overflow-y: auto; }

.fill-field-block {
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 12px 14px;
  background: #fafbfc;
}
.fill-field-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  font-weight: 800;
  color: #475569;
  margin-bottom: 8px;
}
.fill-field-remove {
  border: none;
  background: #fee2e2;
  color: #ef4444;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  font-size: 14px;
  cursor: pointer;
  flex: 0 0 auto;
}
.fill-textarea {
  width: 100%;
  min-height: 60px;
  padding: 9px 11px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 13px;
  font-family: inherit;
  background: white;
  resize: vertical;
}
.fill-options { display: flex; gap: 8px; flex-wrap: wrap; }
.fill-opt {
  padding: 8px 14px;
  border: 1.5px solid #e2e8f0;
  background: white;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
}
.fill-opt:hover { background: #f0f7e6; }
.fill-opt.selected { background: #7ab828; border-color: #7ab828; color: white; }

.fill-actions { display: flex; gap: 10px; }
.fill-actions .submit-btn { flex: 1; }
.fill-actions .again-btn { flex: 0 0 auto; }

.city-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 18px;
  border-bottom: 1px solid #f5f6f8;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}
.city-row:hover { background: #fafbfc; }
.city-row input[type="checkbox"] { width: 17px; height: 17px; accent-color: #7ab828; }
.city-row .count { color: #94a3b8; margin-left: auto; font-size: 12px; font-weight: 700; }

/* assign / submit */
.assign-card { margin-bottom: 0; }
.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #94a3b8;
  margin-bottom: 6px;
}
.field select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  color: #1a1a2e;
  background: #fafbfc;
}

.submit-btn {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, #8ac43f, #6aaa28);
  border: none;
  border-radius: 14px;
  color: white;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.2s;
}
.submit-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(106,170,40,0.35); }
.submit-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; background: #cbd5e1; }
.submit-btn.confirming { background: linear-gradient(135deg, #f59e0b, #d97706); }

/* overlay / results */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,26,46,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
.overlay.hidden { display: none; }
.overlay-card {
  background: white;
  border-radius: 22px;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.overlay-card h2 { font-size: 17px; font-weight: 900; margin-bottom: 10px; }
.results-summary { font-size: 13px; font-weight: 700; color: #64748b; margin-bottom: 12px; }
.results-list { flex: 1; overflow-y: auto; border: 1.5px solid #f1f5f9; border-radius: 14px; margin-bottom: 16px; }
.result-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 12px; font-size: 12.5px; font-weight: 600; border-bottom: 1px solid #f5f6f8; }
.result-row:last-child { border-bottom: none; }
.tag { font-size: 10.5px; font-weight: 800; padding: 3px 9px; border-radius: 999px; white-space: nowrap; text-transform: uppercase; letter-spacing: 0.3px; }
.tag.created { background: #dcf5e6; color: #1a9c5b; }
.tag.skipped { background: #fef3c7; color: #92400e; }
.tag.error { background: #fee2e2; color: #ef4444; }

.again-btn {
  width: 100%;
  padding: 12px;
  background: #f1f5f9;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
}
.again-btn:hover { background: #e6ebf0; }

/* toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  padding: 12px 22px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 14px;
  color: white;
  background: #1a1a2e;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
