/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --gold:      #C08A30;
  --gold-d:    #8B6318;
  --gold-l:    #F0E8D0;
  --gold-pale: #FAF5E8;
  --success:   #2D6A4F;
  --danger:    #dc2626;
  --bg:        #ffffff;
  --card:      #ffffff;
  --card-opt:  #F2EDE0;
  --border:    #D8CEBC;
  --text:      #1A1A1A;
  --muted:     #666666;
  --radius:    8px;
  --shadow:    0 1px 6px rgba(0,0,0,.07);

  /* keep --primary mapped to gold for admin compatibility */
  --primary:   #C08A30;
  --primary-d: #8B6318;
  --accent:    #E6B060;
}

body {
  font-family: 'Georgia', 'Times New Roman', serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Utility ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-muted { color: var(--muted); }
.text-center { text-align: center; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

/* ── Top brand bar ────────────────────────────────────────────────────────── */
.top-brand-bar {
  padding: .65rem 2rem;
  font-size: .82rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  font-style: italic;
  font-family: 'Georgia', serif;
}

/* ── Hero header box ──────────────────────────────────────────────────────── */
.hero-wrapper {
  padding: 1.5rem 2rem 0;
  max-width: 860px;
  margin: 0 auto;
}

.hero-box {
  background: var(--gold-pale);
  border-left: 5px solid var(--gold);
  padding: 2rem 2.5rem;
  text-align: center;
}

.hero-title {
  font-family: 'Georgia', serif;
    font-size: clamp(1.4rem, 4vw, 2rem);
    font-weight: 700;
    letter-spacing: 0em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: .6rem;
}

.hero-subtitle {
  font-style: italic;
  font-size: 1.1rem;
  color: #2a2a2a;
  margin-bottom: .4rem;
}

.hero-date {
  font-weight: 700;
  font-size: 1rem;
  color: #7B3000;
}

/* ── Intro section ────────────────────────────────────────────────────────── */
.intro-wrapper {
  max-width: 860px;
  margin: 1.5rem auto 0;
  padding: 0 2rem;
  margin-bottom: 2em;
}

.intro-text {
  font-size: .97rem;
  line-height: 1.75;
  margin-bottom: 1.25rem;
  color: var(--text);
  text-align: center;
}

.info-badges {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
  border: 1px solid var(--border);
}

.info-badge {
  padding: 1rem 1.25rem;
  text-align: center;
  font-size: .87rem;
}

.info-badge strong {
  display: block;
  font-size: 1rem;
  margin-bottom: .3rem;
}

.info-badge p { color: var(--muted); font-size: .82rem; line-height: 1.45; }

.badge-green  { background: #E8F5EE; color: var(--success); }
.badge-green strong { color: var(--success); }
.badge-neutral { background: #F5EFE0; }
.badge-neutral strong { color: var(--gold-d); }
.badge-pink   { background: #FEF3F0; }
.badge-pink strong { color: #B84020; }

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.progress-wrapper {
  background: var(--gold-d);
  padding: .55rem 2rem .7rem;
  position: sticky;
  top: 0;
  z-index: 10;
  max-width: 860px;
    margin: 1.5rem auto 0;
    margin-bottom: 2em;
}

.progress-bar-bg {
  background: rgba(255,255,255,.25);
  border-radius: 99px;
  height: 7px;
  overflow: hidden;
}

.progress-bar-fill {
  background: #fff;
  height: 100%;
  border-radius: 99px;
  transition: width .4s ease;
  width: 0%;
}

.progress-label {
  color: rgba(255,255,255,.85);
  font-size: .75rem;
  text-align: right;
  margin-top: .2rem;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

/* ── Survey body ──────────────────────────────────────────────────────────── */
.survey-body {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 2rem 4rem;
}

/* ── Section header ───────────────────────────────────────────────────────── */
.section-divider {
  border: none;
  border-top: 1.5px solid var(--gold);
  margin: 2.5rem 0 2rem;
  opacity: .6;
}

.section-header { margin: 2rem 0 1.5rem; }

.section-label {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: .73rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: .4rem;
}

.section-title {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: .4rem;
}

.section-description {
  font-style: italic;
  color: var(--muted);
  font-size: .95rem;
}

.survey-section {
  margin-bottom: 2rem;
}

/* ── Question block ───────────────────────────────────────────────────────── */
.question-block {
  margin-bottom: 2.25rem;
}

.question-header { margin-bottom: .75rem; }

.question-number {
  font-weight: 700;
  color: var(--gold);
  font-size: 1.05rem;
  margin-right: .4rem;
}

.question-text {
  font-size: 1.05rem;
  font-weight: 700;
  display: inline;
  color: var(--text);
}

.required-star { color: var(--danger); margin-left: .2rem; }

.question-prompt {
  font-size: 1.1rem;
  font-weight: 700;
  font-style: italic;
  color: var(--gold);
  margin: .5rem 0;
}

.question-hint {
  font-style: italic;
  color: var(--muted);
  font-size: .88rem;
  margin-bottom: .6rem;
}

/* ── Card options grid ────────────────────────────────────────────────────── */
.card-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  background: var(--card-opt);
  border: 1px solid var(--border);
}

.card-options.cols-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.card-option-item {
  padding: .85rem 1.1rem 1rem;
  cursor: pointer;
  border: 1px solid transparent;
  border-right: 1px solid rgba(0,0,0,.07);
  border-bottom: 1px solid rgba(0,0,0,.07);
  transition: background .15s;
  background: var(--card-opt);
  position: relative;
}

.card-option-item:hover { background: #E8DFC8; }

.card-option-item.selected {
  background: #EDE0C4;
  outline: 2px solid var(--gold);
  outline-offset: -2px;
  z-index: 1;
}

.card-option-item input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.card-option-icon {
  font-size: .9rem;
  color: var(--gold);
  margin-right: .35rem;
}

.card-option-title {
  font-weight: 700;
  font-size: .95rem;
  color: var(--text);
  display: inline;
}

.card-option-desc {
  font-size: .83rem;
  color: var(--muted);
  margin-top: .25rem;
  line-height: 1.4;
}

/* ── Radio / checkbox options ─────────────────────────────────────────────── */
.options-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--card-opt);
}

.option-item {
  border-bottom: 1px solid rgba(0,0,0,.07);
}

.option-item:last-child {
  border-bottom: none;
}

.option-item label {
  display: flex;
  gap: .55rem;
  align-items: center;
  padding: .65rem .9rem;
  cursor: pointer;
}

.option-item.selected {
  background: #EDE0C4;
  outline: 2px solid var(--gold);
  outline-offset: -2px;
  position: relative;
  z-index: 1;
}

.scale-options {
  display: grid;
  grid-template-columns: repeat(var(--scale-columns, 5), minmax(2.2rem, 1fr));
  gap: 0;
  overflow-x: auto;
}

.scale-option-item {
  border-bottom: none;
  border-right: 1px solid rgba(0,0,0,.07);
}

.scale-option-item:last-child {
  border-right: none;
}

.scale-option-item label {
  justify-content: center;
  padding: .55rem .2rem;
}

.scale-option-item input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.scale-option-value {
  font-weight: 700;
  font-size: 1.05rem;
  color: #5d5d5d;
}

.scale-option-item.selected .scale-option-value {
  color: var(--gold-d);
}

/* ── Text answer ──────────────────────────────────────────────────────────── */
.text-answer-wrap {
  background: var(--gold-pale);
  border: 1px solid var(--gold-l);
  padding: .75rem 1rem;
}

.text-answer-label {
  font-weight: 700;
  color: var(--gold);
  font-size: .9rem;
  margin-bottom: .4rem;
}

.text-answer {
  width: 100%;
  min-height: 100px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: .97rem;
  resize: vertical;
  outline: none;
  color: var(--text);
  line-height: 1.6;
}

.char-count {
  font-size: .73rem;
  color: var(--muted);
  text-align: right;
  margin-top: .2rem;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

/* ── Submit area ──────────────────────────────────────────────────────────── */
.section-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  margin: .25rem 0 1.5rem;
}

.btn-nav {
  background: transparent;
  color: var(--gold-d);
  border: 2px solid var(--gold);
}

.btn-nav:hover {
  background: var(--gold);
  color: #fff;
}

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

.submit-area { text-align: center; margin-top: 2.5rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem 2rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

.btn-primary { background: var(--gold); color: #fff; }
.btn-primary:hover { background: var(--gold-d); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(192,138,48,.4); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { background: #D4B878; cursor: not-allowed; transform: none; box-shadow: none; }

.validation-msg {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  padding: .75rem 1.1rem;
  margin-top: 1rem;
  font-size: .9rem;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

.question-block.unanswered .card-options {
  outline: 2px solid var(--danger);
}

.question-block.unanswered .options-list {
  outline: 2px solid var(--danger);
}

.question-block.unanswered .text-answer-wrap {
  outline: 2px solid var(--danger);
}

/* ── Thank you screen ─────────────────────────────────────────────────────── */
.thankyou {
  text-align: center;
  padding: 3rem 1.5rem;
  max-width: 520px;
  margin: auto;
}

.thankyou-icon {
  width: 80px;
  height: 80px;
  background: #dcfce7;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  font-size: 2.2rem;
}

.thankyou h2 { font-size: 1.7rem; margin-bottom: .5rem; }
.thankyou p  { color: var(--muted); font-size: 1rem; }

/* ── Admin page ───────────────────────────────────────────────────────────── */
.admin-layout { display: flex; min-height: 100vh; font-family: 'Segoe UI', system-ui, sans-serif; }

.sidebar {
  width: 240px; flex-shrink: 0;
  background: #0f172a;
  color: #e2e8f0;
  padding: 1.5rem 1rem;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}

.sidebar-brand {
  font-size: 1.05rem; font-weight: 700;
  color: #fff; padding: .5rem .75rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  margin-bottom: 1rem;
}

.sidebar-brand span { color: var(--accent); }

.nav-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem .85rem; border-radius: 8px;
  font-size: .9rem; color: #94a3b8;
  cursor: pointer; transition: all .15s;
  margin-bottom: .2rem;
  border: none; background: none; width: 100%; text-align: left;
}

.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { color: var(--accent); }

.admin-content { flex: 1; padding: 2rem; overflow-y: auto; }

/* Login panel */
.login-panel {
  max-width: 420px; margin: 3rem auto;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 2.5rem;
  text-align: center;
}

.login-panel h2 { margin-bottom: .5rem; }
.login-panel p  { color: var(--muted); margin-bottom: 1.5rem; font-size: .9rem; }

.input-group { position: relative; margin-bottom: 1rem; }

.input-group input {
  width: 100%; padding: .75rem 1rem;
  border: 2px solid var(--border); border-radius: 8px;
  font-size: .97rem; outline: none;
  transition: border-color .2s;
}

.input-group input:focus { border-color: var(--primary); }
.login-error { color: var(--danger); font-size: .87rem; margin-top: .5rem; }

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem 1.5rem;
}

.stat-label { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); margin-top: .25rem; line-height: 1.1; }
.stat-sub   { font-size: .8rem; color: var(--muted); margin-top: .2rem; }

/* Section panels */
.panel {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem; gap: 1rem;
}

.panel-title { font-size: 1.05rem; font-weight: 700; }

/* Toolbar */
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.btn-sm { padding: .45rem 1rem; font-size: .87rem; }
.btn-outline {
  background: transparent; color: var(--primary);
  border: 2px solid var(--primary); border-radius: 8px;
  font-weight: 600; cursor: pointer; transition: all .15s;
  font-family: 'Segoe UI', system-ui, sans-serif;
}
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

/* Responses table */
.table-wrap { overflow-x: auto; }

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

th {
  text-align: left; padding: .65rem 1rem;
  background: #f8f5ee; color: var(--muted);
  font-size: .78rem; font-weight: 600; text-transform: uppercase;
  border-bottom: 2px solid var(--border);
}

td { padding: .65rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #faf8f2; }

.badge {
  display: inline-block; padding: .2rem .65rem;
  border-radius: 20px; font-size: .75rem; font-weight: 600;
}

.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-green  { background: #dcfce7; color: #166534; }

.expand-btn {
  background: none; border: none; cursor: pointer;
  color: var(--primary); font-size: .8rem; font-weight: 600;
  padding: 0;
}

.row-detail { font-size: .85rem; }
.row-detail dt { color: var(--muted); font-weight: 600; margin-top: .4rem; }
.row-detail dd { margin-left: 0; margin-top: .1rem; }

/* Analysis */
.analysis-box {
  background: #faf8f2; border: 1px solid var(--border);
  border-radius: 8px; padding: 1.25rem 1.5rem;
  font-size: .93rem; line-height: 1.75;
  white-space: pre-wrap;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

.analysis-box h2, .analysis-box h3 { margin-top: 1rem; margin-bottom: .35rem; }
.analysis-box ul { padding-left: 1.25rem; }

.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 3px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle; margin-right: .4rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center; padding: 3rem 1rem; color: var(--muted);
}

.empty-state .icon { font-size: 2.5rem; margin-bottom: .75rem; }

/* Toast */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: #1e293b; color: #fff;
  padding: .75rem 1.25rem; border-radius: 8px;
  font-size: .9rem; box-shadow: 0 4px 20px rgba(0,0,0,.2);
  transition: opacity .3s; z-index: 999;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

.toast.hide { opacity: 0; pointer-events: none; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .hero-wrapper { padding: 1rem 1rem 0; }
  .hero-box { padding: 1.5rem 1.25rem; }
  .intro-wrapper { padding: 0 1rem; }
  .survey-body { padding: 0 1rem 3rem; }
  .section-nav { flex-direction: column; align-items: stretch; }
  .info-badges { grid-template-columns: 1fr; }
  .card-options { grid-template-columns: 1fr; }
  .card-options.cols-3 { grid-template-columns: 1fr; }
  .admin-layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .5rem; }
  .sidebar-brand { padding-bottom: 0; border-bottom: none; }
  .nav-item { padding: .45rem .65rem; }
  .admin-content { padding: 1rem; }
}

@media (max-width: 860px) {
  .card-options:not(.cols-3) { grid-template-columns: 1fr; }
}
