
/* ── the batch trace ──────────────────────────────────────────────────────
 *
 * A chain, drawn as one: four stages down a rail. The rail is what makes it
 * read as a sequence rather than four cards that happen to be stacked.
 *
 * THE BROKEN STAGE LOOKS BROKEN. Dispatch cannot be joined to a batch — the
 * record simply does not carry it — and a stage the chain cannot walk is drawn
 * with a dashed rail and a rust dot, so the reader sees the chain stop before
 * reading why. A page that drew it like the other three would be claiming a
 * continuity that is not there.
 */
.trace-step { position: relative; padding-left: 2.1rem; padding-bottom: 1.6rem; }
.trace-step::before {
  content: ""; position: absolute; left: 0.52rem; top: 1.5rem; bottom: 0;
  width: 2px; background: var(--edge-2);
}
.trace-step:last-child::before { display: none; }
.trace-dot {
  position: absolute; left: 0; top: 0.55rem; width: 1.1rem; height: 1.1rem;
  border-radius: 50%; background: var(--green); border: 3px solid var(--deck);
}
.trace-step--broken .trace-dot { background: var(--rust); }
.trace-step--broken::before {
  background: repeating-linear-gradient(var(--rust) 0 4px, transparent 4px 9px);
}
.trace-k {
  font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-4); display: block;
}
.trace-h { font-size: 1.05rem; margin: 0.15rem 0 0.1rem; color: var(--ink); }
.trace-when { font-family: var(--mono); font-size: 0.72rem; color: var(--ink-3); }
.trace-body:not(:empty) { margin-top: 0.7rem; }
.trace-break {
  border-left: 3px solid var(--rust);
  background: color-mix(in srgb, var(--rust) 7%, transparent);
  padding: 0.7rem 0.9rem; border-radius: 0 6px 6px 0;
  font-size: 0.86rem; color: var(--ink-2);
}

/* ── the dashboard ─────────────────────────────────────────────────────────
 *
 * One plant day as three cards, each a hero with a row of drill toggles
 * beneath it. The markup and every measurement here follow the mock the owner
 * approved element by element (docs/mocks/production-dashboard.html), mapped
 * onto the app's own tokens.
 *
 * THE SPECIES COLOUR LAW (owner, 2026-08-21): shrimp wears the house green,
 * fish the house gold, other the neutral grey — at every level, bars, pies,
 * dots and legends alike. Nothing that is not a species may borrow those
 * hues, so materials, customers, products and godowns fill with their own
 * neutral, --material.
 */
.pdash { --material: #5b6357; max-width: 1080px; margin: 0 auto; }

/* the day selector, in the page-header row: the date alone, stepped by two
 * round buttons. The forward one is dead at the newest day the mirror holds. */
.pdash .daysel { display: flex; align-items: center; gap: 0.55rem; padding-top: 0.35rem; }
.pdash .day-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--edge-2);
  background: var(--panel); color: var(--ink-2); font-size: 1.05rem;
  display: flex; align-items: center; justify-content: center;
  padding: 0 0 2px; text-decoration: none;
}
.pdash .day-btn:hover { background: var(--rail); color: var(--ink); }
.pdash .day-btn[disabled] { opacity: 0.35; }
.pdash .day-btn[disabled]:hover { background: var(--panel); color: var(--ink-2); }
.pdash .day-cur { text-align: center; min-width: 10.5rem; }
.pdash .day-date { font-weight: 600; color: var(--ink); font-size: 0.95rem; white-space: nowrap; }

