/* ==========================================================================
   Menú y presupuesto familiar — styles.css · v0.6.0
   --------------------------------------------------------------------------
   1. Tokens de diseño          7. Calendario · vista semana
   2. Base                      8. Panel de resumen semanal
   3. Layout                    9. Diálogo de plato
   4. Barra superior y botones 10. Toast y modo "colocar"
   5. Biblioteca de platos     11. Estados de drag & drop
   6. Calendario · vista mes   12. Responsive · 13. Impresión
   ========================================================================== */

/* 1. TOKENS ---------------------------------------------------------------- */
:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --bg: #F3F5F8;
  --surface: #FFFFFF;
  --surface-2: #F7F8FA;
  --surface-3: #ECEFF3;
  --border: #E1E5EA;
  --border-strong: #C9CFD7;

  --text: #1B1F24;
  --text-2: #5A6472;
  --text-3: #8A93A1;

  --primary: #1F6FEB;
  --primary-soft: #E6EFFD;
  --on-primary: #FFFFFF;

  --danger: #D1343B;
  --danger-soft: #FDECEC;
  --ok: #1E8A4C;
  --ok-soft: #E5F4EB;
  --warn: #A86200;
  --warn-soft: #FFF3DC;

  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  --shadow-1: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-2: 0 10px 28px rgba(16, 24, 40, .16), 0 2px 6px rgba(16, 24, 40, .08);

  --sidebar-w: 300px;
  --panel-w: 304px;
  --topbar-h: 64px;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121418;
    --surface: #1A1D22;
    --surface-2: #20242A;
    --surface-3: #2A2F36;
    --border: #2E333B;
    --border-strong: #3C434D;
    --text: #E8EBEF;
    --text-2: #A6AFBB;
    --text-3: #7B8592;
    --primary: #79A9FF;
    --primary-soft: #1E2D46;
    --on-primary: #0C1424;
    --danger: #FF7076;
    --danger-soft: #3B1F23;
    --ok: #52C487;
    --ok-soft: #173126;
    --warn: #F0B23E;
    --warn-soft: #3A2D14;
    --shadow-2: 0 10px 28px rgba(0, 0, 0, .55);
  }
}

/* 2. BASE ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { fill: currentColor; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* 3. LAYOUT ---------------------------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--panel-w);
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  grid-template-areas:
    "top top top"
    "lib cal nut";
  height: 100vh;
  height: 100dvh;
}
.topbar     { grid-area: top; }
.library    { grid-area: lib; }
.calendar   { grid-area: cal; min-width: 0; min-height: 0; overflow: auto; padding: 16px; }
.budget     { grid-area: bud; display: none; }
.nutrition  { grid-area: nut; min-height: 0; overflow-y: auto; padding: 20px; background: var(--surface); border-left: 1px solid var(--border); }

/* Pestaña Presupuesto: oculta el menú y ocupa todo el ancho */
.app.mode-budget { grid-template-areas: "top top top" "bud bud bud"; }
.app.mode-budget .library,
.app.mode-budget .calendar,
.app.mode-budget .nutrition,
.app.mode-budget [data-only="menu"] { display: none; }
.app.mode-budget .budget { display: grid; }

