:root {
  --primary: #D97757;
  --primary-dark: #C4623E;
  --bg: #FAF9F7;
  --text: #1A1A1A;
  --text-muted: #7A7572;
  --card-bg: #FFFFFF;
  --border: #E0DEDA;
  --badge-bg: #FDF0EB;
  --shadow: 0 1px 8px rgba(0, 0, 0, 0.08);
}

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

a{
  color: var(--primary);
}

body {
  font-family: 'IBM Plex Sans Thai', sans-serif;
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Layout ── */

.page-wrapper {
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 20px 80px;
}

/* ── Card (form page) ── */

.card {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 36px 36px 28px;
  border-bottom: 1px solid var(--border);
}

.title {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  margin-bottom: 8px;
}

.subtitle {
  font-size: 1rem;
  font-weight: 500;
  color: var(--primary);
}

.survey-description {
  margin-top: 12px;
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.7;
}

.survey-description h1,
.survey-description h2,
.survey-description h3 {
  font-weight: 600;
  margin: 1em 0 0.4em;
}

.survey-description h1 { font-size: 1.2rem; }
.survey-description h2 { font-size: 1.1rem; }
.survey-description h3 { font-size: 1rem; }

.survey-description p {
  margin-bottom: 0.8em;
}

.survey-description ul,
.survey-description ol {
  padding-left: 1.4em;
  margin-bottom: 0.8em;
}

.survey-description li {
  margin-bottom: 0.3em;
}

.survey-description code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.survey-description pre {
  background: var(--bg);
  padding: 12px 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 0.8em;
}

.survey-description pre code {
  background: none;
  padding: 0;
}

/* ── Deadline label ── */

.deadline-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Closed state ── */

.closed-state {
  padding: 48px 36px;
  text-align: center;
}

.closed-icon {
  width: 56px;
  height: 56px;
  background: #FEF0EF;
  color: #C0392B;
  border-radius: 50%;
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.closed-state h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.closed-state p {
  color: var(--text-muted);
}

/* ── Already voted state ── */

.already-voted {
  padding: 48px 36px;
  text-align: center;
}

.already-voted-icon {
  width: 56px;
  height: 56px;
  background: #FEF0EF;
  color: #C0392B;
  border-radius: 50%;
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.already-voted h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.already-voted p {
  color: var(--text-muted);
}

/* ── Form ── */

.form {
  padding: 28px 36px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.field input,
.field textarea,
.field select {
  font-family: 'IBM Plex Sans Thai', sans-serif;
  font-size: 1rem;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  resize: vertical;
  width: 100%;
}

.field select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237A7572' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #B5B0AC;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(217, 119, 87, 0.15);
}

.btn-primary {
  font-family: 'IBM Plex Sans Thai', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  padding: 13px 24px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-primary:active {
  transform: scale(0.98);
}

.required-mark {
  color: #C0392B;
  margin-left: 2px;
}

.choices-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.choice-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.choice-label:hover {
  border-color: var(--primary);
  background: var(--badge-bg);
}

.choice-label input[type="radio"],
.choice-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.choice-check {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
}

.choice-label input[type="checkbox"] + .choice-check {
  border-radius: 5px;
}

.choice-label:hover .choice-check {
  border-color: var(--primary);
}

.choice-label input:checked + .choice-check {
  border-color: var(--primary);
  background: var(--primary);
}

.choice-check::after {
  content: "";
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 50%;
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.15s, transform 0.15s;
}

.choice-label input[type="checkbox"] + .choice-check::after {
  width: 5px;
  height: 9px;
  background: none;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  border-radius: 0;
  transform: rotate(45deg) scale(0);
  margin-bottom: 2px;
}

.choice-label input:checked + .choice-check::after {
  opacity: 1;
  transform: scale(1);
}

.choice-label input[type="checkbox"]:checked + .choice-check::after {
  transform: rotate(45deg) scale(1);
}

.choice-text {
  font-size: 0.95rem;
  color: var(--text);
}

.other-input {
  font-family: 'IBM Plex Sans Thai', sans-serif;
  font-size: 1rem;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  width: 100%;
  margin-top: 4px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.other-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(217, 119, 87, 0.15);
}

.btn-primary svg,
.btn-secondary svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.deadline-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 12px;
}

.deadline-label svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ── Thank-you ── */

.thank-you {
  padding: 48px 36px;
  text-align: center;
}

.thank-you-icon {
  width: 56px;
  height: 56px;
  background: var(--badge-bg);
  color: var(--primary);
  border-radius: 50%;
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.thank-you h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.thank-you p {
  color: var(--text-muted);
}

/* ── Card footer ── */

.card-footer {
  padding: 20px 36px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.link-muted {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.link-muted:hover {
  color: var(--primary);
}

/* ── Responses page ── */

.responses-header {
  margin-bottom: 28px;
}

.responses-header .title {
  margin-bottom: 10px;
}

.responses-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.count-label {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.count-badge {
  font-weight: 600;
  color: var(--primary);
}

.btn-download {
  font-family: 'IBM Plex Sans Thai', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--primary);
  text-decoration: none;
  padding: 7px 14px;
  border: 1.5px solid var(--primary);
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}

.btn-download:hover {
  background: var(--primary);
  color: #fff;
}

.btn-dashboard {
  font-family: 'Sarabun', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  color: #fff;
  text-decoration: none;
  padding: 7px 14px;
  border: 1.5px solid var(--primary);
  border-radius: 8px;
  background: var(--primary);
  transition: background 0.15s, color 0.15s;
}

.btn-dashboard:hover {
  background: var(--primary-dark);
  color: #fff;
}

.action-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}

.response-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 32px;
}

.response-card {
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  padding: 0;
  transition: box-shadow 0.2s ease, transform 0.15s ease;
  overflow: hidden;
}

.response-card:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}

.response-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--badge-bg) 0%, var(--card-bg) 100%);
  border-bottom: 1px solid var(--border);
}

