/* ABS Motorworks UI. One design system: navy structure, white surfaces, red only for the main action on a screen. */
:root{
  --bg:#f4f5f8;--surface:#fff;--line:#e4e6ee;--line-strong:#cfd3df;
  --text:#14172e;--muted:#667085;
  --navy:#030327;--red:#FA2424;--gold:#F0E08A;
  --red-soft:#fdeceb;--radius:12px;--radius-sm:8px;
  --shadow:0 1px 2px rgba(3,3,39,.05),0 1px 3px rgba(3,3,39,.04);
  --wrap:76rem;--gutter:1.5rem;
}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;min-height:100vh;display:flex;flex-direction:column;background:var(--bg);color:var(--text);font:16px/1.55 "Segoe UI",system-ui,-apple-system,Roboto,Arial,sans-serif;-webkit-font-smoothing:antialiased}
a{color:var(--navy)}
h1{font-size:1.75rem;line-height:1.2;margin:0;color:var(--navy);font-weight:800;letter-spacing:-.015em}
h2{font-size:1.1rem;margin:2rem 0 .8rem;color:var(--navy);font-weight:800}
h3{font-weight:800}
p{margin:.4rem 0 1rem}
.muted,.meta{color:var(--muted)}
main{flex:1 0 auto;width:100%;max-width:var(--wrap);margin:0 auto;padding:1.75rem var(--gutter) 4rem}
main > h1{margin-bottom:1.25rem}
.pagehead{display:flex;align-items:center;justify-content:space-between;gap:1rem;margin:0 0 1.25rem}
.pagehead h1{margin:0}

