/* App-shell layout for the daily-work screens (receiving). The window never scrolls: the screen is a fixed-height
   grid, and only the long lists inside panels scroll. On phones and very short windows it falls back to a normal page. */
body.app { height: 100vh; height: 100dvh; overflow: hidden; }
.app .foot { display: none; }

.app .msgs { position: fixed; top: 64px; right: 20px; max-width: 440px; width: auto; margin: 0; padding: 0; z-index: 60; }
.app .msgs .msg { box-shadow: 0 6px 24px rgba(0,0,0,.18); transition: opacity .4s; }

.app-form { flex: 1; min-height: 0; display: flex; flex-direction: column; margin: 0; }
.app-main { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 10px 24px 12px; width: 100%; max-width: 1760px; margin: 0 auto; }
.crumbs { font-size: .78rem; color: var(--muted); margin: 0 0 2px; }
.crumbs a { color: var(--muted); text-decoration: none; } .crumbs a:hover { text-decoration: underline; } .crumbs b { color: var(--ink); }
.doc-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 10px; flex: none; }
.doc-head h1 { margin: 0; font-size: 1.35rem; letter-spacing: -.01em; }
.doc-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.doc-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .72rem; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.draft { background: #ece8e6; color: #5d504e; } .status.transit { background: #fff1cf; color: #8a5a00; }
.status.done { background: #e3f4ea; color: #146c3d; } .status.cancel { background: #fde6e6; color: #a31d1d; }
.app .msg-error.slim { margin: 0 0 8px; padding: 8px 14px; flex: none; }

.doc-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: 330px minmax(0, 1fr) 310px; gap: 14px; }
.doc-grid.hub { grid-template-columns: minmax(0, 1fr) 350px; }
.col { min-height: 0; display: flex; flex-direction: column; gap: 12px; overflow: auto; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; min-height: 0; flex: none; }
.panel.fill { flex: 1; }
.panel-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 14px; background: #faf7f5; border-bottom: 1px solid var(--line); border-radius: 12px 12px 0 0; flex: none; min-height: 40px; }
.panel-h h2 { margin: 0; font-size: .74rem; text-transform: uppercase; letter-spacing: .09em; color: var(--brand-deep); font-weight: 800; }
.panel-h .hint { color: var(--muted); font-size: .78rem; }
.panel-b { padding: 12px 14px; }
.panel-b.scroll { flex: 1; min-height: 0; overflow: auto; }
.grid { display: grid; gap: 10px 12px; } .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* denser form controls inside app screens */
.app .field { margin-bottom: 0; }
.app .field label { display: block; font-size: .74rem; font-weight: 700; color: #5d504e; margin-bottom: 4px; }
.app .field input[type=text], .app .field input[type=date], .app .field input[type=datetime-local], .app .field input[type=tel],
.app .field select, .app .inp input { padding: 8px 11px; min-height: 38px; font-size: .95rem; border-radius: 8px; }
.app .inp { border-radius: 8px; } .app .inp span { padding: 0 10px; font-size: .8rem; }
.app .field.narrow { max-width: none; }
.stack { display: grid; gap: 10px; }

.seg { display: flex; border: 1px solid #d9cec9; border-radius: 10px; overflow: hidden; background: #fff; }
.seg label { margin: 0; cursor: pointer; flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 9px 14px; text-align: center; font-weight: 700; font-size: .92rem; border-right: 1px solid #d9cec9; white-space: nowrap; }
.seg label:last-child span { border-right: 0; }
.seg input:checked + span { background: var(--brand); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.seg.sm span { padding: 6px 12px; font-size: .82rem; }
a.seg-link { text-decoration: none; color: inherit; }
.seg a { flex: 1; display: block; padding: 6px 12px; text-align: center; font-weight: 700; font-size: .82rem; text-decoration: none; color: var(--ink); border-right: 1px solid #d9cec9; white-space: nowrap; }
.seg a:last-child { border-right: 0; } .seg a.on { background: var(--brand); color: #fff; }

/* data tables */
.tbl-scroll { flex: 1; min-height: 0; overflow: auto; }
.dt { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .88rem; }
.dt th { position: sticky; top: 0; z-index: 2; background: #fff; text-align: left; font-size: .68rem; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--brand); white-space: nowrap; }
.dt td { padding: 7px 10px; border-bottom: 1px solid #f1ebe8; vertical-align: middle; }
.dt tbody tr:hover { background: #fcf8f6; }
.dt th.num, .dt td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dt th.c, .dt td.c { text-align: center; }
.dt small { color: var(--muted); }
.dt .act { text-align: right; white-space: nowrap; }
.btn-sm { padding: 5px 12px; font-size: .82rem; border-radius: 8px; }
.empty-row td { text-align: center; color: var(--muted); padding: 26px 10px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; flex: none; }
.kpi { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 10px; padding: 8px 14px; }
.kpi small { display: block; color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 800; }
.kpi strong { font-size: 1.45rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi em { font-style: normal; font-size: .78rem; color: var(--muted); margin-left: 6px; }
.kpi.amber { border-left-color: var(--accent); }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 14px; border-bottom: 1px solid var(--line); flex: none; }
.toolbar input[type=search] { flex: 1; min-width: 160px; padding: 7px 12px; border: 1px solid #d9cec9; border-radius: 8px; font: inherit; font-size: .9rem; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted); flex: none; background: #faf7f5; border-radius: 0 0 12px 12px; }
.pager .pg { display: flex; gap: 6px; }
.pager .pg a, .pager .pg span { padding: 4px 11px; border: 1px solid #d9cec9; border-radius: 7px; background: #fff; text-decoration: none; color: var(--ink); font-weight: 700; }
.pager .pg span { color: #b8aaa6; background: #f6f3f1; }

/* goat grid */
.goat-rows { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.goat-rows .dt input[type=text] { width: 100%; min-width: 0; padding: 6px 9px; min-height: 34px; border: 1px solid #d9cec9; border-radius: 7px; font: inherit; font-size: .9rem; background: #fff; }
.goat-rows .dt input[readonly] { background: #f6f3f1; color: #5d504e; }
.goat-rows .dt .inp input { min-height: 34px; padding: 6px 9px; text-align: right; }
.goat-rows .dt td.gn { color: #9a8c89; width: 34px; font-variant-numeric: tabular-nums; }
.goat-rows .dt td.sent { color: #6b5d5a; }
.goat-rows .dt input[type=number] { -moz-appearance: textfield; }
.goat-rows .dt input[type=number]::-webkit-outer-spin-button, .goat-rows .dt input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.goat-rows .x { background: none; border: 0; color: #b34747; font-size: 1.2rem; cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.goat-rows .x:hover { background: #fde6e6; }
.goat-rows tr.is-dead td { background: #fff6f4; } .goat-rows tr.is-dead input[name=a_weight] { color: #a31d1d; text-decoration: line-through; }
.dead-toggle { display: inline-flex; align-items: center; gap: 6px; margin: 0; cursor: pointer; font-size: .78rem; font-weight: 700; color: #8b7d7a; }
.dead-toggle input { width: 17px; height: 17px; accent-color: #a31d1d; }
.gr-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 14px; border-top: 2px solid var(--brand); background: #faf7f5; flex: none; }
.gr-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gr-tools .tip { font-size: .76rem; color: var(--muted); }
.gr-totals { display: flex; gap: 20px; font-size: .86rem; color: var(--muted); }
.gr-totals b { color: var(--ink); font-size: 1rem; font-variant-numeric: tabular-nums; }
.chicken-fields { padding: 14px; }

/* side panels */
.kv { margin: 0; } .kv div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid #f3edea; font-size: .9rem; }
.kv div:last-child { border-bottom: 0; } .kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.big { display: flex; align-items: center; gap: 10px; padding-bottom: 8px; }
.big .pill { font-size: 1.5rem; padding: 4px 16px; } .big small { color: var(--muted); }
.checks { list-style: none; margin: 0; padding: 0; font-size: .86rem; }
.checks li { padding: 5px 0 5px 26px; position: relative; color: #5d504e; }
.checks li::before { content: "•"; position: absolute; left: 6px; color: #b8aaa6; font-weight: 800; }
.checks li.ok::before { content: "\2713"; color: #146c3d; } .checks li.warn::before { content: "!"; color: #8a5a00; background: #fff1cf; border-radius: 50%; width: 16px; text-align: center; left: 4px; }
.checks li.bad::before { content: "\2715"; color: #a31d1d; }
.mini-list { list-style: none; margin: 0; padding: 0; font-size: .84rem; } .mini-list li { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; border-bottom: 1px solid #f3edea; }
.mini-list small { color: var(--muted); display: block; }

.actionbar { flex: none; background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0,0,0,.05); padding: 10px 24px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.actionbar .sum { display: flex; gap: 22px; align-items: baseline; font-size: .86rem; color: var(--muted); flex-wrap: wrap; }
.actionbar .sum b { color: var(--ink); font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.actionbar .btns { display: flex; gap: 10px; align-items: center; }
.actionbar .btn { margin: 0; width: auto; }
.btn-primary-lg { background: var(--brand); color: #fff; padding: 11px 30px; font-size: 1rem; border: 0; border-radius: 10px; font-weight: 800; cursor: pointer; }
.btn-primary-lg:hover { background: #521320; }
.btn-text { background: none; border: 0; color: var(--muted); font-weight: 700; cursor: pointer; text-decoration: none; padding: 10px 6px; font: inherit; font-weight: 700; }
.btn-text.danger { color: #a31d1d; }
.help { font-size: .76rem; color: var(--muted); margin-top: 4px; }

@media (max-width: 1280px) { .doc-grid { grid-template-columns: 290px minmax(0, 1fr) 270px; } }
@media (max-width: 1000px), (max-height: 560px) {
  body.app { height: auto; overflow: auto; }
  .app-form, .app-main { display: block; min-height: auto; }
  .doc-grid, .doc-grid.hub { display: grid; grid-template-columns: 1fr; }
  .col { overflow: visible; } .panel.fill .panel-b.scroll, .tbl-scroll { max-height: 70vh; }
  .goat-rows { min-height: 260px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .actionbar { position: sticky; bottom: 0; padding: 10px 14px; z-index: 30; } .actionbar .sum { display: none; }
  .actionbar .btns { width: 100%; } .btn-primary-lg { flex: 1; }
  .app .msgs { left: 12px; right: 12px; max-width: none; }
  .gr-totals { gap: 12px; }
  .doc-head { flex-direction: column; align-items: stretch; gap: 8px; }
  .doc-title h1 { font-size: 1.25rem; white-space: nowrap; }
  .doc-tools { width: 100%; } .doc-tools .chip { flex: 1; } .doc-tools .chip select { width: 100%; max-width: 100%; }
  .panel-h .hint { display: none; }
  .app-main { padding: 10px 12px 12px; } .tbl-scroll { overflow-x: auto; }
  .goat-rows .dt td, .goat-rows .dt th { padding-left: 4px; padding-right: 4px; }
  .goat-rows .dt .inp input { width: 70px; }
  .gr-tools .tip { display: none; }
}

/* receive: trucks already logged, shown as quick links above the form */
.otw { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; margin-bottom: 10px; background: #fff7e0; border: 1px solid #f0dca0; border-radius: 10px; font-size: .85rem; flex: none; }
.otw a { padding: 4px 11px; border-radius: 999px; background: #fff; border: 1px solid #e3c46a; color: var(--brand); font-weight: 700; text-decoration: none; }
.otw a:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* columns scroll inside themselves rather than clipping their last fields */
.field input[type=number], .field input[type=datetime-local], .field input[type=date], .field input[type=text] { width: 100%; padding: 9px 10px; border: 1px solid #d9cec9; border-radius: 8px; font: inherit; background: #fff; box-sizing: border-box; }
.col > .panel:not(.fill) { flex: none; }

/* supplier picker, purchase order and bills */
.sg-wrap { position: relative; }
.sg-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 2px); margin: 0; padding: 4px; list-style: none; background: #fff; border: 1px solid #d9cec9; border-radius: 10px; box-shadow: 0 10px 28px rgba(60,20,25,.16); max-height: 260px; overflow: auto; }
.sg-list li { display: flex; align-items: baseline; gap: 8px; padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: .9rem; }
.sg-list li:hover, .sg-list li.on { background: #f6eeeb; }
.sg-list li small { color: var(--muted); } .sg-list li em { margin-left: auto; font-style: normal; font-size: .76rem; color: #8a5a00; font-weight: 700; }
.sg-list li.add { color: var(--brand-deep); font-weight: 700; }
.sg-card { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; min-height: 20px; margin-top: 6px; padding: 6px 10px; border-radius: 8px; background: #f7f3f1; color: #5d504e; font-size: .8rem; }
.sg-card.empty { display: none; } .sg-card.new { background: #e8f3fb; color: #1b5a86; }
.sg-card .owed { color: #8a5a00; background: #fff1cf; border-radius: 999px; padding: 1px 9px; font-size: .74rem; }
.field select { width: 100%; padding: 9px 10px; border: 1px solid #d9cec9; border-radius: 8px; font: inherit; background: #fff; box-sizing: border-box; }
.field select:disabled { background: #f5f1ef; color: #9a8d89; }
.pay-seg { margin-top: 2px; }
.subtabs { display: flex; gap: 4px; margin: -2px 0 10px; border-bottom: 1px solid var(--line); flex: none; }
.subtabs a { padding: 7px 14px; text-decoration: none; color: var(--muted); font-weight: 700; font-size: .88rem; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.subtabs a:hover { color: var(--ink); } .subtabs a.on { color: var(--brand-deep); border-bottom-color: var(--brand); }
.pill.pill-blue { background: #e3effa; color: #1b5a86; }
.pay-form { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.pay-form input { padding: 4px 8px; border: 1px solid #d9cec9; border-radius: 7px; font: inherit; font-size: .82rem; width: 130px; }
.pay-form input[type=date] { width: 128px; }
.sup-bars { padding: 10px 14px; display: grid; gap: 8px; }
.sup-bars div { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: .86rem; }
.sup-bars i { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: #efe7e3; position: relative; overflow: hidden; }
.sup-bars i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w); background: var(--brand); border-radius: 3px; }
.fold > summary { cursor: pointer; list-style: none; border-radius: 12px; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: "\25BE"; color: var(--muted); margin-left: 6px; }
.fold[open] > summary { border-radius: 12px 12px 0 0; } .fold[open] > summary::after { content: "\25B4"; }
.fold:not([open]) > summary { border-bottom: 0; }
.bills-t small { white-space: nowrap; }
.bills-t .pay-form input[type=text] { width: 112px; }