.response-number {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--card-bg);
  padding: 4px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--primary);
}

.response-date {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.response-content {
  max-height: 0;
  overflow: hidden;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: max-height 0.25s ease, padding 0.25s ease;
}

/* Expanded state for collapsible cards */
.response-card[data-expanded="true"] .response-content {
  max-height: 1000px; /* plenty of room for content; cf. height-based expand */
  padding: 16px 20px;
}

.response-header[data-expanded="true"] {
  /* ensure header visual feedback if needed */
}

.response-header { cursor: default; }
.response-header[tabindex]{ cursor: pointer; }
.response-header:hover { background: #f7f7f7; }
.response-header .chevron { transition: transform 0.25s ease; }
.response-card[data-expanded="true"] .response-header .chevron { transform: rotate(180deg); }

.response-field {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  align-items: start;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.response-field:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.field-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.5;
  padding-top: 2px;
}

.field-value {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.7;
  word-break: break-word;
}

.field-value p {
  margin-bottom: 0.6em;
}

.field-value p:last-child {
  margin-bottom: 0;
}

.field-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.field-tag {
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--badge-bg);
  color: var(--primary);
  padding: 4px 12px;
  border-radius: 8px;
  border: 1px solid rgba(217, 119, 87, 0.2);
}

@media (max-width: 520px) {
  .response-field {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .field-label {
    padding-top: 0;
  }
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.kpi-card:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}

.kpi-icon {
  width: 40px;
  height: 40px;
  background: var(--badge-bg);
  color: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.kpi-icon svg {
  width: 20px;
  height: 20px;
}

.kpi-value {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  word-break: break-word;
}

.kpi-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.chart-card {
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.chart-card:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}

.chart-card-wide {
  grid-column: 1 / -1;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--badge-bg) 0%, var(--card-bg) 100%);
  border-bottom: 1px solid var(--border);
}

.chart-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.chart-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--card-bg);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1.5px solid var(--primary);
}

.chart-body {
  padding: 20px;
  flex: 1;
  min-height: 280px;
}

/* ── Empty state ── */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 1rem;
}

/* ── Back button ── */

.back-row {
  text-align: center;
}

.btn-secondary {
  font-family: 'IBM Plex Sans Thai', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  padding: 10px 20px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  display: inline-block;
  transition: border-color 0.15s, color 0.15s;
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ── Form error ── */

.form-error {
  font-size: 0.9rem;
  color: #C0392B;
  background: #FDECEA;
  padding: 10px 14px;
  border-radius: 8px;
}

/* ── Passcode gate ── */

.passcode-gate {
  padding: 48px 36px;
  text-align: center;
}

.passcode-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
}

.passcode-gate h2 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 24px;
}

.passcode-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 320px;
  margin: 0 auto;
}

.passcode-form .field input {
  font-family: 'IBM Plex Sans Thai', sans-serif;
  font-size: 1rem;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  text-align: center;
}

.passcode-form .field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(217, 119, 87, 0.15);
}

/* ── Form actions ── */

.form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.form-actions .btn-primary {
  flex: 1;
  min-width: 200px;
}

/* ── Draft status ── */

.draft-status {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  text-align: center;
  opacity: 0;
  transition: opacity 0.2s, background-color 0.2s;
}

.draft-status.saving {
  background: #FEF3C7;
  color: #92400E;
  opacity: 1;
}

.draft-status.saved {
  background: #D1FAE5;
  color: #065F46;
  opacity: 1;
}

.draft-status.error {
  background: #FEE2E2;
  color: #991B1B;
  opacity: 1;
}

.admin-login-wrapper {
  max-width: 420px;
  margin: 80px auto 40px;
  padding: 0 20px;
}

.admin-login-card {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.admin-login-header {
  padding: 36px 36px 24px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--badge-bg) 0%, var(--card-bg) 100%);
}

.admin-login-header .title {
  margin-bottom: 6px;
}

