/* RPP Manager. Colours are taken from the Ratul Printing Press letterhead:
   the indigo of the wordmark and the orange of the logo block. */
@font-face { font-family: "Poppins"; src: url("fonts/poppins-regular.woff") format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Poppins"; src: url("fonts/poppins-medium.woff") format("woff"); font-weight: 500 600; font-display: swap; }
@font-face { font-family: "Poppins"; src: url("fonts/poppins-bold.woff") format("woff"); font-weight: 700; font-display: swap; }

:root {
  --navy: #1b1f5e;
  --royal: #2e3192;
  --royal-soft: #e9eaf7;
  --orange: #f08a24;
  --orange-deep: #b4530a;
  --saffron: #fff3da;
  --paper: #f2f3f9;
  --surface: #ffffff;
  --ink: #161a3a;
  --muted: #5d6390;
  --line: #d9dcee;
  --green: #17794a;
  --green-soft: #e1f3ea;
  --red: #b3261e;
  --red-soft: #fbe6e4;
  --radius: 10px;
  --font: "Poppins", "Hind Siliguri", "Noto Sans Bengali", "Nirmala UI", "Kohinoor Bangla", "Vrinda", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.5; color: var(--ink); background: var(--paper); }
body.lang-bn { font-size: 15.5px; line-height: 1.6; }
a { color: var(--royal); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; text-wrap: balance; }
h1 { font-size: 1.55rem; letter-spacing: -0.01em; }
h2 { font-size: 1.08rem; }
h3 { font-size: 0.95rem; }
p { margin: 0 0 0.8em; }
small, .muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums lining-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; border-radius: 4px; }
.ic { width: 19px; height: 19px; flex: none; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--navy); color: #cfd2f0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 11px; align-items: center; padding: 18px 18px 16px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 4px; }
.brand b { display: block; font-size: 0.98rem; font-weight: 600; line-height: 1.2; }
.brand small { color: #f6b56c; font-size: 0.72rem; }
.side nav { padding: 2px 10px 18px; flex: 1; }
.navgroup { font-size: 0.72rem; color: #8f94cf; padding: 15px 10px 5px; font-weight: 500; }
.side nav a { display: flex; align-items: center; gap: 11px; padding: 7px 10px; border-radius: 7px; color: #d5d8f3; font-size: 0.9rem; position: relative; }
.side nav a:hover { background: rgba(255, 255, 255, 0.07); text-decoration: none; color: #fff; }
.side nav a.on { background: #fff; color: var(--navy); font-weight: 600; }
.side nav a.on::before { content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 4px; border-radius: 0 3px 3px 0; background: var(--orange); }
/* a strip of bars, like the barcodes the press prints all day */
.barcode-strip { height: 26px; margin: 0 18px 16px; opacity: 0.5;
  background: repeating-linear-gradient(90deg, #fff 0 2px, transparent 2px 5px, #fff 5px 6px, transparent 6px 10px, #fff 10px 13px, transparent 13px 15px, #fff 15px 16px, transparent 16px 21px); }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 14px; padding: 10px 26px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.search { flex: 1; max-width: 520px; display: flex; align-items: center; gap: 8px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 0 11px; color: var(--muted); }
.search input[type=search] { border: 0; background: transparent; padding: 8px 0; width: 100%; font: inherit; color: var(--ink); outline: none; box-shadow: none; }
.search:focus-within { border-color: var(--royal); box-shadow: 0 0 0 3px var(--royal-soft); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.langsw { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; font-size: 0.82rem; }
.langsw a { padding: 5px 10px; color: var(--muted); }
.langsw a.on { background: var(--royal); color: #fff; }
.langsw a:hover { text-decoration: none; }
.who { text-align: right; line-height: 1.2; color: var(--ink); }
.who b { display: block; font-weight: 600; font-size: 0.88rem; }
.who small { font-size: 0.74rem; }
.menu-btn { display: none; cursor: pointer; padding: 6px; border-radius: 7px; color: var(--navy); }
.navtoggle { position: absolute; opacity: 0; pointer-events: none; }
.content { padding: 24px 26px 60px; max-width: 1360px; width: 100%; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; font: inherit; font-weight: 500; font-size: 0.9rem; padding: 8px 15px; border-radius: 8px; border: 1px solid var(--royal); background: var(--royal); color: #fff; cursor: pointer; line-height: 1.3; white-space: nowrap; }
.btn:hover { background: var(--navy); border-color: var(--navy); text-decoration: none; }
.btn-accent { background: var(--orange); border-color: var(--orange); color: #25184a; font-weight: 600; }
.btn-accent:hover { background: #f79b3f; border-color: #f79b3f; }
.btn-ghost { background: var(--surface); color: var(--royal); border-color: var(--line); }
.btn-ghost:hover { background: var(--royal-soft); border-color: var(--royal); }
.btn-danger { background: var(--surface); color: var(--red); border-color: #e8b9b5; }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; border-radius: 6px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--royal); cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.linkbtn.danger { color: var(--red); }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card .pad { padding: 16px 18px; }
.stack > * + * { margin-top: 18px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.split { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 18px; align-items: start; }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.t th { text-align: left; font-weight: 500; font-size: 0.8rem; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); background: #f8f8fd; white-space: nowrap; }
.t td { padding: 9px 12px; border-bottom: 1px solid #eceef8; vertical-align: top; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr:hover td { background: #fafaff; }
.t th.num, .t td.num { text-align: right; }
.t tfoot td { font-weight: 600; background: var(--saffron); border-top: 1px solid #f1d9a5; }
.t .sub { display: block; font-size: 0.8rem; color: var(--muted); }
.t td.act { text-align: right; white-space: nowrap; }
.t td.act > * + * { margin-left: 10px; }
.t a.main { font-weight: 500; color: var(--ink); }
.t a.main:hover { color: var(--royal); }

/* ---------- chips ---------- */
.chip { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 0.76rem; font-weight: 500; white-space: nowrap; border: 1px solid transparent; }
.chip-grey { background: #eef0f6; color: #4b5074; }
.chip-blue { background: var(--royal-soft); color: var(--royal); }
.chip-navy { background: var(--navy); color: #fff; }
.chip-green { background: var(--green-soft); color: var(--green); }
.chip-orange { background: #ffe9cf; color: var(--orange-deep); }
.chip-red { background: var(--red-soft); color: var(--red); }

/* ---------- forms ---------- */
.f { display: block; }
.f > span, .flabel { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input[type=text], input[type=number], input[type=date], input[type=month], input[type=email], input[type=password], input[type=search], input[type=file], select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid #c5c9e2; border-radius: 7px; padding: 7px 10px; width: 100%; min-width: 0; }
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--royal); box-shadow: 0 0 0 3px var(--royal-soft); }
input[readonly] { background: #f5f6fb; color: var(--muted); }
.fgrid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px 16px; }
.c2 { grid-column: span 2; } .c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c5 { grid-column: span 5; }
.c6 { grid-column: span 6; } .c8 { grid-column: span 8; } .c9 { grid-column: span 9; } .c12 { grid-column: span 12; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--royal); }
.hint { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.formbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 14px 18px; border-top: 1px solid var(--line); background: #fafaff; border-radius: 0 0 var(--radius) var(--radius); }
form[data-doc] > .formbar { position: sticky; bottom: 0; z-index: 5; box-shadow: 0 -6px 14px rgba(27, 31, 94, 0.06); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.filters .f { min-width: 150px; }
.filters .grow { flex: 1; min-width: 200px; }

/* line items */
table.items { width: 100%; border-collapse: collapse; }
.items th { font-size: 0.78rem; color: var(--muted); font-weight: 500; text-align: left; padding: 6px 5px; white-space: nowrap; }
.items td { padding: 3px 4px; vertical-align: top; }
.items input, .items select, .items textarea { padding: 6px 7px; border-radius: 6px; font-size: 0.88rem; }
.items textarea { min-height: 34px; height: 34px; }
.items .n { width: 28px; text-align: center; color: var(--muted); padding-top: 9px; }
.items input.num { text-align: right; }
.items .x { width: 30px; }
.rowx { border: 0; background: none; color: #a3a7c6; cursor: pointer; font-size: 1.2rem; line-height: 1; padding: 6px; border-radius: 6px; }
.rowx:hover { color: var(--red); background: var(--red-soft); }
.pricehint { font-size: 0.74rem; color: var(--green); margin-top: 2px; }
.pricehint.none { color: var(--muted); }
.totals { margin-left: auto; width: min(340px, 100%); }
.totals div { display: flex; justify-content: space-between; padding: 5px 0; gap: 14px; align-items: center; }
.totals .grand { border-top: 2px solid var(--navy); margin-top: 6px; padding-top: 9px; font-weight: 700; font-size: 1.12rem; }
.totals input { width: 130px; text-align: right; }
.thumb { width: 54px; height: 54px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; }

/* ---------- messages ---------- */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; font-size: 0.92rem; }
.flash-ok { background: var(--green-soft); border-color: #a9d8bf; color: #0f5a36; }
.flash-err { background: var(--red-soft); border-color: #e8b9b5; color: #8a1c15; }
.flash-warn { background: #fff0db; border-color: #f3cf9c; color: #8a4208; }
.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty h2 { color: var(--ink); margin-bottom: 6px; }
.empty .btn { margin-top: 8px; }
.pager { display: flex; gap: 5px; padding: 12px 18px; border-top: 1px solid var(--line); }
.pager a, .pager b, .pager span { padding: 3px 10px; border-radius: 6px; font-size: 0.86rem; }
.pager b { background: var(--royal); color: #fff; }
.pager a { border: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a.on { color: var(--navy); border-color: var(--orange); }
.tabs a:hover { text-decoration: none; color: var(--navy); }
.tabs .count { font-size: 0.76rem; background: #e9eaf5; border-radius: 10px; padding: 1px 7px; margin-left: 5px; }

/* ---------- facts list on document pages ---------- */
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
dl.facts dt { color: var(--muted); font-size: 0.86rem; }
dl.facts dd { margin: 0; font-weight: 500; }
/* the reference ticket: our own number with its barcode */
.ticket { display: flex; align-items: center; gap: 16px; background: var(--saffron); border: 1px dashed #e0b96b; border-radius: var(--radius); padding: 12px 16px; position: relative; }
.ticket::before, .ticket::after { content: ""; position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%; background: var(--paper); border: 1px dashed #e0b96b; transform: translateY(-50%); }
.ticket::before { left: -8px; } .ticket::after { right: -8px; }
.ticket .ref { font-size: 1.12rem; font-weight: 700; color: var(--navy); letter-spacing: 0.02em; }
.ticket svg { height: 44px; width: auto; flex: none; background: #fff; padding: 3px 5px; border-radius: 4px; }

/* ---------- dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; border-top: 3px solid var(--royal); }
.kpi.warm { border-top-color: var(--orange); }
.kpi .label { font-size: 0.84rem; color: var(--muted); }
.kpi .value { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .foot { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.up { color: var(--green); } .down { color: var(--red); }

/* LC rail: every unpaid PI hangs on a line of days, like tags on a string */
.rail { position: relative; padding: 0 18px 14px; }
.rail-scroll { overflow-x: auto; padding-bottom: 6px; }
.rail-track { position: relative; height: 178px; min-width: 760px; margin: 6px 26px 0; }
.rail-line { position: absolute; left: 0; right: 0; top: 30px; height: 3px; background: var(--navy); border-radius: 2px; }
.rail-today { position: absolute; top: 4px; width: 2px; height: 52px; background: var(--orange); }
.rail-today span { position: absolute; top: -4px; left: 6px; font-size: 0.74rem; font-weight: 600; color: var(--orange-deep); white-space: nowrap; }
.rail-tick { position: absolute; top: 30px; width: 1px; height: 9px; background: var(--navy); }
.rail-tick span { position: absolute; top: -22px; left: 50%; transform: translateX(-50%); font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.lctag { position: absolute; top: 31px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; color: var(--ink); }
.lctag:hover { text-decoration: none; z-index: 5; }
.lctag i { display: block; width: 1.5px; background: #8087c4; }
.lctag b { display: block; background: #fff; border: 1.5px solid var(--royal); border-radius: 5px 5px 8px 8px; padding: 9px 9px 5px; font-size: 0.8rem; font-weight: 600; text-align: center; line-height: 1.25; position: relative; min-width: 82px; box-shadow: 0 2px 0 rgba(27, 31, 94, 0.12); }
.lctag b::before { content: ""; position: absolute; top: 3px; left: 50%; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--royal); }
.lctag b small { display: block; font-weight: 400; font-size: 0.7rem; color: var(--muted); }
.lctag.wait b { border-style: dashed; border-color: var(--orange-deep); background: #fff8ee; }
.lctag.wait b::before { background: var(--orange-deep); }
.lctag.late b { border-color: var(--red); background: var(--red-soft); }
.lctag.late b::before { background: var(--red); }
.lctag:hover b { background: var(--navy); color: #fff; border-color: var(--navy); }
.lctag:hover b small { color: #cfd2f0; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.8rem; color: var(--muted); padding: 0 18px 12px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; border: 1.5px solid var(--royal); background: #fff; }
.legend i.wait { border-style: dashed; border-color: var(--orange-deep); background: #fff8ee; }
.legend i.late { border-color: var(--red); background: var(--red-soft); }
.chart svg { display: block; width: 100%; height: auto; }
.chart text { font-family: var(--font); }
.bar-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr) max-content; gap: 10px; align-items: center; padding: 6px 0; font-size: 0.88rem; }
.bar-row .track { background: #edeef7; height: 9px; border-radius: 5px; overflow: hidden; }
.bar-row .track i { display: block; height: 100%; background: var(--royal); border-radius: 5px; }
.bar-row.warm .track i { background: var(--orange); }

.tip { position: fixed; z-index: 99; display: none; background: var(--navy); color: #fff; font-size: 0.8rem; padding: 7px 10px; border-radius: 7px; white-space: pre; pointer-events: none; line-height: 1.5; box-shadow: 0 6px 18px rgba(10, 12, 40, 0.3); }
.chart .hit:hover { fill: rgba(46, 49, 146, 0.06); }
.tableview { margin-top: 8px; font-size: 0.86rem; }
.tableview summary { cursor: pointer; color: var(--royal); }
.tableview .tablewrap { margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; }

/* ---------- login and installer ---------- */
.bare { background: var(--navy); min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate { width: min(940px, 100%); background: var(--surface); border-radius: 14px; overflow: hidden; display: grid; grid-template-columns: 1fr 1fr; box-shadow: 0 30px 80px rgba(8, 10, 40, 0.5); }
.gate-art { background: linear-gradient(160deg, #f6c64a 0%, #fbe3a2 55%, #fff6e0 100%); padding: 38px 34px; display: flex; flex-direction: column; justify-content: space-between; min-height: 430px; }
.gate-art img { width: 84px; border: 0; border-radius: 3px; }
.gate-art h1 { font-size: 2.3rem; color: var(--royal); font-weight: 700; line-height: 1.08; margin-top: 22px; letter-spacing: -0.02em; }
.gate-art p { color: #4a3b12; margin: 12px 0 0; max-width: 30ch; }
.gate-art .bars { height: 54px; background: repeating-linear-gradient(90deg, var(--navy) 0 3px, transparent 3px 6px, var(--navy) 6px 7px, transparent 7px 12px, var(--navy) 12px 16px, transparent 16px 18px, var(--navy) 18px 19px, transparent 19px 25px); }
.gate-art .since { font-size: 0.8rem; color: var(--navy); font-weight: 600; margin-top: 6px; letter-spacing: 0.32em; }
.gate-form { padding: 38px 34px; }
.gate-form h2 { font-size: 1.3rem; margin-bottom: 4px; }
.gate-form form { margin-top: 20px; display: grid; gap: 14px; }
.gate-form .btn { justify-content: center; padding: 10px; }
.gate.wide { grid-template-columns: 1fr; width: min(720px, 100%); }
.checks { list-style: none; padding: 0; margin: 0 0 6px; font-size: 0.9rem; }
.checks li { padding: 3px 0 3px 24px; position: relative; }
.checks li::before { content: "✓"; position: absolute; left: 2px; color: var(--green); font-weight: 700; }
.checks li.bad::before { content: "✕"; color: var(--red); }
.checks li.bad { color: var(--red); }

/* ---------- small screens ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .grid3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 40; width: 262px; transform: translateX(-100%); transition: transform 0.18s ease; }
  .navtoggle:checked ~ .side { transform: none; box-shadow: 0 0 0 100vmax rgba(10, 12, 40, 0.45); }
  .menu-btn { display: inline-flex; }
  .top { padding: 9px 14px; gap: 9px; }
  .who small, .who { display: none; }
  .content { padding: 16px 14px 60px; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .fgrid > * { grid-column: span 12; }
  .gate { grid-template-columns: 1fr; }
  .gate-art { min-height: 0; padding: 26px; }
  .gate-art .bars { display: none; }
  h1 { font-size: 1.3rem; }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .langsw a { padding: 5px 7px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  .side, .top, .actions, .formbar, .filters { display: none !important; }
  .app { display: block; } body { background: #fff; }
}

/* keep line-item boxes wide enough to read; the table scrolls sideways on small screens */
.items input[data-f="item_name"] { min-width: 168px; }
.items input[data-f="item_code"] { min-width: 118px; text-transform: uppercase; font-weight: 500; }
.items [data-codehint] { max-width: 118px; }
.items input[data-f="po_no"] { min-width: 116px; }
.items input[data-f="style"], .items input[data-f="color"], .items input[data-f="group_label"] { min-width: 96px; }
.items input[data-f="ref_code"] { min-width: 160px; }
.items input.num { min-width: 88px; }
.items input[data-f^="size"] { min-width: 56px; padding: 6px 4px; text-align: center; }
.items select { min-width: 80px; }
.items textarea { min-width: 160px; }
#salform input.num { min-width: 98px; }
