/* Zamna Farms — papaya export traceability. Warm paper background, leaf-green shell, papaya-orange actions. */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --sunk: #faf8f4;
  --ink: #1c1917;
  --ink-2: #3f3a33;
  --muted: #6e665b;
  --line: #e9e4da;
  --line-strong: #d8d0c2;
  --brand: #c2410c;
  --brand-hover: #9a3412;
  --brand-ink: #ffffff;
  --brand-soft: #fff1e6;
  --brand-glow: #fed7aa;
  --leaf: #0f2a1e;
  --leaf-2: #173a2a;
  --leaf-ink: #d6e5da;
  --leaf-muted: #8fac98;
  --good: #15803d;
  --good-soft: #e8f6ed;
  --warn: #b45309;
  --warn-soft: #fef4e2;
  --bad: #b91c1c;
  --bad-soft: #fdeceb;
  --info: #1d4ed8;
  --info-soft: #eaf0fe;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(28, 25, 23, 0.05), 0 1px 1px rgba(28, 25, 23, 0.03);
  --shadow-lg: 0 18px 50px rgba(28, 25, 23, 0.22);
  --font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --tabbar-h: 0px;
  --safe-b: 0px;
  color-scheme: light;
}

@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 120ms; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); font-variant-numeric: tabular-nums; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 23px; font-weight: 700; }
h2 { font-size: 15.5px; font-weight: 650; }
h3 { font-size: 14px; }
p { margin: 0 0 12px; }
small, .muted { color: var(--muted); }
.small { font-size: 12.5px; }
.block { display: block; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.pre, .prewrap { white-space: pre-wrap; }
code { font-family: var(--mono); font-size: 0.92em; }
code.tlc { background: var(--brand-soft); color: var(--brand-hover); padding: 1px 6px; border-radius: 6px; font-weight: 600; white-space: nowrap; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pos, .good { color: var(--good); }
.neg, .bad { color: var(--bad); }
td.warn, .warn { color: var(--warn); }
svg { flex: none; }

/* ---- shell ---- */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--leaf); color: var(--leaf-ink); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; color: #fff; font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand img { width: 36px; height: 36px; border-radius: 10px; background: #fff; }
.brand span { line-height: 1.15; font-size: 15px; }
.brand small { display: block; color: var(--leaf-muted); font-weight: 500; font-size: 11px; }
.btn.new-load { width: 100%; margin: 0 0 10px; background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.new-load:hover { background: var(--brand-hover); }
.side-search { position: relative; padding: 0 0 10px; }
.side-search > svg { position: absolute; left: 10px; top: 10px; width: 16px; height: 16px; color: var(--leaf-muted); pointer-events: none; }
.side-search input { min-height: 36px; padding: 6px 10px 6px 32px; border-radius: 9px; border: 1px solid #2a4a39; background: var(--leaf-2); color: #fff; font-size: 13px; }
.side-search input::placeholder { color: var(--leaf-muted); }
.nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.nav .group { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--leaf-muted); padding: 14px 10px 4px; font-weight: 600; }
.nav a { color: var(--leaf-ink); padding: 7px 10px; border-radius: 8px; display: flex; align-items: center; gap: 10px; position: relative; }
.nav a:hover { background: var(--leaf-2); text-decoration: none; color: #fff; }
.nav a.on { background: rgba(254, 215, 170, 0.14); color: #fff; font-weight: 600; }
.nav a.on::before { content: ''; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: #fb923c; }
.nav svg { width: 17px; height: 17px; opacity: 0.85; }
.side form { margin: 0; }
.side .who { border-top: 1px solid #23432f; margin-top: 14px; padding: 12px 6px 0; font-size: 13px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.who-name { display: flex; align-items: center; gap: 8px; color: var(--leaf-ink); min-width: 0; }
.who-name:hover { text-decoration: none; color: #fff; }
.who-name .avatar { width: 30px; height: 30px; font-size: 13px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--leaf-muted); cursor: pointer; font: inherit; }
.linkbtn:hover { color: inherit; text-decoration: underline; }
.side .linkbtn svg { width: 18px; height: 18px; }

main { padding: 24px 32px 64px; width: 100%; min-width: 0; max-width: 1480px; }
.appbar, .tabbar { display: none; }

/* ---- page header ---- */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.head h1 .badge { font-size: 12.5px; }
.head p { margin: 4px 0 0; color: var(--muted); max-width: 820px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 6px; }
.crumbs .sep { color: var(--line-strong); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---- surfaces ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.pad { padding: 16px; }
.pad-x { padding-left: 16px; padding-right: 16px; }
.card + .card, .card + .grid, .grid + .card, .stats + .card, .pills + .card, .card + .stats, form + .card, .card + form { margin-top: 16px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); min-height: 52px; }
.card-h h2 { display: flex; align-items: center; gap: 9px; }
.card-h h2 svg { width: 18px; height: 18px; color: var(--brand); }
.card-h .actions a:not(.btn) { font-size: 13px; font-weight: 600; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: grid; gap: 16px; align-content: start; min-width: 0; }
.stack > .card + .card { margin-top: 0; }
.split { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.span-2 { grid-column: 1 / -1; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { padding: 14px 16px; display: block; color: var(--ink); container-type: inline-size; }
.stat.link:hover { text-decoration: none; border-color: var(--brand-glow); }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat .value { font-size: clamp(14px, 11.5cqi, 22px); font-weight: 700; margin-top: 2px; letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
dl.facts.cols { grid-template-columns: max-content 1fr max-content 1fr; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; background: var(--sunk); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fdfbf8; }
td.num, th.num { text-align: right; white-space: nowrap; }
tfoot td { font-weight: 650; border-top: 1px solid var(--line-strong); border-bottom: 0; background: var(--sunk); }
tr[data-href] { cursor: pointer; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.empty-cta { display: grid; justify-items: center; gap: 10px; padding: 32px 16px; text-align: center; color: var(--muted); }
.empty-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.empty-icon svg { width: 24px; height: 24px; }

/* ---- badges ---- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 650; background: #f0ece4; color: var(--ink-2); white-space: nowrap; line-height: 1.5; }
.badge.dot::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.8; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.brand { background: var(--brand-soft); color: var(--brand-hover); }
.badge.info { background: var(--info-soft); color: var(--info); }

/* ---- forms ---- */
form { margin: 0; }
form.inline { display: inline; }
.form { display: grid; gap: 14px; }
label { display: grid; gap: 5px; font-weight: 600; font-size: 13px; color: var(--ink-2); align-content: start; min-width: 0; }
label .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.req { color: var(--bad); font-weight: 700; }
.fgrid { display: grid; gap: 14px 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.fgrid > * { min-width: 0; }
.fgrid > .wide { grid-column: 1 / -1; }
.fgrid + .fgrid, .fgrid + details, .fgrid + .lines-wrap, .lines-wrap + .live, .live + details, details + details, .fgrid + fieldset, fieldset + details, details + label, .lines-wrap + label, label + p { margin-top: 16px; }
@supports (grid-template-rows: subgrid) {
  .fgrid > label:not(.check):not(.chip) { grid-row: span 2; grid-template-rows: subgrid; row-gap: 5px; }
  .fgrid > label:not(.check) > span:first-child { align-self: end; }
}
input, select, textarea { font: inherit; color: inherit; width: 100%; padding: 8px 11px; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; min-height: 40px; min-width: 0; max-width: 100%; }
textarea { min-height: 72px; resize: vertical; }
input[type='date'], input[type='datetime-local'], input[type='time'] { display: block; }
@supports (-webkit-touch-callout: none) {
  input[type='date'], input[type='datetime-local'] { -webkit-appearance: none; appearance: none; text-align: left; line-height: 1.4; }
  input::-webkit-date-and-time-value { text-align: left; margin: 0; min-height: 1.4em; }
}
input:focus, select:focus, textarea:focus { outline: 3px solid var(--brand-glow); outline-offset: 0; border-color: var(--brand); }
input[type='checkbox'], input[type='radio'] { width: 18px; height: 18px; min-height: 0; padding: 0; flex: none; accent-color: var(--brand); }
input[readonly] { background: var(--sunk); }
input[type='file'] { padding: 6px; font-size: 13px; }
.check { display: flex; align-items: center; gap: 9px; font-weight: 500; }
.checkfield { align-self: end; }
label.invalid input, label.invalid select, label.invalid textarea, input.invalid { border-color: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 15%, transparent); }
.field-error { display: block; color: var(--bad); font-size: 12.5px; margin-top: 4px; font-weight: 500; }
.w-xs { max-width: 80px; }
.w-sm, .w-num { max-width: 110px; }
.w-pallet { max-width: 130px; }

/* a number with its unit inside the box, and a live conversion under it */
.unit-input { position: relative; display: block; }
.unit-input input { padding-right: 44px; }
.unit-input .unit { position: absolute; right: 11px; top: 0; height: 40px; display: flex; align-items: center; color: var(--muted); font-weight: 600; font-size: 13px; pointer-events: none; }
.unit-input .unit.pre { left: 11px; right: auto; }
.unit-input:has(.unit.pre) input { padding-left: 24px; padding-right: 11px; }
.conv { display: block; font-size: 12px; color: var(--muted); min-height: 1.2em; margin-top: 3px; font-weight: 500; }
.with-now { display: flex; gap: 6px; }
.with-now input { flex: 1; }

/* chips (several choices, e.g. a partner's roles) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; flex-direction: row; align-items: center; gap: 7px; padding: 7px 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: #fff; cursor: pointer; font-weight: 550; }
.chip:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-hover); }

details > summary { cursor: pointer; font-weight: 650; color: var(--brand); padding: 2px 0; }
details[open] > summary { margin-bottom: 12px; }
details.more { border-top: 1px dashed var(--line-strong); padding-top: 12px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset > legend { font-weight: 700; font-size: 14px; padding: 0; margin-bottom: 10px; }
fieldset.money-block { background: var(--sunk); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
fieldset.money-block > legend { float: left; width: 100%; margin-bottom: 10px; }
fieldset.money-block > legend + * { clear: both; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: inherit; font-weight: 650; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line-strong); background: #fff; color: var(--ink); cursor: pointer; min-height: 40px; white-space: nowrap; text-decoration: none; }
.btn:hover { text-decoration: none; background: var(--sunk); border-color: #c9bfae; }
.btn:focus-visible { outline: 3px solid var(--brand-glow); outline-offset: 1px; }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); box-shadow: 0 1px 2px rgba(154, 52, 18, 0.25); }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.danger { color: var(--bad); border-color: #efc4c1; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.sm { padding: 4px 10px; min-height: 32px; font-size: 13px; border-radius: 8px; }
.btn.sm svg { width: 15px; height: 15px; }
.btn.lg { min-height: 46px; padding: 10px 20px; font-size: 15px; }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover { background: #f1ede5; }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.alert { padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; border: 1px solid; }
.alert.error { background: var(--bad-soft); border-color: #f2c5c2; color: #8c1616; }
.alert.ok { background: var(--good-soft); border-color: #bfe5cb; color: #135f30; }
.alert.info { background: var(--brand-soft); border-color: var(--brand-glow); color: var(--brand-hover); }
.alert-link { font-weight: 700; color: inherit; text-decoration: underline; margin-left: 6px; }
.copy-row { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.copy-row input { flex: 1 1 260px; min-height: 34px; font-family: var(--mono); font-size: 12.5px; }

/* form card with a sticky save bar */
.form-card { padding-bottom: 0; }
.savebar { position: sticky; bottom: 0; z-index: 5; display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; margin: 18px -16px 0; padding: 12px 16px; background: rgba(255, 255, 255, 0.96); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }
.danger-zone { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line-strong); display: flex; justify-content: flex-end; }

/* pickers with "+ New" */
.select-add { display: flex; gap: 6px; align-items: stretch; min-width: 0; }
.select-add select, .select-add .combo { flex: 1; min-width: 0; }
.select-add .quick { padding: 0 11px; color: var(--brand); font-weight: 700; flex: none; }
.select-add .quick.sm { min-height: 0; padding: 0 10px; font-size: 16px; }
.filters .quick { display: none; }

/* type to search over a long <select> (app.js) */
.combo { position: relative; display: block; flex: 1; min-width: 0; }
.combo-native { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.combo-input { padding-right: 28px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236e665b' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center; text-overflow: ellipsis; }
.combo.invalid .combo-input { border-color: var(--bad); }
.combo-list { position: fixed; z-index: 60; top: 0; left: 0; width: max-content; max-width: min(92vw, 520px); max-height: 300px; overflow: auto; margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: 0 10px 28px rgba(28, 25, 23, 0.16); }
.combo-list li { padding: 8px 10px; border-radius: 7px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-list li[aria-selected='true'] { font-weight: 700; }
.combo-list li.active { background: var(--brand-soft); }
.combo-list li.combo-note { color: var(--muted); cursor: default; font-size: 13px; white-space: normal; }

/* dialogs: quick add and "are you sure?" */
dialog.quick-dialog { border: 0; border-radius: 16px; padding: 0; width: min(760px, 96vw); max-height: 92vh; box-shadow: var(--shadow-lg); overflow: hidden; }
dialog.quick-dialog::backdrop, dialog.ask-dialog::backdrop { background: rgba(15, 42, 30, 0.45); }
dialog.quick-dialog header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
dialog.quick-dialog iframe { display: block; width: 100%; height: 360px; max-height: calc(92vh - 54px); border: 0; background: var(--bg); }
dialog.ask-dialog { border: 0; border-radius: 16px; padding: 20px; width: min(420px, 92vw); box-shadow: var(--shadow-lg); }
dialog.ask-dialog p { margin: 0 0 18px; font-size: 15px; line-height: 1.5; }
dialog.ask-dialog .btn-row { justify-content: flex-end; }
body.embed { background: var(--bg); }
body.embed main { padding: 16px; max-width: none; }
body.embed .crumbs, body.embed .head .actions, body.embed .head h1, body.embed .appbar { display: none !important; }
body.embed .head { margin-bottom: 10px; }
body.embed .head:not(:has(p)) { display: none; }

/* line-item editors */
.lines td { padding: 6px 8px; vertical-align: middle; }
.lines input, .lines select { min-width: 80px; }
.lines tfoot td { vertical-align: middle; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.filters input, .filters select { width: auto; flex: 1 1 160px; }
.filters input[type='search'] { flex: 3 1 260px; }
.js .filters[data-autosubmit] > .btn { display: none; }

/* filter pills */
.pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.pills a { padding: 6px 13px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--ink-2); font-weight: 600; font-size: 13px; }
.pills a:hover { text-decoration: none; border-color: var(--line-strong); }
.pills a.on { background: var(--leaf); color: #fff; border-color: var(--leaf); }
.pill-n { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 9px; background: #f0ece4; color: var(--muted); font-size: 11.5px; font-weight: 700; }
.pills a.on .pill-n { background: rgba(255, 255, 255, 0.18); color: #fff; }

/* menus (print menu on a load) */
details.menu { position: relative; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu[open] > summary { margin-bottom: 0; }
details.menu .menu-list { position: absolute; z-index: 30; right: 0; top: calc(100% + 6px); width: 290px; box-shadow: var(--shadow-lg); }
.head .actions details.menu .menu-list { right: 0; }

/* chart */
.only-narrow { display: none; }
@media (max-width: 700px) { .only-wide { display: none; } .only-narrow { display: block; } }
.chart { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--line); }
.chart text { fill: var(--muted); font-size: 11px; }

/* ======== the load ======== */
/* journey: every step from plan to close */
.journey { margin-bottom: 14px; overflow-x: auto; scrollbar-width: thin; }
.journey ol { list-style: none; margin: 0; padding: 14px 10px 10px; display: flex; min-width: max-content; }
.journey li { position: relative; flex: 1 0 92px; text-align: center; }
.journey li + li::before { content: ''; position: absolute; top: 18px; right: 50%; width: 100%; height: 2px; background: var(--line); z-index: 0; }
.journey li.done + li::before { background: var(--good); }
.journey a { position: relative; z-index: 1; display: grid; justify-items: center; gap: 3px; color: var(--ink-2); padding: 0 4px; }
.journey a:hover { text-decoration: none; }
.journey a:hover .j-dot { border-color: var(--brand); }
.j-dot { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: #fff; border: 2px solid var(--line-strong); color: var(--muted); }
.j-dot svg { width: 17px; height: 17px; }
.j-label { font-size: 12px; font-weight: 650; line-height: 1.2; }
.j-when { font-size: 11px; color: var(--muted); min-height: 1.3em; white-space: nowrap; }
.journey li.done .j-dot { background: var(--good); border-color: var(--good); color: #fff; }
.journey li.current .j-dot { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 0 0 5px var(--brand-soft); animation: pulse 2.4s ease-in-out infinite; }
.journey li.current .j-label { color: var(--brand-hover); }
.journey li.skip .j-dot { border-style: dashed; opacity: 0.6; }
.journey li.todo .j-label { color: var(--muted); font-weight: 550; }
@keyframes pulse { 50% { box-shadow: 0 0 0 9px rgba(255, 241, 230, 0.6); } }
@media (prefers-reduced-motion: reduce) { .journey li.current .j-dot { animation: none; } }

.next-step { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; margin-bottom: 14px; border-left: 4px solid var(--brand); background: linear-gradient(90deg, var(--brand-soft), #fff 70%); }
.next-step .label { display: block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--brand); }
.next-step strong { display: block; font-size: 18px; letter-spacing: -0.01em; }
.next-step small { display: block; margin-top: 2px; }
.next-step.good { border-left-color: var(--good); background: linear-gradient(90deg, var(--good-soft), #fff 70%); }
.next-step.good .label { color: var(--good); }
.next-step.bad { border-left-color: var(--bad); background: linear-gradient(90deg, var(--bad-soft), #fff 70%); }
.next-step.bad .label { color: var(--bad); }
.next-step .btn { flex: none; }

.warnings { display: grid; margin-bottom: 14px; border-color: #f3d9a8; background: var(--warn-soft); overflow: hidden; }
.warnings a { display: flex; align-items: center; gap: 10px; padding: 9px 14px; color: #7c3d06; font-weight: 600; }
.warnings a + a { border-top: 1px solid #f3dfb8; }
.warnings a:hover { text-decoration: none; background: #fdebc8; }
.warnings svg { width: 17px; height: 17px; color: var(--warn); }

.load-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.stage-card .card-h h2 svg { color: var(--muted); }
.stage-card.done .card-h h2 svg { color: var(--good); }
.stage-card.done { border-top: 3px solid #b7e2c4; }
.stage-card > .pad > p.muted:only-child, .stage-card > .pad.muted { margin: 0; }
.packing-session + .packing-session { border-top: 1px solid var(--line); }
.ps-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding-bottom: 8px; }
.count-chips { display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line); }
.count-chip { display: inline-flex; gap: 6px; align-items: baseline; padding: 5px 11px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-hover); font-weight: 650; font-size: 13px; }
.count-chip.total { background: var(--leaf); color: #fff; }
.pay-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.pay-box { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--sunk); display: grid; gap: 4px; align-content: start; }
.pay-box .label { font-size: 12px; color: var(--muted); font-weight: 650; }
.pay-box .value { font-size: 19px; font-weight: 700; }
.pay-box .sub { font-size: 12.5px; color: var(--muted); }
.pay-box .btn-row { margin-top: 6px; }
.pay-box.settled { background: var(--good-soft); border-color: #c7e8d1; }
.pay-box.settled .value { color: var(--good); }
.pnl { border-top: 1px solid var(--line); padding-top: 12px; }
.pnl h3 { margin-bottom: 6px; }
.pnl td:not(:first-child) { white-space: nowrap; }
.pnl tr.revenue td:first-child { font-weight: 650; }
.pnl tr.claim td, .pnl tr.fruit td, .pnl tr.cost td { color: var(--ink-2); }
.pnl tfoot td { font-size: 15px; }

/* step forms: costs and documents */
.costs-block, .docs-block { margin-top: 18px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--sunk); }
.costs-block > summary .hint, .docs-block legend .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; margin-left: 6px; }
.docs-block > legend { float: left; width: 100%; }
.docs-block > legend + * { clear: both; }
.cost-rows { display: grid; gap: 8px; }
.cost-row { display: grid; grid-template-columns: minmax(150px, 1.2fr) minmax(170px, 1.4fr) 90px 100px 86px 120px; gap: 8px; align-items: end; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.cost-row label { gap: 3px; }
.cost-row label > span { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.cost-name { align-self: center; display: grid; line-height: 1.25; }
.cost-name small { font-size: 12px; }
.c-amount input:not(:placeholder-shown) { font-weight: 700; border-color: var(--brand-glow); }
.doc-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.doc-slot { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; gap: 6px; }
.doc-slot.uploaded { border-color: #b7e2c4; background: #f6fbf8; }
.doc-slot.missing { border-color: #f2c5c2; }
.doc-name { font-weight: 650; font-size: 13px; }

/* document checklist (side of the load) */
.checklist { list-style: none; margin: 0; padding: 4px 0 8px; }
.cl-stage { padding: 10px 16px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.cl-row { display: flex; gap: 10px; align-items: flex-start; padding: 7px 16px; }
.cl-row:hover { background: #fdfbf8; }
.cl-mark { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; margin-top: 1px; background: #f0ece4; color: var(--muted); }
.cl-row.uploaded .cl-mark { background: var(--good); color: #fff; }
.cl-row.missing .cl-mark { background: var(--bad); color: #fff; }
.cl-row.na .cl-mark { background: #f0ece4; color: var(--muted); }
.cl-row.na .cl-main > :first-child { text-decoration: line-through; color: var(--muted); }
.cl-main { flex: 1; min-width: 0; display: grid; gap: 2px; font-size: 13.5px; font-weight: 550; }
.cl-main small { font-weight: 400; font-size: 12px; line-height: 1.35; }
.cl-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.cl-files a { width: 38px; height: 38px; border-radius: 7px; overflow: hidden; border: 1px solid var(--line); display: grid; place-items: center; background: var(--sunk); }
.cl-files img { width: 100%; height: 100%; object-fit: cover; }
.ext { font-size: 10px; font-weight: 800; color: var(--muted); letter-spacing: 0.03em; }
.cl-actions { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.upload-inline .btn { cursor: pointer; }
.js .upload-inline[data-auto-upload] button:not([data-keep]) { display: none; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.ph { aspect-ratio: 1; border-radius: 9px; overflow: hidden; background: var(--sunk); border: 1px solid var(--line); display: grid; place-items: center; }
.ph img { width: 100%; height: 100%; object-fit: cover; }

/* history */
ol.timeline { list-style: none; margin: 0; padding: 12px 16px 8px; position: relative; }
ol.timeline::before { content: ''; position: absolute; left: 28px; top: 20px; bottom: 20px; width: 2px; background: var(--line); }
ol.timeline li { position: relative; display: flex; gap: 12px; padding: 0 0 12px; font-size: 13.5px; }
.tl-icon { position: relative; z-index: 1; flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: #fff; border: 1px solid var(--line-strong); color: var(--brand); }
.tl-icon svg { width: 13px; height: 13px; }
ol.timeline li > div { min-width: 0; padding-top: 2px; }
ol.timeline small { display: block; color: var(--muted); font-size: 12px; }
ol.timeline.compact li { padding-bottom: 8px; }
.tl-reason { font-style: italic; color: var(--ink-2); margin-top: 2px; }
.tl-changes { margin: 4px 0 0; padding-left: 16px; font-size: 12.5px; color: var(--ink-2); }
.tl-changes s { color: var(--muted); }

/* reason pop-over (cancel / reject) */
details.reason-pop { position: relative; display: inline-block; }
details.reason-pop > summary { list-style: none; }
details.reason-pop > summary::-webkit-details-marker { display: none; }
details.reason-pop[open] > summary { margin-bottom: 0; }
details.reason-pop .reason-form { position: absolute; z-index: 20; top: calc(100% + 6px); right: 0; width: min(360px, 86vw); box-shadow: var(--shadow-lg); display: grid; gap: 10px; text-align: left; font-weight: 400; }

/* live figures (harvest amounts, packing totals) */
.live { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; }
.live > * { display: block; background: var(--sunk); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font-size: 12px; color: var(--muted); font-weight: 600; }
.money-block .live > * { background: #fff; }
.live b { display: block; font-size: 17px; color: var(--ink); font-weight: 700; margin-top: 1px; }
.live b.bad { color: var(--bad); }

/* "How this works" guides */
details.guide { background: #f3f7ff; border: 1px solid #d3e0f5; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; }
details.guide > summary { color: #1f4f86; display: flex; align-items: center; gap: 8px; list-style: none; }
details.guide > summary::-webkit-details-marker { display: none; }
.guide-i { width: 20px; height: 20px; border-radius: 50%; background: #1f4f86; color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.guide-body { color: #23384f; font-size: 13.5px; }
.tip { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }

/* ======== dashboard & board ======== */
.pipeline-strip { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 6px; margin-bottom: 16px; }
.pipe { display: grid; gap: 1px; padding: 10px 10px 9px; border-radius: 11px; background: #fff; border: 1px solid var(--line); color: var(--muted); min-width: 0; }
.pipe:hover { text-decoration: none; border-color: var(--line-strong); }
.pipe b { font-size: 20px; color: var(--line-strong); line-height: 1.1; }
.pipe span { font-size: 11.5px; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; }
.pipe.on { border-color: var(--brand-glow); background: linear-gradient(180deg, #fff, var(--brand-soft)); color: var(--ink-2); }
.pipe.on b { color: var(--brand); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.dash-grid > .card + .card { margin-top: 0; }
ul.attention, ul.list { list-style: none; margin: 0; padding: 4px 0; }
ul.attention li a, ul.list li { display: block; padding: 9px 16px; color: var(--ink); border-bottom: 1px solid var(--line); }
ul.attention li:last-child a, ul.list li:last-child { border-bottom: 0; }
ul.attention li a:hover { text-decoration: none; background: #fdfbf8; }
ul.attention .badge { margin-right: 6px; }
.setup-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-bottom: 18px; }
.setup-step { display: flex; gap: 14px; padding: 18px; color: var(--ink); align-items: flex-start; }
.setup-step:hover { text-decoration: none; border-color: var(--brand-glow); box-shadow: 0 6px 20px rgba(194, 65, 12, 0.08); }
.setup-step .n { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: #fff; font-weight: 800; }
.setup-step.done .n { background: var(--good); }
.setup-step b { display: block; font-size: 15.5px; margin-bottom: 4px; }
.setup-step p { margin: 0; color: var(--muted); font-size: 13.5px; }

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.board-col { background: #efebe3; border-radius: 12px; padding: 10px; display: grid; gap: 8px; min-height: 120px; align-content: start; }
.board-col.empty { opacity: 0.6; }
.board-col h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-2); display: flex; justify-content: space-between; padding: 2px 4px 4px; }
.board-col .count { background: #fff; border-radius: 9px; padding: 0 7px; font-size: 12px; color: var(--muted); }
.board-card { display: grid; gap: 2px; padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); box-shadow: var(--shadow); font-size: 13px; }
.board-card:hover { text-decoration: none; border-color: var(--brand-glow); }
.board-card b { font-size: 14px; }

/* traceability */
.trace-chain { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 16px; align-items: start; margin: 16px 0; }
.trace-chain > .card + .card { margin-top: 0; }

/* ======== New / More screens ======== */
.tile-group, .menu-group { margin-bottom: 22px; }
.tile-group h2, .menu-group h2 { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 8px 2px; }
.tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.tile { display: flex; gap: 12px; align-items: center; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; color: var(--ink); box-shadow: var(--shadow); }
.tile:hover { text-decoration: none; border-color: var(--brand-glow); }
.tile .ti { flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.tile svg { width: 22px; height: 22px; }
.tile strong { display: block; font-size: 14.5px; line-height: 1.3; }
.tile small { display: block; font-size: 12.5px; line-height: 1.3; }
.profile-row { display: flex; gap: 12px; align-items: center; padding: 14px 16px; margin-bottom: 22px; color: var(--ink); }
.profile-row:hover { text-decoration: none; }
.profile-row small { display: block; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: #fff; font-weight: 700; font-size: 18px; flex: none; }
.menu-list { overflow: hidden; }
.menu-list a { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: var(--ink); border-bottom: 1px solid var(--line); font-weight: 550; }
.menu-list a:last-child { border-bottom: 0; }
.menu-list a:hover { text-decoration: none; background: #fdfbf8; }
.menu-list svg { width: 20px; height: 20px; color: var(--brand); }

/* auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(circle at 15% 0%, #ffe7d3 0, transparent 45%), radial-gradient(circle at 90% 100%, #dcefe2 0, transparent 40%), var(--bg); }
.auth-card { width: 100%; max-width: 390px; }
.auth .logo { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 18px; text-align: center; }
.auth .logo img { width: 72px; height: 72px; border-radius: 18px; }
.auth .switch { text-align: center; margin-top: 14px; font-size: 13px; display: grid; gap: 6px; }

/* public tracking page */
body.track { background: radial-gradient(circle at 0% 0%, #ffe7d3 0, transparent 40%), var(--bg); padding: 24px 16px 40px; max-width: 640px; margin: 0 auto; }
.track-head { margin-bottom: 18px; }
.track-brand { font-weight: 700; color: var(--brand); margin-bottom: 6px; }
.track-head h1 { font-size: 26px; margin-bottom: 8px; }
.track-head h1 small { font-size: 15px; font-weight: 500; }
.track-steps { list-style: none; margin: 0 0 16px; padding: 16px 18px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); position: relative; }
.track-steps li { position: relative; padding: 0 0 16px 32px; display: grid; }
.track-steps li:last-child { padding-bottom: 0; }
.track-steps li::before { content: ''; position: absolute; left: 0; top: 2px; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); background: #fff; }
.track-steps li::after { content: ''; position: absolute; left: 9px; top: 22px; bottom: 0; width: 2px; background: var(--line); }
.track-steps li:last-child::after { display: none; }
.track-steps li.done::before { background: var(--good); border-color: var(--good); }
.track-steps li.done::after { background: var(--good); }
.track-steps li.next::before { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.track-steps li:not(.done) b { color: var(--muted); font-weight: 550; }
.track-steps span { font-size: 13px; color: var(--ink-2); }
.track-steps small { font-size: 12.5px; }

/* ======== printable documents ======== */
body.print-page { background: #e9e5dd; }
.print-main { max-width: 900px; margin: 0 auto; padding: 24px 16px; }
.print-bar { margin-bottom: 12px; }
.doc { padding: 28px 32px; }
.doc-wide { max-width: none; }
.doc-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; padding-bottom: 14px; border-bottom: 2px solid var(--ink); margin-bottom: 16px; }
.doc-from { display: flex; gap: 12px; align-items: flex-start; }
.doc-from h1 { font-size: 19px; }
.doc-title { font-size: 18px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 6px; color: var(--brand-hover); }
.doc h2 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.04em; margin: 18px 0 8px; }
.doc-parties { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 16px; }
.doc-party { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.doc-party .label, .doc-bank .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; margin-bottom: 2px; }
.doc-table td, .doc-table th { padding: 6px 8px; font-size: 12.5px; }
.doc-table tr.group-start td { border-top: 1px solid var(--line-strong); }
@media screen and (max-width: 720px) { table.doc-table { display: block; overflow-x: auto; max-width: 100%; } }
.doc-note { font-size: 12.5px; color: var(--ink-2); margin: 10px 0; }
.doc-bank { border: 1px dashed var(--line-strong); border-radius: 8px; padding: 10px 12px; margin: 12px 0; font-size: 13px; }
.doc-paca { font-size: 11px; line-height: 1.45; color: var(--ink-2); border-top: 1px solid var(--line); padding-top: 10px; margin-top: 16px; }
.doc-block + .doc-block { margin-top: 18px; }
.doc-checklist { columns: 2; padding-left: 0; list-style: none; font-size: 12.5px; margin: 0; }
.doc-checklist li.missing { color: var(--bad); font-weight: 650; }
.doc-sign { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 40px 24px; margin-top: 56px; }
.doc-sign div { flex: 1 1 180px; border-top: 1px solid var(--ink); padding-top: 6px; text-align: center; color: var(--muted); font-size: 12.5px; }
.doc dl.facts { font-size: 13px; }

/* pallet tags */
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(95mm, 1fr)); gap: 6mm; }
.label-card { background: #fff; border: 1px solid #999; border-radius: 6px; padding: 4mm 5mm; display: grid; gap: 2mm; break-inside: avoid; page-break-inside: avoid; font-size: 12px; }
.lc-top { display: flex; justify-content: space-between; font-size: 12px; }
.lc-pallet { font-size: 26px; font-weight: 900; letter-spacing: 0.02em; text-align: center; }
.lc-barcode svg { display: block; width: 100%; height: 16mm; }
.lc-grid { display: grid; grid-template-columns: max-content 1fr; gap: 1mm 4mm; }
.lc-grid span { color: #555; }
.lc-foot { text-align: center; font-weight: 700; border-top: 1px solid #999; padding-top: 2mm; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }

@media print {
  body, body.print-page { background: #fff; font-size: 12px; }
  .side, .tabbar, .appbar, .no-print, details.guide { display: none !important; }
  .shell { display: block; }
  main, .print-main { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #bbb; }
  .doc { border: 0; padding: 0; }
  .labels { grid-template-columns: repeat(2, 1fr); gap: 4mm; }
  .label-card { border-radius: 0; }
  a { color: inherit; }
}

/* ======== tablets ======== */
@media (max-width: 1200px) {
  .load-grid { grid-template-columns: minmax(0, 1fr) 320px; }
  .pipeline-strip { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .cost-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); }
  .cost-name, .c-party { grid-column: span 3; }
}

/* ======== phones & tablets: app-style shell ======== */
@media (max-width: 1024px) {
  :root { --tabbar-h: 62px; --safe-b: env(safe-area-inset-bottom, 0px); --radius: 14px; }
  body { font-size: 15px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  main { display: flex; flex-direction: column; padding: 0 16px calc(var(--tabbar-h) + var(--safe-b) + 28px); }
  main > * { flex: none; }
  a, button { -webkit-tap-highlight-color: transparent; }
  .appbar { order: -1; display: flex; align-items: center; gap: 4px; position: sticky; top: 0; z-index: 15; margin: 0 -16px 14px; padding: calc(env(safe-area-inset-top, 0px) + 6px) 12px 6px; min-height: 54px; background: rgba(246, 244, 239, 0.94); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
  .appbar .back { width: 42px; height: 42px; margin-left: -6px; display: grid; place-items: center; border-radius: 50%; color: var(--ink); flex: none; }
  .appbar .back:active { background: #ece7dd; }
  .appbar .back svg { width: 26px; height: 26px; }
  .appbar-title { font-weight: 750; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .head h1, .crumbs { display: none; }
  .head { margin-bottom: 14px; }
  .head > div:first-child:not(:has(p)) { display: none; }
  .head .actions { width: 100%; }
  .head .actions > * { flex: 1 1 auto; }
  .head .actions > .btn, .head .actions > form.inline { min-width: max-content; }
  .head .actions form.inline .btn { width: 100%; }
  .head .actions { gap: 8px; }
  .head .actions .btn { padding-inline: 11px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(255, 255, 255, 0.97); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); box-shadow: 0 -4px 18px rgba(28, 25, 23, 0.06); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: var(--tabbar-h); color: #776f63; font-size: 11.5px; font-weight: 650; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar .ti { display: grid; place-items: center; width: 52px; height: 28px; border-radius: 14px; transition: background 0.15s; }
  .tabbar svg { width: 23px; height: 23px; }
  .tabbar a.on { color: var(--brand); }
  .tabbar a.on .ti { background: var(--brand-soft); }
  .tabbar a.new .ti { width: 50px; height: 50px; margin-top: -20px; border-radius: 17px; background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(194, 65, 12, 0.35); }
  input, select, textarea { font-size: 16px; min-height: 46px; border-radius: 10px; padding: 10px 12px; }
  .unit-input .unit { height: 46px; }
  input[type='checkbox'], input[type='radio'] { width: 22px; height: 22px; min-height: 0; padding: 0; }
  .btn { min-height: 46px; padding: 10px 16px; border-radius: 11px; font-size: 15px; }
  .btn.sm { min-height: 38px; padding: 6px 12px; font-size: 14px; }
  label { font-size: 14px; }
  .select-add .quick { min-width: 46px; }
  .savebar { bottom: calc(var(--tabbar-h) + var(--safe-b)); }
  .savebar .btn.primary { flex: 1 1 auto; }
  .pills { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 14px; padding: 0 16px 2px; scrollbar-width: none; }
  .pills::-webkit-scrollbar { display: none; }
  .pills a { flex: none; padding: 9px 15px; font-size: 14px; }
  .load-grid, .dash-grid, .trace-chain, .split { grid-template-columns: minmax(0, 1fr); }
  .journey { margin: 0 -16px 14px; border-radius: 0; border-left: 0; border-right: 0; }
  .tile:active, .menu-list a:active, tr[data-href]:active td { background: #fbf1e7; }
  th, td { padding: 8px 9px; }
  details.menu .menu-list { left: 0; right: auto; width: min(320px, calc(100vw - 32px)); }
  .board { grid-auto-columns: minmax(78vw, 1fr); margin: 0 -16px; padding: 0 16px 12px; scroll-snap-type: x mandatory; }
  .board-col { scroll-snap-align: start; }
}

/* List tables become cards whenever their card is narrow: first column is the title, the rest label/value pairs. */
.card { container-type: inline-size; }
@container (max-width: 520px) {
  .table-wrap:has(table.cards) { overflow: visible; }
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tfoot, table.cards tr { display: block; width: 100%; }
  table.cards tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  table.cards tbody tr:last-child { border-bottom: 0; }
  table.cards td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 3px 0; border: 0; text-align: right; background: none !important; }
  table.cards td::before { content: attr(data-label); flex: none; color: var(--muted); font-size: 13px; font-weight: 500; text-align: left; }
  table.cards td:first-child { display: block; padding: 0 0 6px; text-align: left; font-weight: 650; font-size: 15.5px; }
  table.cards td:first-child::before { display: none; }
  table.cards td:first-child small { display: block; font-size: 13px; font-weight: 500; }
  table.cards td:empty { display: none; }
  table.cards td small.block { display: inline; margin-left: 6px; }
  table.cards tfoot tr { background: var(--sunk); border-top: 1px solid var(--line-strong); }
}

/* ======== phones ======== */
@media (max-width: 700px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat .label { font-size: 11px; }
  .stat .value { font-size: clamp(13px, 11.5cqi, 18px); }
  .fgrid { grid-template-columns: minmax(0, 1fr); }
  label .hint { display: block; margin-top: 1px; }
  dl.facts, dl.facts.cols { grid-template-columns: minmax(0, 1fr); gap: 0; }
  dl.facts dd { margin-bottom: 8px; }
  .next-step { flex-direction: column; align-items: stretch; }
  .next-step .btn, .next-step form.inline .btn { width: 100%; }
  .pipeline-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cost-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .cost-name, .c-party, .c-amount { grid-column: 1 / -1; }
  .doc { padding: 18px 16px; }
  .doc-checklist { columns: 1; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tile { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; }
  .tile strong { font-size: 14px; }
  details.reason-pop { display: block; }
  details.reason-pop .reason-form { position: static; width: 100%; margin-top: 8px; }
  .filters > * { flex: 1 1 100%; }
  .filters input[type='date'] { flex: 1 1 40%; }
  dialog.quick-dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  dialog.quick-dialog iframe { height: calc(100dvh - 54px) !important; max-height: none; }
  .btn { white-space: normal; max-width: 100%; }
}

/* ======== line-item editors on phones & portrait tablets: one card per line ======== */
@media (max-width: 820px) {
  .lines thead { display: none; }
  .lines tbody, .lines tfoot { display: block; }
  .lines tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 14px; margin-bottom: 10px; background: var(--sunk); border: 1px solid var(--line); border-radius: 12px; }
  .lines tbody td { display: block; min-width: 0; padding: 0; border: 0; text-align: left; background: none !important; }
  .lines tbody td::before { content: attr(data-label); display: block; margin-bottom: 4px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
  .lines tbody td:first-child { grid-column: 1 / -1; }
  .lines tbody td:has(.quick) { grid-column: 1 / -1; }
  .lines tbody td.num { display: flex; justify-content: space-between; align-items: baseline; grid-column: 1 / -1; padding-top: 8px; border-top: 1px dashed var(--line-strong); font-weight: 700; }
  .lines tbody td.num::before { margin: 0; font-weight: 500; color: var(--muted); }
  .lines tbody td:last-child:has([data-remove-row]) { grid-column: 1 / -1; display: flex; justify-content: flex-end; margin: -6px 0 -6px; }
  .lines tbody td:last-child:has([data-remove-row])::before { display: none; }
  .lines input, .lines select { min-width: 0; max-width: none; background: #fff; }
  .lines tfoot tr { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 4px 2px 0; font-size: 15px; }
  .lines tfoot td { border: 0; background: none; padding: 0; }
  .lines tfoot td:empty { display: none; }
}
