
/* Final responsive/date fix: date selector stays visible and compact on every screen. */
html,body{max-width:100%;overflow-x:hidden!important;}
.top{
  display:block!important;
  height:auto!important;
  min-height:0!important;
  padding:0 28px!important;
}
.top-row{
  height:72px!important;
  min-height:72px!important;
  display:flex!important;
  align-items:center!important;
  justify-content:space-between!important;
  gap:16px!important;
}
.portal-date-row{
  height:52px!important;
  min-height:52px!important;
  display:flex!important;
  align-items:center!important;
  justify-content:center!important;
  padding:0!important;
}
.portal-date{
  position:static!important;
  display:flex!important;
  align-items:center!important;
  justify-content:center!important;
  gap:8px!important;
  margin:0!important;
  padding:0!important;
  max-width:100%!important;
  flex-wrap:nowrap!important;
}
.portal-date input[type="date"]{
  display:block!important;
  width:170px!important;
  min-width:170px!important;
  max-width:170px!important;
  height:36px!important;
  padding:0 10px!important;
  border:1px solid #ccd6e0!important;
  border-radius:9px!important;
  background:#fff!important;
  color:#172b4d!important;
  font-size:14px!important;
}
.portal-date button{
  display:inline-flex!important;
  width:auto!important;
  min-width:68px!important;
  height:36px!important;
  padding:0 14px!important;
  border:0!important;
  border-radius:9px!important;
  background:var(--teal)!important;
  color:#fff!important;
}
/* Prevent any page section from creating accidental viewport-wide stretching. */
.main,.card,.pagehead,.report-mobile-card,.report-table-card{max-width:100%!important;min-width:0!important;}
.report-date-form .field{flex:0 1 240px!important;width:240px!important;max-width:240px!important;min-width:0!important;}
.report-date-form .input[type="date"]{width:100%!important;max-width:100%!important;}
/* Mobile: header stays compact; navigation wraps instead of cutting off the right side. */
@media screen and (max-width:800px){
  .top{padding:7px 10px 8px!important;}
  .top-row{height:56px!important;min-height:56px!important;gap:8px!important;}
  .brand{min-width:0!important;flex:1 1 auto!important;gap:9px!important;}
  .logo{width:42px!important;height:42px!important;min-width:42px!important;flex:0 0 42px!important;}
  .brand>span:last-child{min-width:0!important;max-width:100%!important;font-size:15px!important;white-space:nowrap!important;overflow:hidden!important;text-overflow:ellipsis!important;}
  .user{flex:0 0 auto!important;}
  .user .password-link,.user .avatar,.user>span:first-child{display:none!important;}
  .user .logout-link{display:inline-flex!important;min-height:40px!important;height:40px!important;}
  .portal-date-row{height:56px!important;min-height:56px!important;}
  .portal-date input[type="date"]{width:150px!important;min-width:150px!important;max-width:150px!important;height:36px!important;font-size:14px!important;}
  .portal-date button{height:36px!important;min-width:68px!important;}
  .layout{min-height:calc(100vh - 118px)!important;}
  .side{height:auto!important;padding:6px 8px!important;overflow:visible!important;}
  .nav{display:grid!important;grid-template-columns:repeat(4,minmax(0,1fr))!important;gap:4px!important;width:100%!important;}
  .nav a{min-width:0!important;white-space:normal!important;text-align:center!important;justify-content:center!important;padding:8px 4px!important;font-size:11px!important;line-height:1.2!important;}
  .main{padding:12px 10px 18px!important;width:100%!important;overflow-x:hidden!important;}
  .report-date-form{width:100%!important;}
  .report-date-form .field{flex:0 1 200px!important;width:200px!important;max-width:100%!important;}
  .report-date-form>.btn,.report-date-form>a.btn{flex:0 0 auto!important;}
}
@media screen and (max-width:380px){
  .portal-date input[type="date"]{width:135px!important;min-width:135px!important;max-width:135px!important;}
  .nav{grid-template-columns:repeat(3,minmax(0,1fr))!important;}
  .report-date-form .field{flex-basis:180px!important;width:180px!important;}
}

