/* ======================================================================
   Nuvita · «Huerta clara» (ver DESIGN.md)
   Fondo crema, tarjetas blancas muy redondeadas, el verde azulado del logo
   para lo activo y durazno/ámbar como acento cálido.
   ====================================================================== */

:root {
  --bg:          #F7F2EA;
  --bg-2:        #EFE8DD;
  --surface:     #FFFFFF;
  --surface-2:   #FBF8F2;
  --border:      #EEE7DC;
  --border-2:    #E2D9CB;
  --card-line:   #F2ECE2;
  --hero:        #0D5F55;
  --hero-2:      #0A4E46;

  --text:        #1E2A28;
  --text-2:      #5A6461;
  --text-3:      #626A66;

  --accent:      #02BDA0;
  --accent-2:    #00A88E;
  --accent-ink:  #04332C;
  --fill:        #0A8270;
  --fill-2:      #08715F;
  --fill-ink:    #FFFFFF;
  --brand:       #08796A;
  --brand-2:     #06655A;
  --brand-ink:   #FFFFFF;
  --brand-soft:  #DDF4EE;
  --brand-line:  #B3E6D9;

  --peach:       #F28A4B;
  --peach-soft:  #FFE8D9;
  --peach-ink:   #A84B12;
  --amber:       #E9A92A;
  --amber-soft:  #FFF1CF;
  --amber-ink:   #8A5A00;
  --sky-soft:    #E3EEF8;
  --sky-ink:     #2D6289;
  --rose-soft:   #FCE4DF;
  --rose-ink:    #A8382A;

  --ind-1:       #0AA38B;   /* proteínas / principal  */
  --ind-2:       #E9A92A;   /* hidratos / secundario  */
  --ind-3:       #F28A4B;   /* grasas                 */
  --ind-4:       #B9E3D8;

  --ok:          #26704C;
  --ok-bg:       #E2F3E9;
  --warn:        #975011;
  --warn-bg:     #FFF0DF;
  --warn-line:   #F5D2AA;
  --crit:        #B23A2A;
  --crit-bg:     #FCE6E1;
  --crit-line:   #F2C3B8;
  --info:        #2D6289;
  --info-bg:     #E5EFF8;

  --radius:      14px;
  --radius-sm:   11px;
  --radius-lg:   22px;
  --shadow:      0 1px 2px rgba(74,54,24,.04), 0 10px 28px -16px rgba(74,54,24,.16);
  --shadow-lg:   0 2px 6px rgba(74,54,24,.06), 0 24px 48px -20px rgba(74,54,24,.28);

  --sidebar-w:   248px;
  --topbar-h:    68px;
  --font:        "Plus Jakarta Sans", 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:         #151715;
  --bg-2:       #1B1E1C;
  --surface:    #1E211F;
  --surface-2:  #242826;
  --border:     #2E3330;
  --border-2:   #3A403C;
  --card-line:  #2A2E2B;
  --hero:       #12403A;
  --hero-2:     #0E332E;
  --text:       #ECEDE7;
  --text-2:     #AEB4AE;
  --text-3:     #8E958F;
  --accent:     #1FCFB1;
  --accent-2:   #3BDCC0;
  --accent-ink: #03241F;
  --fill:       #1FCFB1;
  --fill-2:     #3BDCC0;
  --fill-ink:   #03241F;
  --brand:      #4FDCC2;
  --brand-2:    #74E6D1;
  --brand-ink:  #03241F;
  --brand-soft: #143A33;
  --brand-line: #1F5248;
  --peach:      #F5A274;
  --peach-soft: #3A2619;
  --peach-ink:  #F7B58E;
  --amber:      #F0BE55;
  --amber-soft: #352A12;
  --amber-ink:  #F2C870;
  --sky-soft:   #182A38;
  --sky-ink:    #8CBDE0;
  --rose-soft:  #3A201B;
  --rose-ink:   #F09A86;
  --ind-1:      #2FD3B5;
  --ind-2:      #F0BE55;
  --ind-3:      #F5A274;
  --ind-4:      #1F5248;
  --ok:         #6CC197;
  --ok-bg:      #1C3329;
  --warn:       #E9A05C;
  --warn-bg:    #352816;
  --warn-line:  #5B4122;
  --crit:       #EE927E;
  --crit-bg:    #3A201B;
  --crit-line:  #5E3128;
  --info:       #7DB3DA;
  --info-bg:    #182A38;
  --shadow:     0 1px 2px rgba(0,0,0,.25);
  --shadow-lg:  0 18px 40px -16px rgba(0,0,0,.6);
  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;
  -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: 700; letter-spacing: -.015em; text-wrap: balance; }
