/* ======================================================================
   Nutrition Platform · Sistema de diseño
   Fondos cálidos, verde oscuro para navegación y acciones, verde suave
   para indicadores, grafito para textos, naranja discreto para alertas.
   ====================================================================== */

:root {
  --bg:          #F6F4EF;
  --bg-2:        #EFECE5;
  --surface:     #FFFFFF;
  --surface-2:   #F7F6F2;
  --border:      #E4E0D6;
  --border-2:    #D6D1C5;

  --text:        #27343A;
  --text-2:      #5C686D;
  --text-3:      #8A9397;

  --brand:       #1E4A3B;
  --brand-2:     #173A2E;
  --brand-ink:   #FFFFFF;
  --brand-soft:  #E5EFE8;
  --brand-line:  #BFD6C7;

  --ind-1:       #2F5D4E;   /* proteínas / principal  */
  --ind-2:       #7FA58C;   /* hidratos / secundario  */
  --ind-3:       #D4A35A;   /* grasas                 */
  --ind-4:       #A9BFB1;

  --ok:          #2F7A55;
  --ok-bg:       #E4F2EA;
  --warn:        #B4651F;
  --warn-bg:     #FBF0E3;
  --warn-line:   #F0D3AF;
  --crit:        #A8402C;
  --crit-bg:     #FAE8E3;
  --crit-line:   #EFC3B8;
  --info:        #2D6289;
  --info-bg:     #E7F0F7;

  --radius:      12px;
  --radius-sm:   8px;
  --radius-lg:   16px;
  --shadow:      0 1px 2px rgba(39,52,58,.05), 0 1px 1px rgba(39,52,58,.03);
  --shadow-lg:   0 10px 30px rgba(39,52,58,.10);

  --sidebar-w:   236px;
  --topbar-h:    60px;
  --font:        "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono:        "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;
  --fs:          14.5px;

  color-scheme: light;
}

:root[data-text="sm"] { --fs: 13.5px; }
:root[data-text="lg"] { --fs: 16.5px; }

/* El tema "sistema" se resuelve en el <head> a light/dark antes de pintar. */
:root[data-theme="dark"] {
  --bg:         #141A1C;
  --bg-2:       #1A2124;
  --surface:    #1C2427;
  --surface-2:  #222B2E;
  --border:     #2D373B;
  --border-2:   #3A464A;
  --text:       #E7E9E6;
  --text-2:     #A9B2B3;
  --text-3:     #7F898B;
  --brand:      #3E8B6E;
  --brand-2:    #4FA083;
  --brand-ink:  #0F1A16;
  --brand-soft: #1F3530;
  --brand-line: #2E5246;
  --ind-1:      #5FA88C;
  --ind-2:      #8FB89D;
  --ind-3:      #D9AE68;
  --ok:         #6CC197;
  --ok-bg:      #1C3329;
  --warn:       #E39A57;
  --warn-bg:    #352816;
  --warn-line:  #5B4122;
  --crit:       #EC8F7B;
  --crit-bg:    #3A201B;
  --crit-line:  #5E3128;
  --info:       #7DB3DA;
  --info-bg:    #182A38;
  --shadow:     0 1px 2px rgba(0,0,0,.3);
  --shadow-lg:  0 10px 30px rgba(0,0,0,.45);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  font-feature-settings: "tnum" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
small, .small { font-size: .86rem; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.mono { font-family: var(--mono); font-size: .9em; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; border-radius: 4px; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.icon-sm { width: 15px; height: 15px; }

/* ----------------------------------------------------------------------
   Estructura del panel profesional
   ---------------------------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--brand-2);
  color: #DCE7E1;
  display: flex; flex-direction: column;
  padding: 18px 12px;
  overflow-y: auto;
}
:root[data-theme="dark"] .sidebar { background: #10191A; border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; color: #fff; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: #CFE3D7; color: var(--brand-2);
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
}
.brand-name { font-weight: 650; font-size: 1rem; line-height: 1.1; }
.brand-logo { height: 30px; width: auto; display: block; }
.brand-icon { display: none; width: 34px; height: 34px; border-radius: 9px; }
.login-consult { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.login-consult img { height: 64px; max-width: 260px; object-fit: contain; object-position: left center; }
.brand-sub { font-size: .74rem; color: #9FB8AC; letter-spacing: .02em; }

.nav-group { margin-bottom: 18px; }
.nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #86A397; padding: 0 12px 6px; }
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 12px; border-radius: 9px;
  color: #D3E1DA; font-weight: 500; font-size: .95rem;
}
.nav-link:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.nav-link.active { background: rgba(207,227,215,.16); color: #fff; box-shadow: inset 3px 0 0 #9FD0B6; }
.nav-link .badge { margin-left: auto; }
.nav-soon { opacity: .5; pointer-events: none; }
.nav-soon::after { content: "pronto"; margin-left: auto; font-size: .68rem; border: 1px solid rgba(255,255,255,.25); border-radius: 99px; padding: 0 6px; }

.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.user-chip .avatar { background: #CFE3D7; color: var(--brand-2); }
.user-chip-name { color: #fff; font-weight: 600; font-size: .9rem; line-height: 1.2; }
.user-chip-role { color: #9FB8AC; font-size: .76rem; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-search { flex: 1; max-width: 420px; position: relative; }
.topbar-search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.topbar-search input[type="search"] { padding-left: 36px; background: var(--surface); }
.topbar-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.content { padding: 26px 28px 60px; max-width: 1360px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.crumbs { font-size: .84rem; color: var(--text-3); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.crumbs a { color: var(--text-2); }

/* Navegación inferior: móvil en el panel, siempre en el portal del paciente */
.bottom-nav {
  display: none; grid-template-columns: repeat(5, 1fr);
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
}
.bottom-nav.always { display: grid; }
.bottom-nav.always > * { max-width: 150px; justify-self: center; width: 100%; }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .7rem; color: var(--text-2); padding: 4px 0; border-radius: 8px; }
.bottom-nav a.active { color: var(--brand); font-weight: 600; }
.bottom-nav a:hover { text-decoration: none; color: var(--text); }
.bottom-nav .icon { width: 21px; height: 21px; }

@media (max-width: 1024px) {
  :root { --sidebar-w: 76px; }
  .brand-name, .brand-sub, .nav-label, .nav-link span, .nav-link .badge, .user-chip > div, .nav-soon::after, .brand-logo { display: none; }
  .brand-icon { display: block; }
  .brand { justify-content: center; padding-inline: 0; }
  .nav-link { justify-content: center; padding: 10px; }
  .user-chip { justify-content: center; }
}
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: 0 16px; }
  .content { padding: 18px 16px 96px; }
  .bottom-nav { display: grid; }
  .hide-mobile { display: none !important; }
}
@media (min-width: 721px) { .show-mobile { display: none !important; } }

/* ----------------------------------------------------------------------
   Componentes
   ---------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { font-size: 1rem; }
.card-body { padding: 18px 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.eyebrow { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 600; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; gap: 18px; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; }
.split-rev { display: grid; gap: 18px; grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); align-items: start; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 960px) {
  .split, .split-rev { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Indicadores */
