/* =====================================================================
   EnerFab Biomass Storage — design system v3, "weighbridge"
   ---------------------------------------------------------------------
   The app lives at a weighbridge and a wood yard, so it borrows from
   them: figures are set in a DIN-style face like the indicator on the
   scale, bag serials look like the tag tied to the sack, and moisture is
   read off a scale instead of a bare number.

   Colour comes from the EnerFab mark: the deep green of the ring, the
   pale green of its bars, and the red of the wordmark (used only for
   deductions and faults).

   Fonts are system fonts on purpose. The app must open with no signal
   and the Content-Security-Policy allows nothing from other hosts.

   Layout:  phone (<=760px) top bar + bottom tabs + sheets
            tablet (761-1100) icon rail
            desktop (>1100)  full sidebar
   ===================================================================== */

:root {
  --canopy: #0c2f17;        /* sidebar, hero */
  --canopy-2: #124021;
  --leaf: #1a7f0b;          /* the one action colour */
  --leaf-dark: #125c06;
  --leaf-bar: #8cc465;      /* the pale bars of the logo */
  --leaf-tint: #e6f2df;
  --leaf-glow: rgba(26, 127, 11, .18);
  --bg: #f5f6f3;
  --bg-deep: #eaede6;
  --surface: #ffffff;
  --surface-2: #f6f7f4;
  --ink: #132016;
  --ink-2: #445046;
  --ink-3: #6b776d;
  --line: rgba(19, 32, 22, .1);
  --line-strong: rgba(19, 32, 22, .18);
  --red: #b3140f;
  --red-tint: #fbe7e5;
  --amber: #8f5600;
  --amber-tint: #fbefd6;
  --blue: #1f5a73;
  --blue-tint: #dfecf2;

  --r-control: 12px;
  --r-card: 18px;
  --r-modal: 22px;
  --shadow-card: 0 1px 2px rgba(19, 32, 22, .04);
  --shadow-pop: 0 24px 60px -24px rgba(8, 24, 12, .55);

  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, "Noto Sans Sinhala", "Iskoola Pota", "Nirmala UI", sans-serif;
  --display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, "Noto Sans Sinhala", "Iskoola Pota", "Nirmala UI", sans-serif;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --tabbar-h: 66px;
  --rail-w: 84px;
  --side-w: 256px;
  color-scheme: light;
}

/* ------------------------------- base ------------------------------ */
* { box-sizing: border-box; }
html {
  height: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
  background: var(--bg);
}
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
html.has-modal, html.has-modal body { overflow: hidden; }

