/* Ratan ERP. Dark by default, light on request. Flat, quiet, no animations.
   Every colour is a token here; nothing else in the ERP names a colour. */
:root, html[data-theme="dark"] {
  --bg: #0b0b0c; --bg-side: #101011; --surface: #151517; --surface-2: #1b1b1e; --surface-3: #232327;
  --line: #262629; --line-strong: #39393e;
  --text: #ececee; --muted: #9c9ca3; --faint: #6f6f77;
  --accent: #8ab4f8; --accent-ink: #0b0b0c; --accent-soft: rgba(138, 180, 248, 0.12);
  --btn: #f2f2f3; --btn-ink: #0b0b0c;
  --good: #7bd38f; --good-soft: rgba(123, 211, 143, 0.14);
  --warn: #f0c060; --warn-soft: rgba(240, 192, 96, 0.14);
  --bad: #f28b82; --bad-soft: rgba(242, 139, 130, 0.14);
  --organic: #7bd38f; --organic-soft: rgba(123, 211, 143, 0.14);
  --focus: #8ab4f8;
  --radius: 10px; --radius-s: 6px; --gap: 16px;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Roboto Mono", monospace;
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #f5f6f8; --bg-side: #ffffff; --surface: #ffffff; --surface-2: #f2f3f6; --surface-3: #e9ebef;
  --line: #e3e6ea; --line-strong: #c9ced6;
  --text: #1b1d21; --muted: #5d6572; --faint: #8b929d;
  --accent: #1f5fbf; --accent-ink: #ffffff; --accent-soft: rgba(31, 95, 191, 0.10);
  --btn: #141416; --btn-ink: #ffffff;
  --good: #1f7a3a; --good-soft: rgba(31, 122, 58, 0.12);
  --warn: #9a5b00; --warn-soft: rgba(154, 91, 0, 0.12);
  --bad: #b3261e; --bad-soft: rgba(179, 38, 30, 0.10);
  --organic: #1f7a3a; --organic-soft: rgba(31, 122, 58, 0.12);
  --focus: #1f5fbf;
  color-scheme: light;
}
html[data-theme="dark"] .only-light { display: none; }
html[data-theme="light"] .only-dark { display: none; }

