/* =========================================================================
 * styles.css — Family Vault V3 · estilo iOS, verde menta, claro/oscuro automático
 * ========================================================================= */
:root {
  color-scheme: light dark;
  --bg: #F2F7F5; --card: #FFFFFF; --card2: #F6FAF8;
  --txt: #10231E; --txt2: #52665F;
  --sep: rgba(16, 35, 30, .10);
  --acc: #0A7A63; --acc-fg: #FFFFFF; --acc-soft: #DDF3EC; --acc-txt: #0A7A63;
  --rojo: #C0392B; --rojo-soft: #FBE4E1;
  --ambar: #8F5600; --ambar-soft: #FCEFD3;
  --azul: #1D6FB8; --azul-soft: #E0EEFA;
  --blur: rgba(242, 247, 245, .80);
  --sombra: 0 1px 2px rgba(16, 35, 30, .06), 0 6px 20px rgba(16, 35, 30, .06);
  --r: 16px;
  --fuente: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B1412; --card: #14211E; --card2: #182825;
    --txt: #E8F3EF; --txt2: #9DB3AC;
    --sep: rgba(232, 243, 239, .12);
    --acc: #4ADBB5; --acc-fg: #06231C; --acc-soft: #16342C; --acc-txt: #4ADBB5;
    --rojo: #FF8A7A; --rojo-soft: #3A1C19;
    --ambar: #F2B84B; --ambar-soft: #3A2E12;
    --azul: #7DB8F0; --azul-soft: #162A3D;
    --blur: rgba(11, 20, 18, .80);
    --sombra: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .3);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--txt); font: 16px/1.4 var(--fuente);
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
.hidden { display: none !important; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
a { color: var(--acc-txt); text-decoration: none; }
button { font: inherit; color: inherit; }
img { max-width: 100%; }
h1 { font-size: 32px; line-height: 1.12; letter-spacing: -.02em; font-weight: 700; margin: 4px 0 14px; }
h2 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
.saludo { color: var(--txt2); font-size: 15px; margin: 0; }
:focus-visible { outline: 3px solid var(--acc); outline-offset: 2px; border-radius: 8px; }

/* ---------- Barra superior y pestañas (translúcidas) ---------- */
.barra {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px; background: var(--blur);
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-bottom: .5px solid var(--sep);
}
.marca { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--txt); font-size: 17px; }
.marca svg { color: var(--acc); width: 24px; height: 24px; }
.usuario {
  width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--acc-soft); color: var(--acc-txt);
  font-weight: 700; display: grid; place-items: center; overflow: hidden; padding: 0;
}
.usuario img { width: 100%; height: 100%; object-fit: cover; }
.menu {
  position: absolute; right: 12px; top: calc(env(safe-area-inset-top) + 50px); min-width: 240px; background: var(--card);
  border-radius: 14px; box-shadow: var(--sombra); border: .5px solid var(--sep); padding: 6px; z-index: 30;
}
.menu-nombre { padding: 10px 12px; color: var(--txt2); font-size: 14px; word-break: break-all; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 12px; border-radius: 10px; font-size: 16px; }
.menu button:active { background: var(--acc-soft); }
.menu .peligro { color: var(--rojo); }
.vista { max-width: 640px; margin: 0 auto; padding: 14px 16px calc(110px + env(safe-area-inset-bottom)); outline: none; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 4px); background: var(--blur);
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-top: .5px solid var(--sep);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600;
  color: var(--txt2); padding: 4px 0; min-height: 48px; justify-content: center;
}
.tabs a.activo { color: var(--acc-txt); }
.tabs .tab-escanear span {
  width: 54px; height: 54px; border-radius: 50%; background: var(--acc); color: var(--acc-fg); display: grid; place-items: center;
  margin-top: -22px; box-shadow: 0 6px 16px rgba(10, 122, 99, .35);
}
.tabs .tab-escanear svg { width: 26px; height: 26px; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(900px 500px at 50% -10%, var(--acc-soft), transparent 70%), var(--bg); }
.login-card { width: 100%; max-width: 380px; text-align: center; }
.sello {
  width: 84px; height: 84px; border-radius: 24px; margin: 0 auto 18px; display: grid; place-items: center;
  background: var(--acc); color: var(--acc-fg); box-shadow: 0 10px 28px rgba(10, 122, 99, .30);
}
.sello svg { width: 46px; height: 46px; stroke-width: 1.6; }
.login h1 { font-size: 30px; margin-bottom: 8px; }
.login .sub { color: var(--txt2); margin: 0 0 24px; }
.boton-google { display: flex; justify-content: center; min-height: 44px; }
.error { color: var(--rojo); min-height: 22px; margin: 14px 0 0; font-size: 15px; }
.pie { color: var(--txt2); font-size: 13px; margin-top: 18px; }

