/* 88 — "Saffron & Pistachio" design system.
   Material 3 token roles (primary / secondary / error / surface containers) as CSS custom properties,
   light + dark schemes, logical properties everywhere so fa (RTL) and en (LTR) both lay out correctly.
   Saffron = primary actions, pistachio = confirm / "done" / active nav, pomegranate = destructive. */

/* ---------------------------------------------------------------- tokens */
:root, [data-theme="light"] {
  color-scheme: light;
  --primary:#8A5A00; --on-primary:#FFFFFF; --primary-c:#FFDDB0; --on-primary-c:#2C1800;
  --secondary:#4C6B2F; --on-secondary:#FFFFFF; --secondary-c:#CDEBB0; --on-secondary-c:#0F2000;
  --error:#B3261E; --on-error:#FFFFFF; --error-c:#F9DEDC; --on-error-c:#410E0B;
  --info-c:#D6E3FF; --on-info-c:#001B3E;
  --warn-c:#FFE08C; --on-warn-c:#261A00;
  --bg:#F8F8F3; --s0:#FFFFFF; --s1:#F2F3EC; --s2:#ECEDE6; --s3:#E6E8E0; --s4:#DFE1D8;
  --on:#1B1C18; --on-v:#45483F; --outline:#75786D; --outline-v:#C5C8BA;
  /* macros: carbs = purple, fat = red, protein = yellow (the split bar's colors; the calorie ring uses the same).
     -ink = the same hue dark enough for text (only yellow needs its own on a light surface). */
  --m-c:#8A3FD1; --m-f:#CC2B48; --m-p:#A88900;
  --m-c-ink:#8A3FD1; --m-f-ink:#CC2B48; --m-p-ink:#7A6200;
  --scrim:rgba(20,20,15,.42);
  --shadow:0 1px 2px rgba(27,28,24,.08), 0 2px 8px rgba(27,28,24,.06);
  --shadow-lg:0 8px 28px rgba(27,28,24,.18);
  --pattern-opacity:.07;
}
[data-theme="dark"] {
  color-scheme: dark;
  --primary:#FFB951; --on-primary:#472A00; --primary-c:#663E00; --on-primary-c:#FFDDB0;
  --secondary:#B1CF96; --on-secondary:#1E3706; --secondary-c:#354E1E; --on-secondary-c:#CDEBB0;
  --error:#FFB4AB; --on-error:#690005; --error-c:#8C1D18; --on-error-c:#F9DEDC;
  --info-c:#1F3A5F; --on-info-c:#D6E3FF;
  --warn-c:#4F3F00; --on-warn-c:#FFE08C;
  --bg:#121410; --s0:#0D0F0B; --s1:#1B1D18; --s2:#1F211C; --s3:#292B26; --s4:#343631;
  --on:#E3E3DC; --on-v:#C5C8BA; --outline:#8F9285; --outline-v:#454840;
  --m-c:#C084FC; --m-f:#FF6B7D; --m-p:#FFDD3C;
  --m-c-ink:#C084FC; --m-f-ink:#FF6B7D; --m-p-ink:#FFDD3C;
  --scrim:rgba(0,0,0,.6);
  --shadow:0 1px 2px rgba(0,0,0,.4);
  --shadow-lg:0 10px 32px rgba(0,0,0,.55);
  --pattern-opacity:.06;
}
:root {
  --r-xs:8px; --r-sm:12px; --r-md:16px; --r-lg:20px; --r-xl:28px; --r-full:999px;
  --appbar-h:64px; --bnav-h:80px; --rail-w:264px;
  /* top inset; base.html swaps in the last good value when iOS reports 0 after an out-of-scope page (DARS) */
  --safe-top:env(safe-area-inset-top);
  --ease:cubic-bezier(.2,0,0,1); --dur:.18s;
  --font:'Vazirmatn', system-ui, -apple-system, 'Segoe UI', Roboto, Tahoma, sans-serif;
}

/* Persian UI: every 0-9 on the page (server text, numbers JS writes, input values, chart labels) is drawn as
   ۰-۹ by this digits-only face (Vazirmatn "Farsi Digits", subset to U+0030-0039, OFL — see fonts/). The text
   itself stays ASCII, so nothing that reads or parses numbers changes. .latin-digits opts out (emails, codes). */
