:root {
  --brand: #0f6cbd; --brand-dark: #0b4f8a; --brand-soft: #e8f2fc; --accent: #14b8a6;
  --ink: #16202b; --ink-2: #4a5663; --muted: #7b8794; --line: #e3e8ee; --bg: #f4f7fa; --card: #ffffff;
  --ok: #117a43; --ok-bg: #e7f6ee; --warn: #9a5b00; --warn-bg: #fff4e0; --err: #b42318; --err-bg: #fdecea;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.08);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a;
}
[dir="rtl"] { --font: "Noto Nastaliq Urdu", "Inter", system-ui, sans-serif; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 14.5px; line-height: 1.5; }
[dir="rtl"] body { font-size: 14px; line-height: 2.1; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.3; }
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3 { line-height: 1.9; }
h3 { font-size: 1.05rem; }
code { white-space: nowrap; background: var(--bg); padding: 1px 6px; border-radius: 6px; font-size: .85em; direction: ltr; unicode-bidi: embed; }
.muted { color: var(--muted); }
.center { text-align: center; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--brand); color: #fff; border: 1px solid var(--brand); border-radius: 9px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; line-height: 1.2; min-height: 40px; }
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: #fff; color: var(--brand); border-color: var(--line); }
.btn-ghost:hover { background: var(--brand-soft); }
.btn-danger { background: var(--err); border-color: var(--err); }
.btn-sm { padding: 6px 12px; min-height: 34px; font-size: .9em; }
.btn-xs { padding: 3px 9px; min-height: 28px; font-size: .82em; border-radius: 7px; }
.btn-lg { padding: 12px 22px; min-height: 48px; font-size: 1.02em; }
.btn-block { width: 100%; }
.lang-btn { font-weight: 700; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); font-family: "Noto Nastaliq Urdu", var(--font); }
[dir="rtl"] .lang-btn { font-family: "Inter", sans-serif; }