/* 4. BARRA SUPERIOR Y BOTONES --------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: calc(var(--sidebar-w) - 32px); flex: none; }
.brand__logo { flex: none; width: 38px; height: 38px; }
.brand__svg { display: block; width: 100%; height: 100%; }
.tabs { display: inline-flex; gap: 2px; }
.version-tag {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-3); color: var(--text-3);
  font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tabs button {
  position: relative;
  height: 40px; padding: 0 12px;
  border: none; border-radius: var(--radius-sm);
  background: none; color: var(--text-2);
  font-size: 15px; font-weight: 600;
}
.tabs button:hover { background: var(--surface-3); color: var(--text); }
.tabs button.is-active { color: var(--primary); }
.tabs button.is-active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -12px;
  height: 3px; border-radius: 3px 3px 0 0; background: var(--primary);
}
.nav-arrows { display: flex; }
.period-title { font-size: 22px; font-weight: 450; letter-spacing: -.01em; white-space: nowrap; }
.topbar__spacer { flex: 1; }
.toolbar-group { display: flex; align-items: center; gap: 2px; padding-left: 6px; border-left: 1px solid var(--border); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px;
  border: 1px solid transparent; border-radius: 999px;
  background: none;
  font-weight: 500; white-space: nowrap;
  transition: background-color .15s, border-color .15s, filter .15s;
}
.btn svg { width: 18px; height: 18px; }
.btn-outline { border-color: var(--border-strong); }
.btn-outline:hover { background: var(--surface-3); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-tonal { background: var(--primary-soft); color: var(--primary); }
.btn-tonal:hover { filter: brightness(.97); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger-text { color: var(--danger); padding: 0 12px; }
.btn-danger-text:hover { background: var(--danger-soft); }
.btn-block { width: 100%; }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }

.icon-btn {
  width: 36px; height: 36px; flex: none;
  display: inline-grid; place-items: center;
  border: none; border-radius: 50%;
  background: none; color: var(--text-2);
  transition: background-color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn--sm { width: 30px; height: 30px; }
.icon-btn--sm svg { width: 18px; height: 18px; }
.icon-btn--xs { width: 24px; height: 24px; }
.icon-btn--xs svg { width: 15px; height: 15px; }
.icon-btn--tonal { background: var(--primary-soft); color: var(--primary); }
.icon-btn--tonal:hover { background: var(--primary-soft); color: var(--primary); filter: brightness(.96); }

.segmented { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-3); }
.segmented button {
  height: 30px; padding: 0 14px;
  border: none; border-radius: 999px;
  background: none; color: var(--text-2); font-weight: 500;
}
.segmented button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.segmented--sm { padding: 2px; flex: none; }
.segmented--sm button { display: inline-grid; place-items: center; height: 26px; min-width: 30px; padding: 0 8px; font-size: 12px; }
.segmented--sm svg { width: 16px; height: 16px; }

/* 5. BIBLIOTECA DE PLATOS -------------------------------------------------- */
.library {
  position: relative;
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.library__head { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-bottom: 1px solid var(--border); }
.search { position: relative; display: block; }
.search svg { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); fill: var(--text-3); pointer-events: none; }
.search input {
  width: 100%; height: 40px; padding: 0 14px 0 38px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2);
}
.search input:focus { outline: none; border-color: var(--primary); background: var(--surface); }

.library__search-row { display: flex; align-items: center; gap: 8px; }
.library__search-row .search { flex: 1; min-width: 0; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-2);
  font-size: 12.5px; font-weight: 500;
}
.filter-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.filter-chip:hover { background: var(--surface-2); }
.filter-chip.is-active { border-color: transparent; background: var(--primary-soft); color: var(--primary); font-weight: 600; }

.library__list { flex: 1; overflow-y: auto; padding: 4px 12px 16px; }
.lib-section { margin-top: 6px; }
.lib-section summary {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 4px 8px;
  list-style: none; cursor: pointer; user-select: none;
  font-size: 13px; font-weight: 600; color: var(--text-2);
}
.lib-section summary::-webkit-details-marker { display: none; }
.lib-section summary::before {
  content: "";
  width: 6px; height: 6px; margin: 0 4px 0 2px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .15s;
}
.lib-section[open] summary::before { transform: rotate(45deg); }
.lib-section__count { margin-left: auto; padding: 1px 8px; border-radius: 999px; background: var(--surface-3); font-size: 11.5px; font-weight: 500; }
.lib-section__items { display: flex; flex-direction: column; gap: 6px; }
.lib-empty { padding: 2px 6px 8px; font-size: 12.5px; color: var(--text-3); }
.library__hint { padding: 10px 16px 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); }

/* Tarjeta de plato: el borde lleva el color del alimento principal (--c) */
.dish-card {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 36px 8px 8px;
  border: 2px solid var(--c);
  border-radius: var(--radius);
  background: var(--surface);
  background: color-mix(in srgb, var(--c) 7%, var(--surface));
  cursor: grab; user-select: none;
  transition: box-shadow .12s;
}
.dish-card:hover { box-shadow: var(--shadow-1); }
.dish-card:active { cursor: grabbing; }
.dish-card.is-selected { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 40%, transparent); }
.dish-card__emoji {
  flex: none; width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--surface);
  font-size: 21px; line-height: 1;
}
.dish-card__body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dish-card__name { font-size: 13.5px; font-weight: 600; line-height: 1.25; }
.dish-card__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-2); }
.dish-card__edit {
  position: absolute; top: 50%; right: 6px;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border: none; border-radius: 50%;
  background: none; color: var(--text-3);
  transform: translateY(-50%);
  opacity: 0; transition: opacity .12s;
}
.dish-card__edit svg { width: 16px; height: 16px; }
.dish-card:hover .dish-card__edit,
.dish-card:focus-within .dish-card__edit { opacity: 1; }
.dish-card__edit:hover { background: var(--surface-3); color: var(--text); }
@media (hover: none) { .dish-card__edit { opacity: 1; } }

