/* Desafio na Balança — identidade: verde floresta, sálvia, areia, terracota, branco quente; Montserrat.
   Layout: celular com barra inferior; tablet em duas colunas; computador com menu lateral verde floresta. */
:root{
  --bg:#f7f1e8; --surface:#fffdf9; --sand:#ece2d3; --sand-2:#e3d6c2;
  --forest:#24473a; --forest-2:#2f5a49; --forest-ink:#f7f1e8;
  --sage:#a9bf98; --sage-soft:#e6ede0;
  --terra:#c8714f; --terra-dark:#b3603f; --terra-ink:#ffffff; --terra-soft:#f6e2d7;
  --fg:#22342c; --muted:#6c786f; --line:#e7ddcf;
  --good:#2f7a4f; --bad:#b4472d; --gold:#d9a441;
  --shadow:0 1px 2px rgba(36,71,58,.05),0 8px 24px rgba(36,71,58,.06);
  --r:20px; --r-sm:14px; --tab:68px;
  --f:"Montserrat",system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
}
@media (prefers-color-scheme: dark){:root{
  --bg:#121c17; --surface:#1a2821; --sand:#24342b; --sand-2:#2c3e34;
  --forest:#9cc4ad; --forest-2:#7fb096; --forest-ink:#10201a;
  --sage:#93ad83; --sage-soft:#22352b;
  --terra:#de8763; --terra-dark:#e99a79; --terra-ink:#1a120d; --terra-soft:#3a281f;
  --fg:#ece5d8; --muted:#a3b0a7; --line:#2b3c33; --good:#7fd3a0; --bad:#ff9a85; --gold:#e8b85a;
  --shadow:0 1px 2px rgba(0,0,0,.35);
  color-scheme:dark}}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--bg);color:var(--fg);font-family:var(--f);font-size:15.5px;line-height:1.55;-webkit-tap-highlight-color:transparent}
h1,h2,h3{margin:0;line-height:1.2;text-wrap:balance;color:var(--forest);font-weight:700}
h1{font-size:clamp(1.45rem,5.5vw,1.9rem);letter-spacing:-.01em}
h2{font-size:1.15rem}
h3{font-size:1rem;font-weight:600}
p{margin:.4rem 0}
a{color:var(--terra)}
.muted{color:var(--muted)} .small{font-size:.85rem} .tiny{font-size:.74rem}
.num{font-variant-numeric:tabular-nums}
.stack{display:flex;flex-direction:column;gap:14px}
.row{display:flex;flex-wrap:wrap;gap:10px;align-items:center}
.between{justify-content:space-between}
.card{background:var(--surface);border-radius:var(--r);padding:16px 18px;box-shadow:var(--shadow);min-width:0}
.card.flat{box-shadow:none;border:1px solid var(--line)}
.card.sand{background:var(--sand);box-shadow:none}
.eyebrow{font-size:.7rem;font-weight:600;letter-spacing:.14em;text-transform:uppercase;color:var(--terra)}
[hidden]{display:none!important}
:focus-visible{outline:2px solid var(--terra);outline-offset:2px}

/* Botões e campos */
.btn,button{font:inherit;font-weight:600;font-size:.95rem;border-radius:99px;padding:11px 20px;min-height:46px;cursor:pointer;
  border:1.5px solid var(--forest);background:var(--forest);color:var(--forest-ink);display:inline-flex;align-items:center;justify-content:center;gap:8px;text-decoration:none}
