/* ============================================================================
   NutriQuant Pro — Enterprise Design System
   Brand: Deep Emerald #006039 (primary) · Rich Gold #C8A44D (premium, rare)
          Graphite #2F343A (structure)
   All components consume the token layer below. No hard-coded colors elsewhere.
   ========================================================================== */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/inter-400.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/inter-600.woff2") format("woff2");
}

:root {
  /* ---- brand tokens ---- */
  --emerald-900: #03432A;
  --emerald-700: #05603A;
  --emerald-600: #067647;          /* PRIMARY brand — actions only, never tint */
  --emerald-500: #0E8653;
  --emerald-100: #c6ddd1;
  --emerald-050: #e6f2ec;
  --gold-700: #8a6d2a;             /* accessible gold for text */
  --gold-500: #C8A44D;             /* SECONDARY brand — premium, rare */
  --gold-050: #fdf3dc;
  --graphite-900: #22262b;
  --graphite-700: #2F343A;
  --graphite-500: #4b535c;
  --graphite-400: #5f6871;
  --graphite-200: #c2c8ce;
  --graphite-100: #e4e7ea;

  /* ---- semantic status ---- */
  --ok: #1e7e34;      --ok-bg: #e8f3ec;
  --warn: #92610c;    --warn-bg: #fdf3dd;  --warn-border: #e0bc6a;
  --err: #b42318;     --err-bg: #fdecea;
  --info: #175cd3;    --info-bg: #eaf1fd;

  /* ---- Clinical Slate: LIGHT theme ---- */
  --bg: #F5F6F8;                   /* cool slate canvas */
  --card: #FFFFFF;                 /* white cards */
  --card-2: #F2F4F7;
  --row-alt: #F8F9FB;
  --ink: #1B2430;                  /* slate ink */
  --ink-2: #445468;
  --muted: #64748B;
  --line: #E3E7EC;
  --line-2: #D4DAE1;
  --sidebar-bg: #101828;           /* navy-slate sidebar */
  --sidebar-hover: #1B2739;
  --sidebar-text: #98A6BC;
  --tbl-head-bg: #F2F4F7;
  --tbl-head-text: #5D6B85;
  --hover-tint: #EEF2F6;
  --focus-ring: 0 0 0 3px rgba(6, 118, 71, .22);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .07);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .10);
  --radius: 8px;

  /* ---- token aliases used by dashboard + ingredients CSS ---- */
  --text: var(--ink);
  --border: var(--line);
  --brand: var(--emerald-600);
  --surface: var(--card);
  --surface2: var(--card-2);

  /* ---- monospaced numbers for lab-precision feel ---- */
  --mono: 'Cascadia Code','Fira Code','JetBrains Mono','Courier New',ui-monospace,monospace;

  /* ---- legacy aliases consumed by existing components ---- */
  --green: var(--emerald-600);
  --green-2: var(--emerald-700);
  --green-dark: var(--emerald-900);
  --green-deep: var(--graphite-900);
  --green-light: var(--emerald-050);
  --mint: var(--emerald-100);
  --blue: var(--info);
  --blue-2: #1149a8;
  --blue-light: var(--info-bg);
  --gold: var(--gold-500);
  --gold-light: var(--gold-050);
  --amber: var(--warn);
  --amber-light: var(--warn-bg);
  --red: var(--err);
  --red-light: var(--err-bg);

  font-size: 16px;
}

[data-theme="dark"] {
  --bg: #0D1219;
  --card: #161D27;
  --card-2: #121822;
  --row-alt: #1A2230;
  --ink: #E6EAF0;
  --ink-2: #A9B4C4;
  --muted: #8B99AC;
  --line: #26303E;
  --line-2: #202836;
  --sidebar-bg: #0A0F16;
  --sidebar-hover: #161F2C;
  --sidebar-text: #8B99AC;
  --tbl-head-bg: #111823;
  --tbl-head-text: #8B99AC;
  --hover-tint: rgba(23, 178, 106, .10);
  /* dark aliases */
  --text: var(--ink);
  --border: var(--line);
  --brand: #17B26A;
  --surface: var(--card);
  --surface2: var(--card-2);
  --green: #17B26A;
  --green-2: #3CCB7F;
  --green-light: rgba(23, 178, 106, .16);
  --mint: rgba(23, 178, 106, .22);
  --gold-050: rgba(200, 164, 77, .16);
  --gold-700: #d8b869;
  --gold-light: rgba(200, 164, 77, .16);
  --warn-bg: rgba(200, 150, 40, .15);
  --warn: #e2b45f;
  --warn-border: #8a6d2a;
  --ok-bg: rgba(30, 126, 52, .18);  --ok: #3CCB7F;
  --err-bg: rgba(180, 35, 24, .18); --err: #ef8a80;
  --info-bg: rgba(23, 92, 211, .18); --info: #7ba6ef;
  --red: #ef8a80; --red-light: rgba(180, 35, 24, .18);
  --amber: #e2b45f; --amber-light: rgba(200, 150, 40, .15);
  --blue: #7ba6ef; --blue-light: rgba(23, 92, 211, .18);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  font-variant-numeric: tabular-nums;
}

/* ---------- keyboard focus (WCAG 2.2) ---------- */
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.btn:focus-visible, a:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* ---------- app frame ---------- */
#app { display: flex; min-height: 100vh; }

/* ---------- sidebar: graphite structure ---------- */
#sidebar {
  width: 236px; flex: 0 0 236px;
  background: var(--sidebar-bg); color: #fff;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 20px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand img { background: #fff; border-radius: 8px; padding: 3px; }
.brand strong { display: block; font-size: 16.5px; letter-spacing: .2px; font-weight: 600; color: #fff; }
.brand span { font-size: 11px; color: var(--sidebar-text); letter-spacing: .8px; text-transform: uppercase; }
#nav { display: flex; flex-direction: column; padding: 10px 10px; gap: 2px; flex: 1; }
#nav a {
  color: var(--sidebar-text); text-decoration: none; padding: 10px 12px;
  border-radius: 6px; font-size: 14px; display: flex; align-items: center; gap: 11px;
  transition: background .12s, color .12s;
}
#nav a .ico { width: 22px; text-align: center; font-size: 15px; opacity: .9; }
#nav a:hover { background: var(--sidebar-hover); color: #fff; }
#nav a.active { background: var(--emerald-600); color: #fff; font-weight: 600; }
#nav a.active .ico { opacity: 1; }
.sidebar-foot { padding: 14px 14px; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid rgba(255,255,255,.08); }
.pill { font-size: 12px; padding: 4px 11px; border-radius: 99px; width: fit-content; font-weight: 600; }
.pill-ok { background: rgba(23,178,106,.22); color: #7FD6A9; border: 1px solid rgba(127,214,169,.35); }
.pill-off { background: rgba(255,255,255,.08); color: var(--sidebar-text); border: 1px solid rgba(255,255,255,.18); }
#lang-sel, #theme-btn {
  background: rgba(255,255,255,.06); color: var(--sidebar-text); border: 1px solid rgba(255,255,255,.16);
  border-radius: 6px; padding: 8px 10px; font-size: 13px; font-family: inherit; cursor: pointer; text-align: left;
}
#lang-sel:hover, #theme-btn:hover { background: var(--sidebar-hover); color: #fff; }
#lang-sel option { color: var(--graphite-700); background: #fff; }
[dir="rtl"] #nav a { text-align: right; }
/* Lock screen: navigation is not usable until the app is unlocked — hide it, and give
   the mobile lock screen its own language control inside the card (audit #16). */
