:root {
  --orange: #F26A1B;
  --orange-soft: #FFF1E8;
  --ink: #141414;
  --ink-2: #3a3a3a;
  --muted: #7a7a7a;
  --line: #E7E7E7;
  --bg: #F5F5F5;
  --card: #FFFFFF;
  --danger: #D93025;
  --ok: #1E8E3E;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: Poppins, system-ui, sans-serif; font-size: 15px; }
[hidden] { display: none !important; }
h2 { font-size: 20px; margin: 4px 0 14px; }
h3 { font-size: 16px; margin: 0; }
.small { font-size: 12.5px; }
.muted { color: var(--muted); }
.muted-dark { color: var(--ink-2); }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.right { text-align: right; }

/* brand */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.logo-dot { width: 30px; height: 30px; border-radius: 50%; background: var(--orange); color: #fff; display: grid; place-items: center; font-size: 15px; }

/* layout */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; background: var(--card); border-bottom: 1px solid var(--line); }
main { padding: 16px 16px calc(90px + var(--safe-b)); max-width: 560px; margin: 0 auto; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.04); margin-bottom: 14px; scroll-margin-top: 80px; }

/* forms */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
input, select, textarea { font: inherit; font-size: 16px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--orange); border-color: transparent; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span2 { grid-column: span 2; }

/* buttons */
.btn { font: inherit; font-weight: 600; border: 0; border-radius: 12px; padding: 13px 16px; cursor: pointer; text-align: center; text-decoration: none; display: block; }
.btn.primary { background: var(--orange); color: #fff; }
.btn.primary:disabled { opacity: .55; }
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--card); color: var(--danger); border: 1px solid var(--line); }
.btn.wide { width: 100%; margin-bottom: 10px; }
.link { background: none; border: 0; color: var(--orange); font: inherit; font-weight: 500; cursor: pointer; padding: 4px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); font-size: 22px; cursor: pointer; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { background: var(--card); border-radius: 20px; padding: 28px 22px; width: 100%; max-width: 380px; box-shadow: 0 6px 24px rgba(0,0,0,.06); }
.auth-card .brand { font-size: 24px; margin-bottom: 4px; }

/* today */
.datebar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.date-label { font-weight: 600; }
.summary .kcal-row { display: flex; justify-content: space-between; }
.big { font-size: 30px; font-weight: 700; line-height: 1.1; }
.bar { height: 10px; background: var(--bg); border-radius: 10px; margin: 12px 0; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--orange); border-radius: 10px; transition: width .3s; }
.bar-fill.over { background: var(--danger); }
.macros { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; }
.macros span { display: block; font-size: 11.5px; color: var(--muted); }

.meal { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: 14px; padding: 10px; cursor: pointer; }
.meal img, .meal .ph { width: 58px; height: 58px; border-radius: 10px; object-fit: cover; background: var(--orange-soft); display: grid; place-items: center; font-size: 22px; flex-shrink: 0; }
.meal .info { flex: 1; min-width: 0; }
.meal .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meal .kcal { font-weight: 700; }
.meal-detail { background: var(--card); border-radius: 0 0 14px 14px; margin-top: -10px; padding: 8px 12px 12px; font-size: 13px; }
.meal-detail .line { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.coach-note { background: var(--orange-soft); padding: 8px 10px; border-radius: 10px; margin-top: 8px; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }

/* log */
.photo-drop { border: 2px dashed var(--line); border-radius: 14px; min-height: 160px; display: grid; place-items: center; cursor: pointer; overflow: hidden; color: var(--muted); font-size: 15px; }
.photo-drop img { width: 100%; max-height: 320px; object-fit: cover; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 99px; background: var(--bg); }
.pill.tinggi { background: #E6F4EA; color: var(--ok); }
.pill.sederhana { background: var(--orange-soft); color: var(--orange); }
.pill.rendah { background: #FCE8E6; color: var(--danger); }
.tip { background: var(--orange-soft); border-radius: 12px; padding: 10px 12px; margin: 0; font-size: 14px; }
.items { display: flex; flex-direction: column; gap: 10px; }
.item { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.item .name, .item .portion { grid-column: span 3; }
.item .portion { align-self: center; }
.item input { padding: 8px; font-size: 15px; }
.item label { font-size: 11px; gap: 3px; }
.item .rm { align-self: end; background: none; border: 0; color: var(--danger); font-size: 13px; cursor: pointer; padding: 8px 0; }
.totals { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; background: var(--bg); border-radius: 12px; padding: 10px 4px; }
.totals b { display: block; font-size: 17px; }
.totals span { font-size: 11px; color: var(--muted); }

/* body */
.chart { height: 170px; margin-top: 8px; }
.chart svg { width: 100%; height: 100%; }
.hist { background: var(--card); border-radius: 14px; padding: 12px 14px; font-size: 13px; }
.hist .top { display: flex; justify-content: space-between; font-weight: 600; font-size: 14px; }
.down { color: var(--ok); } .up { color: var(--danger); }

/* tab bar */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--card); border-top: 1px solid var(--line); padding: 6px 0 calc(6px + var(--safe-b)); z-index: 10; }
.tabbar button { background: none; border: 0; font: inherit; font-size: 11.5px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; cursor: pointer; }
.tabbar button span { font-size: 20px; filter: grayscale(1); opacity: .7; }
.tabbar button.active { color: var(--orange); font-weight: 600; }
.tabbar button.active span { filter: none; opacity: 1; }

/* toast & spinner */
.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 50; max-width: 90vw; text-align: center; }
.toast.err { background: var(--danger); }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: s .8s linear infinite; vertical-align: -3px; margin-right: 6px; }
@keyframes s { to { transform: rotate(360deg); } }

.badge { display: inline-block; align-self: flex-start; width: auto; font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 99px; margin-left: 4px; vertical-align: 1px; }
.b-db { background: #E6F4EA; color: var(--ok); }
.b-ai { background: var(--orange-soft); color: var(--orange); }
.b-man { background: var(--bg); color: var(--muted); }
