:root { --navy:#1F3864; --line:#e3e6ec; --muted:#6b7280; --red:#fde2e2; --redt:#9b1c1c; --amber:#fff4d6; --bg:#f6f7fb; }
* { box-sizing:border-box; }
body { margin:0; font:14px/1.4 "Segoe UI", Arial, sans-serif; color:#1f2937; background:var(--bg); }
header { background:var(--navy); color:#fff; padding:8px 18px; display:flex; align-items:center; gap:18px; position:sticky; top:0; z-index:5; flex-wrap:wrap; }
header h1 { font-size:17px; margin:0; font-weight:600; white-space:nowrap; }
nav { display:flex; flex-wrap:wrap; gap:2px; }
nav button { background:none; border:0; color:#cbd5e1; font:inherit; padding:8px 12px; cursor:pointer; border-radius:6px; }
nav button.on { background:rgba(255,255,255,.15); color:#fff; }
header .user { margin-left:auto; font-size:12px; color:#cbd5e1; display:flex; gap:12px; align-items:center; }
header .user a { color:#fff; text-decoration:none; cursor:pointer; }
main { padding:16px 18px 60px; }
section { display:none; } section.on { display:block; }
.card { background:#fff; border:1px solid var(--line); border-radius:10px; padding:14px 16px; margin-bottom:14px; }
.card h2 { font-size:15px; margin:0 0 10px; color:var(--navy); }
.row { display:flex; flex-wrap:wrap; gap:10px; align-items:flex-end; }
label { display:flex; flex-direction:column; font-size:12px; color:var(--muted); gap:3px; }
label.inline { flex-direction:row; align-items:center; gap:6px; }
input, select, textarea { font:inherit; padding:6px 8px; border:1px solid #cfd5df; border-radius:6px; background:#fff; color:#111; }
input:disabled, textarea:disabled, select:disabled { background:#f3f4f6; color:#555; }
textarea { resize:vertical; min-height:60px; width:100%; }
.btn { background:var(--navy); color:#fff; border:0; padding:8px 14px; border-radius:6px; font:inherit; cursor:pointer; text-decoration:none; display:inline-block; }
.btn.light { background:#e8ecf4; color:var(--navy); }
.btn.small { padding:4px 9px; font-size:12px; white-space:nowrap; }
.btn:disabled { opacity:.5; cursor:default; }
table { width:100%; border-collapse:collapse; background:#fff; }
th, td { text-align:left; padding:6px 8px; border-bottom:1px solid var(--line); vertical-align:top; font-size:13px; }
th { background:#f1f3f8; font-weight:600; font-size:12px; color:#374151; }
.tablewrap { overflow:auto; max-height:calc(100vh - 230px); } .tablewrap th { position:sticky; top:0; z-index:1; }
tbody tr.click { cursor:pointer; } tbody tr.click:hover { background:#f5f8ff; }
tr.over { background:var(--red); } tr.over td.days { color:var(--redt); font-weight:700; }
tr.warn { background:var(--amber); }
.chips button { border:1px solid #cfd5df; background:#fff; padding:5px 11px; border-radius:16px; cursor:pointer; font:inherit; font-size:12px; }
.chips button.on { background:var(--navy); color:#fff; border-color:var(--navy); }
.pill { display:inline-block; padding:1px 8px; border-radius:10px; font-size:11px; background:#e8ecf4; color:var(--navy); white-space:nowrap; }
.pill.w { background:#fde68a; color:#78350f; } .pill.i { background:#e9d5ff; color:#581c87; } .pill.r { background:#bfdbfe; color:#1e3a8a; } .pill.m { background:#fecaca; color:#7f1d1d; } .pill.d { background:#dcfce7; color:#14532d; }
.muted { color:var(--muted); font-size:12px; }
.no { font-weight:700; color:var(--navy); white-space:nowrap; }
.msg { padding:10px 14px; border-radius:8px; margin-bottom:12px; display:none; }
.msg.ok { background:#dcfce7; color:#14532d; display:block; } .msg.err { background:#fee2e2; color:#7f1d1d; display:block; }
.lines td { cursor:default; } .lines input, .lines select { width:100%; }
#drawer { position:fixed; top:0; right:0; width:min(560px,100%); height:100%; background:#fff; box-shadow:-6px 0 24px rgba(0,0,0,.15);
          transform:translateX(105%); transition:transform .2s; z-index:20; overflow:auto; padding:18px 20px 40px; }
#drawer.on { transform:none; }
#drawer h3 { margin:0 0 4px; color:var(--navy); }
.grid { display:grid; grid-template-columns:120px 1fr; gap:4px 10px; font-size:13px; margin:10px 0 14px; }
.grid b { color:var(--muted); font-weight:500; }
#drawer label { margin-bottom:10px; } #drawer label input, #drawer label select { width:100%; }
#shade { position:fixed; inset:0; background:rgba(0,0,0,.2); display:none; z-index:15; } #shade.on { display:block; }
.loading { padding:30px; text-align:center; color:var(--muted); }
.count { font-weight:600; color:var(--navy); }
.split { display:grid; grid-template-columns:1fr; gap:14px; } @media (min-width:1150px){ .split { grid-template-columns:440px 1fr; } }
.units { margin:6px 0 14px; } .units button { margin:0 4px 4px 0; }
.units button.on { background:var(--navy); color:#fff; }
body[data-role="viewer"] .edit-only { display:none !important; }
body:not([data-role="admin"]) .admin-only { display:none !important; }
body.login { display:flex; align-items:center; justify-content:center; min-height:100vh; }
.loginbox { background:#fff; border:1px solid var(--line); border-radius:12px; padding:28px; width:min(360px, 92vw); }
.loginbox h1 { margin:0; color:var(--navy); font-size:22px; } .loginbox label { margin:12px 0; } .loginbox input { width:100%; }

/* reports */
.kpis { display:grid; grid-template-columns:repeat(auto-fill, minmax(170px, 1fr)); gap:12px; margin-bottom:14px; }
.kpi { background:#fff; border:1px solid var(--line); border-radius:10px; padding:12px 14px; }
.kpi .v { font-size:26px; font-weight:700; color:#111827; line-height:1.15; }
.kpi .l { font-size:12px; color:var(--muted); margin-top:2px; }
.kpi .s { font-size:12px; color:#374151; margin-top:4px; }
.rgrid { display:grid; grid-template-columns:1fr; gap:14px; } @media (min-width:1000px){ .rgrid { grid-template-columns:1fr 1fr; } }
.rgrid3 { display:grid; grid-template-columns:1fr; gap:14px; } @media (min-width:1100px){ .rgrid3 { grid-template-columns:1fr 1fr 1fr; } }
.hbar { display:grid; grid-template-columns:minmax(120px, 42%) 1fr minmax(48px, auto); align-items:center; gap:8px; font-size:13px; padding:3px 0; }
.hbar .nm { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:#1f2937; }
.hbar .track { height:14px; position:relative; }
.hbar .fill { position:absolute; left:0; top:1px; height:12px; background:var(--navy); border-radius:0 4px 4px 0; min-width:2px; }
.hbar .val { text-align:right; color:#374151; font-variant-numeric:tabular-nums; }
.chart svg { width:100%; height:auto; display:block; overflow:visible; }
.chart .tip { position:absolute; pointer-events:none; background:#111827; color:#fff; font-size:12px; padding:4px 8px; border-radius:6px; white-space:nowrap; display:none; z-index:3; }
.cardhead { display:flex; align-items:center; gap:8px; margin-bottom:8px; } .cardhead h2 { margin:0; } .cardhead .btn { margin-left:auto; }
@media print {
  header, .noprint, #msg, nav, .cardhead .btn { display:none !important; }
  body { background:#fff; } main { padding:0; } section { display:none !important; } section#reports { display:block !important; }
  .card { break-inside:avoid; border-color:#ccc; } .tablewrap { max-height:none; overflow:visible; }
}

/* attachments */
.files { margin:12px 0 16px; }
.thumbs { display:grid; grid-template-columns:repeat(auto-fill, minmax(96px, 1fr)); gap:8px; margin:8px 0; }
.thumb { position:relative; border:1px solid var(--line); border-radius:8px; overflow:hidden; background:#f8fafc; height:96px; display:flex; align-items:center; justify-content:center; text-align:center; font-size:11px; color:#374151; }
.thumb img { width:100%; height:100%; object-fit:cover; display:block; }
.thumb a { color:inherit; text-decoration:none; width:100%; height:100%; display:flex; align-items:center; justify-content:center; padding:4px; }
.thumb .del { position:absolute; top:3px; right:3px; background:rgba(17,24,39,.75); color:#fff; border:0; border-radius:50%; width:20px; height:20px; font-size:11px; cursor:pointer; line-height:20px; padding:0; }
.thumb .cap { position:absolute; left:0; right:0; bottom:0; background:rgba(255,255,255,.88); font-size:10px; padding:1px 4px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.drop { border:1.5px dashed #c3cad6; border-radius:8px; padding:10px; text-align:center; color:var(--muted); font-size:12px; cursor:pointer; }
.drop.over { border-color:var(--navy); background:#eef2f8; color:var(--navy); }
header h1.brand { display:flex; align-items:center; gap:10px; }
header .logoplate { background:#fff; border-radius:6px; padding:3px 7px; display:inline-flex; line-height:0; }
header .logoplate img { height:30px; width:auto; }
.loginlogo { display:block; height:64px; width:auto; margin:0 auto 14px; }
.qrbox { display:flex; gap:16px; align-items:flex-start; flex-wrap:wrap; margin:10px 0; }
.qrbox .qr { background:#fff; border:1px solid var(--line); border-radius:8px; padding:8px; line-height:0; }
.qrbox code { word-break:break-all; font-size:13px; background:#f1f4f9; padding:2px 6px; border-radius:4px; }
@media print { header .logoplate { border:1px solid #ccc; } }
th.sel, td.sel { width:30px; text-align:center; padding-left:8px; padding-right:4px; }
td.sel input, th.sel input { width:16px; height:16px; cursor:pointer; }
tr.picked, tr.picked.over, tr.picked.warn { background:#dbe7fb !important; }
.bulkbar { display:none; }
.bulkbar.on { display:flex; flex-wrap:wrap; align-items:center; gap:10px; padding:8px 14px; background:#eef3fb; border-top:1px solid var(--line); border-bottom:1px solid var(--line); position:sticky; top:52px; z-index:3; }
.bulkbar label.inline { flex-direction:row; align-items:center; gap:6px; margin:0; font-weight:400; }
.bulkbar select { width:auto; }
.edited { font-size:11px; color:var(--muted); margin-top:3px; white-space:nowrap; }
.pill.rem { background:#e0ecff; color:#1e40af; margin-top:3px; }
.chlogbox { margin-top:14px; border:1px solid var(--line); border-radius:8px; padding:8px 12px; background:#fafbfd; }
.chlogbox summary { cursor:pointer; font-weight:600; color:var(--navy); }
ul.chlog { list-style:none; padding:0; margin:8px 0 0; max-height:360px; overflow:auto; }
ul.chlog li { border-left:3px solid #c9d4e8; padding:4px 0 6px 10px; margin-bottom:6px; font-size:13px; }
ul.chlog .when { color:var(--muted); font-size:12px; margin-bottom:2px; }
ul.chlog .old { text-decoration:line-through; color:#9b1c1c; }
.card.remind .unitpick { display:flex; flex-direction:row; gap:8px; align-items:center; font-weight:400; margin:3px 0; }
.card.remind .unitpick input { width:auto; }

.custinfo { background:#f1f5f9; border-radius:8px; padding:8px 10px; margin:8px 0; font-size:13px; color:#334155; }
.custinfo.in { margin:4px 0 0; }
.custhint { font-size:12.5px; margin:-4px 0 8px; }
.shipbox { background:#f8fafc; border:1px solid #e5e9f0; border-radius:8px; padding:10px 12px; margin:10px 0; }
.shipbox textarea[readonly] { background:#f1f5f9; color:#334155; }

/* v4.7 grouped menu: groups on top, the pages of the group underneath */
#groups button { font-weight:600; }
.subnav { flex-basis:100%; display:flex; flex-wrap:wrap; gap:2px; margin:0 -18px -8px; padding:3px 18px; background:rgba(255,255,255,.07); border-top:1px solid rgba(255,255,255,.08); }
.subnav button { background:none; border:0; color:#cbd5e1; font:inherit; font-size:13px; padding:6px 12px; cursor:pointer; border-radius:6px; }
.subnav button.on { background:#fff; color:var(--navy); font-weight:600; }
.subnav button.hide { display:none; }
#deBody input, #deBody textarea { width:100%; min-width:0; box-sizing:border-box; }

/* v4.9 customer center */
.cc { display:grid; grid-template-columns:320px 1fr; gap:14px; align-items:start; }
@media (max-width:900px){ .cc { grid-template-columns:1fr; } }
.cclist { position:sticky; top:8px; } .cclist .tablewrap { max-height:calc(100vh - 230px); }
#ccList tr { cursor:pointer; } #ccList tr.sel td { background:#dbeafe; font-weight:600; } #ccList td { padding:5px 8px; }
.ccinfo { display:grid; grid-template-columns:repeat(4, 1fr); gap:14px; margin-top:10px; font-size:13px; } @media (max-width:1300px){ .ccinfo { grid-template-columns:1fr 1fr; } }
.ccinfo .grid { grid-template-columns:auto 1fr; }
.tabs { display:flex; gap:2px; border-bottom:1px solid #e2e8f0; padding:0 8px; flex-wrap:wrap; }
.tabs button { background:none; border:0; border-bottom:2px solid transparent; padding:9px 12px; cursor:pointer; color:#475569; font:inherit; }
.tabs button.on { border-bottom-color:var(--navy); color:var(--navy); font-weight:600; }
.srlink { display:block; padding:5px 8px; border-radius:6px; color:#1e293b; text-decoration:none; font-size:13px; } .srlink:hover { background:#f1f5f9; } .srlink.on { background:var(--navy); color:#fff; }
.srtab td, .srtab th { padding:4px 8px; font-size:13px; } .srgrp td { background:#f8fafc; padding-top:10px; } .srsub td { font-weight:600; border-top:1px solid #94a3b8; background:#fff; }
.srtot td { font-weight:700; border-top:2px solid #1e293b; border-bottom:3px double #1e293b; }
.srchart { display:flex; align-items:flex-end; gap:6px; height:170px; margin:14px 0 4px; padding:0 8px; border-bottom:1px solid #cbd5e1; overflow-x:auto; }
.srchart div { display:flex; flex-direction:column; align-items:center; justify-content:flex-end; min-width:34px; } .srchart span { width:24px; background:var(--navy); border-radius:3px 3px 0 0; } .srchart small { font-size:10px; color:#64748b; white-space:nowrap; }

.skubox { position:absolute; z-index:9999; display:none; background:#fff; border:1px solid #cbd5e1; border-radius:8px; box-shadow:0 8px 24px rgba(15,23,42,.18); min-width:520px; max-width:720px; max-height:340px; overflow:auto; font-size:13px; }
.skuopt { display:flex; gap:8px; align-items:baseline; padding:6px 10px; cursor:pointer; border-bottom:1px solid #f1f5f9; white-space:nowrap; }
.skuopt .nm { flex:1; overflow:hidden; text-overflow:ellipsis; color:#64748b; } .skuopt .st { color:#64748b; font-size:12px; } .skuopt.on, .skuopt:hover { background:#e0e7ff; }

.noperm { display:none !important; }
body.ro .edit-only { display:none !important; }
.permtab td, .permtab th { padding:3px 8px; font-size:13px; } .permtab th { text-align:center; } .permtab th:first-child { text-align:left; }

/* v4.15 sales reports: item chips, sortable headers */
.srchips{display:inline-flex;flex-wrap:wrap;gap:4px;align-self:center;max-width:420px}
.srchips span{background:#e8eef7;border:1px solid #b9c8de;border-radius:12px;padding:1px 4px 1px 9px;font-size:12px;white-space:nowrap}
.srchips b{cursor:pointer;margin-left:4px;color:#666;font-weight:normal;padding:0 4px}
.srtab th.sortable{cursor:pointer;user-select:none}.srtab th.sortable:hover{text-decoration:underline}

#subnav .badge,.badge{display:inline-block;min-width:18px;padding:0 5px;border-radius:9px;background:#dc2626;color:#fff;font-size:11px;line-height:18px;text-align:center;font-weight:700;margin-left:4px}