/* Header date placement: desktop keeps date + View on the top row immediately after the user/role label. */
@media screen and (min-width:801px){
  .top-row{height:72px!important;min-height:72px!important;display:flex!important;align-items:center!important;gap:18px!important;}
  .user{display:flex!important;align-items:center!important;gap:10px!important;min-width:0!important;}
  .user-role{white-space:nowrap!important;}
  .user .portal-date{position:static!important;transform:none!important;margin:0!important;padding:0!important;display:flex!important;align-items:center!important;justify-content:center!important;gap:8px!important;flex:0 0 auto!important;}
  .user .portal-date input[type="date"]{width:170px!important;min-width:170px!important;max-width:170px!important;height:36px!important;}
  .user .portal-date button{width:82px!important;min-width:82px!important;height:36px!important;padding:0!important;justify-content:center!important;}
}
/* Machine/mobile: keep the date row below the compact brand header and center the pair as one unit. */
@media screen and (max-width:800px){
  .top{position:sticky!important;height:118px!important;min-height:118px!important;padding:7px 10px 0!important;}
  .top-row{height:56px!important;min-height:56px!important;display:flex!important;align-items:center!important;justify-content:space-between!important;}
  .user{position:static!important;display:flex!important;align-items:center!important;}
  .user-role,.user .avatar,.user .password-link{display:none!important;}
  .user .portal-date{position:absolute!important;left:50%!important;top:64px!important;right:auto!important;transform:translateX(-50%)!important;margin:0!important;padding:0!important;display:flex!important;align-items:center!important;justify-content:center!important;gap:10px!important;width:max-content!important;}
  .user .portal-date input[type="date"]{width:150px!important;min-width:150px!important;max-width:150px!important;height:38px!important;}
  .user .portal-date button{width:84px!important;min-width:84px!important;height:38px!important;padding:0!important;justify-content:center!important;}
  .layout{min-height:calc(100vh - 118px)!important;}
}

<style id="machine-date-view-final-fix">
/* Final machine fix: Date + View are centered against the FULL device viewport,
   never against the right-side user controls. */
@media screen and (max-width:800px){
  .top{position:sticky!important;top:0!important;overflow:visible!important;}
  .top .top-row{position:relative!important;}
  .top .user .portal-date{
    position:absolute!important;
    left:50%!important;
    right:auto!important;
    top:64px!important;
    transform:translateX(-50%)!important;
    width:max-content!important;
    max-width:calc(100vw - 20px)!important;
    margin:0!important;
    padding:0!important;
    display:flex!important;
    flex-direction:row!important;
    flex-wrap:nowrap!important;
    align-items:center!important;
    justify-content:center!important;
    gap:8px!important;
    z-index:100!important;
  }
  .top .user .portal-date input[type="date"]{
    width:150px!important;min-width:150px!important;max-width:150px!important;
    height:38px!important;
    box-sizing:border-box!important;
  }
  .top .user .portal-date button{
    width:84px!important;min-width:84px!important;max-width:84px!important;
    height:38px!important;min-height:38px!important;
    box-sizing:border-box!important;
    display:inline-flex!important;
    align-items:center!important;
    justify-content:center!important;
    flex:0 0 84px!important;
  }
}
@media screen and (max-width:380px){
  .top .user .portal-date{gap:6px!important;}
  .top .user .portal-date input[type="date"]{width:135px!important;min-width:135px!important;max-width:135px!important;}
  .top .user .portal-date button{width:76px!important;min-width:76px!important;max-width:76px!important;flex-basis:76px!important;}
}


