:root {
  --rosa: #B5495B;
  --rosa-suave: #F3E1E3;
  --crema: #FBF7F4;
  --tinta: #2B2320;
  --tinta-suave: #6B5E58;
  --verde-ok: #3F7A5C;
  --rojo-error: #B23A3A;
  --borde: #E7DAD5;
  --radio: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  overflow-x: hidden;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--crema);
  color: var(--tinta);
}

.oculto { display: none !important; }

/* ---------- LOGIN ---------- */
#pantalla-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, var(--crema) 0%, var(--rosa-suave) 100%);
}

.tarjeta-login {
  background: #fff;
  padding: 40px 36px;
  border-radius: var(--radio);
  box-shadow: 0 10px 30px rgba(43, 35, 32, 0.08);
  width: 320px;
  text-align: center;
  border: 1px solid var(--borde);
}

.tarjeta-login h1 {
  margin: 0 0 4px;
  font-size: 26px;
  letter-spacing: 0.5px;
  color: var(--rosa);
}

.subtitulo {
  margin: 0 0 24px;
  color: var(--tinta-suave);
  font-size: 14px;
}

#form-login input {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 12px;
  border-radius: var(--radio);
  border: 1px solid var(--borde);
  font-size: 16px; /* 16px minimo: evita que Safari haga zoom automatico al enfocar en iPhone */
}

#form-login input:focus {
  outline: 2px solid var(--rosa);
  outline-offset: 1px;
}

.error-texto {
  color: var(--rojo-error);
  font-size: 13px;
  min-height: 18px;
  margin: 4px 0 0;
}

/* ---------- LAYOUT PRINCIPAL ---------- */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--borde);
  padding: 14px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
}

.topbar h1 {
  font-size: 18px;
  margin: 0;
  color: var(--rosa);
}

.topbar-derecha {
  display: flex;
  align-items: center;
  gap: 14px;
}

.badge {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 20px;
  background: #eee;
  color: var(--tinta-suave);
}
.badge.ok { background: #E4F2EA; color: var(--verde-ok); }
.badge.error { background: #F6E3E1; color: var(--rojo-error); }

.contenido {
  max-width: 780px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* ---------- BOTONES ---------- */
.btn-primario {
  background: var(--rosa);
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: var(--radio);
  font-size: 15px;
  cursor: pointer;
  display: inline-block;
}
.btn-primario:hover { background: #9c3d4d; }
.btn-primario:disabled { background: #cbb3b7; cursor: not-allowed; }

.btn-secundario {
  background: #fff;
  border: 1px solid var(--borde);
  padding: 8px 14px;
  border-radius: var(--radio);
  cursor: pointer;
  font-size: 13px;
  color: var(--tinta);
}

.btn-texto {
  background: none;
  border: none;
  color: var(--tinta-suave);
  cursor: pointer;
  font-size: 13px;
  text-decoration: underline;
}

/* ---------- SELECCION DE IMAGENES ---------- */
.zona-seleccion {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.boton-adjuntar { cursor: pointer; }

.contador {
  color: var(--tinta-suave);
  font-size: 14px;
}

.tira-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
}

.tarjeta-preview {
  width: 160px;
  background: #fff;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  overflow: hidden;
  position: relative;
}

.tarjeta-preview img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}

.tarjeta-preview textarea {
  width: 100%;
  border: none;
  border-top: 1px solid var(--borde);
  padding: 8px;
  font-size: 16px; /* evita zoom automatico en iPhone al enfocar */
  resize: none;
  height: 50px;
  font-family: inherit;
}
.tarjeta-preview textarea:focus { outline: none; background: var(--rosa-suave); }

.btn-quitar {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.check-publicada {
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--verde-ok);
  color: #fff;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.check-error {
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--rojo-error);
  color: #fff;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.tarjeta-preview.con-error {
  outline: 2px solid var(--rojo-error);
}

.texto-error-tarjeta {
  color: var(--rojo-error);
  font-size: 11px;
  margin: 4px 0 0;
}

/* ---------- PANEL DE ENVIO ---------- */
.panel-envio {
  border-top: 1px solid var(--borde);
  padding-top: 20px;
}

.destinos {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
}

.check-destino {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

.btn-publicar { width: 100%; font-size: 16px; padding: 14px; }

.progreso { margin-top: 16px; }

.barra-progreso {
  height: 8px;
  background: var(--borde);
  border-radius: 4px;
  overflow: hidden;
}

.barra-relleno {
  height: 100%;
  width: 0%;
  background: var(--rosa);
  transition: width 0.3s ease;
}

#texto-progreso {
  font-size: 13px;
  color: var(--tinta-suave);
  margin: 8px 0 0;
  text-align: center;
}

/* ---------- HISTORIAL ---------- */
.resumen-totales {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.tarjeta-total {
  background: #fff;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 16px 20px;
  flex: 1 1 140px;
  text-align: center;
}

.tarjeta-total .numero {
  font-size: 28px;
  font-weight: 600;
  color: var(--rosa);
}

.tarjeta-total .etiqueta {
  font-size: 13px;
  color: var(--tinta-suave);
}

.tabla-scroll {
  overflow-x: auto;
  margin-bottom: 28px;
  border-radius: var(--radio);
  border: 1px solid var(--borde);
}

.tabla-historial {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
  background: #fff;
}

.tabla-historial th, .tabla-historial td {
  padding: 10px 12px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid var(--borde);
}

.tabla-historial th {
  background: var(--rosa-suave);
  color: var(--tinta);
  font-weight: 600;
}

.pill-ok { color: var(--verde-ok); font-weight: 600; }
.pill-error { color: var(--rojo-error); font-weight: 600; }

@media (max-width: 600px) {
  .topbar { padding: 12px 16px; }
  .topbar h1 { font-size: 16px; }
  .contenido { padding: 20px 14px 50px; }
  .tarjeta-preview { width: calc(50% - 7px); }
  .destinos { flex-direction: column; gap: 10px; }
  .tarjeta-login { width: 100%; max-width: 320px; }
}

@media (max-width: 360px) {
  .tarjeta-preview { width: 100%; }
}