body[data-route="gate"] #nav { display: none; }
body[data-route="gate"] #sidebar .sidebar-foot #install-btn,
body[data-route="gate"] #sidebar .sidebar-foot #share-btn { display: none; }

/* ---------- content ---------- */
#content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#pagebar { display: flex; gap: 8px; padding: 16px clamp(16px, 3.2vw, 40px) 0; max-width: 1220px; align-items: center; }
#pagebar[hidden] { display: none; }
#pb-tools { display: none; margin-inline-start: auto; gap: 6px; align-items: center; }
#pb-tools select { width: auto; padding: 6px 8px; font-size: 12.5px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--card); color: var(--ink); font-family: inherit; }
@media (max-width: 840px) {
  #pb-tools { display: flex; }
}
#main { flex: 1; padding: 28px clamp(16px, 3.2vw, 40px) 96px; max-width: 1220px; }
#pagebar:not([hidden]) + #main { padding-top: 14px; }

/* ---------- typography hierarchy ---------- */
h1 { font-size: 23px; margin: 4px 0 6px; font-weight: 600; letter-spacing: -.2px; color: var(--ink); }
h2 { font-size: 16.5px; margin: 26px 0 10px; font-weight: 600; letter-spacing: -.1px; color: var(--ink); }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; line-height: 1.55; }
.small { font-size: 12.5px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.mt { margin-top: 14px; }
.hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.card b { color: var(--ink); }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); }

/* ---------- dashboard stats ---------- */
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--emerald-600); }
[dir="rtl"] .stat::before { left: auto; right: 0; }
.stat b { display: block; font-size: 24px; color: var(--green); font-weight: 600; letter-spacing: -.4px; }
.stat span { font-size: 12.5px; color: var(--muted); }
/* featured KPI (first stat) — gold, per brand system */
.grid-4 .stat:nth-child(1)::before { background: var(--gold-500); }
.grid-4 .stat:nth-child(1) b { color: var(--gold-700); }