.stat { padding: 16px 18px; }
.stat-label { font-size: .82rem; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 1.85rem; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-unit { font-size: .82rem; color: var(--text-3); font-weight: 500; margin-left: 2px; }
.stat-foot { font-size: .8rem; color: var(--text-3); margin-top: 4px; }
.stat-soft { background: var(--brand-soft); border-color: var(--brand-line); }
.stat-soft .stat-value { color: var(--brand-2); }
:root[data-theme="dark"] .stat-soft .stat-value { color: var(--ok); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.kv-left dd { text-align: left; font-weight: 500; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0; }
.metric { padding: 14px 18px; border-right: 1px solid var(--border); }
.metric:last-child { border-right: 0; }
.metric-label { font-size: .8rem; color: var(--text-2); }
.metric-value { font-size: 1.5rem; font-weight: 650; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.metric-sub { font-size: .78rem; color: var(--text-3); }
@media (max-width: 600px) { .metric { border-right: 0; border-bottom: 1px solid var(--border); } }

/* Barras */
.bar { height: 8px; background: var(--bg-2); border-radius: 99px; overflow: hidden; position: relative; }
.bar > span { display: block; height: 100%; background: var(--ind-1); border-radius: 99px; transition: width .35s ease; }
.bar-2 > span { background: var(--ind-2); }
.bar-3 > span { background: var(--ind-3); }
.bar-range { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--ok) 22%, transparent); border-left: 1.5px solid var(--ok); border-right: 1.5px solid var(--ok); }
.stacked { display: flex; height: 14px; border-radius: 99px; overflow: hidden; background: var(--bg-2); }
.stacked > span { height: 100%; transition: width .35s ease; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--text-2); }
.dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: 0; }