/* a card: hero figures above, drill toggles below, panels underneath */
.pdash .pcard {
  background: var(--panel); border: 1px solid var(--edge-2); border-radius: 14px;
  overflow: hidden; margin-bottom: 1.1rem;
}
.pdash .hero-top { display: grid; grid-template-columns: 1fr 2fr; align-items: stretch; }
.pdash .hero-num { padding: 1.6rem 2rem 1.5rem; min-width: 0; border-right: 1px solid var(--edge); }
.pdash .hero-k {
  font-family: var(--party-mono); font-size: 0.64rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-4); display: block; margin-bottom: 0.5rem;
}
.pdash .hero-v {
  font-size: 3.4rem; font-weight: 750; line-height: 1; color: var(--ink);
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.pdash .hero-v .unit, .pdash .rm-v .unit, .pdash .uval .unit {
  font-size: 1.15rem; font-weight: 600; color: var(--ink-3); margin-left: 0.35rem; letter-spacing: 0;
}
.pdash .hero-day {
  font-family: var(--party-mono); font-size: 0.68rem; color: var(--ink-3); margin-top: 0.65rem;
  font-variant-numeric: tabular-nums;
}

/* the species bars beside a hero */
.pdash .split {
  padding: 1.5rem 2rem 1.4rem; display: flex;
  flex-direction: column; justify-content: center; gap: 0.65rem; min-width: 0;
}
.pdash .srow { display: grid; grid-template-columns: 4.6rem 1fr 6.4rem; gap: 0.9rem; align-items: center; }
.pdash .srow .nm { font-size: 0.84rem; font-weight: 600; color: var(--ink); }
.pdash .srow .track { display: block; height: 0.62rem; background: var(--well); border-radius: 999px; overflow: hidden; }
.pdash .srow .fill { display: block; height: 100%; border-radius: 999px; min-width: 4px; }
.pdash .srow.shrimp .fill { background: var(--green); }
.pdash .srow.fish   .fill { background: var(--gold); }
.pdash .srow.other  .fill { background: var(--ink-4); }
.pdash .srow .val {
  font-family: var(--party-mono); font-size: 0.76rem; color: var(--ink-2); text-align: right;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.pdash .srow .val b { color: var(--ink); font-weight: 700; }

/* the raw-materials card's two heroes */
.pdash .rm-top { display: grid; grid-template-columns: 1fr 1fr; }
.pdash .rm-num { padding: 1.3rem 1.5rem 1.2rem; border-right: 1px solid var(--edge); }
.pdash .rm-num:last-child { border-right: 0; }
.pdash .rm-v {
  font-size: 2.5rem; font-weight: 740; line-height: 1; color: var(--ink);
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em; margin-top: 0.35rem;
}
.pdash .rm-note { font-family: var(--party-mono); font-size: 0.66rem; color: var(--ink-3); margin-top: 0.55rem; }

/* the drill toggles: a row of tabs, one open at a time per card */
.pdash .drills { display: flex; border-top: 1px solid var(--edge); background: var(--rail); }
.pdash .drill-btn {
  flex: 1 1 0; display: flex; align-items: center; justify-content: center; gap: 0.55rem;
  padding: 0.58rem 1rem; background: transparent; border: 0; border-right: 1px solid var(--edge);
  font-family: var(--party-mono); font-size: 0.68rem; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--ink-3); cursor: pointer;
}
.pdash .drill-btn:last-child { border-right: 0; }
.pdash .drill-btn:hover { background: var(--well); color: var(--ink); }
.pdash .drill-btn.on { background: var(--panel); color: var(--ink); font-weight: 600; }
.pdash .drill-btn .chev { transition: transform 0.18s ease; font-size: 0.8rem; }
.pdash .drill-btn.on .chev { transform: rotate(180deg); }
.pdash .drill-btn:focus-visible { outline: 2px solid var(--section-color); outline-offset: -2px; }

.pdash .panel { display: none; border-top: 1px solid var(--edge); }
.pdash .panel.on { display: block; }
.pdash .units.on { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

/* by unit: a pie per unit, in the species colours */
.pdash .ucard { padding: 1.3rem 1.5rem 1.5rem; border-right: 1px solid var(--edge); display: flex; gap: 1.1rem; align-items: center; }
.pdash .ucard:last-child { border-right: 0; }
.pdash .pie { width: 74px; height: 74px; border-radius: 50%; flex: 0 0 auto; position: relative; }
.pdash .pie::after { content: ""; position: absolute; inset: 21px; border-radius: 50%; background: var(--panel); }
.pdash .ustats { min-width: 0; }
.pdash .uname {
  font-family: var(--party-mono); font-size: 0.64rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-4); display: block; margin-bottom: 0.2rem;
}
.pdash .uval { font-size: 1.45rem; font-weight: 720; color: var(--ink); line-height: 1.1; font-variant-numeric: tabular-nums; }
.pdash .uval .unit { font-size: 0.78rem; margin-left: 0.2rem; }
.pdash .ushare { font-family: var(--party-mono); font-size: 0.68rem; color: var(--ink-3); margin-top: 0.15rem; font-variant-numeric: tabular-nums; }
.pdash .ulegend { display: flex; gap: 0.7rem; margin-top: 0.45rem; flex-wrap: wrap; }
.pdash .ulegend span {
  font-family: var(--party-mono); font-size: 0.63rem; color: var(--ink-3);
  display: inline-flex; align-items: center; gap: 0.3rem; font-variant-numeric: tabular-nums;
}
.pdash .ulegend i { width: 0.55rem; height: 0.55rem; border-radius: 3px; display: inline-block; }
.pdash .ulegend .shrimp i { background: var(--green); }
.pdash .ulegend .fish i { background: var(--gold); }
.pdash .ulegend .other i { background: var(--ink-4); }

/* a drilldown row: name, bar, tonnage, count — and the rows inside it */
.pdash .cat { border-bottom: 1px solid var(--edge); }
.pdash .cat:last-child { border-bottom: 0; }
.pdash .cat-head {
  width: 100%; display: grid; align-items: center; gap: 1rem; text-align: left;
  grid-template-columns: 15rem 1fr 8.5rem 6rem 1rem;
  padding: 0.72rem 1.5rem; background: transparent; border: 0; cursor: pointer;
  font: inherit; color: var(--ink-2);
}
.pdash .cat-head:hover { background: var(--rail); }
.pdash .cat-head:focus-visible { outline: 2px solid var(--section-color); outline-offset: -2px; }
/* a flat row is a fact, not a door: no hover, no pointer */
.pdash .cat-head.flat { cursor: default; }
.pdash .cat-head.flat:hover { background: transparent; }
.pdash .cat-nm { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; color: var(--ink); font-size: 0.9rem; }
/* the own-branch tag rides the name and never breaks into a block of its own */
.pdash .cat-nm .tag { white-space: nowrap; flex: 0 0 auto; }
.pdash .sdot { width: 0.5rem; height: 0.5rem; border-radius: 999px; flex: 0 0 auto; }
.pdash .sdot.shrimp { background: var(--green); }
.pdash .sdot.fish { background: var(--gold); }
.pdash .sdot.other { background: var(--ink-4); }
.pdash .cat-track { display: block; height: 0.5rem; background: var(--well); border-radius: 999px; overflow: hidden; }
.pdash .cat-fill { display: block; height: 100%; border-radius: 999px; min-width: 4px; }
.pdash .cat-fill.shrimp, .pdash .sku-fill.shrimp { background: var(--green); }
.pdash .cat-fill.fish, .pdash .sku-fill.fish { background: var(--gold); }
.pdash .cat-fill.other, .pdash .sku-fill.other { background: var(--ink-4); }
.pdash .cat-fill.material, .pdash .sku-fill.material { background: var(--material); }
.pdash .cat-val, .pdash .sku-val {
  font-family: var(--party-mono); font-size: 0.75rem; text-align: right;
  font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink-2);
}
.pdash .cat-val b, .pdash .sku-val b { color: var(--ink); font-weight: 700; }
.pdash .dim { color: var(--ink-4); }
.pdash .cat-n { font-family: var(--party-mono); font-size: 0.66rem; color: var(--ink-4); text-align: right; white-space: nowrap; }
.pdash .cat-chev { color: var(--ink-4); font-size: 0.8rem; transition: transform 0.18s ease; text-align: center; }
.pdash .cat.open .cat-chev { transform: rotate(180deg); }
.pdash .cat.open .cat-head { background: var(--rail); }