.group-tag { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; }
.group-tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.protein-icons { letter-spacing: 1px; }
.badge-single { white-space: nowrap; padding: 1px 7px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 10.5px; font-weight: 600; }
.badge-side { white-space: nowrap; padding: 1px 7px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); font-size: 10.5px; font-weight: 600; }

/* 6. CALENDARIO · VISTA MES ----------------------------------------------- */
.month {
  display: flex; flex-direction: column;
  min-height: 100%;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.month__dow,
.month__row { display: grid; grid-template-columns: 44px repeat(7, minmax(0, 1fr)); }
.month__dow { border-bottom: 1px solid var(--border); }
.month__dow span { padding: 10px 8px; text-align: center; font-size: 12px; font-weight: 600; color: var(--text-2); }
.month__grid { flex: 1; display: grid; grid-template-rows: repeat(var(--rows), minmax(150px, 1fr)); }
.month__row { border-bottom: 1px solid var(--border); }
.month__row:last-child { border-bottom: none; }
.month__row.is-focus { background: color-mix(in srgb, var(--primary) 5%, transparent); }

.week-tag {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 0;
  border: none; border-right: 1px solid var(--border);
  background: none; color: var(--text-3);
  font-size: 11px; font-weight: 600;
}
.week-tag:hover { background: var(--surface-2); }
.month__row.is-focus .week-tag { background: var(--primary-soft); color: var(--primary); }
.week-tag__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.week-tag.is-ok .week-tag__dot { background: var(--ok); }
.week-tag.has-issues .week-tag__dot { background: var(--danger); }

.month-cell {
  min-width: 0;
  display: flex; flex-direction: column; gap: 4px;
  padding: 6px;
  border-right: 1px solid var(--border);
  transition: background-color .12s;
}
.month-cell:last-child { border-right: none; }
.month-cell.is-outside { background: var(--surface-2); }
.month-cell.is-outside .day-num { color: var(--text-3); }
.month-cell.is-outside .chip { opacity: .7; }
.month-cell__head { display: flex; align-items: center; justify-content: space-between; min-height: 26px; }
.day-num {
  min-width: 26px; height: 26px; padding: 0 6px;
  border: none; border-radius: 999px;
  background: none;
  font-size: 12.5px; font-weight: 600;
}
.day-num:hover { background: var(--surface-3); }
.is-today .day-num { background: var(--primary); color: var(--on-primary); }
.cell-warn { font-size: 13px; color: var(--warn); cursor: help; }
/* Zona de comida / cena dentro de cada día */
.meal-zone {
  display: flex; flex-direction: column; gap: 3px;
  min-width: 0;
  border-radius: var(--radius-xs);
  transition: background-color .12s;
}
.meal-zone__label { display: none; padding: 1px 2px 0; font-size: 10.5px; font-weight: 600; color: var(--text-3); }
.meal-zone.has-items .meal-zone__label { display: block; }
body.dnd-active .meal-zone,
body.is-placing .meal-zone {
  min-height: 34px; padding: 3px;
  border: 1.5px dashed var(--border-strong);
}
body.dnd-active .meal-zone__label,
body.is-placing .meal-zone__label { display: block; }
.meal-zone.is-drop-target { background: var(--primary-soft); border-color: var(--primary) !important; }

.chip {
  position: relative;
  display: flex; align-items: flex-start; gap: 4px;
  min-width: 0;
  padding: 3px 18px 3px 5px;
  border: 1.5px solid var(--c);
  border-radius: var(--radius-xs);
  background: var(--surface);
  background: color-mix(in srgb, var(--c) 10%, var(--surface));
  font-size: 11.5px; line-height: 1.3;
  cursor: grab;
}
/* Etiqueta 1º/2º/G: oculta por espacio (el orden ya lo indica). Cambia display para mostrarla. */
.chip__course { display: none; flex: none; width: 15px; text-align: center; font-size: 9.5px; font-weight: 700; color: var(--text-3); }
.chip__emoji { flex: none; font-size: 13px; }
.chip__name {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  overflow: hidden; font-weight: 500; hyphens: auto;
}
.chip__remove,
.plan-card__remove {
  position: absolute;
  display: grid; place-items: center;
  padding: 0; border: none; border-radius: 4px;
  background: none; color: var(--text-2);
  opacity: 0; transition: opacity .12s;
}
.chip__remove { top: 50%; right: 1px; width: 18px; height: 18px; transform: translateY(-50%); }
.chip__remove svg { width: 13px; height: 13px; }
.chip:hover .chip__remove,
.chip:focus-within .chip__remove,
.plan-card:hover .plan-card__remove,
.plan-card:focus-within .plan-card__remove { opacity: 1; }
.chip__remove:hover,
.plan-card__remove:hover { background: var(--surface-3); color: var(--danger); }
@media (hover: none) { .chip__remove, .plan-card__remove { opacity: 1; } }

/* 7. CALENDARIO · VISTA SEMANA -------------------------------------------- */
.week {
  min-height: 100%;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.week__grid { display: grid; grid-template-columns: 88px repeat(7, minmax(104px, 1fr)); min-width: 816px; }
.week__corner,
.week__day-head { position: sticky; top: 0; z-index: 2; background: var(--surface); border-bottom: 1px solid var(--border); }
.week__day-head { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px 12px; border-left: 1px solid var(--border); }
.week__dow { font-size: 12px; font-weight: 600; color: var(--text-2); }
.week__date { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; font-size: 24px; font-weight: 450; }
.week__day-head.is-today .week__dow { color: var(--primary); }
.week__day-head.is-today .week__date { background: var(--primary); color: var(--on-primary); }

.week__meal-head {
  grid-column: 1 / -1;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px; font-weight: 700;
}
.week__row-label { padding: 14px 10px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--text-2); }
.week__row-label--muted { color: var(--text-3); font-weight: 500; }
.week-slot {
  display: flex;
  min-height: 104px; padding: 6px;
  border-left: 1px solid var(--border); border-bottom: 1px solid var(--border);
  transition: background-color .12s;
}
.week-slot__empty {
  flex: 1;
  display: grid; place-items: center;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  font-size: 12px; color: var(--text-3);
  opacity: 0; transition: opacity .15s;
}
.week-slot:hover .week-slot__empty,
body.dnd-active .week-slot__empty,
body.is-placing .week-slot__empty { opacity: 1; }
.week-slot__empty--covered { opacity: 1; padding: 6px; border-style: solid; border-color: var(--border); background: var(--surface-2); text-align: center; }

.plan-card {
  position: relative; flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  padding: 8px;
  border: 2px solid var(--c);
  border-radius: var(--radius);
  background: var(--surface);
  background: color-mix(in srgb, var(--c) 8%, var(--surface));
  cursor: grab;
}
.plan-card__emoji { font-size: 22px; line-height: 1; }
.plan-card__name { font-size: 13px; font-weight: 600; line-height: 1.25; }
.plan-card__meta { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 11px; color: var(--text-2); }
.plan-card__remove { top: 6px; right: 6px; width: 24px; height: 24px; }
.plan-card__remove svg { width: 15px; height: 15px; }

.week-notes { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-height: 48px; padding: 8px; border-left: 1px solid var(--border); }
.note-pill, .ok-pill { padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.note-pill { background: var(--warn-soft); color: var(--warn); }
.ok-pill { background: var(--ok-soft); color: var(--ok); }

/* 8. PANEL DE RESUMEN SEMANAL --------------------------------------------- */
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.panel-kicker { font-size: 12.5px; color: var(--text-2); }
.panel-title { margin-top: 2px; font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.panel-nav { display: flex; margin-right: -6px; }
.panel-sub { margin-top: 6px; font-size: 12.5px; color: var(--text-2); }
.day-dots { display: flex; gap: 4px; margin-top: 10px; }
.day-dots i { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-3); }
.day-dots i.is-on { background: var(--primary); }

.panel-section { margin-top: 24px; }
.panel-section h3 { margin-bottom: 10px; font-size: 13px; font-weight: 600; }

.nut-row {
  display: grid; grid-template-columns: 38px 1fr; gap: 10px; align-items: center;
  margin-bottom: 6px; padding: 10px;
  border: 1px solid transparent; border-radius: var(--radius);
  background: var(--surface-2);
}
.nut-row.is-over { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.nut-row__icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: var(--surface); font-size: 20px; }
.nut-row__top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.nut-row__label { font-size: 13px; font-weight: 600; }
.nut-row__count { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.is-over .nut-row__count { color: var(--danger); }
.nut-row__note { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--text-2); }
.status--over { color: var(--danger); font-weight: 600; }
.status--under { color: var(--warn); font-weight: 600; }
.status--ok { color: var(--ok); font-weight: 600; }

/* Barra de 7 "píldoras": una por día de la semana */
.pips { display: flex; gap: 3px; margin: 7px 0 5px; }
.pip { position: relative; flex: 1; height: 6px; border-radius: 3px; background: var(--surface-3); }
.pip.is-filled { background: var(--ok); }
.pip.is-filled.is-over { background: var(--danger); }
.pip.is-target { background: none; box-shadow: inset 0 0 0 1.5px var(--border-strong); }
.pip.is-limit { margin-right: 5px; }
.pip.is-limit::after { content: ""; position: absolute; top: -3px; right: -5px; width: 2px; height: 12px; border-radius: 1px; background: var(--text-3); }

.group-bar { display: flex; gap: 2px; height: 12px; overflow: hidden; border-radius: 999px; background: var(--surface-3); }
.group-bar span { background: var(--c); }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin-top: 10px; }
.legend__item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.legend__dot { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.legend__count { margin-left: auto; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }

.warn-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.warn-list li { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--warn-soft); font-size: 12.5px; }
.warn-list strong { color: var(--warn); }
.empty-note { font-size: 12.5px; color: var(--text-3); }
.guide { padding: 12px; border-radius: var(--radius); background: var(--surface-2); font-size: 12px; line-height: 1.5; color: var(--text-2); }

/* 9. DIÁLOGO DE PLATO ------------------------------------------------------ */
.dialog {
  width: min(540px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: none; border-radius: 20px;
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-2);
}
.dialog--sm { width: min(440px, calc(100vw - 32px)); }
.dialog--lg { width: min(760px, calc(100vw - 32px)); }
.dialog__text { font-size: 14px; color: var(--text-2); }
.preset-list { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding-top: 14px; border-top: 1px solid var(--border); }
.dialog::backdrop { background: rgba(15, 20, 30, .45); }
.dialog__form { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.dialog__head { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 6px 22px; }
.dialog__head h2 { font-size: 19px; font-weight: 600; }
.dialog__body { display: flex; flex-direction: column; gap: 18px; padding: 8px 22px 18px; overflow-y: auto; }
.dialog__foot { display: flex; align-items: center; gap: 8px; padding: 12px 22px 18px; border-top: 1px solid var(--border); }
.spacer { flex: 1; }
.dialog__preview { padding: 14px; border-radius: var(--radius); background: var(--surface-2); }
.dialog__preview .dish-card { pointer-events: none; padding-right: 10px; }
.dialog__preview .dish-card__edit { display: none; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; padding: 0; border: none; }
.field > span,
.field > legend { padding: 0; margin-bottom: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field small { font-weight: 400; color: var(--text-3); }
.field input[type="text"] {
  height: 42px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface);
}
.field textarea {
  min-height: 64px; padding: 10px 12px; resize: vertical;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); font: inherit; line-height: 1.4;
}
.field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field input[type="text"]:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field-row { display: flex; gap: 12px; }
.field--emoji { width: 78px; flex: none; }
.field--emoji input[type="text"] { text-align: center; font-size: 22px; }
.field--grow { flex: 1; }

.emoji-picker { display: flex; flex-wrap: wrap; gap: 4px; margin-top: -8px; }
.emoji-picker button { width: 34px; height: 34px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); font-size: 18px; line-height: 1; }
.emoji-picker button:hover { background: var(--surface-3); }

