/* ============================================================
   BUTTONS
============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.18s ease;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: var(--on-accent); }
body.theme-dark .btn-primary { color: #0b0b0b; }
.btn-primary:not(:disabled):hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
}
.btn-ghost:not(:disabled):hover {
  background: var(--bg2);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-danger { background: var(--status-failed); color: #fff; }
.btn-danger:not(:disabled):hover { filter: brightness(1.08); transform: translateY(-1px); }

.btn-sm { padding: 7px 14px; font-size: 0.82rem; }
.btn-full { width: 100%; }

/* ============================================================
   CARDS
============================================================ */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
}

.form-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.form-card-header-left { display: flex; align-items: center; gap: 12px; }
.form-card-icon { font-size: 1.2rem; }
.form-card-title { font-weight: 700; font-size: 1rem; color: var(--text); }
.form-card-subtitle { font-size: 0.8rem; color: var(--text3); margin-top: 2px; }
.form-card-body { padding: 24px; }

.meta-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}
.meta-card h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 20px;
}
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.content-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}
.content-card h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.3rem;
  color: var(--text);
  margin-bottom: 24px;
}

/* ============================================================
   TASK ENTRY (report sections)
============================================================ */
.task-entry {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  transition: all 0.2s;
}
.task-entry:hover { border-color: var(--border-strong); }
.task-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.task-num {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
  background: var(--bg2);
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.btn-remove-task {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text3);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.15s;
}
.btn-remove-task:hover {
  border-color: #e53e3e;
  color: #e53e3e;
  background: rgba(229,62,62,0.05);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.add-task-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1.5px dashed var(--border-strong);
  color: var(--text2);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.18s;
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}
.add-task-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--bg2); }

/* ---- Report attachments ---- */
.rf-attach-add { margin-top: 0; }
.rf-attach-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.rf-attach-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.rf-attach-icon { font-size: 1.1rem; }
.rf-attach-name { font-weight: 600; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rf-attach-size { color: var(--text2); font-size: 0.8rem; margin-left: auto; white-space: nowrap; }
.rf-attach-item .btn-remove-task { flex-shrink: 0; }

/* ---- AI "Polish" button (per textarea) ---- */
.rf-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.ai-polish-btn {
  /* Hidden until the server confirms an AI key is configured. */
  display: none;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 3px 11px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.15s;
  white-space: nowrap;
}
.ai-enabled .ai-polish-btn { display: inline-flex; }
.ai-polish-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg2);
}
.ai-polish-btn:disabled { opacity: 0.7; cursor: default; }
.ai-polish-btn.is-undo { border-color: var(--accent); color: var(--accent); }
.spinner-sm { width: 12px; height: 12px; border-width: 2px; }

/* Voice recording button — always visible (no AI key required) */
.voice-rec-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text2);
  padding: 3px 10px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  white-space: nowrap;
}
.voice-rec-btn:hover { border-color: var(--border-strong); background: var(--bg2); }
.voice-rec-btn.voice-listening {
  background: rgba(220, 38, 38, 0.08);
  border-color: #dc2626;
  color: #dc2626;
}
/* Groups Polish + Record buttons side-by-side in a textarea field header */
.rf-field-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* ============================================================
   REPORT TYPE SELECTOR