h1 { font-size: 1.7rem; font-weight: 750; letter-spacing: -.025em; }
h2 { font-size: 1.12rem; }
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); outline-offset: 2px; border-radius: 6px; }
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); color: var(--text); }
html { scrollbar-color: var(--border-2) transparent; }
input, textarea { caret-color: var(--brand); }
.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(--surface-2);
  border-right: 1px solid var(--border);
  color: var(--text-2);
  display: flex; flex-direction: column;
  padding: 22px 14px 16px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 12px 20px; color: var(--text); }
.brand-mark {
  width: 32px; height: 32px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
}
.brand-name { font-weight: 700; font-size: 1rem; line-height: 1.1; }
.brand-logo { height: 32px; width: auto; display: block; }
.brand-icon { display: none; width: 36px; height: 36px; border-radius: 11px; }
.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: .76rem; color: var(--text-3); letter-spacing: .01em; }

.nav-group { margin-bottom: 16px; display: grid; gap: 1px; }
.nav-label { font-size: .8rem; font-weight: 650; color: var(--text-2); padding: 0 14px 6px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px; border-radius: 12px;
  color: var(--text-2); font-weight: 550; font-size: .93rem;
  transition: background .15s ease-out, color .15s ease-out;
}
.nav-link .icon { color: var(--text-3); transition: color .15s ease-out; }
.nav-link:hover { background: var(--bg-2); text-decoration: none; color: var(--text); }
.nav-link:hover .icon { color: var(--text-2); }
.nav-link.active { background: var(--fill); color: var(--fill-ink); font-weight: 650; box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--fill) 60%, transparent); }
.nav-link.active .icon { color: var(--fill-ink); }
.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 var(--border-2); border-radius: 99px; padding: 0 6px; }

.sidebar-foot { margin-top: auto; padding-top: 14px; display: grid; gap: 6px; }
.user-chip { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.user-chip:hover { text-decoration: none; }
.user-chip .avatar { background: var(--peach-soft); color: var(--peach-ink); }
.user-chip-name { color: var(--text); font-weight: 650; font-size: .9rem; line-height: 1.2; }
.user-chip-role { color: var(--text-3); 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 32px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
}
.topbar-search { flex: 1; max-width: 420px; position: relative; }
.topbar-search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.topbar-search input[type="search"] { padding-left: 40px; height: 44px; border-radius: 99px; background: var(--surface); border-color: transparent; box-shadow: var(--shadow); }
.topbar-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.content { padding: 8px 36px 64px; width: 100%; max-width: 2000px; }

.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: 650; }
.bottom-nav a.active .icon { background: var(--fill); color: var(--fill-ink); border-radius: 10px; padding: 3px; width: 30px; height: 26px; }
.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(--card-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.card-pad { padding: 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 14px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { font-size: 1.05rem; }
.card-body { padding: 18px 22px 22px; }
.card-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.eyebrow { font-size: .86rem; color: var(--text); font-weight: 700; letter-spacing: -.005em; }

.grid { display: grid; gap: 18px; }
.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: 20px; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; }
.split-rev { display: grid; gap: 22px; grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
@media (min-width: 1680px) { .split-rev { grid-template-columns: minmax(0, 1fr) 440px; } }
@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: 20px; }
.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: 20px 22px; }
.stat-label { font-size: .86rem; color: var(--text-2); display: flex; align-items: center; gap: 6px; font-weight: 550; }
.stat-value { font-size: 2rem; font-weight: 750; letter-spacing: -.03em; line-height: 1.1; margin-top: 6px; 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: transparent; }
.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: 750; 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: 650;
  padding: 3px 10px; 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: 12px 15px; border-radius: var(--radius); 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); padding: 12px 14px; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 17px;
  border-radius: 12px; border: 1px solid var(--border-2);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 650; font-size: .93rem;
  cursor: pointer; white-space: nowrap;
  transition: background .15s ease-out, border-color .15s ease-out, color .15s ease-out, box-shadow .15s ease-out, transform .1s ease-out;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--fill); border-color: var(--fill); color: var(--fill-ink); box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--fill) 70%, transparent); }
.btn-primary:hover { background: var(--fill-2); border-color: var(--fill-2); color: var(--fill-ink); }
.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: 34px; padding: 0 12px; font-size: .86rem; border-radius: 10px; }
.btn-lg { height: 48px; padding: 0 24px; font-size: 1rem; border-radius: 14px; }
.btn-icon { width: 40px; padding: 0; }
.btn-sm.btn-icon { width: 34px; }
.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: 600; 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: 42px; padding: 0 13px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-2); border-radius: 12px;
  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(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent); }