.admin-login-header .subtitle {
  color: var(--text-muted);
}

.admin-logo {
  width: 48px;
  height: 48px;
  background: var(--badge-bg);
  color: var(--primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.admin-logo svg {
  width: 24px;
  height: 24px;
}

.admin-login-form {
  padding: 28px 36px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-login-form .btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.admin-body {
  background: var(--bg);
}

.admin-layout {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: 240px;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
}

.admin-sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.admin-brand {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.admin-nav {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.admin-nav-link:hover {
  background: var(--badge-bg);
  color: var(--primary);
}

.admin-nav-link.active {
  background: var(--badge-bg);
  color: var(--primary);
}

.admin-nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.admin-sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.admin-main {
  flex: 1;
  margin-left: 240px;
  padding: 32px 40px;
  max-width: 1200px;
}

.admin-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.admin-page-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.admin-page-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.admin-table-wrapper {
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th {
  text-align: left;
  padding: 14px 20px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.admin-table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.admin-table tbody tr:hover {
  background: var(--bg);
}

.admin-table-title {
  font-weight: 600;
  color: var(--text);
}

.admin-table-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.admin-code {
  font-size: 0.8rem;
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--text-muted);
}

.admin-status {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
}

.admin-status.active {
  background: #D1FAE5;
  color: #065F46;
  border-color: #A7F3D0;
}

.admin-table-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.admin-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--card-bg);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  padding: 0;
}

.admin-action-btn:hover {
  background: var(--badge-bg);
  border-color: var(--primary);
  color: var(--primary);
}

.admin-action-btn.danger:hover {
  background: #FEF2F2;
  border-color: #FCA5A5;
  color: #DC2626;
}

.inline-form {
  display: inline;
}

.admin-form-wrapper {
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.admin-edit-form {
  padding: 28px 36px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.admin-form-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-form-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.admin-form-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-question-card {
  background: var(--card-bg);
  border-radius: 12px;
  border: 1.5px solid var(--border);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.admin-question-card:last-child {
  margin-bottom: 0;
}

.admin-question-card.dragging {
  opacity: 0.5;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(217, 119, 87, 0.2);
}

.admin-question-card.drag-over {
  border-top: 3px solid var(--primary);
}

.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding: 4px;
  margin-right: 4px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.drag-handle:hover {
  background: var(--badge-bg);
  color: var(--primary);
}

.drag-handle:active {
  cursor: grabbing;
}

.admin-question-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.admin-question-number {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--badge-bg);
  padding: 4px 12px;
  border-radius: 999px;
}

.field-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding-top: 28px;
}

.field-checkbox input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-width: 20px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--primary);
  border: 1.5px solid var(--border);
  border-radius: 5px;
}

.field-checkbox label {
  margin: 0;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.field-row .field {
  margin: 0;
}

.admin-form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.admin-form-actions .btn-primary {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 768px) {
  .admin-sidebar {
    width: 100%;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .admin-layout {
    flex-direction: column;
  }

  .admin-main {
    margin-left: 0;
    padding: 20px;
  }

  .admin-page-header {
    flex-direction: column;
  }

  .admin-table-wrapper {
    overflow-x: auto;
  }

  .field-row {
    grid-template-columns: 1fr;
  }
}

/* ── Survey Images ── */

.survey-images {
  margin-top: 20px;
}

.survey-images-full {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.survey-images-full .survey-image {
  width: 100%;
  border-radius: 10px;
  display: block;
}

.survey-images-thumbnail {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.survey-images-thumbnail .survey-image-wrapper {
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.survey-images-thumbnail .survey-image-wrapper:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.survey-images-thumbnail .survey-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── Lightbox ── */

.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  padding: 40px;
}

.lightbox-overlay.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.lightbox-close:hover {
  background: rgba(255,255,255,0.25);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  z-index: 1001;
}

.lightbox-nav:hover {
  background: rgba(255,255,255,0.25);
}

.lightbox-prev {
  left: 16px;
}

.lightbox-next {
  right: 16px;
}

.lightbox-counter {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  background: rgba(0,0,0,0.4);
  padding: 6px 14px;
  border-radius: 999px;
  user-select: none;
}

@media (max-width: 520px) {
  .lightbox-nav {
    width: 40px;
    height: 40px;
  }

  .lightbox-prev {
    left: 8px;
  }

  .lightbox-next {
    right: 8px;
  }
}

/* ── Admin Image Management ── */

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 8px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.radio-label input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.image-upload-form {
  margin-top: 8px;
}

.image-upload-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.image-upload-row input[type="file"] {
  flex: 1;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  background: #fff;
}

.admin-image-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.admin-image-item {
  position: relative;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.admin-image-preview {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.admin-image-name {
  display: block;
  padding: 8px 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-image-delete-form {
  position: absolute;
  top: 6px;
  right: 6px;
}

.admin-image-delete-form .admin-action-btn {
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(4px);
}
