:root {
  --bg: #f3f5f9; --panel: #ffffff; --ink: #1c2433; --muted: #6b7486; --line: #e3e7ef;
  --brand: #0f6e5a; --brand-2: #0b5546; --brand-soft: #e3f3ef;
  --red: #c0392b; --red-soft: #fdecea; --amber: #b7791f; --amber-soft: #fdf4e3;
  --blue: #2563a8; --blue-soft: #e8f0fb; --green: #1e8449; --green-soft: #e6f5ec;
  --radius: 10px; --shadow: 0 1px 2px rgba(20,30,50,.06), 0 2px 8px rgba(20,30,50,.05);
  --urdu: 'Noto Nastaliq Urdu', 'Jameel Noori Nastaleeq', 'Urdu Typesetting', serif;
  --text: 'Noto Naskh Arabic', 'Segoe UI', Tahoma, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--text); font-size: 15px; line-height: 1.6; }
h1, h2, h3, h4, .nav a, .stat .label, label, th, .btn, .tabs button, .badge { font-family: var(--urdu); }
h1 { font-size: 22px; margin: 0; line-height: 2; }
h2 { font-size: 18px; margin: 0 0 8px; line-height: 2; }
h3 { font-size: 16px; margin: 0 0 6px; line-height: 2; }
a { color: var(--blue); text-decoration: none; }
.ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }
.num { direction: ltr; unicode-bidi: embed; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.red { color: var(--red); } .green { color: var(--green); } .amber { color: var(--amber); }
.hidden { display: none !important; }

/* layout */
.layout { display: flex; min-height: 100vh; }
/* appearance from the Developer Console */
.sidebar .nav a { color: var(--side-text, #d3e6e0); }
.sidebar .logo small { color: var(--side-text, #9fc1b7); }
input:focus, select:focus, textarea:focus { border-color: var(--outline, var(--brand)); }
html[data-menu="left"] .layout { flex-direction: row; } html[data-menu="left"][dir="rtl"] .layout { flex-direction: row-reverse; }
html[data-menu="right"] .layout { flex-direction: row-reverse; } html[data-menu="right"][dir="rtl"] .layout { flex-direction: row; }
@media (min-width: 901px) {
  html[data-menu="top"] .layout { flex-direction: column; }
  html[data-menu="top"] .sidebar { width: 100%; height: auto; position: static; display: flex; align-items: center; overflow: visible; }
  html[data-menu="top"] .sidebar .logo { border-bottom: 0; padding: 6px 14px; display: flex; align-items: center; gap: 10px; }
  html[data-menu="top"] .sidebar .side-logo { width: 54px; margin: 0; padding: 3px; } html[data-menu="top"] .sidebar .logo small { display: none; }
  html[data-menu="top"] .nav { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px; } html[data-menu="top"] .nav a { padding: 2px 10px; font-size: 13.5px; }
}
/* ---------- menu grouped by category ---------- */
.nav-sec { margin-bottom: 2px; }
.nav-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 12px; background: none; border: 0; border-radius: 8px; cursor: pointer;
  color: var(--side-text, #d3e6e0); font-family: var(--urdu); font-size: 14.5px; line-height: 2.1; text-align: start; opacity: .95; }
.nav-head:hover { background: rgba(255,255,255,.07); }
.nav-head .ic { width: 20px; text-align: center; font-family: var(--text); }
.nav-head .nav-label { flex: 1; }
.nav-head .caret { font-size: 11px; transition: transform .15s; opacity: .8; }
.nav-sec.open > .nav-head .caret { transform: rotate(180deg); }
.nav-sec.has-active > .nav-head { color: #fff; font-weight: 600; }
.nav-sec > .nav-items { display: none; padding-inline-start: 14px; border-inline-start: 1px solid rgba(255,255,255,.12); margin-inline-start: 20px; }
.nav-sec.open > .nav-items { display: block; }
.nav-sec > .nav-items a { font-size: 13.5px; line-height: 1.9; }
@media (min-width: 901px) {
  html[data-menu="top"] .nav { flex-wrap: nowrap; align-items: center; gap: 4px; }
  html[data-menu="top"] .nav-sec { position: relative; margin: 0; }
  html[data-menu="top"] .nav-sec.single > a, html[data-menu="top"] .nav-head { width: auto; padding: 4px 12px; white-space: nowrap; }
  html[data-menu="top"] .nav-sec.has-active > .nav-head { background: var(--brand); color: #fff; }
  html[data-menu="top"] .nav-sec > .nav-items { position: absolute; top: 100%; inset-inline-start: 0; z-index: 70; min-width: 230px; margin: 4px 0 0; padding: 6px;
    background: var(--side, #12302a); border: 1px solid rgba(255,255,255,.15); border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.35); }
  html[data-menu="top"] .nav-sec > .nav-items a { white-space: nowrap; padding: 4px 12px; }
  html[data-menu="top"] .sidebar { position: relative; z-index: 60; }
}
.lic-banner a { color: inherit; text-decoration: underline; }
.lic-banner { padding: 8px 20px; font-family: var(--urdu); line-height: 2; font-weight: 600; }
.lic-banner.red { background: var(--red-soft); color: var(--red); border-bottom: 1px solid #efc4be; }
.lic-banner.amber { background: var(--amber-soft); color: var(--amber); border-bottom: 1px solid #f0d9a8; }
.sidebar { width: 230px; background: var(--side, #12302a); color: #dfeee9; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .logo { padding: 18px 16px 10px; border-bottom: 1px solid rgba(255,255,255,.08); }
.side-logo { background: #fff; border-radius: 10px; padding: 6px; margin-bottom: 8px; text-align: center; }
.side-logo img { width: 100%; max-height: 110px; object-fit: contain; display: block; }
.login-logo { display: block; margin: 0 auto 4px; max-width: 220px; max-height: 140px; object-fit: contain; }
.sidebar .logo b { display: block; font-family: var(--urdu); font-size: 17px; line-height: 2; color: #fff; }
.sidebar .logo small { color: #9fc1b7; font-size: 12px; }
.nav { padding: 8px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 6px 12px; color: #d3e6e0; border-radius: 8px; font-size: 14.5px; line-height: 2.1; }
.nav a:hover { background: rgba(255,255,255,.07); }
.nav a.active { background: var(--brand); color: #fff; }
.nav a .ic { width: 20px; text-align: center; font-family: var(--text); }
.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); padding: 8px 20px; display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 20; }
.topbar .grow { flex: 1; }
.topbar .who { font-size: 13px; color: var(--muted); }
.menu-btn { display: none; }
main { padding: 20px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .grow { flex: 1; }

/* panels */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-head h3 { margin: 0; flex: 1; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); border-top: 3px solid var(--brand); }
.stat .label { color: var(--muted); font-size: 13px; line-height: 2; }
.stat .value { font-size: 22px; font-weight: 700; direction: ltr; text-align: right; }
.stat .sub { font-size: 12px; color: var(--muted); }
.stat.red { border-top-color: var(--red); } .stat.red .value { color: var(--red); }
.stat.amber { border-top-color: var(--amber); }
.stat.blue { border-top-color: var(--blue); }
.stat.green { border-top-color: var(--green); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; }
.kv dt { color: var(--muted); font-family: var(--urdu); line-height: 2; }
.kv dd { margin: 0; font-weight: 600; align-self: center; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: middle; }
th { background: #f7f9fc; color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; line-height: 2; }
tbody tr:hover { background: #fafcff; }
tfoot td { font-weight: 700; background: #f7f9fc; }
td.actions { white-space: nowrap; text-align: left; }
tr.clickable { cursor: pointer; }
.empty { text-align: center; color: var(--muted); padding: 30px; font-family: var(--urdu); }

/* forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 2px; }
label { font-size: 13px; color: #48526a; line-height: 2; }
input, select, textarea { font: inherit; font-size: 14.5px; padding: 7px 10px; border: 1px solid #cfd6e2; border-radius: 8px; background: #fff; color: var(--ink); width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15,110,90,.25); border-color: var(--brand); }
input[type=number], input[type=date], input.ltr-in { direction: ltr; text-align: right; }
textarea { min-height: 70px; resize: vertical; }
input[readonly] { background: #f4f6fa; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline > .field { min-width: 150px; }
.check { display: flex; align-items: center; gap: 6px; }
.check input { width: auto; }
fieldset { border: 1px dashed #cfd6e2; border-radius: var(--radius); padding: 10px 14px; margin: 12px 0 0; }
legend { font-family: var(--urdu); padding: 0 6px; color: var(--brand); line-height: 2; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 4px 14px; border-radius: 8px; border: 1px solid #cfd6e2; background: #fff; color: var(--ink); cursor: pointer; font-size: 14px; line-height: 2.1; white-space: nowrap; }
.btn:hover { background: #f4f6fa; }
.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: #efc4be; }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { padding: 0 9px; font-size: 13px; line-height: 1.9; }
.btn.lg { padding: 6px 22px; font-size: 16px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.seg { display: inline-flex; border: 1px solid #cfd6e2; border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 4px 18px; cursor: pointer; font-family: var(--urdu); font-size: 15px; line-height: 2; }
.seg button.on { background: var(--brand); color: #fff; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { border: 0; background: none; padding: 6px 14px; cursor: pointer; font-size: 14.5px; color: var(--muted); border-bottom: 3px solid transparent; line-height: 2; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* badges */
.badge { display: inline-block; padding: 0 9px; border-radius: 20px; font-size: 12px; line-height: 2; background: #eef1f6; color: #4b5568; white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,22,35,.45); display: flex; align-items: flex-start; justify-content: center; z-index: 100; padding: 40px 12px; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal.wide { max-width: 900px; }
.modal-head { display: flex; align-items: center; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { flex: 1; margin: 0; }
.modal-head .x { border: 0; background: none; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 16px 18px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-start; padding: 12px 18px; border-top: 1px solid var(--line); background: #fafbfd; border-radius: 0 0 12px 12px; }

/* picker */
.picker { position: relative; }
.picker-list { position: absolute; top: 100%; right: 0; left: 0; background: #fff; border: 1px solid #cfd6e2; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 50; max-height: 300px; overflow-y: auto; }
.picker-list div { padding: 7px 12px; cursor: pointer; border-bottom: 1px solid #f0f2f6; font-size: 14px; }
.picker-list div:hover, .picker-list div.hl { background: var(--brand-soft); }
.picker-list small { color: var(--muted); }
.chosen { background: var(--brand-soft); border: 1px solid #bfe2d8; padding: 8px 12px; border-radius: 8px; display: flex; gap: 10px; align-items: center; }
.chosen .grow { flex: 1; }

/* photos */
.avatar { border-radius: 50%; object-fit: cover; vertical-align: middle; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; border: 1px solid var(--line); }
.avatar.ph { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.name-cell { display: flex; align-items: center; gap: 8px; }
.photos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.photo-slot { border: 1px dashed #cfd6e2; border-radius: var(--radius); padding: 8px; text-align: center; display: flex; flex-direction: column; gap: 6px; }
.photo-slot .img { height: 160px; border-radius: 8px; background: #f4f6fa; display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--muted); font-family: var(--urdu); }
.photo-slot .img img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.photo-slot .cap { font-family: var(--urdu); font-size: 13px; line-height: 2; }
.cust-head-photo { width: 110px; height: 130px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); cursor: zoom-in; }
@media (max-width: 600px) { .photos { grid-template-columns: 1fr; } }

/* summary box */
.summary { background: #f7faf9; border: 1px solid #d3e8e1; border-radius: var(--radius); padding: 12px 16px; }
.summary .row { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed #dbe6e2; }
.summary .row:last-child { border-bottom: 0; }
.summary .row span:first-child { font-family: var(--urdu); line-height: 2; }
.summary .row.big { font-size: 18px; font-weight: 700; color: var(--brand); }

/* bars */
.bars { display: flex; align-items: flex-end; gap: 14px; height: 180px; padding: 10px 4px 0; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars .pair { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bars .bar { width: 40%; max-width: 28px; border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .bar.c { background: var(--brand); } .bars .bar.s { background: #9cc7bb; }
.bars small { font-size: 11px; color: var(--muted); direction: ltr; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 4px; vertical-align: middle; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #12302a, #0f6e5a); padding: 16px; }
.login { background: #fff; border-radius: 14px; padding: 28px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login h1 { text-align: center; color: var(--brand); }
.login p { text-align: center; color: var(--muted); margin-top: 0; }
.login .field { margin-bottom: 10px; }

/* toasts */
#toasts { position: fixed; bottom: 20px; left: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1c2433; color: #fff; padding: 8px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); font-size: 14px; max-width: 380px; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }

#print-area { display: none; }

/* ---------- A4 business documents (sales / purchase invoices & returns) — Pesticides ERP layout ---------- */
.doc { --doc-ink: #1f2937; --doc-muted: #6b7280; --doc-line: #d1d5db; --doc-band: #1f3b2d; --doc-soft: #f3f6f4;
  position: relative; background: #fff; color: var(--doc-ink); max-width: 210mm; margin: 0 auto 16px; padding: 14mm 12mm;
  font-family: 'Segoe UI', Tahoma, Arial, sans-serif; font-size: 12.5px; line-height: 1.45; overflow: hidden; direction: ltr; text-align: left; }
.doc table { font-size: inherit; }
.doc :where(th, td) { text-transform: none; letter-spacing: normal; background: transparent; border: 0; font-size: inherit; color: inherit;
  font-family: inherit; line-height: inherit; padding: 0; text-align: left; vertical-align: top; }
.doc .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-head { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 12px; border-bottom: 3px solid var(--doc-band); }
.doc-company { display: flex; gap: 12px; align-items: flex-start; color: var(--doc-muted); }
.doc-logo { height: 70px; max-width: 110px; object-fit: contain; }
.doc-company-name { font-size: 19px; font-weight: 700; color: var(--doc-ink); line-height: 1.2; margin-bottom: 2px; }
.doc-title-box { text-align: right; min-width: 220px; }
.doc-title { font-size: 22px; font-weight: 800; letter-spacing: .06em; color: var(--doc-band); }
.doc-subtitle { color: var(--doc-muted); margin-top: -2px; }
.doc-meta { margin: 8px 0 0 auto; border-collapse: collapse; }
.doc .doc-meta th { text-align: left; font-weight: 600; color: var(--doc-muted); padding: 2px 10px 2px 0; white-space: nowrap; }
.doc .doc-meta td { text-align: right; font-weight: 600; padding: 2px 0; white-space: nowrap; }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.doc-box { border: 1px solid var(--doc-line); border-radius: 4px; padding: 8px 10px; }
.doc-box-label { display: block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--doc-muted); margin-bottom: 3px; text-align: left; }
.doc-party-name { font-size: 14px; font-weight: 700; }
.doc-kv { border-collapse: collapse; width: 100%; }
.doc .doc-kv th { text-align: left; font-weight: 500; color: var(--doc-muted); padding: 1px 10px 1px 0; white-space: nowrap; vertical-align: top; width: 1%; }
.doc .doc-kv td { padding: 1px 0; }
.doc-items { width: 100%; border-collapse: collapse; }
.doc .doc-items thead th { background: var(--doc-band); color: #fff; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; padding: 7px 6px; text-align: left; }
.doc .doc-items thead th.num { text-align: right; }
.doc .doc-items tbody td { padding: 6px; border-bottom: 1px solid var(--doc-line); vertical-align: top; }
.doc .doc-items tbody tr:nth-child(even) td { background: var(--doc-soft); }
.doc .doc-items tfoot td { padding: 7px 6px; font-weight: 700; border-top: 2px solid var(--doc-band); background: transparent; }
.doc-items tr { page-break-inside: avoid; break-inside: avoid; }
.doc-items .doc-sub { color: var(--doc-muted); font-size: 11px; }
.doc-summary { display: flex; justify-content: space-between; gap: 18px; margin-top: 12px; page-break-inside: avoid; break-inside: avoid; }
.doc-summary-left { flex: 1; display: grid; gap: 10px; align-content: start; }
.doc-words { font-weight: 600; font-style: italic; }
.doc-position { width: auto; min-width: 260px; }
.doc-position caption { text-align: left; }
.doc .doc-strong th, .doc .doc-strong td { font-weight: 700; color: var(--doc-ink); border-top: 1px solid var(--doc-line); }
.doc-totals { border-collapse: collapse; min-width: 260px; flex: 1.2; align-self: flex-start; }
.doc .doc-totals th { text-align: left; font-weight: 500; padding: 4px 12px 4px 0; color: var(--doc-muted); }
.doc .doc-totals td { padding: 4px 0; }
.doc-totals-wide { flex: 2; }
.doc .doc-totals .doc-words-below td { padding: 8px 0 0; }
.doc-totals .doc-words-below .doc-box-label { display: inline; margin-right: 6px; }
.doc .doc-totals .doc-grand th, .doc .doc-totals .doc-grand td { background: var(--doc-band); color: #fff; font-size: 15px; font-weight: 800; padding: 8px 10px; }
.doc-notes .doc-box-label { margin-bottom: 2px; }
.doc-signatures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 46px; page-break-inside: avoid; break-inside: avoid; }
.doc-sign { border-top: 1px solid var(--doc-ink); padding-top: 4px; text-align: center; color: var(--doc-muted); font-size: 11.5px; }
.doc-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 18px; padding-top: 6px; border-top: 1px solid var(--doc-line); color: var(--doc-muted); font-size: 10.5px; }
@media print {
  #print-area .doc { box-shadow: none; border-radius: 0; max-width: none; margin: 0; padding: 0; font-size: 11.5px; }
  .doc, .doc * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc-items thead { display: table-header-group; }
}

/* ---------- English (left-to-right) ---------- */
html[dir=ltr] { --urdu: 'Segoe UI', Tahoma, Arial, sans-serif; --text: 'Segoe UI', Tahoma, Arial, sans-serif; }
html[dir=ltr] body { line-height: 1.5; }
html[dir=ltr] h1, html[dir=ltr] h2, html[dir=ltr] h3, html[dir=ltr] label, html[dir=ltr] th, html[dir=ltr] .btn, html[dir=ltr] .nav a,
html[dir=ltr] .stat .label, html[dir=ltr] .tabs button, html[dir=ltr] .seg button, html[dir=ltr] legend, html[dir=ltr] .kv dt { line-height: 1.6; }
html[dir=ltr] h1 { line-height: 1.6; }
html[dir=ltr] th, html[dir=ltr] td { text-align: left; }
html[dir=ltr] td.actions { text-align: right; }
html[dir=ltr] .stat .value { text-align: left; }
html[dir=ltr] input[type=number], html[dir=ltr] input[type=date], html[dir=ltr] input.ltr-in { text-align: left; }
html[dir=ltr] .btn { padding-top: 5px; padding-bottom: 5px; }
html[dir=ltr] #toasts { left: auto; right: 20px; }
html[dir=ltr] .pr .pphoto { float: right; margin: 0 0 6px 8px; }
@media (max-width: 900px) {
  html[dir=ltr] .sidebar { right: auto; left: -240px; transition: left .2s; }
  html[dir=ltr] .sidebar.open { left: 0; box-shadow: 10px 0 30px rgba(0,0,0,.3); }
}

@media (max-width: 900px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .sidebar { position: fixed; right: -240px; transition: right .2s; z-index: 60; }
  .sidebar.open { right: 0; box-shadow: -10px 0 30px rgba(0,0,0,.3); }
  .menu-btn { display: inline-flex; }
  main { padding: 12px; }
}

/* ---------- print ---------- */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 12.5px; }
  #app, #toasts, .modal-bg { display: none !important; }
  #print-area { display: block; }
  .pr { color: #000; }
  .pr table { font-size: 12px; }
  .pr th, .pr td { border: 1px solid #999; padding: 4px 6px; }
  .pr th { background: #eee !important; color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pr .head { text-align: center; border-bottom: 2px solid #000; padding-bottom: 6px; margin-bottom: 10px; }
  .pr .head h1 { font-size: 22px; line-height: 1.8; }
  .pr .head.has-logo { display: flex; align-items: center; gap: 12px; text-align: start; }
  .pr .head .pr-logo { height: 22mm; max-width: 40mm; object-fit: contain; }
  .pr .head .head-text { flex: 1; text-align: center; }
  .pr .receipt .head .pr-logo { height: 16mm; max-width: 28mm; }
  .pr .head div { font-size: 12px; }
  .pr h2 { font-size: 15px; margin: 10px 0 4px; text-align: center; }
  .pr h3 { font-size: 13.5px; margin: 8px 0 4px; border-bottom: 1px solid #999; }
  .pr .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .pr .kv { font-size: 12px; gap: 0 10px; }
  .pr .kv dt { color: #333; }
  .pr .sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 50px; text-align: center; }
  .pr .sign div { border-top: 1px solid #000; padding-top: 4px; font-family: var(--urdu); }
  .pr .terms { white-space: pre-wrap; font-family: var(--urdu); font-size: 12px; line-height: 2.1; }
  .pr .receipt { max-width: 120mm; margin: 0 auto; border: 1px dashed #000; padding: 10px 14px; }
  .pr .receipt + .receipt { margin-top: 14mm; }
  /* receipt no. on the start side; date/time + account no. on the opposite side (right in English, left in Urdu) */
  .pr .rc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 4px; }
  .pr .rc-end { margin-inline-start: auto; }
  .pr .big { font-size: 18px; font-weight: 700; }
  .pr .tot td { font-weight: 700; }
  .pr .badge { border: 1px solid #999; background: none !important; }
  .pr .pphoto { float: left; width: 30mm; height: 36mm; object-fit: cover; border: 1px solid #000; margin: 0 0 6px 8px; }
  .pr .cnics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
  .pr .cnics img { width: 100%; max-height: 55mm; object-fit: contain; border: 1px solid #999; }
}

/* ---------- prayer times & azan reminder (same as the Pesticides ERP) ---------- */
#prayer-bar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 9999; background: #17603c; color: #fff;
  padding: 12px 18px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.25); display: flex; gap: 14px; align-items: center; max-width: calc(100% - 32px); direction: ltr; }
#prayer-bar .ur { font-size: 20px; font-family: var(--urdu); direction: rtl; }
#prayer-bar button { background: #fff; color: #17603c; border: 0; border-radius: 6px; padding: 6px 12px; cursor: pointer; font-weight: 600; }
#prayer-card .p-times { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
#prayer-card .p-time { position: relative; overflow: hidden; text-align: center; padding: 14px 6px 12px; border-radius: 14px; color: #fff;
  box-shadow: 0 3px 10px rgba(20, 50, 35, .14); transition: transform .2s, box-shadow .2s; }
#prayer-card .p-time:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(20, 50, 35, .2); }
#prayer-card .p-time::after { content: ''; position: absolute; right: -18px; top: -18px; width: 64px; height: 64px; border-radius: 50%; background: rgba(255,255,255,.12); }
#prayer-card .p-fajr { background: linear-gradient(160deg, #2b3a67 0%, #5b6fa8 100%); }
#prayer-card .p-sunrise { background: linear-gradient(160deg, #f08a4b 0%, #f6c35b 100%); }
#prayer-card .p-dhuhr { background: linear-gradient(160deg, #1e88c8 0%, #5cc0e8 100%); }
#prayer-card .p-asr { background: linear-gradient(160deg, #c9822b 0%, #e8b45a 100%); }
#prayer-card .p-maghrib { background: linear-gradient(160deg, #a23e5c 0%, #e0705a 100%); }
#prayer-card .p-isha { background: linear-gradient(160deg, #141e3c 0%, #34407a 100%); }
#prayer-card .p-icon { font-size: 24px; line-height: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,.25)); }
#prayer-card .p-ur { font-family: var(--urdu); font-size: 20px; line-height: 1.9; margin-top: 4px; }
#prayer-card .p-name { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; opacity: .9; font-family: 'Segoe UI', Arial, sans-serif; }
#prayer-card .p-clock { font-weight: 800; font-size: 19px; margin-top: 4px; letter-spacing: .02em; direction: ltr; font-family: 'Segoe UI', Arial, sans-serif; }
#prayer-card .p-time.past { filter: saturate(.35) brightness(.95); opacity: .7; }
#prayer-card .p-time.past .p-clock::before { content: '✓ '; font-weight: 400; }
#prayer-card .p-time.next { transform: translateY(-3px) scale(1.04); box-shadow: 0 0 0 3px #fff, 0 0 0 6px #d4a017, 0 10px 24px rgba(0,0,0,.25); }
#prayer-card .p-badge { display: inline-block; margin-top: 6px; padding: 2px 9px; border-radius: 99px; background: #d4a017; color: #2a1e00; font-size: 11px; font-weight: 700; }
#prayer-card .p-place-chip { display: inline-block; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--brand); color: var(--brand); font-weight: 600; }
#prayer-card .p-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-bottom: 14px; }
#prayer-card .p-sub { font-weight: 400; font-size: .8em; opacity: .7; }
#prayer-card .p-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
#prayer-card .p-next { display: flex; align-items: center; gap: 12px; padding: 8px 20px; border-radius: 99px; color: #fff;
  background: linear-gradient(135deg, #0f4a2e, #17603c); box-shadow: 0 4px 14px rgba(23, 96, 60, .3); white-space: nowrap; }
#prayer-card .p-next-label { font-size: 12px; opacity: .85; }
#prayer-card .p-next-ur { font-family: var(--urdu); font-size: 22px; line-height: 1.6; }
#prayer-card .p-next-en { font-weight: 700; font-size: 16px; font-family: 'Segoe UI', Arial, sans-serif; }
#prayer-card .p-count { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 21px; font-weight: 700; padding: 2px 12px;
  border-radius: 8px; background: rgba(255,255,255,.16); letter-spacing: .05em; direction: ltr; }
@media (max-width: 1100px) { #prayer-card .p-head { grid-template-columns: 1fr; justify-items: center; } #prayer-card .p-next { flex-wrap: wrap; justify-content: center; } }
@media (max-width: 900px) { #prayer-card .p-times { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media print { #prayer-bar, #prayer-card { display: none; } }