.choice-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice > span {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 13px;
  border: 1.5px solid var(--border-strong); border-radius: 999px;
  background: var(--surface);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
}
.choice .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.choice input:checked + span {
  border-color: var(--c, var(--primary));
  background: color-mix(in srgb, var(--c, var(--primary)) 13%, var(--surface));
}
.choice input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 13.5px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }

.choice--sm > span { height: 30px; padding: 0 11px; font-size: 12.5px; }
.choice-grid--sm { gap: 6px; }

/* Temporada */
.month-pills { display: flex; flex-wrap: wrap; gap: 4px; }
.month-pills button {
  height: 32px; min-width: 46px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text-2);
  font-size: 12.5px; font-weight: 600;
}
.month-pills button:hover { background: var(--surface-3); }
.month-pills button.is-active { border-color: transparent; background: var(--primary); color: var(--on-primary); }
.season-section h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 15px; font-weight: 600; }
.season-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.season-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2);
}
.season-item__emoji { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--surface); font-size: 20px; }
.season-item__name { font-size: 13.5px; font-weight: 600; }
.season-item--all { opacity: .75; }
.season-badge { margin-left: auto; padding: 2px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 600; white-space: nowrap; }
.season-badge--new { background: var(--ok-soft); color: var(--ok); }
.season-badge--last { background: var(--warn-soft); color: var(--warn); }
.season-badge--all { background: var(--surface-3); color: var(--text-2); }