/* ---------- hero ---------- */
.hero {
  background: var(--emerald-600);
  border: 1px solid var(--emerald-700);
  border-radius: 10px; color: #fff; padding: 28px 30px; margin-bottom: 18px;
  box-shadow: var(--shadow-md);
}
.hero::before, .hero::after { content: none; }
.hero h1 { color: #fff; font-size: 24px; margin: 0 0 6px; }
.hero p { color: #d9eae2; font-size: 14px; margin: 0 0 18px; max-width: 640px; line-height: 1.55; }
.hero .hero-badge {
  display: inline-flex; align-items: center; gap: 6px; background: var(--gold-500);
  color: #2b2208; font-size: 11.5px; font-weight: 600;
  padding: 4px 12px; border-radius: 99px; margin-bottom: 14px; letter-spacing: .4px;
}
.btn-hero { background: #fff; color: var(--emerald-700); }
.btn-hero:hover { background: var(--emerald-050); color: var(--emerald-900); }
.btn-hero-ghost { background: rgba(255,255,255,.10); color: #fff; border: 1px solid rgba(255,255,255,.35); }
.btn-hero-ghost:hover { background: rgba(255,255,255,.2); }

/* ---------- workflow steps ---------- */
.steps { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.step {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 8px;
}
.step .step-n {
  width: 32px; height: 32px; border-radius: 6px; background: var(--emerald-050); color: var(--green);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px;
}
[data-theme="dark"] .step .step-n { background: rgba(23,178,106,.20); }
.step b { font-size: 14.5px; color: var(--ink); }
.step p { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.55; flex: 1; }
.step a { color: var(--green); font-weight: 600; font-size: 13px; text-decoration: none; }
.step a:hover { text-decoration: underline; }

/* ---------- forms ---------- */
label.f {
  display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px;
  font-weight: 600; letter-spacing: .3px; text-transform: uppercase;
}
input, select, textarea {
  width: 100%; padding: 9px 12px; font-size: 14px; font-family: inherit; height: auto;
  border: 1px solid var(--line-2); border-radius: 6px; background: var(--card); color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
/* The dropdown LIST is painted by the operating system, and it does NOT inherit the
   control's colour. The rule above gives the select `color: var(--ink)`, which in dark
   mode is near-white — but the options had no background of their own, so the OS drew
   that near-white text on its own white list. Every dropdown in the app was unreadable
   in dark mode (reported 2026-09-05 on the currency and language pickers).
   Both values must be REAL colours here: `inherit` or `transparent` hands the OS back
   its defaults, which is the bug. Anything needing a different look overrides this with
   a more specific selector (e.g. #lang-sel option). */
select option, select optgroup {
  background-color: var(--card);
  color: var(--ink);
}
input:hover, select:hover, textarea:hover { border-color: var(--graphite-400); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); box-shadow: var(--focus-ring); }
input:disabled, select:disabled, textarea:disabled { background: var(--card-2); color: var(--muted); cursor: not-allowed; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--emerald-600); }
input[type="file"] { padding: 8px; background: var(--card-2); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1; min-width: 120px; }
.row > .w-s { flex: 0 0 115px; min-width: 95px; }
.row > .w-btn { flex: 0 0 auto; min-width: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer;
  background: var(--green); color: #fff; border: 1px solid transparent; border-radius: 6px;
  padding: 10px 18px; font-size: 14px; font-weight: 600; font-family: inherit; letter-spacing: .1px;
  box-shadow: var(--shadow-sm); transition: background .12s, transform .08s;
}
.btn:hover { background: var(--green-2); }
.btn:active { transform: scale(.985); }
.btn-2 { background: var(--card); color: var(--ink); border: 1px solid var(--line-2); box-shadow: none; }
.btn-2:hover { background: var(--card-2); border-color: var(--graphite-400); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line-2); box-shadow: none; }
.btn-ghost:hover { background: var(--card-2); color: var(--ink); }
.btn-gold { background: var(--gold-500); color: #2b2208; }
.btn-gold:hover { background: #b8933f; }
.btn-danger { background: var(--err); color: #fff; }
.btn-danger:hover { background: #8f1c13; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid var(--line); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; background: var(--card); }
.tbl th {
  text-align: left; font-size: 12px; color: var(--tbl-head-text); text-transform: uppercase;
  letter-spacing: .6px; font-weight: 600; padding: 10px 11px; white-space: nowrap;
  background: var(--tbl-head-bg); position: sticky; top: 0;
}
[dir="rtl"] .tbl th { text-align: right; }
.tbl td { border-bottom: 1px solid var(--line); padding: 9px 11px; vertical-align: middle; }
.tbl tr:nth-child(odd) td { background: var(--row-alt); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--hover-tint); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- tags / badges ---------- */
.tag {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 2.5px 9px; border-radius: 99px;
  background: var(--emerald-050); color: var(--emerald-600); margin: 1px 2px 1px 0; white-space: nowrap;
  border: 1px solid var(--emerald-100);
}
[data-theme="dark"] .tag { background: rgba(23,178,106,.16); color: #6FD3A0; border-color: rgba(23,178,106,.4); }
.tag-amber { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.tag-red { background: var(--err-bg); color: var(--err); border-color: transparent; }
.tag-gray { background: var(--graphite-100); color: var(--graphite-500); border-color: transparent; }
[data-theme="dark"] .tag-gray { background: var(--card-2); color: var(--muted); }
.tag-gold { background: var(--gold-050); color: var(--gold-700); border: 1px solid var(--gold-500); }

/* ---------- modal / toast ---------- */
#modal-root:not(:empty) {
  position: fixed; inset: 0; background: rgba(34, 38, 43, .55); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: var(--card); border-radius: 10px; padding: 22px 24px; border: 1px solid var(--line);
  width: min(700px, 100%); max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow-md);
}
.modal h2 { margin-top: 0; }
#toast-root { position: fixed; bottom: 88px; left: 50%; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--graphite-700); color: #fff; padding: 11px 20px; border-radius: 6px; font-size: 13.5px;
  font-weight: 500; box-shadow: var(--shadow-md); animation: fadein .18s; border-left: 3px solid var(--emerald-600);
}
.toast-err { border-left-color: var(--err); }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* ---------- pickers ---------- */
.search-hits { border: 1px solid var(--line-2); border-radius: 8px; max-height: 270px; overflow-y: auto; }
.search-hits button {
  display: block; width: 100%; text-align: left; background: var(--card); border: none;
  border-bottom: 1px solid var(--line); padding: 10px 13px; font-size: 13.5px; cursor: pointer;
  font-family: inherit; color: var(--ink); transition: background .1s;
}
[dir="rtl"] .search-hits button { text-align: right; }
.search-hits button:last-child { border-bottom: none; }
.search-hits button:hover { background: var(--hover-tint); }
.empty { text-align: center; color: var(--muted); padding: 38px 10px; }
.empty .big { font-size: 40px; }
a { color: var(--green); }

/* ---------- semantic disclaimer (warning) ---------- */
.disclaimer {
  background: var(--warn-bg);
  color: var(--ink);
  border: 1px solid var(--warn-border);
  border-left: 4px solid var(--gold-500);
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.55;
  margin-top: 10px;
}
.disclaimer b { color: var(--ink); font-weight: 600; }
[dir="rtl"] .disclaimer { border-left: 1px solid var(--warn-border); border-right: 4px solid var(--gold-500); }

/* ---------- printed labels: regulatory, always black on white ---------- */
.label-holder { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; }
.nlabel { background: #fff !important; color: #000 !important; font-family: Helvetica, Arial, sans-serif; box-shadow: var(--shadow-sm); }
.nlabel * { color: #000; }

@media print {
  body * { visibility: hidden; }
  #print-zone, #print-zone * { visibility: visible; }
  #print-zone { position: absolute; left: 0; top: 0; }
  @page { margin: 4mm; }
}

/* ---------- responsive ---------- */
@media (max-width: 840px) {
  #app { flex-direction: column; }
  #sidebar {
    width: 100%; flex: none; height: auto; position: fixed; bottom: 0; top: auto; z-index: 40;
    flex-direction: row; align-items: center; padding: 0;
    background: var(--graphite-900); box-shadow: 0 -2px 10px rgba(0,0,0,.3);
  }
  .brand, .sidebar-foot { display: none; }
  /* 9 tabs do not fit a phone width at readable size (audit #18): keep every tab a
     real ≥44 px touch target and let the bar scroll sideways, with a soft edge fade
     hinting there is more. Labels stay readable (11px) instead of shrinking. */
  #nav { flex-direction: row; width: 100%; padding: 4px 6px; justify-content: flex-start; gap: 2px;
         overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none;
         scroll-snap-type: x proximity; mask-image: linear-gradient(90deg, #000 0, #000 92%, transparent); }
  #nav::-webkit-scrollbar { display: none; }
  #nav a { flex: 0 0 auto; min-width: 72px; flex-direction: column; gap: 3px; font-size: 12px; line-height: 1.15;
           padding: 8px 6px; text-align: center; border-radius: 8px; scroll-snap-align: start; white-space: nowrap; }
  #nav a .ico { font-size: 20px; width: auto; }
  #nav a.active { scroll-margin-inline: 12px; }
  /* The v2 redesign wrapped the tabs in .nav-group blocks. This bar was written for a
     flat list, so those wrappers turned it into a 288 px-tall grid — 37% of a phone
     screen — with the right-hand tabs clipped. `display: contents` dissolves the
     wrappers so the tabs flow as ONE horizontal scrolling row again; the group
     headings are noise in a compact bar. */
  .nav-group { display: contents; }
  /* #sidebar-qualified: a later plain `.nav-group-label { display: block }` rule further
     down the file would otherwise win on source order and leave a stray heading in the bar. */
  #sidebar .nav-group-label { display: none; }
  /* Search keeps its place but shrinks to its icon: the label and the Ctrl-K hint were
     taking ~160 px of the row on a 375 px screen, and a phone has no Ctrl key. */
  .gs-search-wrap { padding: 0 2px 0 6px; flex: 0 0 auto; }
  .gs-trigger { padding: 9px 10px; min-width: 0; }
  .gs-trigger-text, .gs-trigger-kbd { display: none; }
  #main { padding-bottom: 96px; }
  .hero { padding: 22px 18px; }
  .modal { padding: 18px; }
}

/* ---------- Founding-customer tile on the lock screen: same quiet motion as the landing card ---------- */
.founding-tile { animation: founding-glow 3.2s ease-in-out infinite; position: relative; }
.founding-tile:hover { animation-play-state: paused; }
@keyframes founding-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(200,164,77,.0), 0 6px 22px rgba(200,164,77,.18); }
  50%      { box-shadow: 0 0 0 2px rgba(200,164,77,.55), 0 12px 36px rgba(200,164,77,.36); }
}
.founding-tile .tag-gold { animation: founding-badge 2.2s ease-in-out infinite; display: inline-block; }
@keyframes founding-badge { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.founding-tile .founding-cta { position: relative; overflow: hidden; }
.founding-tile .founding-cta::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent);
  transform: skewX(-18deg); animation: founding-shimmer 4s ease-in-out infinite; pointer-events: none;
}
@keyframes founding-shimmer { 0%, 70% { left: -60%; } 100% { left: 130%; } }
@media (prefers-reduced-motion: reduce) {
  .founding-tile, .founding-tile .tag-gold, .founding-tile .founding-cta::after { animation: none !important; }
}

/* ============================================================
   v2 PROFESSIONAL REDESIGN — append-only additions
   ============================================================ */

/* ── Table header tokens (set in :root / dark above — no override needed) ── */

/* ── Navigation groups ── */
.nav-group { margin-top: 4px; }
.nav-group-label {
  font-size: 11px; font-weight: 700; letter-spacing: .9px;
  text-transform: uppercase; color: rgba(207,212,217,.35);
  padding: 10px 14px 3px; display: block; user-select: none;
}

/* ── SVG icon inside .ico spans ── */
.nav-svg { display: block; width: 16px; height: 16px; opacity: .72; color: var(--sidebar-text); flex-shrink: 0; }
#nav a.active .nav-svg { opacity: 1; }
#nav a:hover .nav-svg { opacity: .9; }

/* ── Global search trigger ── */
.gs-search-wrap { padding: 8px 10px 2px; }
.gs-trigger {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 10px; border-radius: 7px; cursor: pointer;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1);
  color: rgba(207,212,217,.65); font-size: 12.5px; font-family: inherit;
  transition: background .12s, border-color .12s;
}
.gs-trigger:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.2); color: var(--sidebar-text); }
.gs-trigger-icon { width: 13px; height: 13px; flex-shrink: 0; opacity: .7; }
.gs-trigger-text { flex: 1; text-align: left; }
.gs-trigger-kbd { font-size: 10px; opacity: .5; background: rgba(255,255,255,.1); border-radius: 3px; padding: 1px 5px; letter-spacing: .5px; }

/* ── Global search overlay ── */
#gs-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 400;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 72px 16px 16px; backdrop-filter: blur(2px);
}
#gs-overlay[hidden] { display: none; }
#gs-box {
  background: var(--card); border: 1px solid var(--line-2); border-radius: 12px;
  width: min(560px, 100%); box-shadow: 0 24px 64px rgba(0,0,0,.22); overflow: hidden;
}
#gs-input-wrap {
  display: flex; align-items: center; padding: 0 14px;
  border-bottom: 1px solid var(--line); gap: 10px;
}
#gs-input-wrap svg { width: 17px; height: 17px; color: var(--muted); flex-shrink: 0; }
#gs-input {
  flex: 1; padding: 16px 0; font-size: 16px; font-family: inherit;
  border: none; background: transparent; color: var(--ink); outline: none;
}
#gs-results { max-height: 380px; overflow-y: auto; }
.gs-result-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); cursor: pointer;
  transition: background .08s; text-decoration: none; color: inherit;
}
.gs-result-item:last-child { border-bottom: none; }
.gs-result-item:hover, .gs-result-item.gs-sel { background: var(--hover-tint); }
.gs-result-type {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted); width: 74px; flex-shrink: 0;
}
.gs-result-name { font-size: 14px; color: var(--ink); flex: 1; line-height: 1.3; }
.gs-result-meta { font-size: 12px; color: var(--muted); }
.gs-empty { padding: 36px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.gs-footer {
  padding: 9px 16px; border-top: 1px solid var(--line);
  display: flex; gap: 16px; background: var(--card-2);
}
.gs-footer span { font-size: 11px; color: var(--muted); }

/* ── Page header ── */
.page-hdr {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.page-hdr-left { flex: 1; min-width: 0; }
.page-hdr-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-title {
  font-size: 21px; font-weight: 700; letter-spacing: -.3px;
  color: var(--ink); margin: 0 0 3px; line-height: 1.2;
}
.page-subtitle { font-size: 13.5px; color: var(--muted); margin: 0; line-height: 1.5; }

/* ── Eyebrow / section label ── */
.sec-label {
  font-size: 11.5px; font-weight: 700; letter-spacing: .8px;
  text-transform: uppercase; color: var(--muted); display: block;
}
.sec-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sec-link { font-size: 12.5px; font-weight: 600; color: var(--green); text-decoration: none; }
.sec-link:hover { text-decoration: underline; }

/* ── Status strip (clickable KPI bar) ── */
.status-strip {
  display: flex; border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; margin-bottom: 20px; background: var(--card);
  box-shadow: var(--shadow-sm);
}
.ss-item {
  flex: 1; padding: 14px 12px; text-align: center; cursor: pointer;
  border-right: 1px solid var(--line); text-decoration: none; color: var(--ink);
  display: block; transition: background .1s; min-width: 0;
}
.ss-item:last-child { border-right: none; }
.ss-item:hover { background: var(--hover-tint); }
.ss-num {
  font-size: 22px; font-weight: 700; letter-spacing: -.3px; display: block;
  color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.1;
}
.ss-num.ok { color: var(--ok); }
.ss-num.warn { color: var(--warn); }
.ss-num.brand { color: var(--emerald-600); }
.ss-label { font-size: 11px; color: var(--muted); margin-top: 4px; display: block; line-height: 1.3; }

/* ── Attention list ── */
.attn-list {
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  box-shadow: var(--shadow-sm); margin-bottom: 20px;
}
.attn-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 16px; background: var(--card);
  border-bottom: 1px solid var(--line); text-decoration: none; color: inherit;
  transition: background .1s;
}
.attn-item:last-child { border-bottom: none; }
.attn-item:hover { background: var(--hover-tint); }
.attn-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-warn { background: var(--warn); }
.dot-err { background: var(--err); }
.dot-ok { background: var(--ok); }
.dot-info { background: var(--info); }
.attn-text { flex: 1; font-size: 13.5px; color: var(--ink); }
.attn-cta { font-size: 12.5px; font-weight: 600; color: var(--green); white-space: nowrap; }

/* ── Quick actions ── */
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.qa-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 13px; border-radius: 7px; font-size: 13px; font-weight: 600;
  background: var(--card); border: 1px solid var(--line-2); color: var(--ink);
  cursor: pointer; font-family: inherit; text-decoration: none;
  box-shadow: var(--shadow-sm); transition: background .1s, border-color .12s, color .1s;
  white-space: nowrap;
}
.qa-btn:hover { background: var(--hover-tint); border-color: var(--emerald-600); color: var(--emerald-600); }
.qa-btn.qa-primary { background: var(--emerald-600); color: #fff; border-color: var(--emerald-600); }
.qa-btn.qa-primary:hover { background: var(--emerald-700); border-color: var(--emerald-700); color: #fff; }

/* ── KPI metric cards ── */
.kpi-grid { display: grid; gap: 12px; margin-bottom: 20px; }
.kpi-grid-3 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.kpi-grid-4 { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; box-shadow: var(--shadow-sm);
  border-inline-start: 3px solid var(--emerald-600);
}
.kpi.kpi-warn { border-inline-start-color: var(--warn); }
.kpi.kpi-ok { border-inline-start-color: var(--ok); }
.kpi.kpi-gold { border-inline-start-color: var(--gold-500); }
.kpi-val {
  font-size: 22px; font-weight: 700; letter-spacing: -.3px; color: var(--emerald-600);
  margin: 0 0 4px; line-height: 1; font-variant-numeric: tabular-nums;
}
.kpi-val.warn { color: var(--warn); }
.kpi-val.ok { color: var(--ok); }
.kpi-val.gold { color: var(--gold-700); }
.kpi-lbl { font-size: 11.5px; color: var(--muted); font-weight: 500; }

/* ── Data card (key-value pairs) ── */
.data-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow-sm); }
.data-card-hdr { padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--card-2); }
.data-card-title { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.data-card-body { padding: 12px 16px; }
.data-row { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line); }
.data-row:last-child { border-bottom: none; }
.data-row-label { font-size: 13px; color: var(--muted); }
.data-row-val { font-size: 13px; font-weight: 600; color: var(--ink); text-align: right; }
.data-row-val.ok { color: var(--ok); }

