/* ====================== Base / Reset ====================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  background: #f3f4f6;
  color: #111827;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

/* ====================== Layout ====================== */
.app-shell {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px calc(96px + env(safe-area-inset-bottom)) 16px;
}

/* ====================== Header ====================== */
.app-header {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  background: #1e3a8a;
  color: #ffffff;
  padding: 18px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-left { flex: 1 1 auto; }
.header-right { flex: 0 0 auto; }
.app-header h1 { margin: 0; font-size: 1.3rem; font-weight: 700; letter-spacing: -0.01em; }
.app-header .subtitle { margin-top: 3px; font-size: 0.85rem; opacity: 0.85; }
.header-settings {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 10px;
  color: #ffffff;
  cursor: pointer;
  transition: background 0.15s ease;
}
.header-settings:hover { background: rgba(255,255,255,0.25); }
.header-settings svg { width: 20px; height: 20px; }

/* ====================== Progress ====================== */
.progress-wrap {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 16px;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  position: relative;
}
.progress-track {
  width: 100%;
  height: 6px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: #2563eb;
  border-radius: 999px;
  transition: width 0.25s ease;
}
.progress-text {
  margin-top: 8px;
  font-size: 0.82rem;
  color: #374151;
}
.progress-text .pt-section { font-weight: 600; color: #111827; }

.plan-step-pill {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  background: #1e3a8a;
  color: #ffffff;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

/* ====================== Cards / Sections ====================== */
#app { padding-top: 14px; }
.card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f3f4f6;
}
.card-title { margin: 0; font-size: 1.1rem; font-weight: 700; color: #1e3a8a; letter-spacing: -0.01em; }

.survey-inline-card {
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.survey-list-hint {
  margin: 0 0 16px;
  color: #4b5563;
  font-size: 0.92rem;
}

.survey-list-state {
  min-height: 24px;
}

.survey-list-table {
  display: flex;
  flex-direction: column;
  border: 1px solid #dbe7ff;
  border-radius: 14px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(30, 58, 138, 0.06);
}

.survey-list-header,
.survey-list-row {
  display: grid;
  grid-template-columns: 0.9fr 1.3fr 1.9fr 1fr 1.15fr;
  gap: 0;
}

.survey-list-header {
  background: #eff6ff;
  border-bottom: 1px solid #dbe7ff;
}

.survey-list-row {
  border-bottom: 1px solid #edf2ff;
}

.survey-list-row:last-child {
  border-bottom: 0;
}

.survey-list-head-cell {
  padding: 12px 12px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #475569;
}

.survey-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.survey-status-badge.is-progress {
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fde68a;
}

.survey-status-badge.is-complete {
  color: #166534;
  background: #dcfce7;
  border: 1px solid #bbf7d0;
}

.survey-list-col {
  padding: 12px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.survey-list-col-value {
  font-size: 0.95rem;
  color: #111827;
  word-break: break-word;
}

.survey-list-mobile-label {
  display: none;
}

.sector-progress-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sector-progress-list.compact {
  gap: 5px;
}

.sector-progress-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sector-progress-dot {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 800;
  flex: 0 0 20px;
}

.sector-progress-dot.is-completed {
  color: #166534;
  background: #dcfce7;
  border: 1px solid #86efac;
}

.sector-progress-dot.is-in_progress {
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fcd34d;
}

.sector-progress-dot.is-not_started {
  color: #64748b;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
}

.sector-progress-text {
  font-size: 0.95rem;
  color: #111827;
}

.survey-list-actions {
  justify-content: center;
}

.survey-list-muted {
  display: inline-flex;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 600;
  color: #6b7280;
}

.survey-list-locked {
  padding: 10px 12px;
  border-radius: 10px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
}

.survey-list-col-status {
  align-items: center;
  justify-content: center;
}

.survey-list-col-action {
  align-items: center;
  justify-content: center;
}

.survey-link-inline {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 8px 14px;
  color: #1d4ed8;
  font-size: 0.93rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.08);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.survey-link-inline:hover {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1e40af;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.12);
}

.survey-link-inline:focus-visible {
  outline: 3px solid rgba(59, 130, 246, 0.22);
  outline-offset: 2px;
}

.survey-list-col-action .survey-list-locked {
  min-width: 120px;
  justify-content: center;
  text-align: center;
  font-weight: 700;
}

.survey-list-empty {
  padding: 16px 18px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
  color: #475569;
  font-weight: 500;
}

@media (max-width: 640px) {
  .survey-list-header {
    display: none;
  }

  .survey-list-row {
    grid-template-columns: 1fr;
    padding: 8px 0;
  }

  .survey-list-col {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
  }

  .survey-list-col:last-child {
    border-bottom: 0;
  }

  .survey-list-mobile-label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #64748b;
  }

  .survey-list-col-action,
  .survey-list-col-status,
  .survey-list-actions {
    align-items: stretch;
    justify-content: flex-start;
  }

  .survey-link-inline,
  .survey-list-locked {
    width: 100%;
    text-align: left;
  }
}

/* ====================== Field ====================== */
.field { margin-bottom: 20px; }
.field:last-child { margin-bottom: 0; }
.field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1rem;
  font-weight: 500;
  color: #111827;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.field-label .label-text { flex: 0 1 auto; }
.field-label .req { color: #b91c1c; margin-left: 2px; font-weight: 600; }
.field-label .unit-pill {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 500;
  color: #4b5563;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  padding: 2px 10px;
  margin-left: 4px;
}
.field-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.field-row .field-control { flex: 1 1 auto; min-width: 0; }
.field-row .voice-btn { flex: 0 0 auto; }

.field input[type="text"],
.field input[type="email"],
.field input[type="date"],
.field textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  color: #111827;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  min-height: 48px;
  -webkit-appearance: none;
  appearance: none;
}
.field textarea { min-height: 100px; resize: vertical; }
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.field input:disabled,
.field textarea:disabled { background: #f3f4f6; color: #6b7280; }

.field-hint { font-size: 0.8rem; color: #6b7280; margin-top: 6px; }

/* Invalid field highlight (used by Validation module) */
.field.field--invalid input[type="text"],
.field.field--invalid input[type="email"],
.field.field--invalid input[type="number"],
.field.field--invalid input[type="date"],
.field.field--invalid textarea,
.field.field--invalid input[type="range"],
.field.field--invalid .slider-input {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}
.field-error-msg {
  margin-top: 6px;
  font-size: 0.8rem;
  color: #b91c1c;
  font-weight: 500;
}

/* ====================== Speaker button (label, UI only) ====================== */
.speaker-btn {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  border-radius: 999px;
  color: #6b7280;
  font-size: 0.85rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}
.speaker-btn svg { width: 16px; height: 16px; }

.speaker-btn[data-audio="true"] {
  color: #2563eb;
  border-color: #c7d2fe;
  background: #eef2ff;
  cursor: pointer;
}
.speaker-btn[data-audio="true"]:hover {
  background: #dbeafe;
}
.speaker-btn[data-audio="true"].playing {
  color: #2563eb;
  animation: speaker-pulse 1s ease-in-out infinite;
}
@keyframes speaker-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.3); }
  50% { box-shadow: 0 0 0 6px rgba(37, 99, 235, 0); }
}
.speaker-btn[data-audio="true"].loading {
  color: #9ca3af;
  pointer-events: none;
}

/* ====================== Photo upload ====================== */
.photo-upload { margin-bottom: 20px; }
.photo-upload-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 4px;
}
.photo-upload-note {
  font-size: 0.78rem;
  color: #6b7280;
  margin-bottom: 8px;
}
.photo-upload-trigger {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 120px;
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  background: #f9fafb;
  color: #6b7280;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.photo-upload-trigger:hover {
  border-color: #2563eb;
  background: #eef2ff;
}
.photo-upload-trigger svg { width: 32px; height: 32px; }
.photo-upload-trigger span { font-size: 0.9rem; }
.photo-upload-input {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}
.photo-upload-trigger-row {
  display: flex;
  gap: 12px;
}
.photo-upload-capture,
.photo-upload-browse {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 120px;
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  background: #f9fafb;
  color: #6b7280;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.photo-upload-capture:hover,
.photo-upload-browse:hover {
  border-color: #2563eb;
  background: #eef2ff;
}
.photo-upload-capture svg,
.photo-upload-browse svg { width: 32px; height: 32px; }
.photo-upload-capture span,
.photo-upload-browse span { font-size: 0.9rem; }
.photo-upload-fileinfo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;
}
.photo-upload-fileicon {
  flex: 0 0 auto;
  color: #2563eb;
}
.photo-upload-fileicon svg { width: 20px; height: 20px; }
.photo-upload-filename {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.88rem;
  font-weight: 500;
  color: #111827;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.photo-upload-remove-btn {
  flex: 0 0 auto;
  background: none;
  border: none;
  padding: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: #b91c1c;
  cursor: pointer;
  transition: color 0.1s ease;
}
.photo-upload-remove-btn:hover { color: #7f1d1d; }
.photo-upload-error {
  margin-top: 6px;
  font-size: 0.8rem;
  color: #b91c1c;
  font-weight: 500;
}

/* ====================== Voice button (input row, UI only) ====================== */
.voice-btn {
  min-height: 48px;
  min-width: 48px;
  padding: 0 12px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  border-radius: 10px;
  color: #1e3a8a;
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.voice-btn svg { width: 22px; height: 22px; }
.voice-btn:hover { background: #eef2ff; }
.voice-btn.listening {
  background: #fef2f2;
  border-color: #ef4444;
  color: #ef4444;
  animation: mic-pulse 1.2s ease-in-out infinite;
}
.voice-btn.processing {
  background: #fef2f2;
  border-color: #ef4444;
  color: #ef4444;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* ====================== Stepper ====================== */
.stepper {
  display: flex;
  align-items: stretch;
  gap: 0;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
  width: 100%;
  max-width: 240px;
}
.stepper-btn {
  flex: 0 0 48px;
  width: 48px;
  min-height: 48px;
  border: none;
  background: #f9fafb;
  color: #1e3a8a;
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.stepper-btn:hover:not(:disabled) { background: #eef2ff; }
.stepper-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.stepper-value {
  flex: 1 1 auto;
  width: 100%;
  min-height: 48px;
  border: none;
  border-left: 1px solid #e5e7eb;
  border-right: 1px solid #e5e7eb;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  color: #111827;
  background: #ffffff;
  padding: 0 8px;
  -moz-appearance: textfield;
}
.stepper-value::-webkit-outer-spin-button,
.stepper-value::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.stepper-value:focus { outline: none; background: #f9fafb; }
.stepper-value:disabled { background: #f3f4f6; color: #6b7280; }

/* ====================== Stepper row (stepper + unit selector) ====================== */
.stepper-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: 100%;
  max-width: 520px;
}
.stepper-row .stepper { flex: 1 1 auto; max-width: none; }

.unit-select {
  flex: 0 0 auto;
  min-height: 48px;
  padding: 0 28px 0 10px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #374151;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  cursor: pointer;
}
.unit-select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.unit-select:disabled {
  background-color: #f3f4f6;
  color: #6b7280;
  cursor: not-allowed;
}

/* ====================== Slider ====================== */
.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}
.slider-input {
  flex: 1 1 auto;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: linear-gradient(to right,
    #2563eb 0%,
    #2563eb var(--fill, 0%),
    #e5e7eb var(--fill, 0%),
    #e5e7eb 100%);
  border-radius: 999px;
  outline: none;
  margin: 0;
  cursor: pointer;
}
.slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #2563eb;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  cursor: pointer;
  margin-top: -8px;
}
.slider-input::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #2563eb;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  cursor: pointer;
}
.slider-input::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
}
.slider-input::-moz-range-track {
  height: 6px;
  border-radius: 999px;
}
.slider-input:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(37,99,235,0.2);
}
.slider-value {
  flex: 0 0 auto;
  min-width: 52px;
  text-align: right;
  font-size: 0.95rem;
  font-weight: 600;
  color: #2563eb;
}

/* ====================== Custom Dropdown ====================== */
.custom-dropdown { position: relative; width: 100%; }
.dd-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  font-size: 16px;
  color: #111827;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.dd-trigger:hover:not(:disabled) { border-color: #9ca3af; }
.dd-trigger:disabled { background: #f3f4f6; color: #6b7280; cursor: not-allowed; }
.custom-dropdown.open .dd-trigger {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.dd-trigger-label {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dd-chevron {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-left: 8px;
  color: #6b7280;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}
.dd-chevron svg { width: 100%; height: 100%; display: block; }
.custom-dropdown.open .dd-chevron { transform: rotate(180deg); }

.dd-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  max-height: 280px;
  overflow: hidden;
  display: none;
  flex-direction: column;
  z-index: 30;
}
.custom-dropdown.open .dd-panel { display: flex; }

.dd-search-wrap { padding: 8px; border-bottom: 1px solid #f3f4f6; }
.dd-search {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.9rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  min-height: 40px;
  background: #f9fafb;
}
.dd-search:focus { outline: none; border-color: #2563eb; background: #ffffff; }

.dd-options {
  overflow-y: auto;
  max-height: 220px;
  padding: 4px 0;
}
.dd-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.1s ease;
}
.dd-option:hover { background: #f9fafb; }
.dd-option-disabled { opacity: 0.45; pointer-events: none; }
.dd-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
}
.dd-option-indicator {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  border: 2px solid #d1d5db;
  border-radius: 50%;
  background: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dd-multi .dd-option-indicator { border-radius: 4px; }
.dd-option input:checked + .dd-option-indicator {
  border-color: #2563eb;
  background: #2563eb;
}
.dd-option input:checked + .dd-option-indicator::after {
  content: "";
  width: 6px;
  height: 10px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-top: -2px;
}
.dd-single .dd-option input:checked + .dd-option-indicator::after {
  width: 8px;
  height: 8px;
  border: none;
  border-radius: 50%;
  background: #ffffff;
  transform: none;
  margin: 0;
}
.dd-option-label {
  flex: 1 1 auto;
  font-size: 0.95rem;
  color: #111827;
}

/* ====================== Radio / Checkbox groups (standalone) ====================== */
.choice-group { display: flex; flex-direction: column; gap: 10px; }
.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #ffffff;
  min-height: 48px;
}
.choice input { width: 20px; height: 20px; margin: 0; accent-color: #2563eb; }
.choice label { font-size: 0.95rem; cursor: pointer; flex: 1; }

/* ====================== Navigation bar ====================== */
.nav-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  box-shadow: 0 -1px 4px rgba(0,0,0,0.08);
  z-index: 20;
}
.nav-bar-inner {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  gap: 12px;
}
.btn {
  flex: 1 1 0;
  min-height: 48px;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 500;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: #ffffff; color: #1e3a8a; border-color: #d1d5db; }
.btn-secondary:hover:not(:disabled) { background: #f9fafb; }
.btn-primary { background: #2563eb; color: #ffffff; }
.btn-primary:hover:not(:disabled) { background: #1d4ed8; }
.btn-submit { background: #047857; color: #ffffff; flex: 1 1 0; }
.btn-submit:hover:not(:disabled) { background: #065f46; }

/* ====================== Landing screen ====================== */
.landing-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 24px 0;
}
.landing-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 28px 20px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  text-align: center;
}
.landing-title {
  margin: 0 0 6px 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: #1e3a8a;
}
.landing-subtitle {
  margin: 0 0 24px 0;
  font-size: 0.9rem;
  color: #6b7280;
}
.landing-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.landing-btn { width: 100%; }

/* ====================== Sector Selection screen ====================== */
.sector-screen {
  padding-top: 14px;
}
.sector-card { max-width: 100%; }
.sector-hint {
  margin: 0 0 16px 0;
  font-size: 0.9rem;
  color: #6b7280;
}
.sector-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}
.sector-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #ffffff;
  cursor: pointer;
  min-height: 56px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.sector-row:hover { border-color: #9ca3af; }
.sector-row.selected {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 1px #2563eb inset;
}
.sector-row.disabled {
  cursor: not-allowed;
  opacity: 0.55;
  background: #f9fafb;
}
.sector-row.disabled:hover { border-color: #d1d5db; }
.sector-icon {
  flex: 0 0 auto;
  font-size: 1.4rem;
  line-height: 1;
}
.sector-label-wrap {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.sector-label {
  font-size: 1rem;
  font-weight: 500;
  color: #111827;
}
.sector-row.disabled .sector-label { color: #6b7280; }
.sector-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 500;
  color: #6b7280;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  padding: 2px 8px;
}
.sector-actions {
  display: flex;
  gap: 12px;
}
.sector-actions .btn { flex: 1 1 0; }

/* --- Sector module dropdown --- */
.sector-chevron {
  flex: 0 0 auto;
  font-size: 0.85rem;
  color: #6b7280;
  transition: transform 0.2s ease;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.sector-chevron:hover { background: #f3f4f6; }
.sector-chevron.expanded { transform: rotate(180deg); }

.sector-module-count {
  font-size: 0.78rem;
  color: #6b7280;
}

.sector-module-dropdown {
  display: none;
  margin: -4px 0 10px 0;
  padding-left: 44px;
}
.sector-module-dropdown.expanded { display: block; }

.module-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fafafa;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.module-row + .module-row { margin-top: 6px; }
.module-row:hover { border-color: #9ca3af; background: #fff; }
.module-row.selected {
  border-color: #2563eb;
  background: #eff6ff;
}
.module-checkbox {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  accent-color: #2563eb;
}
.module-label {
  font-size: 0.92rem;
  font-weight: 500;
  color: #111827;
}

.sector-validation-msg {
  color: #d32f2f;
  font-size: 0.88rem;
  margin: 8px 0 0;
  padding: 0 16px;
}

/* ====================== Settings screen ====================== */
.settings-screen { padding-top: 14px; }
.settings-card { max-width: 100%; }
.settings-hint {
  margin: 0 0 16px 0;
  font-size: 0.9rem;
  color: #6b7280;
}
.settings-group { margin-bottom: 24px; }
.settings-group:last-child { margin-bottom: 0; }
.settings-group-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}
.seg-control {
  display: flex;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
}
.seg-option {
  flex: 1 1 0;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 500;
  color: #6b7280;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.seg-option + .seg-option { border-left: 1px solid #e5e7eb; }
.seg-option.active {
  background: #2563eb;
  color: #ffffff;
  font-weight: 600;
}
.settings-actions { display: flex; gap: 12px; }
.settings-actions .btn { flex: 1 1 0; }

/* ====================== Block Manager screen ====================== */
.block-screen { padding-top: 14px; }
.block-card { margin-bottom: 20px; }
.block-hint {
  margin: 0 0 12px 0;
  font-size: 0.85rem;
  color: #6b7280;
}
.block-question {
  margin: 0 0 16px 0;
  font-size: 1rem;
  font-weight: 500;
  color: #111827;
}
.block-instance-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.block-instance-empty {
  margin: 0;
  padding: 16px;
  text-align: center;
  font-size: 0.88rem;
  color: #9ca3af;
  border: 1px dashed #e5e7eb;
  border-radius: 10px;
}
.block-instance-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #ffffff;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  min-height: 56px;
}
.block-instance-row:hover {
  border-color: #2563eb;
  background: #f9fafb;
}
.block-instance-info { flex: 1 1 auto; min-width: 0; }
.block-instance-label {
  font-size: 1rem;
  font-weight: 500;
  color: #111827;
}
.block-instance-crop {
  font-size: 0.85rem;
  color: #6b7280;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.block-status-badge {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.block-status-badge.not_started {
  background: #f3f4f6;
  color: #6b7280;
}
.block-status-badge.in_progress {
  background: #fef3c7;
  color: #92400e;
}
.block-status-badge.completed {
  background: #d1fae5;
  color: #065f46;
}
.block-delete-btn {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  border-radius: 8px;
  color: #b91c1c;
  font-size: 1.2rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.block-delete-btn:hover { background: #fef2f2; border-color: #fca5a5; }
.block-add-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.block-add-btn { flex: 1 1 0; min-width: 140px; }
.block-stub {
  margin: 0;
  padding: 16px;
  text-align: center;
  font-size: 0.88rem;
  color: #9ca3af;
  background: #f9fafb;
  border-radius: 10px;
}
.block-back-row { margin-top: 8px; }
.block-back-row .btn { width: 100%; }

/* ====================== Crop Picker overlay ====================== */
.crop-picker-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.crop-picker {
  background: #ffffff;
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 720px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  animation: cropPickerSlideUp 0.2s ease;
}
@keyframes cropPickerSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.crop-picker-title {
  padding: 18px 20px 12px;
  font-size: 1.1rem;
  font-weight: 600;
  color: #111827;
  border-bottom: 1px solid #f3f4f6;
}
.crop-picker-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px 0;
}
.crop-picker-option {
  padding: 14px 20px;
  font-size: 1rem;
  color: #111827;
  cursor: pointer;
  transition: background 0.1s ease;
  min-height: 48px;
  display: flex;
  align-items: center;
}
.crop-picker-option:hover { background: #eff6ff; color: #2563eb; }
.crop-picker-cancel {
  margin: 12px 20px;
  flex: 0 0 auto;
}
.crop-picker-btn-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 20px 16px;
}
@media (min-width: 768px) {
  .crop-picker-overlay { align-items: center; padding: 24px; }
  .crop-picker { border-radius: 12px; }
}

/* ====================== Confirm modal ====================== */
.confirm-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.confirm-modal {
  background: #ffffff;
  border-radius: 12px;
  padding: 24px 20px 16px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  text-align: center;
}
.confirm-msg {
  margin: 0 0 8px 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: #111827;
}
.confirm-sub {
  margin: 0 0 20px 0;
  font-size: 0.85rem;
  color: #6b7280;
}
.confirm-actions {
  display: flex;
  gap: 12px;
}
.confirm-actions .btn { flex: 1 1 0; }

/* Consent modal */
.consent-overlay { z-index: 300; }
.consent-modal {
  max-width: 480px;
  text-align: left;
}
.consent-content {
  margin: 0 0 20px 0;
  font-size: 0.9rem;
  color: #374151;
  max-height: 300px;
  overflow-y: auto;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* Validation modal + issue list (shared by Validation & BlockManager) */
.validation-modal { text-align: left; max-width: 420px; }
.validation-modal .confirm-msg,
.validation-modal .confirm-sub { text-align: center; }
.validation-issue-list {
  list-style: none;
  margin: 0 0 16px 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
}
.validation-issue-item {
  padding: 10px 12px;
  margin-bottom: 6px;
  font-size: 0.88rem;
  color: #111827;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
}
.validation-issue-item.validation-issue-field { background: #fef2f2; border-color: #fecaca; }
.validation-issue-item.validation-issue-profile { background: #fef2f2; border-color: #fecaca; }
.validation-issue-item.validation-issue-block_empty { background: #fffbeb; border-color: #fde68a; }
.validation-issue-item.validation-issue-block_incomplete { background: #fffbeb; border-color: #fde68a; }

/* Block card invalid highlight (used by BlockManager) */
.block-card.block-card--invalid {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}
.block-instance-row.block-instance-row--incomplete {
  background: #fffbeb;
  border: 1px solid #fde68a;
}

/* ====================== Composite List ====================== */
.composite-list-field { margin-bottom: 20px; }
.composite-list-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.composite-list-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 8px;
  padding: 8px 0;
}
.composite-list-row .cl-input {
  grid-column: 1 / -1;
  width: 100%;
}
.composite-list-row .cl-input .field-control,
.composite-list-row .cl-input .dd-trigger {
  width: 100%;
}
.composite-list-row .cl-slider {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.composite-list-row .cl-slider .stepper {
  max-width: none;
}
.composite-list-row .cl-slider .stepper-row {
  max-width: none;
}
.composite-list-row .cl-slider .slider-input {
  flex: 1 1 auto;
}
.composite-list-row .cl-slider .slider-value {
  flex: 0 0 auto;
  min-width: 40px;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 600;
  color: #2563eb;
}
.composite-list-row .cl-slider .cl-slider-label {
  flex: 0 0 100%;
  font-size: 0.75rem;
  color: #6b7280;
  margin-bottom: 2px;
}
.composite-list-row .cl-remove {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  border-radius: 8px;
  color: #b91c1c;
  font-size: 1.2rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.composite-list-row .cl-remove:hover { background: #fef2f2; border-color: #fca5a5; }
.composite-list-add {
  margin-top: 8px;
  width: 100%;
}

/* ====================== States ====================== */
.state-screen {
  padding: 48px 16px;
  text-align: center;
  color: #374151;
  font-size: 0.95rem;
}
.state-screen .state-title { font-size: 1.1rem; font-weight: 600; color: #111827; margin-bottom: 6px; }
.state-error { color: #b91c1c; }

/* ====================== RSK Search ====================== */
.rsk-search { position: relative; width: 100%; }
.rsk-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
}
.rsk-search-icon svg {
  width: 18px;
  height: 18px;
}
.rsk-search-input {
  padding-left: 42px !important;
}
.rsk-search-clear {
  flex: 0 0 auto;
  width: 48px;
  min-height: 48px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  border-radius: 10px;
  color: #6b7280;
  font-size: 1.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.rsk-search-clear:hover { background: #f3f4f6; color: #111827; }
.rsk-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  max-height: 280px;
  overflow-y: auto;
  display: none;
  flex-direction: column;
  z-index: 30;
}
.rsk-result {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  cursor: pointer;
  min-height: 48px;
  transition: background 0.1s ease;
}
.rsk-result:hover { background: #eff6ff; }
.rsk-result-name {
  font-size: 0.95rem;
  font-weight: 500;
  color: #111827;
}
.rsk-result-context {
  font-size: 0.8rem;
  color: #6b7280;
}
.rsk-search-empty {
  padding: 14px;
  text-align: center;
  font-size: 0.88rem;
  color: #9ca3af;
}

.geolocation-error-modal { max-width: 420px; text-align: left; }
.geolocation-error-modal .confirm-msg { text-align: center; }

.loading-overlay { z-index: 300; }
.loading-modal { max-width: 320px; }
.spinner {
  width: 36px; height: 36px;
  margin: 0 auto;
  border: 3px solid #e5e7eb;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ====================== Responsive ====================== */
@media (min-width: 768px) {
  .app-header h1 { font-size: 1.5rem; }
  .card { padding: 24px; }
  .field { margin-bottom: 22px; }
  .stepper { max-width: 280px; }
  .stepper-row { max-width: 520px; }
  .composite-list-row .cl-slider .stepper { max-width: none; }
  .composite-list-row .cl-slider .stepper-row { max-width: none; }
}
