*{box-sizing:border-box}
html,body{margin:0;background:#F4F2EC;color:#1C1B18;font-family:'IBM Plex Sans',system-ui,-apple-system,'Segoe UI',sans-serif;font-size:14px}
a{color:#7A4E0E}a:hover{color:#4F3209}
[hidden]{display:none!important}
.mono{font-family:'IBM Plex Mono',ui-monospace,Consolas,monospace;font-variant-numeric:tabular-nums}
.muted{color:#5E5A52}
.ell{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.fld{font:inherit;font-size:14px;color:#1C1B18;background:#fff;border:1px solid #CFCAC0;border-radius:6px;padding:7px 10px;min-height:40px;width:100%}
.fld:focus{outline:2px solid #7A4E0E;outline-offset:1px;border-color:#7A4E0E}
textarea.fld{resize:vertical;line-height:1.45}
.sel-sm{min-height:34px;padding:4px 8px;font-size:13px}
.btn{font:inherit;font-weight:600;font-size:14px;border-radius:6px;border:1px solid #CFCAC0;background:#fff;color:#1C1B18;padding:0 14px;min-height:44px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:8px;white-space:nowrap;text-decoration:none}
.btn:hover{background:#F0EDE6}
.btn:disabled{opacity:.55;cursor:wait}
.btn:focus-visible,.iconbtn:focus-visible,.tab:focus-visible,.segb:focus-visible,.thumbbtn:focus-visible{outline:2px solid #B07A1E;outline-offset:2px}
.btn-gold{background:#D9AE55;border-color:#D9AE55;color:#1C1B18}.btn-gold:hover{background:#C99A3F}
.btn-pri{background:#7A4E0E;border-color:#7A4E0E;color:#fff}.btn-pri:hover{background:#633F0B}
.btn-xl{background:#1D6B44;border-color:#1D6B44;color:#fff}.btn-xl:hover{background:#155434}
.btn-danger{color:#9E1C14;border-color:#E6B9B4}.btn-danger:hover{background:#FBE9E7}
.btn-dangerfill{background:#9E1C14;border-color:#9E1C14;color:#fff}.btn-dangerfill:hover{background:#82160F}
.btn-sm{min-height:34px;padding:0 10px;font-size:13px}
.btn-dark{background:#2E2C27;border-color:#45423B;color:#F4F2EC}.btn-dark:hover{background:#3A3832}
.iconbtn{width:34px;height:34px;border-radius:6px;border:1px solid transparent;background:transparent;color:#5E5A52;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;padding:0;flex:none}
.iconbtn:hover{background:#ECE8DF;color:#1C1B18}
.iconbtn:disabled{opacity:.28;cursor:default;background:transparent}
.tab{background:transparent;color:#D8D2C4;border:0;border-radius:6px;padding:0 14px;min-height:44px;font:inherit;font-weight:600;cursor:pointer;white-space:nowrap}
.tab:hover{background:#2E2C27;color:#fff}
.tab-on,.tab-on:hover{background:#F4F2EC;color:#1C1B18}
.count{background:#D9AE55;color:#1C1B18;border-radius:999px;padding:1px 8px;font-size:12px;margin-left:4px;font-family:'IBM Plex Mono',monospace}
.lbl{display:block;font-size:12px;font-weight:600;color:#5E5A52;text-transform:uppercase;letter-spacing:.05em;margin-bottom:6px}
.hd{font-size:12px;font-weight:600;color:#5E5A52;text-transform:uppercase;letter-spacing:.05em}
.pill{display:inline-flex;align-items:center;font-size:12px;font-weight:600;padding:3px 10px;border-radius:999px;white-space:nowrap}
.u-Low{background:#ECEAE4;color:#4A473F}
.u-Medium{background:#E1EAF6;color:#1E4E8C}
.u-High{background:#FBE8D3;color:#7F4205}
.u-Urgent{background:#9E1C14;color:#fff}
.pur{background:#F3E9D2;color:#6B4A0C}
.st-0{background:#F1EFEA;color:#4A473F}
.st-1{background:#E1EAF6;color:#1E4E8C}
.st-2{background:#ECE4F6;color:#55308A}
.st-3{background:#DDF0EE;color:#0F5E57}
.st-4{background:#F6E3EE;color:#86245A}
.st-5{background:#FBEFD2;color:#6E4B05}
.st-6{background:#DCF0E3;color:#17603A}
.st-7{background:#2E2C27;color:#F4F2EC}
.r-admin{background:#1C1B18;color:#F4F2EC}
.r-orders{background:#E1EAF6;color:#1E4E8C}
.r-sales{background:#DCF0E3;color:#17603A}

/* layout */
.topbar{background:#1C1B18;color:#F4F2EC;padding:0 24px}
.topbar-in{max-width:1560px;margin:0 auto;display:flex;flex-wrap:wrap;align-items:center;gap:12px;min-height:68px;padding:10px 0}
.brand{display:flex;flex-direction:column;margin-right:10px}
.brand b{font-size:18px;letter-spacing:.01em}
.brand span{font-size:12px;color:#B9B3A6}
.tabs{display:flex;gap:4px;flex-wrap:wrap}
.spacer{flex:1 1 20px}
.usr{display:flex;align-items:center;gap:8px}
.usr-name{font-size:13px;text-align:right;line-height:1.3}
.usr-name small{display:block;color:#B9B3A6;font-size:11px}
main{width:100%;max-width:1608px;margin:0 auto;padding:22px 24px 60px;display:flex;flex-direction:column;gap:18px}
.idlebar{background:#9E1C14;color:#fff;padding:10px 24px;display:flex;justify-content:center;align-items:center;gap:14px;font-weight:600;position:sticky;top:0;z-index:40}
.tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:12px}
.tile{background:#fff;border:1px solid #DDD8CD;border-radius:10px;padding:14px 16px}
.tile-red{background:#FFF1EE;border-color:#EDB3AA}
.tile .big{font-size:30px;font-weight:600;margin-top:4px}
.card{background:#fff;border:1px solid #DDD8CD;border-radius:10px;overflow:hidden}
.cardhead{padding:12px 16px;display:flex;flex-wrap:wrap;align-items:center;gap:12px 18px;background:#F7F5F0;border-bottom:1px solid #DDD8CD}
.toolbar{display:flex;flex-wrap:wrap;gap:12px;align-items:flex-end}
.tablewrap{overflow-x:auto;border:1px solid #DDD8CD;border-radius:10px;background:#fff}
.scrollx{overflow-x:auto}
.title{font-size:18px;font-weight:700}
.sub{font-size:13px;color:#5E5A52}
.empty{padding:44px 24px;text-align:center;color:#5E5A52}

/* grids */
.grid-o{display:grid;grid-template-columns:34px 96px minmax(150px,1.4fr) 116px minmax(90px,.8fr) 150px 84px 46px 84px 120px minmax(120px,1.1fr) 64px;align-items:center;column-gap:12px}
.grid-i{display:grid;grid-template-columns:52px minmax(150px,1.3fr) 60px 92px minmax(110px,1fr) 140px minmax(120px,1fr) 196px minmax(150px,1.3fr);align-items:center;column-gap:12px}
.grid-k{display:grid;grid-template-columns:minmax(180px,1.4fr) 130px 130px 170px 200px;align-items:center;column-gap:12px}
.grid-l{display:grid;grid-template-columns:104px minmax(150px,1.2fr) minmax(150px,1.2fr) 60px 92px 150px 196px 70px;align-items:center;column-gap:12px}
.grid-r{display:grid;grid-template-columns:52px minmax(160px,1.4fr) 60px 92px minmax(120px,1fr) 170px 150px;align-items:center;column-gap:12px}
.grid-f{display:grid;grid-template-columns:28px minmax(170px,1.4fr) 86px 104px minmax(130px,1fr) 150px minmax(150px,1fr) 186px 96px 36px;align-items:center;column-gap:10px}
.grid-fs{display:grid;grid-template-columns:28px minmax(170px,1.6fr) 90px 110px minmax(140px,1.2fr) 150px 96px 36px;align-items:center;column-gap:10px}
.grid-u{display:grid;grid-template-columns:minmax(140px,1fr) minmax(160px,1.2fr) 170px 110px 150px 330px;align-items:center;column-gap:12px}
.grid-a{display:grid;grid-template-columns:130px 130px 170px minmax(240px,1fr) 130px;align-items:center;column-gap:12px}
.thead{padding:10px 12px;background:#F7F5F0;border-bottom:1px solid #DDD8CD}
.orow{border-bottom:1px solid #E7E3DA;padding:10px 12px;background:#fff}
.orow:hover{background:#FBFAF6}
.irow{padding:8px 12px 8px 58px;border-bottom:1px dashed #E2DED4;background:#FAF8F3}
.ihead{padding:8px 12px 6px 58px;background:#F3F0E8;border-bottom:1px solid #E2DED4}
.lrow{padding:9px 14px;border-bottom:1px solid #EEEAE2;background:#fff}
.krow{padding:12px 14px;border-bottom:1px solid #EEEAE2;background:#fff}
.done{color:#77736A}
.done .pill{opacity:.75}
.hot{animation:glow 1.4s ease-in-out infinite;position:relative;z-index:1}
@keyframes glow{0%,100%{background:#FFF4F2;box-shadow:inset 0 0 0 1px #E8A49D}50%{background:#FFDFD9;box-shadow:inset 0 0 0 2px #B4231A,0 0 18px rgba(180,35,26,.35)}}
.dot{width:9px;height:9px;border-radius:50%;background:#B4231A;display:inline-block;flex:none;animation:blink 1s steps(2,start) infinite}
@keyframes blink{to{visibility:hidden}}
@media (prefers-reduced-motion:reduce){.hot{animation:none;background:#FFE7E3;box-shadow:inset 0 0 0 2px #B4231A}.dot{animation:none}}
.due-over{color:#9E1C14;font-weight:700}
.due-soon{color:#A3230F;font-weight:600}
.due-ok{color:#1C1B18}
.duecell{display:flex;align-items:center;gap:6px}
.thumb{width:44px;height:44px;border-radius:6px;object-fit:cover;border:1px solid #DDD8CD;display:block;background:#EEE}
.thumbbtn{padding:0;border:0;background:none;cursor:zoom-in;border-radius:6px}
.noimg{width:44px;height:44px;border-radius:6px;border:1px dashed #CFCAC0;display:flex;align-items:center;justify-content:center;color:#9A958A}
.vh{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;padding:0;margin:-1px}
.upl{display:inline-flex;align-items:center;gap:6px;min-height:40px;padding:0 10px;border:1px dashed #B9B3A6;border-radius:6px;font-size:13px;font-weight:600;color:#5E5A52;cursor:pointer;background:#fff}
.upl:hover{border-color:#7A4E0E;color:#7A4E0E}
.vh:focus-visible + .upl{outline:2px solid #B07A1E;outline-offset:2px}
.segb{font:inherit;font-size:13px;font-weight:600;border:1px solid #CFCAC0;background:#fff;color:#1C1B18;border-radius:999px;padding:0 12px;min-height:40px;cursor:pointer}
.segb:hover{border-color:#7A4E0E}
.frow{padding:14px 14px 16px;border-bottom:1px solid #E2DED4;background:#fff}
.frow:nth-child(even){background:#FCFBF8}
progress{width:70px;height:8px;accent-color:#1D6B44}
.mrow{padding:8px 12px 8px 16px;border-bottom:1px solid #EEEAE2;background:#fff;display:flex;align-items:center;gap:8px}
.mrow:hover{background:#FBFAF6}
.badge{font-size:11px;font-weight:600;padding:2px 8px;border-radius:999px;background:#F1EFEA;color:#6E6A61;white-space:nowrap}
.badge-on{background:#F3E9D2;color:#6B4A0C}
.chk{display:inline-flex;align-items:center;gap:6px;font-size:13px;font-weight:600;cursor:pointer;min-height:34px;padding:0 4px}
.chk input{width:16px;height:16px;accent-color:#1D6B44;margin:0}
.xgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:8px 10px;margin-bottom:10px}
.mgrid{display:grid;grid-template-columns:repeat(auto-fit,minmax(340px,1fr));gap:14px;align-items:start}
.logbox{background:#F4F2EC;border:1px solid #E2DED4;border-radius:6px;padding:8px 10px;min-height:40px;max-height:110px;overflow-y:auto;font-size:12px;display:flex;flex-direction:column;gap:3px}

/* modal / overlays */
.overlay{position:fixed;inset:0;z-index:50;background:rgba(28,27,24,.55);overflow-y:auto;padding:28px 16px}
.sheet{max-width:1400px;margin:0 auto;background:#F9F8F4;border-radius:12px;box-shadow:0 24px 60px rgba(0,0,0,.3);overflow:hidden}
.sheet-sm{max-width:480px;margin-top:8vh}
.sheethead{display:flex;align-items:center;gap:14px;padding:16px 20px;background:#1C1B18;color:#F4F2EC}
.sheethead .iconbtn{color:#F4F2EC}.sheethead .iconbtn:hover{background:#34312B}
.sheetfoot{display:flex;flex-wrap:wrap;align-items:center;gap:10px;padding:14px 20px;border-top:1px solid #DDD8CD;background:#fff}
.formgrid{padding:20px;display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:14px 16px}
.lightbox{position:fixed;inset:0;z-index:80;background:rgba(20,19,17,.88);display:flex;flex-direction:column;align-items:center;justify-content:center;padding:24px;gap:14px}
.lightbox img{max-width:92vw;max-height:78vh;border-radius:8px;box-shadow:0 20px 50px rgba(0,0,0,.5)}
.toast{position:fixed;bottom:24px;left:50%;transform:translateX(-50%);z-index:90;background:#1C1B18;color:#F4F2EC;padding:12px 18px;border-radius:8px;font-weight:600;box-shadow:0 10px 30px rgba(0,0,0,.25);max-width:90vw}
.toast-err{background:#9E1C14}
.err{color:#9E1C14;font-weight:600;font-size:13px}
.note{background:#FFF7E6;border:1px solid #EBCB8B;color:#5A3D05;border-radius:8px;padding:10px 14px;font-size:13px}

/* login */
.loginwrap{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:24px;background:#1C1B18}
.loginbox{width:100%;max-width:400px;background:#F9F8F4;border-radius:12px;padding:28px;box-shadow:0 30px 70px rgba(0,0,0,.4);display:flex;flex-direction:column;gap:14px}
.loginbox h1{margin:0;font-size:22px}
.loginbox p{margin:0}

/* sales */
.salesdone{background:#fff;border:1px solid #BFDDC9;border-radius:12px;padding:32px;text-align:center;display:flex;flex-direction:column;gap:12px;align-items:center}
.salesdone .no{font-size:34px;font-weight:600;color:#17603A}

.mlbl,.mlbl-inline{display:none}
.itemsbar{padding:0 20px 10px;display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.itemsbox{padding:0 20px 20px}
.addmore{display:flex;justify-content:center;padding-top:12px}
.loginwrap{min-height:100vh;min-height:100dvh}
a[href^="tel:"]{color:inherit;text-decoration:none}

/* ======================= PHONES & SMALL TABLETS ======================= */
@media (max-width:760px){
  html{-webkit-text-size-adjust:100%}
  body{font-size:15px}
  /* 16px inputs stop iPhone Safari from zooming in when a field is tapped */
  .fld,select.fld,textarea.fld,.sel-sm{font-size:16px;min-height:46px}
  .btn{min-height:46px}
  .btn-sm{min-height:42px;padding:0 12px;font-size:14px}
  .iconbtn{width:44px;height:44px}
  .segb{min-height:44px;flex:1 1 0;padding:0 6px}
  a[href^="tel:"]{color:#7A4E0E;text-decoration:underline}

  /* top bar: brand + user on one line, tabs scroll sideways, action buttons full width */
  .topbar{padding:0 12px}
  .topbar-in{gap:8px;padding:8px 0;min-height:0}
  .brand{margin-right:0;flex:1 1 auto;min-width:0}
  .brand b{font-size:16px}
  .brand span{display:none}
  .spacer{display:none}
  .tabs{order:3;flex:1 1 100%;flex-wrap:nowrap;overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:none;gap:2px;margin:0 -4px}
  .tabs::-webkit-scrollbar{display:none}
  .tab{min-height:42px;padding:0 12px;font-size:14px;flex:none}
  .topbar-in > .btn{order:4;flex:1 1 40%;min-height:44px;font-size:14px;padding:0 8px}
  .usr{order:2;gap:6px}
  .usr-name{display:none}
  .usr .btn-sm{min-height:38px;padding:0 10px;font-size:13px}
  main{padding:14px 12px 64px;gap:14px}
  .idlebar{padding:10px 12px;flex-wrap:wrap;text-align:center}

  .tiles{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  .tile{padding:10px 12px}
  .tile .big{font-size:24px}
  .tile .hd{font-size:11px}
  .toolbar{gap:10px}
  .toolbar > div{flex:1 1 calc(50% - 5px) !important}
  .toolbar > div:first-child{flex-basis:100% !important}
  .toolbar > .btn{flex:1 1 100%}
  .mgrid{grid-template-columns:minmax(0,1fr)}
  .cardhead{padding:12px}
  .title{font-size:17px}

  /* tables become cards */
  .minw{min-width:0 !important}
  .tablewrap,.scrollx{overflow-x:visible}
  .thead,.ihead{display:none !important}
  .mlbl{display:block;font-family:'IBM Plex Sans',system-ui,sans-serif;font-size:11px;font-weight:600;letter-spacing:.04em;text-transform:uppercase;color:#6E6A61;margin-bottom:2px}
  .mlbl-inline{display:inline}
  .ell{white-space:normal}
  .orow,.irow,.lrow,.krow{column-gap:10px !important;row-gap:8px}

  .grid-o{grid-template-columns:44px minmax(0,1fr) minmax(0,1fr) auto;grid-template-areas:"tog no urg edit" "tog cust cust cust" ". due due due" ". ph staff staff" ". items wt wt" ". prog prog prog" ". kar kar kar";padding:12px 10px}
  .c-tog{grid-area:tog}.grid-o .c-no{grid-area:no;align-self:center}.c-urg{grid-area:urg;align-self:center}.grid-o .c-edit{grid-area:edit}
  .grid-o .c-cust{grid-area:cust}.grid-o .c-due{grid-area:due}.c-ph{grid-area:ph}.c-staff{grid-area:staff}
  .c-items{grid-area:items}.grid-o .c-wt{grid-area:wt}.c-prog{grid-area:prog}.grid-o .c-kar{grid-area:kar}

  .irow{padding:12px 10px 12px 18px;border-left:4px solid #E2DED4}
  .grid-i{grid-template-columns:52px minmax(0,1fr) minmax(0,1fr);grid-template-areas:"img name name" "img pur wt" "due due kar" "dims dims dims" "st st st" "det det det"}
  .grid-i .c-img{grid-area:img}.grid-i .c-name{grid-area:name}.grid-i .c-pur{grid-area:pur}.grid-i .c-wt{grid-area:wt}
  .grid-i .c-due{grid-area:due}.grid-i .c-kar{grid-area:kar}.grid-i .c-dims{grid-area:dims}.grid-i .c-st{grid-area:st}.grid-i .c-det{grid-area:det}
  .grid-i .c-dims:empty{display:none}

  .grid-r{grid-template-columns:52px minmax(0,1fr) minmax(0,1fr);grid-template-areas:"img name name" "img pur wt" "kar wait wait" "btn btn btn"}
  .grid-r .c-img{grid-area:img}.grid-r .c-name{grid-area:name}.grid-r .c-pur{grid-area:pur}.grid-r .c-wt{grid-area:wt}
  .grid-r .c-kar{grid-area:kar}.c-wait{grid-area:wait}.c-btn{grid-area:btn}.c-btn .btn{width:100%}

  .grid-l{grid-template-columns:minmax(0,1fr) minmax(0,1fr) auto;grid-template-areas:"no cust edit" "name name pur" "wt due due" "st st st"}
  .grid-l .c-no{grid-area:no}.grid-l .c-cust{grid-area:cust}.grid-l .c-edit{grid-area:edit}.grid-l .c-name{grid-area:name}
  .grid-l .c-pur{grid-area:pur}.grid-l .c-wt{grid-area:wt}.grid-l .c-due{grid-area:due}.grid-l .c-st{grid-area:st}

  .grid-k{grid-template-columns:repeat(2,minmax(0,1fr))}
  .grid-k .c-name{grid-column:1/-1}
  .grid-k .mono{font-size:16px !important}

  .grid-u{grid-template-columns:repeat(2,minmax(0,1fr))}
  .grid-u .c-acts{grid-column:1/-1;justify-content:flex-start !important}
  .grid-a{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}
  .grid-a > div:nth-child(4){grid-column:1/-1}

  .cardhead .spacer{display:none}
  .cardhead .btn{flex:1 1 40%}

  /* order form: full-screen sheet, one field per row */
  .overlay{padding:0}
  .sheet{border-radius:0;min-height:100vh;min-height:100dvh}
  .sheet-sm{border-radius:12px;min-height:0;margin:12vh 12px 0}
  .sheethead{padding:12px;gap:10px;flex-wrap:wrap;position:sticky;top:0;z-index:3}
  .sheethead > div:first-child{font-size:16px !important}
  .formgrid{padding:14px 12px;grid-template-columns:minmax(0,1fr);gap:12px}
  .itemsbar{padding:0 12px 10px}
  .itemsbox{padding:0 12px 16px}
  .itemsbox .tablewrap{border:0;background:transparent;border-radius:0}
  .frow{padding:12px;border:1px solid #DDD8CD;border-radius:10px;margin-bottom:12px;background:#fff !important}
  .grid-f,.grid-fs{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;row-gap:10px;align-items:end}
  .f-n{grid-column:1;align-self:center;font-size:15px}
  .f-rm{grid-column:2;grid-row:1;justify-self:end}
  .f-name,.f-dims,.f-due,.f-img{grid-column:1/-1}
  .f-pur{grid-column:1}.f-wt{grid-column:2}
  .f-kar{grid-column:1}.f-st{grid-column:2}
  .f-img .upl{width:100%;justify-content:center;min-height:48px;font-size:15px}
  .f-img .thumb{width:72px;height:72px}
  .frow2{margin-top:10px !important}
  .frow2 .f-sp{display:none}
  .frow2 .f-notes,.frow2 .f-log{grid-column:1/-1 !important}
  .xgrid{grid-template-columns:minmax(0,1fr)}
  .sheetfoot{position:sticky;bottom:0;z-index:3;padding:10px 12px calc(10px + env(safe-area-inset-bottom));box-shadow:0 -6px 16px rgba(0,0,0,.06)}
  .sheetfoot .spacer{display:block;flex:0 0 100%;height:0}
  .sheetfoot .err{flex:1 1 100%;order:-1}
  .sheetfoot .btn{flex:1 1 0}
  .addmore .btn{width:100%}

  /* masters rows: name + usage on line 1, controls on line 2 */
  .mrow{flex-wrap:wrap;row-gap:4px;padding:10px 12px}
  .mrow > .ell,.mrow > .pill{flex:0 1 auto;white-space:normal;overflow:visible}
  .mrow > .spacer{display:block;flex:1 0 100%;height:0}
  .mrow > .badge{white-space:nowrap;overflow:visible}
  .mrow > .chk{margin-right:auto}
  .mrow > .fld{flex:1 1 100%}

  .salesdone{padding:24px 16px}
  .salesdone .no{font-size:30px}
  .loginbox{padding:22px 18px}
  .toast{bottom:calc(16px + env(safe-area-inset-bottom));width:calc(100% - 24px);text-align:center}
  .lightbox img{max-width:100%;max-height:70vh}
}
@media (max-width:380px){
  .tiles{grid-template-columns:minmax(0,1fr)}
  .toolbar > div{flex-basis:100% !important}
}
@media print{.topbar,.toolbar,.idlebar{display:none}}
