/* Jyothis Health – daily weight & BMI. Mobile first; wide screens get a top navigation. */
:root {
  --navy: #0f5e57; --navy-2: #14857a; --orange: #f0702a; --orange-2: #f59a3c;
  --bg: #f2f5fa; --surface: #ffffff; --surface-2: #f6f8fc; --ink: #142038; --muted: #5f6b80;
  --line: #e1e6ef; --focus: #2f6fd6;
  --in: #11865a; --in-bg: #e2f4ec; --out: #d2531d; --out-bg: #fdebe2; --warn: #9a6400; --warn-bg: #fff3d6;
  --radius: 16px; --shadow: 0 1px 2px rgba(20,32,56,.06), 0 6px 18px rgba(20,32,56,.06);
  --font: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --navy: #0c3f3a; --navy-2: #16786e; --orange: #ff8a45; --orange-2: #ffab5e;
    --bg: #0e1422; --surface: #161e30; --surface-2: #1c2539; --ink: #e7ecf5; --muted: #9aa6bb;
    --line: #2a3550; --focus: #7fb0ff;
    --in: #4fd39a; --in-bg: #12362a; --out: #ff8f5c; --out-bg: #3c2216; --warn: #f2c15b; --warn-bg: #3a2f12;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: var(--navy-2); text-decoration: none; }
@media (prefers-color-scheme: dark) { a { color: var(--orange-2); } }
h1 { font-size: 21px; font-weight: 700; margin: 0 0 14px; letter-spacing: -.01em; }
h2 { font-size: 13px; margin: 26px 0 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.num, .amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.in { color: var(--in); } .out { color: var(--out); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* brand mark: logo in a white disc */
.mark { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: #fff; flex: none;
  box-shadow: 0 0 0 2px rgba(255,255,255,.25); }
.mark img { width: 30px; height: 30px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand b { display: block; font-size: 16px; line-height: 1.15; font-weight: 700; }
.brand small { display: block; font-size: 11px; opacity: .8; letter-spacing: .04em; }

/* cards & stats */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); color: inherit; }
.stat .label { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat .value { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .sub { font-size: 12px; color: var(--muted); }
.stat.wide { grid-column: 1 / -1; }

/* hero: navy panel with an orange edge */
.hero { position: relative; overflow: hidden; border-radius: 20px; padding: 18px; color: #fff;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%); }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 150px; height: 150px; border-radius: 50%;
  background: radial-gradient(circle, rgba(240,112,42,.55), rgba(240,112,42,0) 70%); }
.hero .label { font-size: 13px; opacity: .85; }
.hero .value { font-size: 32px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.hero .split { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; opacity: .9; margin-top: 4px; }
.hero .btn { margin-top: 12px; position: relative; z-index: 1; }

/* today strip */
.today { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-radius: var(--radius);
  border: 2px dashed var(--orange); background: var(--surface); margin-bottom: 14px; }
.today.done { border: 1px solid var(--line); border-left: 5px solid var(--in); }
.today .t1 { font-weight: 700; }
.today .t2 { font-size: 13px; color: var(--muted); }

/* bars */
.bars { display: grid; gap: 10px; }
.bar-row { color: inherit; }
.bar-row .top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); margin-top: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 4px; }
.pair { display: grid; gap: 3px; margin-top: 5px; }
.pair .bar { margin: 0; height: 7px; }
.pair .bar.c i { background: var(--in); } .pair .bar.e i { background: var(--orange); }
.legend-dots { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.legend-dots span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; background: var(--c); }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .title { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.item .amt { font-weight: 700; text-align: right; }
.item.missing .title { color: var(--warn); }
.cat-chip { display: inline-flex; align-items: center; gap: 5px; }
.cat-chip::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--cat, #888); }
.pill { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.ok { background: var(--in-bg); color: var(--in); }

/* forms */
.form { display: grid; gap: 14px; }
.field label, .field > .lbl { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.field .help { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field .err { color: var(--out); font-size: 13px; margin-top: 4px; }
input[type=text], input[type=number], input[type=date], input[type=time], input[type=month], input[type=password], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 12px; min-height: 48px; }
input:focus, select:focus, textarea:focus { border-color: var(--navy-2); outline: none; box-shadow: 0 0 0 3px rgba(20,133,122,.18); }
input[type=color] { width: 56px; height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: var(--surface); }
textarea { min-height: 0; }
.money input { font-size: 24px; font-weight: 700; }
.money-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.live-total { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px; border-radius: 12px;
  background: var(--in-bg); color: var(--in); font-weight: 600; }
.live-total .num { font-size: 22px; font-weight: 700; }

/* chip picker */
.chips-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.chips-pick input { position: absolute; opacity: 0; pointer-events: none; }
.chips-pick label { margin: 0; padding: 9px 14px; min-height: 42px; display: inline-flex; align-items: center; border: 1.5px solid var(--line);
  border-radius: 999px; background: var(--surface); cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink); }
.chips-pick input:checked + label { background: var(--navy); border-color: var(--navy); color: #fff; }
.chips-pick input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: 2px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600;
  min-height: 46px; padding: 10px 18px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; }
.btn.primary { background: var(--orange); color: #fff; border-color: var(--orange); }
.btn.navy { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.light { background: #fff; color: var(--navy); border-color: #fff; }
.btn.danger { color: var(--out); border-color: var(--out); background: transparent; }
.btn.sm { min-height: 36px; padding: 5px 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* filters & chips */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.filters .q { grid-column: 1 / -1; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: none; }
.chips a { flex: none; font-size: 13px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.chips a.on { background: var(--navy); color: #fff; border-color: var(--navy); }

/* messages */
.msgs { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.msgs li { padding: 10px 14px; border-radius: 12px; background: var(--in-bg); color: var(--in); font-weight: 500; }
.msgs li.error { background: var(--out-bg); color: var(--out); }
.msgs li a { color: inherit; text-decoration: underline; font-weight: 700; }

.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.month-nav .m { font-weight: 700; font-size: 17px; text-align: center; }
.month-nav .m small { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.empty { text-align: center; color: var(--muted); padding: 28px 8px; }
.hint { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.hint a { color: inherit; text-decoration: underline; font-weight: 600; }

/* tables */
table.grid { width: 100%; border-collapse: collapse; background: var(--surface); }
table.grid th, table.grid td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.grid th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); text-transform: uppercase; letter-spacing: .04em; }
table.grid td.amt, table.grid th.amt { text-align: right; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tr.missing td { background: var(--warn-bg); }
table.grid tr.future td { color: var(--muted); }
table.grid tfoot td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--line); }
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }

/* ---------- mobile shell ---------- */
.app .topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--navy); color: #fff; }
.app .topbar .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
.app main { padding: 16px 16px calc(100px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
.app .tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 16px rgba(20,32,56,.06); }
.app .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 10px; font-size: 11px; color: var(--muted); }
.app .tabbar a .ico { font-size: 20px; line-height: 1; }
.app .tabbar a.on { color: var(--navy-2); font-weight: 700; }
@media (prefers-color-scheme: dark) { .app .tabbar a.on { color: var(--orange-2); } }
.app .tabbar a.add .ico { width: 52px; height: 52px; margin-top: -24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--orange); color: #fff; font-size: 28px; box-shadow: 0 6px 16px rgba(240,112,42,.45); border: 4px solid var(--surface); }
.app .tabbar a.add { color: var(--orange); font-weight: 700; }


.app .tabbar { grid-template-columns: repeat(5, 1fr); }
.app .topnav { display: none; }

/* wide screens: nav moves into the top bar */
@media (min-width: 900px) {
  .app .tabbar { display: none; }
  .app main { max-width: 980px; padding-bottom: 48px; }
  .app .topnav { display: flex; gap: 4px; flex: 1; margin-left: 28px; }
  .app .topnav a { color: rgba(255,255,255,.82); padding: 8px 12px; border-radius: 10px; font-size: 14px; font-weight: 500; }
  .app .topnav a.on { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
  .app .topbar { padding-left: max(16px, calc(50vw - 490px)); padding-right: max(16px, calc(50vw - 490px)); }
  .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
}

/* BMI bands */
.b-under { --b: #3b7dd8; --bb: #e3eefc; } .b-normal { --b: #11865a; --bb: #e2f4ec; }
.b-over { --b: #c98a00; --bb: #fff3d6; } .b-obese { --b: #d2453b; --bb: #fde6e3; }
@media (prefers-color-scheme: dark) {
  .b-under { --b: #7fb0ff; --bb: #16263f; } .b-normal { --b: #4fd39a; --bb: #12362a; }
  .b-over { --b: #f2c15b; --bb: #3a2f12; } .b-obese { --b: #ff8a7d; --bb: #3d1f1c; }
}
.band { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; padding: 3px 10px;
  border-radius: 999px; color: var(--b); background: var(--bb); }
.bmi-scale { position: relative; height: 12px; border-radius: 6px; margin: 16px 0 6px; display: flex; overflow: visible; }
.bmi-scale span { height: 100%; background: var(--b); }
.bmi-scale span:first-child { border-radius: 6px 0 0 6px; } .bmi-scale span:last-of-type { border-radius: 0 6px 6px 0; }
.bmi-scale .marker { position: absolute; top: -6px; width: 4px; height: 24px; margin-left: -2px; border-radius: 2px;
  background: var(--ink); box-shadow: 0 0 0 2px var(--surface); }
.bmi-ticks { position: relative; height: 16px; font-size: 11px; color: var(--muted); }
.bmi-ticks i { position: absolute; transform: translateX(-50%); font-style: normal; }
.big-weight { font-size: 44px; font-weight: 700; letter-spacing: -.02em; line-height: 1.05; }
.big-weight small { font-size: 18px; font-weight: 600; opacity: .8; }

/* quick weight entry */
.quick { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.quick input { font-size: 26px; font-weight: 700; }

/* chart */
.chart { width: 100%; height: 220px; display: block; }
.chart .grid line { stroke: var(--line); }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.chart .line { fill: none; stroke: var(--navy-2); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--surface); stroke: var(--navy-2); stroke-width: 2; }
.chart .dot.last { fill: var(--orange); stroke: var(--orange); }
.chart .healthy { fill: var(--in); opacity: .12; }
.chart .target { stroke: var(--orange); stroke-dasharray: 5 4; stroke-width: 1.5; }
.ranges { display: flex; gap: 6px; }
.ranges a { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink); }
.ranges a.on { background: var(--navy); color: #fff; border-color: var(--navy); }

/* fingerprint buttons + password fallback */
.bio-btn { min-height: 56px; font-size: 16px; }
.bio-btn .fp { font-size: 22px; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
#pw-box { margin-top: 14px; }
#pw-box > summary { text-align: center; text-decoration: underline; }
#pw-box[open] > summary { margin-bottom: 12px; }
.setup-bio { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px;
  padding: 12px 14px; border-radius: var(--radius); background: var(--navy); color: #fff; }
.setup-bio .btn { flex: none; }
.col2 { margin-top: 12px; }
@media (min-width: 900px) { .col2 { margin-top: 0; } }

/* calories, water, meals */
.hero.cal .cal-bar { height: 10px; border-radius: 5px; background: rgba(255,255,255,.22); margin: 10px 0 6px; overflow: hidden; position: relative; z-index: 1; }
.hero.cal .cal-bar i { display: block; height: 100%; background: #fff; border-radius: 5px; }
.hero.cal .cal-bar i.over { background: var(--orange-2); }
.water { margin-top: 12px; }
.glasses { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.glasses span { width: 18px; height: 24px; border: 2px solid #3b8fd8; border-top-width: 1px; border-radius: 2px 2px 6px 6px; }
.glasses span.full { background: linear-gradient(transparent 20%, #3b8fd8 20%); }
.sec-head { display: flex; align-items: center; gap: 10px; }
.sec-head b { flex: 1; }
.meal { margin-bottom: 12px; }
.food-edit { gap: 6px !important; }
.food-edit select { width: auto; min-height: 32px; padding: 2px 8px; font-size: 13px; border-radius: 8px; }
.linkish { all: unset; cursor: pointer; color: var(--out); font-size: 13px; text-decoration: underline; }
.chips-pick input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.chips-pick > div, .chips-pick label { display: inline-flex; }

/* food picker */
.food-pick h2.grp { margin: 18px 0 8px; }
.food-list { display: grid; gap: 6px; }
@media (min-width: 640px) { .food-list { grid-template-columns: 1fr 1fr; } }
button.food { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; text-align: left; font: inherit;
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); cursor: pointer; min-height: 48px; }
button.food small { color: var(--muted); font-size: 12px; margin-left: 4px; }
button.food b { color: var(--navy-2); font-variant-numeric: tabular-nums; }
button.food:active { background: var(--surface-2); }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 0 12px calc(12px + env(safe-area-inset-bottom)); }
.sheet-in { max-width: 560px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 -8px 30px rgba(20,32,56,.18); padding: 14px; display: grid; gap: 12px; }
.sheet-top { display: flex; justify-content: space-between; align-items: center; font-size: 17px; }
.sheet-top .linkish { color: var(--muted); text-decoration: none; font-size: 20px; }
.qty-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; }
.qty-row input { text-align: center; font-size: 22px; font-weight: 700; }
.qty-row .btn { font-size: 22px; min-width: 48px; }
.kcal-now { text-align: right; min-width: 64px; } .kcal-now b { font-size: 24px; display: block; line-height: 1; } .kcal-now small { color: var(--muted); }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wk { display: grid; justify-items: center; gap: 3px; color: inherit; font-size: 11px; }
.wk-bars { position: relative; width: 100%; max-width: 30px; height: 90px; }
.wk-bars i { position: absolute; bottom: 0; left: 0; right: 0; border-radius: 4px 4px 0 0; }
.wk-bars i.b { background: var(--line); }
.wk-bars i.e { left: 20%; right: 20%; background: var(--orange); }
.wk-bars i.e.over { background: var(--out); }
.wk-d { font-weight: 600; } .wk-m, .wk-w { color: var(--muted); }

[hidden] { display: none !important; }
.form > *, .field { min-width: 0; }
.waist-form { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-top: 12px; }
.waist-form select { width: auto; }