/* ---------- Tarjetas y listas agrupadas (inset) ---------- */
.lista { background: var(--card); border-radius: var(--r); box-shadow: var(--sombra); overflow: hidden; }
.doc {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: var(--txt); min-height: 60px;
  position: relative;
}
.doc + .doc::before, .fila + .fila::before { content: ""; position: absolute; left: 62px; right: 0; top: 0; border-top: .5px solid var(--sep); }
.doc:active { background: var(--card2); }
.ico {
  width: 38px; height: 38px; border-radius: 10px; background: var(--acc-soft); color: var(--acc-txt);
  display: grid; place-items: center; flex: none;
}
.txt { flex: 1; min-width: 0; }
.t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m { color: var(--txt2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; flex: none; }
.e-VENCIDO { background: var(--rojo-soft); color: var(--rojo); }
.e-URGENTE { background: var(--ambar-soft); color: var(--ambar); }
.e-PROXIMO { background: var(--azul-soft); color: var(--azul); }
.e-VIGENTE { background: var(--acc-soft); color: var(--acc-txt); }
.vacio { color: var(--txt2); text-align: center; padding: 28px 16px; background: var(--card); border-radius: var(--r); }
.alerta { background: var(--ambar-soft); color: var(--ambar); padding: 12px 14px; border-radius: 14px; font-size: 15px; }
.seccion { display: flex; justify-content: space-between; align-items: baseline; margin: 24px 2px 10px; }
.seccion a { font-size: 15px; font-weight: 600; }
.grupo-titulo { color: var(--txt2); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; margin: 22px 14px 8px; font-weight: 600; }

/* Desplegables */
details.grupo { background: var(--card); border-radius: var(--r); box-shadow: var(--sombra); margin-top: 12px; overflow: hidden; }
details.grupo > summary {
  list-style: none; display: flex; align-items: center; gap: 10px; padding: 14px; cursor: pointer; font-weight: 600; min-height: 52px;
}
details.grupo > summary::-webkit-details-marker { display: none; }
details.grupo > summary .cuenta { margin-left: auto; color: var(--txt2); font-weight: 500; font-size: 15px; }
details.grupo > summary .chev { transition: transform .2s ease; color: var(--txt2); width: 18px; height: 18px; }
details.grupo[open] > summary .chev { transform: rotate(90deg); }
details.grupo > .interior { border-top: .5px solid var(--sep); }
details.grupo .doc:first-child::before { display: none; }

/* Atajos de inicio */
.atajos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.atajo {
  background: var(--card); border-radius: var(--r); box-shadow: var(--sombra); padding: 14px; color: var(--txt);
  display: flex; flex-direction: column; gap: 10px; min-height: 92px; justify-content: space-between;
}
.atajo b { font-size: 16px; }
.atajo small { color: var(--txt2); display: block; font-weight: 400; }
.atajo .ico { width: 34px; height: 34px; }
.atajo.caja .ico { background: var(--acc); color: var(--acc-fg); }

/* Miembros de la familia */
.familia { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.miembro {
  background: var(--card); border-radius: var(--r); box-shadow: var(--sombra); padding: 14px; color: var(--txt);
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
}
.miembro b { margin-top: 6px; font-size: 17px; }
.miembro small { color: var(--txt2); font-size: 14px; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  font-weight: 700; font-size: 19px;
}
.avatar svg { width: 24px; height: 24px; stroke-width: 1.7; }
.detalle-cab { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.detalle-cab h1 { margin: 0; font-size: 26px; }
.detalle-cab .ico { width: 52px; height: 52px; border-radius: 14px; }
.volver { display: inline-flex; align-items: center; gap: 2px; font-size: 17px; font-weight: 500; margin: 0 0 6px -6px; }
.volver svg { width: 22px; height: 22px; stroke-width: 2.2; }

/* Datos clave-valor */
.datos { margin: 0; }
.datos > div { display: flex; justify-content: space-between; gap: 16px; padding: 12px 14px; position: relative; }
.datos > div + div::before { content: ""; position: absolute; left: 14px; right: 0; top: 0; border-top: .5px solid var(--sep); }
.datos dt { color: var(--txt2); flex: none; }
.datos dd { margin: 0; text-align: right; word-break: break-word; font-weight: 500; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px;
  padding: 14px 18px; font-weight: 600; font-size: 16px; cursor: pointer; min-height: 50px; text-align: center;
}
.btn svg { width: 20px; height: 20px; }
.btn-p { background: var(--acc); color: var(--acc-fg); }
.btn-s { background: var(--acc-soft); color: var(--acc-txt); }
.btn-r { background: var(--rojo-soft); color: var(--rojo); }
.btn:active { transform: scale(.98); opacity: .9; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-bloque { display: flex; width: 100%; }
.btn-fila { display: flex; gap: 10px; margin-top: 14px; }
.btn-fila > * { flex: 1; }
.btn-txt { border: 0; background: none; color: var(--acc-txt); font-weight: 500; font-size: 17px; padding: 8px; cursor: pointer; }
.btn-txt.fuerte { font-weight: 700; }

/* ---------- Búsqueda, filtros, formularios ---------- */
.campo-busqueda, .campo input, .campo select, .campo textarea {
  width: 100%; font: inherit; color: var(--txt); background: var(--card); border: 1px solid transparent; border-radius: 12px;
  padding: 13px 14px; min-height: 48px; box-shadow: var(--sombra); -webkit-appearance: none; appearance: none;
}
.campo textarea { min-height: 84px; resize: vertical; }
.campo-busqueda:focus, .campo input:focus, .campo select:focus, .campo textarea:focus { outline: 2px solid var(--acc); border-color: transparent; }
.filtros { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 2px; scrollbar-width: none; }
.filtros::-webkit-scrollbar { display: none; }
.pill { border: 0; background: var(--card); border-radius: 99px; padding: 8px 14px; font-size: 15px; white-space: nowrap; box-shadow: var(--sombra); }
.pill.activo { background: var(--acc); color: var(--acc-fg); font-weight: 600; }
.form .campo { margin-bottom: 12px; }
.form label { display: block; font-size: 13px; color: var(--txt2); margin: 0 0 5px 4px; font-weight: 600; }
.form .dos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.campo.dudoso input, .campo.dudoso select { border-color: var(--ambar); background: var(--ambar-soft); }
.check { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--card); border-radius: 12px; box-shadow: var(--sombra); }
.form .check { color: var(--txt); font-size: 16px; margin: 0; }
.check input { width: 22px; height: 22px; accent-color: var(--acc); }
.nota { padding: 12px 14px; border-radius: 14px; font-size: 15px; }
.nota-verde { background: var(--acc-soft); color: var(--acc-txt); }
.nota-ambar { background: var(--ambar-soft); color: var(--ambar); }
.nota-rojo { background: var(--rojo-soft); color: var(--rojo); }

/* Escaneo */
.paso { font-weight: 700; margin: 20px 2px 10px; font-size: 15px; color: var(--txt2); }
.quienes { display: flex; flex-wrap: wrap; gap: 8px; }
.captura { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pdf-ficha { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: var(--r); padding: 12px; box-shadow: var(--sombra); }
.paginas { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.pagina { position: relative; border-radius: 12px; overflow: hidden; background: var(--card); box-shadow: var(--sombra); }
.pagina img { display: block; width: 100%; aspect-ratio: 3/4; object-fit: cover; }
.pagina .n { position: absolute; left: 6px; top: 6px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.pagina .acc { position: absolute; right: 4px; bottom: 4px; display: flex; gap: 4px; }
.pagina .acc button { width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .6); color: #fff; display: grid; place-items: center; }
.pagina .acc svg { width: 18px; height: 18px; }
.vista-previa { width: 100%; max-height: 260px; object-fit: contain; border-radius: 14px; background: var(--card); box-shadow: var(--sombra); }

/* Editor de esquinas */
.editor { position: fixed; inset: 0; z-index: 60; background: #000; color: #fff; display: flex; flex-direction: column; }
.editor-top { display: flex; justify-content: space-between; align-items: center; padding: calc(env(safe-area-inset-top) + 6px) 10px 6px; }
.editor .btn-txt { color: #7CE8C8; }
.editor-lienzo { flex: 1; position: relative; display: grid; place-items: center; min-height: 0; touch-action: none; }
.editor-lienzo canvas { max-width: 100%; max-height: 100%; }
.editor-marco { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.editor-marco polygon { fill: rgba(74, 219, 181, .16); stroke: #4ADBB5; stroke-width: 2; }
.editor-marco circle { fill: #fff; stroke: #4ADBB5; stroke-width: 3; }
.editor-bottom { padding: 10px 12px calc(env(safe-area-inset-bottom) + 12px); }
.segmento { display: grid; grid-template-columns: repeat(3, 1fr); background: rgba(255, 255, 255, .14); border-radius: 10px; padding: 2px; }
.segmento button { border: 0; background: none; color: #fff; padding: 8px; border-radius: 8px; font-weight: 600; font-size: 14px; }
.segmento button.activo { background: #fff; color: #06231C; }
.editor-acciones { display: flex; justify-content: space-between; margin-top: 6px; }

/* Hoja inferior */
.hoja { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; }
.hoja-panel {
  width: 100%; max-width: 640px; max-height: 92dvh; background: var(--bg); border-radius: 22px 22px 0 0; display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.hoja-panel::before { content: ""; width: 38px; height: 5px; border-radius: 3px; background: var(--sep); margin: 8px auto 0; }
.hoja-top { display: flex; justify-content: space-between; align-items: center; padding: 6px 14px 4px 18px; font-weight: 700; font-size: 17px; }
.hoja-cuerpo { padding: 10px 16px 18px; overflow: auto; }
.hoja-cuerpo iframe { width: 100%; height: 66dvh; border: 0; border-radius: 12px; background: #fff; }
.hoja-cuerpo img { display: block; margin: 0 auto; border-radius: 12px; }

/* Cargando y avisos */
.cargando { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, .35); display: grid; place-items: center; }
.cargando-caja { background: var(--card); padding: 22px 26px; border-radius: 18px; text-align: center; font-weight: 600; box-shadow: var(--sombra); max-width: 80vw; }
.spinner { width: 34px; height: 34px; margin: 0 auto 12px; border-radius: 50%; border: 4px solid var(--acc-soft); border-top-color: var(--acc); animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
.aviso {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 95;
  background: var(--txt); color: var(--bg); padding: 11px 18px; border-radius: 99px; font-size: 15px; max-width: 88vw; text-align: center;
  box-shadow: var(--sombra);
}

/* ---------- Bloqueo biométrico y privacidad ---------- */
.bloqueo {
  position: fixed; inset: 0; z-index: 100; background: radial-gradient(900px 500px at 50% -10%, var(--acc-soft), transparent 70%), var(--bg);
  display: grid; place-items: center; padding: 28px; text-align: center;
}
.bloqueo-caja { max-width: 340px; width: 100%; }
.bloqueo .sello { margin-bottom: 20px; }
.bloqueo h1 { font-size: 26px; }
.bloqueo p { color: var(--txt2); margin: 0 0 22px; }
.bloqueo details { margin-top: 22px; color: var(--txt2); font-size: 14px; text-align: left; }
.bloqueo summary { cursor: pointer; text-align: center; }
body.cubierto #app { filter: blur(28px); pointer-events: none; }

/* ---------- Caja fuerte ---------- */
.caja-cab { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.caja-cab .sello { width: 56px; height: 56px; border-radius: 16px; margin: 0; box-shadow: none; }
.caja-cab .sello svg { width: 30px; height: 30px; }
.caja-cab h1 { margin: 0; }
.caja-aviso { font-size: 14px; color: var(--txt2); margin: 8px 2px 16px; }
.caja-barra { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 12px 0 4px; }
.caja-barra .btn { min-height: 44px; padding: 10px 14px; }
.caja-tiempo { font-size: 13px; color: var(--txt2); }
.error-inline { color: var(--rojo); font-size: 15px; min-height: 20px; margin: 8px 2px 0; }

@media (min-width: 700px) {
  .tabs { left: 50%; right: auto; width: 640px; transform: translateX(-50%); border-radius: 22px 22px 0 0; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