/* ---------- header ---------- */
.top{background:var(--navy)}
.bar{max-width:var(--wrap);margin:0 auto;padding:0 var(--gutter);display:grid;grid-template-columns:minmax(0,1fr) auto;grid-template-areas:"brand who" "nav nav";align-items:center}
.brand{grid-area:brand;justify-self:start;display:inline-flex;align-items:center;text-decoration:none;padding:.65rem 0}
.brand-logo{display:block;height:50px;width:auto}
nav{grid-area:nav;display:flex;flex-wrap:wrap;align-items:center;gap:.5rem;min-width:0;border-top:1px solid rgba(255,255,255,.1);margin:0 -.5rem;padding:.55rem 0}
nav a{flex:0 0 auto;display:inline-flex;align-items:center;min-height:44px;padding:.4rem .8rem;border-radius:var(--radius-sm);color:rgba(255,255,255,.72);text-decoration:none;font-size:.93rem;font-weight:600;white-space:nowrap;transition:background .15s,color .15s}
nav a:hover{color:#fff;background:rgba(255,255,255,.08)}
nav a.on{color:#fff;background:rgba(255,255,255,.14)}
.who{grid-area:who;display:flex;align-items:center;gap:.75rem}
.badge{background:var(--gold);color:var(--navy);font-weight:700;font-size:.78rem;padding:.25rem .7rem;border-radius:99px;white-space:nowrap}
.top .who form{margin:0}
.top button.link{min-height:44px;padding:.3rem .9rem;background:transparent;color:#fff;border:1px solid rgba(255,255,255,.35);border-radius:var(--radius-sm);font-size:.9rem;font-weight:600;cursor:pointer}
.top button.link:hover{background:rgba(255,255,255,.1);filter:none}
.top a:focus-visible,.top button:focus-visible{outline:2px solid #fff;outline-offset:2px}

/* ---------- footer (mirrors the header) ---------- */
.foot{background:var(--navy);margin-top:auto;flex:0 0 auto}
.foot .bar{display:flex;flex-wrap:wrap;align-items:center;gap:.6rem 1.2rem;padding-top:.9rem;padding-bottom:.9rem}
.foot .brand{padding:0;min-height:44px}
.foot .brand-logo{height:32px}
.foot nav{flex:1 1 auto;flex-wrap:wrap;overflow:visible;border:0;margin:0;padding:0}
.foot .legal{flex:1 0 100%;margin:.4rem 0 0;padding-top:.7rem;border-top:1px solid rgba(255,255,255,.1);color:rgba(255,255,255,.6);font-size:.8rem}
.foot a:focus-visible{outline:2px solid #fff;outline-offset:2px}
@media (max-width:560px){.foot .bar{flex-direction:column;align-items:flex-start}.foot nav{flex:0 0 auto}}

/* ---------- cards, forms, buttons ---------- */
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:1.25rem 1.35rem;margin:0 0 1rem;max-width:46rem;box-shadow:var(--shadow)}
.card h2:first-child{margin-top:0}
label{display:block;font-size:.85rem;font-weight:700;color:var(--text);margin:1rem 0 0}
label:first-child{margin-top:0}
input,select,textarea{display:block;width:100%;font:inherit;font-size:1rem;color:var(--text);background:#fff;padding:.6rem .85rem;margin-top:.35rem;border:1px solid var(--line-strong);border-radius:var(--radius-sm);min-height:2.75rem;transition:border-color .15s,box-shadow .15s}
input::placeholder{color:#9aa0b2}
input:focus,select:focus,textarea:focus{outline:0;border-color:var(--navy);box-shadow:0 0 0 3px rgba(3,3,39,.12)}
button,.button{display:inline-flex;align-items:center;justify-content:center;gap:.4rem;font:inherit;font-weight:650;font-size:.95rem;min-height:2.75rem;padding:.5rem 1.25rem;background:var(--red);color:#fff;border:1px solid var(--red);border-radius:var(--radius-sm);cursor:pointer;text-decoration:none;text-align:center;line-height:1.2;transition:filter .15s,background .15s,border-color .15s}
button:hover,.button:hover{filter:brightness(.93)}
button:focus-visible,.button:focus-visible,a:focus-visible{outline:2px solid var(--navy);outline-offset:2px}
a.button{background:#fff;color:var(--navy);border-color:var(--line-strong)}
a.button:hover{background:var(--bg);filter:none;border-color:var(--navy)}
a.button.primary{background:var(--red);border-color:var(--red);color:#fff}
a.button.primary:hover{background:var(--red);filter:brightness(.93)}
button.secondary,button.small,a.button.small{background:#fff;color:var(--navy);border-color:var(--line-strong)}
button.small,a.button.small{min-height:44px;padding:.3rem .9rem;font-size:.9rem;font-weight:600}
button.small:hover,button.secondary:hover{background:var(--bg);filter:none;border-color:var(--navy)}
form.inline{display:inline;margin:0}
.card > button[type=submit],form > button[type=submit]{margin-top:1.1rem}
.card > button.secondary{margin-right:.6rem}

/* ---------- messages ---------- */
.flash{background:var(--surface);border:1px solid var(--line);border-left:4px solid var(--navy);border-radius:var(--radius-sm);padding:.8rem 1rem;margin:0 0 1rem;max-width:46rem;font-weight:550;box-shadow:var(--shadow)}
.flash.error{border-left-color:var(--red);background:var(--red-soft)}
.notice{background:var(--red-soft);border-left:4px solid var(--red);border-radius:var(--radius-sm);padding:.8rem 1rem;font-weight:550}
.notice a{color:inherit}
.notice.warn{background:#fff3cd;border-left-color:#d98e00;color:#4d3800}

/* ---------- tables ---------- */
.tablewrap{overflow-x:auto;-webkit-overflow-scrolling:touch;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow)}
.tablewrap table{min-width:34rem}
table{width:100%;border-collapse:collapse;background:var(--surface);font-size:.95rem}
.tablewrap table,.card table{border:0}
th{font-size:.76rem;font-weight:800;text-transform:uppercase;letter-spacing:.06em;color:#2a3045;text-align:left;padding:.8rem 1rem;background:#fafbfd;border-bottom:1px solid var(--line);white-space:nowrap}
td{padding:.85rem 1rem;border-bottom:1px solid var(--line);vertical-align:middle}
tr:last-child td{border-bottom:0}
tbody tr:hover td{background:#fafbfe}
td.num,th.num{text-align:right;font-variant-numeric:tabular-nums}
tr.low td{background:var(--red-soft)}
tr.low td:first-child{box-shadow:inset 3px 0 0 var(--red)}
tr.voided td{color:#9a9ca8;text-decoration:line-through}
tr.voided td:last-child{text-decoration:none}

/* ---------- login ---------- */
body.login-page{background:var(--navy);min-height:100vh}
body.login-page main{background:transparent;display:flex;flex-direction:column;align-items:center;padding-top:3rem}
body.login-page .flash{width:100%;max-width:24rem;margin:0 0 1rem}
.login{width:100%;max-width:24rem;margin:0 auto}
.login h1{text-align:center;color:#fff;margin:0 0 1.2rem;font-size:1.5rem}
.login-logo{display:block;width:260px;max-width:80%;height:auto;margin:0 auto .9rem;border:0;border-radius:0;background:none}
.login .badge{display:block;width:max-content;margin:0 auto 1.6rem}
.login .card{max-width:none;width:100%;padding:1.5rem;margin:0}
.login .card label{color:var(--text)}
.login button{width:100%}

/* ---------- cars page ---------- */
.summary{margin:-.6rem 0 1.1rem;color:var(--muted)}
.carsearch{display:flex;gap:.5rem;margin:0 0 1rem;align-items:center;max-width:46rem}
.carsearch input[type=search]{flex:1 1 auto;margin:0;min-width:0;height:2.75rem;line-height:1.2}
.carsearch button{flex:0 0 auto;margin:0;height:2.75rem}
.chips{display:flex;flex-wrap:wrap;gap:.5rem;margin:0 0 1.1rem}
.chips a{display:inline-flex;align-items:center;min-height:44px;padding:.4rem 1.05rem;border:1px solid var(--line-strong);background:var(--surface);color:var(--navy);border-radius:99px;text-decoration:none;font-weight:650;font-size:.92rem}
.chips a:hover{border-color:var(--navy)}
.chips a.on{background:var(--navy);color:#fff;border-color:var(--navy)}
.src{display:inline-block;padding:.18rem .65rem;border-radius:99px;font-size:.76rem;font-weight:700;background:#eceef4;color:var(--navy)}
.src.mymechanic{background:var(--gold)}
.pill{display:inline-block;padding:.18rem .65rem;border-radius:99px;font-size:.78rem;font-weight:650;background:#eceef4;color:var(--muted)}
.pill.draft{background:#fde7e7;color:#a11}
.pill.paid{background:#e1f4e6;color:#18632a}
.cartable td:first-child b{font-size:1rem;letter-spacing:.02em}
.cartable td.acts{text-align:right;white-space:nowrap}
.cartable .actrow{display:inline-flex;flex-wrap:nowrap;gap:.5rem;align-items:center;justify-content:flex-end}
.cartable .actrow .button{min-height:44px;padding:.3rem .95rem;font-size:.9rem}
.editlink{margin-left:.35rem;font-size:.85rem;color:var(--muted)}
.acts .editlink:hover{color:var(--navy)}

/* ---------- invoice form ---------- */
#inv-form > .card{max-width:66rem}
#inv-form > .card:first-of-type{display:grid;grid-template-columns:repeat(auto-fit,minmax(15rem,1fr));gap:0 1.2rem}
#inv-form select[name=payment_type]{max-width:22rem}
#inv-form > .card:first-of-type label{margin-top:1rem}
.carcard{display:flex;flex-wrap:wrap;gap:.4rem .9rem;align-items:center;max-width:66rem}
.carcard .plate{font-size:1.25rem}
.item-row{max-width:66rem}
.item-row select{width:100%}
.item-row .rm{margin-top:1rem}
.item-row .line-amt{margin-top:1rem;font-size:.85rem;font-weight:600;color:var(--muted)}
.item-row .line-amt output{display:block;margin-top:.35rem;font-size:1rem;font-weight:600;color:var(--navy)}
.mmtotals{margin:.3rem 0 0}
.actionbar{display:flex;gap:.6rem;flex-wrap:wrap;margin:0 0 1rem}
.drafts-note{margin:.2rem 0 1rem;font-weight:600}
details.discard{max-width:56rem}
details.discard summary{cursor:pointer;font-weight:600;color:var(--navy)}
.low-text{color:var(--red)}
@media (min-width:1100px){
  .item-row{display:grid;gap:0 .9rem;align-items:end;grid-template-columns:minmax(9rem,1.6fr) minmax(0,2.2fr) 5.5rem 8rem auto auto}
  .has-mm .item-row{grid-template-columns:minmax(9rem,1.6fr) minmax(0,2.2fr) 5.5rem 8rem 8rem auto auto}
  .item-row label,.item-row .line-amt{margin:0}
  .item-row .line-amt output{padding:.5rem 0}
  .item-row .rm{margin:0 0 .15rem}
}

/* ---------- activity page ---------- */
.activitywrap table{min-width:0}
.activitywrap td{overflow-wrap:anywhere;word-break:break-word}
.activitywrap .what details{margin-top:.3rem;font-size:.88rem;color:var(--muted)}
.activitywrap .what summary{cursor:pointer;color:var(--navy);font-weight:600}
.pager{display:flex;gap:1rem;align-items:center;margin:1rem 0}

/* ---------- boss dashboard ---------- */
.filterbar{max-width:none;padding:1rem 1.2rem}
.filterbar .chips{display:flex;gap:.4rem;overflow-x:auto;padding-bottom:.2rem;margin:0;scrollbar-width:none}
.filterbar .chips::-webkit-scrollbar{display:none}
.chip{flex:0 0 auto;display:inline-flex;align-items:center;min-height:44px;padding:0 .95rem;border:1px solid var(--line-strong);border-radius:99px;background:var(--surface);color:var(--navy);text-decoration:none;font-size:.9rem;font-weight:650}
.chip:hover{border-color:var(--navy)}
.chip.on{background:var(--navy);border-color:var(--navy);color:#fff}
.filterbar .daterow{display:flex;flex-wrap:wrap;gap:.2rem .8rem;margin-top:.2rem}
.filterbar .daterow label{flex:1 1 11rem;max-width:16rem}
.filterrow{display:flex;flex-wrap:wrap;gap:.6rem .8rem;align-items:flex-end;margin-top:.8rem}
.filterrow label{flex:1 1 9rem;max-width:14rem;margin:0}
.filterrow select{margin-top:.3rem}
.filterbar .actions{display:flex;align-items:center;gap:1rem;margin:0}
.filterbar .actions button.small{min-height:44px;padding:0 1.2rem;margin:0}
.filterbar .actions a{display:inline-flex;align-items:center;min-height:44px}
.range{margin:.2rem 0 .6rem;font-weight:650;color:var(--navy)}
.tiles{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.8rem;margin:.8rem 0 .5rem}
.tile{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:1.1rem 1.2rem;box-shadow:var(--shadow);min-height:6.2rem}
.tile span{display:block;color:var(--muted);font-size:.72rem;font-weight:800;text-transform:uppercase;letter-spacing:.08em}
.tile b{display:block;margin-top:.35rem;font-size:1.9rem;line-height:1.15;color:var(--navy);letter-spacing:-.02em;overflow-wrap:anywhere}
.tile.neg b{color:var(--red)}
.tile small{display:block;margin-top:.3rem;font-size:.76rem;overflow-wrap:anywhere}
.tile .delta{display:inline-block;padding:.05rem .5rem;border-radius:99px;font-weight:700;background:#eceef4;color:var(--muted)}
.tile .delta.up{background:#e1f4e6;color:#18632a}
.tile .delta.down{background:var(--red-soft);color:#a11}
a.tile{display:block;text-decoration:none;color:inherit}
a.tile:hover{border-color:var(--navy)}
.statsline{margin:.2rem 0 .6rem;font-size:.9rem}
.note{font-size:.85rem;margin:0 0 .6rem}
.row2,.row3{display:grid;gap:1rem;margin:1rem 0}
.row3{grid-template-columns:repeat(auto-fit,minmax(16rem,1fr))}
@media (min-width:900px){.row2{grid-template-columns:2fr 1fr}}
.row2 .panel,.row3 .panel{margin:0}
.panel{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:.2rem 1.1rem 1.1rem;margin:1rem 0;box-shadow:var(--shadow)}
.panel h2{margin:.9rem 0 .6rem;font-size:1rem}
.panel h3{font-size:.9rem;margin:1rem 0 .5rem;color:var(--text);font-weight:800}
.empty{color:var(--muted);margin:.4rem 0}
.svgchart{display:block;width:100%;height:auto;max-width:100%}
.svgchart .b-rev{fill:var(--navy)}
.svgchart .b-exp{fill:#FA2424}
.svgchart .axis{stroke:var(--line-strong);stroke-width:1}
.svgchart .grid{stroke:var(--line);stroke-width:1;stroke-dasharray:2 4;opacity:.7}
.svgchart .ax{font-size:11px;fill:var(--muted)}
.legend-inline{font-size:.85rem;margin:.4rem 0}
.sw-rev,.sw-exp{display:inline-block;width:.7rem;height:.7rem;border-radius:99px;margin:0 .35rem 0 .6rem}
.sw-rev{background:var(--navy)}
.sw-exp{background:#FA2424}
.numbers summary{cursor:pointer;font-weight:600;color:var(--navy);min-height:44px;display:flex;align-items:center}
.numbers ul{margin:.2rem 0;padding-left:1.1rem;font-size:.85rem;max-height:16rem;overflow:auto}
.rank{list-style:none;margin:0;padding:0;counter-reset:r}
ol.rank li{counter-increment:r}
ol.rank .rk::before{content:counter(r) ".";display:inline-block;min-width:1.4rem;color:var(--muted);font-weight:700}
.qty{margin-right:.6rem}
.rank li{margin:.7rem 0}
.rank-row{display:flex;justify-content:space-between;gap:.8rem;font-size:.95rem}
.rank-name{min-width:0;overflow-wrap:anywhere;font-weight:600}
.rank-val{flex:0 0 auto;color:var(--muted);text-align:right}
.hbar{display:block;height:.4rem;margin-top:.3rem;background:var(--line);border-radius:99px;overflow:hidden}
.hbar i{display:block;height:100%;border-radius:99px}
.hbar .rev{background:var(--navy)}
.hbar .exp{background:#FA2424}
.paybar{display:flex;height:.9rem;border-radius:99px;overflow:hidden;background:var(--line);margin-top:.2rem}
.paybar i{display:block;height:100%}
.legend{list-style:none;padding:0;margin:.8rem 0}
.legend li{display:flex;align-items:center;margin:.3rem 0;font-size:.9rem}
.lg-val{margin-left:auto;padding-left:.6rem;color:var(--muted);text-align:right}
.legend .sw{display:inline-block;width:.7rem;height:.7rem;border-radius:99px;margin-right:.5rem}
.filter-note{font-size:.9rem}
@media (min-width:700px){.tiles{grid-template-columns:repeat(4,minmax(0,1fr))}}

/* ---------- compact forms (stock, lists) ---------- */
.rowform{display:flex;flex-wrap:wrap;gap:.8rem;align-items:flex-end;max-width:none}
.rowform label{flex:1 1 14rem;margin:0}
.rowform h2{flex:1 0 100%;margin:0 0 .2rem}
.rowform button{margin:0!important;flex:0 0 auto}
td form.inline{display:flex;flex-wrap:wrap;gap:.5rem;align-items:center;margin:0}
td form.inline input,td form.inline select{width:auto;min-height:44px;margin:0;padding:.3rem .6rem;font-size:1rem}
td form.inline input[name=qty]{width:4.8rem}
td form.inline input[name=note]{width:9rem}
td form.inline input[name=low_threshold]{width:4.5rem}
td form.inline button{margin:0!important}
td form.inline select{max-width:7.5rem}
td .button.small+a{margin-left:.5rem}

form.cols{display:grid;grid-template-columns:repeat(auto-fit,minmax(12rem,1fr));gap:1rem 1.2rem;align-items:end;max-width:64rem}
form.cols label{margin:0}
form.cols > button,form.cols > .actions{grid-column:1/-1;justify-self:start;margin:0!important}
.rowform select,.rowform input{margin-top:.35rem}

.chiprow{display:flex;flex-wrap:wrap;gap:.2rem 1.6rem;align-items:center;margin:0 0 1rem}
.chiprow .chips{margin:0}
td a[href$="/print"]{white-space:nowrap}

input[type=checkbox],input[type=radio]{display:inline-block;width:1.2rem;height:1.2rem;min-height:0;margin:0 .55rem 0 0;vertical-align:middle;accent-color:var(--navy)}

/* ---------- phones ---------- */
@media (max-width:560px){
  :root{--gutter:1rem}
  main{padding-top:1.2rem;padding-bottom:3rem}
  h1{font-size:1.45rem}
  .brand-logo{height:36px}
  .bar{padding-top:.2rem}
  .card,.flash,.carsearch{max-width:none}
  .card{padding:1rem}
  .pagehead{flex-wrap:wrap}
  form:not(.carsearch):not(.rowform):not(.inline) > button[type=submit],.card > button[type=submit]{width:100%}
  .who .badge{display:none}
  body.login-page main{padding:1.6rem 1rem 2rem}
}
@media (prefers-reduced-motion:reduce){*{transition:none!important}}

/* invoice Share button and status line (screen only; hidden when printing via .no-print) */
.share-btn{min-height:44px;min-width:44px;padding:0 1.2rem;touch-action:manipulation}
.share-btn[disabled]{opacity:.6}
.share-status{display:flex;align-items:center;gap:.8rem;flex-wrap:wrap;margin:.5rem 0}
.share-status[hidden],.share-status a[hidden]{display:none}
.share-status a.button{min-height:44px;display:inline-flex;align-items:center}
.platerow{display:flex;gap:.5rem;align-items:center}
.platerow input{flex:1 1 auto;min-width:0;margin:.35rem 0 0}
.platerow .scan-btn,.carsearch .scan-btn{flex:0 0 auto;margin:.35rem 0 0;min-height:44px;min-width:44px;white-space:nowrap;touch-action:manipulation}
.carsearch .scan-btn{margin:0}
.scan-overlay{position:fixed;inset:0;z-index:1000;background:rgba(3,3,39,.94);display:flex;align-items:center;justify-content:center;padding:1rem}
.scan-overlay[hidden]{display:none}
.scan-box{width:100%;max-width:56rem;color:#fff;text-align:center}
.scan-title{font-size:1.15rem;font-weight:650;margin:0 0 .75rem}
.scan-view{position:relative;width:100%;background:#000;border-radius:var(--radius);overflow:hidden;min-height:12rem}
.scan-view video{display:block;width:100%;height:auto;max-height:65vh;object-fit:fill}
.scan-frame{position:absolute;left:10%;top:35%;width:80%;height:30%;border:3px solid var(--gold);border-radius:.5rem;box-shadow:0 0 0 9999px rgba(0,0,0,.45);pointer-events:none}
.scan-status{min-height:1.6rem;margin:.75rem 0}
.scan-actions{display:flex;gap:.75rem;justify-content:center;flex-wrap:wrap}
.scan-actions .button,.scan-actions button{min-height:44px;min-width:44px;cursor:pointer}
.scan-photo{background:#fff;color:var(--navy);border-color:var(--line-strong)}

/* ---------- tablet / touch (iPad portrait + landscape, phones). Screen only: print is untouched. ---------- */
a,button,input,select,summary,label{touch-action:manipulation}
body{padding-left:env(safe-area-inset-left);padding-right:env(safe-area-inset-right)}
.top{padding-top:env(safe-area-inset-top)}
.foot{padding-bottom:env(safe-area-inset-bottom)}
summary{padding:.6rem 0}
.btnrow{display:flex;flex-wrap:wrap;gap:.5rem .75rem;align-items:center}
.btnrow form{margin:0}
label.check{display:flex;align-items:center;min-height:44px}
input[type=checkbox],input[type=radio]{width:1.4rem;height:1.4rem}
.editlink,td a:not(.button),.pager a,.filter-note a,main > p > a,form.cols > a,.summary a,.carcard a{display:inline-flex;align-items:center;min-height:44px;padding:0 .2rem}
td a:not(.button)+a:not(.button){margin-left:.5rem}
.pager{gap:1rem}
.total-chip{margin-right:auto;font-weight:700;color:var(--navy);align-self:center;white-space:nowrap}
.actionbar{position:sticky;bottom:0;z-index:4;background:var(--bg);border-top:1px solid var(--line);margin:0 calc(-1 * var(--gutter));padding:.6rem var(--gutter) calc(.6rem + env(safe-area-inset-bottom))}
.actionbar button{min-height:48px;min-width:9rem}
#inv-form{padding-bottom:1rem}
#inv-form .item-row .rm{min-height:44px}
@media screen and (max-width:1099px) and (min-width:600px){
  .item-row{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:0 .9rem;align-items:end}
  .item-row .f-prod,.item-row .f-desc{grid-column:span 2}
  .item-row label,.item-row .line-amt{margin-top:1rem}
  .item-row .line-amt{margin-top:1rem}
  .item-row .rm{grid-column:4;margin:1rem 0 0}
}
@media screen and (min-width:561px) and (max-width:820px){
  .actionbar{justify-content:flex-end}
}
@media screen and (max-width:560px){
  .actionbar button{flex:1 1 0;min-width:0}
  .total-chip{flex:1 0 100%}
}
/* wide tables become stacked cards (label above value) below ~820px */
@media screen and (max-width:820px){
  .tablewrap{background:none;border:0;overflow:visible;box-shadow:none}
  .tablewrap table.stack{min-width:0}
  table.stack,table.stack tbody,table.stack tr,table.stack td{display:block;width:100%;min-width:0}
  table.stack thead{display:none}
  table.stack tr{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:.6rem .9rem;margin:0 0 .7rem;box-shadow:var(--shadow)}
  table.stack td{border:0;padding:.25rem 0;overflow-wrap:anywhere}
  table.stack tbody tr:hover td{background:none}
  table.stack tr.low td{background:none}
  table.stack tr.low{border-left:4px solid var(--red);background:var(--red-soft)}
  table.stack td[data-label]::before{content:attr(data-label);display:block;font-size:.72rem;font-weight:700;text-transform:uppercase;letter-spacing:.04em;color:var(--muted)}
  table.stack td form.inline{width:100%}
  table.stack td form.inline input,table.stack td form.inline select{flex:1 1 7rem;min-width:0}
  table.stack td form.inline button{flex:0 0 auto}
  .cartable td:first-child{font-size:1.15rem}
  .cartable td.acts{margin-top:.5rem;text-align:left;white-space:normal}
  .cartable .actrow{flex-wrap:wrap;justify-content:flex-start}
  table.stack td[colspan]{padding:.5rem 0}
}
/* tablets: dashboard/filters and card widths use the room */
@media screen and (min-width:561px) and (max-width:1100px){
  .filterrow label,.filterbar .daterow label{max-width:none}
}
/* the camera overlay must fit short screens (phones/tablets in landscape) */
.scan-overlay{overflow-y:auto;padding:max(1rem,env(safe-area-inset-top)) max(1rem,env(safe-area-inset-right)) max(1rem,env(safe-area-inset-bottom)) max(1rem,env(safe-area-inset-left))}
.scan-box{margin:auto}
@media screen and (max-height:520px){
  .scan-overlay{align-items:flex-start}
  .scan-title{font-size:1rem;margin:0 0 .4rem}
  .scan-view{min-height:0}
  .scan-view video{max-height:55vh;max-height:55dvh;margin:0 auto}
  .scan-status{margin:.4rem 0;min-height:1.3rem}
}
/* invoice sheet on screen: keep it inside the viewport (print layout is in print.css) */
@media screen and (max-width:820px){
  .invoice{padding:.9rem;font-size:13px}
  .invoice .head,.invoice .parties{flex-wrap:wrap;gap:.8rem}
  .invoice .sigs{gap:1rem}
  .invoice .watermark{font-size:80px}
  .actions{gap:.5rem}
  .actions .void-form{flex:1 1 100%}
  .actions .void-form input{flex:1 1 10rem;width:auto}
  .invoice table.items td,.invoice table.items th{padding:.4rem .35rem}
}
@media screen{
  .actions a:not(.button){display:inline-flex;align-items:center;min-height:44px;padding:0 .2rem}
  .actions .void-form{display:flex;flex-wrap:wrap;gap:.5rem;align-items:center}
  .actions .void-form input{margin:0}
  .share-status{gap:.5rem .8rem}
}
.btnrow form > button[type=submit]{margin-top:0}
.carsearch > button{margin:0!important}
@media screen and (min-width:600px) and (max-width:820px){
  table.stack tbody{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.7rem}
  table.stack tr{margin:0}
}
@media screen and (max-width:820px){
  table.stack tr.low td:first-child{box-shadow:none}
  table.stack td form.inline input[name=low_threshold]{flex:0 0 5rem}
  table.stack td form.inline input[name=qty]{flex:0 0 5rem}
}
.tile b{font-size:clamp(1.35rem,3.4vw,1.9rem)}

@media screen and (max-width:820px){table.stack{background:none}}
@media screen and (max-width:560px){
  .invoice .meta{text-align:left}
  .invoice table.items th{white-space:normal;font-size:11px;letter-spacing:0}
}
.card .btnrow{margin-top:.75rem}
.btnrow form > button[type=submit]{width:auto!important}
.filterbar .chips{gap:.5rem}
.chiprow{gap:.5rem 1.6rem}
summary{padding:.7rem 0}
.activitywrap .what details{margin-top:.5rem}
td .button+a:not(.button){margin-left:.6rem}
td a.button,td a:not(.button){margin-top:.25rem;margin-bottom:.25rem}
[hidden]{display:none!important}
.scan-actions label.button{margin:0}