::placeholder { color: var(--text-3); opacity: 1; }
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: 700; font-size: 1rem; margin-bottom: 10px; padding: 0; }

/* Selector segmentado */
.segmented { display: inline-flex; background: var(--bg-2); border-radius: 13px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label { margin: 0; padding: 6px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; 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: 14px; 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(--accent); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.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: .82rem; color: var(--text-3); font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 22px; }
th:last-child, td:last-child { padding-right: 22px; }
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: 38px; height: 38px; border-radius: 12px; display: inline-grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: .82rem; flex: none; }
.avatar-lg { width: 60px; height: 60px; font-size: 1.15rem; border-radius: 18px; }
.person { display: flex; align-items: center; gap: 11px; }
.person-name { font-weight: 650; color: var(--text); }
.person-sub { font-size: .82rem; color: var(--text-2); }

/* Pestañas */
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin-bottom: 20px; padding: 4px; background: var(--bg-2); border-radius: 14px; width: fit-content; max-width: 100%; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 8px 15px; color: var(--text-2); font-weight: 600; white-space: nowrap; background: none; border: 0; border-radius: 11px; font: inherit; cursor: pointer; transition: background .15s ease-out, color .15s ease-out; }
.tab:hover { color: var(--text); text-decoration: none; background: color-mix(in srgb, var(--surface) 55%, transparent); }
.tab.active { color: var(--text); background: var(--surface); box-shadow: var(--shadow); font-weight: 700; }
.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(--accent); }
.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: 13px 22px; }
.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(--hero); 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; gap: 10px; padding: 6px 0 20px; }
.portal-head > .person { min-width: 0; }
.portal-head > .row { flex-wrap: nowrap; flex: none; }
.portal-head .person-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-hero { background: var(--hero); 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: var(--accent); 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 { padding: 10px 14px; background: var(--brand-soft); border-radius: var(--radius-sm); 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: 1px solid color-mix(in srgb, var(--info) 22%, transparent); background: var(--info-bg); padding: 10px 14px; border-radius: var(--radius-sm); font-size: .88rem; }
.interaction-warning { border-color: var(--warn-line); background: var(--warn-bg); }
.interaction-critical { border-color: var(--crit-line); 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; }
.today-meal.is-yes { background: color-mix(in srgb, var(--ok-bg) 45%, var(--surface)); }
.today-meal.is-partial { background: color-mix(in srgb, var(--warn-bg) 45%, var(--surface)); }
.today-meal.is-no { background: color-mix(in srgb, var(--crit-bg) 40%, var(--surface)); }
.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: 8px; }
.glass { width: 28px; height: 36px; border: 2px solid var(--border-2); border-top: 0; border-radius: 0 0 9px 9px; position: relative; overflow: hidden; background: var(--surface-2); }
.glass.is-full { border-color: color-mix(in srgb, var(--sky-ink) 45%, transparent); }
.glass.is-full::after { content: ""; position: absolute; inset: 22% 0 0; background: linear-gradient(#7FC0EC, #4F9FD6); }
.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 { padding: 8px 12px; background: var(--warn-bg); border-radius: var(--radius-sm); }
.note-item.is-read { border-left-color: var(--border-2); }

/* ===================== V5 · Asistente con IA ===================== */
.ai-card .card-head h2 .icon { width: 30px; height: 30px; padding: 7px; border-radius: 10px; background: var(--brand-soft); vertical-align: -9px; margin-right: 4px; }
.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 { background: var(--brand-soft); padding: 8px 12px; border-radius: var(--radius-sm); }
.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: var(--radius); background: color-mix(in srgb, var(--brand-c) 12%, var(--surface)); }
.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-cal { padding: 8px; }
.agenda-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0; }
@media (max-width: 960px) { .agenda-week { grid-template-columns: 1fr; } }
.agenda-day { padding: 8px 8px 12px; min-height: 420px; border-right: 1px solid var(--border);
  background-image: repeating-linear-gradient(to bottom, transparent 0 59px, color-mix(in srgb, var(--border) 70%, transparent) 59px 60px); background-position: 0 86px; }