*, *::before, *::after { box-sizing: border-box; animation: none !important; transition: none !important; }
html { scroll-behavior: auto; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; margin: 0; line-height: 1.25; }
h2 { font-size: 15px; font-weight: 650; margin: 0 0 10px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
h2 .hint, h1 .hint { font-size: 12.5px; font-weight: 400; color: var(--muted); }
h3 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 14px 0 6px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.hint { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.req { color: var(--bad); }
.sr { position: absolute; left: -9999px; }
.code, .mono { font-family: var(--mono); font-size: 0.95em; }
kbd { font: 11px/1 var(--mono); color: var(--muted); border: 1px solid var(--line-strong); border-bottom-width: 2px;
  border-radius: 4px; padding: 2px 5px; background: var(--surface); }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round;
  stroke-linejoin: round; flex: none; vertical-align: -4px; }
.ico .knob { fill: var(--bg-side); }

/* ---------- Shell ---------- */
.topbar { position: sticky; top: 0; z-index: 20; height: 54px; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: var(--bg-side); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 650; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.search { flex: 1; max-width: 720px; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px 0 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; color: var(--muted); }
.search:focus-within { border-color: var(--focus); }
.search input { flex: 1; border: 0; background: none; padding: 0; color: var(--text); min-width: 0; }
.search input:focus { outline: none; }
.search kbd { display: none; }
@media (min-width: 900px) { .search kbd { display: inline-block; } }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.iconbtn { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  color: var(--muted); display: grid; place-items: center; cursor: pointer; padding: 0; }
.iconbtn:hover { color: var(--text); border-color: var(--line-strong); }
.menu-toggle { display: none; }
.who { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 13px; white-space: nowrap; }
.who small { color: var(--muted); }
.viewas label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.viewas select { height: 34px; padding: 0 8px; font-size: 13px; }

.shell { display: flex; min-height: calc(100vh - 54px); }
.side { width: 236px; flex: none; background: var(--bg-side); border-right: 1px solid var(--line);
  position: sticky; top: 54px; height: calc(100vh - 54px); overflow-y: auto; padding: 10px 10px 16px; }
.nav-item { display: grid; grid-template-columns: auto 1fr; column-gap: 10px;
  align-items: center; padding: 6px 10px; border-radius: 8px; color: var(--text); margin: 1px 0; }
.nav-item:hover { background: var(--surface-2); text-decoration: none; }
.nav-item.on { background: var(--accent-soft); }
.nav-item.on .nav-label { color: var(--accent); font-weight: 650; }
.nav-item .ico { color: var(--muted); }
.nav-item.on .ico { color: var(--accent); }
.nav-item:not(.top) { grid-template-columns: 1fr; padding-left: 38px; }
.nav-label { font-size: 13.5px; font-weight: 500; line-height: 1.25; }
.nav-hint { display: none; }  /* shown as a tip on hover, see .navtip */
.nav-item.on .nav-hint { color: var(--muted); }
.nav-group { margin-top: 10px; }
.nav-group-head { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; padding: 8px 10px 3px; }
.nav-group-head .ico { color: var(--muted); }
.nav-group-name { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.nav-group-hint { display: none; }
.side-foot { margin-top: 18px; padding: 10px; font-size: 11.5px; color: var(--faint); border-top: 1px solid var(--line); }

main { flex: 1; min-width: 0; padding: 18px 28px 64px; }
main.bare { display: grid; place-items: center; min-height: 100vh; padding: 16px; }

@media (max-width: 900px) {
  .menu-toggle { display: grid; }
  .shell { display: block; }
  .side { display: none; position: fixed; top: 54px; left: 0; bottom: 0; width: min(320px, 88vw); z-index: 30;
    height: auto; box-shadow: 0 0 0 100vw rgba(0, 0, 0, 0.45); }
  body.menu-open .side { display: block; }
  main { padding: 14px 16px 64px; }
  .brand span:last-child { display: none; }
  .who { display: none; }
  .nav-hint, .nav-group-hint { display: block; font-size: 11.5px; color: var(--faint); line-height: 1.3; }  /* no hover on phones */
  .nav-item { grid-template-rows: auto auto; }
  .nav-item .ico, .nav-group-head .ico { grid-row: 1 / span 2; }
}

/* ---------- Page header ---------- */
.pagehead { margin-bottom: 16px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.crumbs .ico { width: 14px; height: 14px; color: var(--faint); }
.crumbs a { color: var(--muted); }
.crumbs .leaf { color: var(--text); font-family: var(--mono); }
.pagehead-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.pagehead-text { min-width: 0; }
.purpose { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; max-width: 70ch; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* The factory flow strip */
.flow { list-style: none; margin: 14px 0 0; padding: 0; display: flex; gap: 0; overflow-x: auto; }
.flow li { flex: 1 1 0; min-width: 108px; position: relative; }
.flow li + li::before { content: ""; position: absolute; left: -6px; top: 22px; width: 12px; height: 1px; background: var(--line-strong); }
.flow a, .flow > li > span { display: block; margin: 0 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text); min-height: 100%; }
.flow a:hover { text-decoration: none; border-color: var(--line-strong); background: var(--surface-2); }
.flow li.now a, .flow li.now > span { border-color: var(--accent); background: var(--accent-soft); }
.flow li.later > span { color: var(--faint); border-style: dashed; }
.flow-label { display: block; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.flow-label .count { margin-left: 4px; font-family: var(--mono); font-weight: 600; color: var(--accent); }
.flow-hint { display: block; font-size: 11px; color: var(--muted); line-height: 1.3; }
.flow.big li { min-width: 150px; }
.flow.big .flow-label { font-size: 13.5px; }
.flow.big .count { font-size: 16px; }

/* ---------- Cards, facts, tiles ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: var(--gap); }
.card > :last-child { margin-bottom: 0; }
.card.alert { border-left: 3px solid var(--warn); }
.card.alert.bad { border-left-color: var(--bad); }
.card.quiet { background: var(--bg-side); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--gap); align-items: start; }
.tiles .card { margin: 0; }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--gap); align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px 18px; margin: 0; }
.facts dt { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 550; overflow-wrap: anywhere; }
.facts dd small { display: block; font-weight: 400; color: var(--faint); font-size: 12px; }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent-soft);
  color: var(--accent); font-size: 12px; font-weight: 600; text-align: center; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 24px; font-weight: 650; font-family: var(--mono); letter-spacing: -0.02em; }
.stat .hint { font-size: 12px; }

/* Linked records */
.linked ul { list-style: none; margin: 0; padding: 0; }
.linked li { display: grid; grid-template-columns: 18px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); align-items: start; }
.linked li:last-child { border-bottom: 0; }
.linked .ico { color: var(--faint); margin-top: 2px; }
.linked .what { display: block; font-size: 11.5px; color: var(--muted); }

/* ---------- Lists and tables ---------- */
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); }
ul.plain li:last-child { border-bottom: 0; }
ul.inline-list li { display: inline-block; border: 0; margin: 0 12px 4px 0; padding: 0; }
.table-scroll { overflow-x: auto; }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; }
table.grid th, table.grid td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.grid th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
table.grid th[title] { cursor: help; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover td { background: var(--surface-2); }
table.grid .num, table.grid .kg, table.grid .inr { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 13px; }
table.grid td:first-child a { font-family: var(--mono); font-weight: 600; white-space: nowrap; }
table.grid tfoot td { font-weight: 650; background: var(--surface-2); }
table.grid.small td, table.grid.small th { padding: 6px 8px; font-size: 13px; }
table.grid td.empty { color: var(--muted); text-align: center; padding: 28px; }
table.grid a { white-space: nowrap; }
.pages { display: flex; gap: 16px; justify-content: center; align-items: center; color: var(--muted); margin-top: 12px; }
.columns-help { margin: 8px 0 12px; }
.columns-help summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
.columns-help dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 20px; margin: 8px 0 0; font-size: 12.5px; }
.columns-help dt { font-weight: 600; display: inline; }
.columns-help dd { display: inline; margin: 0; color: var(--muted); }
.columns-help dd::before { content: " — "; }

/* Tags: a dot plus a word */
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 1px 8px 1px 6px; border-radius: 999px; font-size: 12px;
  font-weight: 500; background: var(--surface-3); color: var(--text); white-space: nowrap; border: 1px solid transparent; }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.tag.good, .tag.organic { background: var(--good-soft); color: var(--good); }