@font-face { font-family:'FaDigits'; src:url(fonts/fa-digits-400.woff2) format('woff2'); font-weight:100 449; font-display:swap; unicode-range:U+0030-0039; }
@font-face { font-family:'FaDigits'; src:url(fonts/fa-digits-500.woff2) format('woff2'); font-weight:450 549; font-display:swap; unicode-range:U+0030-0039; }
@font-face { font-family:'FaDigits'; src:url(fonts/fa-digits-600.woff2) format('woff2'); font-weight:550 649; font-display:swap; unicode-range:U+0030-0039; }
@font-face { font-family:'FaDigits'; src:url(fonts/fa-digits-700.woff2) format('woff2'); font-weight:650 749; font-display:swap; unicode-range:U+0030-0039; }
@font-face { font-family:'FaDigits'; src:url(fonts/fa-digits-800.woff2) format('woff2'); font-weight:750 1000; font-display:swap; unicode-range:U+0030-0039; }
html[lang="fa"] { --font:'FaDigits', 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', Roboto, Tahoma, sans-serif; }
html[lang="fa"] body.sg { --font:'FaDigits', 'Inter', 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', Roboto, Tahoma, sans-serif; }
html[lang="fa"] :is(input, select, textarea, button, svg text) { font-family:var(--font); }
html[lang="fa"] :is(.latin-digits, input[type="email"], input[type="password"]) { font-family:'Vazirmatn', system-ui, sans-serif; }

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing:border-box; }
html { -webkit-text-size-adjust:100%; }
body { margin:0; min-height:100vh; min-height:100dvh; background:var(--bg); color:var(--on);
  font-family:var(--font); font-size:15px; line-height:1.6; -webkit-font-smoothing:antialiased;
  -webkit-tap-highlight-color:transparent; transition:background-color .25s var(--ease), color .25s var(--ease); }
a { color:var(--primary); }
h1, h2, h3 { line-height:1.3; margin:0 0 12px; }
h2 { font-size:20px; font-weight:700; }
h3 { font-size:16px; font-weight:700; }
p { margin:0 0 12px; }
img { max-width:100%; }
:focus-visible { outline:3px solid var(--primary); outline-offset:2px; border-radius:6px; }
.skip { position:absolute; inset-inline-start:8px; top:-60px; z-index:100; padding:10px 16px; border-radius:var(--r-sm);
  background:var(--primary); color:var(--on-primary); font-weight:700; text-decoration:none; }
.skip:focus { top:8px; }
.num, .ltr { direction:ltr; unicode-bidi:isolate; }
.muted { color:var(--on-v); font-size:13px; }
.big { font-size:28px; font-weight:800; }

/* Material Symbols */
.ms { font-family:'Material Symbols Rounded'; font-weight:normal; font-style:normal; font-size:22px; line-height:1;
  letter-spacing:normal; text-transform:none; white-space:nowrap; direction:ltr; display:inline-block;
  font-feature-settings:'liga'; -webkit-font-feature-settings:'liga'; -webkit-font-smoothing:antialiased;
  font-variation-settings:'FILL' 0, 'wght' 450, 'GRAD' 0, 'opsz' 24; flex:0 0 auto; user-select:none; vertical-align:middle; }
.ms.fill { font-variation-settings:'FILL' 1, 'wght' 450, 'GRAD' 0, 'opsz' 24; }
.ms.sm { font-size:18px; }
.ms.lg { font-size:28px; }
/* directional glyphs point the reading direction: mirror them in RTL */
[dir="rtl"] .ms.flip { transform:scaleX(-1); }

/* ---------------------------------------------------------------- shell */
.shell { min-height:100vh; min-height:100dvh; display:flex; flex-direction:column; }
.appbar { position:sticky; top:0; z-index:30; display:flex; align-items:center; gap:4px;
  min-height:calc(var(--appbar-h) + var(--safe-top));
  padding:var(--safe-top) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
  background:color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter:saturate(1.4) blur(14px); backdrop-filter:saturate(1.4) blur(14px); }
.appbar .brand-mini { display:grid; place-items:center; width:40px; height:40px; margin-inline-start:4px; border-radius:var(--r-sm);
  background:var(--primary); color:var(--on-primary); text-decoration:none; }
.appbar-title { flex:1; min-width:0; margin:0 8px; font-size:20px; font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.appbar-title a { color:inherit; text-decoration:none; border-radius:var(--r-xs); padding:2px 6px; transition:background-color var(--dur) var(--ease); }
.appbar-title a:hover { background:color-mix(in srgb, var(--on) 6%, transparent); }
.appbar-title a:has(.appbar-home) { display:inline-grid; place-items:center; vertical-align:middle; padding:4px 6px; }
.appbar-home { font-size:30px; color:var(--primary); }
.appbar-actions { display:flex; align-items:center; gap:2px; flex-shrink:0; }
.icon-btn { display:inline-grid; place-items:center; width:44px; height:44px; min-height:0; padding:0; margin:0; border:0; border-radius:50%;
  background:transparent; color:var(--on-v); cursor:pointer; text-decoration:none; position:relative;
  transition:background-color var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease); }
.icon-btn:hover { background:color-mix(in srgb, var(--on) 8%, transparent); color:var(--on); }
.icon-btn:active { transform:scale(.92); }
.lang-toggle { display:inline-flex; align-items:center; gap:6px; height:36px; padding:0 12px; margin:0 4px; border-radius:var(--r-full);
  border:1px solid var(--outline-v); color:var(--on-v); font-size:13px; font-weight:700; text-decoration:none; white-space:nowrap;
  transition:background-color var(--dur) var(--ease); }
.lang-toggle:hover { background:color-mix(in srgb, var(--on) 8%, transparent); }
.lang-toggle .ms { font-size:18px; }
#header-refresh.spin .ms { animation:spin .7s linear infinite; }

/* account menu (mobile) */
.menu { position:relative; }
.menu > summary { list-style:none; }
.menu > summary::-webkit-details-marker { display:none; }
.menu-panel { position:absolute; inset-inline-end:0; top:calc(100% + 6px); min-width:200px; padding:8px 0; border-radius:var(--r-md);
  background:var(--s3); box-shadow:var(--shadow-lg); z-index:40; animation:pop .16s var(--ease); }
.menu-panel a { display:flex; align-items:center; gap:12px; min-height:48px; padding:0 16px; color:var(--on); text-decoration:none; font-weight:500; }
.menu-panel a:hover { background:color-mix(in srgb, var(--on) 8%, transparent); }
.menu-panel .ms { color:var(--on-v); }

.wrap { width:100%; max-width:560px; margin:0 auto; flex:1;
  padding:8px max(16px, env(safe-area-inset-right)) calc(var(--bnav-h) + 24px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
body.no-nav .wrap { padding-bottom:40px; }

/* bottom navigation (mobile) — M3 navigation bar: 80dp tall, 64x32 active indicator */
nav.bottom { position:fixed; inset-inline:0; bottom:0; z-index:30; display:flex;
  padding:0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background:var(--s2); border-top:1px solid color-mix(in srgb, var(--outline-v) 50%, transparent); }
nav.bottom a { flex:1; min-width:0; height:var(--bnav-h); display:flex; flex-direction:column; align-items:center; justify-content:center; gap:4px;
  color:var(--on-v); text-decoration:none; font-size:12px; font-weight:600; }
nav.bottom .ind { display:grid; place-items:center; width:64px; height:32px; border-radius:var(--r-full);
  transition:background-color .2s var(--ease), width .2s var(--ease); }
nav.bottom a:hover .ind { background:color-mix(in srgb, var(--on) 8%, transparent); }
nav.bottom a.active { color:var(--on); font-weight:700; }
nav.bottom a.active .ind { background:var(--secondary-c); color:var(--on-secondary-c); }
nav.bottom a.active .ms { font-variation-settings:'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; }
nav.bottom .lbl { max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; padding:0 2px; }

/* side navigation (desktop) — M3 navigation drawer, standard (always visible) */
.rail { display:none; }
@media (min-width:1000px) {
  body.has-nav { display:grid; grid-template-columns:var(--rail-w) minmax(0,1fr); }
  .rail { display:flex; flex-direction:column; gap:2px; position:sticky; top:0; height:100vh; height:100dvh; overflow-y:auto;
    padding:16px 12px 20px; background:var(--s1); border-inline-end:1px solid color-mix(in srgb, var(--outline-v) 45%, transparent); }
  .rail .brand { display:flex; align-items:center; gap:12px; padding:8px 12px 24px; color:var(--on); text-decoration:none; }
  .rail .brand .logo { display:block; width:44px; height:44px; border-radius:50%; object-fit:cover; }
  .rail .brand b { font-size:22px; font-weight:800; letter-spacing:-.5px; }
  .rail .brand small { display:block; font-size:12px; color:var(--on-v); font-weight:500; margin-top:-2px; }
  .rail a.nav { display:flex; align-items:center; gap:14px; height:52px; padding:0 18px; border-radius:var(--r-full);
    color:var(--on-v); text-decoration:none; font-weight:600; font-size:14px; transition:background-color var(--dur) var(--ease), color var(--dur) var(--ease); }
  .rail a.nav:hover { background:color-mix(in srgb, var(--on) 8%, transparent); color:var(--on); }
  .rail a.nav.active { background:var(--secondary-c); color:var(--on-secondary-c); }
  .rail a.nav.active .ms { font-variation-settings:'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; }
  .rail .sep { height:1px; margin:12px 16px; background:var(--outline-v); opacity:.6; }
  .rail .spacer { flex:1; }
  nav.bottom, .appbar .brand-mini, .appbar .menu { display:none; }
  .appbar { padding:0 24px; }
  .appbar-title { font-size:24px; margin:0 8px; }
  .wrap { max-width:1240px; padding:8px 32px 48px; }
  .wrap.narrow { max-width:640px; }
}
body.no-nav .wrap { max-width:460px; }

/* ---------------------------------------------------------------- surfaces */
.card { background:var(--s1); border-radius:var(--r-xl); padding:20px; margin-bottom:12px; }
.card.outlined { background:transparent; border:1px solid var(--outline-v); }
.card > h2:first-child, .card > h3:first-child { margin-top:0; }
.section-h { display:flex; align-items:center; justify-content:space-between; gap:8px; margin:24px 4px 10px;
  font-size:14px; font-weight:700; color:var(--on-v); }
.section-h:first-child { margin-top:4px; }
.section-h a { font-size:13px; font-weight:700; color:var(--primary); text-decoration:none; display:inline-flex; align-items:center; gap:2px; }
.row { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.stat-row { display:flex; align-items:center; justify-content:space-between; gap:10px; min-height:44px; border-bottom:1px solid var(--outline-v); }
.stat-row:last-child { border-bottom:0; }
.grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.stack { display:flex; flex-direction:column; gap:8px; }

/* ---------------------------------------------------------------- buttons */
button, input[type=submit], .btn {
  -webkit-appearance:none; appearance:none; display:flex; align-items:center; justify-content:center; gap:8px; width:100%;
  min-height:52px; padding:12px 20px; margin:0 0 10px; border:0; border-radius:var(--r-full);
  background:var(--s3); color:var(--on); font:inherit; font-size:15px; font-weight:700; text-align:center; text-decoration:none;
  cursor:pointer; position:relative; overflow:hidden; line-height:1.3;
  transition:background-color var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform .12s var(--ease); }
button:hover, input[type=submit]:hover, .btn:hover { background:color-mix(in srgb, var(--on) 10%, var(--s3)); }
button:active, input[type=submit]:active, .btn:active { transform:scale(.98); }
button:disabled, input[type=submit]:disabled { opacity:.45; cursor:default; }
.btn-primary, input[type=submit].btn-primary { background:var(--primary); color:var(--on-primary); }
.btn-primary:hover, input[type=submit].btn-primary:hover { background:color-mix(in srgb, var(--on-primary) 10%, var(--primary)); box-shadow:var(--shadow); }
.btn-good, input[type=submit].btn-good { background:var(--secondary); color:var(--on-secondary); }
.btn-good:hover, input[type=submit].btn-good:hover { background:color-mix(in srgb, var(--on-secondary) 10%, var(--secondary)); box-shadow:var(--shadow); }
.btn-bad, input[type=submit].btn-bad { background:var(--error-c); color:var(--on-error-c); }
.btn-bad:hover, input[type=submit].btn-bad:hover { background:color-mix(in srgb, var(--on-error-c) 10%, var(--error-c)); }
.btn-tonal { background:var(--secondary-c); color:var(--on-secondary-c); }
.btn-tonal:hover { background:color-mix(in srgb, var(--on-secondary-c) 10%, var(--secondary-c)); }
.btn-outline { background:transparent; border:1px solid var(--outline); color:var(--primary); }
.btn-outline:hover { background:color-mix(in srgb, var(--primary) 8%, transparent); }
.btn-text { background:transparent; color:var(--primary); min-height:44px; width:auto; padding:8px 12px; }
.btn-text:hover { background:color-mix(in srgb, var(--primary) 8%, transparent); }
.btn-row { display:flex; gap:10px; }
.btn-row > *, .btn-row form { flex:1; margin:0; }
.btn-row form > button, .btn-row form > input[type=submit] { margin:0; }

/* list tiles (navigation rows) */
a.tile { display:flex; align-items:center; gap:14px; width:100%; min-height:60px; padding:10px 16px; margin-bottom:8px;
  border-radius:var(--r-lg); background:var(--s1); color:var(--on); text-decoration:none; font-size:15px; font-weight:600;
  transition:background-color var(--dur) var(--ease), transform .12s var(--ease); }
a.tile:hover { background:var(--s3); }
a.tile:active { transform:scale(.985); }
a.tile .tile-ic { display:grid; place-items:center; width:40px; height:40px; border-radius:var(--r-sm); background:var(--s3); color:var(--primary); flex:0 0 auto; }
a.tile .tile-txt { flex:1; min-width:0; }
a.tile .tile-sub { display:block; font-size:12px; font-weight:500; color:var(--on-v); }
a.tile .chev { color:var(--on-v); }
a.tile.tile-back { min-height:52px; background:transparent; border:1px solid var(--outline-v); color:var(--on-v); justify-content:center; font-weight:700; margin-top:8px; }
a.tile.tile-back:hover { background:color-mix(in srgb, var(--on) 6%, transparent); color:var(--on); }
a.tile.active { background:var(--secondary-c); color:var(--on-secondary-c); }
a.tile.active .tile-ic { background:color-mix(in srgb, var(--on-secondary-c) 14%, transparent); color:var(--on-secondary-c); }
a.tile.active .chev { color:inherit; }

/* ---------------------------------------------------------------- forms */
.field { display:block; margin:0 2px 6px; font-size:13px; font-weight:600; color:var(--on-v); }
input[type=text], input[type=number], input[type=password], input[type=email], input[type=date], textarea, select {
  width:100%; min-height:52px; padding:12px 16px; margin:0 0 12px; border-radius:var(--r-sm); border:1px solid var(--outline);
  background:var(--s0); color:var(--on); font:inherit; font-size:16px;
  transition:border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
[data-theme="dark"] input[type=text], [data-theme="dark"] input[type=number], [data-theme="dark"] input[type=password],
[data-theme="dark"] input[type=email], [data-theme="dark"] input[type=date], [data-theme="dark"] textarea { background:var(--s2); }
input::placeholder, textarea::placeholder { color:color-mix(in srgb, var(--on-v) 75%, transparent); }
input:focus, textarea:focus, select:focus { outline:none; border-color:var(--primary); box-shadow:0 0 0 1px var(--primary); }
textarea { resize:vertical; line-height:1.6; }
/* clear-all ✕ pinned to a textarea's top corner (added by base.html's script) */
.ta-wrap { position:relative; }
.ta-wrap textarea { padding-inline-end:52px; }
button.ta-clear { position:absolute; top:6px; inset-inline-end:6px; width:40px; min-height:40px; height:40px; padding:0; margin:0;
  border-radius:var(--r-full); background:var(--s3); color:var(--on-v); z-index:1; }
button.ta-clear:hover { background:var(--error-c); color:var(--on-error-c); }
button.ta-clear .ms { font-size:22px; }
.ta-wrap.empty button.ta-clear { opacity:0; pointer-events:none; }
.search { position:relative; }
.search .ms { position:absolute; inset-inline-start:14px; top:50%; transform:translateY(-50%); color:var(--on-v); pointer-events:none; }
.search input[type=text] { padding-inline-start:46px; border-radius:var(--r-full); background:var(--s3); border-color:transparent; margin:0; }
[data-theme="dark"] .search input[type=text] { background:var(--s3); }
.search .fake-caret { position:absolute; top:50%; width:2px; height:22px; margin-top:-11px; border-radius:1px; background:var(--primary);
  pointer-events:none; animation:caret-blink 1.06s steps(1) infinite; }
.search input:focus ~ .fake-caret, .search input:not(:placeholder-shown) ~ .fake-caret { display:none; }
@keyframes caret-blink { 50% { opacity:0; } }
@media (prefers-reduced-motion: reduce) { .search .fake-caret { animation:none; } }
/* food page: a soft light sweep across the search bar on arrival, once more 6s later, then still */
#food-search-wrap .search { overflow:hidden; border-radius:var(--r-full); }
#food-search-wrap .search::after { content:""; position:absolute; inset:0; pointer-events:none; border-radius:inherit;
  background:linear-gradient(105deg, transparent 30%, rgba(255,255,255,.55) 50%, transparent 70%);
  transform:translateX(-110%); animation:search-sheen 6s ease-in-out .5s 2; }
[data-theme="dark"] #food-search-wrap .search::after { background:linear-gradient(105deg, transparent 30%, rgba(255,255,255,.12) 50%, transparent 70%); }
[dir="rtl"] #food-search-wrap .search::after { transform:translateX(110%); animation-name:search-sheen-rtl; }
@keyframes search-sheen { 0% { transform:translateX(-110%); } 28%, 100% { transform:translateX(110%); } }
@keyframes search-sheen-rtl { 0% { transform:translateX(110%); } 28%, 100% { transform:translateX(-110%); } }
@media (prefers-reduced-motion: reduce) { #food-search-wrap .search::after { animation:none; display:none; } }

/* ---------------------------------------------------------------- feedback */
.error, .notice, .warning { display:flex; align-items:flex-start; gap:10px; padding:12px 16px; border-radius:var(--r-md); margin-bottom:12px;
  font-size:14px; font-weight:500; line-height:1.6; animation:fadein .25s var(--ease); white-space:pre-line; }
.error::before, .notice::before, .warning::before { font-family:'Material Symbols Rounded'; font-size:20px; line-height:1.4;
  font-feature-settings:'liga'; font-variation-settings:'FILL' 1; flex:0 0 auto; }
.error { background:var(--error-c); color:var(--on-error-c); }
.error::before { content:'error'; }
.notice { background:var(--secondary-c); color:var(--on-secondary-c); }
.notice::before { content:'check_circle'; }
.warning { background:var(--warn-c); color:var(--on-warn-c); }
.warning::before { content:'warning'; }
.card.muted { color:var(--on-v); font-size:14px; }
.pill { display:inline-flex; align-items:center; gap:4px; height:24px; padding:0 10px; border-radius:var(--r-full); font-size:12px; font-weight:700; white-space:nowrap; }
.pill.run { background:var(--secondary-c); color:var(--on-secondary-c); }
.pill.stop { background:var(--primary-c); color:var(--on-primary-c); }
.chip { display:inline-flex; align-items:center; gap:6px; min-height:32px; padding:4px 12px; border-radius:var(--r-xs);
  background:var(--s3); color:var(--on); font-size:13px; font-weight:600; }

/* tables */
table { width:100%; border-collapse:collapse; font-size:14px; }
td, th { padding:10px 4px; border-bottom:1px solid var(--outline-v); text-align:start; vertical-align:middle; }
tr:last-child td { border-bottom:0; }
td:last-child { text-align:end; color:var(--on-v); font-variant-numeric:tabular-nums; white-space:nowrap; }

/* ---------------------------------------------------------------- nutrient charts (shared) */
.chart-row { margin:0 0 6px; padding:10px 12px; border-radius:var(--r-sm); border-inline-start:4px solid transparent;
  transition:background-color var(--dur) var(--ease); }
.chart-row.clickable { cursor:pointer; }
/* total fat beside its three kinds: a reference line, not a bar (nutrient_bars reference=True) */
.fat-ref { display:flex; flex-wrap:wrap; align-items:baseline; gap:2px 10px; margin:0 0 8px; padding:8px 12px;
  border-radius:var(--r-sm); border:1px dashed var(--outline-v); color:var(--on-v); font-size:12px; }
.fat-ref-label { font-weight:600; color:var(--on); }
.fat-ref-caption { unicode-bidi:plaintext; }
.fat-ref-unknown { color:var(--on-warn-c); background:var(--warn-c); border-radius:999px;
  padding:2px 10px; width:max-content; max-width:100%; flex-basis:auto; }
.sg-n.fat-ref { padding:10px 12px; margin:6px 0; }
.chart-row.clickable:hover { background:color-mix(in srgb, var(--on) 5%, transparent); }
.chart-label { display:flex; justify-content:space-between; align-items:baseline; gap:8px; font-size:14px; }
.chart-label .bold { font-weight:800; font-size:15px; }
.chart-pct { font-weight:800; font-variant-numeric:tabular-nums; direction:ltr; unicode-bidi:isolate; }
/* the track keeps the server's left-anchored geometry (fill / dashed limits are
   positioned with `left:` from app.py), so it is always laid out LTR */
.chart-track { position:relative; height:10px; margin-top:8px; border-radius:5px; background:var(--s4); direction:ltr; }
.chart-track.nutr, .chart-track.nutr .chart-fill { height:13px; border-radius:6.5px; } /* nutrient bars: 30% thicker */
.chart-fill { position:absolute; top:0; bottom:0; left:0; width:0; border-radius:5px; background:var(--primary);
  animation:grow .7s var(--ease) both; transform-origin:left center; }
/* nutrient bars: one color for the whole fill — below the floor / inside the range / past the ceiling */
.chart-fill.tone-low { background:#378ADD; }
.chart-fill.tone-ok { background:#639922; }
.chart-fill.tone-over { background:#E24B4A; }
.chart-fill.tone-short { background:#E8833A; }
.chart-fill.tone-mid { background:#E8C547; }
.chart-dash { position:absolute; top:-4px; bottom:-4px; width:0; border-left:2px dashed #1B1C18; }
/* the default (un-colored) dash is the black "record / goal" line the chart notes describe: keep it black in
   the dark theme too, with a thin light halo so it still reads on the dark track */
[data-theme="dark"] .chart-dash:not([style*="border-color"]) { filter:drop-shadow(0 0 1px rgba(255,255,255,.95)) drop-shadow(0 0 1px rgba(255,255,255,.6)); }
/* captions are server-built mixed-script strings ("1,454 / 2,588 kcal · هدف …", "امروز 5m · رکورد …"):
   the first strong character picks the direction, the block edge follows the page */
.chart-caption { font-size:11px; margin-top:4px; color:var(--on-v); unicode-bidi:plaintext; text-align:left; }
[dir="rtl"] .chart-caption { text-align:right; }
.chart-notes { font-size:11px; color:var(--on-v); margin-top:12px; line-height:1.7; padding:12px 14px; border-radius:var(--r-sm); background:var(--s2); }
[dir="ltr"] .chart-notes, .chart-notes.ltr { direction:ltr; text-align:left; }
.others-toggle { display:flex; align-items:center; justify-content:center; gap:6px; cursor:pointer; min-height:44px; margin:6px 0 8px;
  padding:8px 12px; border-radius:var(--r-full); background:var(--s3); color:var(--on-v); font-size:13px; font-weight:700;
  transition:background-color var(--dur) var(--ease); user-select:none; }
.others-toggle:hover { background:var(--s4); color:var(--on); }
#others-block { display:none; }
#others-block.open { display:block; animation:fadein .25s var(--ease); }
.src-hint, .daily-hint { display:flex; align-items:center; gap:4px; font-size:11px; color:var(--on-v); margin-top:4px; }
.src-hint .ms, .daily-hint .ms { font-size:15px; }
.src-block, .daily-block { display:none; margin-top:10px; }
.src-block.open, .daily-block.open { display:block; animation:fadein .25s var(--ease); }
.src-bar { display:flex; height:20px; border-radius:6px; overflow:hidden; background:var(--s3); gap:2px; margin-bottom:8px; direction:ltr; }
.src-seg { height:100%; display:flex; align-items:center; justify-content:center; overflow:hidden; }
.src-seg-label { font-size:9px; font-weight:800; line-height:1; white-space:nowrap; }
.src-legend { display:flex; flex-direction:column; gap:4px; direction:ltr; }
.src-row { display:flex; align-items:center; gap:8px; font-size:12px; }
.src-swatch { width:10px; height:10px; border-radius:3px; flex:0 0 auto; }
.src-name { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--on); }
.src-amt, .src-pct { color:var(--on-v); font-variant-numeric:tabular-nums; flex:0 0 auto; text-align:right; }
.src-amt { min-width:56px; } .src-pct { min-width:34px; }
.daily-row { margin-bottom:8px; }
.daily-row.clickable { cursor:pointer; }
.daily-head { display:flex; justify-content:space-between; gap:8px; font-size:12px; margin-bottom:3px; }
.daily-track { position:relative; height:8px; background:var(--s4); border-radius:4px; direction:ltr; }
.daily-fill { position:absolute; top:0; bottom:0; left:0; background:var(--secondary); border-radius:4px; }

/* ---------------------------------------------------------------- calorie hero (dashboard + food) */
.hero { position:relative; overflow:hidden; background:var(--s1); border-radius:var(--r-xl); padding:20px; margin-bottom:12px; }
.hero.tappable { cursor:pointer; transition:background-color var(--dur) var(--ease); }
.hero.tappable:hover { background:color-mix(in srgb, var(--on) 3%, var(--s1)); }
.hero .girih { position:absolute; inset:0; width:100%; height:100%; color:var(--primary); opacity:var(--pattern-opacity); pointer-events:none; }
.hero-body { position:relative; display:flex; align-items:center; gap:20px; }
.ring { position:relative; flex:0 0 auto; width:160px; height:160px; }
.ring svg { width:100%; height:100%; transform:rotate(-90deg); overflow:visible; }
[dir="rtl"] .ring svg { transform:rotate(-90deg) scaleY(-1); }  /* fill runs counter-clockwise, the reading direction */
.ring .track { stroke:var(--s4); }
.ring .seg { transition:stroke-dasharray .9s var(--ease), stroke-dashoffset .9s var(--ease); }
.ring.over .track { stroke:color-mix(in srgb, var(--error) 35%, var(--s4)); }
.ring-center { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; }
.ring-kcal { font-size:32px; font-weight:800; line-height:1.05; letter-spacing:-.5px; font-variant-numeric:tabular-nums; }
.ring-unit { font-size:12px; color:var(--on-v); font-weight:600; }
.ring-pct { margin-top:4px; font-size:12px; font-weight:800; color:var(--secondary); }
.ring.over .ring-pct { color:var(--error); }
.hero-side { flex:1; min-width:0; display:flex; flex-direction:column; gap:8px; }
.hero-title { font-size:14px; font-weight:700; color:var(--on-v); }
.hero-caption { font-size:12px; color:var(--on-v); unicode-bidi:plaintext; text-align:left; line-height:1.5; }
[dir="rtl"] .hero-caption { text-align:right; }
.macro-row { display:flex; align-items:center; gap:8px; font-size:14px; }
.macro-row .dot { width:10px; height:10px; border-radius:50%; flex:0 0 auto; }
.macro-row .nm { flex:1; min-width:0; color:var(--on-v); }
.macro-row b { font-weight:800; font-variant-numeric:tabular-nums; }
.macro-row .pc { font-size:12px; color:var(--on-v); min-width:34px; text-align:end; font-variant-numeric:tabular-nums; }
.hero-hint { display:inline-flex; align-items:center; gap:4px; align-self:flex-start; margin-top:2px; padding:4px 10px 4px 8px;
  border-radius:var(--r-full); background:var(--s3); font-size:12px; font-weight:700; color:var(--on-v); }
.hero-hint .ms { font-size:18px; transition:transform .25s var(--ease); }
.hero[aria-expanded="true"] .hero-hint .ms { transform:rotate(180deg); }
@media (max-width:480px) {
  .hero { padding:16px; }
  .hero-body { gap:14px; } .ring { width:136px; height:136px; } .ring-kcal { font-size:26px; }
  .macro-row { font-size:13px; gap:6px; } .macro-row .pc { display:none; }
}
/* macro split bar (under the calorie hero): thick = actual share of the calories, thin = recommended */
.m-carbs { background:var(--m-c); } .m-fat { background:var(--m-f); } .m-protein { background:var(--m-p); }
.m-carbs-ink { color:var(--m-c-ink); } .m-fat-ink { color:var(--m-f-ink); } .m-protein-ink { color:var(--m-p-ink); }
.msplit { display:flex; align-items:center; gap:6px; padding:12px 14px 10px 16px; }
.msplit-body { flex:1; min-width:0; }
.msplit-edit { flex:0 0 auto; width:40px; height:40px; color:var(--on-v); }
.msplit-labels { display:flex; min-height:20px; padding:0 6px; font-size:14px; font-weight:800; }
.msplit-labels span { flex:0 0 auto; min-width:0; white-space:nowrap; text-align:center; }  /* centered over its segment */
.msplit-labels.top { align-items:flex-end; margin-bottom:4px; }
.msplit-labels.bottom { align-items:flex-start; margin-top:4px; }
.msplit-track { background:var(--s3); border:1px solid var(--outline-v); border-radius:var(--r-sm); padding:5px; display:flex; flex-direction:column; gap:5px; }
.msplit-bar, .msplit-rec { display:flex; gap:3px; transform-origin:left center; animation:msgrow .9s var(--ease) both; }
[dir="rtl"] .msplit-bar, [dir="rtl"] .msplit-rec { transform-origin:right center; }
.msplit-bar { height:26px; }
.msplit-bar span { border-radius:6px; min-width:3px; transition:filter var(--dur) var(--ease); }
.msplit-bar.empty { background:var(--s4); border-radius:6px; }
.msplit-rec { height:6px; animation-delay:.12s; }
.msplit-rec span { border-radius:var(--r-full); opacity:.8; }
.msplit-track:hover .msplit-bar span { filter:saturate(1.15) brightness(1.05); }
@keyframes msgrow { from { transform:scaleX(0); } to { transform:scaleX(1); } }
@media (prefers-reduced-motion: reduce) { .msplit-bar, .msplit-rec { animation:none; } .msplit-bar span { transition:none; } }
.details { display:none; }
.details.open { display:block; animation:fadein .25s var(--ease); }

/* ---------------------------------------------------------------- bottom sheet / dialog */
#amount-backdrop { position:fixed; inset:0; background:var(--scrim); opacity:0; pointer-events:none; transition:opacity .22s var(--ease); z-index:60; }
#amount-backdrop.open { opacity:1; pointer-events:auto; }
#amount-sheet, #catalog-sheet { position:fixed; inset-inline:0; bottom:0; z-index:70; max-height:88vh; overflow-y:auto;
  padding:12px 20px calc(20px + env(safe-area-inset-bottom)); border-radius:var(--r-xl) var(--r-xl) 0 0;
  background:var(--s1); box-shadow:var(--shadow-lg); transform:translateY(105%); visibility:hidden;
  transition:transform .28s var(--ease), visibility 0s linear .28s; }
#amount-sheet::before, #catalog-sheet::before { content:""; display:block; width:32px; height:4px; margin:0 auto 14px; border-radius:2px; background:var(--outline); opacity:.6; }
#amount-sheet.open, #catalog-sheet.open { transform:translateY(0); visibility:visible; transition:transform .28s var(--ease), visibility 0s; }
#amount-sheet h3, #catalog-sheet h3 { margin:0 0 16px; text-align:center; font-size:17px; }
.sheet-section-label { font-size:13px; font-weight:600; color:var(--on-v); margin:0 2px 8px; }
.sheet-presets { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-bottom:12px; }
.sheet-presets button { margin:0; min-height:48px; border-radius:var(--r-sm); background:var(--s3); font-variant-numeric:tabular-nums; }
.sheet-presets button:hover { background:var(--primary-c); color:var(--on-primary-c); }
.sheet-custom { display:flex; gap:8px; margin-bottom:12px; }
.sheet-custom input[type=text] { margin:0; }
.sheet-custom input[type=submit] { flex:0 0 auto; width:auto; min-width:96px; max-width:55%; padding-inline:14px; overflow:hidden; text-overflow:ellipsis; margin:0; background:var(--primary); color:var(--on-primary); }
#sheet-alt-section.hidden { display:none; }
#sheet-cancel { margin:4px 0 0; background:transparent; border:1px solid var(--outline-v); color:var(--on-v); }
@media (min-width:700px) {
  #amount-sheet, #catalog-sheet { inset-inline:auto; left:50%; bottom:auto; top:50%; width:460px; border-radius:var(--r-xl);
    padding:24px; transform:translate(-50%,-46%) scale(.96); opacity:0; pointer-events:none;
    transition:transform .22s var(--ease), opacity .22s var(--ease), visibility 0s linear .22s; }
  #amount-sheet::before, #catalog-sheet::before { display:none; }
  #amount-sheet.open, #catalog-sheet.open { transform:translate(-50%,-50%) scale(1); opacity:1; pointer-events:auto; transition:transform .22s var(--ease), opacity .22s var(--ease), visibility 0s; }
}

/* today's items: edit/delete buttons + their yes/no dialog (_ui.html items_table / item_dialog) */
.items-edit td:nth-child(2) { text-align:end; color:var(--on-v); font-variant-numeric:tabular-nums; white-space:nowrap; unicode-bidi:plaintext; }
[dir="rtl"] .items-edit td:nth-child(2) { text-align:left; }
.items-edit td.item-acts { width:1%; padding:2px 0; white-space:nowrap; text-align:end; }
.item-acts .icon-btn { width:40px; height:40px; }
.item-acts .icon-btn .ms { font-size:20px; }
.item-acts .icon-btn.danger:hover { background:var(--error-c); color:var(--on-error-c); }
#item-dlg { width:min(420px, calc(100vw - 32px)); padding:24px; border:0; border-radius:var(--r-xl);
  background:var(--s1); color:var(--on); box-shadow:var(--shadow-lg); }
#item-dlg[open] { animation:pop .2s var(--ease); }
#item-dlg::backdrop { background:var(--scrim); }
#item-dlg h3 { margin:0 0 14px; font-size:18px; }
#item-dlg p { margin:0 0 4px; line-height:1.7; color:var(--on-v); }
#item-dlg input[type=text] { margin:0; direction:ltr; text-align:center; font-variant-numeric:tabular-nums; }
.dlg-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:20px; }
.dlg-actions button { flex:1 1 0; width:auto; min-width:0; margin:0; }
.dlg-actions .dlg-no { background:transparent; border:1px solid var(--outline-v); color:var(--on-v); }
.dlg-actions .dlg-yes { background:var(--primary); color:var(--on-primary); }
.dlg-actions .dlg-yes.danger { background:var(--error); color:var(--on-error); }
.dlg-actions .dlg-yes:hover { box-shadow:var(--shadow); filter:brightness(1.05); }

/* ---------------------------------------------------------------- food / nutrient grids */
.food-grid { display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:10px; }
@media (min-width:640px) { .food-grid { grid-template-columns:repeat(3, minmax(0,1fr)); } }
@media (min-width:1000px) { .food-grid { grid-template-columns:repeat(auto-fill, minmax(190px, 1fr)); } }
.food-item { display:flex; flex-direction:column; gap:10px; min-width:0; padding:12px; border-radius:var(--r-lg); background:var(--s1);
  transition:background-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.food-item:hover { box-shadow:var(--shadow); }
.food-item-name { font-size:14px; font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; padding:0 2px; }
.food-item-name a { color:inherit; text-decoration:none; }
.food-item-name .fridge-mark .ms { font-size:16px; vertical-align:-3px; margin-inline-end:3px; color:var(--primary); }
.food-item-name a:hover { text-decoration:underline; text-underline-offset:3px; }
.food-item-total { font-size:11px; color:var(--on-v); margin-top:-8px; padding:0 2px; }
.food-item .row2 { display:flex; gap:6px; align-items:stretch; }
.food-item .amount-display { flex:1; min-width:0; min-height:44px; margin:0; padding:6px; border-radius:var(--r-sm); border:1px solid var(--outline-v);
  background:var(--s0); color:var(--on); font-size:15px; font-weight:700; font-variant-numeric:tabular-nums; }
[data-theme="dark"] .food-item .amount-display { background:var(--s2); }
.food-item .amount-display:hover { border-color:var(--primary); background:color-mix(in srgb, var(--primary) 6%, var(--s0)); }
.food-item input[type=submit] { flex:0 0 44px; width:44px; min-height:44px; padding:0; margin:0; border-radius:var(--r-sm);
  background:var(--primary-c); color:var(--on-primary-c); font-size:22px; font-weight:700; }
.food-item input[type=submit]:hover { background:var(--primary); color:var(--on-primary); }
.food-item input[type=submit].added { background:var(--secondary); color:var(--on-secondary); }
.food-item input[type=submit].pending { background:var(--primary); color:var(--on-primary); animation:pulse 1s ease-in-out infinite; }
.food-gear { flex:0 0 36px; display:grid; place-items:center; border-radius:var(--r-sm); color:var(--on-v); text-decoration:none;
  transition:background-color var(--dur) var(--ease), color var(--dur) var(--ease); }
.food-gear:hover { background:var(--s3); color:var(--on); }
.food-gear .ms { font-size:20px; }
a.food-item.cat-item { text-decoration:none; color:var(--on-primary-c); background:var(--primary-c); justify-content:space-between; }
a.food-item.cat-item:hover { background:color-mix(in srgb, var(--on-primary-c) 8%, var(--primary-c)); }
.cat-item .cat-top { display:flex; align-items:center; gap:10px; font-weight:800; font-size:14px; }
.cat-item .cat-count { display:flex; align-items:center; justify-content:space-between; font-size:13px; font-weight:700; opacity:.85; }
.sticky-search { position:sticky; top:calc(var(--appbar-h) + var(--safe-top)); z-index:20; padding:8px 0; margin:0 0 8px; background:var(--bg); }

/* ---------------------------------------------------------------- page layouts */
.page-grid { display:grid; grid-template-columns:minmax(0,1fr); gap:0 24px; }
@media (min-width:1000px) {
  .page-grid.two { grid-template-columns:minmax(0,1.1fr) minmax(0,1fr); align-items:start; }
  .page-grid.side-start { grid-template-columns:360px minmax(0,1fr); align-items:start; }
  .page-grid .sticky-col { position:sticky; top:calc(var(--appbar-h) + 8px); }
  .page-grid .span-all { grid-column:1 / -1; }
}
.prose { white-space:pre-wrap; line-height:2; font-size:15px; }
pre { font-family:inherit; }

/* ---------------------------------------------------------------- pull-to-refresh (standalone PWA) */
#ptr-bar { position:fixed; top:0; left:0; right:0; z-index:9999; display:flex; align-items:center; justify-content:center; gap:8px;
  padding:calc(10px + var(--safe-top)) 10px 10px; font-size:13px; font-weight:700; color:var(--on-primary-c); background:var(--primary-c);
  transform:translateY(-100%); transition:transform .15s ease-out; }
#ptr-spinner { width:14px; height:14px; border-radius:50%; border:2px solid color-mix(in srgb, currentColor 35%, transparent);
  border-top-color:currentColor; animation:spin .6s linear infinite; display:none; }
#ptr-bar.loading #ptr-spinner { display:block; }

/* ---------------------------------------------------------------- motion */
@keyframes spin { to { transform:rotate(360deg); } }
@keyframes fadein { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:none; } }
@keyframes pop { from { opacity:0; transform:scale(.96) translateY(-4px); } to { opacity:1; transform:none; } }
@keyframes grow { from { transform:scaleX(0); } to { transform:scaleX(1); } }
@keyframes pulse { 50% { opacity:.55; } }
@keyframes live { 0%, 100% { opacity:1; } 50% { opacity:.25; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration:.001ms !important; animation-iteration-count:1 !important;
    transition-duration:.001ms !important; scroll-behavior:auto !important; }
}

/* "click received, working on it": a gold ring with a light glint running around the tapped key, from the
   touch until the action is done (next page shown / JS action finished). Drawn by the busy script in
   base.html as an overlay (fixed for keys in fixed boxes, else pinned to the page), so it also works on <input>s, keys that use their own ::after, and keys
   inside overflow:hidden boxes. */
@property --busy-a { syntax:'<angle>'; inherits:false; initial-value:0deg; }
:root { --busy-gold:#B8860B; --busy-glint:#FFF3C4; }
[data-theme="dark"] { --busy-gold:#D4A017; --busy-glint:#FFFBEA; }
.busy-ring { position:fixed; z-index:9999; pointer-events:none; left:0; top:0;
  box-shadow:0 0 12px color-mix(in srgb, var(--busy-gold) 45%, transparent);
  animation:busy-in .12s ease-out; }
.busy-ring::before { content:""; position:absolute; inset:0; border-radius:inherit; padding:2.5px;
  background:conic-gradient(from var(--busy-a), var(--busy-gold) 0deg, var(--busy-gold) 250deg, #FFD76A 300deg,
    var(--busy-glint) 330deg, #FFD76A 345deg, var(--busy-gold) 360deg);
  -webkit-mask:linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite:xor;
  mask:linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  animation:busy-glint 1.1s linear infinite; }
.busy-ring.out { opacity:0; transition:opacity .18s ease-out; }
@keyframes busy-glint { to { --busy-a:360deg; } }
@keyframes busy-in { from { opacity:0; transform:scale(1.06); } to { opacity:1; transform:none; } }
@media (prefers-reduced-motion: reduce) {
  .busy-ring, .busy-ring::before { animation:none !important; }
  .busy-ring::before { background:var(--busy-gold); }
}

/* ---------------------------------------------------------------- bidi for server-built quantities
   ("145 g", "2 عدد (100 g)"): let the first strong character pick the direction */
td:last-child, .qty, .amount-display, .food-item-total, .sheet-presets button { unicode-bidi:plaintext; }
[dir="rtl"] td:last-child { text-align:left; }

/* mobile app bar: home lives in the bottom bar, so the title gets the room */
@media (max-width:999px) {
  .appbar .brand-mini { display:none; }
  .appbar-title { font-size:18px; margin-inline-start:12px; }
}
@media (max-width:380px) {
  .lang-toggle .ms { display:none; }
  .lang-toggle { padding:0 10px; }
}

/* ---------------------------------------------------------------- cheat share (amount sheets) + report switch */
/* a rarely used option: small and faint on its own row at the sheet's top-left (in the flow, so a long
   title never runs under it), the percent box shows once ticked */
.cheat-pick { display:flex; width:fit-content; min-height:32px; margin:-8px auto 6px 0; align-items:center; gap:6px; direction:ltr;
  font-size:12px; color:var(--on-v); opacity:.6; transition:opacity var(--dur) var(--ease); }
.cheat-pick:hover, .cheat-pick:focus-within, .cheat-pick.on { opacity:1; }
.cheat-pick label { display:inline-flex; align-items:center; gap:4px; min-height:32px; cursor:pointer; user-select:none; }
.cheat-pick input[type=checkbox] { width:14px; height:14px; margin:0; accent-color:var(--primary); }
.cheat-pick .cheat-pct { display:inline-flex; align-items:center; gap:2px; }
.cheat-pick .cheat-pct[hidden] { display:none; }
.cheat-pick select { width:auto; min-height:32px; height:32px; padding:0 22px 0 8px; margin:0; font-size:16px; border-radius:var(--r-xs, 6px); cursor:pointer; }
@media (prefers-reduced-motion: reduce) { .cheat-pick { transition:none; } }

button.switch { flex:0 0 auto; width:52px; min-height:32px; height:32px; padding:0; margin:0; border-radius:var(--r-full);
  background:var(--s4, var(--s3)); border:2px solid var(--outline); justify-content:flex-start; overflow:visible; }
button.switch .switch-thumb { width:16px; height:16px; margin-inline:6px; border-radius:50%; background:var(--outline);
  transition:transform var(--dur) var(--ease), width var(--dur) var(--ease), height var(--dur) var(--ease), background-color var(--dur) var(--ease); }
button.switch.on { background:var(--primary); border-color:var(--primary); }
button.switch.on .switch-thumb { width:24px; height:24px; margin-inline:2px; background:var(--on-primary); transform:translateX(20px); }
[dir="rtl"] button.switch.on .switch-thumb { transform:translateX(-20px); }
button.switch:hover { background:color-mix(in srgb, var(--on) 10%, var(--s4, var(--s3))); }
button.switch.on:hover { background:color-mix(in srgb, var(--on-primary) 8%, var(--primary)); }
button.switch:focus-visible { outline:3px solid var(--primary); outline-offset:2px; }
@media (prefers-reduced-motion: reduce) { button.switch .switch-thumb { transition:none; } }

/* ---------------------------------------------------------------- "Add to yesterday" (☰ menu): light + yellow
   while food goes to yesterday, both appearances (beats samsung.css's [data-appearance][data-theme] palette) */
html[data-yday][data-theme="light"] {
  --primary:#7A5900; --on-primary:#FFFFFF; --primary-c:#FFE07A; --on-primary-c:#261A00;
  --bg:#FFF4C2; --s0:#FFFDF2; --s1:#FFF9DC; --s2:#FFF3C4; --s3:#FBE9A0; --s4:#F3DC7C;
  --on:#1F1A00; --on-v:#4D4320; --outline:#7A6A2E; --outline-v:#E2CF7A;
  --sg-pill:#F6E39A; --sg-track:#EADB9C; --sg-n-track:#F0E2A8;
}
html[data-yday] #theme-toggle { display:none; }  /* the saved theme comes back with "Come back today" */
.yday-banner { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:10px; margin:0 0 16px;
  padding:10px 14px; border-radius:var(--r-md); background:var(--primary-c); color:var(--on-primary-c); font-weight:700; }
.yday-banner span { display:inline-flex; align-items:center; gap:8px; }
.yday-banner button { margin:0; min-height:40px; }
body.sg .sg-drawer form { margin:0; }
body.sg .sg-drawer form .sg-item { width:100%; }
/* Field Nation counter (top bar, beside refresh): a small error-coloured badge with the number of new work orders */
.fn-badge { position:absolute; top:4px; inset-inline-end:2px; min-width:18px; height:18px; padding:0 5px; border-radius:var(--r-full);
  display:grid; place-items:center; background:var(--error); color:var(--on-error); font-size:11px; font-weight:800; line-height:1;
  box-shadow:0 0 0 2px var(--surface, var(--bg)); pointer-events:none; }
