:root {
  --bg: #f5f6f0;
  --surface: #ffffff;
  --surface-2: #eef1e7;
  --text: #1c271e;
  --muted: #5d6a5f;
  --line: #dde2d3;
  --brand: #1d7348;
  --brand-ink: #ffffff;
  --brand-soft: #e3f2e9;
  --accent: #d9741a;
  --danger: #b93a26;
  --danger-soft: #fbe9e5;
  --warn-soft: #fff4dc;
  --shadow: 0 1px 2px rgba(20, 40, 25, .06), 0 4px 16px rgba(20, 40, 25, .05);
  --radius: 14px;
  --p-legumbre: #8a6a3a;
  --p-pescado: #2a77ad;
  --p-pollo: #d99a12;
  --p-carne_roja: #bf3e2b;
  --p-carne: #b5651d;
  --p-huevo: #c9a80a;
  --p-vegetal: #2f9459;
  --p-lacteo: #7a66c2;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111512; --surface: #181e19; --surface-2: #212922; --text: #e5ebe4; --muted: #9aa79b;
    --line: #2d372e; --brand: #4cc184; --brand-ink: #0c1a11; --brand-soft: #193225; --accent: #f0954a;
    --danger: #f07a64; --danger-soft: #3a1f1a; --warn-soft: #352b14;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111512; --surface: #181e19; --surface-2: #212922; --text: #e5ebe4; --muted: #9aa79b;
  --line: #2d372e; --brand: #4cc184; --brand-ink: #0c1a11; --brand-soft: #193225; --accent: #f0954a;
  --danger: #f07a64; --danger-soft: #3a1f1a; --warn-soft: #352b14;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: .98rem; }
a { color: var(--brand); }
input, select, textarea, button { font: inherit; color: inherit; }
input[type="number"], input[type="text"], select, textarea, input:not([type]) {
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; min-width: 0; width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }

.contenedor {
  max-width: 1240px; margin: 0 auto; padding-block: 18px 60px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.muted { color: var(--muted); }
.nota { color: var(--muted); font-size: .86rem; margin: .5em 0 0; }
.aviso { background: var(--warn-soft); border-radius: 10px; padding: 8px 10px; font-size: .86rem; margin: 10px 0 0; }
.aviso-txt { color: var(--danger); font-size: .85rem; }
.descargo { color: var(--muted); font-size: .8rem; margin-top: 24px; }

/* Cabecera */
.cabecera { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
.cabecera-in {
  max-width: 1240px; margin: 0 auto; padding-block: 8px; display: flex; align-items: center; gap: 18px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.sync { order: 3; margin-left: auto; font-size: .75rem; font-weight: 600; color: var(--brand); background: var(--brand-soft); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.sync[data-estado="lento"], .sync[data-estado="error"], .sync[data-estado="lectura"] { color: var(--accent); background: var(--warn-soft); }
.marca { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--brand); white-space: nowrap; }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: 0; background: none; padding: 8px 12px; border-radius: 10px; cursor: pointer; white-space: nowrap; color: var(--muted); font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.tabs button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.tabs button:hover { background: var(--surface-2); color: var(--text); }
.tabs button.activo { background: var(--brand-soft); color: var(--brand); }
.casa-chip { font-size: .78rem; font-weight: 600; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 2px 10px; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.casa-chip:empty { display: none; }

/* Bloques */
.intro { margin: 6px 0 18px; }
.intro p { color: var(--muted); max-width: 70ch; margin: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.panel h3 { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.panel-cab { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.panel-cab h2 { margin: 0; }
.fila-campos { display: grid; grid-template-columns: 180px 220px 1fr; gap: 16px; align-items: start; }
.campo { display: flex; flex-direction: column; gap: 6px; font-size: .86rem; color: var(--muted); }
.campo > span:first-child { font-weight: 600; }
.con-sufijo { display: flex; align-items: center; gap: 6px; }
.con-sufijo b { color: var(--muted); font-weight: 600; }
.fila-acciones { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin: 10px 0; }
.fila-acciones label { display: flex; flex-direction: column; font-size: .85rem; color: var(--muted); gap: 4px; }

.btn {
  border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; white-space: nowrap;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primario { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primario:hover { filter: brightness(1.07); color: var(--brand-ink); }
.btn.grande { padding: 12px 22px; font-size: 1rem; }
.btn.enlace { border: 0; padding: 0; background: none; color: var(--brand); margin-top: 10px; }
.icono { border: 1px solid var(--line); background: var(--surface); width: 34px; height: 34px; border-radius: 10px; cursor: pointer; display: inline-grid; place-items: center; flex: none; }
.icono:hover { border-color: var(--brand); color: var(--brand); }
.icono.mini { width: 26px; height: 26px; border-radius: 8px; font-size: .85rem; }
.acciones-fin { display: flex; justify-content: flex-end; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: .88rem; color: var(--text); background: var(--surface); }
.chip input:checked + span { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }
.chip input:focus-visible + span { outline: 2px solid var(--brand); }
.chip.pequeno span { padding: 4px 10px; font-size: .8rem; }

/* Personas */
.personas { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 10px; align-items: start; }
.persona { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); min-width: 0; }
.persona[open] { box-shadow: var(--shadow); }
.persona-resumen { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; list-style: none; }
.persona-resumen::-webkit-details-marker { display: none; }
.pr-quien, .pr-macros { display: flex; flex-direction: column; min-width: 0; }
.pr-quien small, .pr-macros small { color: var(--muted); font-size: .78rem; }
.pr-quien small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-macros { text-align: right; font-variant-numeric: tabular-nums; }
.pr-chevron { width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; margin: 0 4px 4px; }
.persona[open] .pr-chevron { transform: rotate(-135deg); margin: 4px 4px 0; }
.persona-edit { display: flex; flex-direction: column; gap: 12px; padding: 12px 14px 14px; border-top: 1px solid var(--line); }
.persona-cab { display: flex; align-items: center; gap: 10px; }
.avatar, .mini-av { display: inline-grid; place-items: center; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 700; flex: none; }
.avatar { width: 36px; height: 36px; font-size: .85rem; }
.mini-av { width: 22px; height: 22px; font-size: .62rem; }
.persona .nombre { font-weight: 700; font-size: 1.02rem; border-color: transparent; background: transparent; padding-left: 4px; }
.persona .nombre:hover, .persona .nombre:focus { border-color: var(--line); background: var(--surface); }
.grid-campos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grid-campos label { display: flex; flex-direction: column; gap: 3px; font-size: .78rem; color: var(--muted); font-weight: 600; min-width: 0; }
.grid-campos .ancho { grid-column: span 2; }
.dietas summary { cursor: pointer; font-size: .86rem; color: var(--muted); font-weight: 600; }
.dietas .chips { margin-top: 8px; }
.comidas-cab { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .88rem; margin-bottom: 6px; }
.presets { display: flex; gap: 4px; flex-wrap: wrap; }
.presets button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 3px 8px; font-size: .76rem; cursor: pointer; }
.presets button:hover { border-color: var(--brand); color: var(--brand); }
.tabla-scroll { overflow-x: auto; }
.tabla-comidas { border-collapse: collapse; width: 100%; }
.tabla-comidas th { font-size: .75rem; color: var(--muted); font-weight: 600; padding: 2px; }
.tabla-comidas th[scope="row"] { text-align: left; padding-right: 8px; white-space: nowrap; }
.tabla-comidas td { text-align: center; padding: 2px; }
.celda { display: inline-block; cursor: pointer; }
.celda input { position: absolute; opacity: 0; pointer-events: none; }
.celda span { display: block; width: 28px; height: 26px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface-2); }
.celda input:checked + span { background: var(--brand); border-color: var(--brand); box-shadow: inset 0 0 0 4px var(--surface); }
.celda input:focus-visible + span { outline: 2px solid var(--brand); }
.necesidades { display: grid; grid-template-columns: auto auto 1fr; gap: 12px; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.necesidades div { display: flex; flex-direction: column; }
.necesidades b { font-size: 1.05rem; }
.necesidades span { font-size: .75rem; color: var(--muted); }
.necesidades .obj b { font-size: .9rem; }

/* Menú */
.semana-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.semana-tit { display: flex; flex-direction: column; min-width: 0; }
.semana-tit strong { font-size: 1.15rem; }
.semana-tit span { color: var(--muted); font-size: .82rem; }
.semana-nav .btn { margin-left: auto; }
.semana-nav .sep { flex: 1; }
.semana-nav .sep + .btn { margin-left: 0; }
.resumen { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 4px; }
.resumen.tres { grid-template-columns: repeat(3, 1fr); }

/* Casas, preferencias y ajustes */
.casa-bar { display: flex; gap: 14px; align-items: end; flex-wrap: wrap; }
.casa-bar .campo { min-width: 180px; }
.casa-bar .crece { flex: 1; }
.casa-botones { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.peligro { color: var(--danger); }
.btn.peligro:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.campo small { font-weight: 400; }
.interruptor { display: flex; align-items: center; gap: 10px; margin-top: 14px; cursor: pointer; font-size: .92rem; }
.interruptor input { position: absolute; opacity: 0; pointer-events: none; }
.interruptor span { width: 40px; height: 22px; border-radius: 99px; background: var(--line); position: relative; flex: none; transition: .2s; }
.interruptor span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); transition: .2s; }
.interruptor input:checked + span { background: var(--brand); }
.interruptor input:checked + span::after { left: 21px; }
.interruptor input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.prioridad { margin-top: 12px; max-width: 420px; }
.prefs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
h3.sub { margin: 16px 0 8px; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.chip-quitar { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 3px 4px 3px 12px; font-size: .85rem; background: var(--surface-2); }
.macros { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr; gap: 6px; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.macro { display: flex; flex-direction: column; border-left: 3px solid var(--line); padding-left: 8px; }
.macro b { font-size: 1.02rem; }
.macro span { font-size: .72rem; color: var(--muted); }
.macro.kcal { border-color: var(--brand); }
.macro.m-p { border-color: var(--p-pescado); }
.macro.m-c { border-color: var(--p-pollo); }
.macro.m-g { border-color: var(--p-carne_roja); }
.macro-nota { grid-column: 1 / -1; margin: 6px 0 0; font-size: .78rem; color: var(--muted); }
.ajustes summary { cursor: pointer; font-size: .86rem; color: var(--muted); font-weight: 600; }
.ajustes .grid-campos { margin-top: 8px; }
.presu-semana { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); font-weight: 600; flex-wrap: wrap; }
.presu-semana input { width: 90px; text-align: right; }
.presu-semana .btn.enlace { margin-top: 0; font-weight: 500; }
.cobertura th[scope="row"] { white-space: nowrap; color: var(--text); font-weight: 600; font-size: .88rem; }
.cobertura small { display: block; color: var(--muted); font-weight: 400; font-size: .76rem; }
.cobertura td { white-space: nowrap; }
.cobertura td.cob-ok { color: var(--brand); font-weight: 700; }
.cobertura td.cob-bajo { color: var(--danger); font-weight: 700; }
.cobertura td.cob-alto { color: var(--accent); font-weight: 700; }
.badge-extra { font-size: .66rem; font-weight: 700; color: var(--p-pescado); border: 1px solid currentColor; border-radius: 6px; padding: 0 4px; }
.mini-av.con-extra { box-shadow: 0 0 0 2px var(--p-pescado); }
.tabla td small { display: block; }
.extra-txt { display: block; color: var(--p-pescado); font-size: .78rem; }
.confirmar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--danger-soft); border-radius: 10px; padding: 8px 10px; font-size: .88rem; font-weight: 600; }
.pill.fuera-regla { outline: 2px dashed var(--danger); outline-offset: 1px; }
.resumen .panel { margin-bottom: 14px; }
.presu-num { display: flex; align-items: baseline; gap: 8px; }
.presu-num b { font-size: 1.6rem; }
.presu-num span { color: var(--muted); }
.barra { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 8px 0 6px; }
.barra span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.presu p { margin: 0; font-size: .88rem; color: var(--muted); }
.presu.pasa .barra span { background: var(--danger); }
.presu.pasa p { color: var(--danger); font-weight: 600; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 10px; font-size: .8rem; font-weight: 600; color: #fff; }
.lista-personas { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: .88rem; }
.lista-personas li { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.semana { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.dia { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow); min-width: 0; }
.dia h3 { margin: 0 0 2px; font-size: 1rem; color: var(--text); text-transform: none; letter-spacing: 0; }
.dia h3 small { color: var(--muted); font-weight: 500; }
.slot { border-radius: 10px; padding: 8px 10px; background: var(--surface-2); display: flex; flex-direction: column; gap: 4px; }
.slot.fuera { background: transparent; border: 1px dashed var(--line); }
.slot-tit { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.slot-tit em { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--accent); }
.plato { text-align: left; border: 0; background: none; padding: 0; cursor: pointer; font-weight: 600; line-height: 1.3; display: flex; gap: 7px; align-items: baseline; }
.plato:hover { color: var(--brand); text-decoration: underline; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; transform: translateY(-1px); }
.slot-pie { display: flex; align-items: center; gap: 6px; }
.quien { display: flex; gap: 2px; }
.kcal { color: var(--muted); font-size: .78rem; margin-left: auto; }

.prot-legumbre { background: var(--p-legumbre); } .prot-pescado { background: var(--p-pescado); }
.prot-pollo { background: var(--p-pollo); } .prot-carne_roja { background: var(--p-carne_roja); }
.prot-carne { background: var(--p-carne); } .prot-huevo { background: var(--p-huevo); }
.prot-vegetal { background: var(--p-vegetal); } .prot-lacteo { background: var(--p-lacteo); }

/* Diálogo receta */
dialog { border: 1px solid var(--line); border-radius: 18px; padding: 0; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 40px); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(10, 20, 12, .45); }
.dlg-cab { display: flex; justify-content: space-between; gap: 12px; align-items: start; padding: 16px 18px 6px; position: sticky; top: 0; background: var(--surface); }
.dlg-cab h2 { margin: 2px 0 0; font-size: 1.25rem; }
.dlg-cuerpo { padding: 0 18px 18px; }
.dlg-cuerpo h3 { margin: 18px 0 8px; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: .88rem; margin: 0; }
.ingr { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 24px; }
.ingr li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--line); break-inside: avoid; font-size: .9rem; }
.pasos { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.ancho-total { width: 100%; }
.tabla { border-collapse: collapse; width: 100%; font-size: .88rem; }
.tabla th, .tabla td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tabla th { color: var(--muted); font-weight: 600; font-size: .8rem; }

/* Lista */
.opciones { display: grid; gap: 8px; }
.opcion { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.opcion.activa { border-color: var(--brand); background: var(--brand-soft); }
.opcion input { accent-color: var(--brand); }
.opcion span { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.opcion small { color: var(--muted); }
.comparativa { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.comparativa li { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--line); }
.comparativa li.principal { font-weight: 700; }
.progreso { color: var(--muted); font-size: .86rem; margin: 0 0 8px; }
.grupos { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; align-items: start; }
.grupo { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); break-inside: avoid; min-width: 0; }
.grupo h3 { display: flex; justify-content: space-between; margin: 0 0 6px; font-size: .95rem; }
.grupo h3 span { color: var(--muted); font-weight: 600; }
.items { list-style: none; margin: 0; padding: 0; }
.item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.check { cursor: pointer; padding-top: 2px; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check span { display: block; width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--line); }
.check input:checked + span { background: var(--brand); border-color: var(--brand); box-shadow: inset 0 0 0 3px var(--surface); }
.check input:focus-visible + span { outline: 2px solid var(--brand); }
.item-info { flex: 1; min-width: 0; }
.item-nombre { font-weight: 600; }
.item-det { font-size: .84rem; }
.sobra { color: var(--accent); }
.prod { display: block; font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prod a { color: var(--muted); }
.item-precio { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; flex: none; }
.lo-tengo { font-size: .74rem; color: var(--muted); display: flex; gap: 4px; align-items: center; cursor: pointer; }
.item.hecho .item-nombre { text-decoration: line-through; color: var(--muted); }
.item.en-casa { opacity: .6; }
.tag { display: inline-block; border-radius: 6px; padding: 0 6px; font-size: .7rem; font-weight: 700; letter-spacing: .02em; }
.tag.fuente-web { background: var(--brand-soft); color: var(--brand); }
.tag.fuente-estimado { background: var(--surface-2); color: var(--muted); }
.tag.fuente-manual, .tag.fuente-ticket { background: var(--warn-soft); color: var(--accent); }

/* Precios */
.fuentes { display: grid; gap: 8px; font-size: .9rem; }
.precios th[scope="row"] { min-width: 180px; font-weight: 600; color: var(--text); font-size: .88rem; }
.precios th[scope="row"] small { display: block; color: var(--muted); font-weight: 500; }
.celda-precio div { display: flex; gap: 4px; align-items: center; }
.celda-precio input { width: 84px; padding: 5px 7px; text-align: right; }
.celda-precio.fuente-manual input, .celda-precio.fuente-ticket input { border-color: var(--accent); }
.celda-precio small { display: flex; gap: 6px; margin-top: 3px; font-size: .75rem; }
.tk select { min-width: 180px; }
.tk td small { display: block; color: var(--muted); }
.tk tr.apagada { opacity: .55; }
.tk input[type="text"] { width: 90px; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 40px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; opacity: 0; transition: .25s; pointer-events: none; z-index: 50; font-weight: 600; }
.toast.ver { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 960px) {
  .resumen, .resumen.tres { grid-template-columns: 1fr; }
  .fila-campos { grid-template-columns: 1fr 1fr; }
  .fila-campos .campo:last-child { grid-column: 1 / -1; }
}
@media (max-width: 620px) {
  h1 { font-size: 1.3rem; }
  .personas { grid-template-columns: 1fr; }
  .grid-campos { grid-template-columns: 1fr 1fr; }
  .grupos { grid-template-columns: 1fr; }
  .ingr { columns: 1; }
  .macros { grid-template-columns: 1fr 1fr; }
  .semana-nav { display: grid; grid-template-columns: auto 1fr auto; }
  .semana-nav .semana-tit { text-align: center; }
  .semana-nav .presu-semana, .semana-nav .sep { grid-column: 1 / -1; }
  .semana-nav .sep { display: none; }
  .semana-nav > .btn { grid-column: span 3; justify-self: stretch; }
  .semana-nav > .btn + .btn { margin-top: -4px; }
  .celda span { width: 26px; }
  .semana-nav .btn { margin-left: 0; }
}

/* Secciones plegables */
details.panel > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary h2, details.panel > summary h3 { margin: 0; }
details.panel > summary::after { content: ""; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin-left: auto; flex: none; }
details.panel[open] > summary::after { transform: rotate(-135deg); }
details.panel[open] > summary { margin-bottom: 14px; }
.resumen-txt { color: var(--muted); font-size: .85rem; }

/* HOY */
.hoy-cab { position: sticky; top: calc(var(--cab-h, 56px) + env(safe-area-inset-top, 0px)); z-index: 5; background: var(--bg); padding-block: 6px 8px; display: flex; flex-direction: column; gap: 8px; }
.semana-mini { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .85rem; font-weight: 600; }
.semana-mini .icono { width: 28px; height: 28px; }
.tira-dias { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.dia-btn { display: flex; flex-direction: column; align-items: center; padding: 6px 0 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; color: var(--muted); font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.dia-btn b { font-size: 1.15rem; color: var(--text); line-height: 1.2; letter-spacing: 0; }
.dia-btn .puntos { font-style: normal; color: var(--brand); letter-spacing: 2px; line-height: 1; height: 10px; }
.dia-btn.es-hoy { border-color: var(--brand); }
.dia-btn.activo { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.dia-btn.activo b, .dia-btn.activo .puntos { color: var(--brand-ink); }
.quien { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.quien::-webkit-scrollbar { display: none; }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px 4px 5px; font-weight: 600; font-size: .85rem; cursor: pointer; white-space: nowrap; flex: none; }
.chip-btn:first-child { padding-left: 12px; }
.chip-btn.activo { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.titulo-dia { font-size: 1.3rem; margin: 8px 0 12px; }
.tomas { display: grid; gap: 16px; }
.toma { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.toma.vacia { box-shadow: none; background: transparent; border-style: dashed; }
.toma.vacia p { margin: 4px 0 0; }
.toma-cab { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.toma-tit { min-width: 0; }
.toma-tit h2 { margin: 2px 0 0; font-size: 1.2rem; display: flex; gap: 8px; align-items: baseline; text-wrap: balance; }
.toma-acc { display: flex; gap: 6px; flex: none; }
.cocinar summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: .88rem; }
.cocinar[open] summary { margin-bottom: 10px; }
.cocinar .pasos { margin-top: 12px; }
.mesa { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.mesa.solo { grid-template-columns: minmax(0, 640px); }
.plato-p { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); min-width: 0; }
.pp-cab { display: flex; align-items: center; gap: 10px; }
.pp-quien { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pp-quien small { color: var(--muted); font-size: .75rem; }
.pp-parte { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.pp-parte b { font-size: 1.4rem; color: var(--brand); line-height: 1.1; font-variant-numeric: tabular-nums; }
.pp-parte small { color: var(--muted); font-size: .72rem; }
.pp-cuerpo { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; align-items: start; }
.plato-p.grande .pp-cuerpo { grid-template-columns: 92px minmax(0, 1fr); }
.donut { width: 100%; height: auto; display: block; }
.seg { fill: none; stroke-width: 7; }
.seg-fondo { stroke: var(--line); }
.seg-verdura { stroke: var(--p-vegetal); }
.seg-proteina { stroke: var(--p-pescado); }
.seg-hidrato { stroke: var(--p-pollo); }
.medidas { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.medidas li { display: flex; flex-direction: column; padding-left: 10px; border-left: 3px solid var(--line); min-width: 0; }
.medidas li span { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.medidas li b { font-size: .95rem; }
.medidas li small { color: var(--muted); font-size: .78rem; }
.medidas .r-proteina { border-color: var(--p-pescado); }
.medidas .r-legumbre { border-color: var(--p-legumbre); }
.medidas .r-hidrato { border-color: var(--p-pollo); }
.medidas .r-verdura { border-color: var(--p-vegetal); }
.medidas .r-extra { border-color: var(--p-pescado); border-left-style: dashed; }
.medidas .r-sin { border-color: var(--accent); }
.barras { display: grid; gap: 5px; }
.bm { display: grid; grid-template-columns: 62px minmax(0, 1fr) 84px; align-items: center; gap: 8px; font-size: .75rem; }
.bm span { color: var(--muted); font-weight: 600; }
.bm em { font-style: normal; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.bm em small { color: var(--muted); font-weight: 500; }
.bm-barra { position: relative; height: 8px; background: var(--line); border-radius: 99px; }
.bm-barra i { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: var(--brand); }
.bm-barra b { position: absolute; top: -3px; bottom: -3px; left: 76.9%; width: 2px; background: var(--text); opacity: .45; border-radius: 1px; }
.bm-barra.cob-bajo i { background: var(--danger); }
.bm-barra.cob-alto i { background: var(--accent); }
.resumen-dia h3 { margin-bottom: 10px; }

/* SEMANA */
.sem-resumen { display: grid; grid-template-columns: 1.2fr 1fr; gap: 12px; }
.panel.compacto { padding: 12px 14px; margin-bottom: 12px; }
.sem-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.sem-dia { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sem-dia.es-hoy { border-color: var(--brand); }
.sem-dia h3 { margin: 0; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sem-dia h3 small { color: var(--text); font-size: 1rem; letter-spacing: 0; }
.sem-celda { background: var(--surface-2); border-radius: 8px; padding: 6px 8px; display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.sem-celda.vacia { background: transparent; border: 1px dashed var(--line); color: var(--muted); font-size: .8rem; }
.sem-celda small { font-size: .63rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.sem-plato { text-align: left; border: 0; background: none; padding: 0; cursor: pointer; font-weight: 600; font-size: .84rem; line-height: 1.25; display: flex; gap: 6px; align-items: baseline; }
.sem-plato:hover { color: var(--brand); }
.sem-pie { display: flex; align-items: center; gap: 4px; margin-top: auto; }
.sem-pie .icono { margin-left: auto; }
.sem-pie .quien { gap: 2px; }

/* COMPRA */
.donde > summary > span { display: flex; flex-direction: column; }
.donde > summary small { color: var(--muted); font-weight: 500; font-size: .8rem; }
.donde-cuerpo { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.contenedor.con-barra { padding-bottom: 120px; }
.barra-compra { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 18px rgba(20, 40, 25, .08); padding-block: 10px calc(10px + env(safe-area-inset-bottom, 0px)); }
.bc-in { max-width: 1240px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: flex; align-items: center; gap: 16px; }
.bc-total { display: flex; flex-direction: column; }
.bc-total b { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.bc-total small { color: var(--muted); font-size: .78rem; }
.bc-total.pasa b, .bc-total.pasa small { color: var(--danger); }
.bc-prog { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.bc-prog .barra { margin: 0; }
.bc-prog small { color: var(--muted); font-size: .78rem; }
.item[data-fila] { cursor: pointer; }
.item[data-fila]:hover .item-nombre { color: var(--brand); }
.grupo h3 span { font-variant-numeric: tabular-nums; }

/* FOTOS DE LOS PLATOS */
:root { --fav: #d6405a; }
.img-plato { position: relative; overflow: hidden; background: var(--surface-2); }
.img-plato img, .img-plato svg { display: block; width: 100%; height: 100%; object-fit: cover; }
.img-plato.grande { aspect-ratio: 16 / 10; border-radius: 12px; }
.img-plato.mini { aspect-ratio: 16 / 9; border-radius: 6px; }
.img-plato.sel { aspect-ratio: 4 / 3; }
.img-plato.hero { aspect-ratio: 16 / 9; max-height: 320px; width: 100%; }
.il-mesa { fill: var(--surface-2); }
.fav { color: var(--muted); font-size: 1.05rem; }
.fav.activo { color: var(--fav); border-color: var(--fav); }
.fav-mark { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, .92); color: var(--fav); font-style: normal; font-size: .8rem; }

/* Tarjeta de comida en Hoy */
.toma-top { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 16px; align-items: start; }
.toma-foto { position: relative; border: 0; padding: 0; background: none; cursor: pointer; border-radius: 12px; display: block; width: 100%; }
.toma-foto:hover .img-plato { filter: brightness(1.04); }
.foto-etq { position: absolute; left: 8px; top: 8px; background: rgba(15, 25, 18, .72); color: #fff; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 3px 9px; border-radius: 999px; }
.toma-info { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.toma-info h2 { margin: 2px 0 0; font-size: 1.3rem; text-wrap: balance; }
.datos-plato { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; color: var(--muted); font-size: .85rem; font-weight: 600; }
.toma-acc { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* Semana con fotos */
.sem-foto { position: relative; border: 0; padding: 0; background: none; cursor: pointer; display: block; width: 100%; }

/* Ficha de receta */
dialog.dlg-receta { padding: 0; }
.dlg-hero { position: relative; }
.dlg-hero form { position: absolute; top: 10px; right: 10px; margin: 0; }
.cerrar-hero { background: rgba(255, 255, 255, .92); color: #1c271e; border-color: transparent; }
.hero-acc { position: absolute; left: 10px; bottom: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.foto-btn { background: rgba(15, 25, 18, .72); color: #fff; border-color: transparent; font-size: .8rem; padding: 6px 12px; }
.foto-btn:hover { background: rgba(15, 25, 18, .85); color: #fff; }
.dlg-receta .dlg-cuerpo { padding-top: 14px; }
.credito { text-transform: none; letter-spacing: 0; font-weight: 500; }
.credito a { color: var(--muted); }
.receta-tit { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin: 4px 0 10px; }
.receta-tit h2 { margin: 0; font-size: 1.35rem; text-wrap: balance; }
.datos-receta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.datos-receta div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.datos-receta b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.datos-receta span { font-size: .72rem; color: var(--muted); }

/* Elegir otro plato */
dialog.dlg-selector { width: min(860px, calc(100vw - 32px)); }
.sel-filtros { margin: 10px 0 12px; }
.sel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.sel-card { position: relative; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); padding: 0; text-align: left; cursor: pointer; display: flex; flex-direction: column; min-width: 0; }
.sel-card:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.sel-txt { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; }
.sel-txt b { font-size: .88rem; line-height: 1.25; }
.sel-txt small { color: var(--muted); font-size: .76rem; }
.sel-txt em { font-style: normal; font-weight: 700; }
.sel-txt em.ahorra { color: var(--brand); }
.sel-txt em.cuesta { color: var(--accent); }

.creditos { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 4px; font-size: .82rem; color: var(--muted); }
.creditos b { color: var(--text); font-weight: 600; }
.creditos a { color: var(--muted); }

/* Modo cocina */
dialog.dlg-cocina { width: min(720px, calc(100vw - 24px)); }
.cocina-barra { height: 6px; background: var(--surface-2); margin: 0 18px; border-radius: 99px; overflow: hidden; }
.cocina-barra span { display: block; height: 100%; background: var(--brand); transition: width .25s; }
.cocina-cuerpo { min-height: 220px; padding-top: 18px; }
.cocina-num { color: var(--brand); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: .8rem; margin: 0 0 8px; }
.cocina-paso { font-size: 1.45rem; line-height: 1.4; font-weight: 600; margin: 0 0 12px; text-wrap: pretty; }
.cocina-ingr { columns: 1; }
.cocina-ingr li { font-size: 1rem; }
.cocina-nav { display: flex; justify-content: space-between; gap: 10px; padding: 12px 18px calc(16px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); }
.cocina-nav form { margin: 0; }
.btn[disabled] { opacity: .45; cursor: default; }

@media (max-width: 1100px) { .sem-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* Móvil: navegación abajo, como una app */
@media (max-width: 760px) {
  .cabecera-in { gap: 8px; padding-block: 8px; }
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line);
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0;
    padding: 4px max(6px, env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) max(6px, env(safe-area-inset-left, 0px)); }
  .tabs button { flex-direction: column; gap: 1px; padding: 6px 2px; font-size: .68rem; }
  .tabs button svg { width: 22px; height: 22px; }
  .contenedor { padding-block: 10px calc(84px + env(safe-area-inset-bottom, 0px)); }
  .contenedor.con-barra { padding-bottom: calc(150px + env(safe-area-inset-bottom, 0px)); }
  .barra-compra { bottom: calc(58px + env(safe-area-inset-bottom, 0px)); padding-block: 8px; }
  .bc-in { gap: 10px; }
  .bc-total b { font-size: 1.15rem; }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
  .sem-resumen, .donde-cuerpo { grid-template-columns: 1fr; }
  .sem-grid { grid-template-columns: 1fr; gap: 6px; }
  .sem-dia { display: grid; grid-template-columns: 40px minmax(0, 1fr) minmax(0, 1fr); align-items: stretch; padding: 6px; }
  .sem-dia h3 { display: flex; flex-direction: column; align-items: center; justify-content: center; }
  .personas { grid-template-columns: 1fr; }
  .persona-resumen { grid-template-columns: auto minmax(0, 1fr) auto; }
  .persona-resumen .pr-chevron { display: none; }
  .mesa { grid-template-columns: 1fr; }
  .toma-tit h2 { font-size: 1.08rem; }
  .toma-top { grid-template-columns: 1fr; gap: 10px; }
  .toma-info h2 { font-size: 1.15rem; }
  .datos-receta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .cocina-paso { font-size: 1.25rem; }
  .sem-dia .img-plato.mini { aspect-ratio: 16 / 8; }
}

@media print {
  .cabecera, .semana-nav button, .no-print, .lo-tengo, .resumen .opciones, .btn { display: none !important; }
  body { background: #fff; color: #000; }
  .panel, .grupo, .dia { box-shadow: none; }
  .grupos { display: block; }
  .grupo { margin-bottom: 10px; }
}