/* ── Tool grid cards ── */
.tool-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 20px; }
.tool-grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.tool-card {
  display: flex; align-items: flex-start; gap: 13px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 15px 16px; text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow-sm); transition: border-color .12s, box-shadow .12s;
}
.tool-card:hover { border-color: var(--emerald-600); box-shadow: 0 2px 14px rgba(6,118,71,.1); color: var(--ink); }
.tool-card-icon {
  width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0;
  background: var(--emerald-050); display: flex; align-items: center;
  justify-content: center; border: 1px solid var(--emerald-100);
}
[data-theme="dark"] .tool-card-icon { background: rgba(23,178,106,.14); border-color: rgba(23,178,106,.25); }
.tool-card-icon svg { width: 18px; height: 18px; color: var(--emerald-600); }
[data-theme="dark"] .tool-card-icon svg { color: #3CCB7F; }
.tool-card-body { min-width: 0; }
.tool-card-name { font-size: 13.5px; font-weight: 700; color: var(--ink); margin: 0 0 3px; }
.tool-card-desc { font-size: 12px; color: var(--muted); line-height: 1.45; }

/* ── Improved scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--graphite-200); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--graphite-400); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); }

/* ── Dark mode adjustments for new components ── */
[data-theme="dark"] .tool-card { border-color: rgba(255,255,255,.08); }
[data-theme="dark"] .status-strip { border-color: rgba(255,255,255,.08); }
[data-theme="dark"] .ss-item { border-right-color: rgba(255,255,255,.08); }
[data-theme="dark"] .attn-list { border-color: rgba(255,255,255,.08); }
[data-theme="dark"] .attn-item { border-bottom-color: rgba(255,255,255,.08); }
[data-theme="dark"] .kpi { border-color: rgba(255,255,255,.08); }
[data-theme="dark"] .data-card { border-color: rgba(255,255,255,.08); }
[data-theme="dark"] .data-card-hdr { border-bottom-color: rgba(255,255,255,.08); }
[data-theme="dark"] .data-row { border-bottom-color: rgba(255,255,255,.06); }

/* ================================================================
   NAVY-SLATE SIDEBAR — permanent dark on both light & dark themes,
   colored entirely by the --sidebar-* tokens above
   ================================================================ */
#sidebar { background: var(--sidebar-bg); border-right: 1px solid rgba(255,255,255,.04); }
#sidebar .brand strong { color: #F4F7FA; }
#sidebar .brand { border-bottom: 1px solid rgba(255,255,255,.05); }
#sidebar .gs-trigger { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.08); }
#sidebar .gs-trigger:hover { background: rgba(255,255,255,.09); }
#sidebar .gs-trigger-text { color: var(--sidebar-text); }
#sidebar .gs-trigger-kbd { color: var(--sidebar-text); opacity: .75; background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.10); }
.nav-group-label { color: var(--sidebar-text); opacity: .62; font-size: 11.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; padding: 14px 14px 4px; display: block; }
#sidebar #nav a { color: var(--sidebar-text); }
#sidebar #nav a:hover { background: rgba(255,255,255,.05); color: #E4EAF2; }
#sidebar #nav a.active { background: var(--sidebar-hover); color: #F4F7FA; box-shadow: inset 3px 0 0 var(--brand); }
#sidebar .sidebar-foot { border-top: 1px solid rgba(255,255,255,.05); }
#sidebar #lang-sel { background: rgba(255,255,255,.05); color: var(--sidebar-text); border-color: rgba(255,255,255,.08); }
#sidebar #theme-btn, #sidebar #install-btn, #sidebar #share-btn { background: rgba(255,255,255,.05); color: var(--sidebar-text); border-color: rgba(255,255,255,.08); }
#sidebar #theme-btn:hover, #sidebar #install-btn:hover, #sidebar #share-btn:hover { background: rgba(255,255,255,.10); color: #E4EAF2; }
#sidebar #net-status { background: rgba(23,178,106,.20); color: #6FD3A0; border-color: transparent; }

/* ================================================================
   DASHBOARD  — Precision Kitchen Intelligence
   ================================================================ */
.db-wrap { max-width: 1200px; }
.db-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; padding-top: 24px; }
.db-header-title { font-size: 26px; font-weight: 700; color: var(--ink); letter-spacing: -.4px; margin: 0; line-height: 1.2; }
.db-header-sub { font-size: 13.5px; color: var(--muted); margin: 4px 0 0; }
.db-header-actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; padding-top: 2px; }
.db-btn-qa { display: flex; align-items: center; gap: 6px; padding: 8px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--ink); cursor: pointer; text-decoration: none; position: relative; transition: background .1s, border-color .1s; }
.db-btn-qa:hover { background: var(--card-2); border-color: var(--line-2); }
.db-btn-new { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; background: var(--emerald-600); color: #fff; border-radius: 8px; font-size: 13px; font-weight: 600; text-decoration: none; border: none; cursor: pointer; transition: background .1s; }
.db-btn-new:hover { background: var(--emerald-700); }
/* KPI row */
.db-kpi-row { display: grid; grid-template-columns: repeat(6,1fr); gap: 12px; margin-bottom: 20px; }
@media (max-width:1100px) { .db-kpi-row { grid-template-columns: repeat(3,1fr); } }
@media (max-width:640px)  { .db-kpi-row { grid-template-columns: repeat(2,1fr); } }
.db-kpi-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; border-inline-start: 3px solid var(--emerald-600); transition: box-shadow .15s, border-color .15s; }
.db-kpi-card:hover { box-shadow: var(--shadow-md); border-color: var(--line-2); }
/* Gold accent on first (Ingredients) KPI */
.db-kpi-row .db-kpi-card:nth-child(1) { border-inline-start-color: var(--gold-500); }
.db-kpi-row .db-kpi-card:nth-child(1) .db-kpi-val { color: var(--gold-700); }
.db-kpi-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; margin-bottom: 4px; font-size: 15px; }
.db-kpi-icon.c-green  { background: var(--emerald-050); }
.db-kpi-icon.c-blue   { background: #E3F0FF; }
.db-kpi-icon.c-amber  { background: var(--warn-bg); }
.db-kpi-icon.c-gold   { background: var(--gold-050); }
.db-kpi-icon.c-red    { background: #FFEBEB; }
.db-kpi-icon.c-purple { background: #F0ECFF; }
.db-kpi-label { font-size: 11.5px; color: var(--muted); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.db-kpi-val   { font-size: 26px; font-weight: 700; color: var(--ink); letter-spacing: -.5px; line-height: 1.1; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.db-kpi-sub   { font-size: 12px; color: var(--muted); }
.db-kpi-status { font-size: 11.5px; font-weight: 500; margin-top: 4px; }
.db-kpi-status.s-ok   { color: var(--ok); }
.db-kpi-status.s-warn { color: var(--warn); }
.db-kpi-status.s-info { color: var(--emerald-600); }
/* Widgets grid */
.db-mid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; margin-bottom: 20px; }
@media (max-width:900px) { .db-mid { grid-template-columns: 1fr; } }
.db-widget { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; overflow: hidden; }
.db-widget-title { font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; margin: 0 0 14px; }
.db-attn-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.db-attn-item:last-child { border-bottom: none; }
.db-attn-icon { width: 28px; height: 28px; border-radius: 7px; background: var(--warn-bg); color: var(--warn); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 12px; }
.db-attn-text { flex: 1; }
.db-attn-msg  { font-size: 13px; font-weight: 500; color: var(--ink); margin-bottom: 2px; }
.db-attn-sub  { font-size: 12px; color: var(--muted); }
.db-attn-btn  { flex-shrink: 0; padding: 5px 10px; font-size: 12px; font-weight: 500; background: var(--card); border: 1px solid var(--line); border-radius: 6px; color: var(--ink); text-decoration: none; white-space: nowrap; transition: background .1s; }
.db-attn-btn:hover { background: var(--card-2); }
.db-donut-wrap { display: flex; align-items: center; gap: 16px; }
.db-donut-legend { flex: 1; display: flex; flex-direction: column; gap: 7px; }
.db-legend-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink); }
.db-legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.db-legend-val { color: var(--muted); margin-left: auto; font-size: 11.5px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.db-cost-main { font-size: 32px; font-weight: 700; color: var(--emerald-600); letter-spacing: -.6px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.db-cost-lbl  { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.db-cost-row  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 13px; }
.db-cost-key  { color: var(--muted); }
.db-recent-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 14px; }
.db-tabs { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.db-tab { padding: 8px 14px; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: color .1s; }
.db-tab.active { color: var(--emerald-600); border-bottom-color: var(--emerald-600); }
.db-tab:hover:not(.active) { color: var(--ink); }
.db-recent-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.db-recent-item:last-child { border-bottom: none; }
.db-ri-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--emerald-050); color: var(--emerald-600); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; font-weight: 600; overflow: hidden; }
.db-ri-avatar img { width: 100%; height: 100%; object-fit: cover; }
.db-ri-name { font-size: 13.5px; font-weight: 500; color: var(--ink); }
.db-ri-sub  { font-size: 11.5px; color: var(--muted); }
.db-ri-badge { padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; background: var(--emerald-050); color: var(--emerald-600); margin-left: auto; flex-shrink: 0; border: 1px solid var(--emerald-100); }
.db-ri-badge.b-dish { background: #E3F0FF; color: #1149a8; border-color: #C5D9F5; }
.db-ri-badge.b-inv  { background: var(--gold-050); color: var(--gold-700); border-color: rgba(200,164,77,.3); }
.db-ri-stats { text-align: right; flex-shrink: 0; margin-left: 8px; }
.db-ri-stat-val { font-size: 13px; font-weight: 500; color: var(--ink); }
.db-ri-stat-lbl { font-size: 12px; color: var(--muted); }
.db-view-all { font-size: 13px; color: var(--emerald-600); text-decoration: none; font-weight: 600; }
.db-view-all:hover { text-decoration: underline; }
.db-bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }
@media (max-width:640px) { .db-bottom { grid-template-columns: 1fr; } }
.db-gauge-wrap { display: flex; align-items: center; gap: 20px; }
.db-gauge-stats { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.db-gauge-row { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; }
.db-gauge-key { color: var(--muted); }
.db-gauge-num { font-weight: 600; color: var(--ink); font-family: var(--mono); font-variant-numeric: tabular-nums; }
.db-backup-icon { width: 44px; height: 44px; background: var(--emerald-050); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; margin-bottom: 10px; }
.db-backup-time { font-size: 16px; font-weight: 700; color: var(--ink); font-family: var(--mono); }
.db-backup-date { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.db-backup-sub  { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.5; }
.db-btn-backup { display: block; padding: 8px 14px; border: 1px solid var(--emerald-600); border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--emerald-600); text-align: center; text-decoration: none; background: var(--emerald-050); cursor: pointer; width: 100%; box-sizing: border-box; transition: background .1s; }
.db-btn-backup:hover { background: var(--emerald-100); }
.db-footer-bar { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 0 8px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 4px; }
.db-qa-menu { position: absolute; top: 100%; left: 0; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px; min-width: 190px; box-shadow: var(--shadow-md); z-index: 200; margin-top: 4px; }
.db-qa-menu a { display: block; padding: 8px 12px; font-size: 13px; color: var(--ink); text-decoration: none; border-radius: 7px; }
.db-qa-menu a:hover { background: var(--card-2); color: var(--emerald-600); }

/* ================================================================
   INGREDIENTS PAGE  — Precision Kitchen Intelligence
   ================================================================ */
.ing-page-header { display: flex; align-items: center; gap: 10px; padding-top: 24px; flex-wrap: wrap; }
.ing-page-title { font-size: 26px; font-weight: 700; color: var(--ink); margin: 0; letter-spacing: -.4px; }
.ing-cnt-badge { padding: 3px 10px; background: var(--emerald-050); border: 1px solid var(--emerald-100); border-radius: 6px; font-size: 13px; font-weight: 700; color: var(--emerald-600); font-family: var(--mono); }
.ing-page-sub { font-size: 13px; color: var(--muted); margin: 4px 0 14px; }
.ing-page-actions { display: flex; gap: 8px; margin-left: auto; }
.ing-btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; font-size: 13px; font-weight: 500; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .1s; }
.ing-btn:hover { background: var(--card-2); }
.ing-btn.primary { background: var(--emerald-600); color: #fff; border-color: var(--emerald-600); }
.ing-btn.primary:hover { background: var(--emerald-700); }
.ing-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.ing-search-wrap { display: flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; min-width: 200px; flex: 1; }
.ing-search-wrap input { border: none; background: transparent; outline: none; font-size: 13px; color: var(--ink); width: 100%; }
.ing-filter-sel { padding: 6px 10px; font-size: 13px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; color: var(--ink); cursor: pointer; }
.ing-results-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; font-size: 13px; }
.ing-results-count { color: var(--muted); }
.ing-results-count strong { color: var(--ink); font-weight: 600; font-family: var(--mono); }
.ing-layout { display: flex; gap: 0; align-items: flex-start; }
.ing-table-zone { flex: 1; min-width: 0; }
.ing-drawer-zone { width: 360px; flex-shrink: 0; border-left: 1px solid var(--line); background: var(--card); max-height: calc(100vh - 160px); overflow-y: auto; }
.ing-tbl-wrap { overflow-x: auto; }
.ing-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.ing-tbl thead th { padding: 8px 12px; text-align: left; font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: .07em; text-transform: uppercase; border-bottom: 2px solid var(--line); background: var(--tbl-head-bg); white-space: nowrap; }
.ing-tbl tbody tr { border-bottom: 1px solid var(--line); cursor: pointer; transition: background .1s; }
.ing-tbl tbody tr:hover { background: var(--hover-tint); }
.ing-tbl tbody tr.selected { background: var(--emerald-050); }
[data-theme="dark"] .ing-tbl tbody tr.selected { background: rgba(0,96,57,.18); }
/* Category left-stripe via --cat-color on data-cat rows */
tr[data-cat] { --cat-color: var(--line); }
tr[data-cat="Meat"]       { --cat-color: #DC2626; }
tr[data-cat="Poultry"]    { --cat-color: #EA580C; }
tr[data-cat="Fish"]       { --cat-color: #2563EB; }
tr[data-cat="Dairy"]      { --cat-color: #0284C7; }
tr[data-cat="Grains"]     { --cat-color: #D97706; }
tr[data-cat="Flour"]      { --cat-color: #B45309; }
tr[data-cat="Legumes"]    { --cat-color: #7C3AED; }
tr[data-cat="Vegetables"] { --cat-color: #16A34A; }
tr[data-cat="Fruits"]     { --cat-color: #DB2777; }
tr[data-cat="Nuts"]       { --cat-color: #C2410C; }
tr[data-cat="Oils"]       { --cat-color: #059669; }
tr[data-cat="Sweeteners"] { --cat-color: #9333EA; }
tr[data-cat="Condiments"] { --cat-color: #C2410C; }
tr[data-cat="Spices"]     { --cat-color: #BE185D; }
tr[data-cat="Beverages"]  { --cat-color: #0891B2; }
.ing-tbl tbody tr td:first-child { box-shadow: inset 3px 0 0 var(--cat-color, var(--line)); }
.ing-tbl td { padding: 9px 12px; vertical-align: middle; }
.ing-tbl td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; font-size: 12.5px; }
.ing-item-cell { display: flex; align-items: center; gap: 10px; }
.ing-item-avatar { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; background: var(--emerald-050); }
.ing-item-name { font-weight: 500; color: var(--ink); font-size: 13px; }
.ing-item-sub  { font-size: 12px; color: var(--muted); }
.cat-pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.c-meat       { background: #FEE2E2; color: #991B1B; }
.c-poultry    { background: #FFEDD5; color: #9A3412; }
.c-fish       { background: #DBEAFE; color: #1E40AF; }
.c-dairy      { background: #E0F2FE; color: #075985; }
.c-grains     { background: #FEF3C7; color: #92400E; }
.c-flour      { background: #FFFBEB; color: #B45309; }
.c-legumes    { background: #EDE9FE; color: #5B21B6; }
.c-vegetables { background: #DCFCE7; color: #166534; }
.c-fruits     { background: #FCE7F3; color: #9D174D; }
.c-nuts       { background: #FED7AA; color: #9A3412; }
.c-oils       { background: #ECFDF5; color: #065F46; }
.c-sweeteners { background: #FDF4FF; color: #6B21A8; }
.c-condiments { background: #FFF7ED; color: #9A3412; }
.c-spices     { background: #FDF2F8; color: #831843; }
.c-beverages  { background: #ECFEFF; color: #155E75; }
.c-default    { background: var(--card-2); color: var(--ink-2); }
[data-theme="dark"] .c-default { background: rgba(255,255,255,.08); color: var(--ink); }
.alg-pill { display: inline-block; padding: 2px 7px; border-radius: 99px; font-size: 11px; font-weight: 600; background: #FEE2E2; color: #991B1B; margin-right: 3px; }
.ing-status-ok { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; color: var(--ok); }
.ing-status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex-shrink: 0; }
.ing-status-custom { color: var(--warn); }
.ing-pagination { display: flex; align-items: center; gap: 8px; padding: 12px 0; font-size: 13px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.ing-rpp { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.ing-rpp select { padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); font-size: 13px; color: var(--ink); }
.ing-pages { display: flex; align-items: center; gap: 3px; margin-left: auto; }
.ing-page-btn { min-width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 6px; border: 1px solid transparent; background: transparent; color: var(--ink); cursor: pointer; font-size: 13px; padding: 0 6px; }
.ing-page-btn:hover:not([disabled]) { background: var(--card-2); }
.ing-page-btn.active { background: var(--emerald-600); color: #fff; border-color: var(--emerald-600); }
.ing-page-btn[disabled] { opacity: .4; cursor: default; }
/* drawer */
.ing-drawer { padding: 16px; position: relative; }
.ing-drawer-close { position: absolute; top: 12px; right: 12px; width: 26px; height: 26px; border-radius: 50%; border: none; background: var(--card-2); color: var(--muted); cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; line-height: 1; }
.ing-drawer-close:hover { background: var(--line); }
.ing-drawer-hero { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; padding-right: 32px; }
.ing-drawer-avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--emerald-050); display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.ing-drawer-name { font-size: 15px; font-weight: 700; color: var(--ink); margin: 0 0 2px; }
.ing-drawer-sub  { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.ing-verified-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; background: var(--emerald-050); color: var(--emerald-600); font-size: 11px; font-weight: 600; border: 1px solid var(--emerald-100); }
.ing-custom-badge { background: var(--gold-050); color: var(--gold-700); border-color: rgba(200,164,77,.3); }
.ing-dtabs { display: flex; border-bottom: 1px solid var(--line); margin: 0 -16px 14px; padding: 0 16px; overflow-x: auto; }
.ing-dtab { padding: 8px 12px; font-size: 12.5px; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: color .1s; }
.ing-dtab.active { color: var(--emerald-600); border-bottom-color: var(--emerald-600); }
.ing-dtab:hover:not(.active) { color: var(--ink); }
.ing-dsec { margin-bottom: 16px; }
.ing-dsec-title { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 8px; }
.ing-drow { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.ing-drow:last-child { border-bottom: none; }
.ing-drow-key { color: var(--muted); }
.ing-drow-val { font-weight: 500; color: var(--ink); text-align: right; max-width: 55%; word-break: break-word; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.ing-nut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.ing-nut-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.ing-nut-key { color: var(--muted); }
.ing-nut-val { font-weight: 600; color: var(--ink); font-family: var(--mono); font-variant-numeric: tabular-nums; }
.ing-drawer-footer { display: flex; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }

/* ================================================================
   MOBILE & TABLET — supplemental responsive overrides
   ================================================================ */

/* ── Ingredients: stack table + drawer on ≤840px (tablets + phones) ── */
@media (max-width: 840px) {
  .ing-layout { flex-direction: column; }
  .ing-drawer-zone {
    width: 100%;
    border-left: none;
    border-top: 2px solid var(--line);
    max-height: none;
  }
  .ing-search-wrap { min-width: 0; }
  /* Touch targets */
  .ing-page-btn { min-width: 40px; height: 40px; }
  .ing-drawer-close { width: 40px; height: 40px; font-size: 20px; top: 10px; right: 10px; }
  .ing-rpp select { padding: 9px 6px; min-height: 40px; }
  .btn-sm { padding: 9px 14px; min-height: 40px; }
  .db-attn-btn { padding: 9px 14px; min-height: 40px; }
  .db-btn-backup { padding: 11px 14px; }
}

/* ── Dashboard header: wrap title + actions on phones ── */
@media (max-width: 680px) {
  .db-header { flex-wrap: wrap; gap: 10px; }
  .db-header-title { font-size: 20px; }
  .db-header-actions { width: 100%; margin-left: 0; padding-top: 0; justify-content: flex-start; }
  .db-btn-new,
  .db-btn-qa { font-size: 12.5px; padding: 7px 12px; }
}

/* ── Ingredients page header: shrink title on phones ── */
@media (max-width: 680px) {
  .ing-page-title { font-size: 20px; }
  .ing-page-sub { margin-bottom: 10px; }
}

/* ── KPI card numbers: slightly smaller on phones ── */
@media (max-width: 480px) {
  .db-kpi-val { font-size: 22px; }
  .db-cost-main { font-size: 26px; }
}

/* ── Pagebar breadcrumb on very small phones ── */
@media (max-width: 480px) {
  #pagebar { flex-wrap: wrap; gap: 4px; }
}

/* ── Tablet (769px–840px): sidebar still visible, widen mid grid threshold ── */
@media (min-width: 769px) and (max-width: 840px) {
  /* With desktop sidebar (236px) at this width, main area ~532px.
     db-mid 3-col collapses at 900px so it's already 1-col — fine.
     db-bottom 2-col holds at 532px — fine.
     Ensure ingredient table header labels wrap gracefully. */
  .ing-tbl thead th { padding: 8px 8px; }
  .ing-tbl td { padding: 8px 8px; }
}

/* ══ Smart Nutrition & Meal Optimizer (additive) ══════════════════════════════
   Built entirely from the existing token layer — no new colours are introduced,
   so the module follows the Clinical Slate theme in light and dark automatically. */

/* Dashboard entry card. Wider and taller than a tool card because it is the single
   doorway to a whole module, but the same materials as everything else on Home. */
.db-smart-card {
  display: flex; align-items: center; gap: 16px;
  background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--brand);
  border-radius: 12px; padding: 18px 20px; margin-bottom: 18px;
  text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow-sm); transition: border-color .12s, box-shadow .12s, transform .12s;
}
.db-smart-card:hover { border-color: var(--emerald-600); border-left-color: var(--brand); box-shadow: 0 3px 18px rgba(6,118,71,.13); color: var(--ink); }
.db-smart-card:active { transform: scale(.995); }
.db-smart-icon {
  width: 46px; height: 46px; border-radius: 10px; flex-shrink: 0;
  background: var(--emerald-050); border: 1px solid var(--emerald-100);
  display: flex; align-items: center; justify-content: center;
}
[data-theme="dark"] .db-smart-icon { background: rgba(23,178,106,.14); border-color: rgba(23,178,106,.25); }
.db-smart-icon svg { width: 23px; height: 23px; color: var(--emerald-600); }
[data-theme="dark"] .db-smart-icon svg { color: #3CCB7F; }
.db-smart-body { min-width: 0; }
.db-smart-title { font-size: 15px; font-weight: 700; color: var(--ink); margin: 0 0 3px; }
.db-smart-sub { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.db-smart-meta { font-size: 12px; font-weight: 600; color: var(--brand); margin-top: 6px; }

/* Field wrapper used by the optimizer's custom-macro grid. */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { margin: 0; }

@media (max-width: 560px) {
  .db-smart-card { flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px; }
}
