/* Fontes da marca (arquivos em /fonts, licença OFL).
   Títulos: Lunaris não tem licença web livre; usamos Young Serif no lugar.
   Se a Vanessa tiver o arquivo da Lunaris com licença para web, salve como
   /fonts/lunaris.woff2 e descomente o bloco abaixo: ela passa a ser usada sozinha. */
/* @font-face { font-family: 'Lunaris'; src: url('/fonts/lunaris.woff2') format('woff2'); font-weight: 400; font-display: swap; } */
@font-face { font-family: 'Young Serif'; src: url('/fonts/young-serif-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Open Sauce Sans'; src: url('/fonts/open-sauce-sans-latin-400-normal.woff') format('woff'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Open Sauce Sans'; src: url('/fonts/open-sauce-sans-latin-500-normal.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Open Sauce Sans'; src: url('/fonts/open-sauce-sans-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Open Sauce Sans'; src: url('/fonts/open-sauce-sans-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Open Sauce Sans'; src: url('/fonts/open-sauce-sans-latin-800-normal.woff2') format('woff2'); font-weight: 800; font-display: swap; }

/* Paleta da Vanessa: terracota #AF7051, azul #5A7883, sálvia #9FB0A0,
   névoa #C3D3D0, amarelinho #F5E6C7, creme #FFF2C5.
   A terracota e o azul ganharam versões mais escuras onde há texto,
   para manter a leitura confortável (contraste mínimo de 4,5:1). */
:root {
  --font-display: 'Lunaris', 'Young Serif', Georgia, serif;
  --font-body: 'Open Sauce Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --terracota: #AF7051;
  --azul: #5A7883;
  --salvia: #9FB0A0;
  --nevoa: #C3D3D0;
  --amarelinho: #F5E6C7;
  --creme: #FFF2C5;

  --bg: #FFF9EC;
  --card: #FFFFFF;
  --ink: #2B3A3F;
  --muted: #5C6A6D;
  --line: #EADFC6;
  --soft: var(--amarelinho);
  --primary: #985A3D;          /* terracota escura: botões e destaques com texto */
  --primary-2: var(--terracota);
  --primary-soft: #F9EDE5;
  --primary-tint: var(--nevoa);
  --on-primary: #FFFFFF;
  --azul-escuro: #45616B;
  --azul-soft: #E4ECEB;
  --border: #CDBFA3;
  --danger: #A3302A;
  --danger-soft: #F9E1DC;
  --warn: #7A4A12;
  --warn-soft: var(--creme);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .6; }
a { color: var(--primary); }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
[hidden] { display: none !important; }

.no-bar { scrollbar-width: none; -ms-overflow-style: none; }
.no-bar::-webkit-scrollbar { display: none; width: 0; height: 0; }

/* ---------- estrutura do app da paciente ---------- */
#app { max-width: 480px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; min-height: 100dvh; }
.scroll { flex: 1; overflow-y: auto; padding: 0 0 24px; display: flex; flex-direction: column; gap: 14px; }
.pad { margin: 0 16px; }

.topbar { padding: 22px 20px 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: calc(22px + env(safe-area-inset-top)); }
.kicker { font-size: 13px; font-weight: 600; color: var(--primary); }
.hello { font-size: 24px; font-weight: 800; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 13px; font-weight: 700; white-space: nowrap; }

.card { background: var(--card); border-radius: 24px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.card h2, .section-title { font-size: 17px; font-weight: 800; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 2px; }

.btn { min-height: 52px; padding: 0 18px; border-radius: 16px; border: 0; background: var(--primary); color: var(--on-primary); font-weight: 700; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn.dark { background: var(--ink); }
.btn.locked { background: transparent; color: var(--muted); border: 1.5px dashed var(--azul); }
.btn.sm { min-height: 44px; font-size: 14px; border-radius: 12px; padding: 0 14px; }
.link-btn { background: none; border: 0; padding: 8px; color: var(--muted); text-decoration: underline; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 700; }
.input { height: 54px; padding: 0 16px; border-radius: 16px; border: 1.5px solid var(--border); background: #fff; font-size: 16px; width: 100%; }
textarea.input { height: auto; min-height: 96px; padding: 12px 16px; resize: vertical; }
.error { color: var(--danger); font-size: 14px; font-weight: 600; }
.notice { padding: 12px 14px; border-radius: 14px; background: var(--warn-soft); color: var(--warn); font-size: 13px; font-weight: 600; }

/* ---------- entrada e boas-vindas ---------- */
.hero { background: var(--azul); color: #fff; border-radius: 0 0 36px 36px; padding: 32px 24px 36px; padding-top: calc(32px + env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 56px; position: relative; overflow: hidden; }
.hero::before, .hero::after { content: ''; position: absolute; border-radius: 999px; background: var(--salvia); opacity: .55; }
.hero::before { right: -70px; top: -50px; width: 240px; height: 240px; }
.hero::after { right: 30px; top: 150px; width: 90px; height: 90px; }
.hero::before, .hero::after { z-index: 0; }
.hero > * { position: relative; z-index: 1; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; background: #fff; color: var(--primary); display: flex; align-items: center; justify-content: center; }
.hero h1 { font-family: var(--font-display); font-size: 38px; font-weight: 400; line-height: 1.08; }
.form-area { padding: 28px 24px 24px; display: flex; flex-direction: column; gap: 16px; flex: 1; }
.steps { display: flex; flex-direction: column; gap: 12px; }
.step-n { flex: none; width: 36px; height: 36px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); font-weight: 800; display: flex; align-items: center; justify-content: center; }
.check-row { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; }
.check-row input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--primary); }

/* ---------- faixa de dias ---------- */
.days { display: flex; align-items: center; gap: 8px; overflow-x: auto; padding: 2px 16px; }
.day { flex: none; width: 48px; height: 74px; border-radius: 999px; border: 1.5px solid var(--salvia); color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.day .wd { font-size: 11px; font-weight: 600; }
.day .dd { font-size: 18px; font-weight: 800; line-height: 1; }
.day .sub { font-size: 11px; font-weight: 600; min-height: 13px; display: flex; align-items: center; }
.day.past { background: var(--nevoa); border-color: var(--nevoa); color: var(--ink); }
.day.today { width: 56px; height: 88px; background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* ---------- prato do dia ---------- */
.plate { display: flex; align-items: center; gap: 18px; }
.ring { flex: none; position: relative; width: 108px; height: 108px; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-num { font-size: 26px; font-weight: 800; line-height: 1; }

.tasks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.task { min-height: 124px; padding: 14px; text-align: left; background: var(--card); color: var(--ink); border: 0; border-radius: 20px; display: flex; flex-direction: column; justify-content: space-between; gap: 10px; }
.task .icon { width: 38px; height: 38px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; }
.task .dot { width: 24px; height: 24px; border-radius: 999px; border: 2px solid var(--azul); display: flex; align-items: center; justify-content: center; color: transparent; }
.task .label { font-weight: 700; line-height: 1.2; }
.task .sub { font-size: 12px; opacity: .85; }
.task.done { background: var(--primary); color: var(--on-primary); }
.task.done .icon { background: #fff; }
.task.done .dot { background: #fff; border-color: #fff; color: var(--primary); }

.next { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 18px; background: var(--soft); }

.drops { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.drop { height: 48px; padding: 0; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; color: var(--azul); }
.drop svg { fill: #fff; }
.drop.on { color: var(--azul); }
.drop.on svg { fill: var(--azul); }

.scale { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; padding: 5px; border-radius: 16px; background: var(--bg); }
.scale button { height: 46px; border-radius: 12px; border: 0; background: transparent; font-size: 16px; font-weight: 800; }
.scale button.on { background: var(--azul-escuro); color: #fff; }

.line-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--soft); }
.line-row:last-child { border-bottom: 0; padding-bottom: 0; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.marks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; text-align: center; }
.mark-n { width: 48px; height: 48px; margin: 0 auto 6px; border-radius: 16px; background: var(--soft); color: var(--muted); font-size: 18px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.mark.got .mark-n { background: var(--terracota); color: #fff; font-family: var(--font-display); font-weight: 400; }

/* ---------- plano e extras ---------- */
.guidance { background: var(--azul-escuro); color: #fff; border-radius: 24px; padding: 20px; white-space: pre-line; }
.meal { background: var(--card); border-radius: 20px; overflow: hidden; }
.meal-head { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 12px 16px; background: none; border: 0; text-align: left; }
.num { flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); font-weight: 800; display: flex; align-items: center; justify-content: center; line-height: 1.1; flex-direction: column; }
.num small { font-size: 9px; font-weight: 700; }
.meal-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.box { padding: 12px; border-radius: 12px; background: var(--primary-soft); white-space: pre-line; }
.box.plain { background: var(--bg); }
.item { display: flex; align-items: center; gap: 12px; min-height: 64px; width: 100%; padding: 12px 16px; border: 0; border-radius: 20px; background: var(--card); text-align: left; }
.item.locked { background: var(--soft); color: var(--muted); }
.item.locked .num { background: var(--bg); color: var(--muted); }
.pre { white-space: pre-line; }

/* ---------- resultado ---------- */
.result { background: var(--primary); color: var(--on-primary); border-radius: 24px; padding: 26px 22px; display: flex; flex-direction: column; gap: 18px; }
.big { font-size: 40px; font-weight: 800; line-height: 1; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 70px; }
.bars div { flex: 1; border-radius: 6px; background: var(--nevoa); min-height: 6px; }
.bars div.last { background: var(--azul); }

/* ---------- menu inferior ---------- */
.nav { flex: none; position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: 0 12px calc(10px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.nav button { height: 62px; border: 0; border-top: 3px solid transparent; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; font-weight: 700; }
.nav button.on { color: var(--primary); border-top-color: var(--primary); }

.footer { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 16px; }
.center { display: flex; flex: 1; align-items: center; justify-content: center; padding: 40px; color: var(--muted); }

/* ---------- painel da nutri ---------- */
.admin-top { background: #fff; border-bottom: 1px solid var(--line); }
.wrap { max-width: 1120px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.admin-top .wrap { padding: 18px 24px 0; }
.wrap-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tabs button { min-height: 44px; padding: 0 16px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); font-weight: 700; }
.tabs button.on { color: var(--primary); border-bottom-color: var(--primary); }
.tiles { display: flex; flex-wrap: wrap; gap: 12px; }
.tile { flex: 1 1 200px; background: #fff; border-radius: 20px; padding: 18px; display: flex; flex-direction: column; gap: 4px; }
.tile .n { font-size: 34px; font-weight: 800; line-height: 1; }
.panel { background: #fff; border-radius: 20px; padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.cols { display: flex; flex-wrap: wrap; gap: 16px; }
.chart { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; align-items: end; height: 190px; }
.chart .col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 190px; }
.chart .bar { width: 100%; max-width: 44px; border-radius: 8px 8px 3px 3px; background: var(--azul); }
.chart .bar.empty { background: var(--line); }
.chart .bar.live { background: var(--terracota); }
.table-box { background: #fff; border-radius: 20px; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 940px; font-size: 14px; }
th { text-align: left; font-size: 12px; color: var(--muted); padding: 14px 12px; border-bottom: 1px solid var(--line); }
td { padding: 12px; border-bottom: 1px solid var(--azul-soft); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 20px; }
.tag { padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--primary-soft); color: var(--primary); white-space: nowrap; }
.tag.red { background: var(--danger-soft); color: var(--danger); }
.tag.grey { background: var(--azul-soft); color: var(--ink); }
.btn-line { min-height: 40px; padding: 0 14px; border-radius: 12px; border: 1.5px solid var(--border); background: transparent; font-size: 13px; font-weight: 700; text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; }
.btn-line.danger { color: var(--danger); border-color: #E3B3AC; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.admin .input { height: 46px; border-radius: 14px; font-size: 15px; }
.admin textarea.input { height: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { min-width: 52px; min-height: 44px; padding: 0 12px; border-radius: 999px; border: 1.5px solid var(--border); background: transparent; font-weight: 700; }
.chips button.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.edit-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px; border-radius: 14px; background: var(--bg); }
.edit-row > .input { flex: 1 1 180px; }
.edit-row > select.input { flex: 0 1 140px; }
.edit-row .form-grid .input { flex: none; }
.admin textarea.input { min-height: 96px; line-height: 1.5; }
.admin .form-grid .field:not(.wide) { max-width: 360px; }
.saved { color: var(--primary); font-weight: 700; font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 14px; z-index: 10; max-width: 90vw; }

.welcome-photo::before, .welcome-photo::after { content: ''; position: absolute; border-radius: 999px; background: var(--salvia); opacity: .55; z-index: -1; }
.welcome-photo::before { right: -60px; top: -40px; width: 260px; height: 260px; }
.welcome-photo::after { left: 30px; bottom: -50px; width: 170px; height: 170px; }
.welcome-photo { flex: none; height: 300px; isolation: isolate; border-radius: 0 0 36px 36px; background: var(--azul) url('/img/boas-vindas.jpg') center / cover no-repeat; position: relative; overflow: hidden; }

/* Títulos na fonte da marca */
.hello, .card h2, .section-title, .panel h2, .welcome-title, .big, .ring-num, .tile .n, .admin-title { font-family: var(--font-display); font-weight: 400; letter-spacing: 0; }
.hello { font-size: 26px; }
.card h2, .section-title, .panel h2 { font-size: 19px; }
.ring-num { font-size: 28px; }
.big { font-size: 36px; white-space: nowrap; }
.tile .n { font-size: 36px; }
.task .label { font-weight: 700; }
.result { background: var(--primary); }
.next { background: var(--amarelinho); }
.drop { color: var(--azul); }
.day { border-color: var(--salvia); }
.task.done .icon { color: var(--primary); }

/* Campos lado a lado sempre alinhados pela caixa, mesmo se um título quebrar linha */
.form-grid .field { justify-content: flex-end; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.admin-h2 { font-family: var(--font-display); font-weight: 400; font-size: 19px; margin: 0; }
.btn-line { white-space: nowrap; }
.table-box .wrap-row .input { height: 44px; }
