/* ============================================================
   CASAMIA · estilo del sitio
   Pensado para el celular primero: dedos, no mouse.
   Paleta: café oscuro + cobre (la misma de las cajas de torta).
   ============================================================ */

:root {
  --cafe:        #2b1d15;
  --cafe-medio:  #4a3527;
  --cafe-suave:  #6b5344;
  --cobre:       #b87333;
  --cobre-claro: #d99b57;
  --crema:       #f7f1e8;
  --papel:       #fffdfa;
  --linea:       #e4d9c9;
  --texto:       #2b1d15;
  --tenue:       #7d6b5c;

  --verde:       #2e7d46;
  --verde-bg:    #e8f5ec;
  --amarillo:    #b8860b;
  --amarillo-bg: #fdf6e3;
  --rojo:        #c0392b;
  --rojo-bg:     #fdeceb;

  --radio: 14px;
  --sombra: 0 2px 10px rgba(43,29,21,.08);
  --alto-toque: 48px;  /* nada clickeable más chico que esto */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--crema);
  color: var(--texto);
  font-size: 16px;           /* menos de 16 hace que iOS haga zoom al escribir */
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Estructura ---------- */
.barra {
  position: sticky; top: 0; z-index: 50;
  background: var(--cafe); color: var(--crema);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.barra h1 { font-size: 17px; margin: 0; font-weight: 600; flex: 1; }
.barra .sub { font-size: 12px; opacity: .7; font-weight: 400; display: block; }
.barra a, .barra button.icono {
  color: var(--crema); text-decoration: none; background: none; border: 0;
  font-size: 22px; padding: 4px 8px; cursor: pointer;
}

.contenido { max-width: 760px; margin: 0 auto; padding: 16px 16px 96px; }

.tarjeta {
  background: var(--papel); border: 1px solid var(--linea);
  border-radius: var(--radio); padding: 16px; margin-bottom: 14px;
  box-shadow: var(--sombra);
}
.tarjeta h2 { margin: 0 0 4px; font-size: 17px; }
.tarjeta h3 { margin: 0 0 10px; font-size: 15px; color: var(--cafe-medio); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--alto-toque); padding: 12px 20px;
  border: 0; border-radius: var(--radio);
  background: var(--cobre); color: #fff;
  font-size: 16px; font-weight: 600; font-family: inherit;
  cursor: pointer; text-decoration: none; transition: filter .15s;
}
.btn:active { filter: brightness(.9); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ancho { width: 100%; }
.btn.suave { background: var(--papel); color: var(--cafe); border: 1.5px solid var(--linea); }
.btn.oscuro { background: var(--cafe); }
.btn.peligro { background: var(--rojo); }

/* ---------- Formularios ---------- */
label.campo { display: block; margin-bottom: 14px; }
label.campo span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password],
input[type=number], input[type=date], select, textarea {
  width: 100%; min-height: var(--alto-toque);
  padding: 12px 14px; font-size: 16px; font-family: inherit;
  border: 1.5px solid var(--linea); border-radius: 10px;
  background: var(--papel); color: var(--texto);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--cobre-claro); outline-offset: 1px; border-color: var(--cobre);
}
textarea { min-height: 88px; resize: vertical; }

/* ---------- Semáforo ---------- */
.semaforo { display: inline-block; padding: 4px 12px; border-radius: 999px;
            font-size: 13px; font-weight: 700; letter-spacing: .3px; }
