:root {
  --bg: #f3f5f7;
  --panel: #ffffff;
  --ink: #14202b;
  --muted: #5a6877;
  --line: #d3dbe2;
  --line-soft: #eaeef2;
  --nav: #0b4f7c;
  --nav-ink: #d6e6f3;
  --nav-active: #0e6aa8;
  --accent: #0b5e95;
  --accent-ink: #ffffff;
  --accent-soft: #dcecf7;
  --danger: #b3261e;
  --danger-soft: #fbe6e4;
  --ok: #2e7d4f;
  --ok-soft: #e3f2e8;
  --warn-soft: #fff4d6;
  --focus: #1478bf;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 25, 35, .06), 0 4px 16px rgba(20, 25, 35, .06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  font-size: 15px;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--focus); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.boot { padding: 40px; color: var(--muted); }

/* ---------- buttons and inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel);
  padding: 7px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap;
  text-decoration: none; color: var(--ink); min-height: 36px;
}
.btn:hover { background: #eef3f7; border-color: #b7c4d0; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #9e5717; }
.btn.danger { color: var(--danger); border-color: #e3b6b2; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 3px 8px; min-height: 28px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=time], input[type=search], input[type=email], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 9px; background: #fff; min-height: 36px;
}
textarea { min-height: 70px; resize: vertical; }
input:disabled, select:disabled, textarea:disabled { background: #f3f1ed; color: var(--muted); }
label.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span.lbl { font-size: 13px; font-weight: 600; color: var(--muted); }
.field .req { color: var(--danger); }
.field .help { font-size: 12px; color: var(--muted); }
.field .err { font-size: 12px; color: var(--danger); }
.field.has-err input, .field.has-err select, .field.has-err textarea { border-color: var(--danger); }

/* ---------- auth pages ---------- */
.auth-wrap { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--panel); border-radius: 12px;
  box-shadow: var(--shadow); padding: 28px; display: flex; flex-direction: column; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 7px; background: var(--accent);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 14px;
}
.auth-card p { margin: 0; color: var(--muted); }
.form-error { background: var(--danger-soft); color: var(--danger); padding: 8px 10px; border-radius: 6px; font-size: 14px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; grid-template-rows: minmax(0, 1fr); height: 100vh; height: 100dvh; overflow: hidden; }
.sidebar { background: var(--nav); color: var(--nav-ink); overflow-y: auto; overscroll-behavior: contain; min-height: 0; height: 100%; display: flex; flex-direction: column; }
.sidebar .brand { color: #fff; padding: 16px; font-size: 16px; }
.nav-group { padding: 6px 0; }
.nav-group h4 {
  margin: 10px 16px 4px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .08em; color: #9cc0dc; font-weight: 600;
}
.nav-link {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 16px; color: var(--nav-ink); text-decoration: none; font-size: 14px;
}
.nav-link:hover { background: var(--nav-active); color: #fff; }
.nav-link.active { background: var(--nav-active); color: #fff; box-shadow: inset 3px 0 0 #fff; }
.nav-link.disabled { color: #6f8094; cursor: default; }
.nav-link.disabled:hover { background: none; color: #6f8094; }
.tag { font-size: 10px; padding: 2px 6px; border-radius: 10px; background: #33465c; color: #a9b8c8; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 18px; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-btn { display: none; }
.content { flex: 1; overflow: auto; padding: 18px 20px 40px; }
.user-menu { position: relative; }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 4px); background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
  min-width: 220px; z-index: 50; padding: 4px; display: flex; flex-direction: column;
}
.dropdown button, .dropdown a {
  text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 5px; cursor: pointer;
  color: var(--ink); text-decoration: none; font-size: 14px;
}
.dropdown button:hover, .dropdown a:hover { background: var(--bg); }
.dropdown hr { border: 0; border-top: 1px solid var(--line-soft); margin: 4px 0; width: 100%; }
.dropdown .dd-label { font-size: 11px; text-transform: uppercase; color: var(--muted); padding: 6px 10px 2px; letter-spacing: .06em; }
.dropdown .on::before { content: "✓ "; color: var(--accent); }

/* ---------- home ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 4px;
}
a.card:hover { border-color: var(--accent); }
.card .num { font-size: 26px; font-weight: 700; }
.card .lbl { color: var(--muted); font-size: 13px; }
.section-title { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 26px 0 10px; }
.next-list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 16px; }
.next-list li { padding: 6px 0; }

/* ---------- toolbar and grid ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .search { flex: 1 1 220px; max-width: 340px; }
.toolbar .spacer { flex: 1; }
.layout-dirty { font-size: 12px; background: var(--warn-soft); padding: 4px 8px; border-radius: 6px; }
.grid-wrap {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: auto; max-height: calc(100vh - 190px);
}
table.grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: max-content; min-width: 100%; }
table.grid th, table.grid td {
  border-bottom: 1px solid var(--line-soft); padding: 8px 10px; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; background: var(--panel);
}
table.grid th {
  position: sticky; top: 0; z-index: 2; background: #f8f6f2; font-size: 12px; font-weight: 600;
  color: var(--muted); user-select: none; border-bottom: 1px solid var(--line);
}
table.grid th .th-inner { display: flex; align-items: center; gap: 4px; cursor: pointer; }
table.grid th .th-inner span { overflow: hidden; text-overflow: ellipsis; }
table.grid th .sort { color: var(--accent); }
table.grid th.drag-over { box-shadow: inset 3px 0 0 var(--accent); }
table.grid th .resizer { position: absolute; right: 0; top: 0; bottom: 0; width: 7px; cursor: col-resize; }
table.grid th .resizer:hover { background: var(--accent-soft); }
table.grid .frozen { position: sticky; z-index: 1; }
table.grid th.frozen { z-index: 3; }
table.grid .frozen-last { box-shadow: 2px 0 0 var(--line); }
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover td { background: #fbf6f0; }
table.grid tr.inactive td { color: #9aa0a8; }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.pill { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--line-soft); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.warn { background: var(--warn-soft); }
.count { color: var(--muted); font-size: 13px; }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(15, 20, 30, .45); z-index: 100;
  display: grid; place-items: center; padding: 16px;
  grid-template-columns: minmax(0, 1fr);
}
.modal {
  background: var(--panel); border-radius: 12px; box-shadow: var(--shadow);
  width: 100%; max-width: 520px; max-height: calc(100vh - 32px - var(--chrome-top, 0px)); display: flex; flex-direction: column;
}
.modal.wide { max-width: none; }          /* record windows run from edge to edge of the page */
.modal header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line-soft); }
.modal header h2 { font-size: 17px; margin: 0; flex: 1; }
.modal .body { padding: 16px 18px; overflow: auto; }
.modal footer {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; padding: 12px 18px;
  border-top: 1px solid var(--line-soft);
}
.modal footer .left { margin-right: auto; display: flex; gap: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); gap: 14px; }
.modal .body > * { min-width: 0; }
.form-grid .wide { grid-column: 1 / -1; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { background: none; border: 0; padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.history-item { border-bottom: 1px solid var(--line-soft); padding: 10px 0; font-size: 14px; }
.history-item .meta { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.change { font-size: 13px; }
.change .old { color: var(--danger); text-decoration: line-through; }
.change .new { color: var(--ok); }
.col-list { display: flex; flex-direction: column; gap: 2px; max-height: 50vh; overflow: auto; }
.col-row { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 5px; }
.col-row:hover { background: var(--bg); }
.col-row label { flex: 1; }
.perm-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.perm-table th, .perm-table td { padding: 6px 8px; border-bottom: 1px solid var(--line-soft); text-align: center; }
.perm-table th:first-child, .perm-table td:first-child { text-align: left; }
.perm-table thead th { font-size: 12px; color: var(--muted); position: sticky; top: 0; background: var(--panel); }
.import-summary { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.note { background: var(--accent-soft); padding: 10px 12px; border-radius: 6px; font-size: 14px; }

/* ---------- toasts ---------- */
#toasts {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 200;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 360px; font-size: 14px; }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* ---------- phone and tablet ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 90;
    transform: translateX(-100%); transition: transform .2s;
  }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 8px 12px; }
  .content { padding: 12px 12px 40px; }
  .grid-wrap { max-height: calc(100vh - 230px); }
  .toolbar .search { max-width: none; }
  .modal-back { padding: 0; }
  .modal, .modal.wide { max-width: none; max-height: 100vh; max-height: 100dvh; height: 100%; border-radius: 0; }
  .hide-mobile { display: none; }
}

/* ---------- documents: lines, sub-tables, calculated fields ---------- */
input.calc, select.calc, textarea.calc { background: #f1f6ef; color: #23402c; border-style: dashed; font-weight: 600; }
.calc-cell { color: #23402c; font-weight: 600; }
.lines-block { margin-top: 20px; }
.lines-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.lines-head h3 { margin: 0; font-size: 15px; flex: 1; }
.tbl-wrap { max-height: 45vh; }
table.grid.lines { table-layout: auto; }
table.grid.lines td.row-actions { white-space: nowrap; text-align: right; }
table.grid tr.row-err td { background: var(--danger-soft); }
table.grid.edit { table-layout: auto; }
table.grid.edit.fixed { table-layout: fixed; width: max-content; min-width: 100%; }
table.grid.edit.fixed input, table.grid.edit.fixed select { min-width: 0; width: 100%; }
table.grid.edit.fixed th { position: relative; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.grid.edit td { padding: 4px 6px; overflow: visible; }
table.grid.edit input, table.grid.edit select { min-width: 90px; min-height: 32px; padding: 4px 6px; }
table.grid.edit select { min-width: 170px; }
.tbl-edit { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.tbl-edit .grid-wrap { width: 100%; }
.lbl.sub { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.tabs.scroll { overflow-x: auto; flex-wrap: nowrap; }
.tabs.scroll button { white-space: nowrap; }
.modal .err div { margin-top: 2px; }
table.grid tr.overdue td { background: var(--danger-soft); color: var(--danger); }
table.grid tr.overdue td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.modal footer .left { flex-wrap: wrap; }
@media (max-width: 860px) {
  .modal footer .left { width: 100%; margin-right: 0; }
  .modal footer .btn { padding: 6px 10px; }
}

/* ---------- stock screen ---------- */
.stock-filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.stock-filters .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stock-filters .row > select, .stock-filters .flt { width: auto; min-width: 110px; flex: 0 1 170px; }
.stock-filters input[type=number].flt { flex-basis: 90px; min-width: 70px; }
.stock-filters .spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg-btn { border: 0; background: var(--panel); padding: 6px 10px; cursor: pointer; font-size: 13px; min-height: 34px; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn.on { background: var(--nav); color: #fff; }
.seg-btn.red.on { background: var(--danger); }
.seg-btn.green.on { background: var(--ok); }
table.grid tr.below-min td { background: var(--danger-soft); }
table.grid tr.above-min td { background: var(--ok-soft); }
.stock-totals { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 10px; font-size: 14px; color: var(--muted); }
.stock-totals b { color: var(--ink); }
.stock-totals .legend { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.sw.red { background: var(--danger-soft); border: 1px solid var(--danger); }
.sw.green { background: var(--ok-soft); border: 1px solid var(--ok); }
h3.sub-h { font-size: 14px; margin: 16px 0 8px; }
h3.sub-h:first-child { margin-top: 0; }
.stock-filters .more { display: flex; flex-direction: column; gap: 8px; }
.stock-filters .more-btn { display: none; }
@media (max-width: 860px) {
  .stock-filters .more { display: none; }
  .stock-filters .more.open { display: flex; }
  .stock-filters .more-btn { display: inline-flex; }
  .stock-filters .row > select, .stock-filters .flt { flex: 1 1 140px; }
  .stock-totals .legend { margin-left: 0; }
}

/* ---------- scanning ---------- */
.scan-panel { background: var(--accent-soft); border: 1px solid #e8c9a8; border-radius: var(--radius); padding: 12px; margin-bottom: 16px; }
.scan-row { display: flex; gap: 8px; flex-wrap: wrap; }
.scan-row .scan-input { flex: 1 1 260px; font-size: 16px; min-height: 42px; }
.scan-msg { min-height: 20px; margin: 6px 0 2px; font-size: 14px; }
.scan-msg.ok { color: var(--ok); }
.scan-msg.bad { color: var(--danger); }
.scan-msg.warn { color: #8a5a00; }
.scan-video { width: 100%; max-height: 60vh; background: #000; border-radius: 8px; }
.pick-list { display: flex; flex-direction: column; gap: 8px; }

/* ---------- shop floor ---------- */
.floor-job { display: flex; flex-direction: column; gap: 10px; }
.floor-job-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.floor-no { font-size: 22px; font-weight: 800; }
.floor-meta { text-align: right; }
.step-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px; }
.step-card.running { border-color: var(--ok); box-shadow: inset 4px 0 0 var(--ok); }
.step-top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.step-run { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.step-run select { flex: 1 1 220px; width: auto; }
.btn.big { min-height: 46px; padding: 10px 26px; font-size: 16px; font-weight: 600; }

/* ---------- live board ---------- */
.live-machines { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.machine-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.machine-card.busy { border-color: var(--ok); box-shadow: inset 4px 0 0 var(--ok); }
.mc-name { font-weight: 700; }
.mc-job { font-size: 17px; font-weight: 700; color: var(--ok); }
.mc-next { font-size: 12px; color: var(--muted); }
.sw.grey { background: #eceae6; border: 1px solid #9aa0a8; }
.legend { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }

/* ---------- planning board ---------- */
.plan-layout { display: grid; grid-template-columns: 260px 1fr; gap: 14px; align-items: start; }
.plan-unplanned { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px;
  max-height: calc(100vh - 190px); overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.plan-board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.plan-col { flex: 0 0 min(250px, 78vw); background: #ebe8e2; border-radius: var(--radius); padding: 8px; display: flex; flex-direction: column; gap: 8px; min-height: 200px; }
.plan-col.drop, .plan-card.drop { outline: 2px dashed var(--accent); }
.plan-head { background: var(--panel); border-radius: 6px; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.plan-card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px; font-size: 13px;
  display: flex; flex-direction: column; gap: 3px; cursor: grab; }
.plan-card.late { border-color: var(--danger); background: var(--danger-soft); }
.plan-card.running { box-shadow: inset 3px 0 0 var(--ok); }
.plan-card .pc-top { display: flex; gap: 6px; align-items: center; }
.plan-card .pc-actions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.late-text { color: var(--danger); font-weight: 600; }
.small-select { width: auto; min-height: 28px; padding: 2px 6px; font-size: 12px; flex: 1; }
.small-link { font-size: 12px; }
.plan-end { text-align: center; padding: 8px; }
@media (max-width: 860px) {
  .plan-layout { grid-template-columns: 1fr; }
  .plan-unplanned { max-height: 40vh; }
  .floor-meta { text-align: left; }
}

table.grid.edit td.na-cell { color: var(--muted); text-align: center; background: #f6f4f0; }
.step-tool { font-weight: 700; color: var(--accent); }
.step-tool.bad { color: var(--danger); }
.step-tool.small { font-size: 12px; }
.inline-check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.rate-chart table.rates input { width: 110px; min-height: 30px; }
.rate-block { margin-bottom: 18px; }

/* costing dropdown lists */
.grid tr.muted td { color: var(--muted, #888); }
.list-add { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }
.list-add input { max-width: 240px; }
.list-add input.short { max-width: 150px; }
ul.plain { list-style: none; padding: 0; margin: 0; font-size: 13px; }
ul.plain li { padding: 3px 0; }

/* paper chooser */
table.grid-simple { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0; }
table.grid-simple th, table.grid-simple td { border-bottom: 1px solid var(--line, #ddd); padding: 6px 8px; text-align: left; vertical-align: middle; }
table.grid-simple td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid-simple tr.dim { opacity: .55; }
.floor-pack { display: flex; gap: 10px; align-items: center; padding: 8px 12px; margin: 8px 0; background: #fff6e8; border: 1px solid #e8c88a; border-radius: 6px; }
td.warn { color: #b3261e; font-weight: 600; }

.floor-hold { background: #fdecea; color: #8a1c14; border: 1px solid #f0b4ae; border-radius: 8px; padding: 10px 12px; margin: 8px 0; font-weight: 600; }

.plan-days { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 12px; }
.plan-day { min-width: 230px; flex: 1 0 230px; background: var(--panel, #fff); border: 1px solid var(--line, #ddd); border-radius: 10px; padding: 8px; }
.plan-day.today { border-color: #0b5e95; }
.plan-day-head { display: flex; gap: 6px; align-items: baseline; margin-bottom: 6px; }
.plan-day-head .small-link { margin-left: auto; }
.plan-card { border: 1px solid var(--line, #ddd); border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; background: #fffdf8; }
.plan-card.hold { background: #fdecea; }
.plan-edit { display: flex; gap: 4px; margin-top: 4px; align-items: center; }
.plan-edit input[type=date] { max-width: 135px; }
.plan-qty { width: 84px; }

.brand-logo { height: 34px; max-width: 150px; object-fit: contain; background: #fff; border-radius: 6px; padding: 2px 4px; }
.auth-card .brand-logo { height: 62px; max-width: 100%; padding: 0; }
.sidebar .brand { justify-content: center; }
.sidebar .brand-logo { height: 40px; max-width: 218px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }

/* ---------- job status ---------- */
.js-bar { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin-bottom: 10px; }
.js-radios { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-bottom: 8px; }
.js-radio { cursor: pointer; font-weight: 600; }
.js-filters { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; }
.js-f .lbl { display: block; font-size: 12px; color: var(--muted); }
.js-f input { min-height: 34px; }
.js-list { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; max-height: 340px; overflow: auto; margin-bottom: 14px; }
.js-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.js-table th { position: sticky; top: 0; background: #eaeef2; text-align: left; font-size: 12px; color: var(--muted); padding: 7px 9px; white-space: nowrap; }
.js-table td { padding: 6px 9px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.js-table .num { text-align: right; }
.js-table tbody tr { cursor: pointer; }
.js-table tbody tr:hover { background: #eef3f7; }
.js-table tbody tr.sel { background: var(--accent-soft); }
.js-table tbody tr.late td:nth-child(2) { color: var(--danger); }
.js-table.small tbody tr { cursor: default; }
.js-table .over { color: var(--danger); font-weight: 700; }
.js-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin-bottom: 10px; }
.js-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.js-title { font-size: 20px; font-weight: 700; }
.js-flow { display: flex; gap: 6px; margin: 12px 0; flex-wrap: wrap; }
.js-flow b { flex: 1; min-width: 90px; text-align: center; padding: 7px 4px; border-radius: 6px; font-size: 12px; background: #eaeef2; color: var(--muted); }
.js-flow b.d { background: var(--ok-soft); color: var(--ok); }
.js-flow b.r { background: var(--accent); color: #fff; }
.js-grid4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 18px; margin: 6px 0; }
.js-card .k, .js-detail .k { font-size: 12px; color: var(--muted); }
.js-card .v { font-weight: 600; }
.js-tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.js-tabs span { padding: 8px 2px; cursor: pointer; color: var(--muted); }
.js-tabs span.on { color: var(--ink); font-weight: 600; border-bottom: 2px solid var(--accent); }
.js-pane { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; }
.js-two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 10px; }
@media (max-width: 800px) { .js-two { grid-template-columns: 1fr; } }

/* department menu */
.nav-dept { display: flex; width: 100%; justify-content: space-between; align-items: center; background: none; border: 0; color: #dbe7f3; font: inherit; font-weight: 600; padding: 9px 16px; cursor: pointer; text-align: left; }
.nav-dept:hover { background: var(--nav-active); color: #fff; }
.nav-dept .chev { transition: transform .15s; font-size: 11px; opacity: .8; }
.nav-collapsible.open > .nav-dept .chev { transform: rotate(90deg); }
.nav-collapsible .nav-body { display: none; padding-bottom: 4px; }
.nav-collapsible.open .nav-body { display: block; }
.nav-sub { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: #8fa7bf; padding: 8px 16px 2px 22px; }
.nav-collapsible .nav-link { padding-left: 28px; }

/* tabs, favourites, menu search */
.panes { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tabbar { display: flex; gap: 2px; padding: 6px 12px 0; background: #e3e9ef; border-bottom: 1px solid #c9d3dd; overflow-x: auto; flex: none; }
.tab { display: flex; align-items: center; max-width: 220px; min-width: 90px; background: #cfd9e3; color: #33475b; border-radius: 6px 6px 0 0; padding: 0 4px 0 12px; font-size: 13px; }
.tab.active { background: #fff; color: #0b5e95; font-weight: 600; box-shadow: inset 0 2px 0 #0b5e95; }
.tab-label { flex: 1; padding: 8px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.tab-x, .fav-x { background: none; border: 0; color: inherit; opacity: .55; cursor: pointer; font-size: 16px; padding: 2px 6px; border-radius: 4px; }
.tab-x:hover, .fav-x:hover { opacity: 1; background: rgba(0,0,0,.1); }
.star { font-size: 20px; padding: 2px 8px; color: #8aa0b4; }
.star.on { color: #e0a800; }
.nav-search-wrap { padding: 4px 12px 2px; }
.nav-search { width: 100%; box-sizing: border-box; padding: 7px 10px; border-radius: 6px; border: 0; background: rgba(255,255,255,.14); color: #fff; font: inherit; font-size: 13px; }
.nav-search::placeholder { color: #a9c0d6; }
.nav-dept.static { cursor: default; }
.nav-dept.static:hover { background: none; color: #dbe7f3; }
.fav-row { display: flex; align-items: center; color: var(--nav-ink); }
.fav-row .nav-link { flex: 1; min-width: 0; }
.fav-row .fav-x { visibility: hidden; color: #dbe7f3; }
.fav-row:hover .fav-x { visibility: visible; }
.nav-hint { font-size: 12px; color: #9cc0dc; padding: 2px 16px 6px 22px; }
.nav-link.nomatch, .nav-collapsible.nomatch { display: none; }
.searching .nav-collapsible .nav-body { display: block; }
.searching .nav-sub { display: none; }
.nav-fav .nav-body { display: block; }
/* tabs and menu stay usable while a dialog is open, so you can go and look something up */
/* On a PC the dialog backdrop starts below the tabs and beside the menu, so neither is covered. */
@media (min-width: 861px) {
  .tabbar { position: relative; z-index: 110; }
  .sidebar { position: relative; z-index: 110; }
  .modal-back { top: var(--chrome-top, 0px); left: 250px; bottom: 0; height: auto; }
}
@supports (height: 100dvh) {
  @media (min-width: 861px) { .modal { max-height: calc(100dvh - 32px - var(--chrome-top, 0px)); } }
}
@media (max-width: 860px) { .sidebar { z-index: 120; } }
.move-cell { white-space: nowrap; width: 1%; }
.move-cell .btn { padding: 2px 7px; }

table.grid.simple { table-layout: auto; width: 100%; }
table.grid.simple td, table.grid.simple th { padding: 6px 8px; vertical-align: top; }
.floor-limits { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-bottom: 10px; }
td.mis-amber, .pill.mis-amber, tr.mis-amber { background: #fff1d6; color: #7a4900; }
td.mis-red, .pill.mis-red { background: #fde4e4; color: #8d1b1f; }
td.mis-blue, .pill.mis-blue, tr.mis-blue td { background: #e3effa; color: #174b78; }
td.mis-green, .pill.mis-green { background: #e4f5ea; color: #14663a; }
.mis-sum { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 10px; font-weight: 600; }
.pill { margin: 1px 4px 1px 0; }
table.grid.simple td { white-space: normal; overflow: visible; text-overflow: clip; }
.nav-search:focus, .nav-search:not(:placeholder-shown) { background: rgba(255,255,255,.14) !important; color: #fff !important; outline: 2px solid #a9c0d6; -webkit-text-fill-color: #fff; }
.nav-search::-webkit-search-cancel-button { filter: invert(1); }

/* ---------- home dashboard ---------- */
.dash { display: flex; flex-direction: column; gap: 16px; animation: dfade .35s ease both; }
@keyframes dfade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.dhero { background: linear-gradient(120deg, #0b4f7c 0%, #0e6aa8 55%, #2a8fd0 100%); color: #fff; border-radius: 14px; padding: 20px 22px 18px; box-shadow: var(--shadow); }
.dhero-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.dhero h2 { margin: 0 0 2px; font-size: 24px; font-weight: 650; letter-spacing: -.01em; }
.dhero p { margin: 0; opacity: .85; font-size: 14px; }
.btn.ghost-light { background: rgba(255,255,255,.16); color: #fff; border: 1px solid rgba(255,255,255,.35); }
.btn.ghost-light:hover { background: rgba(255,255,255,.26); }
.dtiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 16px; }
.dtile { display: block; background: rgba(255,255,255,.13); border: 1px solid rgba(255,255,255,.22); border-radius: 12px; padding: 12px 14px; color: #fff; text-decoration: none; transition: transform .15s ease, background .15s ease; }
.dtile:hover { transform: translateY(-2px); background: rgba(255,255,255,.22); }
.dtile b { display: block; font-size: 28px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.dtile span { font-size: 13px; opacity: .9; }
.dtile.bad { background: rgba(227,73,72,.38); border-color: rgba(255,255,255,.4); }
.dtile.warn { background: rgba(237,161,0,.34); border-color: rgba(255,255,255,.4); }
.dtile.good b::after { content: " ✓"; font-size: 15px; opacity: .8; }
.dgrid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.dgrid.three { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.dcard { background: var(--panel); border: 1px solid var(--line-soft); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.dcard header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.dcard h3 { margin: 0; font-size: 16px; font-weight: 650; }
.dsub { color: var(--muted); font-size: 13px; }
.dempty, .dgood { color: var(--muted); padding: 18px 4px; text-align: center; }
.dgood { color: var(--ok); font-weight: 600; }
.loadlist { display: flex; flex-direction: column; gap: 10px; max-height: 340px; overflow-y: auto; padding-right: 4px; }
.loadrow { display: block; text-decoration: none; color: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-soft); transition: transform .15s ease, box-shadow .15s ease; animation: dfade .4s ease both; }
.loadrow:hover { transform: translateX(3px); box-shadow: var(--shadow); }
.lr-top { display: flex; align-items: baseline; gap: 10px; }
.lr-top b { font-size: 15px; }
.lr-state { font-size: 12px; font-weight: 600; flex: 1; }
.lr-pct { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.lr-bar { height: 8px; background: var(--line-soft); border-radius: 4px; overflow: hidden; margin: 7px 0 5px; }
.lr-bar i { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--ok); transition: width .8s cubic-bezier(.2,.8,.2,1); }
.lr-sub { font-size: 12px; color: var(--muted); }
.loadrow.ok .lr-state { color: var(--ok); } .loadrow.high .lr-state { color: #9a6200; } .loadrow.high .lr-bar i { background: #eda100; }
.loadrow.over { background: var(--danger-soft); border-color: #f1c4c1; } .loadrow.over .lr-state, .loadrow.over .lr-pct { color: var(--danger); } .loadrow.over .lr-bar i { background: #e34948; }
.donutwrap { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; justify-content: center; }
.donut { width: 160px; height: 160px; flex: none; }
.donut-arc { transition: stroke-width .15s ease; } .donut-arc:hover { stroke-width: 22; }
.donut-n { font-size: 24px; font-weight: 700; fill: var(--ink); } .donut-l { font-size: 11px; fill: var(--muted); }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; min-width: 150px; flex: 1; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 14px; } .legend li span { flex: 1; }
.legend .sw { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.strip { display: flex; gap: 12px; overflow-x: auto; padding: 4px 2px 10px; scroll-snap-type: x proximity; scrollbar-width: thin; }
.lcard, .rcard { flex: none; width: 230px; scroll-snap-align: start; text-decoration: none; color: inherit; border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px 14px; background: #fff; transition: transform .15s ease, box-shadow .15s ease; }
.lcard:hover, .rcard:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.lcard.bad { border-top: 4px solid #e34948; } .lcard.warn { border-top: 4px solid #eda100; }
.lc-top, .rc-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.lc-cust { color: var(--muted); font-size: 13px; margin: 2px 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-days { font-size: 14px; } .lc-days strong { font-size: 26px; font-variant-numeric: tabular-nums; }
.lcard.bad .lc-days strong { color: var(--danger); } .lcard.warn .lc-days strong { color: #9a6200; }
.lc-sub, .rc-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.rcard { width: 200px; } .rcard.on { border-top: 4px solid #1baf7a; } .rcard.paused { border-top: 4px solid #eda100; } .rcard.off { border-top: 4px solid #c9d2db; }
.rc-top .dot { width: 10px; height: 10px; border-radius: 50%; background: #b6bfca; } .rc-st { font-size: 12px; color: var(--muted); flex: 1; text-align: right; }
.rcard.on .dot { background: #1baf7a; animation: dpulse 1.6s ease-out infinite; } .rcard.paused .dot { background: #eda100; }
@keyframes dpulse { 0% { box-shadow: 0 0 0 0 rgba(27,175,122,.55); } 100% { box-shadow: 0 0 0 9px rgba(27,175,122,0); } }
.rc-job { font-weight: 700; font-size: 16px; margin: 8px 0 2px; } .rc-job.muted { color: var(--muted); font-weight: 500; }
.cols { width: 100%; height: auto; max-height: 220px; overflow: visible; }
.col-bar { transition: opacity .15s ease; } .cols:hover .col-bar { opacity: .55; } .cols .col-bar:hover { opacity: 1; }
.col-v { font-size: 11px; font-weight: 600; fill: var(--ink); } .col-l { font-size: 11px; fill: var(--ink); } .col-s { font-size: 10px; fill: var(--muted); }
.dskel { height: 150px; border-radius: 14px; background: linear-gradient(90deg, #e9edf1 25%, #f4f6f8 50%, #e9edf1 75%); background-size: 200% 100%; animation: dshimmer 1.2s linear infinite; }
.dskel.short { height: 110px; }
@keyframes dshimmer { to { background-position: -200% 0; } }
details.records { margin-top: 18px; } details.records summary { cursor: pointer; font-weight: 650; color: var(--muted); margin-bottom: 10px; }
@media (max-width: 900px) { .dgrid { grid-template-columns: 1fr; } .dhero h2 { font-size: 20px; } }
@media (prefers-reduced-motion: reduce) { .dash, .loadrow, .lr-bar i, .dskel, .rcard.on .dot { animation: none !important; transition: none !important; } }

.needs-box { background: #fff4e5; border: 1px solid #f0c36d; border-left: 5px solid #e08a00; color: #5a3a00; padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.needs-box.soft { background: #eef5fb; border-color: #b9d4ec; border-left-color: var(--accent); color: var(--ink); }
.needs-box ul { margin: 4px 0 6px 18px; padding: 0; } .needs-box .needs-item { margin-top: 6px; }

/* ---------- costing window: three tabs, inputs on one page ---------- */
.main-tabs { margin-bottom: 14px; } .main-tabs button { font-size: 15px; padding: 10px 18px; }
.stacked { display: flex; flex-direction: column; gap: 14px; }
.stack-sec { border: 1px solid var(--line-soft); border-radius: 10px; padding: 12px 14px 14px; background: #fff; }
.stack-sec h3 { margin: 0 0 10px; font-size: 15px; color: var(--accent); border-bottom: 1px solid var(--line-soft); padding-bottom: 6px; }
.result-strip { position: sticky; top: -1px; z-index: 5; background: #f4f7fa; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-size: 14px; box-shadow: var(--shadow); }
.result-strip.ok { background: #edf7f0; border-color: #bfe0c9; } .result-strip.bad { background: #fff4e5; border-color: #f0c36d; color: #5a3a00; }
.result-strip ul { margin: 4px 0 0 18px; padding: 0; } .rs-meta { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.rs-rates { display: flex; flex-wrap: wrap; gap: 8px 22px; } .rs-rate { display: flex; flex-direction: column; } .rs-rate b { font-size: 18px; } .rs-rate small { color: var(--muted); }
.rs-warn { margin-top: 6px; color: #7a5200; white-space: pre-line; }
.quote-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; } .quote-summary { margin-bottom: 14px; }

.wa-text { width: 100%; font-family: inherit; font-size: 14px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }

.qp-box { border: 1px solid var(--line-soft); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; background: #fff; }
.qp-box h3 { margin: 0 0 8px; font-size: 15px; color: var(--accent); }
.qp-actions { margin-top: 10px; display: flex; gap: 10px; align-items: center; }
.pi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 12px; margin-bottom: 10px; }
.pi-f { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 3px; } .pi-f.span2 { grid-column: span 2; }
.pi-f input, .pi-f textarea, .pi-f select { font: inherit; font-size: 14px; color: var(--ink); padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; }
.pi-line { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 10px; align-items: end; padding: 8px 0; border-top: 1px solid var(--line-soft); }
.inq-qty { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.count.bad { color: var(--danger); }
@media (max-width: 760px) { .pi-grid { grid-template-columns: 1fr 1fr; } .pi-line { grid-template-columns: 1fr 1fr; } }
.fgjob { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }

.fbtn { margin-left: 6px; border: 1px solid #c5cbd6; border-radius: 4px; padding: 0 5px; font-size: 11px; background: #fff; color: #445; cursor: pointer; line-height: 16px; }
.fbtn.on { background: #0b5a8f; color: #fff; border-color: #0b5a8f; }
.colfilter-pop { position: fixed; z-index: 1000; width: 290px; background: #fff; border: 1px solid #c5cbd6; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.2); font-size: 13px; }
.colfilter-pop .cf-row { padding: 8px 12px; border-bottom: 1px solid #eceef2; cursor: pointer; }
.colfilter-pop .cf-row:hover { background: #eef4fa; }
.colfilter-pop .cf-ops { display: flex; flex-direction: column; gap: 6px; padding: 8px 12px; border-bottom: 1px solid #eceef2; }
.colfilter-pop .cf-search { width: calc(100% - 24px); margin: 8px 12px; }
.colfilter-pop .cf-list { max-height: 200px; overflow: auto; padding: 0 12px 6px; }
.colfilter-pop .cf-list label { display: flex; gap: 8px; align-items: center; padding: 3px 0; }
.colfilter-pop .cf-list .n { margin-left: auto; color: #888; }
.colfilter-pop .cf-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 12px; border-top: 1px solid #eceef2; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; font-size: 13px; }
.chips .chip { background: #e3eefa; border-radius: 12px; padding: 3px 10px; }
.chips .chip-x { border: 0; background: none; cursor: pointer; color: #345; }

.item-tabs { margin-bottom: 8px; flex-wrap: wrap; }
.item-tabs button { font-size: 12px; padding: 4px 10px; }
.item-tabs button.bad { border-color: #c0392b; color: #c0392b; }
.item-tabs .add-tab { border-style: dashed; }
.item-remove { margin-top: 12px; }
.rs-diffs { margin: 6px 0 10px; padding: 6px 10px; background: #fff7e0; border-left: 3px solid #e0a800; font-size: 13px; }
.rs-diffs:empty { display: none; }
.rs-diff { margin-right: 14px; }
.rs-table { border-collapse: collapse; width: 100%; margin-top: 6px; }
.rs-table th, .rs-table td { padding: 4px 8px; text-align: left; border-bottom: 1px solid #cfe5cf; font-size: 13px; }
.rs-table tr.pick td { background: rgba(60, 160, 60, .12); }
.rs-table td small, .rs-rate small { display: block; color: #666; font-size: 11px; }
.rs-table td.typed b, .rs-rate.typed b { color: #b36b00; }
.sec-tabs { margin-bottom: 10px; }

/* sales order and product pages: header and lines on one page, lines as small tabs (as in costing) */
.compact-doc .doc-head { display: flex; flex-direction: column; gap: 6px; }
.compact-doc .form-grid { grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: 4px 10px; align-items: end; }
.compact-doc .field { gap: 2px; }
.compact-doc .field > span.lbl { font-size: 11px; }
.compact-doc .field .help { display: none; }
.compact-doc input[type=text], .compact-doc input[type=number], .compact-doc input[type=date], .compact-doc select, .compact-doc textarea { padding: 3px 8px; font-size: 13px; min-height: 28px; height: 28px; }
.compact-doc textarea { resize: none; }
.compact-doc .form-grid .wide { grid-column: 1 / -1; }
.compact-doc .form-grid .field.wide:has(textarea), .compact-doc .field:has(textarea) { grid-column: span 2; }
.compact-doc .lines-head { margin: 6px 0 0; }
.compact-doc .lines-head h3 { margin: 0; font-size: 13px; color: var(--accent); }
.compact-doc .item-remove { margin-top: 4px; }
.compact-doc .item-tabs { margin: 2px 0 6px; }
.compact-doc .cost-items .form-grid { margin-top: 2px; }
.tabs.slim button { padding: 4px 12px; font-size: 13px; }
.tabs.slim { margin-bottom: 6px; }
.modal .body:has(.compact-doc) { padding: 8px 18px 6px; }
.modal:has(.compact-doc) header { padding: 8px 18px; }
.modal:has(.compact-doc) footer { padding: 8px 18px; }

/* order progress on a sales order line */
.op-card { border: 1px solid var(--line-soft); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; background: #fff; }
.op-card .steps { display: flex; align-items: flex-start; }
.op-card .st { display: flex; flex-direction: column; align-items: center; font-size: 11px; color: var(--muted); width: 84px; text-align: center; }
.op-card .st small { font-size: 11px; }
.op-card .dot { width: 18px; height: 18px; border-radius: 50%; background: var(--line-soft); border: 2px solid var(--line); color: #fff; font-size: 11px; display: flex; align-items: center; justify-content: center; margin-bottom: 2px; }
.op-card .st.done .dot { background: var(--ok); border-color: var(--ok); }
.op-card .st.now .dot { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.op-card .st.now { color: var(--accent); font-weight: 700; }
.op-card .ln { flex: 1; height: 2px; background: var(--line); margin-top: 9px; }
.op-card .ln.done { background: var(--ok); }
.pob { position: relative; height: 12px; border-radius: 6px; background: var(--line-soft); margin: 8px 0 4px; overflow: hidden; }
.pob i { position: absolute; top: 0; bottom: 0; }
.pob .pob-d { left: 0; background: var(--ok); }
.pob .pob-r { background: #9bd0b0; }
.pob .pob-q, .pob .pob-c { width: 2px; background: #14202b; }
.pob .pob-c { background: var(--warn, #b26a00); }
.op-note { font-size: 12px; color: var(--muted); }
.more-details > summary { cursor: pointer; font-size: 12px; color: var(--accent); padding: 2px 0; }
.more-details[open] .form-grid { margin: 6px 0; }
.op-card { padding: 4px 10px; margin-bottom: 4px; }
.pob { height: 8px; margin: 4px 0 2px; }
.op-card .st { flex-direction: row; gap: 4px; width: auto; flex: 0 0 auto; align-items: center; }
.op-card .st small { margin-left: 2px; }
.op-card .dot { margin-bottom: 0; }
.op-card .ln { margin-top: 0; margin-left: 6px; margin-right: 6px; min-width: 14px; }

/* jump search */
.jump-back { position: fixed; inset: 0; background: rgba(20, 32, 43, .45); z-index: 2000; display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; }
.jump-box { width: min(680px, 94vw); }
.jump-input { width: 100%; font-size: 18px; padding: 12px 16px; border: 2px solid var(--accent); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.jump-res { background: #fff; border-radius: 12px; margin-top: 8px; overflow: hidden; box-shadow: 0 8px 30px rgba(0,0,0,.2); max-height: 60vh; overflow-y: auto; }
.jump-row { display: flex; justify-content: space-between; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.jump-row.on, .jump-row:hover { background: var(--accent-soft); }
.jump-row small { color: var(--muted); }
.jump-kind { font-size: 12px; color: var(--muted); white-space: nowrap; }
.jump-empty { padding: 14px 16px; color: var(--muted); }

/* action tiles on Home */
.tiles-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 14px; }
.tile-card { flex: 1 1 150px; background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--line); border-radius: 12px; padding: 10px 14px; text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 2px; }
.tile-card:hover { box-shadow: var(--shadow); }
.tile-card .tl { font-size: 12px; color: var(--muted); }
.tile-card b { font-size: 26px; line-height: 1.1; }
.tile-card.warn { border-left-color: #d89a1c; } .tile-card.bad { border-left-color: var(--danger); } .tile-card.bad b { color: var(--danger); }
.tile-card.ok { border-left-color: var(--ok); } .tile-card.info { border-left-color: var(--accent); }
.pill.info { background: var(--accent-soft); color: var(--accent); }
.pill.grey { background: var(--line-soft); color: var(--muted); }
.pill.warn { color: #8a5a00; }

/* boards */
.board { display: grid; grid-template-columns: repeat(5, minmax(190px, 1fr)); gap: 10px; align-items: start; overflow-x: auto; }
.bcol, .dcol { background: #e6ebf0; border-radius: 10px; padding: 8px; min-height: 220px; }
.bcol h4, .dcol h4 { margin: 0 0 8px; display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.kcard { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 7px 9px; margin-bottom: 7px; font-size: 12px; cursor: pointer; }
.kcard b { font-size: 13px; display: block; }
.kcard.late { border-left-color: var(--danger); } .kcard.wait { border-left-color: #d89a1c; } .kcard.done { border-left-color: var(--ok); }
.week { display: grid; grid-template-columns: repeat(8, minmax(130px, 1fr)); gap: 8px; align-items: start; overflow-x: auto; }
.dcol.today { outline: 2px solid var(--accent); } .dcol.over { background: var(--accent-soft); }
.cust-cols { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
.card-box { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.card-box h3 { margin: 0 0 8px; font-size: 14px; color: var(--accent); }
@media (max-width: 860px) { .cust-cols { grid-template-columns: 1fr; } }
.age { display: inline-block; min-width: 52px; text-align: center; padding: 3px 8px; border-radius: 6px; font-weight: 600; }
.age.ok { background: var(--ok-soft); color: var(--ok); } .age.warn { background: var(--warn-soft); color: #8a5a00; }
.age.orange { background: #ffd9a8; color: #8a4b00; } .age.bad { background: var(--danger-soft); color: var(--danger); }

/* paper search window */
.paper-search { background: #f6f8fa; border: 1px solid var(--line-soft); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
.ps-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.ps-gap { flex: 1; }
.tol { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.tol-in { width: 64px; padding: 3px 6px; }
.paper-search select { padding: 3px 8px; }
.wst { display: inline-block; padding: 1px 8px; border-radius: 6px; font-weight: 600; }
.wst.lo { background: var(--ok-soft); color: var(--ok); } .wst.mid { background: var(--warn-soft); color: #8a5a00; } .wst.hi { background: var(--danger-soft); color: var(--danger); }
.paper-grid td, .paper-grid th { white-space: nowrap; }
.paper-search .tol-in, .paper-search input[type=number].tol-in { width: 64px; min-width: 0; flex: none; }
.paper-search .tol { flex: none; }
.paper-search select { width: auto; min-width: 130px; }

td.paper-det { min-width: 280px; max-width: 460px; white-space: normal; font-size: 12.5px; line-height: 1.35; }

.po-filters { gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.po-filters input[type=date] { padding: 3px 8px; min-height: 30px; width: auto; }
.po-filters .radios { display: inline-flex; gap: 10px; }
.po-filters .item-tick { font-weight: 600; background: var(--accent-soft); padding: 3px 10px; border-radius: 6px; }

.sched-top { background: var(--card, #fff); border-radius: 8px; padding: 10px 14px; margin-bottom: 10px; }
.sched-sum { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.sum-tile { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 6px 14px; text-align: left; font-size: 12px; color: var(--muted); cursor: pointer; display: flex; flex-direction: column; min-width: 110px; }
.sum-tile b { font-size: 20px; color: var(--text, #222); }
.sum-tile.on { background: var(--accent-soft); border-color: var(--accent); }
.sum-tile.static { cursor: default; border-left-color: var(--danger); }
.sched-wrap { max-height: none; }
table.sched td { vertical-align: top; }
.sched-job { margin-bottom: 6px; font-size: 12.5px; }
.sbar { display: flex; gap: 3px; margin-top: 4px; }
.sbar i { width: 30px; height: 6px; border-radius: 3px; background: #ddd; }
.sbar i.d { background: #2e9e4f; }
.sbar i.c { background: #e0a21a; }
.bad-text { color: var(--danger); }
.ok-text { color: var(--ok); }
.sched-go { margin: 6px 0; }
.sched-top select { width: auto; min-width: 200px; max-width: 360px; }
.toolbar select { width: auto; max-width: 260px; }
table.sched { width: 100%; table-layout: auto; }
table.sched td { white-space: normal; }
table.sched td:last-child { min-width: 250px; }

/* generic: hide an element */
.hidden { display: none !important; }

/* ---------- slimmer page bar and window title bar (Nov 2026) ---------- */
.topbar { padding: 4px 16px; min-height: 0; }
.topbar h1 { font-size: 15px; }
.topbar .btn, .topbar button { padding-top: 3px; padding-bottom: 3px; }
.tabbar { padding-top: 3px; }
.modal header { padding: 6px 14px; min-height: 0; }
.modal header h2 { font-size: 15px; }
.modal header:has(.hdr-rates:not([hidden])) h2 { flex: none; white-space: nowrap; }
/* the costing rates sit in the window's title bar, on one line */
.hdr-rates { flex: 1; min-width: 0; display: flex; justify-content: flex-end; }
.hdr-rates[hidden] { display: none; }
.result-strip.hdr { position: static; box-shadow: none; margin: 0; padding: 4px 10px; border-radius: 8px; font-size: 13px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; max-width: 100%; }
.result-strip.hdr .rs-name { font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-strip.hdr .rs-line { display: flex; flex-wrap: wrap; gap: 2px 14px; }
.result-strip.hdr .rs-one { white-space: nowrap; } .result-strip.hdr .rs-one b { font-size: 15px; }
.result-strip.hdr .rs-one.typed b { color: #b36b00; }
.result-strip.hdr .rs-meta { margin: 0; font-size: 12px; white-space: nowrap; }
.result-strip.hdr .rs-drop { position: relative; margin: 0; }
.result-strip.hdr .rs-drop > summary { cursor: pointer; font-size: 12px; white-space: nowrap; }
.result-strip.hdr .rs-drop[open] > :not(summary) { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 8px 12px; min-width: 320px; max-width: 70vw; color: var(--text, inherit); }
.result-strip.hdr.bad .rs-drop > summary { font-size: 13px; }
.result-strip.hdr ul { margin: 0 0 0 16px; }
@media (max-width: 860px) { .modal header { flex-wrap: wrap; } .hdr-rates { order: 3; flex-basis: 100%; justify-content: flex-start; } }
/* the title bar and buttons never get squeezed; only the form scrolls */
.modal header, .modal footer { flex: none; }
.modal .body { flex: 1 1 auto; min-height: 0; }

/* ---------- costing: the cost breakup beside the inputs ---------- */
.cost-split { display: grid; grid-template-columns: minmax(0, 1fr) fit-content(50%); gap: 14px; align-items: start; }
.cost-side:not(.folded) { min-width: 300px; }
.cost-split:has(.cost-side.folded) { grid-template-columns: minmax(0, 1fr) auto; }
.cost-main { min-width: 0; }
.cost-side { position: sticky; top: 0; max-height: calc(100dvh - var(--chrome-top, 0px) - 190px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; }
.cost-side.folded { padding: 4px; border: none; background: none; }
.cs-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; } .cs-head .btn { margin-left: auto; }
.cs-wrap { overflow-x: auto; }
.cs-table { border-collapse: collapse; width: 100%; }
.cs-table th, .cs-table td { padding: 3px 6px; border-bottom: 1px solid var(--line-soft); text-align: right; white-space: nowrap; }
.cs-table tbody th { text-align: left; font-weight: normal; color: var(--muted); white-space: normal; min-width: 100px; max-width: 150px; }
.cs-table thead th { background: #edf7f0; font-weight: 600; }
.cs-table tr.cs-sec th { text-align: left; color: var(--text, inherit); font-weight: 600; background: #f4f7fa; }
.cs-table tr.cs-total td, .cs-table tr.cs-total th { border-top: 1px solid var(--line); }
.cs-table tr.cs-rate td b { color: #1e7e34; font-size: 14px; }
.cs-note { margin: 6px 0 0; font-size: 11px; }
@media (max-width: 1100px) { .cost-split { grid-template-columns: minmax(0, 1fr); } .cost-side { position: static; max-height: none; } }

/* ---------- rate breakup card, laid out as on the Quote Desk ---------- */
.cost-split { grid-template-columns: minmax(0, 1fr) minmax(360px, 46%); }
.cost-split:has(.cost-side.folded) { grid-template-columns: minmax(0, 1fr) auto; }
.cost-side:not(.folded) { background: #fff; border: 1px solid #d3dbe2; border-radius: 6px; padding: 14px 16px; font-size: 13px; color: #14202b; min-width: 0; }
.qd-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.qd-head h3 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #5a6877; flex: 1; }
.qd-note { background: #fff1d6; border-left: 3px solid #a65f00; padding: 8px 12px; font-size: 13px; color: #14202b; margin-bottom: 10px; white-space: pre-line; }
.qd-tw { overflow-x: auto; }
.qd-rt { border-collapse: collapse; width: 100%; }
.qd-rt thead th { font-size: 14px; font-weight: 700; text-align: right; padding: 6px 8px; border-bottom: 2px solid #14202b; white-space: nowrap; }
.qd-rt td { font-size: 13px; padding: 6px 8px; border-bottom: 1px solid #d3dbe2; color: #5a6877; }
.qd-rt td.mono, .qd-rt td.q { font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace; text-align: right; color: #14202b; white-space: nowrap; }
.qd-rt tr.key td { font-weight: 600; background: #eaeef2; }
.qd-rt td.q input { width: 96px; background: #fff3b0; border: 1px solid #d4b800; border-radius: 4px; text-align: right; font-weight: 600;
  font-family: inherit; padding: 5px 8px; font-size: 13px; }
.qd-row { margin-top: 8px; font-size: 12px; color: #5a6877; } .qd-row small { display: block; font-size: 12px; }
.qd-link { display: inline-block; margin-top: 8px; color: #0b5c8e; font-weight: 600; text-decoration: none; }
.qd-sec { margin-top: 14px; padding-top: 10px; border-top: 1px solid #d3dbe2; }
.qd-sec h4 { margin: 0 0 6px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: #5a6877; }
.qd-sec p { margin: 2px 0; font-size: 13px; }
@media (max-width: 1100px) { .cost-split { grid-template-columns: minmax(0, 1fr); } }

/* ---------- folding the left menu away (PC) ---------- */
.nav-fold { display: none; font-size: 16px; line-height: 1; padding: 3px 9px; }
@media (min-width: 861px) {
  .nav-fold { display: inline-flex; }
  html.nav-folded .shell { grid-template-columns: minmax(0, 1fr); }
  html.nav-folded .sidebar { display: none; }
  html.nav-folded .modal-back { left: 0; }
}
/* rate breakup: paper / finish options */
.qd-opts, .qd-qtys { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; align-items: center; }
.qd-qtys { font-size: 12px; color: #5a6877; }
.qd-chip { border: 1px solid #d3dbe2; background: #f6f8fa; border-radius: 14px; padding: 4px 10px; font-size: 12px; cursor: pointer; color: #14202b; text-align: left; }
.qd-chip small { color: #5a6877; margin-left: 4px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.qd-chip.used { border-color: #1e7e34; }
.qd-chip.on { background: #14202b; color: #fff; border-color: #14202b; } .qd-chip.on small { color: #cfd8e0; }
.qd-chip.bad { color: #a65f00; border-style: dashed; }
.qd-chip.cmp { border-style: dashed; font-weight: 600; }
.qd-chip.small { padding: 2px 9px; }
.qd-rt thead th.used { color: #1e7e34; }
.qd-rt thead th .sub { font-size: 11px; font-weight: 500; color: #5a6877; white-space: nowrap; }
.qd-rt td.q b.best { color: #1e7e34; }
.qd-use { display: block; margin: 4px 0 0 auto; font-size: 11px; border: 1px solid #d3dbe2; background: #fff; border-radius: 4px; padding: 1px 6px; cursor: pointer; }
.qd-row .btn { margin-top: 6px; }
/* rate by option (as on the Quote Desk) */
.qd-byopt { margin: 0 0 12px; padding-top: 0; border-top: none; }
.qd-sh { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; } .qd-sh small { color: #5a6877; font-size: 12px; }
.qd-byopt thead th:first-child { text-align: left; }
.qd-optrow { cursor: pointer; } .qd-optrow:hover td { background: #f4f7fa; }
.qd-optrow small { color: #5a6877; } .qd-used { color: #1e7e34; font-weight: 600; }
.qd-err { color: #a33 !important; white-space: normal !important; text-align: left !important; }
.qd-byopt > small { display: block; margin-top: 4px; font-size: 12px; color: #5a6877; }

.pi-list { margin-top: 16px; } .pi-list h4 { margin: 0 0 6px; }
.nav-hide { display: none; }
@media (min-width: 861px) {
  .nav-hide { display: block; margin: 0 12px 8px auto; background: none; border: 1px solid rgba(255,255,255,.25); color: #cfd8e2;
    border-radius: 6px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
  .nav-hide:hover { background: rgba(255,255,255,.1); color: #fff; }
}

/* ---------- products and job cards: groups under heads, "label | value" rows (as the old job card) ---------- */
.sheet { display: grid; grid-template-columns: repeat(auto-fit, minmax(520px, 1fr)); gap: 12px 14px; align-items: start; }
.sheet-sec { border: 1px solid #c9d6e2; border-radius: 6px; overflow: hidden; background: #fff; min-width: 0; }
.sheet-sec:has(table) { grid-column: 1 / -1; }
.sheet-head { margin: 0; padding: 5px 10px; background: #4f8fb8; color: #fff; font-size: 12.5px; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase; }
.compact-doc .sheet-grid, .sheet-grid { display: grid; grid-template-columns: 1fr; gap: 0; padding: 0; }
.sheet-grid > .field { display: grid; grid-template-columns: minmax(130px, 42%) minmax(0, 1fr); align-items: center; gap: 0 8px;
  padding: 2px 10px; border-bottom: 1px solid #e3eaf0; min-height: 32px; grid-column: auto !important; }
.sheet-grid > .field:nth-child(odd) { background: #f7fafc; }
.sheet-grid > .field > .lbl { font-size: 12.5px; color: #33475b; margin: 0; }
.sheet-grid > .field > .lbl.has-tip { text-decoration: underline dotted #9fb3c4; text-underline-offset: 3px; cursor: help; }
.sheet-grid > .field > input, .sheet-grid > .field > select, .sheet-grid > .field > textarea { padding: 3px 7px; min-height: 28px; font-size: 13px; }
.sheet-grid > .field > textarea { min-height: 30px; }
.sheet-grid > .field > .err { grid-column: 2; }
.sheet-grid > .field > .err:empty { display: none; }
.sheet-grid > .field > .check { font-size: 12.5px; }
.sheet-grid > .field > .btn { grid-column: 2; justify-self: start; }
.sheet-grid > .wide { grid-column: 1 / -1; padding: 6px 10px; }
.sheet-grid > .wide > .lbl.sub { display: none; }
@media (max-width: 860px) { .sheet { grid-template-columns: 1fr; } }
/* groups flow down two columns with no gaps; a group with a table runs across the full width */
.sheet { display: block; columns: 2 480px; column-gap: 14px; }
.sheet-sec { break-inside: avoid; margin: 0 0 12px; display: block; }
.sheet-sec:has(table) { column-span: all; }
/* a group with many rows on a wide window (the product's own details) lays its rows out in columns too */
.sheet-sec.many .sheet-grid { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); column-gap: 0; }
.doc-head .sheet { columns: 1; }

/* testing copy of the ERP */
html.env-testing body::before { content: "TESTING VERSION - not the factory ERP. Nothing entered here is real."; position: fixed; top: 0; left: 0; right: 0; height: 18px; line-height: 18px; background: #c62828; color: #fff; text-align: center; font: 700 11px/18px system-ui, sans-serif; letter-spacing: .04em; z-index: 99999; pointer-events: none; }
html.env-testing body { padding-top: 18px; }
