:root {
  --bg: #f3efe7;
  --paper: #fffdf8;
  --ink: #1f2a33;
  --muted: #69737d;
  --line: #d7cfc3;
  --accent: #0f766e;
  --accent-dark: #0b5954;
  --warm: #f6c178;
  --danger: #b42318;
  --shadow: 0 18px 60px rgba(31, 42, 51, 0.08);
  --radius: 24px;
  --radius-sm: 14px;
  --maxw: 1180px;
  --font: "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(246, 193, 120, 0.35), transparent 30%),
    linear-gradient(180deg, #fbf7f1 0%, #f2ede5 100%);
}
a { color: inherit; }
input, textarea, select, button {
  font: inherit;
}
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  background: white;
}
button {
  cursor: pointer;
  border: 0;
}
.public-shell, .login-shell {
  width: min(100% - 1.5rem, 760px);
  margin: 0 auto;
  padding: 2rem 0 4rem;
}
.card {
  background: var(--paper);
  border: 1px solid rgba(215, 207, 195, 0.6);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero-card, .survey-card, .login-card {
  padding: 1.4rem;
  margin-top: 1rem;
}
.eyebrow {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.74rem;
  color: var(--accent);
  font-weight: 700;
}
.public-body h1, .admin-body h1, .admin-body h2 {
  margin: 0;
}
.survey-field {
  padding: 1rem 0;
  border-bottom: 1px solid rgba(215, 207, 195, 0.7);
}
.survey-field:last-child {
  border-bottom: 0;
}
.field-label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.field-help, .muted {
  color: var(--muted);
}
.choices-group {
  display: grid;
  gap: 0.65rem;
}
.choice-row, .inline-check {
  display: flex;
  gap: 0.7rem;
  align-items: center;
}
.choice-row input, .inline-check input {
  width: auto;
}
.primary-button, .secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.95rem 1.4rem;
  text-decoration: none;
  font-weight: 700;
}
.primary-button {
  background: var(--accent);
  color: white;
}
.primary-button:hover {
  background: var(--accent-dark);
}
.secondary-button {
  background: transparent;
  border: 1px solid var(--line);
}
.form-feedback {
  min-height: 1.2rem;
  margin-top: 1rem;
  color: var(--accent-dark);
}
.admin-layout {
  display: grid;
  min-height: 100vh;
}
.admin-sidebar {
  background: #20303b;
  color: white;
  padding: 1.5rem;
  display: grid;
  gap: 2rem;
}
.side-nav {
  display: grid;
  gap: 0.6rem;
}
.side-nav a {
  text-decoration: none;
  padding: 0.8rem 0.9rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
}
.side-nav a.active {
  background: rgba(255, 255, 255, 0.16);
}
.admin-main {
  padding: 1.25rem;
  width: min(100%, var(--maxw));
}
.admin-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.table-wrap {
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th, .data-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.stack-form {
  display: grid;
  gap: 1rem;
}
.form-grid {
  display: grid;
  gap: 1rem;
}
.builder-head, .builder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}
.question-builder, .results-grid {
  display: grid;
  gap: 1rem;
}
.question-card, .result-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1rem;
  background: #fff;
}
.question-card-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}
.card-tools {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.drag-handle {
  cursor: grab;
}
.move-up, .move-down {
  color: var(--accent) !important;
  font-size: 1.1rem;
  line-height: 1;
}
.question-card.dragging {
  opacity: 0.4;
}
.question-card.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}
.link-button {
  background: none;
  padding: 0;
  color: var(--danger);
}
.result-row {
  display: grid;
  gap: 0.3rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #eee7dd;
}
.result-row:last-child {
  border-bottom: 0;
}
.flash {
  padding: 0.9rem 1rem;
  border-radius: 14px;
}
.flash-success {
  background: #e7f8f1;
  color: #0c5c40;
}
.flash-error {
  background: #fdecec;
  color: var(--danger);
}
.qr-card {
  width: min(100%, 520px);
  padding: 1.5rem;
}
.qr-image {
  max-width: 260px;
  width: 100%;
  display: block;
  margin-bottom: 1rem;
}
code {
  background: #f5f0e7;
  border-radius: 8px;
  padding: 0.15rem 0.45rem;
}

.survey-step {
  padding: 1rem 0;
}

.survey-progress {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin: 1rem 0 0.5rem;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.thank-you h2 {
  color: var(--accent);
  margin: 0 0 0.5rem;
}
.survey-nav {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding-top: 0.5rem;
}

.pagination {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 0 0.5rem;
}
.pagination-info {
  color: var(--muted);
  font-size: 0.85rem;
}
.stats-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}
.stat-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1rem;
  background: #fff;
}
.stat-card h4 {
  margin: 0 0 0.75rem;
}
.stat-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.4rem;
}
.stat-label {
  width: 30%;
  font-size: 0.85rem;
  word-break: break-word;
}
.stat-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.stat-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s;
}
.stat-count {
  width: 5rem;
  text-align: right;
  font-size: 0.8rem;
  color: var(--muted);
}
.stat-avg {
  font-size: 1.2rem;
  color: var(--ink);
}
.inline-form {
  display: inline;
}
.action-delete {
  color: var(--danger) !important;
}
.action-clone {
  color: var(--accent) !important;
}

@media (min-width: 840px) {
  .stats-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
  .admin-layout {
    grid-template-columns: 280px 1fr;
  }
  .admin-main {
    padding: 2rem;
  }
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .hero-card, .survey-card {
    padding: 2rem;
  }
}