.btn.cta,button.cta{background:var(--terra);border-color:var(--terra);color:var(--terra-ink)}
.btn.cta:hover,button.cta:hover{background:var(--terra-dark);border-color:var(--terra-dark)}
.btn.ghost,button.ghost{background:transparent;color:var(--forest)}
button.link{background:none;border:0;padding:0;min-height:0;color:var(--terra);font-weight:600;border-radius:4px}
button.danger{background:transparent;border-color:var(--bad);color:var(--bad)}
button.full,.btn.full{width:100%}
button:disabled{opacity:.5;cursor:default}
button svg,.btn svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
label{display:flex;flex-direction:column;gap:5px;font-size:.82rem;font-weight:600;color:var(--muted)}
input,select,textarea{font:inherit;font-size:16px;color:var(--fg);background:var(--bg);border:1px solid var(--line);border-radius:var(--r-sm);padding:10px 12px;min-height:46px;width:100%;min-width:0;font-weight:500}
textarea{min-height:80px;resize:vertical}
.grid-form{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
@media(min-width:640px){.grid-form{grid-template-columns:repeat(auto-fill,minmax(170px,1fr))}}
.check-line{flex-direction:row;align-items:center;gap:10px;color:var(--fg);font-weight:500;font-size:.92rem}
.check-line input{width:22px;height:22px;min-height:0;accent-color:var(--forest)}
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.chips{display:flex;gap:8px;flex-wrap:wrap}
.chip{font:inherit;font-size:.82rem;font-weight:600;padding:7px 16px;min-height:36px;border-radius:99px;border:0;background:var(--sand);color:var(--fg)}
.chip[aria-pressed="true"]{background:var(--forest);color:var(--forest-ink)}
.pill{display:inline-block;font-size:.7rem;font-weight:600;padding:2px 10px;border-radius:99px;white-space:nowrap;vertical-align:middle}
.pill.ok{background:var(--sage-soft);color:var(--good)}
.pill.wait{background:var(--terra-soft);color:var(--terra-dark)}
.pill.info{background:var(--sand);color:var(--forest)}
.pos{color:var(--good)} .neg{color:var(--bad)}
.alert{background:var(--terra-soft);color:var(--terra-dark);border-radius:var(--r-sm);padding:10px 14px;font-weight:500;font-size:.9rem}
.note{background:var(--sage-soft);border-radius:var(--r-sm);padding:10px 14px;font-size:.9rem}

/* Estrutura do app */
.app{min-height:100%}
.main{padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px));
  padding-block:calc(14px + env(safe-area-inset-top,0px)) calc(var(--tab) + 28px + env(safe-area-inset-bottom,0px));max-width:760px;margin:0 auto;outline:none}
.side{display:none}
.tabbar{position:fixed;left:0;right:0;bottom:0;z-index:30;display:grid;grid-template-columns:repeat(5,1fr);background:var(--surface);
  border-top:1px solid var(--line);padding:4px max(6px,env(safe-area-inset-right,0px)) env(safe-area-inset-bottom,0px) max(6px,env(safe-area-inset-left,0px))}
