/* ==========================================================
   Kasa Tasks — hoja de estilos única.
   Mobile-first. Verde de la finca (--verde) sobre fondo claro.
   ========================================================== */

:root {
  color-scheme: light;
  --verde: #2f6f4f;
  --verde-o: #245a40;
  --verde-cl: #eaf2ed;
  --bg: #f4f6f4;
  --card: #fff;
  --linea: #e2e8e3;
  --tinta: #1f2a24;
  --gris: #6b7a72;
  --rojo: #b3261e;
  --ambar: #7a5310;
  --ambar-bg: #fff4e5;
  --sombra: 0 1px 2px rgba(31, 42, 36, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--tinta); font-family: var(--font);
  font-size: 16px; line-height: 1.45;
}
.oculto { display: none !important; }

/* ---------- Elementos base ---------- */
.btn {
  background: var(--verde); color: #fff; border: 0; border-radius: 11px;
  padding: 12px 20px; font-size: 16px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.btn:hover { background: var(--verde-o); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.fantasma { background: #fff; color: var(--verde); border: 1px solid var(--linea); }
.btn.fantasma:hover { background: var(--verde-cl); }
.btn.peligro { background: var(--rojo); }
.btn.sm { padding: 8px 13px; font-size: 14px; border-radius: 9px; }
.btn.bloque { width: 100%; }

.enlace {
  background: none; border: 0; color: var(--verde); font-size: 13.5px;
  font-family: inherit; cursor: pointer; padding: 3px 0; text-decoration: underline;
}
.enlace.borrar { color: var(--rojo); }

:focus-visible { outline: 2px solid var(--verde); outline-offset: 2px; }

.campo { margin-bottom: 13px; }
.campo label { display: block; font-size: 13px; color: var(--gris); margin-bottom: 5px; font-weight: 500; }
.campo input, .campo select, .campo textarea {
  width: 100%; padding: 11px; border: 1px solid var(--linea); border-radius: 10px;
  font-size: 16px; font-family: inherit; background: #fff; color: var(--tinta);
}
.campo textarea { min-height: 62px; resize: vertical; }
.campo .pista { font-size: 12px; color: var(--gris); margin-top: 5px; }

.error { color: var(--rojo); font-size: 14px; min-height: 19px; }
.aviso {
  background: var(--ambar-bg); border: 1px solid #f0c98a; color: var(--ambar);
  border-radius: 11px; padding: 11px 13px; margin-bottom: 14px; font-size: 14px;
}
.aviso.ok { background: var(--verde-cl); border-color: #bcd8c7; color: var(--verde-o); }

/* ---------- Acceso ---------- */
.puerta {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px; text-align: center; gap: 14px;
}
.puerta h1 { margin: 0; font-size: 27px; color: var(--verde); }
.puerta p { margin: 0; color: var(--gris); max-width: 340px; }
.puerta-caja {
  background: #fff; border: 1px solid var(--linea); border-radius: 16px;
  padding: 20px; width: 100%; max-width: 380px; text-align: left; box-shadow: var(--sombra);
}
.pestanas-acceso { display: flex; gap: 8px; margin-bottom: 18px; }
.pestanas-acceso button {
  flex: 1; background: var(--bg); border: 1px solid var(--linea); border-radius: 10px;
  padding: 9px; font-size: 14px; font-family: inherit; color: var(--gris); cursor: pointer;
}
.pestanas-acceso button.on { background: var(--verde); color: #fff; border-color: var(--verde); font-weight: 600; }
.codigo-in { font-size: 26px; letter-spacing: 7px; text-align: center; }

/* ---------- Cabecera ---------- */
header.top {
  position: sticky; top: 0; z-index: 5; background: var(--verde); color: #fff;
  padding: 11px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
header.top b { font-size: 17px; display: block; }
header.top .quien { font-size: 12.5px; opacity: .92; }
header.top button {
  background: rgba(255, 255, 255, .18); color: #fff; border: 0; border-radius: 8px;
  padding: 7px 11px; font-size: 13px; font-family: inherit; cursor: pointer; flex: none;
}
header.top button:hover { background: rgba(255, 255, 255, .3); }

.marco { max-width: 720px; margin: 0 auto; padding: 14px 14px 90px; }

/* ---------- Cabecera de sección ---------- */
.seccion-h { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 2px 0 12px; }
.seccion-h h2 { font-size: 19px; margin: 0; }
.chapa { background: #fff; border: 1px solid var(--linea); border-radius: 10px; padding: 6px 12px; font-size: 14px; white-space: nowrap; }
.chapa b { color: var(--verde); }

/* ---------- Filtros ---------- */
.filtros { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 9px; margin-bottom: 6px; }
.filtros button {
  background: #fff; border: 1px solid var(--linea); border-radius: 999px; padding: 6px 13px;
  font-size: 13px; font-family: inherit; white-space: nowrap; cursor: pointer; color: var(--gris);
}
.filtros button.on { background: var(--verde); color: #fff; border-color: var(--verde); font-weight: 600; }

/* ---------- Tarjetas de lista ---------- */
.ficha {
  background: var(--card); border: 1px solid var(--linea); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 10px; display: flex; gap: 12px;
  align-items: flex-start; box-shadow: var(--sombra);
}
.ficha .marca { width: 23px; height: 23px; margin-top: 2px; accent-color: var(--verde); flex: none; cursor: pointer; }
.ficha .cuerpo { flex: 1; min-width: 0; }
.ficha .titulo { font-weight: 600; overflow-wrap: anywhere; }
.ficha.lista .titulo { text-decoration: line-through; color: #9aa8a0; }
.ficha .datos {
  font-size: 12.5px; color: var(--gris); margin-top: 4px;
  display: flex; flex-wrap: wrap; gap: 5px 10px; align-items: center;
}
.ficha .botones { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.vencida { color: var(--rojo); font-weight: 600; }

.pildora { font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 500; }
.pildora.piscina { background: #d9ecf7; color: #1d5b7a; }
.pildora.jardin { background: #ddf0db; color: #2f6f3a; }
.pildora.casa { background: #f3e6cf; color: #87601e; }
.pildora.limpieza { background: #ece0f5; color: #6a3d8c; }
.pildora.compra { background: #f7e0e6; color: #9c3a56; }
.pildora.otros { background: #e6eaef; color: #4a5a6a; }
.pildora.plan { background: var(--verde-cl); color: var(--verde-o); }

.recibo { margin-top: 9px; }
.recibo img { max-width: 130px; border-radius: 8px; border: 1px solid var(--linea); display: block; }

.vacio { text-align: center; color: var(--gris); padding: 34px 10px; }
.cargando { text-align: center; color: var(--gris); padding: 34px 10px; }

/* ---------- Botón flotante y navegación ---------- */
.flotante {
  position: fixed; right: 18px; bottom: 84px; z-index: 6; width: 56px; height: 56px;
  border-radius: 50%; background: var(--verde); color: #fff; border: 0; font-size: 28px;
  line-height: 1; box-shadow: 0 4px 14px rgba(0, 0, 0, .22); cursor: pointer;
}
.flotante:hover { background: var(--verde-o); }

nav.abajo {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: #fff;
  border-top: 1px solid var(--linea); display: flex; padding-bottom: env(safe-area-inset-bottom);
}
nav.abajo button {
  flex: 1; border: 0; background: none; padding: 9px 4px 11px; font-size: 11px;
  font-family: inherit; color: var(--gris); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
nav.abajo button .ic { font-size: 19px; line-height: 1; }
nav.abajo button.on { color: var(--verde); font-weight: 700; }

/* ---------- Menú "Más" ---------- */
.menu-lista { display: flex; flex-direction: column; gap: 10px; }
.menu-lista button {
  background: #fff; border: 1px solid var(--linea); border-radius: 12px; padding: 15px;
  font-size: 16px; font-family: inherit; text-align: left; cursor: pointer; color: var(--tinta);
  display: flex; align-items: center; gap: 12px; box-shadow: var(--sombra);
}
.menu-lista button:hover { border-color: var(--verde); }
.menu-lista button .ic { font-size: 20px; }
.menu-lista button .sub { display: block; font-size: 12.5px; color: var(--gris); font-weight: 400; }

/* ---------- Modal ---------- */
.modal-fondo {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .42); z-index: 20;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; width: 100%; max-width: 520px; border-radius: 16px 16px 0 0;
  padding: 18px; max-height: 92vh; overflow: auto;
}
@media (min-width: 560px) {
  .modal-fondo { align-items: center; }
  .modal { border-radius: 16px; }
}
.modal h3 { margin: 0 0 15px; font-size: 18px; }
.modal-botones { display: flex; gap: 10px; margin-top: 8px; }
.modal-botones .btn { flex: 1; }

.giro {
  display: inline-block; width: 15px; height: 15px; border: 2px solid #fff;
  border-top-color: transparent; border-radius: 50%; animation: giro .7s linear infinite; vertical-align: -2px;
}
@keyframes giro { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .giro { animation: none; } }

/* ---------- Aviso flotante ---------- */
.toast {
  position: fixed; left: 50%; bottom: 96px; z-index: 30; transform: translateX(-50%);
  background: var(--tinta); color: #fff; padding: 12px 18px; border-radius: 11px;
  font-size: 14px; line-height: 1.4; max-width: min(92%, 460px); text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .28); animation: sube .18s ease-out;
}
.toast.mal { background: var(--rojo); }
@keyframes sube { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ---------- Código grande (personas) ---------- */
.codigo-grande {
  font-size: 34px; font-weight: 700; letter-spacing: 6px; color: var(--verde);
  text-align: center; background: var(--verde-cl); border-radius: 12px; padding: 18px; margin: 4px 0 14px;
}

/* ---------- Días de la semana (plan) ---------- */
.dias { display: flex; gap: 6px; flex-wrap: wrap; }
.dias label {
  display: flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  border: 1px solid var(--linea); border-radius: 9px; cursor: pointer; font-size: 13px;
  background: #fff; user-select: none;
}
.dias input { position: absolute; opacity: 0; width: 0; height: 0; }
.dias input:checked + span { color: #fff; }
.dias label:has(input:checked) { background: var(--verde); border-color: var(--verde); color: #fff; font-weight: 600; }
.dias label:has(input:focus-visible) { outline: 2px solid var(--verde); outline-offset: 2px; }

/* ---------- Liquidación ---------- */
.saldo { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.saldo .cifra { font-size: 21px; font-weight: 700; color: var(--verde); white-space: nowrap; }
.desglose { margin-top: 9px; padding-top: 9px; border-top: 1px dashed var(--linea); font-size: 13px; color: var(--gris); }
.desglose div { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }

/* ---------- Tabla sencilla (actividad) ---------- */
.registro { font-size: 13px; }
.registro div { padding: 8px 0; border-bottom: 1px solid var(--linea); display: flex; justify-content: space-between; gap: 10px; }
.registro .cuando { color: var(--gris); white-space: nowrap; font-size: 12px; }