@media screen and (min-width:701px){
  .dispatch-take-grid{display:grid;grid-template-columns:repeat(2,minmax(0,190px));gap:12px;width:max-content;max-width:100%;}
  .adhat-add-form{display:grid;grid-template-columns:repeat(3,minmax(0,240px)) auto;gap:14px;align-items:end;}
  .adhat-add-form .btn{height:42px;align-self:end;}
}

:root{--teal:#0755a1;--navy:#09284c;--navy2:#123c67;--gold:#cc941f}
.sg-brand-logo{width:52px;height:46px;object-fit:contain}.company-picker{margin-bottom:18px;border-left:4px solid var(--gold);padding:14px 18px}.company-picker form{display:flex;align-items:center;gap:20px;flex-wrap:wrap}.company-picker label{display:flex;align-items:center;gap:12px;font-weight:750}.company-picker select{min-width:250px}.company-picker span{font-size:12px;color:#52677d}
.sg-login-page{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:32px 16px;background:radial-gradient(ellipse at 5% 80%,#f5e8c8,transparent 42%),radial-gradient(ellipse at 100% 15%,#f2e5c6,transparent 35%),#fffcf4;position:relative}.sg-login-page:before,.sg-login-page:after{content:'❧';position:absolute;font-size:340px;line-height:1;color:#dfb95826;pointer-events:none}.sg-login-page:before{right:0;top:0;transform:rotate(60deg)}.sg-login-page:after{right:0;bottom:0;transform:rotate(-60deg)}
.sg-login-card{position:relative;z-index:1;width:min(540px,100%);padding:28px 44px 34px;background:#ffffffdf;border:1px solid #c7942d;border-radius:15px;box-shadow:0 20px 50px #a87b2420;text-align:center}.sg-login-logo{width:220px;height:148px;object-fit:contain}.sg-login-card h1{font-family:Georgia,'Times New Roman',serif;color:#082652;font-size:34px;line-height:1.12;margin:12px 0 10px}.sg-gold-line{display:flex;align-items:center;justify-content:center;gap:16px;color:#c99527;font-size:30px}.sg-gold-line:before,.sg-gold-line:after{content:'';height:1px;width:95px;background:#c99527}.sg-login-subtitle{font-size:18px;color:#646b79;margin:12px 0 28px}.sg-login-card .field{text-align:left;margin-bottom:20px}.sg-login-card .field label{font-size:15px;color:#082652}.sg-login-card .input{height:51px;font-size:16px;border-radius:9px;background:#fff}.sg-password{position:relative}.sg-password .input{padding-right:45px}.sg-password button{position:absolute;right:8px;top:8px;width:34px;height:34px;border:0;background:none;color:#5e6a7e;font-size:21px;cursor:pointer}.sg-remember{display:flex;gap:10px;align-items:center;color:#092852;margin:8px 0 25px;font-size:15px}.sg-remember input{width:20px;height:20px;accent-color:#0755a1}.sg-login-button{width:100%;height:58px;background:linear-gradient(#0759a8,#052a58);color:#fff;border:0;border-radius:10px;letter-spacing:4px;font-size:18px;cursor:pointer;box-shadow:0 8px 20px #09284c18}.sg-login-button span{margin-left:14px;font-size:25px}.sg-login-footer{color:#77808d;letter-spacing:5px;font-size:12px;margin-top:34px}.sg-login-footer:before,.sg-login-footer:after{content:'—';color:#c99527;margin:0 14px}
.sg-paper-control{display:flex;gap:8px;align-items:center;font-size:13px;margin:8px 0}.sg-paper-control select{padding:7px;border:1px solid #ccd6e0;border-radius:6px}
@media screen and (max-width:800px){.company-picker{padding:12px}.company-picker form,.company-picker label{display:block}.company-picker select{min-width:0;width:100%;margin:7px 0}.main{padding:12px!important}.form-grid{gap:12px}.field[class*=col-]{grid-column:span 12}.input,.select{min-height:46px;font-size:16px}.btn{min-height:44px}.bag-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.grid.g3{display:block}.grid.g3>.card{margin-bottom:14px}.side{position:static!important;top:auto!important;height:auto!important;padding:6px!important}.side .nav-title{display:none}.side .nav{display:flex;gap:4px;flex-wrap:wrap}.side .nav a{font-size:12px;padding:8px!important}.layout{display:block!important}.top .brand{font-size:13px}.sg-brand-logo{width:38px;height:38px}.table-wrap{overflow-x:auto}.sg-login-card{padding:22px}.sg-login-card h1{font-size:28px}.sg-login-logo{width:190px;height:130px}}
@media print{.company-picker,.sg-paper-control{display:none!important}}

.sg-mobile-menu{display:none}@media screen and (max-width:800px){.sg-mobile-menu{display:block;width:100%;text-align:left;padding:11px 16px;border:0;background:#09284c;color:#fff;font-weight:700}.side{display:none}.side.sg-open{display:block}.sg-login-card .sg-login-logo{height:120px}.sg-login-card h1{margin-top:4px}}

.calc .field label{color:#edf4ff}.calc .input{color:#172b4d}

.sg-leave-overlay{position:fixed;inset:0;background:#0008;z-index:9999;display:flex;align-items:center;justify-content:center;padding:16px}.sg-leave-overlay[hidden]{display:none}.sg-leave-overlay>.card{max-width:480px;width:100%}

.sg-pagination{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap;margin:14px 0;font-size:12px;color:#52677d}.sg-selected-basket:empty{display:none}.sg-selected-basket{padding:12px;background:#eef5fc;border-radius:9px;margin-bottom:12px}.sg-selected-line{display:flex;gap:12px;align-items:center;justify-content:space-between;padding:6px 0;border-bottom:1px solid #d8e4f1}.sg-selected-line span{overflow-wrap:anywhere}.sg-selected-line .btn{flex-shrink:0}

[hidden]{display:none!important}

/* Warehouse: roomy desktop tables, labelled cards on handheld terminals. */
@media screen {
 .sg-warehouse,.sg-warehouse .card,.sg-warehouse .field{min-width:0;box-sizing:border-box}
 .sg-warehouse .table-wrap{max-width:100%;overflow-x:auto!important}
 .sg-warehouse .sg-wh-pending{min-width:940px}
 .sg-warehouse .sg-wh-history{min-width:760px}
 .sg-warehouse .sg-wh-stock{min-width:600px}
 .sg-warehouse .sg-wh-table td,.sg-warehouse .sg-wh-table th{word-break:normal;overflow-wrap:break-word}
 .sg-warehouse .btn{white-space:normal;word-break:normal}
}
@media screen and (max-width:800px){
 .sg-warehouse{width:100%;max-width:100%}
 .sg-warehouse>.card{padding:16px!important}
 .sg-warehouse h1{font-size:24px!important;line-height:1.25!important}
 .sg-warehouse h2{font-size:20px!important;line-height:1.3!important;overflow-wrap:break-word!important;word-break:normal!important}
 .sg-warehouse .form-grid>.card[class*=col-]{grid-column:1/-1!important}
 .sg-warehouse .form-grid>.btn{grid-column:1/-1!important;width:100%!important}
 .sg-warehouse .input,.sg-warehouse .select{box-sizing:border-box!important;width:100%!important;min-width:0!important;max-width:100%!important;height:48px!important;font-size:16px!important}
 .sg-warehouse .actions{flex-wrap:wrap!important;gap:8px!important}
 .sg-warehouse .actions>.btn{flex:1 1 80px!important;padding:10px!important;min-height:44px!important}
 .sg-warehouse .table-wrap{overflow:visible!important;border:0!important;background:transparent!important;box-shadow:none!important}
 .sg-warehouse .sg-wh-table{display:block!important;width:100%!important;min-width:0!important;max-width:100%!important;table-layout:auto!important;border:0!important;background:transparent!important}
 .sg-warehouse .sg-wh-table tbody{display:block!important;width:100%!important}
 .sg-warehouse .sg-wh-table tr{display:grid!important;grid-template-columns:minmax(0,1fr) minmax(0,1fr)!important;gap:12px!important;padding:14px!important;margin:12px 0!important;border:1px solid #dce5ef!important;border-radius:12px!important;background:#fff!important;width:100%!important;box-sizing:border-box!important}
 .sg-warehouse .sg-wh-table tr.sg-wh-head{display:none!important}
 .sg-warehouse .sg-wh-table td,.sg-warehouse .sg-wh-table th{display:block!important;width:auto!important;min-width:0!important;max-width:100%!important;padding:0!important;border:0!important;text-align:left!important;white-space:normal!important;word-break:normal!important;overflow-wrap:break-word!important;font-size:15px!important;line-height:1.45!important;box-sizing:border-box!important;background:transparent!important}
 .sg-warehouse .sg-wh-table [data-label]::before{content:attr(data-label);display:block;font-size:12px;line-height:1.3;font-weight:700;color:#64778e;margin-bottom:5px}
 .sg-warehouse .sg-wh-table .sg-wh-wide,.sg-warehouse .sg-wh-table [colspan]{grid-column:1/-1!important}
 .sg-warehouse .sg-wh-table input[type=checkbox]{width:26px!important;height:26px!important;min-height:26px!important;margin:3px 0!important;accent-color:#0755a1}
 .sg-warehouse .sg-wh-table details{margin-top:6px!important}
 .sg-warehouse .sg-wh-table summary{padding:7px 0!important;min-height:36px!important}
 .sg-warehouse .sg-wh-table small{font-size:13px!important;line-height:1.5!important}
 .sg-warehouse .sg-wh-actions .btn:not([hidden]){display:inline-flex!important;align-items:center!important;justify-content:center!important;width:auto!important;min-width:85px!important;min-height:44px!important;white-space:nowrap!important;word-break:normal!important;margin:4px 6px 0 0!important;padding:10px 14px!important}
 .sg-warehouse .sg-wh-total{background:#edf5fc!important;font-weight:800!important}
 .sg-warehouse form[action="/warehouse/receive"]>button{width:100%!important;margin-top:10px!important;min-height:48px!important;padding:12px!important}
}

.sg-warehouse [hidden]{display:none!important}

.sg-wh-item-link{color:#0755a1;font-weight:750;text-decoration:underline;text-underline-offset:3px}
.sg-warehouse [data-detail-url]{cursor:pointer}.sg-warehouse [data-detail-url]:focus{outline:2px solid #0755a1;outline-offset:2px}
@media screen and (min-width:801px){.sg-warehouse .sg-wh-detail{min-width:1500px}}

/* ADHAT Master: edit controls must not squeeze beside the summary on terminals. */
@media screen and (max-width:800px){
 .adhat-mobile-card .adhat-row{display:block!important;min-width:0!important}
 .adhat-mobile-card .adhat-view{display:grid!important;grid-template-columns:minmax(0,1fr) minmax(0,1fr)!important;align-items:start!important;gap:12px!important}
 .adhat-mobile-card .adhat-view>div:nth-child(n+3){grid-column:1/-1!important}
 .adhat-mobile-card .adhat-value{font-size:14px!important;line-height:1.4!important;word-break:normal!important;overflow-wrap:break-word!important}
 .adhat-mobile-card .adhat-view .muted{font-size:12px!important}
 .adhat-mobile-card .adhat-edit{grid-template-columns:minmax(0,1fr)!important;width:100%!important;gap:10px!important}
 .adhat-mobile-card .adhat-edit .input{width:100%!important;min-width:0!important;max-width:100%!important;box-sizing:border-box!important;height:46px!important;font-size:16px!important}
 .adhat-mobile-card .adhat-edit .btn{width:100%!important;min-height:44px!important;grid-column:1/-1!important}
}
