@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&family=Noto+Sans+Bengali:wght@400;600&display=swap');

:root {
  --ink: #2b2230;
  --ink-soft: #6b5d70;
  --plum: #6e5478;
  --purple: #9b7ec8;
  --purple-wash: #f3eefa;
  --rosewood: #b5562e;
  --coral: #c97b5a;
  --bg: #fbf8f6;
  --surface: #ffffff;
  --line: #ece1e7;
  --line-strong: #d9c9d3;
  --alert: #c0392b;
  --alert-wash: #fdeeeb;
  --good: #46785a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(43, 34, 48, .06), 0 8px 24px rgba(43, 34, 48, .05);
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --sans: 'Inter', 'Noto Sans Bengali', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--rosewood); }

.eyebrow {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--plum);
}

.num { font-family: var(--mono); font-feature-settings: 'tnum'; }

/* ---------------------------------------------------------------- login */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1000px 500px at 50% -10%, var(--purple-wash), transparent 70%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-card img { width: 120px; margin-bottom: 4px; }
.login-card h1 { font-size: 16px; font-weight: 600; margin: 8px 0 2px; }
.login-card p.sub { color: var(--ink-soft); font-size: 12px; margin: 0 0 22px; }
.login-card .field { text-align: left; }

/* ----------------------------------------------------------------- shell */

.shell { display: flex; min-height: 100vh; }

.rail {
  width: 216px;
  flex: 0 0 216px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.rail-logo { text-align: center; padding: 4px 0 16px; }
.rail-logo img { width: 96px; }
.rail-logo .tag {
  font-size: 8px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--plum); margin-top: 2px;
}

.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; border-radius: 8px; border: 0; background: none;
  text-align: left; cursor: pointer; color: var(--ink-soft); font-weight: 500; width: 100%;
}
.nav-item:hover { background: var(--bg); color: var(--ink); }
.nav-item.active { background: var(--purple-wash); color: var(--plum); font-weight: 600; }
.nav-item .badge {
  background: var(--alert); color: #fff; font-size: 10px; font-weight: 600;
  border-radius: 20px; padding: 1px 7px;
}

.rail-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
.rail-foot .who { font-size: 11px; color: var(--ink-soft); padding: 0 12px 6px; }

.main { flex: 1; min-width: 0; padding: 26px 30px 60px; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.page-head h1 { font-size: 22px; font-weight: 600; margin: 2px 0 0; letter-spacing: -.01em; }
.page-head .desc { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- pieces */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card h2 { font-size: 13px; font-weight: 600; margin: 0 0 14px; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); font-weight: 600; }
.stat .value { font-family: var(--mono); font-size: 22px; font-weight: 600; margin-top: 6px; letter-spacing: -.02em; }
.stat .value.accent { color: var(--rosewood); }
.stat .note { font-size: 11px; color: var(--ink-soft); margin-top: 2px; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong);
  border-radius: 7px; background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-wash); }
textarea { resize: vertical; min-height: 62px; }
input[readonly] { background: var(--bg); color: var(--ink-soft); }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 150px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 8px 14px; border-radius: 7px; border: 1px solid var(--line-strong);
  background: #fff; cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn:hover { border-color: var(--purple); color: var(--plum); }