.semaforo.VERDE    { background: var(--verde-bg);    color: var(--verde); }
.semaforo.AMARILLO { background: var(--amarillo-bg); color: var(--amarillo); }
.semaforo.ROJO     { background: var(--rojo-bg);     color: var(--rojo); }
.semaforo.SINDATO  { background: #eee;               color: var(--tenue); }

/* ---------- Ítems de la pauta ---------- */
.seccion { margin-bottom: 8px; }
.seccion > summary {
  list-style: none; cursor: pointer; padding: 14px 16px;
  background: var(--papel); border: 1px solid var(--linea);
  border-radius: var(--radio); font-weight: 600;
  display: flex; align-items: center; gap: 10px;
}
.seccion > summary::-webkit-details-marker { display: none; }
.seccion[open] > summary { border-radius: var(--radio) var(--radio) 0 0; border-bottom: 0; }
.seccion .cuerpo {
  background: var(--papel); border: 1px solid var(--linea); border-top: 0;
  border-radius: 0 0 var(--radio) var(--radio); padding: 4px 16px 16px;
}
.seccion .avance { font-size: 13px; color: var(--tenue); font-weight: 500; margin-left: auto; }

.item { padding: 12px 0; border-bottom: 1px solid var(--linea); }
.item:last-child { border-bottom: 0; }
.item .txt { font-size: 15px; margin-bottom: 10px; }
.item .txt .critico {
  display: inline-block; background: var(--rojo-bg); color: var(--rojo);
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  margin-left: 6px; vertical-align: middle;
}
.item .txt .pide-foto {
  display: inline-block; background: var(--amarillo-bg); color: var(--amarillo);
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  margin-left: 6px; vertical-align: middle;
}
.item.falla { background: var(--rojo-bg); margin: 0 -16px; padding: 12px 16px; }

/* Botonera sí / no / no aplica */
.opciones { display: flex; gap: 8px; }
.opciones button {
  flex: 1; min-height: var(--alto-toque);
  border: 1.5px solid var(--linea); background: var(--papel);
  border-radius: 10px; font-size: 15px; font-weight: 600;
  font-family: inherit; color: var(--tenue); cursor: pointer;
}
.opciones button[aria-pressed="true"][data-v="si"] { background: var(--verde); border-color: var(--verde); color: #fff; }
.opciones button[aria-pressed="true"][data-v="no"] { background: var(--rojo);  border-color: var(--rojo);  color: #fff; }
.opciones button[aria-pressed="true"][data-v="na"] { background: var(--cafe-suave); border-color: var(--cafe-suave); color: #fff; }

/* ---------- Fotos ---------- */
.fotos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.foto {
  position: relative; width: 76px; height: 76px; border-radius: 10px;
  overflow: hidden; border: 1.5px solid var(--linea); background: var(--crema);
}
.foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto .quitar {
  position: absolute; top: 2px; right: 2px; width: 22px; height: 22px;
  border: 0; border-radius: 50%; background: rgba(0,0,0,.65); color: #fff;
  font-size: 14px; line-height: 1; cursor: pointer; padding: 0;
}
.foto.subiendo::after {
  content: ''; position: absolute; inset: 0; background: rgba(255,255,255,.7);
  background-image: linear-gradient(90deg, transparent, rgba(184,115,51,.4), transparent);
  animation: barrido 1.1s infinite;
}
@keyframes barrido { from { background-position: -120px 0 } to { background-position: 120px 0 } }

.agregar-foto {
  width: 76px; height: 76px; border: 1.5px dashed var(--cobre);
  border-radius: 10px; background: var(--papel); color: var(--cobre);
  font-size: 22px; cursor: pointer; display: flex; align-items: center;
  justify-content: center; flex-direction: column; gap: 2px; font-family: inherit;
}
.agregar-foto small { font-size: 10px; font-weight: 600; }
.agregar-foto.obligatoria { border-color: var(--rojo); color: var(--rojo); }

/* ---------- Barra fija de abajo ---------- */
.pie-fijo {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: var(--papel); border-top: 1px solid var(--linea);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 -2px 12px rgba(43,29,21,.08);
}
.pie-fijo .resumen { flex: 1; font-size: 13px; line-height: 1.35; }
.pie-fijo .resumen b { font-size: 15px; }

/* ---------- Listas y tablas ---------- */
.lista-enlaces { display: grid; gap: 10px; }
.enlace-grande {
  display: flex; align-items: center; gap: 14px; text-decoration: none;
  background: var(--papel); border: 1px solid var(--linea);
  border-radius: var(--radio); padding: 16px; color: var(--texto);
  box-shadow: var(--sombra);
}
.enlace-grande .emoji { font-size: 28px; }
.enlace-grande .txt { flex: 1; }
.enlace-grande .txt b { display: block; font-size: 16px; }
.enlace-grande .txt small { color: var(--tenue); font-size: 13px; }
.enlace-grande .flecha { color: var(--cobre); font-size: 20px; }

.tabla { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabla th, .tabla td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--linea); }
.tabla th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--tenue); }
.tabla td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tabla-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- Avisos ---------- */
.aviso { padding: 12px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; }
.aviso.error { background: var(--rojo-bg);     color: var(--rojo);     border: 1px solid #f0c6c1; }
.aviso.ok    { background: var(--verde-bg);    color: var(--verde);    border: 1px solid #bfe3ca; }
.aviso.ojo   { background: var(--amarillo-bg); color: var(--amarillo); border: 1px solid #ecdcae; }

.tenue { color: var(--tenue); font-size: 14px; }
.centrado { text-align: center; }
.cargando { text-align: center; padding: 40px 16px; color: var(--tenue); }

/* ---------- Login ---------- */
.login-caja { max-width: 380px; margin: 8vh auto; padding: 0 20px; }
.login-caja .marca { text-align: center; margin-bottom: 24px; }
.login-caja .marca .nombre {
  font-size: 30px; font-weight: 700; letter-spacing: 2px; color: var(--cafe);
}
.login-caja .marca .bajada { color: var(--tenue); font-size: 14px; }

/* ---------- Impresión (para el papel de la SEREMI) ---------- */
@media print {
  .barra, .pie-fijo, .btn, .agregar-foto, .quitar { display: none !important; }
  body { background: #fff; }
  .tarjeta, .seccion .cuerpo, .seccion > summary { box-shadow: none; break-inside: avoid; }
  .seccion .cuerpo { display: block !important; }
}
