/* Direction: "The Ledger Book", in its working register. The design documents are the
   book being read; the screens are the book being written in. Same paper, ink, and
   faces as docs/assets/docs.css. Dense, ruled, numbers in mono. Red means one of two
   things only: a quantity going out, or something that needs a person. The screens
   carry no explanation of themselves; that is written on the BuddyBot Labs page, next
   to a screenshot. No motion. */

:root {
  --paper: #f3f5ee;
  --sheet: #fafbf6;
  --ink: #1b2430;
  --ink-soft: #4d5866;
  --ink-faint: #8a9388;
  --rule: #c5d1c0;
  --rule-soft: #dde4d8;
  --margin-red: #bf4438;
  --link: #1f4a7d;
  --tint: #e6ecdf;
  --mark: #fdf0a6;

  --serif: Charter, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Avenir Next", Avenir, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  --rail-w: 196px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 13px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); }
a:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.num { font-family: var(--mono); font-size: 11.5px; font-variant-numeric: tabular-nums; }

.app {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------- Rail: the screens ---------- */

.rail {
  padding: 22px 14px 40px 18px;
  border-right: 1px solid var(--rule);
}

.rail-name { margin: 0; font-size: 14px; font-weight: 700; }

.rail-concept {
  margin: 4px 0 22px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--ink-soft);
}

.rail-label {
  margin: 0 0 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.rail ol { margin: 0 0 24px; padding: 0; list-style: none; counter-reset: s; }

.rail li {
  counter-increment: s;
  display: grid;
  grid-template-columns: 22px 1fr;
  padding: 4px 0;
  border-top: 1px solid var(--rule-soft);
  color: var(--ink-faint);
}

.rail li::before {
  content: counter(s);
  font-family: var(--mono);
  font-size: 11px;
  padding-top: 1px;
}

.rail li a { color: var(--ink); text-decoration: none; }
.rail li a:hover { text-decoration: underline; }
.rail li.here { color: var(--ink); font-weight: 600; }
.rail li.here::before { color: var(--margin-red); }

.rail-docs { font-size: 12.5px; }

/* ---------- Main ---------- */

.main { padding: 0 0 60px; min-width: 0; }

.bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 24px;
  padding: 9px 20px;
  border-bottom: 1px solid var(--rule);
  font-size: 12px;
  color: var(--ink-soft);
}

.bar .crumbs span + span::before { content: "/"; margin: 0 7px; color: var(--ink-faint); }
.bar strong { color: var(--ink); font-weight: 600; }

.item { padding: 20px 20px 0; }

.item h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.item h1 .num { margin-left: 10px; font-size: 13px; font-weight: 400; color: var(--ink-soft); letter-spacing: 0; }

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 0;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  color: var(--ink-soft);
}

.facts li + li::before { content: "\00b7"; margin: 0 8px; color: var(--ink-faint); }

/* On hand, by place. Set in a ruled strip; the total is the widest cell. */

.onhand {
  display: grid;
  grid-template-columns: 1.3fr repeat(4, 1fr);
  margin: 18px 20px 0;
  border: 1px solid var(--rule);
  background: var(--sheet);
}

.onhand > div { padding: 10px 14px 11px; border-left: 1px solid var(--rule-soft); position: relative; }
.onhand > div:first-child { border-left: 0; }

