:root {
  --bg: #f8faf5;
  --surface: #ffffff;
  --surface-low: #f2f4ef;
  --ink: #191c1a;
  --muted: #42493e;
  --outline: #72796e;
  --outline-soft: #c2c9bb;
  --primary: #154212;
  --primary-mid: #2d5a27;
  --primary-soft: #bcf0ae;
  --secondary: #77574d;
  --secondary-soft: #fed3c7;
  --accent: #415700;
  --accent-soft: #cdef79;
  --error: #ba1a1a;
  --ok: #2d5a27;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(25, 28, 26, 0.08);
  --font: "Work Sans", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 10% -10%, #e8f5e1 0%, transparent 55%),
    linear-gradient(180deg, #f8faf5 0%, #eef2ea 100%);
  color: var(--ink);
  font-family: var(--font-body);
}
a { color: var(--primary-mid); text-decoration: none; }
button, input, select, textarea { font: inherit; }

.app-shell {
  max-width: 920px;
  margin: 0 auto;
  padding: 1rem 1rem 5.5rem;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.brand {
  font-family: var(--font);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--primary);
}
.card {
  background: var(--surface);
  border: 1px solid var(--outline-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
h1, h2, h3 {
  font-family: var(--font);
  margin: 0 0 0.5rem;
  color: var(--primary);
}
.muted { color: var(--muted); }
.progress {
  height: 8px;
  background: var(--surface-low);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.75rem 0 1.25rem;
}
.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--primary-mid), var(--accent));
}
.field { margin-bottom: 1rem; }
.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.95rem;
}
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--outline-soft);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  background: #fff;
}
.field textarea { min-height: 110px; resize: vertical; }
.scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
}
.scale button {
  border: 1px solid var(--outline-soft);
  background: var(--surface-low);
  border-radius: 10px;
  padding: 0.7rem 0;
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.scale button:hover {
  border-color: var(--primary-mid);
  background: #eef8ea;
}
.scale button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Filas dimensión (estilo prototipo: texto + escala) */
.dim-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  margin-bottom: 0.65rem;
  background: var(--surface-low);
  border: 1px solid var(--outline-soft);
  border-radius: 12px;
}
.dim-row:last-child { margin-bottom: 0; }
.dim-title {
  font-family: var(--font);
  font-weight: 700;
  color: var(--ink);
  font-size: 0.98rem;
  margin-bottom: 0.2rem;
}
.dim-desc {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}
.scale-dim {
  flex: 0 0 auto;
  min-width: min(100%, 220px);
  max-width: 260px;
}
.scale-dim button {
  min-height: 2.5rem;
  border-radius: 8px;
  padding: 0.45rem 0;
}
@media (min-width: 720px) {
  .dim-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
  }
  .dim-copy { flex: 1; min-width: 0; }
}
.radio-list { display: grid; gap: 0.5rem; }
.radio-item {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--outline-soft);
  border-radius: 10px;
  background: var(--surface-low);
  cursor: pointer;
}
.radio-item.selected {
  border-color: var(--primary-mid);
  background: #eef8ea;
}

/* Botones de opción (Mayor freno, etc.) */
.choice-list {
  display: grid;
  gap: 0.55rem;
}
.choice-list-grid {
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .choice-list-grid {
    grid-template-columns: 1fr 1fr;
  }
}
.q-card {
  padding: 0.95rem 1rem;
  background: var(--surface-low);
  border: 1px solid var(--outline-soft);
  border-radius: 12px;
}
.q-card label {
  margin-bottom: 0.75rem;
}
.choice-btn {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin: 0;
  padding: 0.95rem 1.1rem;
  border: 2px solid var(--outline-soft);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.choice-btn input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}
