:root{
  --ink:#1A1A1A; --muted:#5C5C5C; --line:#E5E5E5; --soft:#F5F5F5; --soft2:#FAFAFA;
  --blue:#005FE0; --blue-d:#004BB0; --blue-l:#EEF4FF;
  --green:#0B7A3B; --green-l:#EAF6EE; --amber:#B45309; --amber-l:#FFF4E5; --red:#B42318; --red-l:#FDECEA;
}
*{box-sizing:border-box}
html,body{margin:0;background:#fff;color:var(--ink);font-family:Inter,system-ui,-apple-system,sans-serif;-webkit-font-smoothing:antialiased}
body{padding-bottom:env(safe-area-inset-bottom)}
button,input,select{font:inherit;color:inherit}
a{color:var(--blue);text-decoration:none}
.center{min-height:60vh;display:flex;align-items:center;justify-content:center;padding:24px;text-align:center}
.muted{color:var(--muted)}
.wrap{max-width:640px;margin:0 auto;padding:0 20px 40px}
.top{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:20px 0 12px}
.top .sub{font-size:13px;color:var(--muted)}
.top h1{margin:2px 0 0;font-size:28px;font-weight:700;letter-spacing:-.02em}
.bar{display:flex;align-items:center;gap:6px;padding:14px 0 8px;margin-left:-10px}
.bar h1{margin:0;font-size:22px;font-weight:700}
.bar .sub{font-size:13px;color:var(--muted)}
.back{width:44px;height:44px;border:0;background:none;display:flex;align-items:center;justify-content:center;cursor:pointer;border-radius:10px;flex-shrink:0}
.back:active{background:var(--soft)}
.icon{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.card{border:1px solid var(--line);border-radius:16px;padding:14px 16px}
.panel{background:var(--soft);border-radius:16px;padding:16px}
.stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin-top:10px}
.stat .k{font-size:12px;color:var(--muted)}
.stat .v{font-size:20px;font-weight:700;margin-top:2px;white-space:nowrap}
.pos{color:var(--green)} .neg{color:var(--red)}
.row-sb{display:flex;justify-content:space-between;align-items:baseline;gap:8px}
h2{font-size:15px;font-weight:600;margin:22px 0 10px}
.alerts{display:flex;flex-direction:column;gap:8px}
.alert{display:flex;align-items:center;gap:12px;padding:12px 14px;border:1px solid var(--line);border-radius:12px;background:#fff;width:100%;text-align:left;cursor:pointer;min-height:48px}
.alert .dot{width:8px;height:8px;border-radius:4px;flex-shrink:0}
.alert .t{flex:1;font-size:14px}
.alert .a{font-size:13px;color:var(--blue);font-weight:600}
.tiles{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin-top:20px}
.tile{min-height:96px;padding:14px;border-radius:16px;border:1px solid var(--line);background:#fff;display:flex;flex-direction:column;justify-content:space-between;gap:10px;color:var(--ink);text-align:left;cursor:pointer}
.tile:active{background:var(--soft2)}
.tile .ic{width:36px;height:36px;border-radius:10px;background:var(--blue-l);color:var(--blue);display:flex;align-items:center;justify-content:center}
.tile .l{font-size:15px;font-weight:600}
.tile .s{font-size:12px;color:var(--muted);margin-top:2px}
.tbl{width:100%;border-collapse:collapse;font-size:15px}
.tbl th{font-size:12px;color:var(--muted);font-weight:500;text-align:right;padding:8px 0;border-bottom:1px solid var(--line)}
.tbl th:first-child,.tbl td:first-child{text-align:left}
.tbl td{text-align:right;padding:11px 0;border-bottom:1px solid #F0F0F0}
.tbl td:first-child{font-weight:500}
.tbl tr.tot td{font-weight:700;border-bottom:0}
.tbl .dim{color:var(--muted)}
.lines{display:flex;flex-direction:column;gap:8px;font-size:14px}
.lines .tot{padding-top:8px;border-top:1px solid #E0E0E0;font-weight:700;font-size:15px}
.lines .k{color:var(--muted)}
.btn{height:52px;border:0;border-radius:12px;background:var(--blue);color:#fff;font-size:16px;font-weight:600;width:100%;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:8px}
.btn:active{background:var(--blue-d)}
.btn[disabled]{opacity:.5;cursor:default}
.btn.ghost{background:#fff;color:var(--ink);border:1px solid var(--line)}
.btn.small{height:40px;font-size:14px;width:auto;padding:0 14px}
.link{border:0;background:none;color:var(--blue);font-weight:600;font-size:14px;cursor:pointer;padding:10px 0;min-height:44px}
.note{font-size:12px;color:var(--muted);text-align:center;margin:8px 0}
.seg{display:flex;gap:4px;padding:4px;background:#F0F0F0;border-radius:10px;overflow-x:auto}
.seg button{flex:1;min-width:max-content;height:36px;border:0;border-radius:8px;background:transparent;font-size:14px;font-weight:500;color:var(--muted);padding:0 12px;cursor:pointer}
.seg button[aria-pressed="true"]{background:#fff;color:var(--ink);font-weight:600;box-shadow:0 1px 2px rgba(0,0,0,.08)}
.fg{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}
.fg .c{padding:10px 8px;border-radius:12px;background:var(--soft)}
.fg .c .n{font-size:12px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.fg .c .v{font-size:18px;font-weight:700}
.fg .c .s{font-size:11px;color:var(--muted)}
.fg .c.short{background:var(--red-l)}
.fg .c.short .s{color:var(--red);font-weight:600}
.ing{padding:10px 0;border-bottom:1px solid #F0F0F0}
.ing .meter{height:6px;border-radius:3px;background:#EDEDED;overflow:hidden;margin:6px 0}
.ing .meter i{display:block;height:6px;border-radius:3px}
.ing .st{font-size:12px;font-weight:600}
.field{display:flex;flex-direction:column;gap:4px;font-size:12px;color:var(--muted)}
.field input,.field select,.in{height:44px;padding:0 12px;border:1px solid #D9D9D9;border-radius:10px;font-size:16px;color:var(--ink);background:#fff;width:100%}
.in.num{text-align:right}
.photo{width:96px;height:120px;flex-shrink:0;border:1.5px dashed #BDBDBD;border-radius:12px;background:var(--soft2);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;font-size:12px;font-weight:500;color:var(--muted);cursor:pointer;overflow:hidden;position:relative}
.photo img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
.photo input{position:absolute;inset:0;opacity:0;cursor:pointer}
.item{border:1px solid var(--line);border-radius:12px;padding:10px;display:grid;grid-template-columns:1fr 84px 104px 36px;gap:8px;align-items:end;margin-bottom:8px}
.item .name{grid-column:1/-1;display:grid;grid-template-columns:1fr;gap:8px}
.item .x{width:36px;height:44px;border:0;background:none;color:var(--muted);cursor:pointer;font-size:20px}
.item .lbl{font-size:11px;color:var(--muted);margin-bottom:2px}
.list .r{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:12px 0;border-bottom:1px solid #F0F0F0;width:100%;background:none;border-left:0;border-right:0;border-top:0;text-align:left;cursor:pointer}
.list .r .t{font-weight:600;font-size:15px}
.list .r .s{font-size:12px;color:var(--muted);margin-top:2px}
.pill{display:inline-block;padding:3px 9px;border-radius:999px;font-size:12px;font-weight:600;background:var(--soft);color:var(--muted)}
.pill.ok{background:var(--green-l);color:var(--green)}
.pill.warn{background:var(--amber-l);color:var(--amber)}
.toast{position:fixed;left:50%;bottom:24px;transform:translateX(-50%) translateY(20px);background:var(--ink);color:#fff;padding:12px 18px;border-radius:12px;font-size:14px;opacity:0;pointer-events:none;transition:.2s;z-index:50;max-width:90vw;text-align:center}
.toast.show{opacity:1;transform:translateX(-50%)}
.toast.err{background:var(--red)}
.sheet-bg{position:fixed;inset:0;background:rgba(0,0,0,.35);z-index:40;display:flex;align-items:flex-end;justify-content:center}
.sheet{background:#fff;width:100%;max-width:440px;border-radius:20px 20px 0 0;padding:20px 20px calc(20px + env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:14px;align-items:center}
.sheet h3{margin:0;font-size:18px}
.dots{display:flex;gap:12px}
.dots i{width:14px;height:14px;border-radius:7px;border:2px solid #BDBDBD}
.dots i.on{background:var(--ink);border-color:var(--ink)}
.pad{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;width:100%}
.pad button{height:54px;border:0;border-radius:12px;background:#F2F2F2;font-size:22px;font-weight:600;cursor:pointer}
.pad button:active{background:#E4E4E4}
.err{color:var(--red);font-size:14px;min-height:18px}
.login{max-width:360px;margin:12vh auto 0;padding:0 20px;display:flex;flex-direction:column;gap:12px}
.login h1{margin:0 0 8px;font-size:28px}
@media (min-width:700px){ .tiles{grid-template-columns:repeat(3,minmax(0,1fr))} }
@media print{ .bar,.btn,.link{display:none} }

/* Driver pay › route sheet › "Cost per delivery": on phones, show each stop as a stacked block
   (no side-scrolling table) so the whole sheet scrolls straight down. */
@media (max-width:699px){
  .sheet .card[style*="overflow-x:auto"]{overflow:visible !important}
  .sheet .card[style*="overflow-x:auto"] .tbl{min-width:0 !important;margin-top:6px}
  .sheet .card[style*="overflow-x:auto"] .tbl thead{display:none}
  .sheet .card[style*="overflow-x:auto"] .tbl tbody{display:block}
  .sheet .card[style*="overflow-x:auto"] .tbl tr{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px 8px;padding:14px 0;border-bottom:1px solid var(--line)}
  .sheet .card[style*="overflow-x:auto"] .tbl td{display:block;padding:0;border:0;text-align:left;font-size:15px}
  .sheet .card[style*="overflow-x:auto"] .tbl td:first-child{grid-column:1/-1;font-weight:600;font-size:16px}
  .sheet .card[style*="overflow-x:auto"] .tbl td .dim{font-weight:400}
  .sheet .card[style*="overflow-x:auto"] .tbl td:nth-child(n+2):nth-child(-n+6)::before{display:block;font-size:12px;font-weight:500;color:var(--muted);margin-bottom:2px}
  .sheet .card[style*="overflow-x:auto"] .tbl td:nth-child(2)::before{content:"Loading"}
  .sheet .card[style*="overflow-x:auto"] .tbl td:nth-child(3)::before{content:"Drive"}
  .sheet .card[style*="overflow-x:auto"] .tbl td:nth-child(4)::before{content:"At stop"}
  .sheet .card[style*="overflow-x:auto"] .tbl td:nth-child(5)::before{content:"Drive back"}
  .sheet .card[style*="overflow-x:auto"] .tbl td:nth-child(6)::before{content:"Miles"}
  .sheet .card[style*="overflow-x:auto"] .tbl td:nth-child(7){grid-column:1/-1;padding-top:10px;border-top:1px dashed var(--line);text-align:right}
  .sheet .card[style*="overflow-x:auto"] .tbl td:nth-child(7)::before{content:"Delivery cost";float:left;font-size:14px;font-weight:600;color:var(--ink)}
  .sheet .card[style*="overflow-x:auto"] .tbl tr td[colspan="7"]{grid-column:1/-1}
  .sheet .card[style*="overflow-x:auto"] .tbl tr.tot{grid-template-columns:1fr auto;border-bottom:0;font-weight:700}
  .sheet .card[style*="overflow-x:auto"] .tbl tr.tot td:nth-child(2){display:none}
  .sheet .card[style*="overflow-x:auto"] .tbl tr.tot td:first-child{grid-column:auto;font-size:17px}
  .sheet .card[style*="overflow-x:auto"] .tbl tr.tot td:nth-child(3){text-align:right;font-size:17px}
  .sheet .card[style*="overflow-x:auto"] .tbl tr.tot td:nth-child(3)::before{content:none}
}