.onhand dt {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.onhand dd { margin: 3px 0 0; }
.onhand .q { font-family: var(--mono); font-size: 22px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.onhand .total .q { font-size: 28px; }
.onhand .sub { display: block; font-size: 11.5px; color: var(--ink-soft); }
.onhand .open .q { color: var(--margin-red); }

/* ---------- Sections and tables ---------- */

.sec { margin: 26px 20px 0; }

.sec-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 20px;
  margin-bottom: 7px;
}

.sec h2 { margin: 0; font-size: 14px; font-weight: 600; }
.sec .carried { margin: 0 0 8px; color: var(--ink-soft); max-width: 78ch; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 12px; color: var(--ink-soft); }

.filters select {
  font: 12px var(--sans);
  color: var(--ink);
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 0;
  padding: 3px 6px;
}

.filters output { font-family: var(--mono); font-size: 11.5px; color: var(--ink); min-width: 25ch; text-align: right; }

.scroll { overflow-x: auto; border: 1px solid var(--rule); background: var(--sheet); }

table { border-collapse: collapse; width: 100%; }

th, td {
  padding: 4px 7px;
  text-align: left;
  vertical-align: baseline;
  white-space: nowrap;
  border-left: 1px solid var(--rule-soft);
  border-top: 1px solid var(--rule-soft);
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  border-top: 0;
  border-bottom: 1px solid var(--ink-soft);
  background: var(--tint);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

tbody tr:first-child td { border-top: 0; }
tbody tr:hover td { background: var(--tint); }

.r { text-align: right; }
td.cause { white-space: normal; min-width: 20ch; color: var(--ink-soft); }
td.id { color: var(--ink-soft); }
td.b { color: var(--ink-soft); }

tr.neg .q { color: var(--margin-red); }
tr.voided td, tr.reversal td { background: var(--tint); }
tr[hidden] { display: none; }

.lots td, .lots th { white-space: nowrap; }

/* The rail stays put while a long table scrolls past. */
@media (min-width: 821px) {
  .rail { position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto; }
}

/* ---------- Narrower windows ---------- */

@media (max-width: 820px) {
  .app { display: block; }
  .rail { border-right: 0; border-bottom: 1px solid var(--rule); padding-bottom: 8px; }
  .rail ol { columns: 2; column-gap: 20px; }
  .rail li { break-inside: avoid; }
  .onhand { grid-template-columns: 1fr 1fr; }
  .onhand > div { border-top: 1px solid var(--rule-soft); }
  .onhand .total { grid-column: 1 / -1; border-top: 0; }
  .item, .bar { padding-left: 16px; padding-right: 16px; }
  .onhand, .sec { margin-left: 16px; margin-right: 16px; }
}

/* ---------- Inventory dashboard ---------- */

.split { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); }
.split .today { margin-left: 8px; }

.count { margin-left: 6px; font-family: var(--mono); font-size: 12px; color: var(--margin-red); }

/* A ruled list with a red margin, like entries waiting to be dealt with. */
.attention ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: a;
  border: 1px solid var(--rule);
  background: var(--sheet);
}

.attention li {
  counter-increment: a;
  position: relative;
  padding: 7px 14px 7px 44px;
  border-top: 1px solid var(--rule-soft);
  line-height: 1.5;
}

.attention li:first-child { border-top: 0; }

.attention li::before {
  content: counter(a);
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 30px;
  padding-top: 8px;
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--margin-red);
  border-right: 1px solid var(--margin-red);
}

.attention .act { color: var(--ink-soft); }
.attention strong { font-weight: 600; }

.today dl { margin: 0; border: 1px solid var(--rule); background: var(--sheet); }
.today dl > div { padding: 8px 14px 9px; border-top: 1px solid var(--rule-soft); }
.today dl > div:first-child { border-top: 0; }
.today dt { font-size: 10.5px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-soft); }
.today dd { margin: 2px 0 0; }
.today .sub { display: block; font-size: 11.5px; color: var(--ink-soft); }
.today .sub .num { font-size: 11px; }

#items td.neg { color: var(--margin-red); font-weight: 600; }
#items td.z { color: var(--ink-faint); }
#items td.t { color: var(--ink); font-weight: 600; }
#items td.unit, #items td.rep { color: var(--ink-soft); }
#items td.note { white-space: normal; min-width: 24ch; color: var(--ink-soft); }
#items td.note.flag { color: var(--margin-red); }
#items tr.group th {
  position: static;
  padding-top: 12px;
  border-bottom: 1px solid var(--rule);
  background: var(--sheet);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}