.choice-mark {
  flex: 0 0 1.35rem;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  border: 2px solid var(--outline);
  background: #fff;
  position: relative;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.choice-mark::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 999px;
  background: var(--primary);
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.choice-label {
  font-family: var(--font);
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink);
  line-height: 1.25;
  text-align: left;
}
.choice-btn:hover {
  border-color: var(--primary-mid);
  background: #f4faf1;
}
.choice-btn:active {
  transform: scale(0.985);
}
.choice-btn.selected,
.choice-btn:has(input:checked) {
  border-color: var(--primary);
  background: linear-gradient(180deg, #e8f5e1 0%, #f3f9f0 100%);
  box-shadow: 0 0 0 3px rgba(45, 90, 39, 0.18);
}
.choice-btn.selected .choice-mark,
.choice-btn:has(input:checked) .choice-mark {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.choice-btn.selected .choice-mark::after,
.choice-btn:has(input:checked) .choice-mark::after {
  opacity: 1;
  transform: scale(1);
}
.choice-btn:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}
.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  font-weight: 600;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--secondary-soft); color: var(--secondary); }
.btn-ghost { background: transparent; border: 1px solid var(--outline-soft); }
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.96);
  border-top: 1px solid var(--outline-soft);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 0.5rem;
  backdrop-filter: blur(8px);
}
.bottom-nav a {
  text-align: center;
  padding: 0.55rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}
.bottom-nav a.active { color: var(--primary); }
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--outline-soft);
  padding: 2rem 1.5rem;
  text-align: center;
}
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
}
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td {
  text-align: left;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--outline-soft);
}
.alert {
  padding: 0.85rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
}
.alert-error { background: #ffdad6; color: #93000a; }
.alert-ok { background: #e8f5e1; color: var(--primary); }
.step-panel { display: none; }
.step-panel.active { display: block; }

/* Encuesta: una sola pantalla (scroll) */
.encuesta-page { max-width: 720px; }
.encuesta-hero h1 {
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  margin-bottom: 0.35rem;
}
.encuesta-hint {
  margin-top: 0.85rem;
  padding: 0.85rem 1rem;
  background: var(--surface-low);
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
  text-align: left;
}
.save-status {
  min-height: 1.25rem;
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
}
.section-block {
  background: var(--surface);
  border: 1px solid var(--outline-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  overflow: hidden;
}
.section-head {
  background: var(--primary);
  color: #fff;
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  padding: 0.75rem 1.1rem;
}
.section-body {
  padding: 1.1rem 1.15rem 1.2rem;
}
.encuesta-actions {
  position: sticky;
  bottom: 4.5rem;
  z-index: 5;
  background: rgba(248, 250, 245, 0.94);
  backdrop-filter: blur(8px);
  padding: 0.75rem 0 0.5rem;
  margin-top: 0.5rem;
  justify-content: stretch;
}
.encuesta-actions .btn {
  flex: 1;
  text-align: center;
}
@media (min-width: 900px) {
  .encuesta-actions { bottom: 0.5rem; }
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}
.stat {
  background: var(--surface-low);
  border-radius: 10px;
  padding: 0.85rem;
}
.stat strong { display: block; font-size: 1.4rem; color: var(--primary); }
@media (min-width: 900px) {
  .bottom-nav { display: none; }
  .app-shell { padding-bottom: 2rem; }
}

/* Modal in-app (sustituye alert nativo) */
.dlg-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(25, 28, 26, 0.45);
  backdrop-filter: blur(4px);
  animation: dlg-fade 0.18s ease-out;
}
.dlg-card {
  width: min(400px, 100%);
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--outline-soft);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.35rem 1.25rem;
  text-align: center;
  animation: dlg-pop 0.2s ease-out;
}
.dlg-ok .dlg-title { color: var(--primary); }
.dlg-error .dlg-title { color: var(--error); }
.dlg-title {
  font-family: var(--font);
  font-size: 1.2rem;
  margin: 0 0 0.5rem;
}
.dlg-msg {
  margin: 0 0 1.25rem;
  color: var(--muted);
  line-height: 1.45;
  white-space: pre-wrap;
}
.dlg-actions { display: flex; justify-content: center; }
@keyframes dlg-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes dlg-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
