/* ============================================================
   GO LABAN · v1.10 additions — overview, ingredients, purchases
   Uses the tokens from styles.css.
   ============================================================ */
.ranges { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.ranges::-webkit-scrollbar { display: none; }
.ranges button { border: 1px solid var(--line); background: var(--paper); border-radius: 99px; padding: 7px 14px; font-weight: 600; cursor: pointer; white-space: nowrap; color: var(--ink-2); }
.ranges button:hover { border-color: var(--blue); color: var(--blue); }
.ranges button.on { background: var(--blue); border-color: var(--blue); color: #fff; }

.delta { font-weight: 700; font-size: 12px; white-space: nowrap; }
.delta.up { color: var(--green-deep); }
.delta.down { color: var(--red); }
.fig.lead .delta.up { color: #B9F5B0; }
.fig.lead .delta.down { color: #FFC9C5; }
.neg { color: var(--red); }
.fig.lead b.neg { color: #FFC9C5; }

.panel.attention { border-color: var(--green); margin-bottom: 16px; }
.compare th.sortable { cursor: pointer; user-select: none; }
.compare th.sortable:hover, .compare th.sorted { color: var(--blue); }
.compare td .sub .delta { font-size: 11.5px; }
.compare td .tag { min-width: 30px; justify-content: center; }

/* trend bars (any number of days) */
.trend { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: clamp(2px, 1vw, 8px); align-items: end; height: 180px; padding-top: 6px; }
.tcol { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 5px; font-size: 11px; color: var(--ink-3); min-width: 0; }
.tcol i { display: block; width: 100%; max-width: 40px; background: var(--blue); opacity: .78; border-radius: 4px 4px 1px 1px; min-height: 2px; }
.tcol:hover i { opacity: 1; }
.tcol.today i { background: var(--green); opacity: 1; }
.tcol em { font-style: normal; font-weight: 700; color: var(--ink-2); font-size: 11px; }
.tcol span { height: 14px; white-space: nowrap; }

/* shortages */
.short-list { padding: 4px 16px 14px; display: grid; gap: 12px; max-height: 330px; overflow: auto; }
.short-br b { display: block; font-size: 13.5px; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--line-2); color: var(--ink-2); }
.chip.out { background: var(--red-wash); color: var(--red); }
.chip.low { background: var(--amber-wash); color: var(--amber); }

/* horizontal bars (expenses) */
.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; align-items: center; font-size: 13.5px; }
.hbar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); font-weight: 600; }
.hbar i { display: block; height: 10px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.hbar em { display: block; height: 100%; background: var(--amber); border-radius: 99px; }
.hbar b { font-weight: 700; min-width: 70px; text-align: right; }

/* ingredients */
.out { color: var(--red); font-weight: 700; }
.lowq { color: var(--amber); font-weight: 700; }
.matrix td:first-child, .matrix th:first-child { position: sticky; left: 0; background: var(--paper); z-index: 1; }
.needs { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.needs .need-card { margin: 0; display: flex; flex-direction: column; }
.need-card .panel-head { align-items: flex-start; }
.need-card .table-wrap { flex: 1; max-height: 300px; overflow: auto; }
.need-acts { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.qunit { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.qunit input { width: 100px; text-align: right; }
.qunit span { color: var(--ink-3); min-width: 26px; font-size: 13px; }
.recipe-sum { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; padding: 12px 14px; background: var(--milk); border-radius: var(--r-s); font-size: 13.5px; color: var(--ink-2); }
.recipe-sum b { color: var(--ink); margin-left: 4px; }
.doc-lines .sub { display: block; }

@media (min-width: 901px) { .ranges { flex-wrap: wrap; overflow: visible; } }
@media (max-width: 560px) {
  .trend.dense em { display: none; }
  .hbar { grid-template-columns: 84px 1fr auto; }
  .trend { height: 150px; }
  .needs { grid-template-columns: 1fr; }
}

.lbl-like { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.payout-due { border-color: var(--amber); }

/* product photos (v1.13) */
.tile.has-ph { padding-top: 10px; }
.tile .ph { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: #00529C; display: block; }
.tile.out .ph { filter: grayscale(1); }
.prow { display: flex; align-items: center; gap: 10px; }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: var(--line-2); display: inline-block; }
.photo-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.photo-pick button { border: 2px solid var(--line); border-radius: 10px; background: var(--paper); padding: 4px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; align-items: stretch; font-size: 11px; color: var(--ink-2); }
.photo-pick button img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }
.photo-pick button .none { aspect-ratio: 1; display: grid; place-items: center; background: var(--line-2); border-radius: 6px; font-weight: 600; }
.photo-pick button.on { border-color: var(--green); box-shadow: 0 0 0 2px var(--green-wash); color: var(--ink); }

/* ============ v1.14: sections, phone layout ============ */
.cv { display: contents; }
.subnav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: -6px 0 18px; border-bottom: 1px solid var(--line); }
.subnav::-webkit-scrollbar { display: none; }
.subnav a { position: relative; flex-shrink: 0; padding: 10px 14px 11px; font-weight: 700; color: var(--ink-2); text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.subnav a:hover { color: var(--blue); }
.subnav a.on { color: var(--blue); border-bottom-color: var(--blue); }
.subnav a .badge { position: static; display: inline-grid; place-items: center; margin-left: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--green); color: #fff; font-size: 11px; font-weight: 800; vertical-align: 1px; }
.matrix td:first-child, .matrix th:first-child { position: sticky; left: 0; z-index: 1; background: var(--paper); box-shadow: 1px 0 0 var(--line-2); }

@media (max-width: 600px) {
  .subnav { margin: -4px -16px 14px; padding: 0 10px; background: var(--paper); }
  .page-head { gap: 12px; }
  .page-head h1 { font-size: 23px; }
  .page-head .actions { width: 100%; display: flex; flex-wrap: wrap; gap: 8px; }
  .page-head .actions .btn { flex: 1 1 calc(50% - 4px); justify-content: center; padding-left: 10px; padding-right: 10px; }
  .page-head .actions .btn.primary { flex-basis: 100%; order: -1; }
  .filters { gap: 8px; }
  .panel-head { flex-wrap: wrap; }
  .panel-head .seg { width: 100%; }
  .panel-head .seg button { flex: 1; }
  .seg { max-width: 100%; overflow-x: auto; }
  .seg button { white-space: nowrap; padding: 7px 11px; }
  .figures .fig b { font-size: 20px; }

  /* tables become cards */
  table.stack, table.stack tbody, table.stack tfoot { display: block; width: 100%; }
  table.stack thead { display: none; }
  table.stack tr { display: block; padding: 10px 14px; border-bottom: 1px solid var(--line-2); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 3px 0 !important; border: 0 !important; text-align: right; white-space: normal; min-height: 0; }
  table.stack td::before { content: attr(data-label); color: var(--ink-3); font-size: 12.5px; font-weight: 600; text-align: left; flex-shrink: 0; }
  table.stack td[data-label=""]::before { content: none; }
  table.stack td[data-label=""] { justify-content: flex-end; }
  table.stack td:first-child { display: block; text-align: left; font-size: 15px; padding-bottom: 6px !important; }
  table.stack td:first-child::before { content: none; }
  table.stack td:empty { display: none; }
  table.stack td.hide-sm { display: flex !important; }
  table.stack td.hide-sm:empty { display: none !important; }
  table.stack td .sub { text-align: inherit; }
  table.stack td > .cv { display: block; text-align: right; min-width: 0; }
  table.stack td > .cv .btn { margin-left: 4px; margin-top: 2px; }
  table.stack td.num > .sub { display: block; }
  table.stack tfoot tr { background: var(--milk); font-weight: 700; }
  table.stack tfoot td:first-child { font-size: 14px; }
  table.stack .tag { white-space: nowrap; }
  table.stack td.empty { display: block; text-align: center; }
  .prow { gap: 12px; }
  .matrix { font-size: 13px; }
}

.pick-list { display: grid; gap: 6px; max-height: 260px; overflow: auto; padding: 8px; border: 1px solid var(--line); border-radius: var(--r-s); }
.branch .acts .btn.primary .i { width: 16px; height: 16px; }

/* ============ v1.15: form alignment, photos ============ */
/* Labels: the caption is one line on top, the field sits right under it; nothing stretches. */
label { align-content: start; grid-auto-rows: max-content; }
.form-grid { align-items: start; }
label > span:first-child { display: flex; align-items: center; gap: 6px; min-height: 20px; }
.unit-chip { font-style: normal; font-weight: 700; font-size: 11.5px; padding: 1px 8px; border-radius: 99px; background: var(--blue-wash); color: var(--blue); }
.photo-field { display: flex; align-items: center; gap: 14px; padding: 10px; border: 1px dashed var(--line); border-radius: var(--r-m); background: var(--milk); }
.pf-prev { width: 76px; height: 76px; border-radius: 12px; overflow: hidden; flex-shrink: 0; display: grid; place-items: center; background: var(--paper); border: 1px solid var(--line); color: var(--ink-3); }
.pf-prev img { width: 100%; height: 100%; object-fit: cover; }
.pf-prev .i { width: 30px; height: 30px; }
.pf-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; }
.pf-acts .fine { flex-basis: 100%; }
.pf-up { cursor: pointer; display: inline-flex; }
.thumb.none { display: inline-grid; place-items: center; color: var(--ink-3); border: 1px solid var(--line-2); }
.thumb.none .i { width: 20px; height: 20px; }
.thumb.sm { width: 32px; height: 32px; border-radius: 7px; }
.thumb.sm.none .i { width: 16px; height: 16px; }

/* v1.17: captions always one line; the unit sits inside the box */
label > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.in-unit { position: relative; display: block; }
.in-unit input { width: 100%; padding-right: 54px; }
.in-unit em { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-style: normal; font-weight: 700; font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--blue-wash); color: var(--blue); pointer-events: none; }
.in-unit input::-webkit-outer-spin-button, .in-unit input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.in-unit input[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* v1.18: stock count — Set count / Add / Reduce */
.adj-top { margin-bottom: 12px; }
.adj-seg button { min-width: 92px; }
.adj-after { font-weight: 700; color: var(--blue); white-space: nowrap; }
.adj-after.neg { color: #c0392b; }
@media (max-width: 640px) { .adj-seg { display: flex; width: 100%; } .adj-seg button { flex: 1; min-width: 0; } }
@media (max-width: 640px) { td.adj-none { display: none !important; } .adj-after:empty { display: none !important; } }

/* v1.21: popups never wider than the phone; line editors become cards on phones */
.modal-back { grid-template-columns: minmax(0, 1fr); }
.modal, .modal-body, .modal-head, .modal-foot { min-width: 0; max-width: 100%; }
.modal .table-wrap { max-width: 100%; overflow-x: auto; }
@media (max-width: 640px) {
  .modal .doc-lines { display: block; width: 100%; min-width: 0; }
  .modal .doc-lines thead { display: none; }
  .modal .doc-lines tbody, .modal .doc-lines tfoot { display: block; width: 100%; }
  .modal .doc-lines tbody tr { position: relative; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 10px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
  .modal .doc-lines tbody td { display: block; padding: 0; border: 0; flex: 1 1 0; min-width: 0; text-align: left; }
  .modal .doc-lines tbody td:first-child { flex: 1 1 100%; padding-right: 46px; }
  .modal .doc-lines tbody td:last-child { position: absolute; top: 12px; right: 0; flex: none; }
  .modal .doc-lines tbody td:not(:first-child):not(:last-child)::before { content: attr(data-label); display: block; font-size: 11.5px; font-weight: 600; color: var(--ink-3); margin-bottom: 4px; white-space: nowrap; }
  .modal .doc-lines tbody td.num:not(:has(input)) { align-self: stretch; display: flex; flex-direction: column; justify-content: space-between; font-weight: 700; }
  .modal .doc-lines input, .modal .doc-lines select, .modal .doc-lines .q, .modal .doc-lines .rt { width: 100%; max-width: 100%; }
  .modal .doc-lines tfoot tr { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-top: 12px; }
  .modal .doc-lines tfoot td { display: block; padding: 0; border: 0; }
  .modal .doc-lines tfoot td:empty { display: none; }
  .modal .doc-lines tfoot td.num { font-weight: 800; font-size: 16px; }
}

/* v1.22: nav bars keep one fixed size on every page; version shown */
@media (max-width: 900px) {
  .app { grid-template-rows: auto 1fr; align-content: start; }
}
.mbar { box-sizing: border-box; flex: none; align-self: start; height: calc(60px + env(safe-area-inset-top, 0px)); min-height: 0; overflow: hidden; }
.mbar-brand { display: flex; align-items: flex-end; gap: 6px; flex: none; }
.mbar-ver { font-size: 10.5px; font-weight: 700; color: rgba(255, 255, 255, .7); line-height: 1; padding-bottom: 3px; }
#mbarBranch { min-width: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.tabbar { box-sizing: border-box; }
.tabbar a { grid-template-rows: 24px 14px; align-content: center; height: 48px; }
.tabbar a .i { width: 44px; height: 24px; padding: 2px 0; box-sizing: border-box; border-radius: 99px; }
.tabbar a span:not(.badge) { line-height: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.login-ver { text-align: center; margin-top: 10px; opacity: .8; }
.ver { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