#items tr.group th + th { border-left: 0; }
#items tr.group th.num { font-weight: 400; font-size: 11.5px; }

.check { display: inline-flex; align-items: center; gap: 5px; }

@media (max-width: 1000px) {
  .split { grid-template-columns: 1fr; }
  .split .today { margin-left: 20px; }
}

/* ---------- Shared by the record screens (batch, order, route, and so on) ---------- */

.item .status { margin-left: 10px; font: 600 11px var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); vertical-align: 3px; }
.item .status.warn { color: var(--margin-red); }

.cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.cols.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.cols > .sec + .sec { margin-left: 8px; }

.kv { margin: 0; border: 1px solid var(--rule); background: var(--sheet); }
.kv > div { display: grid; grid-template-columns: 38% 1fr; padding: 6px 12px; border-top: 1px solid var(--rule-soft); }
.kv > div:first-child { border-top: 0; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; }
.kv .sub, td .sub { display: block; font-size: 11.5px; color: var(--ink-soft); }

.sec > p.lead { margin: 0 0 8px; color: var(--ink-soft); max-width: 86ch; }

td.wrap { white-space: normal; min-width: 22ch; }
td.soft, th.soft { color: var(--ink-soft); }
td.warn, span.warn { color: var(--margin-red); }
tfoot td { border-top: 1px solid var(--ink-soft); font-weight: 600; background: var(--tint); }

/* a run of steps with times: what has happened to this record, in order */
.steps { display: flex; flex-wrap: wrap; margin: 18px 20px 0; padding: 0; list-style: none; border: 1px solid var(--rule); background: var(--sheet); }
.steps li { flex: 1 1 0; min-width: 130px; padding: 8px 12px 9px; border-left: 1px solid var(--rule-soft); }
.steps li:first-child { border-left: 0; }
.steps .what { display: block; font-weight: 600; }
.steps .when { display: block; font-family: var(--mono); font-size: 11.5px; color: var(--ink-soft); }
.steps .who { display: block; font-size: 11.5px; color: var(--ink-soft); }
.steps li.todo { color: var(--ink-faint); }
.steps li.todo .what { font-weight: 400; }
.steps li.now { box-shadow: inset 0 -2px 0 var(--margin-red); }

@media (max-width: 1000px) {
  .cols, .cols.even { grid-template-columns: 1fr; }
  .cols > .sec + .sec { margin-left: 20px; }
}

/* ---------- POS ---------- */

.pos { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) 330px; align-items: start; margin: 18px 20px 0; border: 1px solid var(--rule); background: var(--sheet); }
.pos > section { padding: 12px 14px 16px; border-left: 1px solid var(--rule); min-height: 560px; }
.pos > section:first-child { border-left: 0; }
.pos h2 { margin: 0 0 8px; font-size: 14px; font-weight: 600; }
.pos h3 { margin: 14px 0 6px; font-size: 10.5px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-soft); }

.tabs { display: flex; flex-wrap: wrap; gap: 0; margin: 0 0 10px; padding: 0; list-style: none; border-bottom: 1px solid var(--ink-soft); }
.tabs li { padding: 6px 12px; color: var(--ink-soft); }
.tabs li.on { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--ink); }

.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.keys.two { grid-template-columns: repeat(2, 1fr); }
.key { padding: 9px 10px 10px; border: 1px solid var(--rule); background: var(--paper); line-height: 1.3; }
.key b { display: block; font-weight: 600; }
.key span { display: block; font-family: var(--mono); font-size: 11.5px; color: var(--ink-soft); }
.key.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--sheet); }
.key.off { color: var(--ink-faint); }
.key.off span { color: var(--ink-faint); }

