:root {
  --bg: #f6f8f3; --surface: #ffffff; --surface-2: #f1f5ec; --ink: #0f1a0a; --ink-2: #3f4a38; --muted: #6b7563;
  --line: #e3e8dc; --line-2: #d3dbc9;
  --brand: #65a30d; --brand-ink: #3f6212; --brand-soft: #ecfccb; --brand-strong: #4d7c0f;
  --ok: #15803d; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7; --bad: #b91c1c; --bad-soft: #fee2e2;
  --info: #1d4ed8; --info-soft: #dbeafe; --violet: #6d28d9; --violet-soft: #ede9fe;
  --shadow: 0 1px 2px rgba(15,26,10,.05), 0 6px 24px -8px rgba(15,26,10,.10);
  --radius: 14px; --radius-sm: 10px;
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-ur: 'Noto Nastaliq Urdu', 'Plus Jakarta Sans', serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1008; --surface: #121a0e; --surface-2: #18220f; --ink: #eef5e6; --ink-2: #c5d0bb; --muted: #8e9a84;
  --line: #233019; --line-2: #2e3d22; --brand: #a3e635; --brand-ink: #d9f99d; --brand-soft: #1f2e10; --brand-strong: #84cc16;
  --ok: #4ade80; --ok-soft: #12301c; --warn: #fbbf24; --warn-soft: #2f2410; --bad: #f87171; --bad-soft: #351414;
  --info: #93c5fd; --info-soft: #14233d; --violet: #c4b5fd; --violet-soft: #241a3d;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px -10px rgba(0,0,0,.6);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
html[lang="ur"] body { font-family: var(--font-ur); line-height: 1.9; }
html[lang="ur"] .ltr, html[lang="ur"] input, html[lang="ur"] textarea, html[lang="ur"] select, html[lang="ur"] code, html[lang="ur"] .num { font-family: var(--font); }
a { color: var(--brand-ink); text-decoration: none; }
svg { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
svg.tiny { width: 12px; height: 12px; vertical-align: -1px; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { height: 100vh; display: grid; place-items: center; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; transform: scale(.96); } }

/* Layout */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; background: var(--surface); border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 14px; gap: 6px; }
.brand { display: grid; padding: 2px 8px 16px; }
.brand img { height: 46px; width: auto; justify-self: start; }
.brand small { display: block; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; margin: 2px 0 0 4px; font-family: var(--font); }
.logo-d { display: none !important; }
:root[data-theme="dark"] .logo-l { display: none !important; }
:root[data-theme="dark"] .logo-d { display: inline-block !important; }
.tb-logo img { height: 32px; width: auto; }
.login-logo img { height: 52px; width: auto; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 600; font-size: 14px; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.on { background: var(--brand-soft); color: var(--brand-ink); }
.nav a .pill { margin-inline-start: auto; }
.nav svg { width: 18px; height: 18px; flex: none; }
.side .foot { margin-top: auto; display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.who { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.who div { min-width: 0; } .who b { display: block; font-size: 13.5px; } .who span { font-size: 12px; color: var(--muted); }
.toggles { display: flex; gap: 6px; padding: 0 6px; }
main { min-width: 0; padding: 26px 32px 60px; max-width: 1360px; width: 100%; }
.topbar { display: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 26px; letter-spacing: -.025em; line-height: 1.2; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
html[lang="ur"] .page-head h1 { font-size: 24px; line-height: 1.8; }

/* Components */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 18px 20px; }
.card h2, .card h3 { margin: 0 0 12px; font-size: 15.5px; letter-spacing: -.01em; }
.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)); } .g6 { grid-template-columns: repeat(6, minmax(0,1fr)); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; } .row.between { justify-content: space-between; }
.stack { display: grid; gap: 12px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .tiny { font-size: 11.5px; }
.num { font-variant-numeric: tabular-nums; }
.kpi { padding: 16px 18px; }
.kpi .v { font-size: 28px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin-top: 6px; }
.kpi .l { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.hl { background: linear-gradient(135deg, var(--brand-soft), var(--surface)); border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 15px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 650; font-size: 14px; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { background: var(--surface-2); } .btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #0b1008; }
.btn.primary:hover { background: var(--brand-strong); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.btn.sm { height: 31px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn.icon { width: 36px; padding: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; font-family: var(--font); }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); } .pill.info { background: var(--info-soft); color: var(--info); }
.pill.brand { background: var(--brand-soft); color: var(--brand-ink); } .pill.violet { background: var(--violet-soft); color: var(--violet); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

.score { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; font-weight: 800; font-size: 14px; font-family: var(--font); }
.score.hi { background: var(--ok-soft); color: var(--ok); } .score.mid { background: var(--warn-soft); color: var(--warn); } .score.lo { background: var(--surface-2); color: var(--muted); }

label.f { display: grid; gap: 6px; font-size: 13px; font-weight: 650; color: var(--ink-2); }
label.f .hint { font-weight: 500; color: var(--muted); font-size: 12px; }
.input, select.input, textarea.input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; }
textarea.input { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; font-size: 13.5px; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border: 1px solid var(--line-2); border-radius: 99px; cursor: pointer; font-size: 13px; font-weight: 600; background: var(--surface); user-select: none; }
.chip input { display: none; }
.chip.on, .chip:has(input:checked) { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); }

/* Tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.t th { text-align: start; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; font-family: var(--font); }
.t td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr { cursor: pointer; } .t tbody tr:hover td { background: var(--surface-2); }
.t .name b { display: block; font-weight: 700; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t .name span { color: var(--muted); font-size: 12px; }
.icons { display: inline-flex; gap: 5px; }
.ic { width: 24px; height: 24px; display: inline-grid; place-items: center; border-radius: 7px; background: var(--surface-2); color: var(--muted); }
.ic.on { background: var(--brand-soft); color: var(--brand-ink); }
.ic svg { width: 14px; height: 14px; }

/* Filters bar */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.filters .input { height: 36px; width: auto; min-width: 150px; }
.filters .search { flex: 1 1 220px; }

/* Drawer */
.overlay { position: fixed; inset: 0; background: rgba(10,16,6,.35); backdrop-filter: blur(2px); z-index: 40; animation: fade .15s; }
.drawer { position: fixed; top: 0; inset-inline-end: 0; height: 100vh; width: min(640px, 100vw); background: var(--bg); z-index: 41; overflow-y: auto; box-shadow: -20px 0 50px -20px rgba(0,0,0,.3); animation: slide .2s ease-out; }
html[dir="rtl"] .drawer { animation-name: slide-rtl; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } } @keyframes slide-rtl { from { transform: translateX(-30px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.drawer-head { position: sticky; top: 0; z-index: 2; background: var(--surface); border-bottom: 1px solid var(--line); padding: 16px 20px; display: flex; gap: 14px; align-items: flex-start; }
.drawer-head h2 { margin: 0; font-size: 19px; letter-spacing: -.02em; line-height: 1.3; }
.drawer-body { padding: 18px 20px 40px; display: grid; gap: 14px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); font-weight: 600; } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.reasons { margin: 0; padding-inline-start: 18px; font-size: 13px; color: var(--ink-2); display: grid; gap: 3px; }
.timeline { display: grid; gap: 0; font-size: 13px; }
.timeline div { display: grid; grid-template-columns: 112px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.timeline time { color: var(--muted); font-size: 12px; }
.quote { background: var(--surface-2); border-radius: 10px; padding: 9px 12px; font-size: 13px; color: var(--ink-2); border-inline-start: 3px solid var(--line-2); }

/* Approval cards */
.appr { display: grid; grid-template-columns: auto 1fr; gap: 14px; padding: 16px 18px; }
.appr + .appr { border-top: 1px solid var(--line); }
.appr .msg { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; font-size: 14px; white-space: pre-wrap; }
.wa-bubble { background: #dcf8c6; color: #0f1a0a; border-radius: 12px 12px 12px 4px; padding: 10px 12px; max-width: 520px; font-size: 14px; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
:root[data-theme="dark"] .wa-bubble { background: #1f3d24; color: #e8f5e3; }
.wa-btns { display: flex; gap: 6px; margin-top: 6px; max-width: 520px; }
.wa-btns span { flex: 1; text-align: center; padding: 7px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; color: #0a84ff; font-weight: 600; font-size: 13px; }

/* Bars / chart */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; min-width: 0; }
.bars .col { width: 100%; max-width: 34px; border-radius: 6px 6px 3px 3px; background: var(--line-2); position: relative; min-height: 2px; }
.bars .col i { position: absolute; inset-inline: 0; bottom: 0; border-radius: inherit; background: var(--brand); }
.bars .b span { font-size: 10.5px; color: var(--muted); font-family: var(--font); }
.funnel { display: grid; gap: 10px; }
.funnel .f-row { display: grid; grid-template-columns: 96px 1fr 52px; gap: 10px; align-items: center; font-size: 13px; font-weight: 600; }
.funnel .track { height: 12px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.funnel .track i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }

.status-list { display: grid; gap: 8px; }
.status-list div { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.status-list div span:last-child { margin-inline-start: auto; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: 13.5px; font-weight: 600; }
.notice.info { background: var(--info-soft); color: var(--info); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; font-weight: 650; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--brand-ink); border-color: var(--brand); }
code, .code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12.5px; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; overflow-wrap: anywhere; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); font-size: 13px; }

/* Login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login .art { background: radial-gradient(900px 500px at 95% 5%, rgba(217,249,157,.55) 0, transparent 60%), linear-gradient(160deg, #3f6212, #1a2e05); color: #f7fee7; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login .art h2 { font-size: 38px; letter-spacing: -.035em; line-height: 1.1; margin: 0 0 14px; max-width: 460px; }
.login .art p { opacity: .85; max-width: 420px; }
.login .art ul { list-style: none; padding: 0; display: grid; gap: 10px; font-weight: 600; }
.login .art li::before { content: '✓'; display: inline-grid; place-items: center; width: 22px; height: 22px; margin-inline-end: 10px; border-radius: 50%; background: rgba(217,249,157,.18); color: #d9f99d; font-size: 12px; }
.login form { align-self: center; justify-self: center; width: min(380px, 90vw); display: grid; gap: 14px; }
.login form h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }

#toasts { position: fixed; bottom: 18px; inset-inline-end: 18px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 12px; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow); animation: slide .2s; max-width: 360px; }
.toast.err { background: var(--bad); color: #fff; }

.mob-nav { display: none; }
.hide-sm { }
@media (max-width: 1100px) { .g6 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: 10px 16px; }
   .topbar .row { margin-inline-start: auto; }
  main { padding: 18px 16px 96px; }
  .mob-nav { display: flex; position: fixed; bottom: 0; inset-inline: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .mob-nav a { display: grid; justify-items: center; gap: 2px; font-size: 10.5px; font-weight: 700; color: var(--muted); padding: 4px 6px; border-radius: 10px; min-width: 56px; position: relative; font-family: var(--font); }
  .mob-nav a.on { color: var(--brand-ink); background: var(--brand-soft); }
  .mob-nav svg { width: 21px; height: 21px; }
  .mob-nav .badge { position: absolute; top: 0; inset-inline-end: 8px; background: var(--bad); color: #fff; border-radius: 99px; font-size: 9.5px; padding: 0 5px; }
  .g2, .g3 { grid-template-columns: 1fr; } .g4, .g6 { grid-template-columns: repeat(2, 1fr); }
  .page-head h1 { font-size: 22px; }
  .hide-sm { display: none !important; }
  .login { grid-template-columns: 1fr; } .login .art { display: none; }
  .kv { grid-template-columns: 105px 1fr; }
  .appr { grid-template-columns: 1fr; }
  .filters .input { min-width: 0; flex: 1 1 140px; }
  .t .name b { max-width: 180px; }
}