.agenda-day:last-child { border-right: 0; }
.agenda-day.past { opacity: .7; }
@media (max-width: 960px) { .agenda-day { min-height: 0; border-right: 0; border-bottom: 1px solid var(--border); background-image: none; } }
.agenda-day-head { display: grid; justify-items: center; gap: 2px; padding: 8px 4px 10px; margin-bottom: 10px; border-radius: 16px; color: var(--text-3); font-size: .8rem; font-weight: 650; text-transform: capitalize; }
.agenda-day-head strong { font-size: 1.35rem; font-weight: 800; color: var(--text); line-height: 1.1; }
.agenda-day-head em { font-style: normal; font-size: .74rem; color: var(--brand); font-weight: 700; }
.agenda-day.today .agenda-day-head { background: var(--fill); color: var(--fill-ink); }
.agenda-day.today .agenda-day-head strong, .agenda-day.today .agenda-day-head em { color: var(--fill-ink); }
.agenda-free { text-align: center; color: var(--text-3); font-size: .8rem; padding: 10px 0; }
.agenda-item { display: block; padding: 8px 10px; border-radius: 12px; margin-bottom: 6px; font-size: .82rem; background: var(--amber-soft); color: var(--text); }
.agenda-item summary { cursor: pointer; list-style: none; }
.agenda-item summary::-webkit-details-marker { display: none; }
.agenda-item.st-confirmed { background: var(--brand-soft); }
.agenda-item.st-completed { background: var(--ok-bg); }
.agenda-item.st-no_show { background: var(--crit-bg); }
.agenda-item.st-cancelled { opacity: .55; text-decoration: line-through; background: var(--bg-2); }
.agenda-item.block { background: var(--warn-bg); }
.book-link { word-break: break-all; }
.rail-form .fields { grid-template-columns: 1fr; }
.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; }