.ticket { margin: 0; padding: 0; list-style: none; }
.ticket > li { padding: 8px 0; border-top: 1px solid var(--rule-soft); display: grid; grid-template-columns: 1fr auto; gap: 0 10px; }
.ticket > li:first-child { border-top: 0; }
.ticket > li.sel { box-shadow: -14px 0 0 var(--tint), 14px 0 0 var(--tint); background: var(--tint); }
.ticket b { font-weight: 600; }
.ticket .mods { grid-column: 1 / -1; margin: 2px 0 0; padding: 0; list-style: none; color: var(--ink-soft); display: grid; grid-template-columns: 1fr auto; gap: 0 10px; }
.ticket .mods span:nth-child(even) { font-family: var(--mono); font-size: 11.5px; text-align: right; }
.totals { margin: 8px 0 0; border-top: 1px solid var(--ink-soft); padding-top: 6px; }
.totals > div { display: flex; justify-content: space-between; padding: 2px 0; }
.totals dt { color: var(--ink-soft); }
.totals dd { margin: 0; font-family: var(--mono); font-size: 12px; }
.totals .due { margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--rule); font-weight: 600; }
.totals .due dt { color: var(--ink); }
.totals .due dd { font-size: 18px; }
.pay { margin-top: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pay .key { text-align: center; font-weight: 600; }
.pay .key.go { grid-column: 1 / -1; background: var(--ink); color: var(--sheet); border-color: var(--ink); }

@media (max-width: 1100px) {
  .pos { grid-template-columns: 1fr; }
  .pos > section { border-left: 0; border-top: 1px solid var(--rule); min-height: 0; }
}

/* ---------- Map of the operation ---------- */

.opmap { margin: 18px 20px 0; border: 1px solid var(--rule); background: var(--sheet); }
.opmap svg { display: block; width: 100%; height: auto; }
.opmap rect { fill: var(--paper); stroke: var(--ink-soft); stroke-width: 1; }
.opmap rect.hub { fill: var(--tint); stroke: var(--ink); stroke-width: 1.5; }
.opmap a:hover rect { stroke: var(--link); stroke-width: 2; }
.opmap text { font-family: var(--sans); font-size: 13px; fill: var(--ink); }
.opmap text.t { font-weight: 600; }
.opmap text.n { font-family: var(--mono); font-size: 11.5px; fill: var(--ink-soft); }
.opmap text.warn { fill: var(--margin-red); }
.opmap text.band { font-size: 10.5px; font-weight: 600; letter-spacing: 0.09em; fill: var(--ink-faint); }
.opmap path { fill: none; stroke: var(--ink-soft); stroke-width: 1.2; }
.opmap path.money { stroke-dasharray: 5 4; }
.opmap marker path { fill: var(--ink-soft); stroke: none; }
.opmap line.rule { stroke: var(--margin-red); stroke-width: 1; }

/* ---------- Tucking the rail away ---------- */

.rail-toggle {
  font: 600 11px var(--sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: none;
  border: 1px solid var(--rule);
  padding: 2px 8px;
  margin-right: 4px;
  cursor: pointer;
}
.rail-toggle:hover { color: var(--ink); border-color: var(--ink-soft); }
.bar { justify-content: flex-start; align-items: center; }
.bar > div:last-child { margin-left: auto; }
body.rail-closed .app { display: block; }
body.rail-closed .rail { display: none; }

/* ---------- Arriving from a link that points at one thing: mark it ---------- */

:target { scroll-margin-top: 80px; }
tr:target > td, tr:target > th { background: var(--mark); }
.onhand > div:target, .kv > div:target, .ticket > li:target, .attention li:target { background: var(--mark); }
.ticket > li:target { box-shadow: -14px 0 0 var(--mark), 14px 0 0 var(--mark); }

@media (max-width: 820px) {
  .cols > .sec + .sec, .split .today { margin-left: 16px; }
  .pos, .steps, .opmap { margin-left: 16px; margin-right: 16px; }
}
