/* AHN ERP - colourful professional theme */
:root {
  --brand: #12805c;
  --brand-dark: #0b5a42;
  --brand-deep: #073d2e;
  --brand-soft: #e3f5ec;
  --accent: #12805c;           /* changes per department */
  --accent-soft: #e3f5ec;
  --bg: #f3f6fb;
  --panel: #ffffff;
  --text: #182230;
  --muted: #667085;
  --line: #e4e9f0;
  --danger: #d92d20;
  --danger-soft: #fef0ef;
  --warn: #b54708;
  --warn-soft: #fff6e6;
  --ok: #067647;
  --info: #175cd3;
  --info-soft: #eaf2ff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 20px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  font-family: "Segoe UI", "Inter", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}
/* department colours */
[data-dept="sales"] { --accent: #2563eb; --accent-soft: #e8f0ff; }
[data-dept="qc"] { --accent: #9333ea; --accent-soft: #f4ebff; }
[data-dept="store"] { --accent: #d97706; --accent-soft: #fff4e0; }
[data-dept="purchase"] { --accent: #0d9488; --accent-soft: #e0f7f4; }
[data-dept="accounts"] { --accent: #16a34a; --accent-soft: #e6f7ec; }
[data-dept="delivery"] { --accent: #e11d48; --accent-soft: #ffe8ee; }
[data-dept="production"] { --accent: #4f46e5; --accent-soft: #ecebff; }

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); background-image: radial-gradient(1200px 500px at 100% -10%, #e6f7ef 0%, transparent 60%), radial-gradient(900px 400px at -10% 110%, #eaf0ff 0%, transparent 60%); background-attachment: fixed; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 21px; margin: 0; letter-spacing: -.2px; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; }
.boot { padding: 40px; color: var(--muted); }
::selection { background: #bfe9d5; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.side { width: 236px; flex: none; background: linear-gradient(175deg, #0b5a42 0%, #073d2e 55%, #062a22 100%); color: #d6efe3; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; box-shadow: 4px 0 24px rgba(6, 42, 34, .18); }
.brand { display: block; padding: 20px 20px 16px; font-weight: 800; font-size: 19px; color: #fff; letter-spacing: .4px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand::before { content: ""; display: inline-block; width: 26px; height: 26px; margin-right: 9px; vertical-align: -6px; border-radius: 8px;
  background: #3ddc97 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 18c0-7 5-11 12-11-1 7-5 11-12 11z' fill='%23073d2e'/%3E%3C/svg%3E") center/18px no-repeat; }
.brand small { display: block; font-weight: 400; font-size: 11px; color: #94d3b6; margin: 4px 0 0 35px; letter-spacing: 0; }
.nav { padding: 12px 10px; flex: 1; overflow: auto; }
.nav a { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 10px; color: #cfe9dd; margin-bottom: 2px; font-weight: 500; transition: background .15s, color .15s; }
.nav a::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.28); flex: none; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav a.active { background: #fff; color: var(--text); font-weight: 650; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.nav a.active::before { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.nav a[data-nav="home"] { color: #94d3b6; font-size: 13px; }
.nav a[data-nav="home"]::before { display: none; }
.nav .sep { display: flex; align-items: center; gap: 8px; font-size: 11px; text-transform: uppercase; color: #fff; padding: 16px 12px 8px; letter-spacing: .8px; font-weight: 700; }
.nav .sep::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 0 3px rgba(255,255,255,.12); }
.nav .sep.sub { color: #94d3b6; font-size: 10.5px; padding-top: 18px; }
.nav .sep.sub::before { background: rgba(255,255,255,.3); width: 8px; height: 8px; }
.who { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; background: rgba(0,0,0,.12); }
.who b { color: #fff; display: block; }
.who .links { margin-top: 8px; display: flex; gap: 12px; flex-wrap: wrap; }
.who a { color: #94d3b6; cursor: pointer; }
.main { flex: 1; min-width: 0; padding: 24px 30px 48px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.topbar h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar h1::before { content: ""; width: 6px; height: 24px; border-radius: 4px; background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 50%, #fff)); }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.menu-btn { display: none; }

/* ---------- panels ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.card > h2:first-child { display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { --k: #2563eb; position: relative; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 16px 20px; box-shadow: var(--shadow); }
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--k); }
.kpi::after { content: ""; position: absolute; right: -26px; top: -26px; width: 86px; height: 86px; border-radius: 50%; background: var(--k); opacity: .09; }
.kpi:nth-child(7n+1) { --k: #2563eb; } .kpi:nth-child(7n+2) { --k: #16a34a; } .kpi:nth-child(7n+3) { --k: #9333ea; }
.kpi:nth-child(7n+4) { --k: #e11d48; } .kpi:nth-child(7n+5) { --k: #d97706; } .kpi:nth-child(7n+6) { --k: #0d9488; } .kpi:nth-child(7n+7) { --k: #4f46e5; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.kpi .value { font-size: 24px; font-weight: 750; margin-top: 6px; font-variant-numeric: tabular-nums; color: var(--text); }
.kpi .value.red { color: var(--danger); }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
a.kpi:hover { box-shadow: var(--shadow-lg); text-decoration: none; }

/* ---------- buttons & inputs ---------- */
button, .btn { font: inherit; font-weight: 550; border: 1px solid #d5dce6; background: #fff; color: var(--text); padding: 8px 15px; border-radius: 10px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; box-shadow: 0 1px 2px rgba(16,24,40,.05); }
button:hover, .btn:hover { border-color: #b7c2d0; background: #f8fafc; text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }
.primary { background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 75%, #000)); border-color: transparent; color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 30%, transparent); }
.primary:hover { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 88%, #000), color-mix(in srgb, var(--accent) 65%, #000)); border-color: transparent; color: #fff; }
.danger { color: var(--danger); border-color: #f5c2bd; background: #fff; }
.danger:hover { background: var(--danger-soft); border-color: #f0a8a1; }
.small { padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.link { border: none; background: none; color: var(--accent); padding: 0; box-shadow: none; }
.link:hover { background: none; text-decoration: underline; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; border: 1px solid #d0d8e3; border-radius: 10px; padding: 8px 11px; background: #fff; color: var(--text); width: 100%; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); }
input:disabled, select:disabled, input[readonly] { background: #f4f6f9; color: var(--muted); }
.adv { color: #067647; font-weight: 700; }
/* section heading inside a form */
.form-head { margin-top: 6px; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); font-weight: 700; color: var(--text); }
.form-head small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 2px; }
/* "+ Add new" box under a pick list */
.pick-add { display: flex; gap: 6px; margin-top: 6px; padding: 8px; background: var(--accent-soft); border-radius: 10px; }
.pick-add input { flex: 1; min-width: 0; }
.pick-add[hidden], .upz-pop[hidden], label.f[hidden] { display: none; }
/* upazila popup in the customer form */
.upz-pop { grid-column: 1 / -1; border: 1px solid color-mix(in srgb, var(--accent) 35%, #fff); border-radius: 12px; background: #fff; box-shadow: var(--shadow-lg); padding: 12px; }
.upz-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.upz-head .upz-q { width: 200px; }
.upz-all { padding: 8px 10px; background: var(--accent-soft); border-radius: 8px; font-weight: 650; margin-bottom: 8px; }
.upz-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 12px; max-height: 230px; overflow: auto; padding: 4px; }
.upz-list label { padding: 4px 6px; border-radius: 6px; }
.upz-list label:hover { background: #f4f6f9; }
.upz-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
textarea { min-height: 72px; resize: vertical; }
label.f { display: block; }
label.f > span { display: block; font-size: 12px; color: #475467; margin-bottom: 5px; font-weight: 600; }
label.f > small { color: var(--muted); font-size: 11px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); }
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.filters label.f { width: auto; }
.filters input { width: 165px; }
.search { max-width: 340px; padding-left: 34px !important; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") 11px center/16px no-repeat; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; border-radius: 10px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11.5px; color: #475467; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; background: color-mix(in srgb, var(--accent) 7%, #f8fafc); white-space: nowrap; }
thead th:first-child { border-top-left-radius: 10px; } thead th:last-child { border-top-right-radius: 10px; }
tbody tr:nth-child(even) td { background: #fafbfd; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent) 5%, #fff); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 750; background: color-mix(in srgb, var(--accent) 9%, #f8fafc); border-bottom: none; }
tr.sub td { background: #fcfcfd !important; font-size: 13px; color: #3b4652; }
.empty { color: var(--muted); padding: 28px; text-align: center; background: #fafbfd; border: 1px dashed var(--line); border-radius: 12px; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; background: var(--brand-soft); color: var(--brand-dark); letter-spacing: .2px; }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.amber { background: var(--warn-soft); color: var(--warn); }
.badge.grey { background: #eef1f5; color: var(--muted); }
.red { color: var(--danger); }
.muted { color: var(--muted); }
.right { text-align: right; }

/* ---------- bar chart ---------- */
.bars { display: flex; align-items: flex-end; gap: 12px; height: 160px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 5px; }
.bar .col { width: 100%; max-width: 46px; background: linear-gradient(180deg, #34d399, #2563eb); border-radius: 8px 8px 3px 3px; min-height: 3px; box-shadow: 0 4px 10px rgba(37, 99, 235, .18); }
.bar .v { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar .d { font-size: 11px; color: var(--muted); font-weight: 600; }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.picker { position: relative; }
.picker input { font-size: 15px; padding: 11px 14px; }
.results { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); max-height: 360px; overflow: auto; margin-top: 6px; }
.results div { padding: 10px 14px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid #f0f3f7; }
.results div:hover, .results div.hi { background: var(--accent-soft); }
.cart input { padding: 6px 8px; }
.cart input.qty { width: 74px; }
.cart input.price { width: 94px; }
.cart input.disc { width: 64px; }
.cart select { width: 210px; padding: 6px 8px; }
.totals .row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 22px; font-weight: 800; border-top: 2px dashed var(--line); margin-top: 8px; padding-top: 12px; color: var(--accent); }
.totals input { text-align: right; width: 135px; }
.stack > * + * { margin-top: 12px; }
.info { background: var(--info-soft); color: #1d3f7a; border-radius: 10px; padding: 9px 12px; font-size: 13px; border: 1px solid #d3e3ff; }
.info.warn { background: var(--warn-soft); color: var(--warn); border-color: #fde3b5; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; background: #fff; padding: 5px; border-radius: 12px; border: 1px solid var(--line); width: fit-content; max-width: 100%; box-shadow: var(--shadow); }
.tabs a { padding: 8px 15px; color: var(--muted); border-radius: 9px; font-weight: 600; }
.tabs a.on { color: #fff; background: var(--accent); box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 30%, transparent); }
.tabs a.on .badge { background: rgba(255,255,255,.25); color: #fff; }
.tabs a:hover { text-decoration: none; color: var(--text); background: #f3f5f9; }
.tabs a.on:hover { color: #fff; background: var(--accent); }

/* ---------- modal & toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 22, 40, .5); backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow: auto; }
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 640px; box-shadow: 0 24px 70px rgba(0,0,0,.3); overflow: hidden; animation: pop .16s ease-out; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal header { padding: 16px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; background: linear-gradient(90deg, var(--accent-soft), #fff); }
.modal header h2 { margin: 0; }
.modal .body { padding: 20px 22px; }
.modal footer { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: #fafbfd; }
.err { background: var(--danger-soft); color: var(--danger); padding: 10px 13px; border-radius: 10px; margin-bottom: 12px; border: 1px solid #f9cfca; }
#toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #182230; color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow-lg); max-width: 400px; border-left: 4px solid #3ddc97; animation: pop .16s ease-out; }
.toast.bad { background: #7a1610; border-left-color: #ff8a80; }

/* ---------- login / setup ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(800px 500px at 15% 20%, #1fa97a 0%, transparent 60%), radial-gradient(700px 500px at 90% 90%, #2563eb 0%, transparent 60%), linear-gradient(135deg, #073d2e, #0b5a42 50%, #0e3a6b); }
.auth .box { background: rgba(255,255,255,.97); border-radius: 20px; padding: 32px; width: 100%; max-width: 410px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.auth h1 { color: var(--brand-dark); margin-bottom: 4px; font-size: 26px; font-weight: 800; }
.auth h1::before { content: ""; display: inline-block; width: 34px; height: 34px; margin-right: 10px; vertical-align: -8px; border-radius: 10px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 18c0-7 5-11 12-11-1 7-5 11-12 11z' fill='%23fff'/%3E%3C/svg%3E") center/22px no-repeat, linear-gradient(135deg, #3ddc97, #12805c); }
.auth p { color: var(--muted); margin: 0 0 20px; }
.auth .stack > button { width: 100%; justify-content: center; padding: 11px; font-size: 15px; }

/* ---------- printable documents ---------- */
.invoice { background: #fff; max-width: 840px; margin: 0 auto; padding: 34px 38px; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); border-top: 6px solid var(--accent); }
.invoice table th { background: #f4f7fa; }
.inv-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid var(--brand); padding-bottom: 14px; margin-bottom: 16px; }
.inv-head h1 { color: var(--brand-dark); font-size: 22px; }
.inv-title { font-size: 19px; font-weight: 800; letter-spacing: 1.5px; color: var(--brand-dark); text-align: right; }
.inv-meta { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.inv-sum { margin-left: auto; width: 310px; margin-top: 12px; }
.inv-sum .row { display: flex; justify-content: space-between; padding: 4px 0; font-variant-numeric: tabular-nums; }
.inv-sum .grand { font-weight: 800; font-size: 16px; border-top: 1px solid var(--text); padding-top: 6px; }
.inv-words { margin-top: 12px; font-style: italic; }
.inv-sign { display: flex; justify-content: space-between; gap: 16px; margin-top: 60px; }
.inv-sign div { border-top: 1px solid var(--text); padding-top: 4px; width: 180px; text-align: center; font-size: 12px; }
.void-stamp { color: var(--danger); border: 3px solid var(--danger); display: inline-block; padding: 4px 14px; font-weight: 800; font-size: 20px; transform: rotate(-6deg); margin-bottom: 10px; }

/* ---------- invoice (new layout) ---------- */
.inv2 { border-top: 6px solid var(--brand); }
.inv2-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; padding-bottom: 14px; border-bottom: 2px solid var(--brand); }
.inv2-co { display: flex; gap: 14px; align-items: flex-start; min-width: 0; }
.inv2-logo { flex: none; width: auto; max-height: 64px; max-width: 130px; }
div.inv2-logo { width: 54px; height: 54px; }
.inv2-name { font-size: 22px; font-weight: 800; color: var(--brand-dark); line-height: 1.2; }
.inv2-addr { font-size: 13px; margin-top: 2px; }
.inv2-contact { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 12px; margin-top: 3px; }
.inv2-contact b { color: var(--brand-dark); font-weight: 650; }
.inv2-lic { font-size: 12px; margin-top: 2px; color: var(--muted); }
.inv2-doc { flex: none; display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.inv2-title { color: var(--brand-dark); font-weight: 800; font-size: 30px; line-height: 1; letter-spacing: 6px; margin-right: -6px; }
.inv2-title::after { content: ''; display: block; width: 46px; height: 4px; border-radius: 2px; background: var(--brand); margin: 7px 6px 0 auto; }
.inv2-copy { margin-top: 7px; border: 1.5px solid var(--brand-dark); color: var(--brand-dark); border-radius: 999px; padding: 2px 10px; font-size: 10px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; }
.inv2-kv { width: auto; margin: 10px 0 0 auto; font-size: 12.5px; background: #f4f8f6 !important; border-left: 3px solid var(--brand); border-radius: 6px; }
.inv2-kv td { padding: 3px 10px 3px 14px; border: none; background: none !important; text-align: right; }
.inv2-kv tr:first-child td { padding-top: 6px; } .inv2-kv tr:last-child td { padding-bottom: 6px; }
.inv2-kv td:first-child { text-align: left; }
.inv2-kv td:first-child { color: var(--muted); }
.inv2-kv .ok { color: #067647; } .inv2-kv .warn { color: #b54708; }
.inv2-parties { display: grid; grid-template-columns: 1.3fr 1fr; gap: 12px; margin: 14px 0; }
.inv2-box { border: 1px solid #d5dce6; border-radius: 10px; padding: 0 12px 10px; font-size: 13px; overflow: hidden; }
.inv2-box-h { margin: 0 -12px 8px; padding: 6px 12px; background: #f1f5f3; border-bottom: 1px solid #d5dce6; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--brand-dark); }
.inv2-cust { font-size: 15px; font-weight: 750; }
.inv2-box dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; }
.inv2-box dt { color: var(--muted); } .inv2-box dd { margin: 0; text-align: right; }
.inv2-parties .inv2-box.right { text-align: left; }
.inv2-parties .inv2-box dt { text-align: left; }
.inv2-table { border: 1px solid #d5dce6; border-radius: 10px; overflow: hidden; }
.inv2-table th { background: #f1f5f3 !important; color: var(--brand-dark); }
.inv2-table tbody tr:nth-child(even) td { background: #fafbfc; }
.inv2-bottom { display: grid; grid-template-columns: 1fr 300px; gap: 16px; margin-top: 12px; align-items: start; }
.inv2-left .inv-words { margin-top: 4px; font-style: normal; font-size: 13px; padding: 8px 12px; background: #f6faf8; border-radius: 8px; border: 1px solid #e0ece5; }
.inv2-note { margin-top: 8px; font-size: 13px; }
.inv2-sum { width: auto; margin: 0; border: 1px solid #d5dce6; border-radius: 10px; padding: 6px 12px; }
.inv2-sum .grand { color: var(--brand-dark); }
.inv2-sign { display: flex; justify-content: space-between; gap: 40px; margin-top: 40px; }
.inv2-signer { width: 220px; text-align: center; font-size: 12.5px; }
.inv2-sigimg { height: 56px; display: flex; align-items: flex-end; justify-content: center; }
.inv2-sigline { border-top: 1.5px solid var(--text); margin: 2px 0 4px; }
.inv2-foot { text-align: center; margin-top: 18px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
@media (max-width: 700px) { .inv2-head, .inv2-bottom, .inv2-parties { display: block; } .inv2-doc { text-align: left; align-items: flex-start; margin-top: 10px; } .inv2-kv { margin-left: 0; } .inv2-box { margin-bottom: 10px; } }
@media print {
  .inv2-title, .inv2-kv, .inv2-box-h, .inv2-table th, .inv2-logo, .inv2-left .inv-words { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .inv2-head, .inv2-parties, .inv2-bottom { display: flex !important; }
  .inv2-parties > *, .inv2-bottom > .inv2-left { flex: 1; } .inv2-bottom > .inv2-sum { width: 42%; flex: none; }
  .invoice.inv2.compact .inv2-bottom > .inv2-sum { width: 54%; }
}
.inv2-sum .row { gap: 10px; }
/* three printed copies: each starts on a new page */
@media print { .copy-page + .copy-page { break-before: page; } .copy-page .copy-label { font-size: 9px; font-weight: 800; color: #333; height: auto; margin-bottom: 3px; } }
/* POS courier box */
.courier-box { border: 1px solid #fde3b5; background: #fff8ec; border-radius: 10px; padding: 10px; display: grid; gap: 8px; }
.courier-box[hidden] { display: none; }
.courier-h { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: #b54708; }

/* big payment stamp: PAID / DUE / CASH ON DELIVERY */
.pay-stamp { display: inline-block; border: 3px solid currentColor; border-radius: 10px; padding: 6px 16px 7px; margin-bottom: 10px; transform: rotate(-3deg); text-align: center; }
.pay-stamp .ps-big { font-size: 26px; font-weight: 900; letter-spacing: 1.5px; line-height: 1.1; }
.pay-stamp .ps-sub { font-size: 12px; font-weight: 700; margin-top: 2px; }
.pay-stamp.paid { color: #067647; background: #e9f8ef; }
.pay-stamp.due { color: #c01b12; background: #fdeeed; }
.pay-stamp.cod { color: #b54708; background: #fff3df; }
/* bigger e-signatures on the invoice */
.inv2-sigimg { height: 86px; }
.inv2-sigimg .sig-img { max-height: 82px; max-width: 240px; }
.inv2-signer { width: 240px; }

/* invoice in A5 (two copies on A4 landscape) */
.invoice.inv2.compact .inv2-name { font-size: 14px; }
.invoice.inv2.compact .inv2-addr, .invoice.inv2.compact .inv2-contact, .invoice.inv2.compact .inv2-lic { font-size: 8.5px; }
.invoice.inv2.compact .inv2-logo { max-height: 36px; max-width: 70px; }
.invoice.inv2.compact div.inv2-logo { width: 34px; height: 34px; background-size: 20px, auto; }
.invoice.inv2.compact .inv2-head { padding-bottom: 6px; gap: 8px; }
.invoice.inv2.compact .inv2-title { font-size: 19px; letter-spacing: 4px; margin-right: -4px; }
.invoice.inv2.compact .inv2-title::after { width: 30px; height: 2.5px; margin-top: 4px; margin-right: 4px; }
.invoice.inv2.compact .inv2-copy { margin-top: 4px; font-size: 7px; padding: 1px 7px; border-width: 1px; letter-spacing: 1px; }
.invoice.inv2.compact .inv2-kv { font-size: 8.5px; margin-top: 5px; border-left-width: 2px; border-radius: 4px; }
.invoice.inv2.compact .inv2-kv td { padding: 1px 6px 1px 8px; }
.invoice.inv2.compact .inv2-kv tr:first-child td { padding-top: 3px; } .invoice.inv2.compact .inv2-kv tr:last-child td { padding-bottom: 3px; }
.invoice.inv2.compact .inv2-parties { margin: 6px 0; gap: 6px; }
.invoice.inv2.compact .inv2-box { font-size: 9px; padding: 0 8px 5px; border-radius: 6px; }
.invoice.inv2.compact .inv2-box-h { margin: 0 -8px 4px; padding: 3px 8px; font-size: 7.5px; }
.invoice.inv2.compact .inv2-cust { font-size: 10.5px; }
.invoice.inv2.compact .inv2-table { border-radius: 6px; }
.invoice.inv2.compact .inv2-table th, .invoice.inv2.compact .inv2-table td { padding: 3px 4px; }
.inv2-table .nowrap { white-space: nowrap; }
.invoice.inv2.compact .inv2-bottom { grid-template-columns: 1fr 52%; gap: 8px; margin-top: 6px; }
.invoice.inv2.compact .inv2-left .inv-words { font-size: 8.5px; padding: 4px 6px; }
.invoice.inv2.compact .inv2-sum { padding: 3px 8px; border-radius: 6px; width: auto; font-size: 9.5px; }
.invoice.inv2.compact .inv2-sum .grand { font-size: 11.5px; }
.invoice.inv2.compact .inv2-sign { margin-top: 14px; gap: 16px; }
.invoice.inv2.compact .inv2-signer { width: 44%; font-size: 9px; }
.invoice.inv2.compact .inv2-sigimg { height: 58px; }
.invoice.inv2.compact .inv2-sigimg .sig-img { max-height: 56px; max-width: 170px; }
.invoice.inv2.compact .pay-stamp { padding: 3px 10px 4px; border-width: 2.5px; border-radius: 7px; margin-bottom: 6px; }
.invoice.inv2.compact .pay-stamp .ps-big { font-size: 17px; letter-spacing: 1px; }
.invoice.inv2.compact .pay-stamp .ps-sub { font-size: 8.5px; }
.invoice.inv2.compact .inv2-foot { margin-top: 8px; padding-top: 4px; font-size: 8px; }

/* ---------- invoice print: A5 halves on A4 landscape, or A4 portrait ---------- */
#print-host { display: none; }
.a5-probe { position: absolute !important; left: -10000px; top: 0; width: 131mm; }
.a5-probe .no-print { display: none !important; }
.invoice.compact { max-width: none; padding: 0; border: none; box-shadow: none; border-radius: 0; font-size: 10.5px; }
.invoice.compact .inv-head { padding-bottom: 6px; margin-bottom: 8px; gap: 10px; }
.invoice.compact .inv-head h1 { font-size: 15px; }
.invoice.compact .inv-title { font-size: 13px; letter-spacing: 1px; }
.invoice.compact .co-logo { max-height: 38px; max-width: 80px; }
.invoice.compact .co-extra { font-size: 9px; }
.invoice.compact .inv-meta { margin-bottom: 8px; gap: 10px; }
.invoice.compact th, .invoice.compact td { padding: 4px 5px; font-size: 10px; }
.invoice.compact th { font-size: 8.5px; letter-spacing: .2px; }
.invoice.compact .inv-sum { width: 62%; margin-top: 6px; }
.invoice.compact .inv-sum .row { padding: 2px 0; }
.invoice.compact .inv-sum .grand { font-size: 12px; }
.invoice.compact .inv-words { margin-top: 6px; font-size: 10px; }
.invoice.compact .inv-sign { margin-top: 30px; }
.invoice.compact .inv-sign div { width: 42%; font-size: 9.5px; }
.invoice.compact .void-stamp { font-size: 14px; padding: 2px 8px; }
.invoice.compact .muted[style*="margin-top:24px"] { margin-top: 10px !important; font-size: 9.5px !important; }
.copy-label { text-align: right; font-size: 8.5px; text-transform: uppercase; letter-spacing: .8px; color: #555; height: 5mm; }
@media print {
  body.print-host-on > *:not(#print-host) { display: none !important; }
  body.print-host-on #print-host { display: block !important; }
  .a5-pair { display: flex; width: 100%; align-items: stretch; }
  .a5-sheet { width: 50%; padding: 0 5mm; box-sizing: border-box; break-inside: avoid; overflow: hidden; }
  .a5-sheet + .a5-sheet { border-left: 1px dashed #999; }
  #print-host .invoice { border-top: none !important; }
  /* A4 portrait invoice: tighter rows so more lines fit on a page; table header repeats on each page */
  #print-host .invoice:not(.compact) .inv2-table th, #print-host .invoice:not(.compact) .inv2-table td { padding: 6px 8px; }
  .pay-stamp { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #print-host .invoice thead { display: table-header-group; }
  #print-host .invoice tr { break-inside: avoid; }
  #print-host .invoice .inv-sum, #print-host .invoice .inv-sign { break-inside: avoid; }
}

/* ---------- stock receive slip ---------- */
.slip { max-width: 880px; border-top: 6px solid var(--brand); padding: 30px 34px; }
.slip-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 18px; border-bottom: 2px solid var(--brand); }
.slip-co { display: flex; gap: 12px; align-items: center; }
.slip-logo { width: 46px; height: 46px; border-radius: 12px; flex: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 18c0-7 5-11 12-11-1 7-5 11-12 11z' fill='%23fff'/%3E%3C/svg%3E") center/28px no-repeat, linear-gradient(135deg, #3ddc97, #12805c); }
.slip-co-name { font-size: 21px; font-weight: 800; color: var(--brand-dark); }
.slip-co-sub { color: var(--muted); font-size: 13px; }
.slip-doc { text-align: right; }
.slip-title { display: inline-block; background: var(--brand-dark); color: #fff; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; font-size: 14px; padding: 6px 14px; border-radius: 6px; }
.slip-no { font-size: 18px; font-weight: 800; margin: 8px 0 6px; font-variant-numeric: tabular-nums; }
.slip-status { display: inline-block; padding: 3px 12px; border-radius: 99px; font-size: 12px; font-weight: 800; border: 1.5px solid currentColor; }
.slip-status.s-received { color: #067647; background: #e6f7ec; }
.slip-status.s-processing, .slip-status.s-under_review { color: #b54708; background: #fff6e6; }
.slip-status.s-rejected { color: #d92d20; background: #fef0ef; }
.slip-boxes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
.slip-box { border: 1px solid #d5dce6; border-radius: 10px; overflow: hidden; }
.slip-box-h { background: #f1f5f3; border-bottom: 1px solid #d5dce6; padding: 7px 12px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--brand-dark); }
.slip-box dl { margin: 0; padding: 8px 12px 10px; display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; font-size: 13px; }
.slip-box dt { color: var(--muted); }
.slip-box dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.slip-box dd.big { font-size: 16px; font-weight: 800; }
.slip-table { border: 1px solid #d5dce6; border-radius: 10px; overflow: hidden; }
.slip-table th { background: #f1f5f3 !important; color: var(--brand-dark); }
.slip-table td, .slip-table th { border-bottom: 1px solid #e4e9f0; }
.slip-table tbody tr:nth-child(even) td { background: #fff; }
.slip-table tfoot td { background: #f1f5f3; font-size: 14px; }
.slip-note { margin-top: 14px; padding: 10px 14px; border: 1px dashed #c3ccd7; border-radius: 10px; font-size: 13px; }
.slip-sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; margin-top: 54px; text-align: center; font-size: 13px; }
.slip-sign-line { border-top: 1.5px solid var(--text); margin-bottom: 6px; }
/* company logo, website, licence on documents */
.inv-head > div.with-logo { display: grid; grid-template-columns: auto 1fr; column-gap: 14px; align-items: start; }
.inv-head > div.with-logo > :not(.co-logo) { grid-column: 2; }
.inv-head > div.with-logo > .co-logo { grid-column: 1; grid-row: 1 / span 6; }
.co-logo { max-height: 64px; max-width: 130px; object-fit: contain; }
.slip-co-logo { max-height: 56px; max-width: 120px; }
.co-extra { font-size: 12px; color: var(--muted); }
.brand.has-logo::before, .home-brand.has-logo::before { background: #fff var(--logo) center / 85% no-repeat; }
/* settings save bar */
.save-bar { position: sticky; bottom: 0; display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin: 14px -18px -18px; padding: 12px 18px; background: rgba(255,255,255,.95); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); backdrop-filter: blur(4px); }
.save-state { font-size: 13px; color: var(--muted); }
.save-state.dirty { color: #b54708; font-weight: 700; }
.save-state.dirty::before { content: "● "; }
form.is-dirty .save-bar { background: #fff6e6; }
/* logo upload box in settings */
.logo-box { display: flex; gap: 14px; align-items: center; padding: 12px; border: 1px dashed #c3ccd7; border-radius: 12px; margin-bottom: 14px; }
.logo-prev { width: 130px; height: 70px; flex: none; display: grid; place-items: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.logo-prev img { max-width: 120px; max-height: 60px; object-fit: contain; }
@media print { .co-logo { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }
/* e-signatures */
.slip-sig { height: 56px; display: flex; align-items: flex-end; justify-content: center; }
.sig-img { max-height: 54px; max-width: 180px; object-fit: contain; display: block; }
.inv-sign > div { position: relative; }
.inv-sign .sig-img { position: absolute; bottom: calc(100% + 2px); left: 50%; transform: translateX(-50%); }
.sig-pad { width: 100%; max-width: 600px; aspect-ratio: 3 / 1; height: auto; border: 2px dashed #b9c6d3; border-radius: 12px; background: #fff; touch-action: none; cursor: crosshair; display: block; }
.sig-paper { min-height: 90px; border: 1px solid var(--line); border-radius: 10px; background: #fff; display: flex; align-items: center; justify-content: center; padding: 10px; margin-top: 4px; }
.sig-paper img { max-height: 80px; max-width: 100%; }
@media print { .sig-img { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }
.slip-foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 26px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
@media (max-width: 700px) { .slip-boxes { grid-template-columns: 1fr; } .slip-head { flex-direction: column; } .slip-doc { text-align: left; } .slip { padding: 18px; } }
@media print {
  .slip { border-top: 4px solid #000 !important; max-width: none; }
  .slip-title { background: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .slip-box-h, .slip-table th, .slip-table tfoot td, .slip-logo, .slip-status { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .slip-boxes { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}

/* ---------- department home ---------- */
.shell.home-mode .side { display: none; }
.shell.home-mode .main { padding: 26px 40px 56px; }
.home-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 30px; }
.home-top .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.home-brand { font-size: 22px; font-weight: 800; color: var(--brand-dark); display: flex; align-items: center; gap: 10px; }
.home-brand::before { content: ""; width: 32px; height: 32px; border-radius: 10px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 18c0-7 5-11 12-11-1 7-5 11-12 11z' fill='%23fff'/%3E%3C/svg%3E") center/20px no-repeat, linear-gradient(135deg, #3ddc97, #12805c); }
.hello { text-align: center; color: var(--muted); font-weight: 600; letter-spacing: .3px; margin-bottom: 6px; }
.welcome { text-align: center; font-size: 32px; font-weight: 800; margin: 0 auto 10px; max-width: 1180px; text-wrap: balance; letter-spacing: -.5px;
  background: linear-gradient(90deg, #0b5a42, #12805c 35%, #2563eb 75%, #9333ea); -webkit-background-clip: text; background-clip: text; color: transparent; }
.welcome-sub { text-align: center; color: var(--muted); margin: 0 0 38px; }
.depts { display: flex; flex-wrap: wrap; justify-content: center; gap: 26px; max-width: 1220px; margin: 0 auto; }
.dept { --c: #12805c; flex: 0 1 270px; min-height: 196px; border-radius: 22px; background: #fff; border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 22px 22px 18px; position: relative; overflow: hidden;
  color: var(--text); text-decoration: none; box-shadow: var(--shadow); transition: box-shadow .2s, transform .2s, border-color .2s; }
.dept::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 6px; background: linear-gradient(90deg, var(--c), color-mix(in srgb, var(--c) 45%, #fff)); }
.dept::after { content: ""; position: absolute; right: -40px; bottom: -40px; width: 140px; height: 140px; border-radius: 50%; background: var(--c); opacity: .07; transition: transform .3s, opacity .3s; }
a.dept:hover { transform: translateY(-4px); box-shadow: 0 18px 40px color-mix(in srgb, var(--c) 22%, transparent); border-color: color-mix(in srgb, var(--c) 40%, #fff); text-decoration: none; }
a.dept:hover::after { transform: scale(1.35); opacity: .12; }
a.dept:focus-visible { outline: 3px solid color-mix(in srgb, var(--c) 45%, #fff); outline-offset: 3px; }
.dept-icon { width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 70%, #fff), var(--c)); box-shadow: 0 8px 18px color-mix(in srgb, var(--c) 35%, transparent); }
.dept-icon svg { width: 26px; height: 26px; }
.dept-name { font-size: 18px; font-weight: 750; }
.dept-stat { font-size: 12.5px; color: var(--muted); }
.dept-go { font-size: 13px; font-weight: 700; color: var(--c); display: flex; align-items: center; gap: 6px; }
a.dept:hover .dept-go { gap: 10px; }
.dept.off { opacity: .45; cursor: not-allowed; filter: grayscale(.9); }
.dept.off .dept-go { color: var(--muted); }

@media (max-width: 900px) {
  .pos, .g2 { grid-template-columns: 1fr; }
  .side { position: fixed; left: -250px; z-index: 40; transition: left .2s; }
  .side.open { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .menu-btn { display: inline-flex; }
  .main { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .invoice { padding: 18px; }
  .shell.home-mode .main { padding: 18px 16px 32px; }
  .welcome { font-size: 23px; }
  .welcome-sub { margin-bottom: 22px; }
  .depts { gap: 14px; }
  .dept { flex-basis: 100%; min-height: 0; flex-direction: row; align-items: center; justify-content: flex-start; padding: 18px; }
  .dept .dept-go { display: none; }
  .tabs { width: 100%; }
}

@media print {
  body { background: #fff; }
  .side, .no-print, .topbar, #toast-root, .menu-btn, .tabs { display: none !important; }
  .main { padding: 0; }
  .card, .invoice { border: none; box-shadow: none; padding: 0; border-top: none; }
  th { background: #f1f1f1 !important; color: #000; }
  tbody tr:nth-child(even) td { background: #fff; }
  .print-title { display: block !important; }
  @page { margin: 12mm; }
}
.print-title { display: none; margin-bottom: 10px; }

/* invoice approval */
.approve-alert { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; max-width: 980px; margin: 0 auto 18px; padding: 12px 16px; border-radius: 12px;
  background: #fff7e6; border: 1px solid #f5c26b; color: #8a4b00; text-decoration: none; }
.approve-alert span { font-weight: 700; }
.approval-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; font-size: 14px; }
.approval-bar span { color: inherit; opacity: .9; }
.approval-bar.pending { background: #fff7e6; border: 1px solid #f5c26b; color: #8a4b00; }
.approval-bar.rejected { background: var(--danger-soft); border: 1px solid #f3b7b1; color: var(--danger); }
.approval-bar.ok { background: #ecf8f2; border: 1px solid #b7e2cb; color: #0b4d36; }
.mail-test { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 4px 0 10px; font-size: 13px; }
.mail-test input { flex: 1; min-width: 180px; }
.actions [hidden] { display: none !important; }
/* invoice waiting for approval: only the way back stays in the toolbar */
.topbar.inv-pending .actions > *:not([href="#/sales"]):not([href="#/pos"]), .topbar.inv-pending h1 .badge { display: none !important; }
