/* ==========================================================================
   Generador Retención · estilos
   Índice:
   1. Variables
   2. Base
   3. Layout (header, main, tarjetas, grillas)
   4. Formularios (campos y botones)
   5. Instalaciones y promociones
   6. Chips
   7. Texto generado y acciones
   8. Página de administración
   9. Utilidades
   10. Responsive
   ========================================================================== */


/* 1. Variables
   -------------------------------------------------------------------------- */
:root {
  --bg: #f4f4f5;
  --card: #fff;
  --ink: #1b2333;
  --mut: #6b7488;
  --pri: #ff0033; /* rojo Verisure */
  --ok: #15803d;
  --bad: #a80024;
  --bd: #d9deea;
}


/* 2. Base
   -------------------------------------------------------------------------- */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font: 15px/1.4 system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

h2 {
  margin: 0 0 10px;
  font-size: 15px;
  color: #2b2f36;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--pri);
}


/* 3. Layout
   -------------------------------------------------------------------------- */
header {
  background: var(--pri);
  color: #fff;
  padding: 14px 20px;
  font-weight: 600;
  font-size: 18px;
}

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 10px;
  padding: 14px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.hint {
  color: var(--mut);
  font-size: 12px;
  margin-top: 4px;
}

.warn {
  color: var(--bad);
  font-size: 12px;
}


/* 4. Formularios
   -------------------------------------------------------------------------- */
label {
  display: block;
  font-size: 12px;
  color: var(--mut);
  margin-bottom: 3px;
}

input,
select,
textarea,
button {
  font: inherit;
  padding: 9px 10px;
  border: 1px solid var(--bd);
  border-radius: 7px;
  width: 100%;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 70px;
  resize: vertical;
}

/* Casilla con texto al lado */
.chk {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 13px;
  color: var(--ink);
  margin: 0;
}

.chk input {
  width: auto;
}

/* Botones */
button {
  cursor: pointer;
  width: auto;
  background: var(--pri);
  color: #fff;
  border: 0;
  font-weight: 600;
}

button.sec {
  background: #fff;
  color: var(--pri);
  border: 1px solid var(--pri);
}

button.del {
  background: #fff;
  color: var(--bad);
  border: 1px solid #e5b4be;
  padding: 6px 10px;
}

.big {
  font-size: 16px;
  padding: 12px 22px;
}

/* Enlace con aspecto de botón */
a.btn {
  display: inline-block;
  padding: 9px 14px;
  border-radius: 7px;
  font-weight: 600;
  text-decoration: none;
  background: var(--pri);
  color: #fff;
}

a.btn.sec {
  background: #fff;
  color: var(--pri);
  border: 1px solid var(--pri);
}


/* 5. Instalaciones y promociones
   -------------------------------------------------------------------------- */
.inst {
  border: 2px solid var(--pri);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  background: #fafafa;
}

.inst-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.inst-head b {
  color: var(--pri);
}

.promo {
  border: 1px solid var(--bd);
  border-radius: 9px;
  padding: 10px;
  margin-bottom: 10px;
  background: #fff;
}

.promo .row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  align-items: end;
}

/* Resultado del cálculo de cada promo */
.calc {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.calc div {
  background: #fafafa;
  border: 1px solid var(--bd);
  border-radius: 7px;
  padding: 6px 8px;
}

.calc small {
  display: block;
  color: var(--mut);
  font-size: 11px;
}

.calc b {
  font-size: 14px;
}


/* 6. Chips
   -------------------------------------------------------------------------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  border: 1px solid var(--bd);
  border-radius: 99px;
  padding: 5px 11px;
  cursor: pointer;
  background: #fff;
  font-size: 13px;
  user-select: none;
}

.chip.on {
  background: var(--pri);
  color: #fff;
  border-color: var(--pri);
}


/* 7. Texto generado y acciones
   -------------------------------------------------------------------------- */
.out {
  white-space: pre-wrap;
  background: #0f172a;
  color: #e6edf7;
  border: 0;
  border-radius: 8px;
  padding: 12px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  min-height: 150px;
  width: 100%;
  resize: vertical;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}


/* 8. Página de administración
   -------------------------------------------------------------------------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar a {
  color: #fff;
  font-size: 14px;
  font-weight: 500;
}

/* Formulario de contraseña del administrador */
.login-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  max-width: 420px;
  margin-top: 10px;
}

.login-row input {
  flex: 1;
  min-width: 200px;
}

/* Contenedor del panel de edición (se muestra solo a administradores) */
.stack {
  display: grid;
  gap: 14px;
}

.pill {
  display: inline-block;
  border-radius: 99px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  background: #ffe5ea;
  color: var(--pri);
}

.pill.ok {
  background: #dcfce7;
  color: var(--ok);
}

.pill.no {
  background: #fde8ec;
  color: var(--bad);
}

.ok-msg {
  color: var(--ok);
  font-size: 13px;
}

/* Tabla de últimos cambios */
.audit {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.audit th,
.audit td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--bd);
  vertical-align: top;
}

.audit th {
  color: var(--mut);
  font-weight: 600;
  font-size: 12px;
}


/* 9. Utilidades
   -------------------------------------------------------------------------- */
.hidden {
  display: none !important;
}


/* 10. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 520px) {
  main {
    padding: 10px;
  }

  .big {
    width: 100%;
  }
}