/* 10. TOAST Y MODO "COLOCAR" ---------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60;
  display: flex; align-items: center; gap: 16px;
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  border-radius: 12px;
  background: #2B2F36; color: #FFFFFF;
  font-size: 13.5px;
  box-shadow: var(--shadow-2);
  opacity: 0; pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity .2s, transform .2s;
}
.toast.is-visible { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.toast__action { padding: 4px 6px; border: none; border-radius: 6px; background: none; color: #8AB4F8; font-weight: 600; }
.toast__action:hover { background: rgba(255, 255, 255, .08); }

.placing-banner {
  position: fixed; left: 50%; top: calc(var(--topbar-h) + 12px); z-index: 50;
  display: none; align-items: center; gap: 12px;
  padding: 7px 7px 7px 16px;
  border-radius: 999px;
  background: var(--text); color: var(--surface);
  font-size: 13px;
  box-shadow: var(--shadow-2);
  transform: translateX(-50%);
}
body.is-placing .placing-banner { display: flex; }
.placing-banner button { height: 30px; padding: 0 14px; border: none; border-radius: 999px; background: color-mix(in srgb, var(--surface) 18%, transparent); color: inherit; font-weight: 600; }
body.is-placing .meal-zone,
body.is-placing .week-slot { cursor: copy; }
body.is-placing .meal-zone:hover,
body.is-placing .week-slot:hover { background: var(--primary-soft); }

/* LISTA DE LA COMPRA ------------------------------------------------------- */
.panel-shop { margin-top: 14px; }
.shop-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.shop-toolbar .panel-nav { align-items: center; gap: 4px; margin: 0; }
.shop-week { min-width: 150px; text-align: center; font-size: 15px; }
.shop-meals { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.shop-empty { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 13px; color: var(--text-2); }
.shop-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.shop-col { display: flex; flex-direction: column; gap: 12px; padding: 14px; border-radius: var(--radius-lg); border: 1px solid var(--border); }
.shop-col--fresco { background: color-mix(in srgb, var(--ok) 6%, var(--surface)); }
.shop-col--despensa { background: var(--surface-2); }
.shop-col__head h3 { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; }
.shop-col__head h3 .lib-section__count { margin-left: 0; }
.shop-col__head p { margin-top: 2px; font-size: 12px; color: var(--text-2); }
.shop-group h4 { margin-bottom: 4px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.shop-group ul { margin: 0; padding: 0; list-style: none; }
.shop-item { display: flex; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.shop-item:last-child { border-bottom: none; }
.shop-item label { flex: 1; display: flex; align-items: flex-start; gap: 10px; min-width: 0; cursor: pointer; }
.shop-item input[type="checkbox"] { flex: none; width: 18px; height: 18px; margin-top: 1px; accent-color: var(--ok); }
.shop-item__text { display: flex; flex-direction: column; min-width: 0; }
.shop-item__name { font-size: 13.5px; font-weight: 500; }
.shop-item__name em { font-style: normal; font-size: 11.5px; font-weight: 700; color: var(--primary); }
.shop-item small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 11px; color: var(--text-3); }
.shop-item.is-checked .shop-item__name { color: var(--text-3); text-decoration: line-through; }
.shop-swap {
  flex: none; width: 28px; height: 28px;
  border: 1px solid var(--border); border-radius: 50%;
  background: var(--surface); font-size: 13px; line-height: 1;
  opacity: .55; transition: opacity .12s;
}
.shop-item:hover .shop-swap, .shop-swap:focus-visible { opacity: 1; }
@media (hover: none) { .shop-swap { opacity: 1; } }
.shop-add { display: grid; grid-template-columns: minmax(0, 1fr) 120px auto; gap: 8px; }
.shop-add input, .shop-add select {
  height: 36px; min-width: 0; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
}
.shop-actions { display: flex; align-items: center; gap: 8px; }
@media (max-width: 720px) {
  .shop-columns { grid-template-columns: 1fr; }
  .shop-add { grid-template-columns: 1fr 1fr; }
  .shop-add input { grid-column: 1 / -1; }
}

/* PRESUPUESTO -------------------------------------------------------------- */
.budget {
  grid-template-columns: 370px minmax(0, 1fr);
  gap: 20px; align-items: start;
  min-height: 0; overflow: auto;
  padding: 20px;
}
.budget__side { position: sticky; top: 0; }
.b-card {
  display: flex; flex-direction: column; gap: 14px;
  padding: 20px;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface);
}
.b-card__title { font-size: 17px; font-weight: 600; }
.b-card__subtitle { margin-top: 4px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.money-field { display: flex; flex-direction: column; gap: 6px; }
.money-field > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }

.name-input {
  height: 38px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface);
}
.name-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.money-input { position: relative; display: inline-flex; align-items: center; min-width: 0; }
.money-input input {
  width: 100%; height: 38px; padding: 0 26px 0 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface);
  text-align: right; font-variant-numeric: tabular-nums;
}
.money-input > span { position: absolute; right: 10px; color: var(--text-3); pointer-events: none; }
.money-input input:focus,
.fixed-item__name:focus,
.inline-add input:focus,
.wb-add input:focus,
.wb-add select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.money-input__big { height: 50px !important; font-size: 22px; font-weight: 600; padding-right: 34px !important; }
.money-field .money-input > span { right: 14px; font-size: 18px; }