============================================================ */
.report-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.report-type-card { position: relative; cursor: pointer; }
.report-type-card input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.report-type-label {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
  height: 100%;
}
.report-type-label:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.report-type-card input:checked + .report-type-label {
  border-color: var(--check-active);
  background: var(--bg2);
  box-shadow: var(--shadow-sm);
}
.report-type-icon { font-size: 1.5rem; line-height: 1; }
.report-type-name { font-size: 0.88rem; font-weight: 700; color: var(--text); }
.report-type-desc { font-size: 0.78rem; color: var(--text3); line-height: 1.4; }
.check-indicator {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1.5px solid var(--border-strong);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  flex-shrink: 0;
  transition: all 0.15s;
}
.report-type-card input:checked + .report-type-label .check-indicator {
  background: var(--check-active);
  border-color: var(--check-active);
}
.check-indicator::after {
  content: '';
  width: 10px;
  height: 6px;
  border-left: 2px solid white;
  border-bottom: 2px solid white;
  transform: rotate(-45deg) translateY(-1px);
  opacity: 0;
  transition: opacity 0.15s;
}
body.theme-dark .check-indicator::after { border-color: #0b0b0b; }
.report-type-card input:checked + .report-type-label .check-indicator::after { opacity: 1; }

/* ============================================================
   TOGGLE SWITCH
============================================================ */
.toggle-switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border-strong);
  border-radius: 24px;
  transition: 0.25s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  left: 4px;
  top: 4px;
  transition: 0.25s;
  box-shadow: var(--shadow-sm);
}
input:checked + .toggle-slider { background: var(--check-active); }
input:checked + .toggle-slider::before { transform: translateX(20px); }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.setting-label { font-weight: 600; font-size: 0.9rem; color: var(--text); }
.setting-desc { font-size: 0.8rem; color: var(--text3); margin-top: 2px; }
.select-sm {
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  cursor: pointer;
  appearance: none;
  width: auto;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a6f61' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  padding-right: 28px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.select-sm:focus { outline: none; border-color: var(--accent); box-shadow: var(--input-focus-shadow); }

/* ============================================================
   MODALS
============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 24px;
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.modal-box.modal-wide { max-width: 720px; text-align: left; }
.modal-icon { font-size: 3rem; margin-bottom: 16px; }
.modal-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 8px;
}
.modal-sub {
  font-size: 0.88rem;
  color: var(--text3);
  line-height: 1.6;
  margin-bottom: 28px;
}
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.modal-box.modal-wide .modal-actions { justify-content: flex-end; }
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.4rem;
  color: var(--text);
}
.modal-close-x {
  background: transparent;
  border: none;
  color: var(--text3);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.modal-close-x:hover { color: var(--text); }
.modal-body-scroll { max-height: 70vh; overflow-y: auto; }

/* ============================================================
   AVATAR
============================================================ */
.avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
body.theme-dark .avatar { color: #0b0b0b; }
.avatar-sm { width: 34px; height: 34px; font-size: 0.85rem; }
.avatar-lg { width: 120px; height: 120px; font-size: 2.4rem; }

/* ============================================================
   BADGES
============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.badge-admin { background: rgba(124,58,237,0.12); color: var(--badge-admin); border-color: rgba(124,58,237,0.25); }
.badge-user  { background: rgba(37,99,235,0.12);  color: var(--badge-user);  border-color: rgba(37,99,235,0.25); }
.badge-submitted { background: rgba(22,163,74,0.12);  color: var(--status-submitted); border-color: rgba(22,163,74,0.25); }
.badge-draft     { background: rgba(202,138,4,0.12);  color: var(--status-draft);     border-color: rgba(202,138,4,0.25); }
.badge-failed    { background: rgba(220,38,38,0.12);  color: var(--status-failed);    border-color: rgba(220,38,38,0.25); }
.badge-active    { background: rgba(22,163,74,0.12);  color: var(--status-submitted); border-color: rgba(22,163,74,0.25); }
.badge-inactive  { background: var(--bg2);            color: var(--text3);            border-color: var(--border); }
.badge-neutral   { background: var(--bg2);            color: var(--text2);            border-color: var(--border); }

/* ============================================================
   METRIC CARD
============================================================ */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.metric-card {
  background: var(--card-metric-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.metric-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  background: var(--bg2);
}
.metric-body { display: flex; flex-direction: column; }
.metric-value {
  font-family: 'DM Serif Display', serif;
  font-size: 2rem;
  line-height: 1.1;
  color: var(--text);
}
.metric-label { font-size: 0.82rem; color: var(--text3); margin-top: 4px; }

/* ============================================================
   DATA TABLE
============================================================ */
.data-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  overflow-x: auto;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface2);
  text-align: left;
  padding: 13px 16px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: default;
}
.data-table thead th.sortable { cursor: pointer; user-select: none; }
.data-table thead th.sortable:hover { color: var(--text); }
.data-table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
  vertical-align: middle;
}
.data-table tbody tr:nth-child(even) { background: var(--surface2); }
.data-table tbody tr:hover { background: var(--bg2); }
.data-table tbody tr:last-child td { border-bottom: none; }
.table-actions { display: flex; gap: 6px; }
.table-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text3);
}
.table-empty .empty-icon { font-size: 2.5rem; margin-bottom: 10px; opacity: 0.5; }

/* ============================================================
   MULTI-SELECT DROPDOWN
============================================================ */
.multiselect { position: relative; }
.ms-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.ms-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--tag-bg);
  color: var(--tag-text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
  font-size: 0.82rem;
}
.ms-chip button {
  background: transparent;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0 2px;
}
.ms-chip button:hover { color: var(--status-failed); }
.ms-trigger {
  width: 100%;
  text-align: left;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text2);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ms-trigger:hover { border-color: var(--border-strong); }
.ms-trigger .ms-caret { transition: transform 0.2s; color: var(--text3); }
.multiselect.open .ms-trigger .ms-caret { transform: rotate(180deg); }
.ms-panel {
  position: absolute;
  z-index: 200;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 10px;
  max-height: 320px;
  overflow-y: auto;
}
.ms-search { margin-bottom: 8px; }
.ms-group-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 8px 8px 4px;
}
.ms-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.ms-option:hover { background: var(--bg2); }
.ms-option input { width: auto; }
.ms-option .ms-opt-main { font-size: 0.88rem; color: var(--text); }
.ms-option .ms-opt-sub { font-size: 0.76rem; color: var(--text3); }
.ms-empty { padding: 16px 8px; color: var(--text3); font-size: 0.85rem; text-align: center; }

