:root {
  --brand: #1d3557;
  --brand-2: #2b4c7e;
  --brand-soft: #e8eef7;
  --ink: #1b1f24;
  --muted: #667085;
  --line: #e4e7ec;
  --bg: #f5f7fa;
  --card: #ffffff;
  --red: #b42318;
  --red-bg: #fee4e2;
  --amber: #b54708;
  --amber-bg: #fef0c7;
  --green: #067647;
  --green-bg: #dcfae6;
  --gray-bg: #f2f4f7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, "Noto Sans", "Noto Sans Gujarati", "Noto Sans Devanagari", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- top bar */
.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--brand); color: #fff;
  padding: 10px 16px 0;
  box-shadow: 0 1px 0 rgba(0,0,0,.08);
}
.top-row { display: flex; align-items: center; gap: 12px; max-width: 1100px; margin: 0 auto; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { display: block; font-weight: 500; font-size: 12px; opacity: .75; letter-spacing: .4px; }
.spacer { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; padding: 5px 10px; border-radius: 999px;
  background: rgba(255,255,255,.14); color: #fff; white-space: nowrap; border: 0; cursor: pointer;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa4b2; }
.pill.ok .dot { background: #47cd89; }
.pill.warn .dot { background: #fdb022; }
.pill.bad .dot { background: #f97066; }
.tabs { display: flex; gap: 4px; max-width: 1100px; margin: 8px auto 0; overflow-x: auto; scrollbar-width: none; }
.tabs a {
  padding: 9px 14px 11px; font-weight: 600; font-size: 14px; color: rgba(255,255,255,.72);
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.tabs a.on { color: #fff; border-bottom-color: #fff; }

main { max-width: 1100px; margin: 0 auto; padding: 16px 16px 90px; }
h1 { font-size: 22px; margin: 4px 0 2px; }
h2 { font-size: 16px; margin: 22px 0 10px; }
.sub { color: var(--muted); font-size: 13.5px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--brand-2); font-weight: 600; font-size: 14px; margin-bottom: 6px; }

/* ---------- banner */
.banner {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--amber-bg); color: #7a2e0e; border: 1px solid #fedf89;
  padding: 10px 12px; border-radius: var(--radius); margin-bottom: 14px; font-size: 14px;
}
.banner b { color: #7a2e0e; }
.banner a { text-decoration: underline; font-weight: 600; }

/* ---------- stat tiles */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 8px 0 14px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow); cursor: pointer;
}
.stat .v { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 12.5px; font-weight: 600; margin-top: 2px; }
.stat.red .v { color: var(--red); }
.stat.amber .v { color: var(--amber); }
.stat.green .v { color: var(--green); }
@media (max-width: 640px) { .stats { grid-template-columns: repeat(2, 1fr); } }

/* ---------- search + chips */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0 12px; }
.search {
  flex: 1; min-width: 200px; display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; height: 42px;
}
.search input { border: 0; outline: 0; flex: 1; background: transparent; height: 40px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 7px 13px; font-weight: 600; font-size: 13px; white-space: nowrap; cursor: pointer; color: #344054;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .n { opacity: .7; margin-left: 4px; font-weight: 500; }

/* ---------- lists */
.list { display: grid; gap: 10px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.party {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 14px; cursor: pointer;
}
.party:hover, .po:hover { border-color: #c7d2e3; }
.avatar {
  width: 52px; height: 52px; border-radius: 10px; background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-weight: 700; font-size: 18px; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.party .name { font-weight: 700; font-size: 16px; }
.party .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.party .right { text-align: right; }
.party .bal { font-weight: 700; font-size: 15px; white-space: nowrap; }
.party .bal-l { color: var(--muted); font-size: 12px; }
.tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 5px; }
.tag { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--gray-bg); color: #344054; }
.tag.red { background: var(--red-bg); color: var(--red); }
.tag.amber { background: var(--amber-bg); color: var(--amber); }
.tag.green { background: var(--green-bg); color: var(--green); }
.tag.blue { background: var(--brand-soft); color: var(--brand); }
.tag.gray { background: var(--gray-bg); color: var(--muted); }

.po { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 12px 14px; cursor: pointer; }
.po .thumb { width: 64px; height: 64px; border-radius: 10px; background: var(--gray-bg); overflow: hidden; display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.po .thumb img { width: 100%; height: 100%; object-fit: cover; }
.po .l1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.po .pid { font-weight: 700; font-size: 13.5px; color: var(--brand-2); }
.po .pname { font-weight: 700; font-size: 16px; margin-top: 1px; }
.po .pmeta { color: var(--muted); font-size: 13px; }
.po .l3 { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.bar { flex: 1; height: 7px; border-radius: 99px; background: var(--gray-bg); overflow: hidden; min-width: 60px; }
.bar i { display: block; height: 100%; background: var(--brand-2); border-radius: 99px; }
.bar.done i { background: var(--green); }
.qtyline { font-size: 13px; font-weight: 600; white-space: nowrap; }
.due { font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.due.red { color: var(--red); }
.due.amber { color: var(--amber); }
.due.muted { color: var(--muted); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

@media (min-width: 900px) {
  .list.two { grid-template-columns: 1fr 1fr; }
}

/* ---------- PO detail */
.po-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.po-head .title { flex: 1; min-width: 220px; }
.po-head h1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 42px; padding: 0 15px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #b8c3d4; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--red); border-color: #fda29b; }
.btn.danger.solid { background: var(--red); color: #fff; border-color: var(--red); }
.btn.green { color: var(--green); border-color: #75e0a7; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.small { height: 34px; padding: 0 11px; font-size: 13px; }

.grid2 { display: grid; grid-template-columns: 1.1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }
.photos { padding: 10px; display: grid; gap: 8px; grid-template-columns: repeat(2, 1fr); }
.photos.one { grid-template-columns: 1fr; }
.photos img { width: 100%; border-radius: 8px; display: block; cursor: zoom-in; background: var(--gray-bg); }
.photos.one img { max-height: 560px; object-fit: contain; }
.nophoto { padding: 30px; text-align: center; color: var(--muted); }
.specs { display: grid; grid-template-columns: 1fr 1fr; }
.spec { padding: 11px 14px; border-bottom: 1px solid var(--line); }
.spec:nth-child(odd) { border-right: 1px solid var(--line); }
.spec .k { color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; }
.spec .v { font-weight: 700; font-size: 15.5px; margin-top: 2px; word-break: break-word; }
.spec.wide { grid-column: 1 / -1; border-right: 0; }
.progress { padding: 14px; }
.progress .nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.progress .nums div { text-align: center; }
.progress .nums b { display: block; font-size: 17px; }
.progress .nums span { color: var(--muted); font-size: 12px; font-weight: 600; }
.progress .bar { height: 10px; }
.timeline { padding: 6px 14px 10px; }
.ev { display: grid; grid-template-columns: 14px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.ev:last-child { border-bottom: 0; }
.ev .d { width: 10px; height: 10px; border-radius: 50%; background: var(--brand-2); margin-top: 6px; }
.ev .w { font-weight: 600; font-size: 14px; }
.ev .t { color: var(--muted); font-size: 12.5px; }
.section-title { padding: 12px 14px 0; font-weight: 700; font-size: 13px; color: var(--muted); letter-spacing: .5px; text-transform: uppercase; }

/* ---------- modal */
.overlay {
  position: fixed; inset: 0; background: rgba(16,24,40,.45); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 640px) { .overlay { align-items: center; } }
.modal {
  background: #fff; width: 100%; max-width: 520px; max-height: 92vh; overflow: auto;
  border-radius: 16px 16px 0 0; padding: 18px 18px 22px;
}
@media (min-width: 640px) { .modal { border-radius: 16px; } }
.modal h3 { margin: 0 0 4px; font-size: 18px; }
.modal .hint { color: var(--muted); font-size: 13.5px; margin-bottom: 12px; }
.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field label { font-weight: 600; font-size: 13px; color: #344054; }
.field input, .field select, .field textarea {
  height: 44px; border: 1px solid #d0d5dd; border-radius: 10px; padding: 0 12px; background: #fff; outline: 0; width: 100%;
}
.field textarea { height: 84px; padding: 10px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px #d9e3f2; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid #d0d5dd; border-radius: 10px; overflow: hidden; margin-bottom: 12px; }
.seg button { border: 0; background: #fff; height: 42px; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--brand); color: #fff; }
.modal .btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.err { color: var(--red); font-size: 13.5px; font-weight: 600; min-height: 18px; }

/* ---------- lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 60; display: grid; place-items: center; cursor: zoom-out; }
.lightbox img { width: 96vw; max-width: 96vw; max-height: 92vh; object-fit: contain; }
.lightbox .lbx { position: fixed; top: 10px; right: 12px; width: 44px; height: 44px; border: 0; border-radius: 22px; background: rgba(255,255,255,.15); color: #fff; font-size: 22px; cursor: pointer; }
.lightbox .lbhd { position: fixed; top: 10px; right: 64px; height: 44px; padding: 0 14px; border: 0; border-radius: 22px; background: rgba(255,255,255,.15); color: #fff; font-weight: 700; cursor: pointer; }
.lightbox .lbl { position: fixed; left: 0; right: 0; bottom: 16px; text-align: center; color: #d0d5dd; font-size: 13px; }
.lightbox .lbc { position: fixed; top: 14px; left: 14px; padding: 8px 14px; border-radius: 20px; background: rgba(255,255,255,.15); color: #fff; font-weight: 700; font-size: 14px; }

/* ---------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(180deg, var(--brand) 0 38%, var(--bg) 38%); }
.login .box { background: #fff; border-radius: 18px; padding: 26px 22px; width: 100%; max-width: 360px; box-shadow: 0 10px 30px rgba(16,24,40,.12); text-align: center; }
.login h1 { font-size: 20px; margin: 0; }
.login p { color: var(--muted); margin: 4px 0 18px; font-size: 14px; }
.login input { text-align: center; font-size: 28px; letter-spacing: 10px; height: 58px; border: 1px solid #d0d5dd; border-radius: 12px; width: 100%; outline: 0; }
.login input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px #d9e3f2; }
.login .btn { width: 100%; margin-top: 12px; height: 48px; }

/* ---------- settings */
.panel { padding: 14px; }
.panel + .panel { border-top: 1px solid var(--line); }
.grp { display: grid; grid-template-columns: 1fr 190px; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.grp:last-child { border-bottom: 0; }
.grp .gn { font-weight: 600; }
.grp select { height: 40px; border: 1px solid #d0d5dd; border-radius: 9px; padding: 0 8px; background: #fff; }
@media (max-width: 520px) { .grp { grid-template-columns: 1fr; } }
.qr { text-align: center; padding: 10px; }
.qr img { width: 260px; max-width: 100%; }
.linkalt { border-top: 1px dashed var(--line); margin-top: 12px; padding-top: 12px; }
.code { font: 700 34px ui-monospace, Consolas, monospace; letter-spacing: 5px; background: var(--gray-bg); padding: 12px; border-radius: 10px; display: inline-block; }

/* ---------- toast */
#toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px);
  background: #101828; color: #fff; padding: 11px 16px; border-radius: 10px; font-weight: 600; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 70; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--red); }

/* ---------- multi-design POs */
.designs { padding: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.dz { background: var(--gray-bg); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.dz img { width: 100%; aspect-ratio: 4 / 5; object-fit: contain; background: #eef1f5; cursor: zoom-in; display: block; }
.dz .noph { aspect-ratio: 4 / 5; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.dl { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; padding: 6px 8px 2px; }
.dl span { font-weight: 700; font-size: 12.5px; color: var(--brand-2); }
.dl b { font-size: 15px; }
.dl b.miss { color: var(--red); }
.dn { color: var(--muted); font-size: 12px; padding: 0 8px 6px; }
.dtotal { margin: 2px 10px 12px; background: var(--brand); color: #fff; border-radius: 10px; padding: 10px 12px; font-size: 15px; }
.elines { display: grid; gap: 6px; max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.eline { display: grid; grid-template-columns: 40px 34px 1fr 90px; gap: 6px; align-items: center; }
.eline img, .eline .noph { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; background: var(--gray-bg); display: grid; place-items: center; }
.eline .en { font-weight: 700; font-size: 13px; color: var(--brand-2); }
.eline input { height: 38px; border: 1px solid #d0d5dd; border-radius: 8px; padding: 0 8px; width: 100%; min-width: 0; }

/* ---------- part delivery, design-wise */
.dp { font-size: 12px; color: var(--muted); padding: 0 8px 6px; }
.dp b { color: var(--brand); }
.dp.ok { color: var(--green); font-weight: 600; }
.dloose { margin: -6px 10px 12px; font-size: 12.5px; color: var(--amber); }
.rlines { display: grid; gap: 6px; max-height: 50vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.rline { display: grid; grid-template-columns: 56px 1fr 72px 74px; gap: 8px; align-items: center; }
.rline img, .rline .noph { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; background: var(--gray-bg); display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.rline img { cursor: zoom-in; }
.rline .ri { display: grid; min-width: 0; }
.rline .ri b { font-size: 13px; color: var(--brand-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rline .ri small { color: var(--muted); font-size: 11.5px; }
.rline input { height: 38px; border: 1px solid #d0d5dd; border-radius: 8px; padding: 0 8px; width: 100%; min-width: 0; }
.rline .btn.small { height: 34px; padding: 0 6px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rline .btn.small[disabled] { opacity: .5; cursor: default; }
.rtot { margin-top: 8px; background: var(--brand-soft); color: var(--brand); border-radius: 10px; padding: 9px 12px; font-size: 14.5px; }
.modal .sub a { color: var(--brand-2); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- photos of a PO without design lines: numbers, received badges, picking in the receive form */
.photos .ph { position: relative; }
.photos .pn, .pick .pn { position: absolute; top: 6px; left: 6px; background: rgba(16,24,40,.7); color: #fff; font-size: 12px; font-weight: 700; border-radius: 6px; padding: 1px 6px; }
.photos .pb { position: absolute; left: 6px; bottom: 6px; background: var(--brand); color: #fff; font-size: 11.5px; font-weight: 700; border-radius: 6px; padding: 2px 7px; }
.photos .pb.ok { background: var(--green); }
.psum { margin: -4px 10px 12px; font-size: 13.5px; color: var(--muted); }
.psum b { color: var(--green); }
.pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; max-height: 44vh; overflow: auto; }
.pick .pk { position: relative; padding: 0; border: 2px solid transparent; border-radius: 8px; background: var(--gray-bg); cursor: pointer; overflow: hidden; aspect-ratio: 3 / 4; }
.pick .pk img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pick .pk.on { border-color: var(--green); box-shadow: 0 0 0 2px var(--green-bg); }
.pick .pk.on::after { content: '✓'; position: absolute; right: 4px; bottom: 4px; width: 22px; height: 22px; border-radius: 11px; background: var(--green); color: #fff; font-weight: 800; font-size: 13px; display: grid; place-items: center; }
.pick .pd { position: absolute; right: 4px; top: 4px; background: rgba(6,118,71,.85); color: #fff; font-size: 11px; font-weight: 800; border-radius: 6px; padding: 0 5px; }
