/* Macro tracker — self-contained styles, system fonts (no CDN, durable).
   Signature element: the calorie ring + macro bars on the Today view. */

:root {
  --bg:        #0f1419;   /* ink background */
  --surface:   #171d26;
  --surface-2: #1f2733;
  --line:      #2b3543;
  --text:      #e8edf2;
  --muted:     #8a97a8;
  --accent:    #18b69b;   /* calories / on-track */
  --protein:   #6b7cff;
  --carbs:     #e0a13a;
  --fat:       #e5586e;
  --danger:    #ef5350;
  --radius:    14px;
  --maxw:      720px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

button { font: inherit; cursor: pointer; }
input, select { font: inherit; }
a { color: var(--accent); }

#app { min-height: 100%; }

/* ---------- Layout shell ---------- */
.shell { max-width: var(--maxw); margin: 0 auto; padding: 0 16px 96px; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; max-width: var(--maxw); margin: 0 auto;
  background: linear-gradient(var(--bg) 70%, transparent);
  backdrop-filter: blur(6px);
}
.brand { font-weight: 700; letter-spacing: -0.03em; font-size: 1.15rem; }
.brand small { color: var(--muted); font-weight: 500; letter-spacing: 0; }

/* Bottom tab bar (mobile-first) */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(15,20,25,0.92); border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.tab {
  flex: 1; max-width: 120px; background: none; border: none; color: var(--muted);
  padding: 8px 6px; border-radius: 10px; font-size: 0.78rem; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tab .ico { font-size: 1.1rem; line-height: 1; }
.tab.active { color: var(--text); background: var(--surface-2); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin: 12px 0;
}
.card h2 { margin: 0 0 12px; font-size: 1rem; letter-spacing: -0.01em; }
.row { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

/* ---------- Date nav ---------- */
.datenav { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 6px 0 2px; }
.datenav button { background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  width: 38px; height: 38px; border-radius: 10px; font-size: 1.1rem; }
.datenav .label { font-weight: 700; min-width: 150px; text-align: center; letter-spacing: -0.01em; }
.today-link { display: block; text-align: center; margin-top: 6px; }

/* ---------- Ring + macro bars (signature) ---------- */
.summary { display: grid; grid-template-columns: 132px 1fr; gap: 18px; align-items: center; }
.ring-wrap { position: relative; width: 132px; height: 132px; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; }
.ring-center .big { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.03em; }
.ring-center .lbl { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.macros { display: flex; flex-direction: column; gap: 12px; }
.macro .spread { margin-bottom: 4px; }
.macro .name { font-weight: 600; font-size: 0.9rem; }
.macro .val { font-variant-numeric: tabular-nums; font-size: 0.85rem; color: var(--muted); }
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; transition: width .35s ease; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---------- Entry / food lists ---------- */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 2px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: none; }
.item .name { font-weight: 600; }
.item .sub { color: var(--muted); font-size: 0.8rem; }
.item .kcal { font-variant-numeric: tabular-nums; font-weight: 700; }
.meal-head { margin: 14px 0 2px; font-size: 0.72rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); }
.iconbtn { background: none; border: none; color: var(--muted); font-size: 1rem; padding: 6px; }
.iconbtn:hover { color: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 28px 0; }

/* ---------- Buttons / forms ---------- */
.btn { background: var(--accent); color: #04201b; border: none; font-weight: 700;
  padding: 12px 16px; border-radius: 11px; width: 100%; }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn.ghost { background: none; border: 1px solid var(--line); color: var(--text); }
.btn.sm { width: auto; padding: 9px 13px; font-size: 0.85rem; }
.fab { position: fixed; right: 18px; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 25;
  width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #04201b;
  border: none; font-size: 1.7rem; box-shadow: 0 8px 24px rgba(0,0,0,.4); }

label { display: block; font-size: 0.8rem; color: var(--muted); margin: 12px 0 5px; font-weight: 600; }
input, select {
  width: 100%; padding: 12px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.err { color: var(--danger); font-size: 0.85rem; margin-top: 8px; min-height: 1em; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px 18px 0 0; width: 100%; max-width: var(--maxw);
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); max-height: 88vh; overflow: auto; }
.modal h3 { margin: 4px 0 8px; }
.seg { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 11px; margin: 6px 0 4px; }
.seg button { flex: 1; background: none; border: none; color: var(--muted); padding: 9px;
  border-radius: 8px; font-weight: 600; }
.seg button.active { background: var(--surface); color: var(--text); }

/* ---------- Auth ---------- */
.auth-wrap { max-width: 380px; margin: 12vh auto 0; padding: 0 20px; }
.auth-wrap h1 { font-size: 2rem; letter-spacing: -0.04em; margin: 0 0 4px; }
.auth-wrap .tagline { color: var(--muted); margin: 0 0 24px; }

/* ---------- Trends ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 4px; }
.kpi { background: var(--surface-2); border-radius: 10px; padding: 10px 8px; text-align: center; }
.kpi .v { font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.chart { width: 100%; height: auto; display: block; margin-top: 6px; }
.chart text { fill: var(--muted); font-size: 10px; }

/* ---------- Desktop refinements ---------- */
@media (min-width: 720px) {
  .tabs { position: sticky; top: 0; bottom: auto; max-width: var(--maxw); margin: 0 auto;
    border-top: none; border-bottom: 1px solid var(--line); background: transparent;
    justify-content: flex-start; gap: 6px; backdrop-filter: none; }
  .tab { flex: 0 0 auto; max-width: none; flex-direction: row; gap: 7px; padding: 8px 14px; }
  .shell { padding-bottom: 40px; }
  .fab { bottom: 26px; }
  .summary { grid-template-columns: 150px 1fr; }
}
