:root {
  --verde-oscuro: #1b6e2a;
  --verde: #2e9e3f;
  --verde-claro: #8fce5a;
  --fondo: #f4f8f4;
  --borde: #d7e3d7;
  --texto: #1f2a1f;
  --rojo: #c62828;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background: var(--fondo);
  color: var(--texto);
}

/* ---------- Login ---------- */
.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: linear-gradient(160deg, var(--verde-oscuro), var(--verde) 60%, var(--verde-claro));
}
.login-card {
  background: #fff;
  border-radius: 14px;
  padding: 32px;
  width: min(380px, 92vw);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
}
.login-head h1 { margin: 0; font-size: 1.35rem; color: var(--verde-oscuro); }
.login-head p { margin: 4px 0 20px; color: #567; font-size: .9rem; }
.login-card label { display: block; margin: 12px 0 4px; font-weight: 600; font-size: .9rem; }
.login-card input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--borde);
  border-radius: 8px; font-size: 1rem;
}
.login-card button { width: 100%; margin-top: 18px; }

/* ---------- Barra superior ---------- */
.topbar {
  background: linear-gradient(90deg, var(--verde-oscuro), var(--verde));
  color: #fff;
  padding: 14px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.topbar h1 { margin: 0; font-size: 1.2rem; }
.topbar p { margin: 2px 0 0; font-size: .8rem; opacity: .9; font-style: italic; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(340px, 1fr);
  gap: 18px;
  padding: 18px 22px;
  max-width: 1300px;
  margin: 0 auto;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: #fff;
  border: 1px solid var(--borde);
  border-radius: 12px;
  padding: 18px;
}

.step { margin-bottom: 24px; }
.step h2 { font-size: 1.02rem; margin: 0 0 10px; color: var(--verde-oscuro); }
.step-num {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--verde); color: #fff; font-size: .85rem; margin-right: 6px;
}

label { display: block; font-weight: 600; margin: 10px 0 4px; font-size: .92rem; }
.hint { color: #6a7a6a; font-size: .82rem; font-weight: 400; }

input[type="text"], textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--borde); border-radius: 8px;
  font-size: .98rem; font-family: inherit;
}
textarea { resize: vertical; }

.textarea-wrap { position: relative; }
.textarea-wrap textarea { padding-right: 46px; }
.mic-btn {
  position: absolute; top: 8px; right: 8px;
  border: 1px solid var(--borde); background: #fff;
  border-radius: 50%; width: 34px; height: 34px;
  font-size: 1rem; cursor: pointer;
}
.mic-btn.recording {
  background: var(--rojo); border-color: var(--rojo);
  animation: pulse 1.2s infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(198, 40, 40, .25); } }

/* ---------- Botones ---------- */
.btn {
  display: inline-block;
  border: none; border-radius: 8px;
  padding: 10px 16px; font-size: .95rem; font-weight: 600;
  cursor: pointer; margin-top: 8px;
  text-decoration: none; text-align: center;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--verde); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--verde-oscuro); }
.btn-secondary { background: #eef5ee; color: var(--verde-oscuro); border: 1px solid var(--borde); }
.btn-ghost { background: transparent; color: inherit; border: 1px solid rgba(255,255,255,.6); }
.panel .btn-ghost, .template-body .btn-ghost { color: var(--verde-oscuro); border-color: var(--borde); }
.btn-big { font-size: 1.05rem; padding: 12px 22px; }

.error { color: var(--rojo); font-size: .88rem; }

/* ---------- Confirmación ---------- */
.confirm-box {
  display: flex; gap: 10px; align-items: flex-start;
  background: #fff8e1; border: 1px solid #f0d98c;
  padding: 12px; border-radius: 8px; margin-top: 10px;
  font-weight: 600; font-size: .92rem; cursor: pointer;
}
.confirm-box input { margin-top: 3px; transform: scale(1.2); }

/* ---------- Imágenes ---------- */
.previews {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px; margin-top: 10px;
}
.preview-item { position: relative; }
.preview-item img {
  width: 100%; height: 90px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--borde);
}
.preview-item button {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  border: none; background: var(--rojo); color: #fff;
  font-size: .8rem; cursor: pointer; line-height: 1;
}

/* ---------- Plantilla ---------- */
.template-section summary { cursor: pointer; font-weight: 600; color: var(--verde-oscuro); }
.template-body { margin-top: 10px; }
.template-thumb {
  max-width: 160px; border: 1px solid var(--borde); border-radius: 6px; display: block;
}
.row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Vista previa ---------- */
.preview-panel { display: flex; flex-direction: column; min-height: 500px; }
.preview-panel h2 { font-size: 1.02rem; margin: 0 0 10px; color: var(--verde-oscuro); }
.preview-empty {
  flex: 1; display: grid; place-items: center;
  border: 2px dashed var(--borde); border-radius: 10px; color: #8a9a8a;
}
#pdfFrame { flex: 1; width: 100%; min-height: 560px; border: 1px solid var(--borde); border-radius: 8px; }
#downloadLink { margin-top: 10px; }