/* Etiquetas */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .76rem; font-weight: 600;
  padding: 2px 9px; border-radius: 99px;
  background: var(--bg-2); color: var(--text-2);
  white-space: nowrap; line-height: 1.6;
}
.badge-ok    { background: var(--ok-bg);    color: var(--ok); }
.badge-warn  { background: var(--warn-bg);  color: var(--warn); }
.badge-crit, .badge-alert { background: var(--crit-bg); color: var(--crit); }
.badge-info  { background: var(--info-bg);  color: var(--info); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.badge-neutral { background: var(--bg-2); color: var(--text-2); }
.badge-outline { background: transparent; border: 1px solid var(--border-2); }

/* Alertas */
.alert { display: flex; gap: 10px; padding: 11px 14px; border-radius: var(--radius-sm); border: 1px solid; font-size: .92rem; align-items: flex-start; }
.alert .icon { margin-top: 2px; }
.alert-warning { background: var(--warn-bg); border-color: var(--warn-line); color: var(--text); }
.alert-warning .icon { color: var(--warn); }
.alert-critical, .alert-error { background: var(--crit-bg); border-color: var(--crit-line); color: var(--text); }
.alert-critical .icon, .alert-error .icon { color: var(--crit); }
.alert-success { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.alert-success .icon { color: var(--ok); }
.alert-info { background: var(--info-bg); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.alert-info .icon { color: var(--info); }
.alerts > * + * { margin-top: 8px; }
.flash-stack { position: fixed; top: 72px; right: 20px; z-index: 60; width: min(420px, calc(100vw - 32px)); display: grid; gap: 8px; }
.flash-stack .alert { box-shadow: var(--shadow-lg); animation: slidein .25s ease; }
@keyframes slidein { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }
.note { font-size: .82rem; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 16px;
  border-radius: 9px; border: 1px solid var(--border-2);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; font-size: .93rem;
  cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--text); }
.btn-danger { color: var(--crit); }
.btn-sm { height: 32px; padding: 0 11px; font-size: .86rem; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 1rem; }
.btn-icon { width: 38px; padding: 0; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

[hidden] { display: none !important; }
/* Tablas de intercambio */
.exch-table td { vertical-align: middle; }
.exch-grams { display: inline-flex; align-items: center; gap: 4px; margin: 0; }
.exch-grams input { width: 76px; height: 32px; text-align: right; }
.exch-portal summary { cursor: pointer; list-style: none; }
.exch-portal summary::-webkit-details-marker { display: none; }
.print-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.print-table td { padding: 4px 6px; border-bottom: 1px solid var(--border); }
/* Micronutrientes (ficha del alimento y editor del plan) */
.micro-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 16px; }
.micro-panel summary { cursor: pointer; list-style: none; }
.micro-panel summary::-webkit-details-marker { display: none; }
.micro-table { width: 100%; font-size: .82rem; border-collapse: collapse; }
.micro-table td { padding: 4px 2px; border-top: 1px solid var(--border); vertical-align: middle; }
.micro-table td.num { text-align: right; white-space: nowrap; }
.micro-bar { height: 3px; background: var(--bg-2); border-radius: 2px; margin-top: 2px; }
.micro-bar span { display: block; height: 100%; background: currentColor; border-radius: 2px; }
/* Asistente clínico y cambios con palabras */
.asst-thread { display: flex; flex-direction: column; gap: 8px; max-height: 460px; overflow-y: auto; margin-bottom: 10px; }
.asst-msg { padding: 9px 12px; border-radius: 12px; max-width: 92%; font-size: .9rem; line-height: 1.45; }
.asst-msg p { margin: 0 0 6px; } .asst-msg p:last-child { margin: 0; }
.asst-msg ul { margin: 4px 0 6px 18px; padding: 0; }
.asst-user { align-self: flex-end; background: var(--brand); color: var(--brand-ink, #fff); }
.asst-bot { align-self: flex-start; background: var(--bg-2); }
.asst-pending { opacity: .7; }
.asst-form { display: flex; gap: 8px; align-items: flex-end; }
.asst-form textarea { flex: 1; resize: vertical; }
.ai-edit { display: flex; gap: 8px; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.ai-edit input { flex: 1; min-width: 200px; }
/* Formularios */
label { display: block; font-size: .87rem; font-weight: 550; color: var(--text); margin-bottom: 5px; }
.hint { font-size: .78rem; color: var(--text-3); margin-top: 4px; }
input:not([type]), input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="time"], input[type="search"], input[type="tel"], select, textarea {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-2); border-radius: 9px;
  font: inherit; font-size: .95rem;
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238A9397' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
input[readonly] { background: var(--surface-2); color: var(--text-2); }
.field { margin-bottom: 14px; }
.fields { display: grid; gap: 14px 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fields-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fields-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fields .full { grid-column: 1 / -1; }
.fields .field { margin: 0; }
@media (max-width: 760px) { .fields-3, .fields-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .fields, .fields-3, .fields-4 { grid-template-columns: 1fr; } }
.input-unit { position: relative; }
.input-unit input { padding-right: 52px; }
.sticky-col { position: sticky; top: calc(var(--topbar-h) + 16px); }
@media (max-width: 960px) { .sticky-col { position: static; } }
.input-unit span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: .84rem; pointer-events: none; }
.check { display: flex; gap: 9px; align-items: flex-start; font-weight: 500; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--brand); width: 16px; height: 16px; }
fieldset { border: 0; padding: 0; margin: 0 0 18px; }
legend { font-weight: 650; font-size: .98rem; margin-bottom: 10px; padding: 0; }

/* Selector segmentado */
.segmented { display: inline-flex; background: var(--bg-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label { margin: 0; padding: 6px 13px; border-radius: 8px; cursor: pointer; font-weight: 550; font-size: .88rem; color: var(--text-2); }
.segmented input:checked + label { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented input:focus-visible + label { outline: 2px solid var(--brand); }

/* Opciones en tarjeta */
.choice-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; }
.choice label {
  display: block; margin: 0; padding: 12px 14px; height: 100%;
  border: 1px solid var(--border-2); border-radius: 11px; cursor: pointer;
  background: var(--surface); font-weight: 600;
}
.choice label small { display: block; font-weight: 400; color: var(--text-2); margin-top: 2px; }
.choice input:checked + label { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.choice input:focus-visible + label { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Deslizadores */
input[type="range"] { width: 100%; accent-color: var(--brand); height: 22px; }
.slider-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.slider-row output { font-weight: 650; font-variant-numeric: tabular-nums; min-width: 72px; text-align: right; }

/* Tablas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.row-link { cursor: pointer; }

/* Avatar */
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: .82rem; flex: none; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.1rem; }
.person { display: flex; align-items: center; gap: 11px; }
.person-name { font-weight: 600; color: var(--text); }
.person-sub { font-size: .82rem; color: var(--text-2); }

/* Pestañas */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; margin-bottom: 18px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 10px 14px; color: var(--text-2); font-weight: 550; border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; background: none; border-top: 0; border-left: 0; border-right: 0; font: inherit; cursor: pointer; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 650; }
.tab-panel[hidden] { display: none; }

/* Pasos de la evaluación */
.stepper { display: grid; grid-template-columns: repeat(var(--n, 6), 1fr); gap: 6px; margin: 14px 0 6px; }
.stepper a { height: 5px; border-radius: 99px; background: var(--bg-2); display: block; }
.stepper a.done { background: var(--brand); }
.stepper a.current { background: var(--ind-2); }
.step-list { list-style: none; margin: 0; padding: 0; }
.step-list li a { display: flex; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text-2); align-items: flex-start; }
.step-list li a:hover { background: var(--bg-2); text-decoration: none; }
.step-list li.current a { background: var(--brand-soft); color: var(--text); }
.step-num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 700; border: 1.5px solid var(--border-2); flex: none; background: var(--surface); }
.step-list li.done .step-num { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.step-list li.current .step-num { border-color: var(--brand); color: var(--brand); }
.step-title { font-weight: 600; color: var(--text); display: block; line-height: 1.3; }
.step-desc { font-size: .8rem; }
.form-actions { display: flex; gap: 10px; justify-content: space-between; align-items: center; flex-wrap: wrap; padding-top: 18px; margin-top: 8px; border-top: 1px solid var(--border); }
.calc-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 14px 16px; }

/* Fórmulas */
.formula { font-family: var(--mono); font-size: .84rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; overflow-x: auto; white-space: nowrap; color: var(--text); }
.calc-steps { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.calc-steps li { position: relative; padding: 0 0 16px 34px; counter-increment: s; }
.calc-steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-size: .75rem; font-weight: 700; display: grid; place-items: center; }
.calc-steps li::after { content: ""; position: absolute; left: 10.5px; top: 26px; bottom: 4px; width: 1px; background: var(--border); }
.calc-steps li:last-child::after { display: none; }
.calc-steps strong { display: block; margin-bottom: 5px; font-size: .92rem; }
.calc-steps .muted { font-size: .82rem; margin-top: 5px; }
details.disclosure { border: 1px solid var(--border); border-radius: 11px; background: var(--surface); }
details.disclosure > summary { cursor: pointer; padding: 13px 16px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::after { content: "+"; color: var(--text-3); font-size: 1.2rem; font-weight: 400; }
details.disclosure[open] > summary::after { content: "−"; }
details.disclosure > div { padding: 0 16px 16px; }

/* Listas */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 11px 0; border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.list-pad > li { padding: 12px 20px; }
.empty { text-align: center; padding: 36px 20px; color: var(--text-2); }
.empty .icon { width: 30px; height: 30px; color: var(--text-3); margin-bottom: 8px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 18px 22px; }
.timeline li::before { content: ""; position: absolute; left: 0; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--brand); }
.timeline li::after { content: ""; position: absolute; left: 4px; top: 18px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }

/* Gráfico */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-text { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .line { fill: none; stroke: var(--ind-1); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--ind-1); opacity: .08; }
.chart .pt { fill: var(--surface); stroke: var(--ind-1); stroke-width: 2; }
.chart .target { stroke: var(--ind-3); stroke-dasharray: 4 4; stroke-width: 1.5; }

/* Pantalla de acceso */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-aside { background: var(--brand-2); color: #DCE7E1; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-aside h1 { color: #fff; font-size: 2rem; max-width: 460px; margin-top: 40px; }
.auth-aside p { color: #AFC6BB; max-width: 440px; font-size: 1.02rem; }
.auth-principles { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; max-width: 440px; }
.auth-principles li { display: flex; gap: 12px; align-items: flex-start; color: #CFE0D7; }
.auth-principles .icon { color: #9FD0B6; margin-top: 2px; }
.auth-main { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 1.5rem; margin-bottom: 6px; }
.profile-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 22px 0 18px; }
.demo-box { margin-top: 22px; font-size: .84rem; }
.demo-box button { all: unset; cursor: pointer; display: flex; justify-content: space-between; width: 100%; padding: 7px 10px; border-radius: 7px; box-sizing: border-box; }
.demo-box button:hover { background: var(--bg-2); }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth-aside { display: none; } }

/* Portal del paciente */
.portal { max-width: 760px; margin: 0 auto; padding: 20px 16px 110px; }
.portal-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 0 20px; }
.portal-hero { background: var(--brand-2); color: #E2ECE6; border-radius: 22px; padding: 24px; position: relative; overflow: hidden; }
.portal-hero h1 { color: #fff; font-size: 1.5rem; }
.portal-hero .hero-num { font-size: 2.6rem; font-weight: 700; color: #fff; letter-spacing: -.02em; line-height: 1; }
.portal .card { border-radius: 20px; }
.ring { width: 92px; height: 92px; }
.ring circle { fill: none; stroke-width: 9; }
.ring .track { stroke: rgba(255,255,255,.15); }
.ring .val { stroke: #9FD0B6; stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; }
.meal-card { display: flex; gap: 14px; align-items: center; padding: 14px 16px; }
.meal-time { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--brand); min-width: 52px; }

/* Asistente / panel lateral */
.panel-note { border-left: 3px solid var(--brand); padding: 8px 12px; background: var(--brand-soft); border-radius: 0 8px 8px 0; font-size: .88rem; }

/* Utilidades */
.mt-0 { margin-top: 0 !important; } .mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 18px; } .mt-4 { margin-top: 26px; }
.mb-0 { margin-bottom: 0 !important; } .mb-1 { margin-bottom: 6px; } .mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 18px; }
.p-0 { padding: 0 !important; }
.text-right { text-align: right; }
.text-ok { color: var(--ok); } .text-warn { color: var(--warn); } .text-crit { color: var(--crit); }
.w-100 { width: 100%; }
.divider { height: 1px; background: var(--border); margin: 16px 0; border: 0; }
.is-loading { opacity: .55; transition: opacity .2s; }

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

/* ===================== V2 · Sistema clínico ===================== */
.text-brand { color: var(--brand); }
.is-muted { opacity: .6; }
.grow { flex: 1; min-width: 0; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.inline { display: inline; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; text-decoration: underline; }
.link-btn:hover { color: var(--brand-2); }
textarea.code, pre.code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .82rem; line-height: 1.45; }
pre.code { background: var(--bg-2); border-radius: var(--radius-sm); padding: 12px; overflow-x: auto; white-space: pre; margin: 0; }
textarea.code.is-invalid { border-color: var(--crit); box-shadow: 0 0 0 3px var(--crit-bg); }

/* Alertas con revisión */
.alert-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.alert-reviewed { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.alert-reviewed .icon { color: var(--ok); }
.alert-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.alert-actions input[type="text"] { flex: 1 1 180px; height: 32px; font-size: .86rem; padding: 0 10px; min-width: 0; }

/* Interacciones fármaco-nutriente */
.interaction { border-left: 3px solid var(--info); background: var(--info-bg); padding: 8px 12px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: .88rem; }
.interaction-warning { border-left-color: var(--warn); background: var(--warn-bg); }
.interaction-critical { border-left-color: var(--crit); background: var(--crit-bg); }

/* Carga de laboratorio */
.lab-inputs { display: grid; gap: 10px; grid-template-columns: 1fr; }
.lab-input { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 10px; align-items: center; font-size: .9rem; }
.lab-input small { display: block; color: var(--text-3); font-size: .76rem; }
.lab-input input { height: 36px; }
.lab-input input.is-high, .lab-input input.is-low { border-color: var(--warn); background: var(--warn-bg); }
.lab-input input.is-normal { border-color: var(--ok); }
/* Valores propuestos por la IA: resaltados hasta que se revisan */
.lab-input input.ai-filled { box-shadow: 0 0 0 2px var(--brand); }
.lab-input .ai-src { color: var(--brand); }
input.ai-missing { border-color: var(--warn); background: var(--warn-bg); }
/* Análisis adjuntos */
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { padding: 10px 0; border-top: 1px solid var(--border); }
.doc-list li:first-child { border-top: 0; }
.doc-list li.is-current { background: var(--bg-2); margin: 0 -16px; padding: 10px 16px; }
.doc-main { display: flex; gap: 8px; align-items: flex-start; min-width: 0; }
.doc-info { min-width: 0; overflow-wrap: anywhere; }
.doc-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.doc-actions form { margin: 0; }

/* Minigráfico */
.spark { display: block; overflow: visible; }
.spark-band { fill: var(--ok-bg); }
.spark-line { fill: none; stroke: var(--brand); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.spark-pt { fill: var(--brand); }

/* Catálogo */
.card-link { display: block; color: inherit; transition: border-color .15s, box-shadow .15s; }
.card-link:hover { text-decoration: none; border-color: var(--brand); box-shadow: var(--shadow-sm, 0 2px 8px rgb(0 0 0 / .06)); }
.rule-list { list-style: none; padding: 0; margin: 0; }
.rule-list li + li { margin-top: 3px; }

@media (max-width: 960px) {
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .catalog-grid { grid-template-columns: 1fr; }
  .lab-input { grid-template-columns: minmax(0, 1fr) 130px; }
}

/* ===================== V3 · Planes alimentarios ===================== */
.planner { display: grid; gap: 18px; grid-template-columns: 280px minmax(0, 1fr) 320px; align-items: start; }
.planner.is-readonly { grid-template-columns: minmax(0, 1fr) 320px; }
.planner > * { min-width: 0; }

/* Panel de alimentos */
.food-panel { position: sticky; top: calc(var(--topbar-h) + 16px); max-height: calc(100vh - var(--topbar-h) - 32px); display: flex; flex-direction: column; overflow: hidden; }
.food-panel-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--border); }
.food-panel-head h2 { font-size: 1rem; }
.food-panel .topbar-search { max-width: none; }
.food-panel-close { display: none; }
.food-panel-foot { padding: 8px 14px 12px; margin: 0; border-top: 1px solid var(--border); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chips .chip { border: 1px solid var(--border-2); background: var(--surface); color: var(--text-2); border-radius: 999px; padding: 3px 10px; font: inherit; font-size: .78rem; cursor: pointer; }
.chips .chip:hover { border-color: var(--brand); color: var(--text); }
.chips .chip.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.select-sm { height: 32px; font-size: .86rem; padding: 0 28px 0 10px; }
.food-list { list-style: none; margin: 0; padding: 4px 6px; overflow-y: auto; flex: 1; }
.food-row { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: var(--radius-sm); cursor: grab; }
.food-row:hover { background: var(--surface-2); }
.food-row:active { cursor: grabbing; }
.fr-main { flex: 1; min-width: 0; }
.fr-name { font-weight: 550; font-size: .9rem; line-height: 1.25; }
.food-row.is-excluded { opacity: .62; }

/* Comidas */
.meals { display: grid; gap: 14px; }
.plan-meal { padding: 14px 16px 10px; transition: border-color .15s, box-shadow .15s; }
.plan-meal.drop-over { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.planner.is-dragging .plan-meal { border-style: dashed; }
.plan-meal.confirm-del { border-color: var(--crit); }
.meal-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.meal-head input.meal-name { font-weight: 650; font-size: 1.02rem; border-color: transparent; background: transparent; padding: 0 6px; height: 34px; width: auto; flex: 1 1 140px; min-width: 0; margin-left: -6px; }
.meal-head input.meal-name:hover, .meal-head input.meal-name:focus { border-color: var(--border-2); background: var(--surface); }
.meal-head h3.meal-name { flex: 1; font-size: 1.02rem; }
.meal-head input.pm-time { width: 104px; height: 32px; font-size: .86rem; padding: 0 8px; }
.meal-kcal { font-size: .92rem; white-space: nowrap; }
.meal-actions { display: flex; gap: 2px; }
.meal-bar { position: relative; height: 5px; background: var(--bg-2); border-radius: 99px; margin: 10px 0 6px; }
.meal-bar span { position: absolute; inset: 0 auto 0 0; background: var(--ind-1, var(--brand)); border-radius: 99px; }
.meal-bar.is-near span { background: var(--warn); }
.meal-bar.is-off span { background: var(--crit); }
.meal-bar i, .tbar-track i { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text-2); border-radius: 2px; }
.meal-macros { margin-bottom: 6px; }
.meal-items { list-style: none; margin: 0; padding: 0; }
.meal-empty { padding: 18px; text-align: center; color: var(--text-3); font-size: .88rem; border: 1px dashed var(--border-2); border-radius: var(--radius-sm); margin: 6px 0; }
.meal-item { display: grid; grid-template-columns: auto minmax(0, 1fr) 92px 96px auto; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--border); }
.is-readonly .meal-item { grid-template-columns: minmax(0, 1fr) 70px 96px; }
.meal-item .grip { color: var(--text-3); cursor: grab; display: flex; }
.meal-item.is-flagged .mi-name::before { content: "!"; display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--crit); color: #fff; font-size: .7rem; font-weight: 700; margin-right: 6px; vertical-align: 1px; }
.mi-name { font-weight: 550; line-height: 1.3; }
.mi-sub { margin-top: 2px; }
.mi-grams { position: relative; display: block; }
.mi-grams input { height: 34px; padding: 0 24px 0 8px; text-align: right; font-variant-numeric: tabular-nums; }
.mi-grams span { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: .8rem; pointer-events: none; }
.mi-grams-ro { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.mi-kcal { text-align: right; line-height: 1.3; font-variant-numeric: tabular-nums; }
.mi-actions { display: flex; gap: 0; }
.add-meal { width: 100%; margin-top: 12px; border: 1px dashed var(--border-2); }

/* Sustitutos */
.subs { list-style: none; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; margin: 0 0 8px; display: grid; gap: 4px; }
.subs-head { margin-bottom: 4px; }
.sub-opt { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: inherit; color: inherit; cursor: pointer; }
.sub-opt:hover, .sub-opt:focus-visible { border-color: var(--brand); }
.sub-name { font-weight: 550; }
.sub-opt .faint { grid-column: 1 / -1; }

/* Resumen */
.plan-summary { display: grid; gap: 14px; }
.tbar + .tbar { margin-top: 12px; }
.tbar-track { position: relative; height: 7px; background: var(--bg-2); border-radius: 99px; margin-top: 5px; }
.tbar-track span { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: var(--ok); }
.tbar-warn .tbar-track span { background: var(--warn); }
.tbar-fail .tbar-track span { background: var(--crit); }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: .88rem; }
.checks li { display: flex; gap: 8px; align-items: flex-start; }
.check-ic { flex: none; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; font-weight: 700; color: #fff; margin-top: 1px; }
.check-ok .check-ic { background: var(--ok); }
.check-warn .check-ic { background: var(--warn); }
.check-fail .check-ic { background: var(--crit); }
.plan-current { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }

/* Botón flotante y aviso */
.fab { display: none; position: fixed; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); z-index: 40; box-shadow: var(--shadow-lg); border-radius: 999px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: .9rem; z-index: 60; box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px); }

@media (max-width: 1280px) {
  .planner { grid-template-columns: minmax(0, 1fr) 300px; }
  .food-panel { position: fixed; z-index: 50; top: 0; right: 0; bottom: 0; left: auto; width: min(380px, 100vw); max-height: none; border-radius: 0; transform: translateX(100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .food-panel.is-open { transform: none; }
  .food-panel-close { display: inline-flex; }
  .fab { display: inline-flex; bottom: 24px; }
}
@media (max-width: 1024px) { .fab { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); } .toast { bottom: calc(90px + env(safe-area-inset-bottom, 0px)); } }
@media (max-width: 960px) {
  .planner, .planner.is-readonly { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .meal-item { grid-template-columns: minmax(0, 1fr) 84px auto; grid-template-areas: "main grams act" "kcal kcal kcal"; row-gap: 4px; }
  .meal-item .grip { display: none; }
  .mi-main { grid-area: main; } .mi-grams { grid-area: grams; } .mi-actions { grid-area: act; }
  .mi-kcal { grid-area: kcal; text-align: left; display: flex; gap: 8px; }
  .is-readonly .meal-item { grid-template-columns: minmax(0, 1fr) 70px; grid-template-areas: "main grams" "kcal kcal"; }
  .mi-grams-ro { grid-area: grams; }
}

/* Impresión */
@media print {
  .sidebar, .topbar, .bottom-nav, .fab, .toast, .no-print { display: none !important; }
  body { background: #fff; }
}

/* Hoja imprimible del plan */
.print-sheet { max-width: 820px; margin: 0 auto; padding: 28px 24px 48px; background: var(--surface); min-height: 100vh; }
.print-actions { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 20px; }
.print-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; border-bottom: 2px solid var(--brand); padding-bottom: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.print-head h1 { font-size: 1.5rem; margin-top: 4px; }
.print-pro { text-align: right; }
.print-meal { break-inside: avoid; margin-bottom: 18px; }
.print-meal h2, .print-block h2 { font-size: 1.05rem; color: var(--brand); margin-bottom: 6px; }
.print-meal table { width: 100%; border-collapse: collapse; }
.print-meal td { padding: 6px 4px; border-bottom: 1px solid var(--border); vertical-align: top; }
.print-meal td:nth-child(2) { color: var(--text-2); width: 32%; }
.print-meal td.num { text-align: right; width: 70px; }
.print-block { break-inside: avoid; margin-top: 18px; }
.print-calendar { margin: 0 0 18px; }
.print-cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
.print-cal td { border: 1px solid var(--border); padding: 5px 6px; font-size: .82rem; vertical-align: top; }
.print-menu-title { font-size: 1.2rem; margin: 22px 0 8px; padding-bottom: 4px; border-bottom: 2px solid var(--brand); break-after: avoid; }
.print-menu-title:not(:first-of-type) { break-before: auto; }
.print-block ul { margin: 0; padding-left: 18px; }
.print-foot { margin-top: 26px; border-top: 1px solid var(--border); padding-top: 10px; }
@media print { .print-sheet { padding: 0; max-width: none; } .print-meal h2, .print-block h2 { color: #000; } }

/* Informe de evolución */
.report .print-block { break-inside: auto; }
.report .print-block h2 { break-after: avoid; }
.report h3 { font-size: .9rem; margin-bottom: 4px; }
.report ul { margin: 0; padding-left: 18px; }
.report .print-actions select, .report .print-actions input { width: auto; height: 32px; padding-top: 0; padding-bottom: 0; font-size: .86rem; }
.report .print-actions { align-items: center; }
.report-options { margin: -8px 0 16px; padding: 8px 12px; border: 1px dashed var(--border-2); border-radius: 10px; }
.report-options summary { cursor: pointer; color: var(--text-2); }
.report-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.report-kpi { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; break-inside: avoid; }
.report-kpi-label { font-size: .76rem; color: var(--text-2); }
.report-kpi-value { font-size: 1.35rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.report-kpi-value small { font-size: .75rem; color: var(--text-3); font-weight: 500; }
.report-kpi-sub { font-size: .74rem; color: var(--text-3); }
.report-chart { margin: 4px 0 8px; break-inside: avoid; }
.report-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.report-table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-3); font-weight: 600; padding: 4px; border-bottom: 1px solid var(--border-2); }
.report-table td { padding: 6px 4px; border-bottom: 1px solid var(--border); vertical-align: top; }
.report-table .num { text-align: right; }
.report-table tr { break-inside: avoid; }
.report-table.compact td { padding: 3px 4px; }
.report-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.tiny { font-size: .72rem; }
.report-weeks { display: flex; gap: 6px; align-items: flex-end; overflow-x: auto; padding-top: 4px; break-inside: avoid; }
.report-week { flex: 1 0 34px; max-width: 56px; text-align: center; }
.report-week-bar { height: 70px; background: var(--bg-2); border-radius: 6px; display: flex; align-items: flex-end; overflow: hidden; }
.report-week-bar span { display: block; width: 100%; border-radius: 6px 6px 0 0; }
.report-week-bar .is-good { background: var(--ok); }
.report-week-bar .is-mid { background: color-mix(in srgb, var(--warn) 75%, #fff); }
.report-week-bar .is-low { background: var(--crit); }
.report-week-pct { font-size: .72rem; font-weight: 600; margin-top: 2px; }
.report-week-label { font-size: .66rem; color: var(--text-3); }
.report-notes { min-height: 90px; border: 1px dashed var(--border-2); border-radius: 10px; padding: 10px 12px; outline: none; white-space: pre-wrap; }
.report-notes:focus { border-color: var(--brand); }
.report-notes:empty::before { content: attr(data-placeholder); color: var(--text-3); }
.report-sign { display: block; margin-top: 28px; text-align: right; }
.print-block.is-excluded { opacity: .35; }
@media (max-width: 640px) { .report-kpis { grid-template-columns: 1fr 1fr; } .report-cols { grid-template-columns: 1fr; } }
@media print {
  .print-block.is-excluded, .print-block.is-empty { display: none; }
  .report-notes { border: 0; padding: 0; min-height: 0; }
  .report-kpis { grid-template-columns: repeat(4, 1fr); }
  .report-cols { grid-template-columns: 1fr 1fr; }
  .report .text-warn { color: #9a5b00; }
  @page { margin: 14mm 12mm; }
}

/* ===================== V4 · Portal del paciente ===================== */
.portal-title { font-size: 1.45rem; }
.section-title { font-size: 1.05rem; }
.hero-kicker { color: #9FD0B6; font-weight: 600; font-size: .85rem; }
.hero-sub { color: #AFC6BB; }
.hero-of { font-size: 1.2rem; font-weight: 500; color: #AFC6BB; }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 700; }
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wday { display: grid; justify-items: center; gap: 2px; padding: 8px 0 7px; border-radius: 12px; color: #CFE0D7; text-decoration: none; background: rgba(255,255,255,.06); }
.wday:hover { background: rgba(255,255,255,.12); color: #fff; }
.wday.is-sel { background: #F6F1E7; color: #1F3A2E; }
.wday-name { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; }
.wday-num { font-weight: 700; font-size: 1rem; }
.wday-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.18); }
.wday.is-sel .wday-dot { background: rgba(0,0,0,.12); }
.wday-dot.is-good, .cal-cell.is-good, .lg.is-good { background: var(--ok); }
.wday-dot.is-mid, .cal-cell.is-mid, .lg.is-mid { background: color-mix(in srgb, var(--warn) 75%, #fff); }
.wday-dot.is-low, .cal-cell.is-low, .lg.is-low { background: var(--crit); }

.today-meal { padding: 0; overflow: hidden; border-left: 4px solid var(--border-2); }
.today-meal.is-yes { border-left-color: var(--ok); }
.today-meal.is-partial { border-left-color: var(--warn); }
.today-meal.is-no { border-left-color: var(--crit); }
.today-meal summary { display: flex; align-items: center; gap: 12px; padding: 14px 16px 10px; cursor: pointer; list-style: none; }
.today-meal summary::-webkit-details-marker { display: none; }
.tm-check { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--border-2); display: grid; place-items: center; color: #fff; }
.is-yes .tm-check { background: var(--ok); border-color: var(--ok); }
.is-partial .tm-check { background: var(--warn); border-color: var(--warn); }
.is-no .tm-check { background: var(--crit); border-color: var(--crit); }
.tm-main { flex: 1; min-width: 0; display: grid; }
.tm-chev { color: var(--text-3); transition: transform .15s; }
details[open] .tm-chev { transform: rotate(90deg); }
.tm-items { list-style: none; margin: 0 16px; padding: 4px 0; border-top: 1px solid var(--border); }
.tm-items li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: .92rem; }
.tm-items li + li { border-top: 1px dashed var(--border); }
.tm-note { margin: 0 16px 8px; }
.tm-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 4px 16px 14px; }
.tm-btn { font: inherit; font-size: .84rem; font-weight: 600; padding: 9px 6px; border-radius: 10px; border: 1px solid var(--border-2); background: var(--surface); color: var(--text-2); cursor: pointer; min-height: 40px; }
.tm-btn:hover { border-color: var(--brand); color: var(--text); }
.tm-yes.is-on { background: var(--ok); border-color: var(--ok); color: #fff; }
.tm-partial.is-on { background: var(--warn); border-color: var(--warn); color: #fff; }
.tm-no.is-on { background: var(--crit); border-color: var(--crit); color: #fff; }

.glasses { display: flex; flex-wrap: wrap; gap: 6px; }
.glass { width: 22px; height: 30px; border: 2px solid var(--border-2); border-top: 0; border-radius: 0 0 6px 6px; position: relative; overflow: hidden; }
.glass.is-full::after { content: ""; position: absolute; inset: 25% 0 0; background: #5B9BD5; }
.scale5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.scale5 button { font: inherit; font-size: .8rem; padding: 9px 4px; border-radius: 10px; border: 1px solid var(--border-2); background: var(--surface); color: var(--text-2); cursor: pointer; min-height: 40px; }
.scale5 button:hover { border-color: var(--brand); }
.scale5 button.is-on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.callout { display: flex; gap: 8px; align-items: flex-start; background: var(--brand-soft); color: var(--text); border-radius: 12px; padding: 10px 14px; }
.pm-list { list-style: none; margin: 0; padding: 0 18px 6px; }
.pm-list > li { padding: 10px 0; border-top: 1px solid var(--border); }
.pm-list > li:first-child { border-top: 0; }
.pm-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.pm-name { min-width: 0; }
.pm-swaps { margin-top: 8px; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.pm-swaps ul { list-style: none; margin: 0; padding: 0; }
.pm-swaps li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: .9rem; }
.dot-list { margin: 0; padding-left: 18px; }
.dot-list li { padding: 2px 0; }

.seg-link { padding: 6px 12px; border-radius: 8px; font-weight: 550; font-size: .86rem; color: var(--text-2); text-decoration: none; }
.seg-link.is-on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.shop-list { list-style: none; margin: 0; padding: 0 18px 8px; }
.shop-list li + li { border-top: 1px solid var(--border); }
.shop-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; cursor: pointer; margin: 0; font-weight: 400; }
.shop-item input { width: 20px; height: 20px; flex: none; accent-color: var(--brand); }
.shop-name { flex: 1; }
.shop-qty { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.shop-item input:checked ~ .shop-name, .shop-item input:checked ~ .shop-qty { text-decoration: line-through; color: var(--text-3); }

.portal-stats .stat-value { font-size: 1.6rem; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.lg { width: 10px; height: 10px; border-radius: 3px; background: var(--bg-2); display: inline-block; }
.cal { display: grid; gap: 6px; }
.cal-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head span { text-align: center; font-size: .72rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.cal-cell { aspect-ratio: 1; border-radius: 10px; background: var(--bg-2); position: relative; display: grid; place-items: center; color: var(--text-2); }
.cal-cell.is-good, .cal-cell.is-mid, .cal-cell.is-low { color: #fff; }
.cal-cell.is-today { outline: 2px solid var(--brand); outline-offset: 1px; }
.cal-num { font-weight: 650; font-size: .85rem; }
.cal-water { position: absolute; right: 3px; bottom: 2px; line-height: 0; opacity: .9; }
.cal-water .icon { width: 11px; height: 11px; }
.portal-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cal { max-width: 480px; margin-inline: auto; }
@media (max-width: 600px) { .portal-stats { gap: 8px; } .portal-stats .card-pad { padding: 12px; } .portal-stats .stat-value { font-size: 1.25rem; } .portal-stats .small { font-size: .72rem; } }

/* Profesional: registros del paciente */
.adh-strip { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; }
.adh-strip span { height: 26px; border-radius: 6px; background: var(--bg-2); }
.adh-strip span.is-good { background: var(--ok); }
.adh-strip span.is-mid { background: color-mix(in srgb, var(--warn) 75%, #fff); }
.adh-strip span.is-low { background: var(--crit); }
.note-item { border-left: 3px solid var(--warn); padding: 6px 0 6px 12px; }
.note-item.is-read { border-left-color: var(--border-2); }

/* ===================== V5 · Asistente con IA ===================== */
.ai-card { border-color: color-mix(in srgb, var(--brand) 25%, var(--border)); }
.ai-card .card-head h2 .icon, .ai-card-inline .icon { color: var(--brand); }
.ai-card-inline { border: 1px dashed color-mix(in srgb, var(--brand) 35%, var(--border-2)); border-radius: 12px; padding: 12px 14px; }
.ai-out { font-size: .93rem; }
.ai-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ai-points li { display: flex; gap: 10px; align-items: flex-start; }
.ai-points .badge { flex: none; min-width: 52px; justify-content: center; }
.ai-foot { display: flex; gap: 6px; align-items: flex-start; font-size: .76rem; color: var(--text-3); margin: 10px 0 0; }
.ai-foot .icon { flex: none; margin-top: 1px; }
.ai-draft { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.ai-text { line-height: 1.55; }
.note-reply { margin-top: 8px; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; }
.pm-ideas { padding: 0 18px 14px; }
.ai-ideas { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.ai-idea + .ai-idea { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.ai-idea ol { margin: 6px 0 0; padding-left: 20px; }
.ai-idea li { padding: 2px 0; }
.reply-item { border-left: 3px solid var(--brand); padding-left: 12px; }
.reply-quote { font-style: italic; }
[aria-busy="true"] { opacity: .6; }
.spinner { display: inline-block; width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }


/* ===== Embarazo ===== */
.preg-bar { position: relative; height: 12px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--border); }
.preg-band { position: absolute; top: 0; bottom: 0; border-radius: 999px; background: var(--brand-line); }
.preg-mark { position: absolute; top: -5px; width: 4px; height: 20px; margin-left: -2px; border-radius: 2px; background: var(--brand); }
.preg-mark.is-off { background: var(--warn); }
/* ===== Índice glucémico ===== */
.gi { display: inline-block; padding: 0 6px; border-radius: 999px; font-size: .78em; font-weight: 600; line-height: 1.6; white-space: nowrap; }
.gi-low  { background: var(--ok-bg); color: var(--ok); }
.gi-mid  { background: var(--warn-bg); color: var(--warn); }
.gi-high { background: var(--crit-bg); color: var(--crit); }
.text-warn { color: var(--warn); }

/* ===== Seguimiento ===== */
.stat-active { outline: 2px solid var(--brand); outline-offset: -2px; }
.chips .chip { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; font-size: .84rem; }
.chip-n { font-size: .74rem; opacity: .75; font-variant-numeric: tabular-nums; }
.clamp-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.fu-list { list-style: none; margin: 0; padding: 0; }
.fu-row { display: grid; grid-template-columns: minmax(180px, 1.1fr) minmax(220px, 1.6fr) 170px 150px auto; gap: 14px 20px; align-items: start;
  padding: 14px 18px; border-top: 1px solid var(--border); border-left: 3px solid transparent; }
.fu-row.fu-critical { border-left-color: var(--crit); }
.fu-row.fu-warning { border-left-color: var(--warn); }
.fu-who { display: flex; gap: 10px; align-items: center; min-width: 0; }
.fu-flags { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fu-flag { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fu-flag .badge { align-self: flex-start; }
.fu-meta { display: flex; flex-direction: column; gap: 4px; }
.fu-actions { display: flex; gap: 4px; align-items: flex-start; justify-content: flex-end; }
.adh-mini { gap: 2px; }
.adh-mini span { height: 16px; border-radius: 3px; }
.fu-form summary { list-style: none; white-space: nowrap; }
.fu-form summary::-webkit-details-marker { display: none; }
.fu-form[open] summary { background: var(--bg-2); }
.fu-form form { position: absolute; right: 18px; z-index: 20; width: min(460px, calc(100vw - 32px)); margin-top: 6px; box-shadow: var(--shadow-lg, 0 12px 32px rgba(0,0,0,.18)); }
.fu-row { position: relative; }
@media (max-width: 1100px) {
  .fu-row { grid-template-columns: 1fr 1fr; }
  .fu-who { grid-column: 1 / -1; }
  .fu-flags { grid-column: 1 / -1; }
  .fu-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 520px) {
  .fu-row { grid-template-columns: 1fr; padding: 14px 16px; }
  .fu-form form { position: static; width: 100%; }
}

/* ===================== Recetas ===================== */
.recipe-grid { gap: 14px; }
.recipe-card { display: flex; flex-direction: column; gap: 8px; padding: 16px; color: inherit; text-decoration: none; transition: border-color .15s, transform .15s; }
.recipe-card:hover { border-color: var(--brand); transform: translateY(-1px); }
.recipe-card h3 { margin: 0 0 2px; font-size: 1.02rem; }
.recipe-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px; }
.recipe-kpis div { display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.recipe-kpis strong { font-size: 1rem; }
.recipe-kpis span { font-size: .72rem; opacity: .75; }
.recipe-ings { margin-top: auto; }
.nutri-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.nutri-table th { text-align: left; font-weight: 600; padding: 4px 0; border-bottom: 2px solid var(--border-2); }
.nutri-table td { padding: 4px 0; border-bottom: 1px solid var(--border); }
.nutri-table tr.sub td:first-child { padding-left: 14px; opacity: .8; }
.macro-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--surface-2); }
.tip-box { background: var(--brand-soft); border-color: transparent; }
.tip-box ul { margin: 0; padding-left: 20px; }
.tip-box li + li { margin-top: 4px; }
.recipe-steps { margin: 0; padding-left: 22px; }
.recipe-steps li { margin-bottom: 8px; line-height: 1.5; }
.ing-search { position: relative; }
.ing-search input { width: 100%; }
.ing-results { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 320px; overflow-y: auto; }
.ing-opt { display: flex; justify-content: space-between; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; color: inherit; text-align: left; cursor: pointer; font: inherit; }
.ing-opt:hover, .ing-opt.is-active { background: var(--brand-soft); }
.ing-table input { width: 100%; }
.recipe-live { position: sticky; top: 16px; }
@media (max-width: 600px) { .recipe-kpis strong { font-size: .92rem; } }
.recipe-gi { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.recipe-gi .stat { padding: 10px 12px; }
.recipe-steps + *, .table-wrap td.text-right { white-space: nowrap; }
.mod-list { margin: 4px 0 0; padding-left: 18px; color: var(--text-2); }
.prep-effect { font-size: 1.05rem; }
.prep-card.is-inactive { opacity: .6; }
.prep-foods { max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 2px 12px; }
.prep-foods label[hidden] { display: none; }
.ing-table select { width: 100%; }.cook-yield { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; }
.cook-yield > div { display: flex; flex-direction: column; text-align: center; }
.cook-arrow { color: var(--brand); }
.effect-list { list-style: none; margin: 0; padding: 0; }
.effect-list > li { padding: 10px 0; border-top: 1px solid var(--border); }
.effect-list > li:first-child { border-top: 0; }
.effect-list .small + .small { margin-top: 2px; }

/* Menús del plan (rotación de 2 semanas) */
.day-bar { padding: 12px 16px; margin-bottom: 14px; }
.day-bar-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.day-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.day-tabs[hidden] { display: none; }
.day-tab { position: relative; min-width: 38px; height: 34px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--border-2); background: var(--surface); color: var(--text-2); font: inherit; font-weight: 600; cursor: pointer; }
.day-tab:hover { border-color: var(--brand); color: var(--text); }
.day-tab.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.day-tab:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.day-tab::after { content: ""; position: absolute; top: -3px; right: -3px; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--surface); background: transparent; }
.day-tab.is-ok::after { background: var(--ok, #2e7d4f); }
.day-tab.is-warn::after { background: var(--warn, #c98a12); }
.day-tab.is-fail::after { background: var(--crit); }
.day-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.day-actions .confirm { color: var(--crit); }
.plan-overall { padding-top: 10px; border-top: 1px solid var(--border); }
.menu-switch { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.menu-switch a { flex: 0 0 auto; min-width: 54px; text-align: center; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--border-2); color: var(--text-2); text-decoration: none; font-size: .85rem; line-height: 1.2; }
.menu-switch a small { display: block; font-size: .7rem; color: var(--text-3); }
.menu-switch a.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.menu-switch a.active small { color: var(--brand-ink); opacity: .85; }
.menu-switch a.is-today:not(.active) { border-color: var(--brand); color: var(--text); }

/* Lista de alimentos del paciente */
.pf-legend { display: flex; gap: 14px; flex-wrap: wrap; padding: 8px 18px; border-bottom: 1px solid var(--border); }
.pf-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--border-2); vertical-align: -1px; }
.pf-dot.pf-prefer { background: var(--brand); }
.pf-dot.pf-exclude { background: var(--crit); }
.pf-cat { border-bottom: 1px solid var(--border); }
.pf-cat-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 18px 4px; }
.pf-cat-head h3 { margin: 0; font-size: 1rem; }
.pf-list { list-style: none; margin: 0; padding: 0 18px 10px; }
.pf-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px dashed var(--border); }
.pf-row:first-child { border-top: 0; }
.pf-info { min-width: 0; }
.pf-name { font-weight: 550; color: var(--text); text-decoration: none; }
.pf-name:hover { text-decoration: underline; }
.pf-row[data-status="prefer"] .pf-name::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-right: 6px; vertical-align: 1px; }
.pf-row[data-status="exclude"] .pf-info { opacity: .6; }
.pf-row[data-status="exclude"] .pf-name { text-decoration: line-through; }
.pf-seg { flex-shrink: 0; }
.pf-seg label { padding: 4px 11px; min-width: 34px; text-align: center; }
.pf-seg input[value="prefer"]:checked + label { background: var(--brand); color: var(--brand-ink); }
.pf-seg input[value="exclude"]:checked + label { background: var(--crit); color: #fff; }
/* Datos de acceso al portal (se copian para pasárselos al paciente) */
.portal-creds { white-space: pre-line; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .85rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; overflow-wrap: anywhere; }
/* Gustos por grupo */
.taste-grid { display: grid; gap: 4px 18px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.taste-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px dashed var(--border); }
.taste-row strong { font-weight: 550; }
.taste-seg label { padding: 4px 10px; font-size: .82rem; }
.taste-seg input[value="like"]:checked + label { background: var(--brand); color: var(--brand-ink); }
.taste-seg input[value="dislike"]:checked + label { background: var(--crit); color: #fff; }
.pf-cov { list-style: none; margin: 0 0 8px; padding: 0; }
.pf-cov li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-top: 1px solid var(--border); }
.pf-cov li:first-child { border-top: 0; }
.pf-missing { list-style: none; margin: 0; padding: 0; }
.pf-missing li { padding: 5px 0; border-top: 1px solid var(--border); }
.pf-missing li:first-child { border-top: 0; }
.pf-missing .link-btn { margin-right: 8px; }
.pf-suggest { margin: -2px 0 6px; }
.pf-suggest .link-btn { margin-right: 8px; font-size: .8rem; }
/* En pantallas angostas el panel lateral queda al final: barra de guardado fija. */
.pf-savebar { display: none; }
@media (max-width: 960px) {
  .pf-savebar { display: flex; position: sticky; bottom: 12px; z-index: 30; align-items: center; justify-content: space-between; gap: 10px;
    margin: 0 12px 12px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg, var(--shadow)); }
}
@media (max-width: 720px) { .pf-savebar { bottom: 76px; } }

/* Revisión de recetas de la biblioteca */
.review-box { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.review-box p { margin: 4px 0 0; }
.chip-check { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--border);
  border-radius: 999px; font-size: 13px; font-weight: 500; cursor: pointer; background: var(--surface); margin: 0; }
.field-title { display: block; font-size: .87rem; font-weight: 550; margin-bottom: 5px; }
.chip-check:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, var(--surface)); }
.chip-check input { margin: 0; }
/* Foto de la comida (portal y ficha) */
.tm-photo { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0 14px 12px; }
.tm-photo img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; display: block; }
.tm-photo form { margin: 0; }
.tm-photo label.btn { cursor: pointer; }
.tm-photo label.disabled { opacity: .6; pointer-events: none; }
.meal-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.meal-gallery figure { margin: 0; background: var(--bg-2); border-radius: 10px; overflow: hidden; }
.meal-gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.meal-gallery figcaption { padding: 6px 8px; font-size: .78rem; }
/* Marca del consultorio en el PDF y en «Mi consultorio» */
.print-brand { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.print-brand img { max-height: 54px; max-width: 170px; object-fit: contain; }
.print-brand-contact { margin-left: auto; text-align: right; max-width: 50%; }
.brand-preview { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; border-top: 4px solid var(--brand-c); background: var(--bg-2); }
.brand-preview img { max-height: 48px; max-width: 140px; object-fit: contain; }
/* Materiales */
.res-patients { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 4px 12px; max-height: 220px; overflow: auto; margin-top: 8px; font-size: .85rem; }
.res-patients label { display: flex; gap: 6px; align-items: center; }
.res-patients input { width: auto; }
.res-video { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; }
.res-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.res-img { max-width: 100%; border-radius: 10px; display: block; }
.card.is-muted { opacity: .6; }
/* Formularios */
.form-field-row { border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 8px; }
.ffr-main { display: grid; grid-template-columns: 1fr 190px; gap: 8px; }
@media (max-width: 600px) { .ffr-main { grid-template-columns: 1fr; } }
.ffr-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ffr-foot input[type=text] { flex: 1; min-width: 160px; }
.ffr-foot label { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.ffr-foot input[type=checkbox] { width: auto; }
.form-answers { margin: 0; padding: 4px 18px 14px; }
.form-answers dt { font-weight: 600; margin-top: 12px; }
.form-answers dd { margin: 4px 0 0; color: var(--text-2); }
.form-q-label { font-weight: 600; display: block; margin-bottom: 6px; }
.form-opts { display: flex; flex-direction: column; gap: 8px; }
.form-opts label { display: flex; gap: 8px; align-items: center; }
.form-opts input { width: auto; }
.form-scale label { min-width: 44px; text-align: center; }
/* Reserva online y gestión del turno */
.booking { max-width: 640px; margin: 0 auto; padding: 24px 16px 40px; display: flex; flex-direction: column; gap: 16px; }
.booking-head { display: flex; align-items: center; gap: 12px; }
.booking-logo { height: 56px; max-width: 240px; object-fit: contain; object-position: left center; }
.booking-name { font-weight: 700; font-size: 1.15rem; }
.booking .btn-primary { background: var(--brand-c, var(--brand)); border-color: var(--brand-c, var(--brand)); }
.booking-step { display: flex; align-items: center; gap: 8px; font-weight: 600; margin: 4px 0 10px; }
.booking-step span { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--brand-c, var(--brand)); color: #fff; font-size: .8rem; }
.slot-days { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; }
.slot-day { flex: 0 0 auto; min-width: 58px; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer; scroll-snap-align: start; font: inherit; }
.slot-day small { font-size: .72rem; color: var(--text-3); text-transform: capitalize; }
.slot-day strong { font-size: 1.1rem; }
.slot-day.active { border-color: var(--brand-c, var(--brand)); box-shadow: 0 0 0 1px var(--brand-c, var(--brand)) inset; }
.slot-times { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; margin-top: 12px; }
.slot-time { padding: 9px 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer; font: inherit; font-weight: 600; }
.slot-time.active { background: var(--brand-c, var(--brand)); border-color: var(--brand-c, var(--brand)); color: #fff; }
.booking-summary { padding: 10px 12px; border-radius: 10px; background: var(--bg-2); font-weight: 600; }
.booking-dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.booking-dl dt { color: var(--text-3); }
.booking-dl dd { margin: 0; }
.btn.pulse { animation: pulse 1.6s ease-in-out 3; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--brand) 25%, transparent); } }
/* Agenda del profesional */
.agenda-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 960px) { .agenda-week { grid-template-columns: 1fr; } }
.agenda-day { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px; min-height: 120px; }
.agenda-day.today { border-color: var(--brand); }
.agenda-day h3 { font-size: .85rem; margin: 0 0 8px; text-transform: capitalize; }
.agenda-item { display: block; padding: 7px 8px; border-radius: 8px; background: var(--bg-2); margin-bottom: 6px; font-size: .82rem; border-left: 3px solid var(--brand); }
.agenda-item.st-cancelled { opacity: .5; text-decoration: line-through; border-left-color: var(--text-3); }
.agenda-item.st-no_show { border-left-color: var(--crit); }
.agenda-item.st-confirmed, .agenda-item.st-completed { border-left-color: var(--ok); }
.agenda-item.block { border-left-color: var(--warn); background: var(--warn-bg); }
.hours-row { display: grid; grid-template-columns: 110px 1fr 1fr auto; gap: 8px; align-items: center; margin-bottom: 6px; }
.appt-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); color: inherit; text-decoration: none; }
.appt-row:first-of-type { border-top: 0; }
.appt-row small { display: block; }
.booking .choice input:checked + label { border-color: var(--brand-c, var(--brand)); background: color-mix(in srgb, var(--brand-c, var(--brand)) 10%, var(--surface)); }

/* Ojito de las contraseñas (lo agrega app.js) */
.pw-wrap { position: relative; }
.pw-wrap input { width: 100%; padding-right: 44px; }
.pw-toggle { position: absolute; top: 50%; right: 4px; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); cursor: pointer; }
.pw-toggle:hover { color: var(--text); background: var(--surface-2); }
.pw-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