/* WhatsApp (enlaces wa.me, sin la API) */
.btn-wa { background: #25D366; border-color: #25D366; color: #052E16; }
.btn-wa:hover { background: #1EBE5A; border-color: #1EBE5A; color: #052E16; }
.wa-btn { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 30px; height: 30px; margin-left: 4px;
  border-radius: 50%; color: #1FAF54; background: color-mix(in srgb, #25D366 12%, transparent); }
.wa-btn:hover { color: #052E16; background: #25D366; }
.wa-btn .icon { width: 17px; height: 17px; }

/* ----------------------------------------------------------------------
   «Huerta clara»: cuadraditos de color, indicadores y agenda del panel
   ---------------------------------------------------------------------- */
.tile { width: 46px; height: 46px; border-radius: 14px; display: inline-grid; place-items: center; flex: none; background: var(--brand-soft); color: var(--brand); }
.tile .icon { width: 21px; height: 21px; vertical-align: 0; }
.tile-sm { width: 36px; height: 36px; border-radius: 11px; }
.tile-sm .icon { width: 17px; height: 17px; }
.tile-teal  { background: var(--brand-soft); color: var(--brand); }
.tile-amber { background: var(--amber-soft); color: var(--amber-ink); }
.tile-peach { background: var(--peach-soft); color: var(--peach-ink); }
.tile-sky   { background: var(--sky-soft);   color: var(--sky-ink); }
.tile-rose  { background: var(--rose-soft);  color: var(--rose-ink); }
.tile-solid { background: var(--fill); color: var(--fill-ink); }

.kpi { display: flex; align-items: center; gap: 16px; padding: 20px 22px; color: inherit; transition: box-shadow .2s ease-out; }
a.kpi:hover { text-decoration: none; box-shadow: var(--shadow-lg); }
.kpi-label { font-size: .88rem; color: var(--text-2); font-weight: 550; }
.kpi-value { font-size: 2rem; font-weight: 750; letter-spacing: -.03em; line-height: 1.05; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi-foot { font-size: .82rem; color: var(--text-3); margin-top: 2px; }
.kpi-warn { background: var(--warn-bg); border-color: var(--warn-line); }
.kpi-warn .kpi-value { color: var(--warn); }

.greeting h1 { font-size: 1.9rem; }
.greeting p { margin: 4px 0 0; color: var(--text-2); }

.card-head.plain { border-bottom: 0; padding-bottom: 6px; }
.card-head.plain + .card-body, .card-head.plain + .list-pad { padding-top: 4px; }

.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.week-day { display: grid; justify-items: center; gap: 3px; padding: 9px 0 8px; border-radius: 14px; color: var(--text-3); font-size: .76rem; font-weight: 650; }
.week-day strong { font-size: 1.1rem; color: var(--text); font-weight: 750; }
.week-day.is-today { background: var(--fill); color: var(--fill-ink); box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--fill) 70%, transparent); }
.week-day.is-today strong { color: var(--fill-ink); }
.week-dot { width: 5px; height: 5px; border-radius: 99px; background: var(--peach); }
.week-day.is-today .week-dot { background: var(--fill-ink); }
.week-dot.is-empty { background: transparent; }

.appt-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.appt { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 16px; background: var(--surface-2); color: inherit; }
a.appt:hover { text-decoration: none; background: var(--bg-2); }
.appt-time { font-weight: 750; font-size: .95rem; font-variant-numeric: tabular-nums; min-width: 46px; }
.appt-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt-sub { font-size: .8rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt-day { font-size: .82rem; font-weight: 700; color: var(--text-3); margin: 8px 2px 2px; }

@media (max-width: 600px) {
  .grid-4 { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpi { flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px; }
  .kpi-value { font-size: 1.7rem; }
  .greeting h1 { font-size: 1.55rem; }
}


/* ----------------------------------------------------------------------
   Ficha del paciente: encabezado verde (mismo idioma que el portal)
   ---------------------------------------------------------------------- */
.pt-hero { position: relative; overflow: hidden; border-radius: 26px; padding: 26px 28px 24px; color: #E4F2EE;
  background: radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--accent) 34%, var(--hero)) 0%, var(--hero) 55%, var(--hero-2) 100%);
  box-shadow: 0 18px 40px -24px color-mix(in srgb, var(--hero) 80%, transparent); }
.pt-top { display: flex; justify-content: space-between; gap: 20px 28px; flex-wrap: wrap; }
.pt-id { display: flex; gap: 18px; align-items: flex-start; min-width: 0; flex: 1 1 380px; }
.pt-avatar { width: 64px; height: 64px; border-radius: 20px; flex: none; display: grid; place-items: center; font-weight: 800; font-size: 1.3rem; color: var(--accent-ink); background: var(--accent); box-shadow: 0 10px 22px -12px rgba(0,0,0,.5); }
.pt-hero h1 { color: #fff; font-size: 1.85rem; letter-spacing: -.03em; }
.pt-meta { color: #B9DAD2; font-size: .92rem; margin-top: 4px; }
.pt-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.pt-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 99px; font-size: .82rem; font-weight: 650; color: #fff; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.12); }
a.pt-chip:hover { text-decoration: none; background: rgba(255,255,255,.2); }
.pt-chip.is-warn { background: #FFE2B8; color: #6B3A04; border-color: transparent; }
.pt-chip.is-crit { background: #FFD7CF; color: #7F2214; border-color: transparent; }
a.pt-chip.is-crit:hover { background: #FFC8BD; }
.pt-side { display: grid; gap: 12px; justify-items: end; align-content: start; }
.pt-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.btn-hero { background: #fff; border-color: #fff; color: var(--hero); box-shadow: 0 10px 22px -14px rgba(0,0,0,.6); }
.btn-hero:hover { background: #F1FBF8; border-color: #F1FBF8; color: var(--hero); }
.btn-hero-soft { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.18); color: #fff; }
.btn-hero-soft:hover { background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.26); color: #fff; }
.pt-contact { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; font-size: .9rem; color: #CFE6E0; }
.pt-contact a { color: #fff; }
.pt-sep { width: 4px; height: 4px; border-radius: 99px; background: rgba(255,255,255,.4); }
.pt-wa { width: 38px; height: 38px; border-radius: 12px; display: inline-grid; place-items: center; background: #fff; color: #1FAF54; box-shadow: 0 8px 18px -12px rgba(0,0,0,.6); }
.pt-wa:hover { background: #E9FBF0; }
.pt-wa .icon { width: 20px; height: 20px; vertical-align: 0; }
.pt-add { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.pt-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.1fr); gap: 12px; margin-top: 24px; }
.pt-num { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.1); border-radius: 18px; padding: 14px 18px; }
.pt-num-label { font-size: .84rem; color: #B9DAD2; font-weight: 600; }
.pt-num-value { font-size: 2.3rem; font-weight: 800; letter-spacing: -.04em; color: #fff; line-height: 1.05; margin-top: 2px; font-variant-numeric: tabular-nums; }
.pt-num-value small { font-size: .95rem; font-weight: 600; color: #B9DAD2; margin-left: 4px; letter-spacing: 0; }
.pt-num-sub { font-size: .82rem; color: #CFE6E0; margin-top: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pt-num-sub a { color: #fff; font-weight: 650; }
.pt-dot { width: 8px; height: 8px; border-radius: 99px; display: inline-block; flex: none; background: #8FD3FF; }
.pt-dot.is-ok { background: #7EE2A8; }
.pt-dot.is-warn { background: #FFC56B; }
.pt-dot.is-crit { background: #FF9A85; }
.pt-num-mini { display: grid; gap: 6px; align-content: center; padding: 10px 18px; border-radius: 18px; border: 1px dashed rgba(255,255,255,.2); }
.pt-num-mini > div { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.pt-num-mini span { color: #B9DAD2; width: 62px; }
.pt-num-mini strong { color: #fff; font-variant-numeric: tabular-nums; }
.pt-num-mini em { margin-left: 2px; }
@media (max-width: 1100px) {
  .pt-nums { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pt-num-mini { grid-column: 1 / -1; grid-template-columns: repeat(3, auto); justify-content: start; gap: 6px 28px; }
}
@media (max-width: 720px) {
  .pt-hero { padding: 20px 18px; border-radius: 22px; }
  .pt-side { justify-items: start; }
  .pt-actions, .pt-contact { justify-content: flex-start; }
  .pt-nums { grid-template-columns: 1fr 1fr; }
  .pt-num-value { font-size: 1.8rem; }
  .pt-num-mini { grid-template-columns: 1fr; }
}

/* Menús desplegables (más acciones, + Nuevo) */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; min-width: 220px; padding: 6px; display: grid; gap: 2px;
  background: var(--surface); border: 1px solid var(--card-line); border-radius: 16px; box-shadow: var(--shadow-lg); animation: pop .16s ease-out; }
.menu-pop a, .menu-pop button { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 11px; color: var(--text); font: inherit; font-weight: 600; font-size: .92rem; background: none; border: 0; cursor: pointer; text-align: left; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--bg-2); text-decoration: none; }
.menu-pop .icon { color: var(--text-2); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .menu-pop { animation: none; } }

/* Menú lateral agrupado */
.nav-fold { margin-bottom: 4px; }
.nav-fold > summary { list-style: none; cursor: pointer; }
.nav-fold > summary::-webkit-details-marker { display: none; }
.nav-caret { margin-left: auto; transition: transform .18s ease-out; }
.nav-fold[open] > summary .nav-caret { transform: rotate(90deg); }
.nav-fold-items { display: grid; gap: 1px; padding: 2px 0 6px 12px; margin-left: 22px; border-left: 1px solid var(--border-2); }
.nav-sub { font-size: .9rem; padding: 7px 12px; }
.nav-bottom { margin-top: 10px; }
@media (max-width: 1024px) {
  .nav-fold-items { padding-left: 0; margin-left: 0; border-left: 0; }
  .nav-caret { display: none; }
  .nav-sub { justify-content: center; padding: 10px; }
}

/* Resumen de la IA plegado y asistente compacto */
.ai-collapsible:not(.is-open) { max-height: 290px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.ai-more { display: block; width: 100%; padding: 12px; border: 0; border-top: 1px solid var(--border); background: none; color: var(--brand); font: inherit; font-weight: 650; cursor: pointer; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.ai-more:hover { background: var(--surface-2); }
.ai-out p { max-width: 75ch; }
.asst-card:not(:focus-within) [data-asst-chips] { display: none; }
.asst-card .asst-form textarea { min-height: 46px; height: 46px; transition: height .18s ease-out; }
.asst-card:focus-within .asst-form textarea { height: 84px; }
/* El logo de WhatsApp es relleno, no trazo como el resto de los íconos. */
.icon.icon-wa { fill: currentColor; stroke: none; }
.pt-contact .pt-wa { color: #1FAF54; }
.food-cell { display: flex; gap: 12px; align-items: flex-start; }
.food-cell .tile { margin-top: 2px; }
.flow-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; counter-reset: paso; }
.flow-steps li { display: flex; gap: 14px; align-items: center; padding: 18px 20px; background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--radius-lg); box-shadow: var(--shadow); position: relative; }
.flow-steps li div { display: grid; gap: 2px; }
.flow-steps strong { font-size: .98rem; }
.flow-steps span:not(.tile) { font-size: .84rem; color: var(--text-2); }
@media (max-width: 900px) { .flow-steps { grid-template-columns: 1fr; } }


/* ----------------------------------------------------------------------
   Gráficos y movimiento (paletas validadas con dataviz/validate_palette.js)
   ---------------------------------------------------------------------- */
:root {
  --cat-1: #0A9A85; --cat-2: #E2683A; --cat-3: #3B7DC4; --cat-4: #E09A1F; --cat-5: #8B62C6; --cat-6: #6C8A2B;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}
:root[data-theme="dark"] {
  --cat-1: #16A88D; --cat-2: #DA6C40; --cat-3: #5A93D8; --cat-4: #B5871F; --cat-5: #9A78DE; --cat-6: #73983A;
}

/* Entrada: las tarjetas suben apenas, una tras otra. Visibles aunque no haya animación. */
.anim-rise { animation: rise .7s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.card.kpi, .chart-card { transition: transform .25s var(--ease-out), box-shadow .25s var(--ease-out); }
.card.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card.kpi .tile { transition: transform .35s var(--ease-out); }
.card.kpi:hover .tile { transform: rotate(-6deg) scale(1.06); }

/* Banda principal del panel */
.dash-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 28px; align-items: center; margin-bottom: 22px;
  padding: 30px 34px; border-radius: 28px; color: #E4F2EE; position: relative; overflow: hidden;
  background: radial-gradient(90% 160% at 100% 0%, color-mix(in srgb, var(--accent) 40%, var(--hero)) 0%, var(--hero) 52%, var(--hero-2) 100%);
  box-shadow: 0 22px 48px -26px color-mix(in srgb, var(--hero) 85%, transparent); }
.dash-hero::after { content: ""; position: absolute; width: 420px; height: 420px; right: -120px; bottom: -260px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--peach) 30%, transparent), transparent 70%); pointer-events: none; }
.dash-hero h1 { color: #fff; font-size: 2.1rem; letter-spacing: -.035em; }
.dash-hero p { color: #B9DAD2; margin: 6px 0 0; }
.dash-hero-stats { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.dash-hero-stats a { display: grid; gap: 0; min-width: 150px; padding: 14px 18px; border-radius: 18px; color: #fff;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.1); transition: background .2s var(--ease-out), transform .25s var(--ease-out); }
.dash-hero-stats a:hover { text-decoration: none; background: rgba(255,255,255,.14); transform: translateY(-2px); }
.dash-hero-stats strong { font-size: 2.4rem; font-weight: 800; letter-spacing: -.04em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.dash-hero-stats span { font-size: .86rem; color: #CFE6E0; }
.dash-hero-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 20px; }
.dash-hero-ring { display: grid; justify-items: center; gap: 10px; position: relative; z-index: 1; max-width: 230px; text-align: center; }
.ring-wrap { position: relative; width: 190px; height: 190px; }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-center strong { font-size: 2.8rem; font-weight: 800; color: #fff; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.ring-center strong small { font-size: 1.1rem; font-weight: 700; margin-left: 2px; color: #CFE6E0; }
.ring-center > span { font-size: .84rem; color: #CFE6E0; margin-top: 4px; }
.ring-caption { font-size: .82rem; color: #CFE6E0; line-height: 1.4; }
@media (max-width: 900px) {
  .dash-hero { grid-template-columns: 1fr; padding: 24px 20px; }
  .dash-hero-ring { grid-template-columns: auto 1fr; justify-items: start; text-align: left; max-width: none; align-items: center; }
  .ring-wrap { width: 130px; height: 130px; }
  .ring-center strong { font-size: 2rem; }
  .dash-hero-stats a { min-width: 0; flex: 1 1 120px; }
  .dash-hero-stats strong { font-size: 1.9rem; }
}

/* SVG comunes */
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart-body { padding-top: 0; }
.chart-cols, .chart-area { aspect-ratio: 640 / 215; }
.chart-grid { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-base { stroke: var(--border-2); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-goal { stroke: var(--text-3); stroke-width: 1.2; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.chart-axis { fill: var(--text-3); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart-hit { outline: none; cursor: default; }
.chart-hitbox { fill: transparent; }
.chart-hit:hover .chart-hitbox, .chart-hit:focus-visible .chart-hitbox { fill: color-mix(in srgb, var(--accent) 7%, transparent); }

.chart-col { fill: var(--accent); transform-box: fill-box; transform-origin: 50% 100%; animation: grow-y .9s var(--ease-out) both; animation-delay: calc(240ms + var(--i, 0) * 45ms); transition: fill .15s; }
.chart-hit:hover .chart-col, .chart-hit:focus-visible .chart-col { fill: var(--brand); }
.chart-zero { fill: var(--border-2); }
@keyframes grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }

.chart-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke;
  stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.4s var(--ease-out) .3s forwards; }
.chart-fill { fill: url(#areaFill); animation: fade-in 1s ease-out .6s both; }
.chart-cross { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; opacity: 0; transition: opacity .12s; }
.chart-dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; vector-effect: non-scaling-stroke; opacity: 0; transition: opacity .12s; }
.chart-hit:hover .chart-cross, .chart-hit:hover .chart-dot, .chart-hit:focus-visible .chart-cross, .chart-hit:focus-visible .chart-dot { opacity: 1; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Dona y anillo */
.chart-donut { width: 150px; height: 150px; flex: none; }
.donut-track { fill: none; stroke: var(--bg-2); stroke-width: 14; }
.donut-seg { fill: none; stroke-width: 14; transform: rotate(-90deg); transform-origin: 60px 60px; outline: none;
  animation: seg .9s var(--ease-out) both; animation-delay: calc(300ms + var(--i, 0) * 120ms); transition: stroke-width .15s; }
.donut-seg:hover, .donut-seg:focus-visible { stroke-width: 18; }
@keyframes seg { from { stroke-dasharray: 0 100; } }
.donut-center { fill: var(--text); font-size: 26px; font-weight: 800; font-family: var(--font); letter-spacing: -.03em; }
.donut-sub { fill: var(--text-3); font-size: 10px; font-family: var(--font); }
.donut-row { display: flex; gap: 20px; align-items: center; }
.legend-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; flex: 1; min-width: 0; }
.legend-list li { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; font-size: .88rem; }
.legend-list .dot { width: 10px; height: 10px; border-radius: 3px; margin: 0; }
.legend-list strong { font-variant-numeric: tabular-nums; }
@media (max-width: 420px) { .donut-row { flex-direction: column; align-items: stretch; } .chart-donut { margin: 0 auto; } }

.chart-ring { width: 100%; height: 100%; }
.ring-track { fill: none; stroke: rgba(255,255,255,.12); stroke-width: 11; }
.ring-val { fill: none; stroke: var(--accent); stroke-width: 11; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 60px 60px;
  animation: seg 1.6s var(--ease-out) .25s both; filter: drop-shadow(0 0 10px color-mix(in srgb, var(--accent) 55%, transparent)); }

/* Barras horizontales (IMC) */
.hbars { display: grid; gap: 12px; }
.hbar { display: grid; grid-template-columns: 128px minmax(0, 1fr) 28px; gap: 10px; align-items: center; outline: none; border-radius: 10px; }
.hbar:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.hbar-label { font-size: .86rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 12px; background: var(--bg-2); border-radius: 99px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; width: var(--w); border-radius: 99px; background: var(--peach);
  transform-origin: left; animation: grow-x .9s var(--ease-out) both; animation-delay: calc(300ms + var(--i, 0) * 80ms); }
.hbar:hover .hbar-fill { background: var(--peach-ink); }
.hbar-n { text-align: right; font-variant-numeric: tabular-nums; }
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* Tooltip de los gráficos (lo posiciona app.js) */
.chart-tip { position: fixed; z-index: 90; pointer-events: none; max-width: 260px; padding: 8px 12px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-size: .82rem; font-weight: 600; line-height: 1.35; box-shadow: var(--shadow-lg);
  transform: translate(-50%, calc(-100% - 12px)); opacity: 0; transition: opacity .12s; }
.chart-tip.is-on { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .anim-rise, .chart-col, .chart-fill, .donut-seg, .ring-val, .hbar-fill { animation: none; }
  .chart-line { animation: none; stroke-dashoffset: 0; }
  .card.kpi:hover, .card.kpi:hover .tile, .dash-hero-stats a:hover { transform: none; }
}
@media (max-width: 600px) {
  .chart-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .chart-body > .chart-cols, .chart-body > .chart-area { min-width: 560px; }
}
.col-wa { width: 56px; }
.col-wa .wa-btn { margin-left: 0; width: 36px; height: 36px; border-radius: 12px; }
.portal-head > .person > div { min-width: 0; }

/* Consultorio de demostración: franja fija arriba con el acceso a crear el propio */
.demo-bar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap;
  padding: 10px 32px; background: var(--fill); color: var(--fill-ink); font-size: .9rem; }
.demo-bar .icon { vertical-align: -3px; }
.demo-bar-cta { background: #fff; color: var(--fill); border-color: #fff; font-weight: 700; }
.demo-bar-cta:hover { background: #F1FBF8; color: var(--fill); }
.demo-bar + .topbar { top: 44px; }
@media (max-width: 760px) { .demo-bar { padding: 10px 16px; font-size: .84rem; } .demo-bar + .topbar { top: 0; position: relative; } }
.demo-bar-actions { display: flex; align-items: center; gap: 8px; }
.demo-bar-close { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px 6px 9px; border-radius: 99px; color: var(--fill-ink); font-weight: 650; font-size: .84rem;
  border: 1px solid rgba(255,255,255,.45); transition: background .15s; }
.demo-bar-close:hover { background: rgba(255,255,255,.16); text-decoration: none; color: var(--fill-ink); }
@media (max-width: 760px) { .demo-bar-close span { display: none; } .demo-bar-close { padding: 6px 8px; } }
