/* Evolua Nutri — paleta inspirada no hofglow.com.br */
:root {
  --navy-900: #04081a;
  --navy-800: #070b1c;
  --navy-700: #0c1736;
  --navy-600: #1a2448;
  --gold: #d8b26e;
  --gold-light: #f1d59c;
  --gold-dark: #b8863f;
  --gold-ink: #82612e;
  --rose: #ebbab5;
  --rose-soft: #f3e1da;
  --cream: #fbf4f1;
  --sand: #e9d6d1;
  --text: #0c1736;
  --text-2: #5d5a6b;
  --muted: #8c8796;
  --line: #eadfdb;
  --white: #ffffff;
  --good: #3c8d6e;
  --good-bg: #e3f2ec;
  --bad: #c0564b;
  --bad-bg: #f9e4e1;
  --neutral-bg: #efeaf0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(12, 23, 54, .06), 0 6px 24px rgba(12, 23, 54, .06);
  --font: 'Jost', 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--text); background: var(--cream); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--gold-ink); }
h1, h2, h3, h4 { font-weight: 500; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
small, .muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, #000 0%, var(--navy-900) 40%, var(--navy-700) 100%);
  color: #f4ecea; padding: 28px 18px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; margin: 0 8px 28px; }
.brand-mark { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(180deg, var(--gold-light), var(--gold) 55%, var(--gold-dark)); display: grid; place-items: center; color: var(--navy-900); font-weight: 600; }
.brand-name { font-size: 1.25rem; letter-spacing: .02em; }
.brand-name b { color: var(--gold); font-weight: 500; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: #c9b6b8; text-decoration: none; font-size: .97rem; }
.nav a:hover { background: rgba(216, 178, 110, .08); color: #f4ecea; }
.nav a.active { background: rgba(216, 178, 110, .16); color: var(--gold-light); }
.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar .spacer { flex: 1; }
.main { padding: 32px clamp(16px, 4vw, 44px) 60px; max-width: 1200px; width: 100%; min-width: 0; }

.topbar { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .topbar .brand-name { font-size: 1rem; white-space: nowrap; }
  .topbar .brand-mark { width: 28px; height: 28px; }
  .sidebar { display: none; }
  .topbar { display: flex; align-items: center; justify-content: space-between; background: var(--navy-900); color: #f4ecea; padding: 12px 16px; position: sticky; top: 0; z-index: 20; }
  .topbar nav { display: flex; gap: 4px; }
  .topbar nav a { color: #c9b6b8; text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: .9rem; }
  .topbar nav a.active { color: var(--gold-light); background: rgba(216, 178, 110, .16); }
  .main { padding: 20px 14px 60px; }
}

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 0; color: var(--text-2); }
.crumb { font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
.crumb a { color: var(--muted); text-decoration: none; }

/* ---------- componentes ---------- */
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; border: 1px solid #f1e8e4; }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .stat .value { font-size: 1.3rem; } }

.btn { font: inherit; border: 1px solid transparent; border-radius: 999px; padding: 9px 18px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-size: .95rem; line-height: 1.2; white-space: nowrap; }
.btn-primary { background: linear-gradient(180deg, var(--gold-light), var(--gold) 55%, var(--gold-dark)); color: var(--navy-900); font-weight: 500; }
.btn-primary:hover { filter: brightness(1.04); }
.btn-dark { background: var(--navy-700); color: #f4ecea; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: var(--rose-soft); }
.btn-danger { background: transparent; border-color: #efc9c4; color: var(--bad); }
.btn-sm { padding: 5px 12px; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

label { display: block; font-size: .85rem; color: var(--text-2); margin-bottom: 4px; }
input, select, textarea {
  font: inherit; width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fffdfc; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(216, 178, 110, .5); border-color: var(--gold); }
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: 14px; }
.field .hint { font-size: .78rem; color: var(--muted); margin-top: 3px; }
.input-unit { position: relative; }
.input-unit input { padding-right: 44px; }
.input-unit span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: .8rem; color: var(--muted); pointer-events: none; }
.input-unit input.computed { background: #f7f1e6; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; color: var(--text); }
.check input { width: auto; margin-top: 4px; }

fieldset { border: 0; padding: 0; margin: 0 0 6px; }
details.section { border-top: 1px solid var(--line); padding: 14px 0 4px; }
details.section > summary { cursor: pointer; font-weight: 500; list-style: none; display: flex; justify-content: space-between; margin-bottom: 12px; }
details.section > summary::after { content: '+'; color: var(--gold-dark); font-size: 1.2rem; }
details.section[open] > summary::after { content: '–'; }

table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid #f4ece9; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #fdf8f6; }
.table-wrap { overflow-x: auto; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text); border-bottom-color: var(--gold); }

.stat { background: var(--white); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); border: 1px solid #f1e8e4; }
.stat .label { font-size: .82rem; color: var(--muted); }
.stat .value { font-size: 1.6rem; font-weight: 500; line-height: 1.2; margin-top: 2px; }
.stat .value small { font-size: .85rem; font-weight: 400; }
.delta { display: inline-block; font-size: .78rem; padding: 2px 8px; border-radius: 999px; margin-top: 6px; }
.delta.good { background: var(--good-bg); color: var(--good); }
.delta.bad { background: var(--bad-bg); color: var(--bad); }
.delta.neutral { background: var(--neutral-bg); color: var(--text-2); }

.pill { display: inline-block; font-size: .75rem; padding: 2px 9px; border-radius: 999px; background: var(--rose-soft); color: var(--gold-ink); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty h3 { color: var(--text); }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #f4ece9; }
.list li:last-child { border-bottom: 0; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(160deg, var(--rose-soft), var(--sand)); color: var(--gold-ink); display: grid; place-items: center; font-weight: 500; flex: none; }
.row { display: flex; align-items: center; gap: 12px; }

.progress { height: 8px; background: #f1e8e4; border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-dark)); }

.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 170px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(180deg, #000 0%, #03050c 40%, var(--navy-700) 100%); padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: rgba(12, 23, 54, .55); border: 1px solid rgba(216, 178, 110, .24); border-radius: 20px; padding: 34px 30px; color: #f4ecea; backdrop-filter: blur(8px); }
.login-card label { color: #c9b6b8; }
.login-card input { background: rgba(255, 255, 255, .06); border-color: rgba(216, 178, 110, .3); color: #f4ecea; }
.login-card .brand { justify-content: center; margin-bottom: 8px; }
.login-card p { text-align: center; color: #c9b6b8; margin: 0 0 24px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 6px; }
.error { color: var(--bad); font-size: .88rem; margin-top: 8px; }
.login-card .error { color: var(--rose); }

/* ---------- toast & modal ---------- */
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--navy-700); color: #f4ecea; padding: 11px 20px; border-radius: 999px; box-shadow: var(--shadow); z-index: 100; font-size: .92rem; opacity: 0; transition: opacity .2s; pointer-events: none; }
#toast.show { opacity: 1; }
#toast.err { background: var(--bad); }
.modal-bg { position: fixed; inset: 0; background: rgba(4, 8, 26, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--white); border-radius: 18px; padding: 24px; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(4, 8, 26, .3); }
.modal h2 { margin-bottom: 16px; }
.modal .btn-row { justify-content: flex-end; margin-top: 10px; }

.loading { padding: 50px; text-align: center; color: var(--muted); }

/* ---------- relatório PDF (renderizado fora da tela) ---------- */
.report-host { position: fixed; left: -10000px; top: 0; }
.rpage { width: 794px; height: 1123px; background: #fffdfc; color: var(--text); font-family: var(--font); position: relative; overflow: hidden; display: flex; flex-direction: column; }
.rhead { background: linear-gradient(170deg, var(--navy-700), var(--navy-900)); color: #f4ecea; padding: 34px 48px 30px; display: flex; justify-content: space-between; align-items: center; }
.rhead .who { font-size: 13px; color: #c9b6b8; line-height: 1.45; }
.rhead .who strong { color: var(--gold-light); font-weight: 500; font-size: 15px; display: block; }
.rhead img { max-height: 54px; max-width: 170px; }
.rhead .rbrand { font-size: 22px; color: var(--gold-light); }
.rtitle { padding: 30px 48px 6px; }
.rtitle .hello { font-size: 26px; font-weight: 500; }
.rtitle .sub { color: var(--text-2); font-size: 14px; }
.rbody { padding: 14px 48px 0; flex: 1; min-height: 0; overflow: hidden; }
.rsection { margin-top: 22px; }
.rsection h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .12em; color: var(--gold-ink); font-weight: 500; margin-bottom: 12px; }
.rcards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.rcard { background: var(--white); border: 1px solid #efe4df; border-radius: 14px; padding: 14px 16px; }
.rcard .l { font-size: 12.5px; color: var(--text-2); }
.rcard .v { font-size: 27px; font-weight: 500; line-height: 1.15; margin: 3px 0 2px; }
.rcard .v small { font-size: 13px; color: var(--muted); font-weight: 400; }
.rcard .d { font-size: 12px; font-weight: 500; }
.rcard .d.good { color: var(--good); }
.rcard .d.bad { color: var(--bad); }
.rcard .d.neutral { color: var(--muted); }
.rcard .e { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.35; }
.rchart { background: var(--white); border: 1px solid #efe4df; border-radius: 14px; padding: 12px 14px; }
.rchart img { width: 100%; display: block; }
.rmsg { background: var(--rose-soft); border-radius: 14px; padding: 16px 20px; font-size: 14.5px; line-height: 1.6; white-space: pre-wrap; }
.rguide { font-size: 14px; line-height: 1.65; white-space: pre-wrap; }
.rgoal { display: grid; grid-template-columns: 1fr 210px; gap: 14px; align-items: center; padding: 8px 0; font-size: 14px; border-bottom: 1px solid #f4ece9; }
.rnext { margin-top: 18px; background: var(--navy-700); color: #f4ecea; border-radius: 14px; padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.rnext strong { color: var(--gold-light); font-weight: 500; font-size: 16px; }
.rfoot { padding: 14px 48px 22px; font-size: 10.5px; color: var(--muted); display: flex; justify-content: space-between; border-top: 1px solid #f1e8e4; margin-top: 16px; }

/* ================= v2: camadas, menus e cartões clicáveis ================= */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input[type=search], .toolbar .search { flex: 1 1 260px; max-width: 420px; }
.toolbar select { width: auto; min-width: 150px; }
.select-label { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--text-2); }
.select-label select { padding: 7px 10px; }

/* cartões clicáveis (pacientes, consultas) */
.plist { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.pcard { background: var(--white); border: 1px solid #f1e8e4; border-radius: var(--radius); box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s; }
.pcard:hover { border-color: var(--gold); }
.pcard.open { border-color: var(--gold); box-shadow: 0 8px 30px rgba(12, 23, 54, .1); }
.pcard-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; cursor: pointer; user-select: none; }
.pcard-row:active { background: #fdf8f6; border-radius: var(--radius); }
.pcard-main { flex: 1; min-width: 0; }
.pcard-name { font-weight: 500; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard-sub { font-size: .85rem; color: var(--muted); }
.chev { color: var(--gold-dark); line-height: 0; transition: transform .2s; flex: none; display: inline-flex; }
.pcard.open .chev { transform: rotate(90deg); }
.pcard-more { border-top: 1px solid var(--line); padding: 14px 16px 16px; display: none; }
.pcard.open .pcard-more { display: block; }
.mini-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.mini-stat { background: #fdf8f6; border-radius: 12px; padding: 10px 12px; }
.mini-stat .label { font-size: .75rem; color: var(--muted); }
.mini-stat .value { font-size: 1.15rem; font-weight: 500; }
.mini-stat .delta { margin-top: 2px; font-size: .72rem; }
.spark { width: 100%; height: 34px; display: block; margin-top: 4px; }
@media (max-width: 520px) { .mini-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.tag { display: inline-block; font-size: .75rem; padding: 2px 9px; border-radius: 999px; background: var(--neutral-bg); color: var(--text-2); white-space: nowrap; }
.tag.gold { background: #f7ecd6; color: var(--gold-ink); }
.tag.warn { background: var(--bad-bg); color: var(--bad); }

/* navegação da ficha: 4 seções grandes */
.secnav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 20px; }
.secnav a { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 10px; border-radius: 14px; background: var(--white); border: 1px solid var(--line); color: var(--text-2); text-decoration: none; font-weight: 500; transition: all .15s; }
.secnav a svg { width: 19px; height: 19px; }
.secnav a:hover { border-color: var(--gold); color: var(--text); }
.secnav a.active { background: var(--navy-700); border-color: var(--navy-700); color: var(--gold-light); box-shadow: 0 6px 18px rgba(12, 23, 54, .18); }
@media (max-width: 640px) { .secnav { grid-template-columns: repeat(3, minmax(0, 1fr)); } .secnav a { padding: 10px 6px; font-size: .9rem; } }

/* menu suspenso ⋯ */
.menu-wrap { position: relative; display: inline-block; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--white); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 14px 40px rgba(12, 23, 54, .16); min-width: 230px; padding: 6px; z-index: 30; display: none; }
.menu.show { display: block; }
.menu a, .menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; border: 0; background: none; font: inherit; color: var(--text); text-decoration: none; cursor: pointer; text-align: left; }
.menu a:hover, .menu button:hover { background: var(--rose-soft); }
.menu .danger { color: var(--bad); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* blocos recolhíveis */
details.block { background: var(--white); border: 1px solid #f1e8e4; border-radius: var(--radius); box-shadow: var(--shadow); margin-top: 12px; }
details.block > summary { list-style: none; cursor: pointer; padding: 16px 18px; display: flex; align-items: center; gap: 12px; }
details.block > summary::-webkit-details-marker { display: none; }
details.block > summary .t { font-weight: 500; flex: 1; }
details.block > summary .s { font-size: .85rem; color: var(--muted); }
details.block > summary::after { content: ''; width: 8px; height: 8px; border-right: 2px solid var(--gold-dark); border-bottom: 2px solid var(--gold-dark); transform: rotate(-45deg); transition: transform .2s; margin: 0 4px; flex: none; }
details.block[open] > summary::after { transform: rotate(45deg); }
details.block > .body { padding: 0 18px 18px; }

/* chips de escolha (anamnese, personalização) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: .85rem; border: 1px solid var(--line); background: #fffdfc; color: var(--text-2); border-radius: 999px; padding: 5px 12px; cursor: pointer; transition: all .12s; }
.chip:hover { border-color: var(--gold); }
.chip.on { background: var(--navy-700); border-color: var(--navy-700); color: #f4ecea; }
.chip.on::before { content: '✓ '; color: var(--gold-light); }
.q { padding: 12px 0; border-bottom: 1px solid #f4ece9; }
.q:last-child { border-bottom: 0; }
.q > label { font-size: .92rem; color: var(--text); font-weight: 500; margin-bottom: 8px; }
.q .sublabel { font-size: .8rem; color: var(--muted); margin: 10px 0 6px; }
.q textarea, .q input.obs { margin-top: 8px; min-height: 0; }
.q textarea { min-height: 60px; }

/* gráficos: botões de métrica */
.metric-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.metric-chips .chip.on::before { content: ''; }
.chart-box.lg { height: 320px; }

/* cartões de consulta */
.vcard { display: flex; align-items: center; gap: 16px; padding: 14px 16px; background: var(--white); border: 1px solid #f1e8e4; border-radius: var(--radius); box-shadow: var(--shadow); cursor: pointer; transition: border-color .15s; }
.vcard:hover { border-color: var(--gold); }
.vcard .when { min-width: 92px; }
.vcard .when strong { display: block; font-weight: 500; }
.vcard .nums { flex: 1; display: flex; gap: 18px; flex-wrap: wrap; font-size: .9rem; }
.vcard .nums span small { display: block; font-size: .72rem; color: var(--muted); }
.vcard .acts { display: flex; gap: 6px; align-items: center; }
@media (max-width: 640px) { .vcard { flex-wrap: wrap; } .vcard .acts { width: 100%; justify-content: flex-end; } }

.hint-line { font-size: .82rem; color: var(--muted); margin: -6px 0 14px; }
.stat.clickable { cursor: pointer; }
.stat.clickable:hover { border-color: var(--gold); }

/* ================= v3: carrossel e seletor de medidas ================= */
.car-dots { display: none; justify-content: center; gap: 6px; margin-top: 10px; }
.car-dots.always { display: flex; }
.car-dots button { width: 7px; height: 7px; border-radius: 50%; border: 0; padding: 0; background: #e3d6d1; cursor: pointer; transition: all .2s; }
.car-dots button.on { background: var(--gold-dark); width: 18px; border-radius: 999px; }
@media (max-width: 640px) {
  .car-m { display: flex !important; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px; position: relative; scrollbar-width: none; padding-bottom: 2px; }
  .car-m::-webkit-scrollbar { display: none; }
  .car-m > * { flex: 0 0 calc(50% - 5px); scroll-snap-align: start; min-width: 0; }
  .car-m + .car-dots { display: flex; }
}
.slides-wrap { position: relative; }
.slides { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; position: relative; scrollbar-width: none; }
.slides::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; scroll-snap-align: start; min-width: 0; padding: 0 2px; }
.car-arrow { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--white); color: var(--gold-dark); font-size: 1.4rem; line-height: 1; cursor: pointer; box-shadow: var(--shadow); }
.car-arrow:hover { border-color: var(--gold); }
.car-arrow.prev { left: -14px; }
.car-arrow.next { right: -14px; }
@media (max-width: 640px) { .car-arrow { display: none; } }

.pk-top { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.pk-sel { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; min-height: 30px; align-items: center; }
.pk-count { font-size: .78rem; color: var(--muted); white-space: nowrap; padding-top: 6px; }
.pk-count.full { color: var(--gold-ink); font-weight: 500; }
.tag-x { display: inline-flex; align-items: center; gap: 4px; background: var(--navy-700); color: #f4ecea; border-radius: 999px; padding: 4px 6px 4px 12px; font-size: .85rem; }
.tag-x button { border: 0; background: rgba(255, 255, 255, .14); color: #f4ecea; width: 20px; height: 20px; border-radius: 50%; cursor: pointer; font-size: .9rem; line-height: 1; padding: 0; }
.tag-x button:hover { background: rgba(255, 255, 255, .3); }
.pk-search { margin-bottom: 8px; }
.pk-results:empty { display: none; }
.pk-results { margin-bottom: 8px; }
.pk-all > summary { cursor: pointer; font-size: .88rem; color: var(--gold-ink); padding: 4px 0; list-style: none; }
.pk-all > summary::-webkit-details-marker { display: none; }
.pk-group { border-top: 1px solid #f4ece9; }
.pk-group > summary { cursor: pointer; font-size: .85rem; padding: 8px 0; color: var(--text-2); }
.pk-group > .chips { padding-bottom: 10px; }

/* ================= v4: início e busca ================= */
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search-wrap input { padding-left: 42px; }
.hero-search { background: linear-gradient(170deg, var(--navy-700), var(--navy-900)); border: 0; color: #f4ecea; }
.hero-search .search-wrap input { font-size: 1.05rem; padding-top: 13px; padding-bottom: 13px; background: #fffdfc; }
.hero-search .list li { border-bottom-color: rgba(255, 255, 255, .08); }
.hero-search .list small, .hero-search .muted { color: #c9b6b8; }
.hero-search .list a.row { color: #f4ecea !important; }
.hero-search .chev { color: var(--gold-light); }
.hero-search .btn-ghost { color: #f4ecea; border-color: rgba(216, 178, 110, .4); }
.hero-search .btn-ghost:hover { background: rgba(216, 178, 110, .12); }
.mini-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--gold-light); margin: 16px 0 8px; }
.recent-row { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.recent-row::-webkit-scrollbar { display: none; }
.recent { flex: 0 0 auto; width: 96px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; border-radius: 14px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(216, 178, 110, .18); color: #f4ecea; text-decoration: none; text-align: center; transition: border-color .15s; }
.recent:hover { border-color: var(--gold); }
.recent .n { font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.recent small { color: #c9b6b8; font-size: .72rem; }
.seg { display: flex; background: #f5ede9; border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 8px; }
.seg button { flex: 1; font: inherit; font-size: .88rem; border: 0; background: none; padding: 7px 8px; border-radius: 9px; cursor: pointer; color: var(--text-2); }
.seg button b { font-weight: 500; margin-left: 4px; background: rgba(12, 23, 54, .08); border-radius: 999px; padding: 0 7px; font-size: .78rem; }
.seg button.on { background: var(--white); color: var(--text); box-shadow: 0 1px 4px rgba(12, 23, 54, .1); }
.seg button.alert b { background: var(--bad-bg); color: var(--bad); }
.list li .chev { margin-left: 4px; }

/* ================= plano alimentar: PDF ================= */
.dtargets { display: flex; gap: 12px; flex-wrap: wrap; }
.dtarget { background: var(--rose-soft); border-radius: 14px; padding: 12px 18px; min-width: 130px; }
.dtarget b { display: block; font-size: 22px; font-weight: 500; color: var(--text); }
.dtarget span { font-size: 12.5px; color: var(--text-2); }
.rsection.dmeal { margin-top: 14px; }
.dmeal-card { background: var(--white); border: 1px solid #efe4df; border-radius: 14px; padding: 14px 18px; }
.dmeal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.dtime { background: var(--navy-700); color: var(--gold-light); font-size: 13px; font-weight: 500; border-radius: 999px; padding: 3px 12px; min-width: 58px; text-align: center; }
.dtime:empty { display: none; }
.dname { font-size: 17px; font-weight: 500; }
.ditems { list-style: none; margin: 0; padding: 0; }
.ditems li { padding: 6px 0; border-bottom: 1px dashed #efe4df; font-size: 14px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; }
.ditems li:last-child { border-bottom: 0; }
.dfood { color: var(--text); }
.dqty { color: var(--text-2); white-space: nowrap; }
.dsubs { width: 100%; font-size: 12.5px; color: var(--gold-ink); font-style: italic; }
.dnotes { margin-top: 8px; font-size: 13px; color: var(--text-2); background: #fdf8f6; border-radius: 10px; padding: 8px 12px; white-space: pre-wrap; }

/* ================= plano alimentar: telas ================= */
.status { display: inline-block; font-size: .75rem; padding: 2px 10px; border-radius: 999px; font-weight: 500; }
.status.rascunho { background: #f7ecd6; color: var(--gold-ink); }
.status.enviado { background: var(--good-bg); color: var(--good); }
.status.substituido { background: var(--neutral-bg); color: var(--muted); }
.plan-current { border: 1px solid var(--gold); }
.meal { background: var(--white); border: 1px solid #f1e8e4; border-radius: var(--radius); box-shadow: var(--shadow); margin-top: 12px; }
.meal-head { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.meal-head .mtime { width: 128px; flex: none; }
.meal-head .mname { flex: 1; font-weight: 500; }
.meal-body { padding: 10px 14px 14px; }
.item { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, .7fr) minmax(0, 1.1fr) auto; gap: 8px; align-items: center; padding: 6px 0; }
.item + .item { border-top: 1px dashed #f1e8e4; }
.item .subs { grid-column: 1 / -1; }
.item .link-btn.subs { justify-self: start; padding: 0; }
.item input { padding: 7px 10px; }
.icon-btn { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 1.1rem; width: 30px; height: 30px; border-radius: 8px; }
.icon-btn:hover { background: var(--rose-soft); color: var(--bad); }
.link-btn { border: 0; background: none; color: var(--gold-ink); cursor: pointer; font: inherit; font-size: .85rem; padding: 4px 0; }
.savebar { position: sticky; bottom: 0; z-index: 15; background: rgba(251, 244, 241, .94); backdrop-filter: blur(6px); border-top: 1px solid var(--line); padding: 12px 0; margin-top: 18px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.savebar .saved { font-size: .85rem; color: var(--muted); margin-right: auto; }
@media (max-width: 640px) {
  .item { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .item .food { grid-column: 1 / -1; }
  .meal-head .mtime { width: 112px; }
}

/* ================= tabela de alimentos e cálculo ================= */
.item { grid-template-columns: minmax(0, 2.2fr) minmax(0, .6fr) minmax(0, 1.1fr) minmax(0, .8fr) auto; }
.item .nutri { grid-column: 1 / -1; font-size: .8rem; color: var(--muted); margin-top: -2px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.item .nutri:empty { display: none; }
.item .nutri .ok { color: var(--good); font-weight: 500; }
.item .nutri .warn, .daytot .warn { color: var(--gold-ink); }
.item .nutri .src { color: var(--muted); }
.item .nutri .link-btn { font-size: .8rem; }
.item .gram input { padding-right: 26px; }
.item .gram span { right: 9px; }
.ac-wrap { position: relative; }
.ac { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--white); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 40px rgba(12, 23, 54, .16); z-index: 25; display: none; max-height: 300px; overflow: auto; }
.ac.show { display: block; }
.ac-opt { padding: 8px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; align-items: baseline; font-size: .9rem; }
.ac-opt small { color: var(--muted); white-space: nowrap; font-size: .75rem; }
.ac-opt.on, .ac-opt:hover { background: var(--rose-soft); }
.mkcal { font-size: .82rem; color: var(--gold-ink); font-weight: 500; white-space: nowrap; margin-left: auto; }
.meal-head .mkcal { margin-left: 0; }
.daytot { width: 100%; font-size: .9rem; }
table.foods td { vertical-align: middle; }
@media (max-width: 640px) {
  .item { grid-template-columns: minmax(0, .8fr) minmax(0, 1.3fr) minmax(0, .9fr) auto; }
  .item .food { grid-column: 1 / -1; }
  .meal-head { flex-wrap: wrap; }
  .meal-head .mkcal { width: 100%; order: 5; }
}