/* ============================================================
   TOAST SYSTEM
============================================================ */
#toastHost {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 14px 18px;
  font-size: 0.88rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideDown 0.22s ease;
}
.toast.toast-success { border-left-color: var(--status-submitted); }
.toast.toast-error   { border-left-color: var(--status-failed); }
.toast.toast-info    { border-left-color: var(--badge-user); }
.toast .toast-icon { font-size: 1.1rem; }

/* ============================================================
   BAR CHART (SVG)
============================================================ */
.chart-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
}
.chart-panel h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 18px;
}
.bar-row { margin-bottom: 14px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text2);
  margin-bottom: 5px;
}
.bar-label .bar-count { font-weight: 700; color: var(--text); }
.bar-track {
  height: 10px;
  background: var(--chart-bar-empty);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--chart-bar);
  border-radius: 999px;
  width: 0;
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.bar-row.empty .bar-label { color: var(--text3); }

/* ============================================================
   ACTIVITY FEED
============================================================ */
.activity-feed { display: flex; flex-direction: column; }
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 7px;
  flex-shrink: 0;
}
.activity-text { font-size: 0.85rem; color: var(--text2); line-height: 1.5; }
.activity-text strong { color: var(--text); }
.activity-time { font-size: 0.76rem; color: var(--text3); margin-top: 2px; }

/* ============================================================
   TABS
============================================================ */
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
}
.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text3);
  padding: 12px 18px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.tab-btn:hover { color: var(--text2); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }

/* ============================================================
   NOTE CARDS
============================================================ */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.note-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  min-height: 140px;
}
.note-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.note-card h4 { font-size: 0.95rem; color: var(--text); margin-bottom: 8px; }
.note-card .note-preview {
  font-size: 0.83rem;
  color: var(--text2);
  line-height: 1.5;
  flex: 1;
  white-space: pre-wrap;
  overflow: hidden;
}
.note-card .note-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.note-card .note-date { font-size: 0.74rem; color: var(--text3); }
.note-card-actions { display: flex; gap: 6px; }
.note-editor textarea { min-height: 240px; resize: vertical; }

/* ============================================================
   FILTER BAR
============================================================ */
.filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 20px;
}
.filter-bar label { margin-bottom: 4px; }

/* ============================================================
   SUBMIT BAR
============================================================ */
.submit-bar {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px 0 0;
  border-top: 1px solid var(--border);
  margin-top: 24px;
}

/* ============================================================
   DRAFT BANNER
============================================================ */
.draft-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(202,138,4,0.10);
  border: 1px solid rgba(202,138,4,0.3);
  color: var(--text);
  border-radius: var(--radius);
  padding: 12px 18px;
  margin-bottom: 18px;
  font-size: 0.88rem;
}
.draft-banner .draft-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ============================================================
   SURVEY RESULTS
   Token-based so it renders correctly in both portals.