/* ---------- forms: labels on top, one grid, everything aligned ---------- */
.form .field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-grid .field > label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.form > .field { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; align-items: start; }
.form-grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.span-2 { grid-column: 1 / -1; }
label { font-weight: 600; font-size: .88em; color: var(--ink-2); }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid #cfd7e0; border-radius: 9px; padding: 9px 12px; min-height: 40px; transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,108,189,.15); }
input:disabled { background: var(--bg); color: var(--muted); }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; accent-color: var(--brand); flex: none; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); cursor: pointer; }
.checks { gap: 10px; padding-top: 26px; }
.hint { color: var(--muted); font-weight: 500; min-height: 1em; }
.hint.found { color: var(--ok); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.fieldset { border: 1px dashed #cfd7e0; border-radius: var(--radius); padding: 14px 16px; margin: 18px 0 0; }
.fieldset legend { font-weight: 700; padding: 0 6px; }
.note { background: var(--brand-soft); border-radius: 9px; padding: 10px 12px; color: var(--brand-dark); font-size: .92em; }
.input-pair { display: flex; gap: 4px; min-width: 150px; }
.input-pair input { flex: 1 1 70px; min-width: 60px; }
.input-pair select { flex: 0 0 96px; padding-inline: 8px; }
.inline-field { display: flex; align-items: center; gap: 8px; }
.inline-field label { white-space: nowrap; }
.inline-field select { min-width: 160px; }
.num-input { max-width: 110px; text-align: end; }
form.inline { display: inline-flex; gap: 4px; margin: 0 4px; vertical-align: middle; }

/* ---------- cards, tables, tabs ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h3 { margin: 0; }
.form-card { max-width: 640px; }
.form-card.wide { max-width: 900px; }
.narrow-card { max-width: 720px; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.top-align { align-items: start; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .93em; }
.table th { text-align: start; font-weight: 600; color: var(--ink-2); background: #f8fafc; border-bottom: 1px solid var(--line); padding: 10px 10px; white-space: nowrap; font-size: .9em; }
.table td { padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: #fafcff; }
.table .num { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table tfoot td { font-weight: 600; background: #f8fafc; }
.table tr.strong td { font-weight: 700; }
.table tr.grand td { font-weight: 800; font-size: 1.05em; border-top: 2px solid var(--ink); }
.table tr.group td { background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; }
.table tr.late td:first-child { box-shadow: inset 3px 0 0 var(--err); }
.table td.actions { white-space: nowrap; text-align: end; }
.table td.actions .btn { margin-inline-start: 4px; }
.table .indent { padding-inline-start: 28px; color: var(--ink-2); }
.matrix th, .matrix td { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: start; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; scrollbar-width: thin; }
.tabs a { padding: 10px 14px; color: var(--ink-2); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.tabs a:hover { color: var(--brand); text-decoration: none; }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); }
.tabs .count { display: inline-block; background: var(--brand); color: #fff; border-radius: 999px; font-size: .75em; padding: 0 7px; margin-inline-start: 4px; }
.filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-bar input, .filter-bar select { width: auto; min-width: 150px; }
.filter-bar label { display: flex; align-items: center; gap: 6px; }
.filter-card { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
.quick-ranges { display: inline-flex; gap: 10px; margin-inline-start: 6px; font-size: .9em; }

/* badges */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78em; font-weight: 700; background: #eef1f4; color: var(--ink-2); white-space: nowrap; line-height: 1.7; }
.st-requested, .st-pending, .st-unpaid { background: var(--warn-bg); color: var(--warn); }
.st-received, .st-online { background: var(--brand-soft); color: var(--brand-dark); }
.st-processing, .st-in_process, .st-partial { background: #f1ecfd; color: #5b3cc4; }
.st-ready, .st-done, .st-paid, .st-verified, .st-active, .st-delivered { background: var(--ok-bg); color: var(--ok); }
.st-cancelled, .st-rejected, .st-inactive { background: var(--err-bg); color: var(--err); }

.alert { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; border: 1px solid; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border-color: #b7e4c9; }
.alert-err { background: var(--err-bg); color: var(--err); border-color: #f5c2bd; }
.site-main .alert { margin-top: 14px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpis-sm { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; color: var(--ink); border-top: 3px solid var(--brand); }
a.kpi:hover { text-decoration: none; border-color: var(--brand); }
.kpi span { color: var(--ink-2); font-size: .85em; font-weight: 600; }
.kpi strong { font-size: 1.45rem; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); }
.kpi.good { border-top-color: var(--ok); }
.kpi.warn { border-top-color: #e8a317; }
.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.chart-box { position: relative; width: 100%; }
.hbar { background: var(--bg); border-radius: 4px; height: 10px; overflow: hidden; }
.hbar span { display: block; height: 100%; background: var(--series-1); border-radius: 4px; }

/* ---------- staff app shell ---------- */
.app-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: #0e1b2b; color: #cfd8e3; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.sidebar .brand { color: #fff; margin: 0 6px 18px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a { color: #cfd8e3; padding: 9px 12px; border-radius: 9px; display: flex; align-items: center; gap: 10px; font-weight: 500; }
.sidebar nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.sidebar nav a.on { background: var(--brand); color: #fff; }
.sidebar .ico { width: 22px; text-align: center; }
.sidebar .credit { color: #8797a8; font-size: .75em; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.08); margin-top: 12px; }
.sidebar .credit a { color: #9cc7f0; }
.app-main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 14px; background: #fff; border-bottom: 1px solid var(--line); padding: 12px 24px; position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 1.2rem; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.branch-pick select { min-width: 180px; min-height: 36px; padding: 6px 10px; }
.chip { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: .85em; font-weight: 600; white-space: nowrap; }
.content { padding: 22px 24px 40px; }
.nav-toggle { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; font-size: 1.2rem; padding: 4px 10px; cursor: pointer; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--ink); font-size: 1.05rem; line-height: 1.2; }
.brand:hover { text-decoration: none; }
.brand small { display: block; font-weight: 500; font-size: .72em; opacity: .75; margin-top: 2px; }
.logo { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; background: linear-gradient(135deg, var(--brand), var(--accent)); color: #fff; font-weight: 800; flex: none; font-family: "Inter", sans-serif; }
.logo.big { width: 56px; height: 56px; font-size: 1.4rem; border-radius: 16px; }

/* order screens */
.order-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.order-head h2 { font-size: 1.25rem; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.order-head p { margin: 0; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.head-actions form.inline { margin: 0; }
.lines-table { min-width: 760px; }
.lines-table select, .lines-table input { min-width: 0; }
.lines-table td { padding: 6px 6px; }
.lines-table .rm { background: none; border: 0; color: var(--err); font-size: 1.2rem; cursor: pointer; padding: 4px 8px; }
.add-line { margin-top: 10px; }
.totals-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.totals-row > div, .totals-box > div { background: var(--bg); border-radius: 10px; padding: 10px 14px; display: flex; flex-direction: column; }
.totals-row span, .totals-box span { color: var(--ink-2); font-size: .85em; font-weight: 600; }
.totals-row strong, .totals-box strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.totals-row .hl { background: var(--brand); color: #fff; }
.totals-row .hl span { color: #dbeafe; }
.totals-grid { margin-top: 16px; grid-template-columns: 2fr 1fr; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; }
.kv-grid div { display: flex; flex-direction: column; }
.kv-grid span { color: var(--muted); font-size: .85em; }
.timeline { display: flex; list-style: none; padding: 0; margin: 14px 0 4px; }
.timeline li { flex: 1; text-align: center; position: relative; color: var(--muted); font-weight: 600; font-size: .85em; padding-top: 26px; }
.timeline li span { position: absolute; top: 4px; left: 50%; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; background: #d7dee6; z-index: 1; }
.timeline li::before { content: ""; position: absolute; top: 11px; left: -50%; width: 100%; height: 3px; background: #d7dee6; }
.timeline li:first-child::before { display: none; }
.timeline li.done { color: var(--ok); }
.timeline li.done span, .timeline li.done::before { background: var(--ok); }
[dir="rtl"] .timeline li::before { left: auto; right: -50%; }
.log { list-style: none; padding: 0; margin: 0; }
.log li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.perm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.perm { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; font-weight: 500; color: var(--ink); }
.perm:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.partner { background: linear-gradient(135deg, #0e1b2b, #0f3f6e); color: #e6eef7; }
.partner h3 { color: #fff; }

/* ---------- public site ---------- */
.site-header { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.nav-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; }
.site-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.site-nav > a:not(.btn):not(.lang-btn) { color: var(--ink-2); padding: 8px 12px; border-radius: 8px; font-weight: 600; }
.site-nav > a.on, .site-nav > a:not(.btn):not(.lang-btn):hover { background: var(--brand-soft); color: var(--brand); text-decoration: none; }
.hero { background: linear-gradient(135deg, #0e1b2b 0%, #0f4c81 60%, #0f6cbd 100%); color: #fff; padding: 64px 0; }
.hero-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; align-items: center; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); }
.hero .lead { font-size: 1.1rem; color: #d4e4f5; }
.eyebrow { display: inline-block; background: rgba(255,255,255,.12); padding: 4px 12px; border-radius: 999px; font-weight: 600; font-size: .85em; margin-bottom: 14px; }
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; margin: 20px 0; }
.hero .btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.hero-points { list-style: none; padding: 0; color: #d4e4f5; }
.hero-card { background: #fff; color: var(--ink); border-radius: 18px; padding: 24px; box-shadow: 0 20px 40px rgba(0,0,0,.25); }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.steps li { display: flex; gap: 14px; align-items: flex-start; }
.steps b { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); flex: none; }
.steps strong { display: block; }
.steps span { color: var(--muted); font-size: .92em; }
.section { padding: 40px 16px; }
.section.narrow { max-width: 820px; }
.section-title { font-size: 1.6rem; }
.feature { text-align: start; }
.feature-ico { font-size: 1.8rem; width: 52px; height: 52px; display: grid; place-items: center; background: var(--brand-soft); border-radius: 14px; margin-bottom: 10px; }
.feature p { color: var(--ink-2); margin: 0; }
.split-cta { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.split-cta h2 { margin: 0; }
.split-cta p { margin: 4px 0 0; color: var(--ink-2); }
.prose p { color: var(--ink-2); }
.info-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.auth-wrap { display: flex; justify-content: center; }
.auth-card { width: 100%; max-width: 440px; padding: 28px; }
.auth-head { text-align: center; margin-bottom: 18px; }
.auth-head .logo { margin-bottom: 8px; }
.auth-foot { text-align: center; margin-top: 16px; color: var(--muted); }
.portal-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.portal-head h2 { margin: 0; }
.portal-head p { margin: 0; }
.stat-mini { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px; display: flex; flex-direction: column; }
.stat-mini span { color: var(--muted); font-size: .85em; }
.stat-mini strong { font-size: 1.3rem; }
.site-footer { background: #0e1b2b; color: #b8c4d1; padding: 36px 0 20px; margin-top: 30px; }
.site-footer strong { color: #fff; }
.site-footer a { color: #9cc7f0; }
.footer-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.footer-grid p { margin: 6px 0; }
.credit { font-size: .82em; color: #8797a8; margin-top: 18px; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  [dir="rtl"] .sidebar { inset: 0 0 0 auto; transform: translateX(100%); }
  .nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .nav-toggle { display: inline-block; }
  .grid-2, .grid-3, .hero-grid, .footer-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .user-chip { display: none; }
  .topbar-right { width: 100%; justify-content: flex-start; }
  .site-nav { display: none; position: absolute; top: 68px; inset-inline: 0; background: #fff; flex-direction: column; align-items: stretch; padding: 10px 16px; border-bottom: 1px solid var(--line); }
  .nav-open .site-nav { display: flex; }
}
@media (max-width: 640px) {
  .form-grid, .perm-grid, .totals-row, .totals-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi strong { font-size: 1.15rem; }
  .card { padding: 14px; }
  .hero { padding: 36px 0; }
  .filter-bar input, .filter-bar select { min-width: 0; flex: 1 1 140px; }
  .timeline li { font-size: .72em; }
}
@media print {
  .sidebar, .topbar, .tabs, .filter-card, .btn, .quick-actions, .site-header, .site-footer { display: none !important; }
  .app-shell { display: block; }
  .card { box-shadow: none; border: 0; }
  body { background: #fff; }
}