h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; font-family: var(--display); font-weight: 700; letter-spacing: -.015em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: .95rem; color: var(--ink-2); margin-top: 1.1em; }
p { margin: 0 0 .7em; max-width: 78ch; }
a { color: var(--leaf-dark); }
code, .mono { font-family: var(--display); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
code { background: var(--bg-deep); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--ink-3); }
.small { font-size: .84rem; }
.big { font-family: var(--display); font-size: 1.5rem; }
.t-ok { color: var(--leaf-dark); }
.t-warn { color: var(--amber); }
.t-danger { color: var(--red); }
.t-muted { color: var(--ink-3); }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.num, .stat-value, .data-table td.num, .mini td.num, .mini th.num { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid var(--leaf); outline-offset: 2px; border-radius: 4px; }
button, a, [role="button"], label.check { touch-action: manipulation; }
button, .badge, .avatar { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* ------------------------------ icons ------------------------------ */
.ico { width: 20px; height: 20px; flex: 0 0 auto; display: block; }
.i {
  display: inline-block; width: 1.1em; height: 1.1em; flex: 0 0 auto;
  background: currentColor; vertical-align: -.18em;
  -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat;
}
.i-plus { --m: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22black%22 stroke-width=%222%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cpath d=%22M12 5v14M5 12h14%22/%3E%3C/svg%3E"); }
.i-flame { --m: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22black%22 stroke-width=%222%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cpath d=%22M12 3c1 3.5 5 5.5 5 10a5 5 0 0 1-10 0c0-2.5 1.5-4 2.5-5.5C10 10 11 11 12 11c0-3-1-5.5 0-8Z%22/%3E%3C/svg%3E"); }
.i-chart { --m: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22black%22 stroke-width=%222%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cpath d=%22M4 20V10M10 20V4M16 20v-7M22 20H2%22/%3E%3C/svg%3E"); }
.i-printer { --m: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22black%22 stroke-width=%222%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cpath d=%22M6 9V3h12v6%22/%3E%3Crect x=%223%22 y=%229%22 width=%2218%22 height=%228%22 rx=%222%22/%3E%3Cpath d=%22M6 14h12v7H6z%22/%3E%3C/svg%3E"); }
.i-tag { --m: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22black%22 stroke-width=%222%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cpath d=%22M3 12V4a1 1 0 0 1 1-1h8l9 9-9 9-9-9Z%22/%3E%3Ccircle cx=%227.5%22 cy=%227.5%22 r=%221.5%22/%3E%3C/svg%3E"); }
.i-alert { --m: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22black%22 stroke-width=%222%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cpath d=%22M12 3 2 20h20L12 3Z%22/%3E%3Cpath d=%22M12 10v4M12 17.5v.01%22/%3E%3C/svg%3E"); }
.i-download { --m: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22black%22 stroke-width=%222%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cpath d=%22M12 3v12%22/%3E%3Cpath d=%22m7 10 5 5 5-5%22/%3E%3Cpath d=%22M5 21h14%22/%3E%3C/svg%3E"); }
.i-play { --m: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22black%22 stroke-width=%222%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Ccircle cx=%2212%22 cy=%2212%22 r=%229%22/%3E%3Cpath d=%22m10 8.5 5 3.5-5 3.5z%22/%3E%3C/svg%3E"); }
.i-eye { --m: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22black%22 stroke-width=%222%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cpath d=%22M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z%22/%3E%3Ccircle cx=%2212%22 cy=%2212%22 r=%223%22/%3E%3C/svg%3E"); }

/* ----------------------------- surfaces ---------------------------- */
.nm-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-card); }
.nm-inset { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-control); }
.pad { padding: 24px; }
.pad-sm { padding: 14px 16px; }
.view > section, .view > form > section { margin-bottom: 20px; }

/* ------------------------------ buttons ---------------------------- */
.nm-btn {
  appearance: none; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap;
  min-height: 48px; padding: 11px 20px; border-radius: var(--r-control);
  background: var(--bg-deep); color: var(--ink); border: 1px solid transparent;
  transition: transform 120ms var(--ease-out), background 140ms ease, border-color 140ms ease;
}
.nm-btn:active { transform: scale(.97); background: #dde2d8; }
.nm-btn.primary { background: var(--leaf); color: #fff; border-color: var(--leaf-dark); }
.nm-btn.primary:active { background: var(--leaf-dark); }
.nm-btn.danger { background: var(--red); color: #fff; border-color: #8c0f0b; }
.nm-btn.danger-ghost { color: var(--red); }
.nm-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.nm-btn.small, .nm-btn.tiny { min-height: 38px; padding: 6px 14px; font-size: .88rem; border-radius: 10px; }
.nm-btn.block { display: flex; width: 100%; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
  transition: transform 120ms var(--ease-out), background 140ms ease;
}
.icon-btn:active { transform: scale(.94); background: var(--surface-2); }
.link {
  background: none; border: 0; padding: 0; color: var(--leaf-dark); cursor: pointer;
  font: inherit; font-size: .86rem; font-weight: 600; display: inline-flex; align-items: center; gap: 5px;
  text-decoration: underline; text-decoration-color: rgba(18, 92, 6, .35); text-underline-offset: 3px;
}
.danger-text { color: var(--red) !important; }

/* ------------------------------ inputs ----------------------------- */
.nm-input {
  width: 100%; font: inherit; font-size: .92rem; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: var(--r-control);
  min-height: 48px; padding: 10px 14px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.nm-input::placeholder { color: #98a39a; }
.nm-input:focus { outline: none; border-color: var(--leaf); box-shadow: 0 0 0 4px var(--leaf-glow); }
.nm-input[readonly] { background: var(--surface-2); color: var(--ink-2); }
.nm-input[type="number"] { font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; }
textarea.nm-input { resize: vertical; min-height: 84px; }
select.nm-input { cursor: pointer; }
.tiny-input { min-height: 40px; padding: 6px 10px; max-width: 120px; }
select.tiny-input { max-width: 220px; }
.search { max-width: 320px; }
select.nm-input.attention { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(143, 86, 0, .2); }

.field { display: block; margin-bottom: 18px; }
.field > span { display: block; font-size: .9rem; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.field .hint { display: block; margin-top: 5px; color: var(--ink-3); font-size: .8rem; }
.check { display: flex; align-items: flex-start; gap: 9px; font-size: .88rem; color: var(--ink-2); margin: 4px 0 14px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--leaf); width: 17px; height: 17px; }

.form-errors { display: none; }
.form-errors.show {
  display: block; background: var(--red-tint); color: #6f0c09; border: 1px solid rgba(179, 20, 15, .25);
  border-left: 4px solid var(--red); border-radius: var(--r-control); padding: 10px 14px; margin-bottom: 14px; font-size: .88rem;
}
.form-errors ul { margin: 0; padding-left: 18px; }
.pw-wrap { position: relative; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; cursor: pointer; color: var(--ink-3); padding: 8px; display: grid; place-items: center;
}

/* ------------------------------- shell ----------------------------- */
.app-root, .app-shell { min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); height: 100vh; height: 100dvh;
  background: var(--surface); color: var(--ink); border-right: 1px solid var(--line);
  padding: 20px 14px 14px; display: flex; flex-direction: column; gap: 20px;
  overflow-y: auto; z-index: 30; scrollbar-gutter: stable;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 6px; }
.brand-logo { width: 40px; height: 40px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--display); font-size: 1.15rem; font-weight: 700; color: var(--ink); }
.brand-text span { font-size: .8rem; color: var(--ink-3); }

.nav { display: flex; flex-direction: column; gap: 16px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group-label { font-size: .78rem; color: var(--ink-3); padding: 0 12px 4px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px;
  background: transparent; border: 0; font: inherit; font-size: .95rem; font-weight: 500;
  color: var(--ink-2); text-align: left; padding: 10px 12px; min-height: 44px; border-radius: var(--r-control); cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}
.nav-item .nav-ico { width: 19px; height: 19px; opacity: .8; }
.nav-item:active { background: var(--bg-deep); }
.nav-item.active { background: var(--leaf-tint); color: var(--leaf-dark); font-weight: 650; }
.nav-item.active .nav-ico { opacity: 1; color: var(--leaf-dark); }
.nav-item.active::before { content: none; }
.nav-short { display: none; }
.sidebar-foot { margin-top: auto; padding: 8px 12px 0; }
.version { font-size: .78rem; color: var(--ink-3); }


.main { margin-left: var(--side-w); min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 20;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 28px 12px;
  background: rgba(242, 245, 239, .86);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.menu-btn { display: none; }
.back-btn[hidden] { display: none; }
.topbar-logo { display: none; width: 30px; height: 30px; object-fit: contain; }
.topbar-title { flex: 1 1 auto; min-width: 0; }
.topbar-title h1 { margin: 0; font-size: 1.5rem; }
.crumb { font-size: .8rem; color: var(--ink-3); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.sync-chip {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 13px; min-height: 36px; font: inherit; font-size: .8rem; font-weight: 600; color: var(--ink-2);
}
.sync-chip:active { background: var(--surface-2); }
.sync-chip { transition: background-color .25s ease, border-color .25s ease, color .25s ease; }
.sync-text { transition: opacity .2s ease; }
.sync-dot {
  position: relative; width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px;
  background: var(--leaf); box-shadow: 0 0 0 3px var(--leaf-glow);
  transition: background-color .35s ease, box-shadow .35s ease;
}
/* Live: a slow, soft ring breathing out from the dot */
.sync-chip[data-tone="live"] .sync-dot::after {
  content: ""; position: absolute; inset: -3px; border-radius: 50%;
  border: 2px solid var(--leaf); opacity: 0; animation: live-ring 2.8s ease-out infinite;
}
.sync-chip[data-tone="ok"] .sync-dot { background: var(--leaf); }
/* Getting online by itself: a gentle green pulse, never red */
.sync-chip[data-tone="connecting"] .sync-dot { background: var(--leaf-bar); box-shadow: 0 0 0 3px var(--leaf-glow); animation: pulse 1.6s ease-in-out infinite; }
.sync-chip[data-tone="offline"] .sync-dot { background: var(--amber); box-shadow: 0 0 0 3px rgba(143, 86, 0, .18); }
.sync-chip[data-tone="problem"] .sync-dot { background: var(--red); box-shadow: 0 0 0 3px rgba(179, 20, 15, .16); }
.sync-chip[data-tone="problem"] { border-color: rgba(179, 20, 15, .28); color: var(--red); }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes live-ring { 0% { transform: scale(.6); opacity: .55; } 70%, 100% { transform: scale(2.1); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .sync-chip[data-tone="live"] .sync-dot::after, .sync-chip[data-tone="connecting"] .sync-dot { animation: none; }
}

.user-menu { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 9px; cursor: pointer; font: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 16px 4px 4px; min-height: 46px;
}
.user-btn:active { background: var(--surface-2); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto;
  background: var(--leaf-tint); color: var(--leaf-dark); font-family: var(--display); font-weight: 700; font-size: 1rem;
}
.avatar.lg { width: 46px; height: 46px; font-size: 1.3rem; }
.user-meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.user-meta strong { font-size: .84rem; }
.user-meta small { font-size: .74rem; color: var(--ink-3); }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; z-index: 40;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-pop);
  padding: 6px; display: flex; flex-direction: column; gap: 2px;
  transform-origin: top right; animation: pop-in 160ms var(--ease-out);
}
.dropdown[hidden] { display: none; }
.dropdown-head { font-size: .78rem; color: var(--ink-3); padding: 8px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; word-break: break-all; }
.dropdown button {
  display: flex; align-items: center; gap: 10px; background: none; border: 0; font: inherit; font-size: .9rem;
  text-align: left; padding: 10px 12px; border-radius: 6px; cursor: pointer; color: var(--ink-2);
}
.dropdown button .ico { width: 18px; height: 18px; color: var(--ink-3); }
.dropdown button.danger-text .ico { color: var(--red); }
@keyframes pop-in { from { opacity: 0; transform: scale(.96) translateY(-4px); } }

.view { padding: 20px 28px 36px; flex: 1 1 auto; width: 100%; max-width: 1320px; }
.view:focus { outline: none; }
.view-enter { animation: view-in 220ms var(--ease-out); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }
.app-foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 0 28px; padding: 16px 0 26px; border-top: 1px solid var(--line); font-size: .78rem; color: var(--ink-3);
}

.banner {
  margin: 14px 28px 0; padding: 11px 15px; border-radius: var(--r-control); font-size: .88rem; line-height: 1.45;
  border: 1px solid var(--line); border-left-width: 4px;
}
.banner-warn { background: var(--amber-tint); color: #5c3700; border-color: rgba(143, 86, 0, .3); }
.banner-danger { background: var(--red-tint); color: #6f0c09; border-color: rgba(179, 20, 15, .3); }
.banner-info { background: var(--leaf-tint); color: #17420d; border-color: rgba(26, 127, 11, .3); }
.view .banner, .modal-body .banner { margin: 0 0 12px; }

.tabbar { display: none; }

/* ----------------------------- dashboard --------------------------- */
.hero {
  border: 0; background: none; box-shadow: none; padding: 0;
  display: grid; grid-template-columns: 1fr minmax(260px, 340px); gap: 20px; align-items: stretch;
}
.hero-main { display: flex; flex-direction: column; justify-content: center; padding: 6px 0; min-width: 0; }
.hero-date { margin: 0 0 4px; color: var(--ink-3); font-size: .95rem; }
.hero h2 { font-size: clamp(1.7rem, 3.2vw, 2.4rem); margin: 0 0 20px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero .nm-btn.primary { min-height: 54px; padding: 12px 24px; font-size: 1.02rem; }
.hero-yard {
  display: flex; flex-direction: column; gap: 6px; padding: 22px 24px;
  border-radius: var(--r-card); background: var(--canopy); color: #e9f1e7;
}
.hero-yard-label { font-size: .88rem; color: rgba(233, 241, 231, .75); }
.hero-yard-value { font-family: var(--display); font-weight: 600; font-size: clamp(2.6rem, 5vw, 3.6rem); line-height: 1; color: #fff; font-variant-numeric: tabular-nums; }
.hero-yard-value small { font-size: 1rem; font-weight: 400; margin-left: 8px; color: var(--leaf-bar); }
.hero-yard-sub { font-size: .82rem; color: rgba(233, 241, 231, .75); }

.alerts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 10px; }
.tasks > h3 { margin: 0 0 10px; }
.tasks-none { margin: 0; padding: 14px 16px; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r-card); }
.alert-chip {
  display: flex; align-items: center; gap: 11px; text-align: left; font: inherit; font-size: .9rem; color: var(--ink);
  min-height: 60px; padding: 14px 16px; cursor: pointer; box-shadow: none;
  transition: transform 120ms var(--ease-out), border-color 140ms ease;
}
.alert-chip:active { transform: scale(.985); }
.alert-chip .alert-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; background: var(--amber); }
.alert-chip.tone-danger .alert-dot { background: var(--red); }
.alert-chip.tone-info .alert-dot { background: var(--leaf); }
.alert-chip .chev { margin-left: auto; width: 18px; height: 18px; color: var(--ink-3); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.stat { padding: 20px 22px; display: flex; flex-direction: column; gap: 4px; box-shadow: none; }
.stat-label { font-size: .9rem; color: var(--ink-2); }
.stat-value {
  font-family: var(--display); font-size: clamp(1.4rem, 2vw, 1.9rem); font-weight: 700; line-height: 1.15; letter-spacing: -.02em;
  overflow-wrap: anywhere;
}
.stat-sub { font-size: .86rem; color: var(--ink-3); }

.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h3 { margin: 0; }

/* The meter is drawn as stacked bars, like the bars in the EnerFab mark. */
.meter { height: 10px; border-radius: 999px; overflow: hidden; background: var(--bg-deep); }
.meter span {
  display: block; height: 100%;
  background: var(--leaf); border-radius: 999px;
}
.meter.big { height: 14px; margin-bottom: 8px; }
.meter.on-dark { background: rgba(255, 255, 255, .12); }
.meter.on-dark span { background: var(--leaf-bar); }
.bay-row { margin-bottom: 13px; }
.bay-row-head { display: flex; justify-content: space-between; font-size: .88rem; margin-bottom: 5px; }
.bay-row-head b { font-family: var(--display); font-weight: 600; }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { display: flex; align-items: flex-start; gap: 11px; font-size: .88rem; padding: 9px 0; border-top: 1px solid var(--line); }
.timeline li:first-child { border-top: 0; padding-top: 0; }
.timeline li > div { flex: 1 1 auto; min-width: 0; }
.tl-dot { width: 8px; height: 8px; border-radius: 2px; margin-top: 7px; flex: 0 0 8px; background: var(--leaf); }
.tl-dot.tone-info { background: var(--blue); }
.tl-dot.tone-warn { background: var(--amber); }
.tl-dot.tone-danger { background: var(--red); }

.quick-trace { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.quick-trace p { margin: 0; }
.quick-trace h3 { margin-bottom: 2px; }

/* ------------------------------ tables ----------------------------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); margin-bottom: 12px; }
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th {
  text-align: left; font-size: .84rem; font-weight: 600; color: var(--ink-3); padding: 14px 16px; white-space: nowrap;
  background: transparent; border-bottom: 1px solid var(--line);
}
.data-table td { padding: 15px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.data-table th:first-child, .data-table td:first-child { padding-left: 20px; }
.data-table th:last-child, .data-table td:last-child { padding-right: 20px; }
.data-table tbody tr:first-child td { border-top: 0; }
.data-table .num, .mini .num { text-align: right; }
.data-table td.num { font-weight: 600; }
.data-table .actions { text-align: right; white-space: nowrap; }
.data-table td > b:first-child, .mono { font-family: var(--display); font-weight: 600; white-space: nowrap; }
.data-table td .small { white-space: nowrap; }
.mini { width: 100%; border-collapse: collapse; font-size: .88rem; }
.mini th, .mini td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.mini th { font-size: .8rem; font-weight: 600; color: var(--ink-2); }
.mini tr:last-child > * { border-bottom: 0; }
.mini tfoot th { border-top: 1px solid var(--line-strong); padding-top: 9px; }
.mini td.num, .mini th.num { font-family: var(--display); }

.empty, .empty-state { padding: 30px 24px; text-align: center; color: var(--ink-3); font-size: .9rem; }
.empty-state .empty-ico { width: 44px; height: 44px; margin: 0 auto 10px; border-radius: var(--r-control); display: grid; place-items: center; background: var(--leaf-tint); color: var(--leaf-dark); }
.empty-state h3 { color: var(--ink); }
.empty-state p { margin-left: auto; margin-right: auto; }

/* ------------------------------ badges ----------------------------- */
.badge {
  display: inline-block; font-size: .82rem; font-weight: 600; padding: 4px 11px; border-radius: 999px; white-space: nowrap;
  background: var(--bg-deep); color: var(--ink-2);
}
.badge-ok { background: var(--leaf-tint); color: #17520b; }
.badge-warn { background: var(--amber-tint); color: #6e4200; }
.badge-danger { background: var(--red-tint); color: #8a100c; }
.badge-info { background: var(--blue-tint); color: #184a5f; }
.badge-muted { background: var(--bg-deep); color: var(--ink-2); }
.pill { font-size: .74rem; padding: 2px 8px; border-radius: 999px; background: var(--leaf-tint); color: #17520b; font-weight: 600; margin-left: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { font-size: .8rem; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); }

/* ----------------------------- toolbar ----------------------------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar > p { margin: 0; flex: 1 1 320px; }
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.toolbar-left .nm-input { width: auto; min-width: 200px; }
.seg { display: inline-flex; gap: 2px; padding: 4px; border-radius: 999px; background: var(--bg-deep); flex-wrap: wrap; }
.seg.wide { display: flex; margin-bottom: 16px; }
.seg-btn {
  background: transparent; border: 0; font: inherit; font-size: .86rem; font-weight: 600; color: var(--ink-2);
  padding: 8px 18px; min-height: 40px; border-radius: 999px; cursor: pointer; transition: background 140ms ease, color 140ms ease;
}
.seg-btn.active { background: var(--surface); color: var(--leaf-dark); box-shadow: 0 1px 2px rgba(19, 32, 22, .16); }
.seg-btn .count { background: var(--amber); color: #fff; border-radius: 999px; padding: 1px 7px; font-size: .74rem; margin-left: 4px; }

/* ------------------------------ intake ----------------------------- */
.step-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.step-no {
  flex: 0 0 38px; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--leaf-tint); color: var(--leaf-dark); font-family: var(--display); font-weight: 700; font-size: 1.1rem;
}
.step-head h3 { margin: 0 0 2px; }
.step-head p { margin: 0; }
.calc-strip {
  display: flex; flex-wrap: wrap; gap: 10px 28px; margin-top: 4px; padding: 12px 16px;
  border-radius: var(--r-control); background: var(--surface-2); border: 1px solid var(--line);
}
.calc-strip > div { display: flex; flex-direction: column; gap: 1px; }
.calc-strip b { font-family: var(--display); font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.weigh-out { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: stretch; }
.weigh-out .calc-strip { margin: 0; align-content: center; }
.fill-check { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; }
.fill-head { font-size: .88rem; margin-bottom: 8px; }
.fill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.fill-cell { display: flex; flex-direction: column; gap: 3px; font-size: .78rem; color: var(--ink-3); }
.fill-cell .nm-input { text-align: center; padding: 8px 6px; }
.fill-result { padding: 18px; text-align: center; display: flex; flex-direction: column; gap: 4px; }
.fill-big { font-family: var(--display); font-size: 2.8rem; font-weight: 700; line-height: 1; letter-spacing: -.02em; }
.fill-big.ok { color: var(--leaf-dark); }
.fill-big.warn { color: var(--amber); }
.fill-big.danger { color: var(--red); }
.fill-big.muted { color: var(--ink-3); }
.fill-table { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 14px; font-size: .86rem; margin-top: 10px; text-align: left; }
.fill-table > div { display: flex; justify-content: space-between; gap: 8px; }
.fill-table b { font-family: var(--display); }
.fill-action { font-size: .86rem; margin: 10px auto 0; }
.fill-action.tone-ok { color: var(--leaf-dark); }
.fill-action.tone-warn { color: var(--amber); }
.fill-action.tone-muted { color: var(--ink-3); }
.intake-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.intake-spacer { flex: 1 1 auto; }
.intake-actions .nm-btn.primary { min-width: 160px; min-height: 52px; }
.intake section[hidden], .intake-actions [hidden] { display: none; }
.intake { max-width: 860px; }

/* Where am I in the form: four numbered steps, the current one filled. */
.stepper { list-style: none; margin: 0 0 18px; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stepper button {
  width: 100%; display: flex; align-items: center; gap: 10px; cursor: pointer; text-align: left;
  background: none; border: 0; border-top: 4px solid var(--bg-deep); padding: 10px 2px 0; font: inherit; font-size: .9rem; font-weight: 600; color: var(--ink-3);
}
.stepper b {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg-deep); color: var(--ink-2); font-size: .9rem;
}
.stepper .done button { border-top-color: var(--leaf-bar); color: var(--ink-2); }
.stepper .done b { background: var(--leaf-tint); color: var(--leaf-dark); }
.stepper .on button { border-top-color: var(--leaf); color: var(--ink); }
.stepper .on b { background: var(--leaf); color: #fff; }
@media (max-width: 760px) { .stepper span { display: none; } .stepper button { justify-content: center; } }
.tip { margin-top: 8px; box-shadow: none; background: var(--surface-2); }
.tip p { margin: 4px 0 0; }

/* -------------------------- moisture scale ------------------------- */
/* Bag weight read against the site line: 18 kg = 20 %, 36 kg = 60 %. */
.mscale { padding: 14px 16px 12px; border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface); }
.mscale-read { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.mscale-pct { font-family: var(--display); font-size: 2.2rem; font-weight: 700; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.mscale-cap { font-size: .86rem; color: var(--ink-2); }
.mscale-track { position: relative; display: flex; height: 12px; border-radius: 999px; }
.mz { display: block; height: 100%; }
.mz-ok { background: var(--leaf); border-radius: 999px 0 0 999px; }
.mz-warn { background: #d99a1c; }
.mz-high { background: var(--red); border-radius: 0 999px 999px 0; }
.mscale-pin {
  position: absolute; top: -6px; bottom: -6px; width: 4px; margin-left: -2px; border-radius: 2px;
  background: var(--ink); box-shadow: 0 0 0 2px var(--surface);
  transition: left 260ms var(--ease-out);
}
.mscale-ticks { position: relative; height: 34px; margin-top: 6px; }
.mscale-ticks span {
  position: absolute; top: 0; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center;
  font-size: .74rem; color: var(--ink-3); line-height: 1.25; white-space: nowrap;
}
.mscale-ticks span::before { content: ''; width: 1px; height: 5px; background: var(--line-strong); margin-bottom: 2px; }
.mscale-ticks b { font-family: var(--display); font-weight: 600; color: var(--ink-2); }
.mscale.compact { padding: 10px 14px 8px; background: var(--surface-2); }
.mscale.compact .mscale-pct { font-size: 1.5rem; }
.mscale.compact .mscale-read { margin-bottom: 10px; }

/* ------------------------------ dialogs ---------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(8, 24, 12, .5); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  opacity: 0; transition: opacity 200ms ease;
}
.modal-backdrop.open { opacity: 1; }
.modal {
  background: var(--surface); border-radius: var(--r-modal); box-shadow: var(--shadow-pop);
  width: 100%; max-width: 620px; max-height: 88vh; max-height: 88dvh; display: flex; flex-direction: column;
  transform: translateY(12px) scale(.98); transition: transform 260ms var(--ease-out);
}
.modal-backdrop.open .modal { transform: none; }
.modal-sm { max-width: 440px; }
.modal-lg { max-width: 920px; }
.modal-backdrop.is-sheet .modal { max-width: 560px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 24px 14px; }
.modal-head h2 { margin: 0; font-size: 1.3rem; }
.modal-head .icon-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--bg-deep); border-color: transparent; }
.modal-head .icon-btn .ico { width: 18px; height: 18px; }
.modal-body { padding: 6px 24px 22px; overflow-y: auto; overscroll-behavior: contain; }
.modal-body > h4:first-child { margin-top: 0; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 9px; flex-wrap: wrap;
  padding: 16px 24px calc(18px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--surface);
  border-radius: 0 0 var(--r-modal) var(--r-modal);
}
.modal-body .notice, .notice {
  background: var(--leaf-tint); border: 1px solid rgba(26, 127, 11, .2); border-radius: var(--r-control);
  padding: 12px 14px; margin-bottom: 14px; color: #17420d; font-size: .88rem;
}
.notice b { display: block; margin-bottom: 3px; }
.notice ul { margin: 4px 0 0; padding-left: 18px; }
.sheet-grabber { display: none; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.detail-grid h4:first-child { margin-top: 0; }
.detail-grid p { margin: 0 0 6px; font-size: .9rem; }
.detail-status { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.plain-list { list-style: none; margin: 0 0 8px; padding: 0; font-size: .88rem; display: flex; flex-direction: column; gap: 5px; }
.mini-timeline { list-style: none; margin: 0; padding: 0; font-size: .84rem; display: flex; flex-direction: column; gap: 8px; }
.mini-timeline b { display: block; text-transform: lowercase; }
.mini-timeline b::first-letter { text-transform: uppercase; }
.row-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* Phone "More" sheet */
.more-account { display: flex; align-items: center; gap: 12px; padding: 0 2px 14px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.more-account strong { display: block; font-size: 1rem; }
.more-account small { display: block; color: var(--ink-3); font-size: .8rem; word-break: break-all; }
.more-group h4 { margin: 14px 2px 8px; }
.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.more-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  min-height: 86px; padding: 12px 6px; border-radius: var(--r-card); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); font: inherit; font-size: .8rem; font-weight: 600; text-align: center; line-height: 1.2;
  transition: transform 120ms var(--ease-out), background 140ms ease;
}
.more-item:active { transform: scale(.95); background: var(--bg-deep); }
.more-ico { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--leaf-tint); color: var(--leaf-dark); }
.more-item.active { background: var(--leaf-tint); border-color: rgba(26, 127, 11, .3); color: var(--leaf-dark); }
.more-actions { display: grid; gap: 10px; margin-top: 18px; }

/* ------------------------------ switch ----------------------------- */
.switch {
  width: 44px; height: 24px; border-radius: 999px; position: relative; cursor: pointer; padding: 0;
  background: var(--bg-deep); border: 1px solid var(--line-strong);
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: left 160ms var(--ease-out);
}
.switch.on { background: var(--leaf); border-color: var(--leaf-dark); }
.switch.on::after { left: 22px; }

/* ------------------------------- bays ------------------------------ */
.bay-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.bay-grid.tight { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.bay-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.bay-head h3 { margin: 0; font-size: 1.3rem; }
.bay-head b { font-family: var(--display); font-weight: 600; font-size: 1.05rem; }
.bay-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 12px; }
.bay-mini-row { display: flex; justify-content: space-between; gap: 8px; font-size: .86rem; margin-top: 4px; }
.request-list { display: flex; flex-direction: column; gap: 9px; }
.request-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; border-radius: var(--r-control); background: var(--surface-2); border: 1px solid var(--line); font-size: .9rem;
}
.request-actions { display: flex; gap: 7px; flex-wrap: wrap; }

/* ------------------------------- trace ----------------------------- */
.trace-search { display: flex; gap: 9px; margin: 12px 0 16px; }
.quick-trace .trace-search { margin: 0; flex: 0 1 420px; }
.trace-search .nm-input { max-width: 340px; font-family: var(--display); font-size: 1.05rem; letter-spacing: .04em; text-transform: uppercase; }
.trace-search .nm-input::placeholder { text-transform: none; }
.trace-card { padding: 20px 22px; background: var(--surface); }
.trace-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
/* The serial is drawn as the tag tied to the sack: punched hole, clipped corner. */
.bag-tag {
  position: relative; display: inline-flex; flex-direction: column; padding: 10px 18px 10px 44px;
  background: var(--canopy); color: #fff; border-radius: 4px;
  clip-path: polygon(16px 0, 100% 0, 100% 100%, 16px 100%, 0 calc(100% - 16px), 0 16px);
}
.bag-tag::before {
  content: ''; position: absolute; left: 16px; top: 50%; width: 12px; height: 12px; margin-top: -6px; border-radius: 50%;
  background: var(--surface);
}
.bag-tag span { font-size: .78rem; color: var(--leaf-bar); }
.bag-tag h2 { margin: 0; color: #fff; font-size: 1.6rem; letter-spacing: .05em; }
.trace-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px 18px; margin: 18px 0; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.trace-grid > div { display: flex; flex-direction: column; font-size: .92rem; }
.trace-timeline { list-style: none; margin: 16px 0; padding: 0; border-left: 2px solid var(--leaf-bar); }
.trace-timeline li { position: relative; padding: 0 0 13px 18px; font-size: .9rem; }
.trace-timeline li::before {
  content: ''; position: absolute; left: -6px; top: 5px; width: 10px; height: 10px; border-radius: 2px;
  background: var(--leaf); box-shadow: 0 0 0 3px var(--surface);
}
.trace-timeline b { display: block; }
.trace-timeline span { color: var(--ink-2); }
.trace-quality { background: var(--amber-tint); border-radius: var(--r-control); padding: 12px 14px; margin-top: 8px; }
.trace-quality h4 { margin-top: 0; color: #6e4200; }

/* ------------------------------- toasts ---------------------------- */
.toast-stack { position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 9px; z-index: 200; max-width: min(400px, calc(100vw - 40px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; background: var(--canopy); color: #eef4ec;
  border-radius: var(--r-control); padding: 12px 15px; font-size: .9rem; box-shadow: var(--shadow-pop);
  border-left: 4px solid var(--leaf-bar); animation: toast-in 240ms var(--ease-out);
}
.toast-dot { display: none; }
.toast-warn { border-left-color: #e0a52b; }
.toast-danger { border-left-color: #f0614f; }
.toast-out { opacity: 0; transform: translateY(6px); transition: all .3s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* -------------------------------- auth ----------------------------- */
.auth-wrap {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 18px calc(24px + env(safe-area-inset-bottom, 0px));
}
.auth-wrap.split { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); padding: 0; gap: 0; align-items: stretch; justify-items: stretch; }
.auth-side {
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px; padding: 48px 56px; color: #e9f1e7;
  background: var(--canopy);
}
.auth-side .brand { padding: 0; }
.auth-side .brand-logo { background: #fff; border-radius: 12px; padding: 5px; width: 46px; height: 46px; }
.auth-side .brand-text strong { color: #fff; }
.auth-side .brand-text span { color: var(--leaf-bar); }
.auth-side h1 { font-size: clamp(2rem, 3.6vw, 3.1rem); color: #fff; line-height: 1.08; margin: 0 0 16px; max-width: 14ch; }
.auth-side p { color: rgba(233, 241, 231, .82); font-size: 1.02rem; max-width: 44ch; }
.auth-facts { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, auto); gap: 8px 32px; justify-content: start; }
.auth-facts li { display: flex; flex-direction: column; font-size: .84rem; color: rgba(233, 241, 231, .75); }
.auth-facts b { font-family: var(--display); font-size: 1.7rem; font-weight: 600; color: var(--leaf-bar); line-height: 1.1; }
.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 32px 22px; }
.auth-card { width: 100%; max-width: 430px; padding: 30px 30px 26px; border-radius: var(--r-modal); }
.auth-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; }
.auth-logo { width: 52px; height: 52px; object-fit: contain; }
.auth-brand h1, .auth-card h1 { margin: 0; font-size: 1.6rem; }
.auth-brand p { margin: 0; font-size: .86rem; }
.auth-form .nm-btn.primary { min-height: 52px; font-size: 1rem; margin-top: 4px; }
.auth-links { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.dot-sep { color: var(--ink-3); }
.auth-foot { font-size: .78rem; color: var(--ink-3); text-align: center; margin: 0; }
.auth-card.suspended, .auth-card.pending { text-align: center; }
.auth-card.suspended .auth-logo, .auth-card.pending .auth-logo { width: 64px; height: 64px; margin: 0 auto 12px; display: block; }
.auth-card.suspended h1 { color: var(--red); margin-bottom: 10px; }
.auth-card.pending h1 { color: var(--amber); margin-bottom: 10px; }
.auth-card.suspended p, .auth-card.pending p { margin-left: auto; margin-right: auto; }
.tone-danger-border { border-color: rgba(179, 20, 15, .5); box-shadow: 0 0 0 3px rgba(179, 20, 15, .12); }
.preview-row { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.preview-row p { margin: 8px 0 0; text-align: center; }
.nm-btn.google { background: #fff; color: #232323; min-height: 52px; gap: 10px; border-color: var(--line-strong); }
.google .g-icon { width: 18px; height: 18px; flex: 0 0 18px; }
.or-sep { display: flex; align-items: center; gap: 10px; margin: 16px 0 14px; color: var(--ink-3); font-size: .82rem; }
.or-sep::before, .or-sep::after { content: ''; flex: 1 1 auto; height: 1px; background: var(--line); }

/* ------------------------------ reports ---------------------------- */
.report-filters { display: flex; flex-direction: column; gap: 14px; }
.report-filter-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 0 14px; align-items: end; }
.report-filter-row .field { margin-bottom: 0; }
.report-actions { display: flex; gap: 8px; }
.report-period { margin: 0 0 12px; font-size: .95rem; }
.report-period b { font-family: var(--display); font-weight: 600; font-size: 1.1rem; }
.report-split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; margin-bottom: 10px; }
.report-chart svg { display: block; width: 100%; height: auto; }
.rc-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: .84rem; color: var(--ink-2); margin-bottom: 6px; }
.rc-legend span { display: inline-flex; align-items: center; gap: 6px; }
.rc-key { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.rc-key.rc-in, path.rc-in { background: #1a7f0b; fill: #1a7f0b; }
.rc-key.rc-out, path.rc-out { background: #2f6fb0; fill: #2f6fb0; }
.rc-grid { stroke: var(--line); stroke-width: 1; }
.rc-base { stroke: var(--line-strong); stroke-width: 1; }
.rc-axis { font: 10px var(--font); fill: var(--ink-3); }
.rc-hit { fill: transparent; }
.rc-col { outline: none; cursor: default; }
.rc-col:hover .rc-hit, .rc-col.on .rc-hit, .rc-col:focus-visible .rc-hit { fill: rgba(19, 32, 22, .06); }
.rc-tip { min-height: 1.4em; margin-top: 6px; font-size: .84rem; color: var(--ink-2); }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--leaf); margin-right: 6px; box-shadow: 0 0 0 3px var(--leaf-glow); }
@media (max-width: 1080px) {
  .report-filter-row { grid-template-columns: 1fr 1fr; gap: 12px 14px; }
  .report-actions { grid-column: 1 / -1; }
  .report-split { grid-template-columns: 1fr; }
}

/* ------------------------------- roles ----------------------------- */
.role-guide { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.role-card { padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-control); }
.role-card b { font-family: var(--display); font-weight: 600; font-size: 1.05rem; }
.role-card p { margin: 4px 0 6px; font-size: .88rem; }
.role-card small { display: block; color: var(--ink-3); font-size: .78rem; line-height: 1.4; }

.role-jobs { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.role-jobs fieldset { margin: 0; padding: 10px 14px 4px; border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface-2); }
.role-jobs legend { font-family: var(--display); font-weight: 600; padding: 0 6px; }
.role-jobs .check { margin: 4px 0 10px; }

/* --------------------------- biomass types ------------------------- */
.type-list { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.type-chip {
  display: inline-flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 10px 8px 12px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px;
  font: inherit; color: var(--ink); text-align: left;
}
.type-chip > .ico { color: var(--leaf-dark); }
.type-chip > span { display: flex; flex-direction: column; line-height: 1.25; }
.type-chip b { font-family: var(--display); font-weight: 600; font-size: 1.05rem; }
.type-chip small { color: var(--ink-3); font-size: .78rem; }
.type-x {
  width: 30px; height: 30px; margin-left: 4px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; background: transparent; color: var(--ink-3);
}
.type-x .ico { width: 16px; height: 16px; }
.type-x:hover { background: var(--red-tint); color: var(--red); }
.type-add { cursor: pointer; border-style: dashed; background: transparent; color: var(--leaf-dark); padding-right: 18px; }
.type-add:hover { background: var(--leaf-tint); border-color: var(--leaf); }
.field .hint .link { font-size: .82rem; }

/* ----------------------------- language ---------------------------- */
/* Sinhala sits beside the English as a quieter second voice: same line in
   buttons and headings, its own line under menu items and column heads. */
.si, [lang="si"] { font-family: "Noto Sans Sinhala", "Iskoola Pota", "Nirmala UI", sans-serif; letter-spacing: 0; }
.si { font-weight: 400; font-size: .86em; line-height: 1.5; opacity: .78; margin-left: .55em; white-space: normal; }
.nav-label .si, .nav-group-label .si, .stat-label .si, .hero-yard-label .si, th .si, .field > span .si, .more-item .si {
  display: block; margin-left: 0;
}
.nav-item { align-items: center; }

.nm-btn .si { opacity: .85; }
.badge .si { font-size: .9em; }
h1 .si, h2 .si, h3 .si { font-size: .68em; }

.lang-switch { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--bg-deep); border: 1px solid var(--line); }
.lang-switch .lang-opt {
  flex: 1 1 0; display: block; text-align: center; background: transparent; border: 0; cursor: pointer;
  font: inherit; font-size: .84rem; font-weight: 600; color: var(--ink-2); padding: 7px 10px; min-height: 34px; border-radius: 7px; white-space: nowrap;
}
html[data-lang="en"] .lang-opt[data-lang="en"],
html[data-lang="mix"] .lang-opt[data-lang="mix"] { background: var(--surface); color: var(--leaf-dark); box-shadow: 0 1px 2px rgba(19, 32, 22, .16); }
.dropdown .lang-switch { margin: 4px 4px 6px; }
.auth-main .lang-switch { width: 100%; max-width: 300px; }

/* ----------------------------- hover (mouse only) ------------------ */
@media (hover: hover) and (pointer: fine) {
  .nm-btn:hover { background: #dfe4da; }
  .nm-btn.primary:hover { background: var(--leaf-dark); border-color: var(--leaf-dark); }
  .nm-btn.danger:hover { background: #8c0f0b; }
  
  
  .icon-btn:hover, .sync-chip:hover, .user-btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
  .nav-item:hover:not(.active) { background: var(--bg-deep); color: var(--ink); }
  .dropdown button:hover { background: var(--leaf-tint); color: var(--ink); }
  .alert-chip:hover { border-color: var(--line-strong); }
  .data-table tbody tr:hover { background: var(--surface-2); }
  .more-item:hover { background: var(--bg-deep); }
  .link:hover { text-decoration-color: currentColor; }
  .seg-btn:hover:not(.active) { color: var(--ink); }
}

/* ----------------------------- responsive -------------------------- */
@media (max-width: 1080px) {
  .cols-2, .fill-check, .detail-grid { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .hero { grid-template-columns: 1fr; align-items: start; }
  .weigh-out { grid-template-columns: 1fr; }
  .auth-wrap.split { grid-template-columns: 1fr; }
  .auth-side { padding: 32px 28px; gap: 24px; }
  .auth-side h1 { max-width: none; }
}

/* tablet: icon rail */
@media (max-width: 1100px) and (min-width: 761px) {
  .sidebar { width: var(--rail-w); padding: 16px 8px; }
  .brand { justify-content: center; padding: 0; }
  .brand-text, .nav-group-label, .sidebar-foot { display: none; }
  .nav { gap: 8px; }
  .nav-group { padding-top: 8px; border-top: 1px solid var(--line); }
  .nav-group:first-child { border-top: 0; padding-top: 0; }
  .nav-item { flex-direction: column; gap: 4px; padding: 9px 2px 7px; font-size: .7rem; text-align: center; line-height: 1.1; }
  .nav-item .nav-label { display: none; }
  .nav-item .nav-short { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-item .nav-ico { width: 22px; height: 22px; }
  .nav-item.active::before { left: -8px; }
  .main { margin-left: var(--rail-w); }
  .topbar, .view { padding-left: 22px; padding-right: 22px; }
  .banner { margin-left: 22px; margin-right: 22px; }
  .app-foot { margin: 0 22px; }
  .user-meta { display: none; }
  .user-btn { padding: 4px; }
}

/* phone */
@media (max-width: 760px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }
  .topbar { padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px; min-height: calc(58px + env(safe-area-inset-top, 0px)); gap: 10px; }
  .topbar.is-root .topbar-logo { display: block; }
  .topbar-title h1 { font-size: 1.3rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .crumb, .user-meta, .sync-chip .sync-text { display: none; }
  .back-btn { width: 38px; height: 38px; border-radius: 50%; margin-left: -2px; }
  .sync-chip { padding: 0; width: 38px; height: 38px; min-height: 38px; justify-content: center; }
  .user-btn { padding: 0; border: 0; background: transparent; min-height: 0; }
  .avatar { width: 40px; height: 40px; }
  .banner { margin: 10px 14px 0; font-size: .86rem; }
  .view { padding: 14px 14px 24px; }
  .app-foot { display: none; }
  .pad { padding: 16px; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }

  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); padding: 6px 6px env(safe-area-inset-bottom, 0px);
    background: rgba(255, 255, 255, .94); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    border-top: 1px solid var(--line-strong);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; position: relative;
    background: none; border: 0; font: inherit; font-size: .76rem; font-weight: 600; color: var(--ink-3); cursor: pointer; padding: 0;
  }
  .tab .ico { width: 25px; height: 25px; transition: transform 160ms var(--ease-out); }
  .tab::before {
    content: ''; position: absolute; top: -6px; width: 32px; height: 4px; border-radius: 0 0 3px 3px;
    background: var(--leaf); opacity: 0; transition: opacity 160ms ease;
  }
  .tab.active { color: var(--leaf-dark); }
  .tab.active::before { opacity: 1; }
  .tab:active .ico { transform: scale(.88); }

  /* dialogs become bottom sheets */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal, .modal-sm, .modal-lg, .modal-backdrop.is-sheet .modal {
    max-width: none; border-radius: 18px 18px 0 0;
    max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px));
    transform: translateY(100%); transition: transform 320ms var(--ease-out);
  }
  .modal-backdrop.open .modal { transform: none; }
  .sheet-grabber { display: block; width: 40px; height: 5px; border-radius: 99px; background: var(--line-strong); margin: 8px auto 0; }
  .modal-head { padding: 10px 18px 10px; }
  .modal-body { padding: 14px 18px; }
  .modal-foot { padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px)); border-radius: 0; }
  .modal-foot .nm-btn { flex: 1 1 auto; min-height: 52px; }
  .toolbar-right .nm-btn.primary, .intake-actions .nm-btn.primary { min-height: 54px; font-size: 1rem; }

  /* tables become stacked cards */
  .table-wrap { overflow: visible; background: transparent; border: 0; }
  .data-table, .data-table tbody { display: block; }
  .data-table thead { display: none; }
  .data-table tr { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 4px 14px; margin-bottom: 10px; }
  .data-table td {
    display: flex; justify-content: space-between; align-items: center; gap: 14px;
    border: 0; border-top: 1px solid var(--line); padding: 9px 0; text-align: right; min-height: 40px;
  }
  .data-table tr td:first-child { border-top: 0; }
  .data-table td::before { content: attr(data-label); flex: 0 0 auto; max-width: 45%; text-align: left; font-family: var(--font); font-size: .8rem; font-weight: 600; color: var(--ink-3); }
  .data-table td[data-label=""]::before { display: none; }
  .data-table td[data-label=""], .data-table td.actions { justify-content: flex-end; flex-wrap: wrap; }
  .data-table td > * { min-width: 0; }

  .hero { padding: 0; }
  .hero-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .hero-actions .nm-btn.primary { grid-column: 1 / -1; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 1.4rem; }
  .toolbar-left, .toolbar-right { width: 100%; }
  .toolbar-left .nm-input, .toolbar-right .nm-btn { flex: 1 1 auto; }
  .search { max-width: none; }
  .seg { display: flex; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; max-width: 100%; }
  .seg::-webkit-scrollbar { display: none; }
  .seg-btn { white-space: nowrap; flex: 0 0 auto; }
  .trace-search { flex-wrap: wrap; }
  .trace-search .nm-input { max-width: none; flex: 1 1 200px; }
  .quick-trace .trace-search { flex: 1 1 100%; }
  .intake-actions .nm-btn { flex: 1 1 0; }
  .toast-stack { left: 14px; right: 14px; max-width: none; bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom, 0px)); }
  .auth-card { padding: 24px 20px 20px; }
  .auth-facts { gap: 8px 20px; }
  .auth-facts b { font-size: 1.35rem; }
  .mscale-ticks span { font-size: .68rem; }
}

/* inputs never trigger iOS zoom */
@media (pointer: coarse) {
  input, textarea, select, .nm-input { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ------------------------------ printing ---------------------------
   UI.print() puts the document to print in #print-root. On paper, that is
   the only thing shown; on screen it is never shown. This works the same
   on a PC, an Android tablet and an iPhone. */
#print-root { display: none; }
@page { margin: 10mm; }
@media print {
  html, body { background: #fff !important; height: auto !important; overflow: visible !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root {
    display: block; color: #111; background: #fff;
    font: 10pt/1.4 "Segoe UI", Roboto, Arial, "Noto Sans Sinhala", "Iskoola Pota", sans-serif;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  #print-root * { box-shadow: none !important; }
  #print-root h1 { font: 600 15pt/1.2 var(--display); margin: 0 0 2mm; }
  #print-root h2, #print-root h3 { font: 600 11pt/1.2 var(--display); margin: 4mm 0 1.5mm; break-after: avoid; }
  #print-root h4 { font: 600 9.5pt/1.2 var(--display); margin: 3mm 0 1mm; color: #111; break-after: avoid; }
  #print-root p { margin: 0 0 1.5mm; max-width: none; }
  #print-root hr { border: 0; border-top: 1px solid #111; margin: 2mm 0 3mm; }
  #print-root .co { font-size: 8pt; color: #187800; font-weight: 700; }
  #print-root .meta, #print-root .muted, #print-root .small { font-size: 8.5pt; color: #333; }
  #print-root .row { display: flex; justify-content: space-between; gap: 6mm; }
  #print-root table { width: 100%; border-collapse: collapse; font-size: 9pt; margin-bottom: 2mm; }
  #print-root th, #print-root td { border: 1px solid #999; padding: 1.3mm 2mm; text-align: left; vertical-align: top; }
  #print-root th { background: #f0f0f0; font-weight: 600; }
  #print-root .num { text-align: right; }
  #print-root tr { break-inside: avoid; }
  #print-root .sign { margin-top: 12mm; border-top: 1px solid #111; width: 55mm; font-size: 8pt; padding-top: 1mm; }
  #print-root .mono { font-family: var(--display); }

  /* bag labels: 70 mm stickers, as many as fit, never split across pages */
  #print-root .sheet { display: flex; flex-wrap: wrap; gap: 5mm; }
  #print-root .sticker { width: 70mm; border: 1.2px solid #111; border-radius: 3mm; padding: 3mm; break-inside: avoid; }
  #print-root .sticker .serial { font: 700 13pt/1.2 var(--display); letter-spacing: .5px; }
  #print-root .sticker .sub { font-size: 7.5pt; color: #333; margin: 1mm 0; }
  #print-root .sticker .write { border: 1px dashed #555; border-radius: 2mm; padding: 2mm; margin-top: 2mm; font-size: 7pt; min-height: 14mm; }
  #print-root .sticker svg { display: block; margin: 1mm 0; max-width: 100%; }

  /* a screen section printed as a report */
  #print-root section, #print-root .nm-card { border: 0; padding: 0; margin: 0 0 4mm; background: none; }
  #print-root .cols-2, #print-root .report-split { display: block; }
  #print-root .stats { display: flex; flex-wrap: wrap; gap: 3mm; margin-bottom: 4mm; }
  #print-root .stat { border: 1px solid #999; padding: 2mm 3mm; display: flex; flex-direction: column; min-width: 40mm; }
  #print-root .stat-value { font: 600 13pt/1.2 var(--display); color: #111 !important; }
  #print-root .stat-label, #print-root .stat-sub { font-size: 8pt; color: #333; }
  #print-root .table-wrap { border: 0; overflow: visible; }
  #print-root .data-table, #print-root .data-table tbody { display: table; width: 100%; }
  #print-root .data-table thead { display: table-header-group; }
  #print-root .data-table tr { display: table-row; }
  #print-root .data-table td, #print-root .data-table th { display: table-cell; }
  #print-root .data-table td::before { display: none; }
  #print-root .badge { background: none; padding: 0; color: #111; font-weight: 600; }
  #print-root .t-danger, #print-root .t-warn, #print-root .t-ok { color: #111; }
  #print-root .card-head { display: block; margin: 0; }
  #print-root .report-chart { break-inside: avoid; margin-bottom: 3mm; }
  #print-root .report-chart svg { width: 100%; max-height: 60mm; }
  #print-root .rc-tip, #print-root .link { display: none; }
  #print-root .si { font-size: .85em; opacity: 1; color: #333; }
}
.noscript { padding: 40px; text-align: center; font-family: var(--font); }

/* ------------------------- supplier search ------------------------- */
.supplier-pick { display: flex; gap: 10px; margin-bottom: 14px; }
.supplier-pick .nm-input { flex: 1 1 auto; }
.fill-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.fill-progress { margin-left: auto; font-weight: 600; font-size: .86rem; }
.bank-box td:first-child { color: var(--ink-3); width: 42%; }
.bank-box td { padding: 5px 8px; }

/* -------------------------- choosing bays -------------------------- */
.alloc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; max-height: 300px; overflow-y: auto; padding: 2px; }
.alloc-cell { display: flex; flex-direction: column; gap: 3px; padding: 8px; border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface-2); }
.alloc-cell.on { border-color: var(--leaf); background: var(--leaf-tint); }
.alloc-cell.over { border-color: var(--amber); background: var(--amber-tint); }
.alloc-code { font-family: var(--display); font-weight: 600; }
.alloc-cell .nm-input { min-height: 36px; padding: 4px 8px; text-align: center; }
.alloc-room { font-size: .72rem; color: var(--ink-3); line-height: 1.2; }
.alloc-total { margin: 10px 0 0; }
.alloc-total b { font-family: var(--display); font-size: 1.15rem; }

/* ------------------------------ bay tiles --------------------------
   One tile per bay. The left edge and the moisture figure carry the
   state, and every tile also says it in words (never colour alone).
   A dry bay is the one to act on, so it is the loud one. */
.bay-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 10px; }
.bay-tile {
  display: flex; flex-direction: column; gap: 6px; text-align: left; font: inherit; color: var(--ink);
  padding: 12px 12px 8px; border-radius: var(--r-card); background: var(--surface);
  border: 1px solid var(--line); border-left: 5px solid var(--leaf);
  transition: transform 120ms var(--ease-out), border-color 140ms ease;
}
.bay-tile:has(.bt-main:active) { transform: scale(.98); }
.bt-main { display: flex; flex-direction: column; gap: 6px; text-align: left; cursor: pointer; font: inherit; color: inherit; background: none; border: 0; padding: 0; width: 100%; }
.bt-spark { display: block; min-height: 30px; }
.spark { display: block; width: 100%; height: 30px; }
.spark path { stroke: var(--leaf); }
.spark circle { fill: var(--leaf); }
.spark.is-up path { stroke: var(--blue); } .spark.is-up circle { fill: var(--blue); }
.spark-empty { font-size: .72rem; color: var(--ink-3); line-height: 30px; }
.bt-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; border-top: 1px solid var(--line); padding-top: 6px; }
.bt-check { font-size: .72rem; color: var(--ink-3); }
.bt-check.is-done { color: var(--leaf); font-weight: 600; }
.bt-more { font: inherit; font-size: .76rem; font-weight: 600; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; cursor: pointer; min-height: 28px; white-space: nowrap; flex: none; }
.bt-more:hover { border-color: var(--ink-3); }
.bay-chart { width: 100%; height: auto; margin: 4px 0 14px; display: block; }
.bay-chart .grid { stroke: var(--line); stroke-width: 1; }
.bay-chart .ax { fill: var(--ink-3); font-size: 11px; }
.bay-chart .ax.dry { fill: var(--red); }
.bay-chart .dry-line { stroke: var(--red); stroke-width: 1.2; stroke-dasharray: 5 4; }
.bay-chart .ln { fill: none; stroke: var(--leaf); stroke-width: 2.2; stroke-linejoin: round; }
.bay-chart .pt { fill: var(--surface); stroke: var(--leaf); stroke-width: 2; }
.bay-chart .pt-in { stroke: var(--ink-2); } .bay-chart .pt-out { stroke: var(--amber); } .bay-chart .pt-check { fill: var(--leaf); }
.day-check .nm-input { max-width: 120px; }
.bank-edit .bank-show { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.bank-edit .bank-show[hidden], .bank-edit .bank-form[hidden] { display: none; }
.bank-edit .bank-form { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface-2); }
.bank-edit .bank-form .row-actions { margin-top: 4px; }
.link-btn { font: inherit; font-weight: 600; color: var(--ink); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; text-align: left; }
.staff-filters .field { margin-bottom: 8px; }
#staff-results > section { margin-top: 14px; }
.bt-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.bt-head b { font-family: var(--display); font-weight: 600; font-size: 1.15rem; }
.bt-moist { font-family: var(--display); font-weight: 600; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.bt-count { font-size: .82rem; color: var(--ink-2); }
.bt-state { font-size: .78rem; color: var(--ink-3); }
.bay-tile.is-empty { border-left-color: var(--line-strong); background: var(--surface-2); color: var(--ink-3); }
.bay-tile.is-empty .meter span { background: none; }
.bay-tile.is-damp { border-left-color: #d99a1c; }
.bay-tile.is-damp .bt-moist { color: var(--amber); }
.bay-tile.is-wet { border-left-color: #2b6f93; }
.bay-tile.is-wet .bt-moist { color: var(--blue); }
.bay-tile.is-dry { border-color: var(--red); border-left-color: var(--red); background: var(--red-tint); }
.bay-tile.is-dry .bt-moist, .bay-tile.is-dry .bt-state { color: var(--red); font-weight: 600; }
.bay-tile.is-dry .meter span { background: repeating-linear-gradient(90deg, var(--red) 0 6px, transparent 6px 8px); }
.bay-tile.is-over .bt-count { color: var(--amber); font-weight: 600; }
.bay-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-bottom: 12px; max-width: none; }
.bay-legend .key { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-left: 10px; }
.bay-legend .key:first-child { margin-left: 0; }
.key-dry { background: var(--red); } .key-damp { background: #d99a1c; } .key-wet { background: #2b6f93; } .key-empty { background: var(--line-strong); }
button.bay-mini { font: inherit; color: inherit; text-align: left; cursor: pointer; }
.bay-mini.is-dry { border-color: var(--red); background: var(--red-tint); }
.pill-dry { background: var(--red-tint); color: var(--red); }
.bay-now { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface-2); }
.bay-now.is-dry { border-color: var(--red); background: var(--red-tint); }
.bay-now > div { display: flex; flex-direction: column; gap: 1px; }
.bay-now b { font-family: var(--display); font-size: 1.5rem; font-weight: 600; line-height: 1.15; }
.bay-weigh { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.bay-weigh .field { margin-bottom: 0; flex: 0 1 240px; }
@media (hover: hover) and (pointer: fine) { .bay-tile:has(.bt-main:hover) { border-color: var(--ink-3); } .bay-tile.is-dry:hover { border-color: var(--red); } }
@media (max-width: 760px) { .bay-tiles { grid-template-columns: 1fr 1fr; } .supplier-pick { flex-direction: column; } .alloc-grid { grid-template-columns: repeat(3, 1fr); } }

/* -------------------------- print additions ------------------------ */
@media print {
  #print-root .print-head { align-items: center; gap: 5mm; }
  #print-root .print-logo { width: 16mm; height: 16mm; object-fit: contain; flex: 0 0 16mm; }
  #print-root .print-title { flex: 1 1 auto; }
  #print-root .sticker .co { display: flex; align-items: center; gap: 1.5mm; }
  #print-root .sticker-logo { width: 5mm; height: 5mm; object-fit: contain; }
  #print-root .blank { display: inline-block; min-width: 45mm; border-bottom: 1px solid #555; height: 5mm; }
  #print-root .fill-sheet { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3mm; margin-top: 3mm; }
  #print-root .fill-box { border: 1.2px solid #111; border-radius: 2mm; height: 19mm; padding: 1.5mm 2mm; position: relative; break-inside: avoid; }
  #print-root .fill-box span { font-size: 8pt; color: #333; }
  #print-root .fill-box i { position: absolute; right: 2mm; bottom: 1.5mm; font-style: normal; font-size: 11pt; color: #555; }
  #print-root .bank-box td { border: 0; padding: .5mm 2mm .5mm 0; }
}

/* ---------------------------- scrollbars --------------------------- */
:root { --sb-thumb: rgba(19, 32, 22, .2); --sb-thumb-hover: rgba(19, 32, 22, .38); }
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: var(--sb-thumb) transparent; }
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--sb-thumb); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; min-height: 40px; }
::-webkit-scrollbar-thumb:hover { background-color: var(--sb-thumb-hover); }
::-webkit-scrollbar-button { display: none; height: 0; width: 0; }
.sidebar::-webkit-scrollbar-thumb { background-color: transparent; }
.sidebar:hover::-webkit-scrollbar-thumb { background-color: var(--sb-thumb); }

/* ============================ training ============================== */
/* The spotlight: four shades around a hole, a glowing ring on the hole,
   and a card. It sits above dialogs (100) and below toasts (200). */
.tour { position: fixed; inset: 0; z-index: 150; pointer-events: none; }
.tour-shade { position: fixed; background: rgba(8, 22, 12, .58); pointer-events: auto; transition: all .28s var(--ease-out); }
.tour-hole { position: fixed; pointer-events: auto; border-radius: 14px; }
.tour.lets-tap .tour-hole { pointer-events: none; }
.tour-ring {
  position: fixed; pointer-events: none; border-radius: 14px;
  box-shadow: 0 0 0 3px var(--leaf-bar), 0 0 0 7px rgba(140, 196, 101, .28), 0 10px 40px rgba(0, 0, 0, .25);
  transition: all .28s var(--ease-out); animation: tour-glow 2.2s ease-in-out infinite;
}
.tour.lets-tap .tour-ring { box-shadow: 0 0 0 3px #f4c430, 0 0 0 8px rgba(244, 196, 48, .3), 0 10px 40px rgba(0, 0, 0, .25); }
@keyframes tour-glow { 50% { box-shadow: 0 0 0 3px var(--leaf-bar), 0 0 0 12px rgba(140, 196, 101, .12), 0 10px 40px rgba(0, 0, 0, .25); } }
.tour.is-moving .tour-card { opacity: .0; }
.tour-card {
  position: fixed; pointer-events: auto; width: min(400px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); border-radius: 20px; padding: 16px 18px 14px;
  box-shadow: var(--shadow-pop), 0 0 0 1px var(--line); outline: none;
  transition: left .28s var(--ease-out), top .28s var(--ease-out), opacity .2s ease;
}
.tour.no-target .tour-card { width: min(460px, calc(100vw - 32px)); }
.tour-card.pop { animation: tour-pop .32s var(--ease-out); }
@keyframes tour-pop { from { transform: translateY(8px) scale(.98); opacity: .4; } }
.tour-card.as-sheet {
  left: 0 !important; right: 0; bottom: 0; top: auto !important; width: 100%; max-height: 62vh; overflow-y: auto;
  border-radius: 22px 22px 0 0; padding: 14px 18px calc(14px + env(safe-area-inset-bottom, 0px));
}
.tour-card.as-sheet.at-top { top: 0 !important; bottom: auto; border-radius: 0 0 22px 22px; padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
.tour-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tour-mission { display: inline-flex; align-items: center; gap: 7px; font-size: .74rem; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: var(--leaf); min-width: 0; }
.tour-mission span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tour-mission .ico { width: 16px; height: 16px; flex: 0 0 16px; }
.tour-x { border: 0; background: var(--surface-2); color: var(--ink-2); width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; flex: 0 0 34px; }
.tour-x .ico { width: 16px; height: 16px; }
.tour-bar { height: 5px; border-radius: 99px; background: var(--bg-deep); margin: 10px 0 12px; overflow: hidden; }
.tour-bar span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--leaf), var(--leaf-bar)); transition: width .35s var(--ease-out); }
.tour-card h3 { margin: 0 0 6px; font: 650 1.12rem/1.25 var(--display); }
.tour-text { font-size: .95rem; line-height: 1.5; color: var(--ink-2); }
.tour-text b { color: var(--ink); }
.tour-note { margin: 8px 0 0; font-size: .8rem; color: var(--ink-3); }
.tour-hint { display: flex; align-items: center; gap: 6px; margin: 10px 0 0; font-size: .85rem; font-weight: 600; color: #8a6a00; }
.tour-hint .ico { width: 16px; height: 16px; animation: tour-nudge 1.2s ease-in-out infinite; }
@keyframes tour-nudge { 50% { transform: translateX(4px); } }
.tour-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.tour-count { font-size: .8rem; color: var(--ink-3); }
.tour-count b { color: var(--leaf); }
.tour-btns { display: flex; gap: 8px; margin-left: auto; }
.tour-btns .nm-btn { min-height: 44px; }

/* mission complete */
.win { text-align: center; padding: 6px 0 2px; position: relative; }
.win-badge {
  width: 84px; height: 84px; margin: 0 auto 10px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  background: radial-gradient(circle at 30% 25%, var(--leaf-bar), var(--leaf) 60%, var(--leaf-dark));
  box-shadow: 0 0 0 6px var(--leaf-tint), 0 14px 30px -10px rgba(26, 127, 11, .6); animation: win-in .6s var(--ease-out);
}
.win-badge .ico { width: 40px; height: 40px; }
@keyframes win-in { from { transform: scale(.4) rotate(-20deg); opacity: 0; } 70% { transform: scale(1.08); } }
.win-kicker { margin: 0; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--leaf); }
.win h3 { margin: 2px 0 2px; font: 700 1.5rem/1.2 var(--display); }
.win-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 4px; }
.win-stats div { background: var(--surface-2); border-radius: 14px; padding: 10px 6px; display: flex; flex-direction: column; gap: 2px; }
.win-stats b { font: 700 1.05rem/1.2 var(--display); }
.win-stats span { font-size: .72rem; color: var(--ink-3); }
.win-cert { display: flex; gap: 8px; align-items: flex-start; text-align: left; background: var(--leaf-tint); border-radius: 14px; padding: 10px 12px; margin: 12px 0 0; font-size: .88rem; }
.win-cert .ico { width: 18px; height: 18px; color: var(--leaf); flex: 0 0 18px; margin-top: 1px; }
.win-confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.win-confetti i { position: absolute; top: -12px; left: var(--x); width: 8px; height: 12px; border-radius: 2px; background: var(--c); transform: rotate(var(--r)); animation: confetti 1.8s var(--d) cubic-bezier(.2, .7, .4, 1) forwards; opacity: 0; }
@keyframes confetti { 0% { opacity: 1; transform: translateY(0) rotate(var(--r)); } 100% { opacity: 0; transform: translateY(420px) rotate(calc(var(--r) + 540deg)); } }

/* the Training screen */
.train-hero { display: flex; gap: 24px; align-items: center; padding: 22px; margin-bottom: 22px; }
.train-ring { position: relative; width: 120px; height: 120px; flex: 0 0 120px; }
.train-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.train-ring circle { fill: none; stroke-width: 10; }
.train-ring .tr-bg { stroke: var(--bg-deep); }
.train-ring .tr-fg { stroke: var(--leaf); stroke-linecap: round; transition: stroke-dasharray .8s var(--ease-out); }
.train-ring > div { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.train-ring b { font: 700 1.5rem/1 var(--display); }
.train-ring span { font-size: .72rem; color: var(--ink-3); }
.train-hero-main { min-width: 0; }
.train-kicker { margin: 0; font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--leaf); }
.train-hero h2 { margin: 2px 0 4px; font: 700 1.6rem/1.15 var(--display); }
.train-actions { margin: 14px 0 8px; display: flex; flex-wrap: wrap; gap: 10px; }
.train-actions .nm-btn .ico { width: 18px; height: 18px; }
.train-h { margin: 6px 0 12px; }
.train-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 26px; }
.train-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 16px; display: flex; flex-direction: column; gap: 6px; transition: transform .2s var(--ease-out), box-shadow .2s ease; }
.train-card:hover { transform: translateY(-2px); box-shadow: 0 12px 28px -18px rgba(8, 24, 12, .5); }
.train-card h4 { margin: 4px 0 0; font: 650 1.02rem/1.25 var(--display); }
.train-card p { margin: 0; }
.train-card .nm-btn { margin-top: auto; }
.train-card.is-next { border-color: var(--leaf); box-shadow: 0 0 0 3px var(--leaf-glow); }
.train-card.is-done { background: linear-gradient(180deg, var(--leaf-tint), var(--surface) 55%); }
.train-card-top { display: flex; justify-content: space-between; align-items: center; }
.train-no { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem; background: var(--bg-deep); color: var(--ink-2); }
.train-card.is-done .train-no { background: var(--leaf); color: #fff; }
.train-card.is-next .train-no { background: var(--leaf); color: #fff; }
.train-no .ico { width: 16px; height: 16px; }
.train-ico { color: var(--leaf); }
.train-ico .ico { width: 22px; height: 22px; }
.train-meta { font-size: .78rem; color: var(--ink-3); margin-bottom: 6px !important; }
.train-meta b { color: var(--leaf); }
.train-badges { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.tb { width: 92px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.tb span { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-deep); color: var(--ink-3); }
.tb span .ico { width: 24px; height: 24px; }
.tb small { font-size: .72rem; color: var(--ink-3); line-height: 1.2; }
.tb.on span { color: #fff; background: radial-gradient(circle at 30% 25%, var(--leaf-bar), var(--leaf) 65%); box-shadow: 0 0 0 4px var(--leaf-tint); }
.tb.on small { color: var(--ink); font-weight: 600; }
.train-reset { text-align: center; margin: 8px 0 20px; }

/* first-time invitation */
.train-invite {
  position: fixed; z-index: 140; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 30px); opacity: 0;
  width: min(560px, calc(100vw - 24px)); display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-pop), 0 0 0 1px var(--line);
  transition: transform .4s var(--ease-out), opacity .3s ease;
}
.train-invite.in { transform: translate(-50%, 0); opacity: 1; }
.ti-badge { width: 48px; height: 48px; flex: 0 0 48px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: radial-gradient(circle at 30% 25%, var(--leaf-bar), var(--leaf) 65%); }
.ti-badge .ico { width: 24px; height: 24px; }
.ti-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: .88rem; color: var(--ink-2); }
.ti-text b { color: var(--ink); font-size: .95rem; }
.ti-btns { display: flex; gap: 8px; margin-left: auto; flex: 0 0 auto; }

/* My account */
.acc-training { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; background: var(--leaf-tint); margin: 4px 0 14px; }
.acc-training-ico { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--leaf); color: #fff; flex: 0 0 40px; }
.acc-training-ico .ico { width: 20px; height: 20px; }
.acc-training > div { display: flex; flex-direction: column; min-width: 0; }
.acc-training small { color: var(--ink-2); font-size: .8rem; }
.acc-training .nm-btn { margin-left: auto; }

#print-root .cert { text-align: center; padding: 18mm 10mm; border: 2px solid #187800; border-radius: 4mm; margin-top: 6mm; }
#print-root .cert h1 { font-size: 22pt; margin: 4mm 0; }
#print-root .cert h2 { font-size: 15pt; margin: 3mm 0 5mm; color: #187800; }
#print-root .cert .sign { margin: 18mm auto 0; }

@media (max-width: 760px) {
  .train-hero { flex-direction: column; text-align: center; padding: 18px; gap: 14px; }
  .train-actions { justify-content: center; }
  .train-actions .nm-btn { width: 100%; justify-content: center; }
  .train-invite { bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom, 0px)); flex-wrap: wrap; }
  .ti-btns { width: 100%; }
  .ti-btns .nm-btn { flex: 1; }
  .train-grid { grid-template-columns: 1fr; }
  .tb { width: 76px; }
}
@media (prefers-reduced-motion: reduce) {
  .tour-ring, .tour-hint .ico, .win-badge, .tour-card.pop { animation: none; }
  .tour-shade, .tour-ring, .tour-card, .train-invite, .train-card { transition: none; }
}

/* Administration → Data & sync */
.danger-zone { border: 1px solid rgba(179, 20, 15, .22); background: var(--red-tint); border-radius: 14px; padding: 12px 14px; }
.danger-zone p { margin: 0 0 8px; }
.danger-zone .row-actions { margin-top: 4px; }

/* Bag store */
.bag-shelves { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 14px; }
.bag-shelves > div { background: var(--surface-2); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.bag-shelves b { font: 700 1.3rem/1.15 var(--display); }
.bag-where { margin: -4px 0 14px; }
label.check { display: flex; align-items: flex-start; gap: 10px; margin: 10px 0 4px; font-size: .92rem; line-height: 1.4; cursor: pointer; }
label.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--leaf); flex: 0 0 20px; }

/* Help: "What is this?" — hidden until asked for */
.help-toggle {
  display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: 999px; padding: 6px 12px 6px 9px; min-height: 34px; cursor: pointer;
  font: inherit; font-size: .82rem; font-weight: 600; white-space: nowrap;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.help-toggle .ico { width: 17px; height: 17px; color: var(--leaf); }
.help-toggle:hover { background: var(--surface-2); border-color: var(--line-strong); }
.help-toggle.on { background: var(--leaf-tint); border-color: rgba(26, 127, 11, .25); color: var(--leaf-dark); }
.modal-head h2 { flex: 1 1 auto; min-width: 0; }
.modal-head .help-toggle { margin-left: auto; }
.help-bar { display: flex; flex-direction: column; align-items: flex-end; margin: 0 0 12px; }
.help-panel { width: 100%; }
.help-panel[hidden] { display: none; }
.help-inner {
  background: var(--leaf-tint); border: 1px solid rgba(26, 127, 11, .18); border-radius: 14px;
  padding: 12px 16px; margin: 8px 0 4px; color: var(--ink); font-size: .95rem; line-height: 1.5;
  animation: help-in .22s var(--ease-out);
}
.modal-body > .help-panel .help-inner { margin: 0 0 14px; }
.help-inner p { margin: 0 0 6px; font-weight: 600; }
.help-inner ul { margin: 0; padding-left: 20px; }
.help-inner li { margin: 3px 0; }
@keyframes help-in { from { opacity: 0; transform: translateY(-4px); } }
.auth-card .help-bar { margin: 0 0 8px; }
@media (prefers-reduced-motion: reduce) { .help-inner { animation: none; } }

/* Accepting a truck: the fill check next to "Take money off" */
.fill-note { background: var(--surface-2); border-radius: 12px; padding: 10px 14px; font-size: .92rem; line-height: 1.45; margin: 6px 0 0; }
.fill-note.is-low { background: var(--amber-tint); color: #5a3a00; }

/* Gasifier: one bag weight per type */
.type-weigh { display: flex; flex-direction: column; gap: 6px; margin: 0 0 8px; }
.type-row { display: grid; grid-template-columns: minmax(90px, 1fr) 1fr 1fr; gap: 10px; align-items: end; background: var(--surface-2); border-radius: 14px; padding: 10px 12px; }
.type-row .type-name { align-self: center; font-size: 1rem; }
.type-row .field { margin: 0; }
@media (max-width: 520px) { .type-row { grid-template-columns: 1fr 1fr; } .type-row .type-name { grid-column: 1 / -1; } }
