/* Panel del mayordomo · tokens del prototipo (docs/diseno/prototipo, colores()) */
:root {
  --bg: #F6EFE4; --sf: #FFFBF5; --sf2: #EFE5D5; --bd: #E3D5C1; --col: #EDE3D2;
  --tx: #2A2019; --tx2: #67554A; --link: #A8441F;
  --ac: #B14E2B; --ac-tx: #FFFFFF; --ac-soft: #F6DDD0; --ac-soft-tx: #87341A;
  --ok: #5A6B2B; --ok-soft: #E3E8CC; --ok-tx: #3D4A18;
  --am: #F5E2BC; --am-tx: #774B00; --rj: #F7D8D0; --rj-tx: #9A2E1F;
  --sh: 0 1px 2px rgba(70,45,20,.05), 0 4px 14px rgba(70,45,20,.06);
  --scrim: rgba(40,25,15,.4); --toast: #2A2019; --toast-tx: #FBF4EA; --toast-ac: #F4A983;
  --r: 16px;
  --top: env(safe-area-inset-top, 0px); --bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1C1511; --sf: #2A2119; --sf2: #382C23; --bd: #46382D; --col: #231B15;
    --tx: #F4EADD; --tx2: #C4B29E; --link: #F09A74;
    --ac: #E57F57; --ac-tx: #1F130C; --ac-soft: #4A2A1C; --ac-soft-tx: #F7C6AF;
    --ok: #B3C476; --ok-soft: #343A1F; --ok-tx: #D7E4A6;
    --am: #45341A; --am-tx: #F0C979; --rj: #4E241D; --rj-tx: #F8AC9C;
    --sh: 0 1px 2px rgba(0,0,0,.35); --scrim: rgba(0,0,0,.58);
    --toast: #F4EADD; --toast-tx: #1C1511; --toast-ac: #A8441F;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--tx);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--link); }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #D9734C; outline-offset: 2px; }
h1, h2 { font-family: ui-rounded, -apple-system, system-ui, sans-serif; margin: 0; }
.oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.pantalla { min-height: 100%; padding: calc(var(--top) + 24px) 20px calc(var(--bottom) + 24px); display: flex; flex-direction: column; gap: 20px; }
.sub { color: var(--tx2); margin: 0; }

/* Botones */
.btn { min-height: 52px; border: 0; border-radius: 14px; padding: 0 20px; font-weight: 600; }
.btn-pri { background: var(--ac); color: var(--ac-tx); }
.btn-pri:disabled { opacity: .5; }
.btn-sec { background: var(--sf); color: var(--tx); border: 1px solid var(--bd); }

/* Entrar */
.entrar { justify-content: center; max-width: 420px; margin: 0 auto; }
.entrar h1 { font-size: 32px; }
.quien { display: flex; gap: 12px; }
.quien button {
  flex: 1; min-height: 132px; border-radius: 20px; background: var(--sf); border: 2px solid var(--bd);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; font-weight: 600;
}
.quien button[aria-pressed="true"] { border-color: var(--ac); }
.avatar { position: relative; overflow: hidden; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; font-weight: 700; flex: none; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.medio { width: 48px; height: 48px; font-size: 20px; }
.con-avatar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.boton-avatar { border: 0; background: none; padding: 0; border-radius: 50%; min-width: 48px; min-height: 48px; }
.av-inigo { background: var(--ac-soft); color: var(--ac-soft-tx); }
.av-lourdes { background: var(--ok-soft); color: var(--ok-tx); }
.campo { display: flex; flex-direction: column; gap: 6px; }
.campo input[type=password] {
  min-height: 52px; border-radius: 14px; border: 1px solid var(--bd); background: var(--sf); padding: 0 16px;
}
.campo input[aria-invalid="true"] { border-color: var(--rj-tx); }
.recordar { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.recordar input { width: 22px; height: 22px; accent-color: var(--ac); }
.error { background: var(--rj); color: var(--rj-tx); border-radius: 12px; padding: 12px 14px; margin: 0; }

/* Aviso sin conexión */
.offline { background: var(--am); color: var(--am-tx); border-radius: 12px; padding: 10px 14px; font-size: 14px; }

/* ── Esqueleto ── */
:root { --barra: 64px; }
.vista { padding: calc(var(--top) + 16px) 16px calc(var(--barra) + var(--bottom) + 156px); min-height: 100vh; }
.cabecera { margin: 4px 4px 14px; }
.cabecera h1 { font-size: 32px; line-height: 1.15; }
.cabecera .sub { margin-top: 4px; font-size: 15px; }
.con-atras { display: flex; align-items: center; gap: 4px; margin-left: -8px; }
.atras { width: 44px; height: 44px; border: 0; background: none; display: grid; place-items: center; color: var(--link); border-radius: 12px; }
.cargando { padding: 24px 4px; }
.offline { position: sticky; top: 0; z-index: 5; margin: 0; border-radius: 0; padding-top: calc(var(--top) + 8px); }
.offline[hidden] { display: none; }

/* Barra inferior */
.barra {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex;
  height: calc(var(--barra) + var(--bottom)); padding-bottom: var(--bottom);
  background: var(--sf); border-top: 1px solid var(--bd);
}
.barra button {
  flex: 1; border: 0; background: none; color: var(--tx2); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; font-size: 12px; font-weight: 600; min-height: 44px;
}
.barra button[aria-current] { color: var(--ac); }

/* Selector de columnas */
.segmento { display: flex; background: var(--sf2); border-radius: 14px; padding: 3px; gap: 3px; margin-bottom: 12px; }
.segmento button {
  flex: 1; min-height: 44px; border: 0; border-radius: 11px; background: transparent; color: var(--tx2); font-weight: 600; font-size: 15px;
}
.segmento button[aria-selected="true"] { background: var(--sf); color: var(--tx); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.segmento b { font-variant-numeric: tabular-nums; margin-left: 4px; opacity: .75; }

/* Tarjetas */
.lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tarjeta { display: flex; align-items: stretch; background: var(--sf); border-radius: var(--r); box-shadow: var(--sh); overflow: hidden; }
.tarjeta-principal {
  flex: 1; min-width: 0; min-height: 60px; border: 0; background: none; text-align: left;
  display: flex; align-items: center; gap: 12px; padding: 10px 6px 10px 14px;
}
.tarjeta-texto { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.t1 { font-weight: 600; font-size: 17px; overflow-wrap: anywhere; margin: 0; }
.t2 { color: var(--tx2); font-size: 14px; }
.tarjeta-mas { width: 48px; border: 0; background: none; color: var(--tx2); display: grid; place-items: center; }
.marca { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--bd); display: grid; place-items: center; font-size: 15px; font-weight: 700; }
.marca.llena { background: var(--ok); border-color: var(--ok); color: var(--sf); }
.chip { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--sf2); color: var(--tx2); vertical-align: 2px; }
.chip.rojo { background: var(--rj); color: var(--rj-tx); }
.chip.ambar { background: var(--am); color: var(--am-tx); }
.chip.ok { background: var(--ok-soft); color: var(--ok-tx); }
.avatar.mini { width: 28px; height: 28px; font-size: 13px; flex: none; }
.avatar.grande { width: 88px; height: 88px; font-size: 36px; }

/* Vacío */
.vacio { text-align: center; padding: 40px 24px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.vacio-t { font-weight: 700; font-size: 19px; margin: 0; }

/* Acción principal y añadir: abajo, al alcance del pulgar */
.pie-accion {
  position: fixed; left: 0; right: 0; bottom: calc(var(--barra) + var(--bottom)); z-index: 9;
  padding: 10px 16px; display: flex; flex-direction: column; gap: 8px;
  background: linear-gradient(to bottom, transparent, var(--bg) 14px);
}
.ancho { width: 100%; }
.anadir { display: flex; gap: 8px; }
.anadir input { flex: 1; min-width: 0; min-height: 52px; border-radius: 14px; border: 1px solid var(--bd); background: var(--sf); padding: 0 14px; font-size: 17px; }

/* Hoja inferior */
.hoja-fondo { position: fixed; inset: 0; z-index: 30; background: var(--scrim); display: flex; align-items: flex-end; animation: aparece .15s ease-out; }
.hoja {
  width: 100%; max-height: 85vh; overflow: auto; background: var(--bg); border-radius: 22px 22px 0 0;
  padding: 8px 16px calc(var(--bottom) + 16px); display: flex; flex-direction: column; gap: 8px;
}
.hoja-asa { width: 40px; height: 5px; border-radius: 3px; background: var(--bd); margin: 4px auto 6px; }
.hoja h2 { font-size: 19px; margin: 0 4px 6px; }
.hoja-op {
  min-height: 52px; border-radius: 14px; border: 1px solid var(--bd); background: var(--sf); text-align: left;
  padding: 10px 16px; display: flex; flex-direction: column; justify-content: center; font-weight: 600;
}
.hoja-op small { font-weight: 400; color: var(--tx2); font-size: 14px; }
.hoja-op.marcada { border-color: var(--ac); background: var(--ac-soft); color: var(--ac-soft-tx); }
.hoja-op.peligro { color: var(--rj-tx); }
.hoja-op.cancelar { text-align: center; align-items: center; background: transparent; border-color: transparent; color: var(--link); }
@keyframes aparece { from { opacity: 0; } }

/* Toast */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--barra) + var(--bottom) + 140px); z-index: 40;
  background: var(--toast); color: var(--toast-tx); border-radius: 14px; padding: 12px 14px; display: flex; align-items: center; gap: 12px;
  font-size: 15px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.visible { opacity: 1; transform: none; pointer-events: auto; }
.toast span { flex: 1; }
.toast button { border: 0; background: none; color: var(--toast-ac); font-weight: 700; min-height: 44px; padding: 0 6px; }
@media (prefers-reduced-motion: reduce) { .toast, .hoja-fondo { transition: none; animation: none; } }

/* Mi cuenta */
.cuenta { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 0 24px; text-align: center; }
.pila { display: flex; flex-direction: column; gap: 10px; }
.quien { border: 0; padding: 0; margin: 0; }

/* ── Pantallas K5–K8 ── */
.seccion { font-size: 15px; font-weight: 700; color: var(--tx2); text-transform: none; margin: 22px 6px 8px; display: flex; gap: 6px; align-items: center; }
.seccion b { font-weight: 600; opacity: .7; }
.vacio-corto { color: var(--tx2); margin: 4px 6px 8px; }
.dos-lineas { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hecho { flex: none; width: 52px; border: 0; background: none; display: grid; place-items: center; padding-left: 6px; }
.hecho:active .marca { background: var(--ok-soft); }
.tarjeta-principal.con-hecho { padding-left: 2px; }
div.tarjeta-principal { cursor: default; }
.ico { flex: none; width: 32px; height: 32px; border-radius: 10px; background: var(--sf2); display: grid; place-items: center; font-size: 17px; }
.ir-compra { width: 100%; margin-top: 18px; border: 0; padding: 14px; gap: 12px; align-items: center; text-align: left; }
.nota { color: var(--tx2); font-size: 13.5px; margin: 16px 6px 0; }
.intro { margin: 0 6px 10px; font-size: 15px; }
.apagado { color: var(--tx2); font-weight: 400; }

/* Buscador y pestañas de zona */
.buscador { display: flex; align-items: center; gap: 8px; background: var(--sf); border: 1px solid var(--bd); border-radius: 14px; padding: 0 12px; margin-bottom: 10px; color: var(--tx2); }
.buscador input { flex: 1; min-width: 0; min-height: 46px; border: 0; background: none; font-size: 17px; color: var(--tx); outline: none; }
.pestanas-zona { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; scrollbar-width: none; }
.pestanas-zona button { flex: 1 0 auto; min-height: 44px; border-radius: 12px; border: 1px solid var(--bd); background: var(--sf); color: var(--tx2); font-weight: 600; font-size: 14.5px; padding: 0 10px; white-space: nowrap; }
.pestanas-zona button[aria-selected="true"] { background: var(--ac-soft); color: var(--ac-soft-tx); border-color: var(--ac); }
.pestanas-zona b { font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.tarjeta-accion { flex: none; border: 0; border-left: 1px solid var(--bd); background: none; color: var(--link); font-weight: 600; font-size: 14px; padding: 0 14px; min-width: 76px; }
.plegable { width: 100%; min-height: 48px; margin-top: 12px; border: 0; background: none; display: flex; justify-content: space-between; align-items: center; color: var(--tx2); font-weight: 600; padding: 0 6px; }
.plegable span { color: var(--link); }
.lista.apagada .tarjeta { opacity: .65; }
.hoja-nota { margin: -4px 4px 4px; }
.hoja .campo { margin: 4px 0; }
.hoja input[type=date], .hoja input[type=text] { min-height: 52px; border-radius: 14px; border: 1px solid var(--bd); background: var(--sf); padding: 0 14px; font-size: 17px; }

/* Recetas */
.volver { border: 0; background: none; color: var(--link); font-weight: 600; min-height: 44px; display: flex; align-items: center; gap: 2px; padding: 0; margin-left: -4px; }
.ficha-t { font-size: 26px; margin: 4px 4px 2px; }
.ingredientes, .pasos { margin: 0; padding: 0 6px; display: flex; flex-direction: column; gap: 6px; }
.ingredientes { list-style: none; }
.ingredientes li { display: flex; gap: 10px; align-items: baseline; }
.ingredientes li > span { width: 18px; text-align: center; color: var(--tx2); font-weight: 700; }
.ingredientes .en-casa { color: var(--ok); }
.ingredientes small { color: var(--tx2); }
.pasos { padding-left: 26px; }
.pasos li { padding-left: 4px; }

/* Menú */
.dia-chip { flex: none; width: 46px; height: 46px; border-radius: 12px; background: var(--sf2); display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; line-height: 1.1; }
.dia-chip small { font-size: 11.5px; font-weight: 600; color: var(--tx2); text-transform: capitalize; }
.dia-chip.hoy { background: var(--ac-soft); color: var(--ac-soft-tx); }
.dia-chip.hoy small { color: var(--ac-soft-tx); }
.enlace { color: var(--link); font-weight: 600; font-size: 15px; background: none; border: 0; min-height: 44px; padding: 0 8px; }

/* Semana */
.nav-semana { display: flex; align-items: center; justify-content: space-between; margin: 0 -6px 6px; font-weight: 600; }
.nav-semana button { width: 44px; height: 44px; border: 0; background: none; color: var(--link); display: grid; place-items: center; }
.dia { margin-bottom: 14px; }
.dia h2 { font-size: 17px; margin: 0 6px 6px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dia.pasado { opacity: .55; }
.dia.es-hoy h2 { color: var(--link); }
.lista.compacta { gap: 0; background: var(--sf); border-radius: var(--r); box-shadow: var(--sh); overflow: hidden; }
.fila-dia { display: flex; gap: 12px; padding: 10px 14px; align-items: flex-start; }
.fila-dia + .fila-dia { border-top: 1px solid var(--bd); }
.hora { flex: none; width: 46px; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--link); padding-top: 1px; }
.nada { color: var(--tx2); margin: 0 6px; font-size: 15px; }

/* Recordatorios */
.tarjeta.col { flex-direction: column; }
.acciones { display: flex; justify-content: flex-end; align-items: center; gap: 6px; padding: 0 10px 10px; }
.acciones > :first-child { margin-right: auto; }
.btn-peq { min-height: 44px; border-radius: 12px; border: 1px solid var(--bd); background: var(--bg); padding: 0 14px; font-weight: 600; font-size: 15px; }

/* Casa */
.otro { display: flex; align-items: center; gap: 4px; font-size: 18px; flex: none; }
.caras { display: flex; gap: 6px; padding: 0 10px 10px; }
.caras button { flex: 1; min-height: 44px; border-radius: 12px; border: 1px solid var(--bd); background: var(--bg); font-size: 13.5px; font-weight: 600; padding: 0 4px; }
.caras button span { font-size: 18px; }
.caras button[aria-pressed="true"] { background: var(--ac-soft); color: var(--ac-soft-tx); border-color: var(--ac); }
.balance { background: var(--ac-soft); color: var(--ac-soft-tx); border-radius: 20px; padding: 18px; margin-bottom: 12px; }
.balance.paz { background: var(--ok-soft); color: var(--ok-tx); }
.balance .t2 { color: inherit; opacity: .85; margin: 0; }
.balance-t { font-size: 24px; font-weight: 700; margin: 4px 0; }
.importe { font-weight: 700; font-variant-numeric: tabular-nums; padding-right: 8px; flex: none; }
.novedad { padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.novedad p { margin: 0; }
.novedad .accion { color: var(--link); font-weight: 600; }
.aviso-lectura { background: var(--sf2); border-radius: 12px; padding: 12px 14px; margin: 0 0 6px; font-weight: 600; }
.grupo { background: var(--sf); border-radius: var(--r); box-shadow: var(--sh); overflow: hidden; }
.ajuste { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 56px; padding: 6px 14px; }
.ajuste + .ajuste { border-top: 1px solid var(--bd); }
.ajuste input, .ajuste select { min-height: 44px; border-radius: 10px; border: 1px solid var(--bd); background: var(--bg); padding: 0 10px; font-size: 17px; }
.valor { font-weight: 600; color: var(--tx2); }
.dos { display: flex; gap: 6px; }
.contador { display: flex; align-items: center; gap: 10px; }
.contador button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--bd); background: var(--bg); font-size: 22px; }