.tabbar a{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;min-height:60px;color:var(--muted);text-decoration:none;font-size:.66rem;font-weight:600;border-radius:12px}
.tabbar a[aria-current="page"]{color:var(--terra)}
.ico{width:23px;height:23px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;flex:none}
.top-brand{display:flex;align-items:center;gap:10px;color:var(--forest);font-weight:700;line-height:1.05;margin-bottom:12px}
.top-brand svg{width:52px}
.top-brand b{font-size:1.25rem}
@media (min-width:1000px){
  .app{display:grid;grid-template-columns:250px 1fr}
  .side{display:flex;flex-direction:column;gap:18px;position:sticky;top:0;height:100vh;background:var(--forest);color:var(--forest-ink);padding:26px 16px;overflow:auto}
  .side-brand{display:flex;align-items:center;gap:10px;color:var(--forest-ink);text-decoration:none;line-height:1.05;font-weight:600;padding:0 8px}
  .side-brand b{font-size:1.25rem}
  .side-logo{width:56px;--forest:var(--forest-ink);--bg:var(--forest)}
  .side nav{display:flex;flex-direction:column;gap:2px}
  .side nav a{display:flex;align-items:center;gap:12px;padding:11px 12px;border-radius:12px;color:var(--forest-ink);opacity:.8;text-decoration:none;font-weight:500}
  .side nav a:hover{opacity:1;background:rgba(255,255,255,.06)}
  .side nav a[aria-current="page"]{opacity:1;background:rgba(255,255,255,.12);font-weight:600}
  .side nav .ico{width:21px;height:21px}
  .side .sep{height:1px;background:rgba(255,255,255,.12);margin:8px 6px}
  .tabbar{display:none}
  .main{max-width:1060px;padding-block:32px 48px;margin:0}
  .top-brand{display:none}
}
@media (prefers-color-scheme: dark) and (min-width:1000px){.side{background:#18291f}}
.loading{padding:60px 0;text-align:center;color:var(--muted)}
.view{display:flex;flex-direction:column;gap:16px}
.cols{display:grid;gap:16px}
@media(min-width:760px){.cols.two{grid-template-columns:1fr 1fr}.cols.three{grid-template-columns:repeat(3,1fr)}}
.head{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;gap:10px}

/* Início */
.hello h1{color:var(--fg)}
.hello p{color:var(--muted);margin:2px 0 0}
.hero{display:grid;gap:16px;align-items:center}
@media(min-width:760px){.hero{grid-template-columns:auto 1fr}}
.ring{position:relative;width:170px;height:170px;margin:0 auto}
.ring svg{width:100%;height:100%;transform:rotate(-90deg)}
.ring .t{position:absolute;inset:0;display:grid;place-items:center;text-align:center;color:var(--muted);font-size:.8rem;padding:24px}
.ring .t b{display:block;color:var(--fg);font-size:1.3rem;font-weight:700}
.kpis{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.kpi{background:var(--surface);border-radius:var(--r-sm);padding:12px 14px;box-shadow:var(--shadow);text-align:center;min-width:0}
.kpi .k{font-size:.74rem;color:var(--muted);font-weight:600}
.kpi .v{font-size:1.4rem;font-weight:700;color:var(--fg);font-variant-numeric:tabular-nums;line-height:1.25}
.kpi .s{font-size:.72rem;color:var(--muted)}
.today{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
.today div{background:var(--bg);border-radius:12px;padding:10px;text-align:center;font-size:.72rem;color:var(--muted)}
.today b{display:block;font-size:1.05rem;color:var(--fg)}
.trophy{display:flex;gap:12px;align-items:center;background:var(--sand);border-radius:var(--r);padding:14px 16px}
.trophy svg{width:40px;flex:none}
.trophy b{font-size:1.15rem}

/* Cartões de números e gráficos */
.cards{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
@media(min-width:640px){.cards{grid-template-columns:repeat(auto-fill,minmax(170px,1fr))}}
.metric{background:var(--surface);border-radius:var(--r-sm);padding:12px 14px;box-shadow:var(--shadow);min-width:0}
.metric .k{font-size:.7rem;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.05em}
.metric .v{font-size:1.25rem;font-weight:700;font-variant-numeric:tabular-nums}
.metric .d{font-size:.72rem;font-weight:500}
.charts{display:grid;gap:12px}
@media(min-width:640px){.charts{grid-template-columns:repeat(2,minmax(0,1fr))}}
.chart{background:var(--surface);border-radius:var(--r-sm);padding:12px 12px 6px;box-shadow:var(--shadow);min-width:0}
.chart h3{font-size:.85rem;margin-bottom:4px}
.chart svg{width:100%;height:auto;display:block}
.chart .grid{stroke:var(--line);stroke-width:1}
.chart .axis{fill:var(--muted);font-family:var(--f);font-size:9px}
.chart .line{fill:none;stroke:var(--forest);stroke-width:2.6;stroke-linejoin:round;stroke-linecap:round}
.chart .area{fill:var(--sage-soft)}
.chart .dot{fill:var(--surface);stroke:var(--forest);stroke-width:2}
.chart .last{fill:var(--terra)}
.chart .lbl{fill:var(--fg);font-family:var(--f);font-size:10px;font-weight:600}
.chart .bar{fill:var(--sage)}
.chart .bar.hi{fill:var(--forest)}

/* Listas */
.list{display:flex;flex-direction:column;gap:8px}
.item{display:flex;flex-direction:column;align-items:stretch;justify-content:flex-start;gap:6px;width:100%;text-align:left;background:var(--surface);color:var(--fg);border:0;border-radius:var(--r-sm);padding:12px 14px;box-shadow:var(--shadow);font-weight:400;min-height:0}
.item-head{display:flex;justify-content:space-between;align-items:center;gap:8px}
.item-head b{font-weight:600}
.vals{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px;font-variant-numeric:tabular-nums;font-size:.9rem;font-weight:600}
.vals small{display:block;font-size:.66rem;color:var(--muted);font-weight:500}
.rank{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:8px}
.rank li{display:grid;grid-template-columns:34px minmax(0,1fr) auto;gap:10px;align-items:center;background:var(--surface);border-radius:var(--r-sm);padding:12px 14px;box-shadow:var(--shadow)}
.rank li.me{outline:2px solid var(--sage)}
.rank .pos-n{width:30px;height:30px;border-radius:50%;display:grid;place-items:center;background:var(--sand);font-weight:700;font-size:.85rem;color:var(--forest)}
.rank li:nth-child(1) .pos-n{background:var(--gold);color:#3b2a08}
.rank .who{min-width:0}
.rank .name{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;color:var(--fg);background:none;border:0;padding:0;min-height:0;font-size:.95rem;text-align:left;max-width:100%}
.rank .meta{font-size:.74rem;color:var(--muted);display:flex;gap:6px;align-items:center;flex-wrap:wrap}
.rank .big{text-align:right;font-variant-numeric:tabular-nums}
.rank .big b{display:block;font-size:1.15rem}
.rank .big small{color:var(--muted);font-size:.72rem}

/* Registros */
.check{display:flex;flex-direction:column;gap:10px}
.check .it{background:var(--surface);border-radius:var(--r-sm);padding:12px 14px;box-shadow:var(--shadow);display:flex;flex-direction:column;gap:10px}
.check .it-head{display:flex;align-items:center;justify-content:space-between;gap:10px}
.check .it-head b{font-weight:600}
.drops{display:flex;flex-wrap:wrap;gap:6px}
.drop{width:30px;height:38px;min-height:0;padding:0;border:0;background:none;border-radius:8px}
.drop svg{width:100%;height:100%}
.drop path{fill:var(--line)}
.drop[aria-pressed="true"] path{fill:var(--sage)}
.seg3{display:grid;grid-template-columns:repeat(3,1fr);gap:6px}
.seg3 button,.faces button{min-height:42px;padding:6px;border-radius:12px;background:var(--bg);color:var(--fg);border:1px solid var(--line);font-weight:500;font-size:.85rem}
.seg3 button[aria-pressed="true"],.faces button[aria-pressed="true"]{background:var(--forest);color:var(--forest-ink);border-color:var(--forest)}
.faces{display:grid;grid-template-columns:repeat(5,1fr);gap:6px}
.faces button{font-size:1.25rem}
.stepper{display:flex;align-items:center;gap:10px}
.stepper button{width:42px;height:42px;padding:0;min-height:0;border-radius:50%;background:var(--sand);color:var(--forest);border:0;font-size:1.2rem}
.stepper output{min-width:70px;text-align:center;font-weight:700;font-variant-numeric:tabular-nums}
.saved{font-size:.75rem;color:var(--good);font-weight:600}

/* Conquistas */
.badges{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
@media(min-width:640px){.badges{grid-template-columns:repeat(auto-fill,minmax(180px,1fr))}}
.badge{background:var(--surface);border-radius:var(--r-sm);padding:14px;box-shadow:var(--shadow);display:flex;flex-direction:column;gap:6px;align-items:flex-start}
.badge .medal{width:42px;height:42px;border-radius:50%;display:grid;place-items:center;background:var(--sand)}
.badge .medal svg{width:24px;height:24px;fill:none;stroke:var(--muted);stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.badge.on .medal{background:var(--gold)}
.badge.on .medal svg{stroke:#3b2a08}
.badge:not(.on){opacity:.6}
.badge b{font-weight:600;font-size:.9rem}

/* Comunidade */
.post{background:var(--surface);border-radius:var(--r-sm);padding:14px 16px;box-shadow:var(--shadow);display:flex;flex-direction:column;gap:8px}
.post.conquista{background:var(--sand)}
.post-head{display:flex;align-items:center;gap:10px}
.avatar{width:36px;height:36px;border-radius:50%;display:grid;place-items:center;background:var(--sage);color:var(--forest-ink);font-weight:700;font-size:.85rem;flex:none}
.post-head .who{flex:1;min-width:0}
.post-head .who b{display:block;font-weight:600;font-size:.92rem}
.post p{white-space:pre-wrap;margin:0;overflow-wrap:anywhere}
.reacts{display:flex;gap:6px;flex-wrap:wrap}
.reacts button{min-height:34px;padding:4px 12px;border-radius:99px;background:var(--bg);color:var(--fg);border:1px solid var(--line);font-weight:600;font-size:.85rem}
.reacts button[aria-pressed="true"]{background:var(--sage-soft);border-color:var(--sage)}
.comments{display:flex;flex-direction:column;gap:6px;border-top:1px solid var(--line);padding-top:8px}
.comment{font-size:.88rem;overflow-wrap:anywhere}
.comment b{font-weight:600}
.comment-form{display:flex;gap:8px}
.comment-form input{min-height:40px;padding:8px 12px}
.comment-form button{min-height:40px;padding:6px 14px}

/* Upload */
.dropzone{display:flex;flex-direction:column;align-items:center;gap:6px;text-align:center;padding:26px 16px;border:2px dashed var(--sand-2);border-radius:var(--r);background:var(--surface);color:var(--fg);cursor:pointer;font-weight:500}
.dropzone svg{width:38px;height:38px;fill:none;stroke:var(--terra);stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.dropzone b{font-size:1.02rem;font-weight:600;color:var(--forest)}
.preview{display:grid;grid-template-columns:110px 1fr;gap:14px;align-items:start}
.preview img{width:100%;border-radius:12px}
@media(min-width:640px){.preview{grid-template-columns:180px 1fr}}

/* Plano */
.meal-head{display:flex;flex-wrap:wrap;gap:8px 10px;align-items:center;justify-content:space-between}
.meal-head .time{color:var(--terra);margin-right:8px;font-variant-numeric:tabular-nums}
.opts{display:grid;gap:10px}
@media(min-width:640px){.opts{grid-template-columns:repeat(auto-fill,minmax(240px,1fr))}}
.opt{background:var(--bg);border-radius:var(--r-sm);padding:12px 14px;display:flex;flex-direction:column;gap:6px;min-width:0}
.opt b{font-weight:600;color:var(--forest)}
.opt ul{margin:0;padding-left:1.1rem;font-size:.9rem}
.opt .macro{font-size:.74rem;color:var(--muted);margin-top:auto;font-weight:500}
.plain-list{margin:.4rem 0;padding-left:1.2rem}
.plain-list li{margin:.25rem 0}

/* Tabela do painel */
.table-wrap{overflow-x:auto;border-radius:var(--r-sm);background:var(--surface);box-shadow:var(--shadow)}
table{border-collapse:collapse;width:100%;min-width:640px;font-size:.88rem}
th,td{text-align:left;padding:10px 12px;border-bottom:1px solid var(--line);vertical-align:middle}
th{font-size:.74rem;color:var(--muted);font-weight:600;background:var(--sand)}
tr:last-child td{border-bottom:0}

/* Diálogo e aviso */
dialog{border:0;border-radius:24px;background:var(--surface);color:var(--fg);padding:0;width:100%;max-width:min(620px,calc(100vw - 32px));box-shadow:var(--shadow)}
dialog::backdrop{background:rgba(20,35,28,.5)}
@media (max-width:640px){dialog{max-width:100vw;margin:auto 0 0;border-radius:24px 24px 0 0}}
.dlg{padding:20px 20px calc(20px + env(safe-area-inset-bottom,0px));display:flex;flex-direction:column;gap:12px;max-height:88vh;overflow:auto}
.dlg img{max-width:100%;border-radius:14px;align-self:center;max-height:55vh}
.kv{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px 14px;font-size:.9rem}
.kv span{color:var(--muted)}
.toast{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(var(--tab) + 16px + env(safe-area-inset-bottom,0px));z-index:50;background:var(--forest);color:var(--forest-ink);padding:10px 18px;border-radius:99px;font-weight:600;font-size:.88rem;box-shadow:var(--shadow);max-width:calc(100vw - 32px)}
@media(min-width:1000px){.toast{bottom:24px}}

/* Login */
.auth{min-height:100vh;display:grid;place-items:center;gap:24px;padding-block:calc(28px + env(safe-area-inset-top,0px)) 40px;
  padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px));
  background:radial-gradient(120% 60% at 0% 100%,var(--sage-soft) 0%,transparent 60%),var(--bg)}
@media(min-width:900px){.auth{grid-template-columns:1fr 420px;max-width:980px;margin:0 auto;gap:60px}}
.auth-brand{text-align:center}
@media(min-width:900px){.auth-brand{text-align:left}}
.auth-logo{width:150px;max-width:40vw}
.auth-brand h1{font-size:clamp(2rem,8vw,3.2rem);font-weight:500;line-height:1}
.auth-brand h1 strong{font-weight:700}
.tagline{letter-spacing:.14em;text-transform:uppercase;font-size:.78rem;color:var(--fg);margin-top:14px}
.auth-card{width:100%;max-width:420px;display:flex;flex-direction:column;gap:14px;padding:22px}
.seg{display:grid;grid-template-columns:1fr 1fr;background:var(--sand);border-radius:99px;padding:4px}
.seg a{text-align:center;padding:9px;border-radius:99px;text-decoration:none;color:var(--fg);font-weight:600;font-size:.9rem}
.seg a[aria-selected="true"]{background:var(--forest);color:var(--forest-ink)}
@media (prefers-reduced-motion: reduce){*{transition:none!important;animation:none!important}}