.tag.good::before, .tag.organic::before { background: var(--good); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.warn::before { background: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.bad::before { background: var(--bad); }
.tag.info { background: var(--accent-soft); color: var(--accent); }
.tag.info::before { background: var(--accent); }
.tag[title] { cursor: help; }

/* ---------- Forms ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  padding: 7px 10px; min-width: 0; color: var(--text); }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
input[type="radio"] { accent-color: var(--accent); }
textarea { width: 100%; min-height: 72px; font-family: var(--mono); font-size: 13px; }
select { padding-right: 28px; }
button, .button { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-s); padding: 7px 12px; cursor: pointer; color: var(--text); font-weight: 500; line-height: 1.2; }
button:hover, .button:hover { background: var(--surface-2); text-decoration: none; }
button.primary, .button.primary { background: var(--btn); border-color: var(--btn); color: var(--btn-ink); font-weight: 650; }
button.primary:hover, .button.primary:hover { background: var(--btn); filter: brightness(0.9); }
button.danger { color: var(--bad); border-color: var(--bad); background: none; }
button.danger:hover { background: var(--bad-soft); }
button.link { background: none; border: 0; color: var(--accent); padding: 0; }
form.inline { display: inline; }
.form .fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field.check { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 20px; }
.field.check label { font-size: 14px; color: var(--text); font-weight: 500; }
.field.check small { flex-basis: 100%; margin-left: 24px; }
.field.wide { grid-column: 1 / -1; }
.field small { color: var(--faint); font-size: 12px; line-height: 1.4; }
.field small.error, .field.bad label { color: var(--bad); }
.field.bad input, .field.bad select, .field.bad textarea { border-color: var(--bad); }
.field select[multiple] { min-height: 110px; }
.field .options { display: flex; flex-wrap: wrap; gap: 2px 12px; }
.field .options span b { font-weight: 600; color: var(--muted); }
.field ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 12px; flex-wrap: wrap; }
.field ul li label { font-size: 14px; color: var(--text); font-weight: 400; }
.form-actions, .actions-row { margin: 18px 0 0; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.filters { display: flex; gap: 10px 14px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; padding: 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); }
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.filters input[type="search"] { min-width: 220px; }
.lines td input, .lines td select { width: 100%; }
.lines td textarea { min-height: 54px; min-width: 220px; }
.lines .del { width: 60px; text-align: center; }
.scan-button { margin-top: 6px; }
@media (max-width: 900px) {
  table.lines, table.lines tbody { display: block; border: 0; background: none; }
  table.lines thead { display: none; }
  table.lines tr { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 12px;
    border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; background: var(--surface); }
  table.lines td { border: 0; padding: 0; }
  table.lines td::before { content: attr(data-label); display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
  table.lines td:has(textarea) { grid-column: 1 / -1; }
  table.lines td textarea { min-width: 0; }
}
.login { width: min(400px, 94vw); }
.login-people { display: grid; gap: 6px; }
.login-people form { display: block; }
.login-people button { width: 100%; justify-content: flex-start; }
.login-people small { color: var(--muted); font-weight: 400; margin-left: auto; }
.login.quiet { margin-top: 14px; }
.login .field { margin-bottom: 14px; }
.login input { width: 100%; }
.login .brand { justify-content: center; font-size: 18px; margin-bottom: 18px; }

/* ---------- Messages ---------- */
.messages { margin-bottom: 14px; }
.msg { margin: 0 0 8px; padding: 10px 12px; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--surface);
  display: flex; align-items: flex-start; gap: 10px; }
.msg .ico { margin-top: 1px; }
.msg.success { border-color: var(--good); color: var(--good); }
.msg.success span { color: var(--text); }
.msg.error { border-color: var(--bad); color: var(--bad); }
.msg.warning { border-color: var(--warn); color: var(--warn); }
.msg.warning span, .msg.error span { color: var(--text); }

/* ---------- Steps rail on a lot card ---------- */
.steps { list-style: none; padding: 0; margin: 0; counter-reset: step; }
.steps li { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: start; position: relative; }
.steps li:last-child { border-bottom: 0; }
.steps li::before { counter-increment: step; content: counter(step); width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--line-strong); display: grid; place-items: center; font-size: 12px; font-family: var(--mono); color: var(--muted); background: var(--surface); z-index: 1; }
.steps li::after { content: ""; position: absolute; left: 13px; top: 36px; bottom: -10px; width: 1px; background: var(--line); }
.steps li:last-child::after { display: none; }
.steps li.done::before { content: "✓"; background: var(--good-soft); border-color: var(--good); color: var(--good); }
.steps li.now::before { border: 2px solid var(--accent); color: var(--accent); font-weight: 700; }
.steps .entry { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Trace tree ---------- */
.tree, .tree ul { list-style: none; margin: 0; padding-left: 18px; border-left: 1px dashed var(--line-strong); }
.tree { padding-left: 0; border: 0; }
.tree li { padding: 4px 0; }
.tree li a:first-child { font-family: var(--mono); font-weight: 600; }

/* ---------- QR labels, paper and print ---------- */
.qr svg { display: block; max-width: 100%; height: auto; }
.qrcard { display: flex; gap: 14px; align-items: center; }
.qrcard svg { background: #fff; padding: 6px; border-radius: 6px; }
.labels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; background: #fff; color: #000; padding: 4px; }
.label { border: 1px dashed #aaa; padding: 6px; display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: center;
  height: 34mm; overflow: hidden; font-size: 11px; break-inside: avoid; }
.label .code { font-size: 15px; font-weight: 700; font-family: var(--mono); }
.label .org { font-weight: 700; }
.paper { background: #fff; color: #000; max-width: 210mm; padding: 10mm; margin: 0 auto; border: 1px solid var(--line); border-radius: 4px; }
.paper h1, .paper h2 { color: #000; }
.paper table { width: 100%; border-collapse: collapse; }
.paper th, .paper td { border: 1px solid #999; padding: 4px 6px; text-align: left; }
.paper .num { text-align: right; }
@media print {
  .topbar, .side, .noprint, .messages, .pagehead, .crumbs { display: none !important; }
  body, main { background: #fff; padding: 0; color: #000; }
  .paper { border: 0; padding: 0; max-width: none; }
  .labels { padding: 0; }
  @page { size: A4; margin: 8mm; }
}


/* ---------- Letterhead on printed documents, and the logo on screen ---------- */
.brand-logo { height: 30px; width: auto; }
.login-logo { display: block; width: 200px; height: auto; margin: 0 auto 10px; }
.letterhead { display: grid; grid-template-columns: 140px 1fr; gap: 16px; align-items: center; padding-bottom: 10px;
  border-bottom: 2px solid #c04638; margin-bottom: 12px; }
.lh-logo { width: 140px; height: auto; }
.lh-name { font-size: 18px; font-weight: 700; color: #c04638; }
.lh-addr { font-size: 12px; line-height: 1.4; margin-top: 2px; }
.lh-ids { font-size: 11.5px; margin-top: 4px; }
.doc-title { font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; margin: 6px 0 12px; }
.letterfoot { margin-top: 24px; padding-top: 8px; border-top: 1px solid #999; font-size: 10.5px; color: #333; }
.lh-small { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 10px; }
.lh-small img { height: 28px; width: auto; }
.paper h1, .paper h2, .paper .lh-addr, .paper .lh-ids { color: #000; }


/* ---------- Progress bars, reports, stock count ---------- */
.bar { display: inline-block; width: 72px; height: 6px; border-radius: 3px; background: var(--surface-3); vertical-align: middle; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--good); }
.bar.low i { background: var(--warn); }
.bar.none i { background: var(--faint); }
.pct-cell { white-space: nowrap; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: var(--gap); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi b { display: block; font-size: 22px; font-family: var(--mono); font-weight: 650; letter-spacing: -0.02em; }
.kpi span { font-size: 12px; color: var(--muted); }
.count-list { columns: 2; column-gap: 24px; }
@media (max-width: 700px) { .count-list { columns: 1; } }


/* ---------- Documents laid out like Tally's ---------- */
.paper .doc-top { text-align: center; font-size: 11px; letter-spacing: 0.06em; margin: 0 0 6px; }
.paper table.doc-head { margin-bottom: 10px; }
.paper table.doc-head > tbody > tr > td { padding: 6px 8px; font-size: 12px; line-height: 1.4; }
.paper table.doc-meta { width: 100%; }
.paper table.doc-meta td { font-size: 11px; color: #333; padding: 4px 8px; width: 50%; }
.paper table.doc-meta td b { font-size: 12.5px; color: #000; }
.paper table.doc-lines th { font-size: 11.5px; background: #f3f3f3; }
.paper table.doc-lines td { font-size: 12px; vertical-align: top; }
.paper table.doc-lines small { color: #555; }
.paper table.doc-foot td { border: 0; font-size: 11.5px; padding: 4px 0; }
.paper .doc-note { text-align: center; font-size: 10.5px; color: #555; margin-top: 10px; }
.idcards { grid-template-columns: repeat(2, 1fr); }
.idcard { height: 54mm; }
.idcard-company { display: flex; align-items: center; gap: 6px; font-weight: 600; margin-bottom: 4px; }
.idcard-company img { height: 22px; width: auto; }


/* ---------- Access: what the role may not do stays visible, faded, with a lock ---------- */
.locked { opacity: 0.42; cursor: not-allowed; }
.locked:hover { text-decoration: none; }
a.locked:hover, .button.locked:hover { background: inherit; }
.lock-ico { display: inline-block; width: 12px; height: 12px; background: currentColor; flex: none;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><rect x='5' y='11' width='14' height='10' rx='2'/><path d='M8 11V7a4 4 0 0 1 8 0v4'/></svg>") center / contain no-repeat;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><rect x='5' y='11' width='14' height='10' rx='2'/><path d='M8 11V7a4 4 0 0 1 8 0v4'/></svg>") center / contain no-repeat; }
.nav-item.locked { position: relative; }
.nav-item.locked .lock-ico { position: absolute; right: 10px; top: 50%; margin-top: -6px; }
.fm-btn.locked .lock-ico { position: absolute; right: 10px; top: 9px; }
.fm-btn.locked { position: relative; }
.button.locked .lock-ico, button.locked .lock-ico { margin-left: 2px; }
.nav-group-head.locked { opacity: 0.6; }
.ico.big { width: 40px; height: 40px; color: var(--faint); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; max-width: min(520px, 92vw);
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px; background: var(--surface-3);
  color: var(--text); border: 1px solid var(--line-strong); box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35); font-size: 13.5px; }
.toast .lock-ico { width: 16px; height: 16px; color: var(--warn); }

/* Roles & Access table */
table.access td.tick, table.access th.tick { text-align: center; width: 64px; }
table.access th.tick label { cursor: pointer; display: inline-flex; flex-direction: column; align-items: center; gap: 4px; }
table.access tr.group td { background: var(--surface-2); }
table.access tr.group label { cursor: pointer; }
table.access td .what { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; }
table.access td:first-child { font-weight: 550; white-space: normal; min-width: 180px; }

/* Prepared / checked / approved on screen and on paper */
.signoff { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.signoff li { position: relative; padding: 10px 12px 10px 36px; border: 1px dashed var(--line-strong); border-radius: 8px; min-height: 64px; }
.signoff li::before { content: ""; position: absolute; left: 11px; top: 12px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-strong); }
.signoff li.done { border-style: solid; border-color: var(--good); }
.signoff li.done::before { border-color: var(--good); background: var(--good); }
.signoff b { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 2px; }
.signoff span { font-weight: 550; }
.signoff small { display: block; color: var(--faint); font-size: 12px; }
.signoff form { margin-top: 2px; }
.paper table.doc-sign { margin-top: 18px; }
.paper table.doc-sign td { border: 0; border-top: 1px solid #999; width: 33.3%; padding: 6px 8px 0; font-size: 11px; vertical-align: top; height: 40px; }
.paper table.doc-sign b { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: #333; }

/* ---------- The start page: the whole factory on one screen ---------- */
.flowmap { margin-bottom: var(--gap); }
.rail-title { margin: 0 0 8px; font-size: 12px; }
.rail-title b { text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; color: var(--muted); }
.flowmap .rail { list-style: none; margin: 0; padding: 4px 0 8px; display: flex; gap: 30px; overflow-x: auto; align-items: stretch;
  position: relative; isolation: isolate; }
/* The track: a bright dashed line through every stage, and a light that travels along it. Cards sit on top, so it shows in the gaps. */
.flowmap .rail::before { content: ""; position: absolute; left: 0; right: 0; top: 30px; height: 3px; z-index: 0; border-radius: 2px;
  background: repeating-linear-gradient(90deg, var(--accent) 0 10px, transparent 10px 18px); background-size: 18px 3px; }
.flowmap .rail::after { content: ""; position: absolute; top: 26px; left: 0; width: 90px; height: 11px; z-index: 0; border-radius: 6px;
  background: linear-gradient(90deg, transparent, var(--accent) 50%, transparent); opacity: 0.9; }
.flowmap .stage { position: relative; z-index: 1; flex: 1 1 180px; min-width: 176px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; }
.flowmap .stage + .stage::after { content: ""; position: absolute; left: -14px; top: 24px; border: 7px solid transparent;
  border-left: 10px solid var(--accent); z-index: 2; }
.flowmap .stage.coming { border-style: dashed; background: var(--bg-side); }
.flowmap .stage + .stage.coming::after { border-left-color: var(--faint); }
.flowmap .stage.locked { opacity: 1; cursor: default; }
.flowmap .stage.locked .stage-head { opacity: 0.5; }
.stage-head { display: grid; grid-template-columns: 30px 1fr; column-gap: 10px; align-items: center; margin-bottom: 10px; }
.stage-no { grid-row: 1 / span 2; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--accent); display: grid; place-items: center;
  font: 700 13px var(--mono); color: var(--accent); background: var(--surface); }
.stage.coming .stage-no { border-style: dashed; border-color: var(--faint); color: var(--faint); }
.stage-name { font-size: 14.5px; font-weight: 650; line-height: 1.2; }
.stage-name .count { margin-left: 4px; font-family: var(--mono); }
.stage-hint { font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.stage-buttons { display: flex; flex-direction: column; gap: 5px; }
.fm-btn { display: grid; grid-template-columns: 18px 1fr; column-gap: 8px; align-items: center; padding: 6px 9px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface-2); color: var(--text); line-height: 1.25; }
.fm-btn:hover { text-decoration: none; border-color: var(--accent); background: var(--accent-soft); }
.fm-btn .ico { grid-row: 1 / span 2; color: var(--muted); width: 16px; height: 16px; }
.fm-btn .fm-label { font-size: 13px; font-weight: 550; }
.fm-btn small { font-size: 11px; color: var(--faint); line-height: 1.3; }
.fm-btn.locked:hover { border-color: var(--line); background: var(--surface-2); }
.fm-btn.locked .fm-label { padding-right: 16px; }
.fm-btn.coming { border-style: dashed; color: var(--faint); background: none; }
.fm-btn.coming .ico { color: var(--faint); }
/* The turn: from the end of one row, down and across, into the start of the next */
.rail-turn { position: relative; height: 46px; margin: 0 0 8px; }
.rail-turn::before { content: ""; position: absolute; left: 10%; right: 10%; top: 20px; height: 3px; border-radius: 2px;
  background: repeating-linear-gradient(270deg, var(--accent) 0 10px, transparent 10px 18px); background-size: 18px 3px; }
.rail-turn i { position: absolute; width: 3px; height: 23px; background: repeating-linear-gradient(180deg, var(--accent) 0 10px, transparent 10px 18px);
  background-size: 3px 18px; }
.rail-turn i:first-of-type { right: 10%; top: 0; }
.rail-turn i:last-of-type { left: 10%; top: 20px; }
.rail-turn i:last-of-type::after { content: ""; position: absolute; left: -5.5px; bottom: -9px; border: 7px solid transparent; border-top: 10px solid var(--accent); }
.rail-turn span { position: absolute; left: calc(10% + 16px); top: 25px; font-size: 11.5px; color: var(--muted); }
.lanes { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--gap); }
.lane { margin: 0; }
.lane h2 .ico { color: var(--muted); }
.lane-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.lane .fm-btn { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; }
.lane .fm-btn small { display: none; }
.lane .fm-btn.locked .fm-label { padding-right: 0; }
.lane .fm-btn.locked .lock-ico { position: static; }
.lane-coming { border-style: dashed; background: var(--bg-side); }
.lane-setup { grid-column: 1 / -1; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 12.5px; margin-top: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .ico { width: 14px; height: 14px; }
.legend .lock-ico { width: 12px; height: 12px; }

/* The one place with motion: the start page map draws itself, the dashes flow and a light runs along the track.
   The rule at the top of this file switches motion off everywhere else. */
.flowmap .stage { animation: fm-rise 0.35s ease-out backwards !important; animation-delay: calc(var(--i) * 45ms) !important; }
.flowmap .rail::before { animation: fm-flow 0.6s linear infinite !important; }
.flowmap .rail::after { animation: fm-light 3s ease-in-out infinite !important; }
.rail-turn::before { animation: fm-flow-back 0.6s linear infinite !important; }
.rail-turn i { animation: fm-drop 0.6s linear infinite !important; }
.lanes .lane { animation: fm-rise 0.35s ease-out backwards !important; animation-delay: calc(0.45s + var(--i) * 60ms) !important; }
@keyframes fm-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fm-flow { to { background-position: 18px 0; } }
@keyframes fm-flow-back { to { background-position: -18px 0; } }
@keyframes fm-drop { to { background-position: 0 18px; } }
@keyframes fm-light { from { left: 0; } to { left: calc(100% - 90px); } }
@media (prefers-reduced-motion: reduce) {
  .flowmap .stage, .flowmap .rail::before, .flowmap .rail::after, .lanes .lane, .rail-turn::before, .rail-turn i { animation: none !important; }
}
@media (max-width: 900px) {
  .flowmap .rail { flex-direction: column; gap: 16px; }
  .flowmap .rail::before, .flowmap .rail::after { display: none; }
  .flowmap .stage { flex-basis: auto; }
  .flowmap .stage + .stage::before { content: ""; position: absolute; left: 25px; top: -16px; width: 3px; height: 16px;
    background: repeating-linear-gradient(180deg, var(--accent) 0 6px, transparent 6px 12px); background-size: 3px 12px; animation: fm-drop 0.6s linear infinite !important; }
  .flowmap .stage + .stage::after { left: 20px; top: -6px; border: 6px solid transparent; border-top: 8px solid var(--accent); border-left-color: transparent; }
  .rail-turn { display: none; }
}

/* ---------- Sidebar hints appear on hover, so the menu stays compact ---------- */
.navtip { position: fixed; z-index: 70; max-width: 280px; padding: 6px 10px; border-radius: 8px; background: var(--surface-3); color: var(--text);
  border: 1px solid var(--line-strong); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); font-size: 12.5px; line-height: 1.4; pointer-events: none; }
.navtip::before { content: ""; position: absolute; left: -6px; top: 50%; margin-top: -5px; border: 5px solid transparent; border-right-color: var(--line-strong); border-left: 0; }

/* ---------- Login: the company first, then the form ---------- */
main.bare { padding: 0; }
.login-wrap { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 100vh; width: 100%; }
.login-hero { position: relative; display: grid; place-items: center; padding: 48px 40px; overflow: hidden; border-right: 1px solid var(--line);
  background: radial-gradient(ellipse at 30% 35%, rgba(192, 70, 56, 0.28), transparent 58%), var(--bg-side); }
.login-hero::after { content: ""; position: absolute; inset: auto -120px -160px auto; width: 420px; height: 420px; border-radius: 50%;
  border: 28px solid rgba(192, 70, 56, 0.10); }
.login-hero-inner { position: relative; max-width: 460px; }
.login-logo { display: block; width: 240px; max-width: 70%; height: auto; margin: 0 0 24px; }
.login-kicker { font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: #c04638; margin: 0 0 10px; }
.login-title { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; margin: 0 0 22px; }
.login-points { list-style: none; margin: 0 0 28px; padding: 0; display: grid; gap: 10px; color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.login-points b { color: var(--text); font-weight: 600; }
.login-points li { padding-left: 16px; position: relative; }
.login-points li::before { content: ""; position: absolute; left: 0; top: 8px; width: 6px; height: 6px; border-radius: 50%; background: #c04638; }
.login-foot { font-size: 12px; color: var(--faint); margin: 0; }
.login-side { display: grid; place-items: center; padding: 32px 20px; }
.login-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.login-h2 { font-size: 20px; margin-bottom: 2px; }
.login .hint { margin-bottom: 14px; }
@media (max-width: 860px) {
  .login-wrap { grid-template-columns: 1fr; min-height: auto; }
  .login-hero { border-right: 0; border-bottom: 1px solid var(--line); padding: 32px 24px 28px; }
  .login-hero::after { display: none; }
  .login-logo { width: 180px; margin-bottom: 16px; }
  .login-title { font-size: 22px; }
  .login-points { display: none; }
  .login-side { padding: 24px 16px 40px; }
}

/* ---------- Order Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.timeline li { display: grid; grid-template-columns: 160px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.timeline li.done { border-color: var(--good); }
.timeline li.late { border-color: var(--bad); background: var(--bad-soft); }
.timeline li.late-done { border-color: var(--warn); }
.timeline li.soon { border-color: var(--warn); }
.timeline b { font-weight: 600; }
.tl-dates { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.tl-dates label { display: inline-flex; align-items: center; gap: 6px; }
.tl-dates input { padding: 3px 6px; font-size: 12.5px; }
@media (max-width: 700px) { .timeline li { grid-template-columns: 1fr; } }