.pdash .skus { display: none; padding: 0.35rem 1.5rem 0.85rem 3.05rem; background: var(--rail); }
.pdash .cat.open .skus { display: block; }
.pdash .sku {
  display: grid; align-items: center; gap: 1rem;
  grid-template-columns: 1fr 7rem 10rem; padding: 0.26rem 0;
}
.pdash .sku-nm { font-size: 0.82rem; color: var(--ink-2); min-width: 0; overflow-wrap: anywhere; }
.pdash .sku-track { display: block; height: 0.34rem; background: var(--well); border-radius: 999px; overflow: hidden; }
.pdash .sku-fill { display: block; height: 100%; border-radius: 999px; opacity: 0.55; min-width: 4px; }

/* brand names are short; batch codes are longer and must not wrap; customer
 * and product names run longest. Each panel sizes its name column for what
 * it actually holds. */
.pdash .products .cat-head { grid-template-columns: 9.5rem 1fr 8.5rem 5.5rem 1rem; }
.pdash .bcode { font-family: var(--party-mono); font-size: 0.8rem; }
.pdash .batches .cat-head { grid-template-columns: 13.5rem 1fr 8.5rem 5.5rem 1rem; }
.pdash .batches .cat-nm { white-space: nowrap; }

/* the two bucket rows: the codeless bags and the unmapped doses. Styled to be
 * seen — they are the page's honesty, not its dregs. */
