/* 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; }