============================================================ */
.sv-settings { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.sv-settings .checkbox-row { align-items: flex-start; flex-wrap: wrap; }
.sv-settings .helper-text { flex-basis: 100%; margin-top: 2px; }

.sv-results {
  display: flex;
  flex-direction: column;
  max-height: min(86vh, 900px);
  text-align: left;
  padding: 0;
  overflow: hidden;
}
.sv-results-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 24px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sv-results-sub { font-size: 0.84rem; color: var(--text3); margin-top: 4px; }
.sv-results-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Tabs */
.sv-tabs { display: flex; gap: 6px; padding: 12px 24px 0; flex-shrink: 0; }
.sv-tab {
  border: 1px solid transparent;
  background: none;
  padding: 7px 14px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text3);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.sv-tab:hover { color: var(--text2); background: var(--bg2); }
.sv-tab.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* Question card */
.sv-q-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}
.sv-q-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.sv-q-index {
  flex-shrink: 0;
  width: 24px; height: 24px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.74rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.sv-q-titles { min-width: 0; }
.sv-q-prompt { font-size: 0.94rem; font-weight: 600; color: var(--text); line-height: 1.35; }
.sv-q-meta { font-size: 0.74rem; color: var(--text3); margin-top: 3px; }

/* Bar chart */
.sv-bars { display: flex; flex-direction: column; gap: 8px; }
.sv-bar-row { display: flex; align-items: center; gap: 10px; font-size: 0.82rem; }
.sv-bar-label {
  flex: 0 0 34%;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sv-bar-track {
  flex: 1;
  height: 9px;
  background: var(--bg2);
  border-radius: 999px;
  overflow: hidden;
}
.sv-bar-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.sv-bar-val {
  flex: 0 0 74px;
  text-align: right;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.sv-bar-pct { font-weight: 500; color: var(--text3); font-size: 0.75rem; }

/* Free-text answers */
.sv-textlist { display: flex; flex-direction: column; gap: 8px; }
.sv-textitem {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.sv-textitem-body { font-size: 0.88rem; color: var(--text2); line-height: 1.55; }
.sv-textitem-meta { font-size: 0.72rem; color: var(--text3); margin-top: 6px; }
.sv-empty { font-size: 0.84rem; color: var(--text3); font-style: italic; }

/* By-respondent view */
.sv-person-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.sv-person-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.sv-person-name { font-weight: 700; font-size: 0.9rem; color: var(--text); }
.sv-person-date { font-size: 0.74rem; color: var(--text3); }
.sv-ans-row { display: flex; gap: 12px; padding: 6px 0; font-size: 0.84rem; }
.sv-ans-q { flex: 0 0 42%; color: var(--text3); }
.sv-ans-v { flex: 1; color: var(--text); font-weight: 500; }
.sv-skipped { color: var(--text3); font-style: italic; font-weight: 400; }

@media (max-width: 620px) {
  .sv-results-head, .sv-results-body { padding-left: 16px; padding-right: 16px; }
  .sv-tabs { padding-left: 16px; padding-right: 16px; }
  .sv-bar-label { flex-basis: 40%; }
  .sv-bar-val { flex-basis: 62px; }
  .sv-ans-row { flex-direction: column; gap: 2px; }
  .sv-ans-q { flex-basis: auto; }
}

/* ---- Newsletter external-recipient picker ---- */
.nl-recip-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 190px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 10px;
  background: var(--surface);
}
.nl-recip { display: flex; align-items: center; gap: 8px; margin: 0; padding: 4px 0; }
.nl-recip-name { font-weight: 600; font-size: 0.85rem; color: var(--text); }
.nl-recip-email { font-size: 0.76rem; color: var(--text3); margin-left: auto; }
.nl-recip-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.nl-recip-add input { flex: 1 1 150px; }
@media (max-width: 560px) {
  .nl-recip-email { margin-left: 0; flex-basis: 100%; }
  .nl-recip { flex-wrap: wrap; }
}

/* ---- Newsletter reader modal (unscoped base; admin-pro.css restyles it) ---- */
.nl-modal {
  max-width: 640px;
  width: 100%;
  max-height: min(85vh, 860px);
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-align: left;
}
.nl-modal-img { width: 100%; max-height: 240px; object-fit: cover; display: block; flex: 0 0 auto; }
.nl-modal-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px 28px 12px;
}
.nl-modal-body { white-space: pre-wrap; line-height: 1.7; color: var(--text2); }
.nl-modal-actions {
  flex: 0 0 auto;
  justify-content: flex-end;
  margin: 0;
  padding: 14px 28px 18px;
  border-top: 1px solid var(--border);
}
@media (max-width: 560px) {
  .nl-modal-scroll { padding: 20px 18px 10px; }
  .nl-modal-actions { padding: 12px 18px 16px; }
}

/* ============================================================
   REPORT → GOAL LINKAGE (report form)
============================================================ */
.rf-goal-list { display: flex; flex-direction: column; gap: 10px; }
.rf-goal-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}
.rf-goal-row.is-on { border-color: var(--accent); background: var(--surface2); }
.rf-goal-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 1;
  min-width: 0;
  margin: 0;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}
.rf-goal-check input[type="checkbox"] { margin-top: 3px; flex-shrink: 0; }
.rf-goal-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.rf-goal-title { font-size: 0.88rem; font-weight: 600; color: var(--text); }
.rf-goal-sub { font-size: 0.74rem; color: var(--text3); }
.rf-goal-track {
  position: relative;
  display: block;
  height: 7px;
  background: var(--bg2);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 2px;
}
.rf-goal-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--text3);
  border-radius: 999px;
}
/* The projected gain from this report, previewed on top of current progress */
.rf-goal-gain {
  position: absolute;
  top: 0; bottom: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.25s ease, left 0.25s ease;
}
.rf-goal-pct { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.rf-goal-pct input[type="number"] { width: 72px; text-align: right; padding: 8px 10px; }
.rf-goal-pct input:disabled { opacity: 0.45; cursor: not-allowed; }
.rf-goal-pct-sign { font-size: 0.82rem; color: var(--text3); font-weight: 600; }
.rf-goal-done { color: var(--status-submitted); font-weight: 700; }
#rfGoalSummary { margin-top: 12px; line-height: 1.7; }

@media (max-width: 560px) {
  .rf-goal-row { flex-wrap: wrap; }
  .rf-goal-pct { width: 100%; justify-content: flex-end; }
}