.pdash .cat.stray .cat-head { color: var(--ink-3); }
.pdash .cat.stray .bcode { font-style: italic; }
.pdash .cat.unmapped-row .cat-nm { font-style: italic; color: var(--ink-3); }

/* customer, product and godown names run long: give the name column room */
.pdash .wide .cat-head { grid-template-columns: 22rem 1fr 8.5rem 6rem 1rem; }

/* one column when the screen is narrow */
@media (max-width: 760px) {
  .pdash .daysel { width: 100%; justify-content: space-between; }
  .pdash .hero-top { grid-template-columns: 1fr; }
  .pdash .hero-num { border-right: 0; border-bottom: 1px solid var(--edge); padding: 1.4rem 1.25rem 1.2rem; }
  .pdash .split { padding: 1.25rem 1.25rem 1.2rem; }
  .pdash .srow { grid-template-columns: 4rem 1fr; row-gap: 0.25rem; }
  .pdash .srow .val { grid-column: 2; text-align: left; }
  .pdash .units.on { grid-template-columns: 1fr; }
  .pdash .drills { flex-direction: column; }
  .pdash .drill-btn { border-right: 0; border-bottom: 1px solid var(--edge); }
  .pdash .drill-btn:last-child { border-bottom: 0; }
  .pdash .cat-head, .pdash .products .cat-head,
  .pdash .wide .cat-head, .pdash .batches .cat-head {
    grid-template-columns: 1fr auto; row-gap: 0.3rem; padding: 0.8rem 1.1rem;
  }
  .pdash .cat-track { grid-column: 1 / -1; }
  .pdash .cat-val { grid-column: 1; text-align: left; }
  .pdash .cat-n { grid-column: 2; }
  .pdash .cat-chev { display: none; }
  .pdash .skus { padding: 0.35rem 1.1rem 0.85rem 1.6rem; }
  .pdash .sku { grid-template-columns: 1fr; gap: 0.1rem; padding: 0.4rem 0; }
  .pdash .sku-val { text-align: left; }
  .pdash .sku-track { display: none; }
  .pdash .rm-top { grid-template-columns: 1fr; }
  .pdash .rm-num { border-right: 0; border-bottom: 1px solid var(--edge); }
  .pdash .rm-num:last-child { border-bottom: 0; }
  .pdash .ucard { border-right: 0; border-bottom: 1px solid var(--edge); padding: 1.15rem 1.25rem; }
  .pdash .ucard:last-child { border-bottom: 0; }
}