.btn.primary { background: var(--rosewood); border-color: var(--rosewood); color: #fff; }
.btn.primary:hover { background: #9d4a28; color: #fff; }
.btn.ghost { border-color: transparent; background: var(--bg); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-soft); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #fdfbfa; }
td.r, th.r { text-align: right; }
.table-wrap { overflow-x: auto; }

.pill { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: var(--purple-wash); color: var(--plum); }
.pill.low { background: var(--alert-wash); color: var(--alert); }
.pill.out { background: #f1eef2; color: var(--ink-soft); }
.pill.ok { background: #eef5f0; color: var(--good); }

.empty { padding: 26px; text-align: center; color: var(--ink-soft); font-size: 13px; }

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 90;
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 8px;
  box-shadow: var(--shadow); max-width: 340px; font-size: 13px;
}
.toast.bad { background: var(--alert); }

.modal-back {
  position: fixed; inset: 0; background: rgba(43, 34, 48, .4);
  display: grid; place-items: center; padding: 20px; z-index: 80;
}
.modal {
  background: var(--surface); border-radius: 12px; padding: 22px;
  width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; box-shadow: var(--shadow);
}
.modal h3 { margin: 0 0 4px; font-size: 15px; }
.modal .sub { color: var(--ink-soft); font-size: 12px; margin: 0 0 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin-bottom: 0; min-width: 140px; }

.line-row { display: grid; grid-template-columns: 1fr 92px 92px 104px 34px; gap: 8px; align-items: center; margin-bottom: 8px; }
.line-row .stockhint { font-size: 11px; color: var(--ink-soft); }
.totals { max-width: 340px; margin-left: auto; }
.totals .line { display: flex; justify-content: space-between; padding: 5px 0; }
.totals .line.grand { border-top: 1px solid var(--line-strong); margin-top: 6px; padding-top: 9px; font-weight: 600; font-size: 16px; }
.totals .line.due { color: var(--rosewood); font-weight: 600; }

.bar { height: 6px; border-radius: 4px; background: var(--purple); opacity: .85; }
.bar.alt { background: var(--coral); }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .rail { width: auto; flex: none; height: auto; position: static; flex-direction: row; overflow-x: auto; padding: 10px; align-items: center; }
  .rail-logo { padding: 0 10px 0 4px; }
  .rail-logo img { width: 54px; }
  .rail-logo .tag { display: none; }
  .rail-foot { margin: 0; border: 0; padding: 0; }
  .rail-foot .who { display: none; }
  .nav-item { width: auto; white-space: nowrap; }
  .main { padding: 18px 16px 50px; }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .line-row { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ----------------------------------------------------------- print area */

#printArea { display: none; }

@media print {
  @page { size: A4 portrait; margin: 8mm; }
  body { background: #fff; }
  .shell, .toast, .modal-back { display: none !important; }
  #printArea { display: block !important; }
  #printArea, #printArea * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

.sheet { display: flex; flex-direction: column; font-family: var(--sans); color: #2b2230; }
.cut {
  height: 5mm; display: flex; align-items: center; gap: 3mm;
  color: #bfaeb9; font-size: 6pt; letter-spacing: .2em; text-transform: uppercase;
}
.cut::before, .cut::after { content: ''; flex: 1; border-top: 1px dashed #cbbcc6; }
.copy {
  width: 100%; min-height: 138mm; border: 1px solid #d9c9d3; border-radius: 3mm;
  padding: 5mm 6mm; font-size: 9pt; line-height: 1.3; display: flex; flex-direction: column;
  background: #ffffff;
}
.copy .c-head { display: flex; align-items: center; gap: 4mm; border-bottom: 1px solid #d9c9d3; padding-bottom: 2.5mm; }
.copy .c-head img { width: 21mm; }
.copy .c-head .biz { line-height: 1.25; }
.copy .c-head .biz strong { font-size: 13pt; display: block; letter-spacing: .02em; }
.copy .c-head .biz .tl {
  display: block; font-size: 7pt; letter-spacing: .12em;
  text-transform: uppercase; color: #6e5478;
}
.copy .c-head .c-label {
  margin-left: auto; align-self: flex-start; text-align: right;
  font-size: 6.5pt; letter-spacing: .16em; text-transform: uppercase; color: #b5562e;
}
.copy .c-meta { display: flex; justify-content: space-between; gap: 4mm; margin: 2mm 0 1.5mm; font-size: 8.5pt; }
.copy .c-meta .invno { font-family: var(--mono); font-weight: 600; font-size: 11pt; }
.copy .c-cust { border-top: 1px solid #ece1e7; border-bottom: 1px solid #ece1e7; padding: 2mm 0; font-size: 8.5pt; line-height: 1.35; }
.copy table { width: 100%; border-collapse: collapse; margin-top: 2mm; font-size: 8.5pt; }
.copy th { font-size: 6.5pt; letter-spacing: .08em; padding: 1.2mm 1mm; border-bottom: 1px solid #d9c9d3; }
.copy td { padding: 1.2mm 1mm; border-bottom: 1px solid #f2ebef; line-height: 1.25; vertical-align: top; }
.copy .c-totals { margin-top: 2mm; margin-left: auto; width: 62mm; font-size: 9pt; }
.copy .c-totals div { display: flex; justify-content: space-between; padding: .5mm 0; }
.copy .c-totals .g { border-top: 1px solid #d9c9d3; margin-top: 1mm; padding-top: 1.2mm; font-weight: 700; font-size: 9.5pt; }
.copy .c-totals .d { color: #b5562e; font-weight: 700; font-size: 9.5pt; }
.copy .c-note { margin-top: 2mm; font-size: 8pt; line-height: 1.35; }
.copy .c-foot { margin-top: auto; padding-top: 2.5mm; font-size: 7.5pt; line-height: 1.4; text-align: center; color: #6b5d70; border-top: 1px solid #ece1e7; }
.copy .c-foot .check { color: #b5562e; font-weight: 600; font-size: 8pt; }

.typeswitch { display: flex; gap: 10px; flex-wrap: wrap; }
.type-btn {
  flex: 1; min-width: 180px; text-align: left; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; padding: 12px 14px;
}
.type-btn strong { display: block; font-size: 14px; }
.type-btn span { font-size: 11.5px; color: var(--ink-soft); }
.type-btn:hover { border-color: var(--purple); }
.type-btn.on { border-color: var(--rosewood); background: #fdf4f0; box-shadow: inset 0 0 0 1px var(--rosewood); }
.type-btn.gift.on { border-color: var(--plum); background: var(--purple-wash); box-shadow: inset 0 0 0 1px var(--plum); }

.pill.gift { background: var(--purple-wash); color: var(--plum); }
.gift-row { background: #fcfaff; }
.gift-banner {
  background: var(--purple-wash); border: 1px solid #ddd0ef; border-radius: 8px;
  padding: 10px 12px; font-size: 12px; color: var(--plum); margin-bottom: 12px;
}
.copy .c-gift { color: #6e5478; font-size: 6.5pt; letter-spacing: .1em; margin-top: 1mm; }

.returned-row { background: #fdf6f4; }
.returned-row td { color: var(--ink-soft); }
.return-banner {
  background: var(--alert-wash); border: 1px solid #f3d3cc; border-radius: 8px;
  padding: 10px 12px; font-size: 12px; line-height: 1.5; color: #8d3323; margin-bottom: 12px;
}
.return-banner div { margin-top: 4px; color: #a3564a; }

/* ------------------------------------------------- searchable product pick */

.pick { position: relative; }
.pick-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
  background: #fff; border: 1px solid var(--line-strong); border-radius: 8px;
  max-height: 268px; overflow-y: auto; box-shadow: 0 10px 28px rgba(43,34,48,.14);
}
.pick-opt {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 8px 11px; cursor: pointer; border-bottom: 1px solid var(--line);
}
.pick-opt:last-child { border-bottom: 0; }
.pick-opt.active, .pick-opt:hover { background: var(--purple-wash); }
.pick-opt .meta { color: var(--ink-soft); font-size: 11px; white-space: nowrap; }
.pick-opt .meta.low { color: var(--alert); }
.pick-empty { padding: 12px; color: var(--ink-soft); font-size: 12px; text-align: center; }
