:root {
  --azul: #1e3a8a;
  --azul-claro: #3b82f6;
  --gris-bg: #f4f6f9;
  --gris-borde: #d9dee5;
  --texto: #1f2937;
  --verde: #16a34a;
  --rojo: #dc2626;
  --radio: 8px;
}

* { box-sizing: border-box; }

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

a { color: var(--azul-claro); }

.topbar {
  background: var(--azul);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar .marca { font-weight: 700; font-size: 18px; }
.topbar nav a { color: #dbeafe; text-decoration: none; margin-left: 18px; font-size: 14px; }
.topbar nav a:hover { color: #fff; text-decoration: underline; }

.contenedor {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.tarjeta {
  background: #fff;
  border: 1px solid var(--gris-borde);
  border-radius: var(--radio);
  padding: 20px;
  margin-bottom: 20px;
}

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.subtitulo { color: #6b7280; margin: 0 0 20px; font-size: 14px; }

.fila { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.fila-entre { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

label { display: block; font-size: 13px; font-weight: 600; margin: 10px 0 4px; color: #374151; }

input[type=text], input[type=date], input[type=password], input[type=search], select, textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--gris-borde);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

input[type=file] { font-size: 13px; }

input[type=color] {
  width: 100%;
  height: 38px;
  padding: 3px;
  border: 1px solid var(--gris-borde);
  border-radius: 6px;
  cursor: pointer;
  background: #fff;
}

.paleta-colores { display: flex; flex-wrap: wrap; gap: 7px; margin: 6px 0 4px; }
.paleta-colores .swatch {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--gris-borde);
  cursor: pointer;
  padding: 0;
}
.paleta-colores .swatch:hover { box-shadow: 0 0 0 2px #93c5fd; }
.paleta-colores .swatch.activo { box-shadow: 0 0 0 2px var(--azul-claro); }

.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 6px;
  border: 1px solid var(--azul);
  background: var(--azul);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #16306e; }
.btn.secundario { background: #fff; color: var(--azul); }
.btn.secundario:hover { background: #eef2ff; }
.btn.peligro { background: #fff; color: var(--rojo); border-color: var(--rojo); }
.btn.peligro:hover { background: #fef2f2; }
.btn.chico { padding: 5px 10px; font-size: 12px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid #eef1f5; }
th { color: #6b7280; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: #fafbfc; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.vigente { background: #dcfce7; color: #166534; }
.badge.vencido { background: #fee2e2; color: #991b1b; }
.badge.inactivo { background: #f1f5f9; color: #64748b; }

.alerta { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.alerta.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alerta.ok { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--azul);
}
.login-caja {
  background: #fff;
  padding: 32px;
  border-radius: 10px;
  width: 100%;
  max-width: 360px;
}

.miniatura {
  width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: #e2e8f0;
}

.paginacion { display: flex; gap: 6px; margin-top: 16px; }
.paginacion a, .paginacion span {
  padding: 6px 11px; border: 1px solid var(--gris-borde); border-radius: 6px; text-decoration: none; color: var(--texto); font-size: 13px;
}
.paginacion .activa { background: var(--azul); color: #fff; border-color: var(--azul); }

.verif-card { max-width: 420px; margin: 40px auto; }
.verif-card .foto-grande { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; background: #e2e8f0; display: block; margin: 0 auto 16px; }
.verif-card h1 { text-align: center; }
.verif-datos { margin-top: 20px; }
.verif-datos .dato { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #eef1f5; }
.verif-datos .dato .etiqueta { color: #6b7280; font-size: 13px; }
.verif-datos .dato .valor { font-weight: 600; }

/* --- Editor de plantilla --- */
.editor-wrap { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.editor-lienzo-cont { position: relative; overflow: auto; border: 1px dashed var(--gris-borde); background: repeating-conic-gradient(#f3f4f6 0% 25%, #ffffff 0% 50%) 50% / 20px 20px; }
#lienzo { position: relative; }
#lienzo img.fondo { display: block; max-width: 100%; user-select: none; pointer-events: none; }
.campo-box {
  position: absolute;
  border: 2px solid var(--azul-claro);
  background: rgba(59,130,246,0.12);
  cursor: move;
  font-size: 12px;
  color: #1e3a8a;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  padding: 2px;
}
.campo-box.seleccionado { border-color: #f59e0b; background: rgba(245,158,11,0.15); z-index: 5; }
.campo-box .resize-handle {
  position: absolute; right: -6px; bottom: -6px; width: 12px; height: 12px;
  background: var(--azul-claro); border-radius: 50%; cursor: nwse-resize; border: 2px solid #fff;
}
.panel-lateral { width: 280px; flex-shrink: 0; }

/* --- Modal de vista previa --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.modal-contenido {
  background: #fff;
  border-radius: 10px;
  padding: 22px;
  max-width: 92vw;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}
.lista-campos { list-style: none; padding: 0; margin: 0; }
.lista-campos li {
  padding: 8px 10px; border: 1px solid var(--gris-borde); border-radius: 6px; margin-bottom: 6px;
  font-size: 13px; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
}
.lista-campos li.activa { border-color: var(--azul-claro); background: #eff6ff; }
.propiedades-campo { margin-top: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.ayuda { font-size: 12px; color: #6b7280; margin-top: 6px; }