.fixed-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.fixed-item, .inline-add { display: grid; grid-template-columns: minmax(0, 1fr) 100px 30px; gap: 6px; align-items: center; }
.fixed-item__name, .inline-add > input {
  height: 38px; min-width: 0; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.inline-add > input { background: var(--surface); border-style: dashed; border-color: var(--border-strong); }

.b-summary { display: flex; flex-direction: column; margin: 4px 0 0; padding-top: 12px; border-top: 1px solid var(--border); }
.b-summary > div { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 13.5px; }
.b-summary dt { color: var(--text-2); }
.b-summary dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.b-summary__total { margin: 4px 0; padding: 8px 10px !important; border-radius: var(--radius-sm); background: var(--primary-soft); }
.b-summary__total dt, .b-summary__total dd { color: var(--primary); font-weight: 700; }
.b-summary__left dd { font-size: 17px; color: var(--ok); }
.b-summary__left.is-above dd { color: var(--text); }
.b-note { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--text); font-size: 12.5px; }

.budget__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.budget__head h2 { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.budget__head p { max-width: 70ch; margin-top: 4px; font-size: 13px; color: var(--text-2); }
.week-budgets { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }

.wb-card {
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface);
}
.wb-card.is-current { border: 2px solid var(--primary); padding: 15px; }
.wb-card.is-done { background: var(--surface-2); }
.wb-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.wb-card__kicker { font-size: 12px; color: var(--text-3); }
.wb-card__head h3 { margin-top: 1px; font-size: 17px; font-weight: 600; }
.wb-state { padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.wb-state--current { background: var(--primary-soft); color: var(--primary); }
.wb-state--done { background: var(--surface-3); color: var(--text-2); }
.wb-state--next { border: 1px solid var(--border); color: var(--text-3); }

.wb-figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.wb-figures > div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.wb-figures span { font-size: 11.5px; color: var(--text-2); }
.wb-figures strong { font-size: 15.5px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wb-figures small { font-size: 11px; color: var(--text-3); }
.wb-figures__left strong { color: var(--ok); }
.wb-card.is-above .wb-figures__left strong { color: var(--text-2); }
.wb-card.is-praised .wb-state { background: var(--ok-soft); color: var(--ok); border-color: transparent; }

.wb-bar { height: 8px; overflow: hidden; border-radius: 999px; background: var(--surface-3); }
.wb-bar span { display: block; height: 100%; border-radius: inherit; background: var(--ok); transition: width .25s; }
.wb-card.is-above .wb-bar span { background: var(--warn); }
.wb-note { padding: 7px 10px; border-radius: var(--radius-sm); font-size: 12px; }
.wb-note--above { background: var(--surface-3); color: var(--text-2); }
.wb-note--ok { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.wb-card__summary, .wb-card__activity { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.wb-expenses { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--border); }
.wb-exp { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto 24px; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--border); }
.wb-exp__emoji { font-size: 18px; text-align: center; }
.wb-exp__name { display: flex; flex-direction: column; min-width: 0; font-size: 13px; font-weight: 500; }
.wb-exp__name small { font-size: 11px; font-weight: 400; color: var(--text-3); }
.wb-exp__amount { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.wb-exp--capricho .wb-exp__amount { color: var(--warn); }

.wb-add { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: var(--radius); background: var(--surface-2); }
.wb-card.is-done .wb-add { background: var(--surface); }
.wb-add > input, .wb-add select {
  height: 36px; min-width: 0; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface);
}
.wb-add__row { display: grid; grid-template-columns: 88px minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.wb-add .money-input input { height: 36px; }

/* DISPOSICIÓN: CUADROS (grid) / LÍNEAS (list) ------------------------------
   .layout-auto usa cuadros en horizontal (landscape) y líneas en vertical (portrait). */

/* Biblioteca en cuadros */
.layout-grid .lib-section__items { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.layout-grid .dish-card { flex-direction: column; justify-content: center; gap: 6px; min-height: 124px; padding: 12px 8px; text-align: center; }
.layout-grid .dish-card__emoji { width: 44px; height: 44px; font-size: 26px; }
.layout-grid .dish-card__meta { justify-content: center; }
.layout-grid .dish-card__edit { top: 6px; transform: none; }
/* Presupuesto en líneas */
.week-budgets.layout-list { grid-template-columns: 1fr; }
.layout-list .wb-card { display: grid; grid-template-columns: 170px minmax(0, 1fr) minmax(0, 1.15fr); gap: 20px; align-items: start; }
.layout-list .wb-card__head { flex-direction: column; }

@media (orientation: landscape) {
  .layout-auto .lib-section__items { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
  .layout-auto .dish-card { flex-direction: column; justify-content: center; gap: 6px; min-height: 124px; padding: 12px 8px; text-align: center; }
  .layout-auto .dish-card__emoji { width: 44px; height: 44px; font-size: 26px; }
  .layout-auto .dish-card__meta { justify-content: center; }
  .layout-auto .dish-card__edit { top: 6px; transform: none; }
}
@media (orientation: portrait) {
  .week-budgets.layout-auto { grid-template-columns: 1fr; }
}
@media (orientation: portrait) and (min-width: 721px) {
  .layout-auto .wb-card { display: grid; grid-template-columns: 170px minmax(0, 1fr) minmax(0, 1.15fr); gap: 20px; align-items: start; }
  .layout-auto .wb-card__head { flex-direction: column; }
}
@media (max-width: 900px) {
  .layout-list .wb-card { display: flex; }
  .layout-list .wb-card__head { flex-direction: row; }
}

/* 11. DRAG & DROP ---------------------------------------------------------- */
.is-dragging { opacity: .45; }
.week-slot.is-drop-target { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--primary); }

.trash-zone {
  position: absolute; inset: 8px; z-index: 5;
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 24px; text-align: center;
  border: 2px dashed var(--danger); border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--danger); font-weight: 600;
  pointer-events: none;
}
.trash-zone svg { width: 32px; height: 32px; }
body.dnd-plan .trash-zone { display: flex; }
.library.is-drop-target .trash-zone { background: var(--danger-soft); }

/* 12. RESPONSIVE ----------------------------------------------------------- */
@media (max-width: 1360px) {
  :root { --sidebar-w: 276px; --panel-w: 280px; }
  .btn__label { display: none; }
  #btn-autofill, #btn-season, #btn-shopping { width: 36px; padding: 0; }
}

@media (max-width: 1080px) {
  .app { display: flex; flex-direction: column; height: auto; min-height: 100vh; }
  .topbar { position: sticky; top: 0; z-index: 20; flex-wrap: wrap; row-gap: 8px; padding: 10px 12px; }
  .brand { width: auto; }
  .brand__name { display: none; }
  .library { max-height: 360px; border-right: none; border-bottom: 1px solid var(--border); }
  .calendar { overflow: visible; padding: 12px; }
  .nutrition { border-left: none; border-top: 1px solid var(--border); }
  .app.mode-budget .budget { grid-template-columns: 1fr; overflow: visible; padding: 12px; }
  .budget__side { position: static; }
  .tabs button.is-active::after { display: none; }
  .tabs button.is-active { background: var(--primary-soft); }
  .placing-banner { top: auto; bottom: 84px; }
}

@media (max-width: 720px) {
  .period-title { font-size: 18px; }
  .month { overflow-x: auto; }
  .month__dow, .month__row { min-width: 760px; }
  .toolbar-group { border-left: none; padding-left: 0; }
}

/* 13. IMPRESIÓN ------------------------------------------------------------ */
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  :root { color-scheme: light; }
  body { background: #FFFFFF; }
  .app { display: block; height: auto; }
  .library, .nutrition, .toolbar-group, .segmented, #btn-today, #btn-autofill,
  .nav-arrows, .toast, .placing-banner, .chip__remove, .plan-card__remove, .tabs, .wb-add, .inline-add,
  .week-slot__empty, .week-tag, .cell-warn { display: none !important; }
  .topbar { height: auto; padding: 0 0 8px; border: none; }
  .calendar { overflow: visible; padding: 0; }
  .app.mode-budget .budget { display: block; overflow: visible; padding: 0; }
  .budget__side { position: static; margin-bottom: 12px; }
  .wb-card, .b-card { break-inside: avoid; }
  .month, .week { border-radius: 0; }
  .month__dow, .month__row { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .month__grid { grid-template-rows: repeat(var(--rows), minmax(96px, auto)); }
  .chip__name { white-space: normal; }
  .week__grid { min-width: 0; grid-template-columns: 80px repeat(7, minmax(0, 1fr)); }
  .chip, .plan-card, .month__row, .is-today .day-num {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
