:root {
  --lime: #c4f45d;
  --lime-deep: #a8d63a;
  --sage: #e7f3ea;
  --sage-soft: #f3f8f4;
  --charcoal: #161616;
  --charcoal-soft: #2a2a2a;
  --surface: #eef6f0;
  --surface-dim: #d7e8dc;
  --surface-bright: #ffffff;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #f7fbf8;
  --surface-container: #e7f3ea;
  --surface-container-high: #d5e8db;
  --surface-container-highest: #bfd9c8;
  --on-surface: #161616;
  --on-surface-variant: #5a6b60;
  --inverse-surface: #161616;
  --inverse-on-surface: #f3f8f4;
  --outline: #8aa193;
  --outline-variant: rgba(22, 22, 22, 0.08);
  --primary: #161616;
  --on-primary: #c4f45d;
  --primary-container: #c4f45d;
  --on-primary-container: #161616;
  --inverse-primary: #c4f45d;
  --secondary: #2f6b45;
  --on-secondary: #ffffff;
  --secondary-container: #e7f3ea;
  --on-secondary-container: #1d3f2a;
  --tertiary: #c4f45d;
  --error: #dc2626;
  --on-error: #ffffff;
  --error-container: #fef2f2;
  --on-error-container: #991b1b;
  --emerald-dark: #161616;
  --mint-subtle: #eef8e4;
  --surface-border: rgba(22, 22, 22, 0.07);
  --text-main: #161616;
  --text-muted: #5a6b60;
  --status-error: #dc2626;
  --status-warning: #2f6b45;
  --chart-1: #161616;
  --chart-2: #2f6b45;
  --chart-3: #c4f45d;
  --chart-4: #7cbc4a;
  --radius: 0.75rem;
  --radius-card: 1.25rem;
  --shadow: 0 8px 24px rgba(22, 22, 22, 0.04);
  --shadow-overlay: 0 18px 40px rgba(22, 22, 22, 0.12);
  --sidebar: 256px;
  --header: 68px;
  --font: "Outfit", "Segoe UI", sans-serif;
  --display: "Outfit", "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --urdu: "Noto Nastaliq Urdu", "Noto Sans Arabic", serif;
  --green: #2f6b45;
  --green-dark: var(--charcoal);
  --green-soft: var(--sage);
  --ink: var(--text-main);
  --muted: var(--text-muted);
  --line: var(--surface-border);
  --paper: var(--surface);
  --card: #ffffff;
  --danger: var(--error);
  --brand: #161616;
  --accent: var(--lime);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 20px;
  color: var(--on-surface);
  background:
    radial-gradient(920px 480px at 8% -8%, rgba(196, 244, 93, 0.28), transparent 55%),
    radial-gradient(720px 420px at 96% 4%, rgba(47, 107, 69, 0.1), transparent 52%),
    linear-gradient(180deg, #f5faf6 0%, #eaf4ed 45%, #eef6f0 100%);
  background-attachment: fixed;
  min-height: 100vh;
}
h1, h2, h3, .page-head h1, .side-brand strong { font-family: var(--display); letter-spacing: -0.03em; }
a { color: var(--secondary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(16px) saturate(1.2);
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 1.5rem;
  border-bottom: 1px solid rgba(22, 22, 22, 0.05);
  box-shadow: none;
}
.scope-label { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 700; font-size: 14px; letter-spacing: -0.02em; white-space: nowrap; }
.scope-label small { display: block; font-family: var(--font); font-weight: 500; color: var(--text-muted); font-size: 11px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 12px;
  background: var(--lime); color: var(--charcoal);
  display: grid; place-items: center;
  font-weight: 700; letter-spacing: .04em; font-size: 12px;
}
.budgetly-logo { display: flex; align-items: center; gap: 14px; }
.budgetly-logo .logo-mark { width: 56px; height: 56px; flex: 0 0 56px; display: block; filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .22)); }
.budgetly-logo strong { font-family: var(--display); font-size: 30px; font-weight: 700; letter-spacing: -0.04em; color: white; line-height: 1; }
.side-brand .logo-mark { width: 34px; height: 34px; flex: 0 0 34px; display: block; }
.side-brand { height: 72px; display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); background: transparent; color: white; }
.side-brand strong { display: block; font-size: 15px; font-weight: 700; letter-spacing: -0.02em; color: white; }
.side-brand small { display: block; color: rgba(255, 255, 255, 0.55); font-size: 10px; font-weight: 500; }
.side-scroll { flex: 1; overflow: auto; padding: 12px; }
.top-search { flex: 1; max-width: 440px; }
.top-search input {
  width: 100%; height: 42px; border: 0; border-radius: 999px;
  padding: 0 18px; background: rgba(255, 255, 255, 0.92); color: var(--text-main); font-size: 13px;
  box-shadow: 0 8px 24px rgba(22, 22, 22, 0.05);
}
.top-search input::placeholder { color: var(--text-muted); }
.top-search input:focus { outline: none; box-shadow: 0 0 0 3px rgba(196, 244, 93, 0.55), 0 8px 24px rgba(22, 22, 22, 0.06); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.year-form select, .filters select, .filters input, .field input, .pass-form input {
  height: 40px; border: 1px solid rgba(22, 22, 22, 0.08); border-radius: 12px; background: white;
  padding: 0 12px; color: var(--text-main);
}
.year-form { margin: 0; }
.year-form label { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 14px; border-radius: 999px; background: #fff; border: 0; box-shadow: 0 8px 20px rgba(22, 22, 22, 0.05); font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--charcoal); }
.year-form select { height: 28px; border: 0; background: transparent; padding: 0; font-weight: 600; color: var(--text-main); }
.filters select:focus, .filters input:focus, .field input:focus, .pass-form input:focus, .year-form select:focus {
  outline: none; border-color: transparent; box-shadow: 0 0 0 3px rgba(196, 244, 93, 0.55);
}
.menu-btn {
  display: none; width: 3rem; height: 3rem; border-radius: 14px;
  border: 0; align-items: center; justify-content: center;
  color: var(--text-main); cursor: pointer; background: white;
  box-shadow: var(--shadow);
}
.userbox { position: relative; }
.userbox summary {
  list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer;
  background: white; border-radius: 999px; padding: 4px 12px 4px 4px; min-height: 44px;
  border: 0; box-shadow: 0 8px 20px rgba(22, 22, 22, 0.05);
}
.userbox summary::-webkit-details-marker { display: none; }
.avatar {
  width: 36px; height: 36px; border-radius: 9999px; background: var(--lime); color: var(--charcoal);
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.who { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.who strong { font-size: 13px; font-weight: 600; }
.who small { font-size: 11px; color: var(--text-muted); }
.userbox-menu {
  position: absolute; right: 0; top: calc(100% + 8px); background: white; color: var(--text-main);
  border: 0; border-radius: 18px; min-width: 220px;
  box-shadow: var(--shadow-overlay); padding: 8px; z-index: 50;
}
.userbox-menu span, .userbox-menu a { display: block; padding: 8px 10px; border-radius: 12px; }
.userbox-menu a:hover { background: var(--sage); }

.workspace { margin-left: var(--sidebar); min-height: 100vh; min-width: 0; }
.sidebar {
  width: var(--sidebar);
  background: linear-gradient(180deg, #1b1b1b 0%, #121212 100%);
  color: #cfd6d1;
  border-right: 0;
  padding: 0;
  position: fixed; inset: 0 auto 0 0; height: 100vh; z-index: 50;
  display: flex; flex-direction: column;
  transition: width .18s ease;
  border-radius: 0 28px 28px 0;
  box-shadow: 12px 0 40px rgba(0, 0, 0, 0.12);
}
.nav-label {
  margin: 16px 12px 6px; font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: rgba(255, 255, 255, 0.38); font-family: var(--mono);
  display: flex; justify-content: space-between; gap: 8px;
}
.nav-label em { font-style: normal; font-family: var(--urdu); letter-spacing: 0; text-transform: none; font-weight: 500; font-size: 11px; }
.sidebar a.nav-link {
  display: flex; align-items: center; gap: 10px; margin: 2px 0; padding: 10px 14px;
  border-radius: 14px; color: rgba(255, 255, 255, 0.72); font-size: 13px; font-weight: 500; min-height: 40px;
}
.sidebar a.nav-link:hover { background: rgba(255, 255, 255, 0.06); color: white; }
.sidebar a.nav-link.is-active {
  background: var(--lime); color: var(--charcoal); font-weight: 700;
  box-shadow: 0 10px 24px rgba(196, 244, 93, 0.28);
}
.sidebar a.nav-link.is-active svg { color: var(--charcoal); }
.sidebar svg { width: 18px; height: 18px; flex: 0 0 18px; }
.sidebar .logo-mark { width: 34px; height: 34px; flex: 0 0 34px; }
.backdrop { display: none; }
.collapse-btn {
  margin-left: auto; width: 28px; height: 28px; border: 0; border-radius: 10px;
  background: transparent; color: rgba(255, 255, 255, 0.45); display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.collapse-btn:hover { color: white; background: rgba(255, 255, 255, 0.08); }
body.is-collapsed .sidebar { width: 72px; }
body.is-collapsed .workspace { margin-left: 72px; }
body.is-collapsed .side-copy, body.is-collapsed .nav-label, body.is-collapsed .nav-link span { display: none; }
body.is-collapsed .nav-link, body.is-collapsed .side-brand { justify-content: center; }
body.is-collapsed .collapse-btn svg { transform: scaleX(-1); }

.main { min-width: 0; padding: 1.5rem 1.5rem 56px; max-width: 1600px; margin: 0 auto; }
.page-head {
  margin-bottom: 1.25rem; padding: 1.4rem 1.5rem 1.25rem;
  border-bottom: 0;
  border-radius: 28px;
  background:
    radial-gradient(520px 220px at 90% 20%, rgba(196, 244, 93, 0.42), transparent 60%),
    linear-gradient(135deg, #e7f3ea 0%, #f7fbf8 48%, #eef8e4 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75), 0 16px 36px rgba(22, 22, 22, 0.04);
}
.eyebrow { margin: 0 0 6px; color: var(--text-muted); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; font-family: var(--mono); }
.page-head h1, .report-mast h2 { margin: 0; font-size: 32px; font-weight: 700; line-height: 1.15; letter-spacing: -0.04em; color: var(--text-main); }
.lede { margin: 8px 0 0; color: var(--text-muted); max-width: 70ch; font-size: 15px; line-height: 1.55; }

.help, .summary-card, .panel, .filter-card, .report, .kpi, .stat, .reading, .metric {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(22, 22, 22, 0.04);
  border-radius: 24px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 14px 36px rgba(22, 22, 22, 0.05);
  backdrop-filter: blur(10px);
}
.panel, .filter-card, .report { transition: box-shadow .18s ease, transform .18s ease; }
.panel:hover, .filter-card:hover { box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 18px 40px rgba(22, 22, 22, 0.07); }
.help, .summary-card { margin-bottom: 1rem; padding: 1.25rem; }
.help summary, .sum-toggle { cursor: pointer; color: var(--primary); font-weight: 600; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 10px; }
.help-grid p { margin: 6px 0 0; }
.urdu { font-family: var(--urdu); direction: rtl; text-align: right; line-height: 1.7; }
.summary-box { display: none; margin-top: 10px; padding: 12px; background: var(--secondary-container); border-radius: var(--radius); color: var(--on-secondary-container); }
.sum-check { position: absolute; opacity: 0; }
.sum-check:checked ~ .summary-box { display: block; }

.kpis, .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.kpi, .stat { padding: 1.25rem 1.3rem; }
.kpi span, .stat span, .muted { color: var(--text-muted); font-size: 12px; font-weight: 500; letter-spacing: 0.05em; }
.kpi b, .stat b { display: block; margin-top: 6px; font-size: 22px; font-weight: 700; line-height: 28px; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kpi em, .stat em, .metric em { font-style: normal; color: var(--secondary); font-size: 12px; font-weight: 600; }
.meter { height: 8px; background: #edf3ee; border-radius: 9999px; margin-top: 10px; overflow: hidden; }
.meter span { display: block; height: 100%; background: linear-gradient(90deg, #2f6b45, var(--lime)); }
.kpi { position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--lime); }

.dash { display: grid; grid-template-columns: 1.3fr .7fr; gap: 1rem; }
.panel { padding: 1.25rem; margin-bottom: 1rem; }
.panel h2, .filter-card h2, .chart-head h2 { margin: 0 0 12px; font-size: 20px; font-weight: 600; line-height: 28px; color: var(--text-main); }
.chart-head h2 { margin: 0; }
.split { display: grid; grid-template-columns: 1.4fr .8fr; gap: 1rem; align-items: start; }

.filter-card { padding: 1.25rem; margin-bottom: 1rem; }
.filters { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; }
.filters label, .field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
.btn, a.btn, button.btn {
  height: 40px; border-radius: 999px; border: 0; padding: 0 16px;
  background: var(--charcoal); color: var(--lime); cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; text-decoration: none; font-weight: 700; font-size: 13px;
  box-shadow: 0 10px 24px rgba(22, 22, 22, 0.12);
}
.btn.secondary { background: white; color: var(--text-main); border: 1px solid rgba(22, 22, 22, 0.08); box-shadow: none; }
.btn:hover { background: #000; }
.btn.secondary:hover { background: var(--sage); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs a { padding: 8px 14px; border-radius: 9999px; background: white; border: 1px solid rgba(22, 22, 22, 0.06); color: var(--text-main); font-size: 14px; min-height: 40px; display: inline-flex; align-items: center; }
.tabs a.is-active { background: var(--lime); color: var(--charcoal); border-color: var(--lime); font-weight: 700; }

.table-wrap { overflow: auto; max-height: 600px; border: 0; border-radius: 20px; background: white; box-shadow: inset 0 0 0 1px rgba(22, 22, 22, 0.04); }
table.data { width: 100%; border-collapse: collapse; min-width: 680px; }
table.data th, table.data td { padding: 12px 14px; text-align: left; border-bottom: 1px solid rgba(22, 22, 22, 0.05); vertical-align: middle; font-size: 14px; }
table.data td { height: 44px; }
table.data th {
  position: sticky; top: 0; z-index: 1;
  background: #f7fbf8; font-size: 11px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-muted); font-weight: 600;
}
table.data td.num, table.data th.num, table.data tfoot td {
  text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap;
  font-weight: 600; letter-spacing: -0.01em; font-family: var(--mono); font-size: 13px;
}
table.data tbody tr:hover td { background: rgba(231, 243, 234, 0.55); }
table.data tr.total td, table.data tfoot td { background: #eef8e4; font-weight: 700; }
table.data code { font-size: 12px; color: var(--on-surface-variant); }
.group { margin: 0 0 18px; }
.group h3 { margin: 0 0 8px; font-size: 20px; font-weight: 600; }
.crumb { color: var(--text-muted); font-size: 13px; margin-bottom: 4px; }

.report { padding: 0; overflow: hidden; }
.report-mast { display: flex; justify-content: space-between; gap: 16px; padding: 1.25rem 1.25rem 8px; align-items: start; }
.report-mast p { margin: 4px 0 0; color: var(--text-muted); }
.report-actions { display: flex; gap: 8px; }
.report .table-wrap { border: 0; border-radius: 0; max-height: none; }
.note, .alert { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.note { background: white; border: 1px solid var(--surface-border); color: var(--text-muted); }
.alert { background: var(--error-container); color: var(--on-error-container); }
.list-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; justify-content: space-between; margin: 4px 0 12px; }
.list-bar .muted { margin: 0; }
.info { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin-left: 6px; padding: 0; border-radius: 999px; border: 1px solid var(--primary); background: white; color: var(--primary); cursor: pointer; vertical-align: middle; }
.info:hover, .info:focus { background: var(--mint-subtle); }
.share-help { max-width: 380px; padding: 14px 16px; border: 1px solid var(--surface-border); border-radius: 12px; background: white; color: var(--text-main); font-size: 14px; font-weight: 400; line-height: 20px; letter-spacing: 0; text-transform: none; text-align: left; box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12); }
.share-help strong { display: block; margin-bottom: 6px; font-weight: 600; }
.share-help p { margin: 0 0 8px; }
.share-help p:last-child { margin: 0; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.pager a, .pager span { padding: 8px 12px; border: 1px solid var(--surface-border); border-radius: var(--radius); background: white; min-height: 40px; display: inline-flex; align-items: center; }
.pager a.is-current { background: var(--mint-subtle); color: var(--primary); border-color: transparent; font-weight: 600; }
.saved { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.saved a { background: white; border: 1px solid var(--surface-border); border-radius: 9999px; padding: 6px 12px; }
.pass-form { display: flex; gap: 6px; margin-top: 6px; }
.pass-form input { min-width: 140px; }
.stack-form { display: grid; gap: 1rem; }
.stack-form .filters { margin: 0; }
.stack-form .form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.stack-form .hint { margin: 0; }
.chat-turn p { margin: 0 0 8px; }
.chat-lines { margin: 0; padding-left: 18px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.login-body {
  min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr;
  background:
    radial-gradient(900px 500px at 12% 12%, rgba(196, 244, 93, 0.22), transparent 50%),
    linear-gradient(160deg, #121212 0%, #1b1b1b 48%, #0d1a12 100%);
}
.login-side { background: transparent; color: white; padding: 56px 48px; display: flex; flex-direction: column; justify-content: center; }
.login-lead { margin: 22px 0 0; max-width: 38ch; font-size: 16px; line-height: 1.55; color: rgba(255, 255, 255, .88); }
.login-card .budgetly-logo { display: none; margin: 0 0 18px; }
.login-card .budgetly-logo .logo-mark { width: 44px; height: 44px; flex-basis: 44px; filter: none; }
.login-card .budgetly-logo strong { color: var(--text-main); font-size: 24px; }
.login-points { display: grid; gap: 10px; margin-top: 28px; }
.login-points div { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16); border-radius: var(--radius-card); padding: 12px 14px; }
.login-card { display: grid; place-items: center; padding: 32px; background: var(--surface); }
.login-card form { width: min(420px, 100%); background: white; border: 0; border-radius: 28px; padding: 28px; box-shadow: var(--shadow-overlay); }
.login-card h1 { margin: 0 0 6px; font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.field { margin-bottom: 12px; }
.field input { width: 100%; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 1rem; }
.chips a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid rgba(22, 22, 22, 0.06); background: white; color: var(--text-main); font-size: 13px; font-weight: 600; }
.chips a span { margin-left: 6px; font-weight: 500; font-variant-numeric: tabular-nums; opacity: .72; }
.chips a.is-on { background: var(--lime); color: var(--charcoal); border-color: var(--lime); }
.reason-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.reason-grid .urdu { margin: 10px 0 0; }
.anomaly-table td { white-space: nowrap; }
.anomaly-table td:last-child, .anomaly-table th:last-child { width: 1%; }
.case-dialog { width: min(560px, calc(100vw - 32px)); border: 0; border-radius: 12px; padding: 0; color: var(--text-main); box-shadow: 0 24px 48px rgba(15, 23, 42, 0.24); }
.case-dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
.case-dialog form { padding: 1.25rem; }
.case-dialog header { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.case-dialog h2 { margin: 0; font-size: 18px; line-height: 26px; }
.case-dialog h3 { margin: 14px 0 4px; font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--primary); }
.case-dialog p { margin: 0; line-height: 1.45; }
.case-figures { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 0; }
.case-figures div { padding: 10px 12px; border-radius: 8px; background: var(--surface); }
.case-figures dt { font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
.case-figures dd { margin: 4px 0 0; font-family: var(--mono); font-weight: 700; }
.chart-trio { display: grid; grid-template-columns: 1.15fr .8fr 1.05fr; gap: 1rem; align-items: start; margin-bottom: 1rem; }
table.compare td small, table.data td small { font-weight: 500; }
.chart-grid, .dash-grid { display: grid; grid-template-columns: 1.35fr .9fr; gap: 1rem; align-items: start; }
.dash-3 { display: grid; grid-template-columns: minmax(280px, 1.15fr) 1fr 1fr; gap: 1rem; align-items: start; margin-top: 1rem; }
.chart-wide { grid-column: 1 / -1; }
.chart-box {
  position: relative; height: 260px; width: 100%; max-width: 100%; overflow: hidden;
  background: linear-gradient(180deg, rgba(247, 251, 248, 0.7), rgba(255, 255, 255, 0)), #fff;
  border-radius: 18px; padding: 10px 6px 6px;
}
.chart-box.tall { height: 320px; }
.chart-box.xl { height: 460px; }
.metric strong { display: block; margin-top: 6px; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; word-break: break-word; font-family: var(--mono); }
.metric small { display: block; margin-top: 4px; color: var(--text-muted); font-size: 12px; letter-spacing: 0; text-transform: none; font-weight: 500; }
.series-legend { display: flex; flex-wrap: wrap; gap: 8px; max-height: 148px; overflow: auto; margin-top: 12px; }
.series-legend button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--surface-border); background: white; border-radius: 999px; padding: 6px 10px; cursor: pointer; font-size: 12px; }
.series-legend button.is-off { opacity: 0.4; }
.series-legend i { width: 10px; height: 10px; border-radius: 999px; display: inline-block; }
.flow { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 1rem; }
.flow span { display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border-radius: 999px; background: white; border: 1px solid var(--surface-border); font-size: 13px; font-weight: 600; }
.flow span.is-on { background: var(--lime); color: var(--charcoal); border-color: var(--lime); }
.status-pill { display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #eef8e4; color: #1d3f2a; }
.status-pill.department { background: #e7f3ea; color: #161616; }
.status-pill.district { background: var(--lime); color: #161616; }
.status-pill.approved { background: #eef8e4; color: #1d3f2a; }
.import-steps { margin: 0; padding-left: 1.2rem; display: grid; gap: 8px; }
.import-steps li { line-height: 1.45; }
details.panel > summary { cursor: pointer; }
details.panel > summary h2 { display: inline; margin: 0; }
.explain { margin: 6px 0 0; color: var(--text-muted); font-size: 14px; line-height: 20px; max-width: 78ch; }
.help-block { display: grid; gap: 4px; }
.help-kicker { margin: 10px 0 0; font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--primary); }
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 1rem; color: var(--text-muted); font-size: 14px; }
.crumbs a { font-weight: 600; }
.money-form { margin: 0; }
.money-switch { display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 14px; border: 0; border-radius: 999px; background: white; box-shadow: 0 8px 20px rgba(22, 22, 22, 0.05); font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--text-main); cursor: pointer; }
.money-switch input { width: 16px; height: 16px; accent-color: #2f6b45; }
.share { display: inline-block; width: 72px; height: 8px; margin-right: 8px; border-radius: 9999px; background: #edf3ee; vertical-align: middle; overflow: hidden; }
.share i { display: block; height: 100%; background: linear-gradient(90deg, #2f6b45, var(--lime)); }
.pager .is-current { background: var(--lime); color: var(--charcoal); border-color: transparent; font-weight: 700; }
.chart-box.pie { height: 180px; width: 180px; margin: 0 auto; }
.chart-box canvas { display: block; width: 100% !important; height: 100% !important; }
.reading {
  padding: 1.2rem 1.35rem; margin: 0 0 1rem; font-size: 14px; line-height: 22px;
  border-left: 0; border-radius: 24px;
  background: linear-gradient(135deg, rgba(255,255,255,0.75), rgba(238,248,228,0.9));
  box-shadow: inset 0 0 0 1px rgba(196, 244, 93, 0.35);
}
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.metric { padding: 1.1rem 1.15rem 1rem; min-width: 0; position: relative; overflow: hidden; border-radius: 22px; }
.metric::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--lime); }
.metric:nth-child(2)::before { background: #2f6b45; }
.metric:nth-child(3)::before { background: #7cbc4a; }
.metric:nth-child(4)::before { background: #161616; }
.metric:nth-child(5)::before { background: #a8d63a; }
.metric span { display: block; color: var(--text-muted); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; font-family: var(--mono); }
.metric b { display: block; margin-top: 6px; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; word-break: break-word; font-family: var(--mono); }
.rank { width: 100%; border-collapse: collapse; }
.rank td { padding: 10px 0; border-bottom: 1px solid var(--surface-border); vertical-align: top; font-size: 14px; }
.rank td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }
.pie-card .spend-legend { margin-top: 8px; }
.chart-head, .chat-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 14px; flex-wrap: wrap; padding-bottom: 10px; border-bottom: 1px solid rgba(22, 22, 22, 0.05); }
.chart-head h2, .chat-head h2 { font-size: 17px; font-weight: 650; letter-spacing: -0.02em; }
.seg { display: inline-flex; padding: 4px; background: #edf3ee; border-radius: 9999px; gap: 2px; box-shadow: inset 0 1px 2px rgba(22, 22, 22, 0.04); }
.seg button { border: 0; background: transparent; border-radius: 9999px; padding: 8px 12px; cursor: pointer; font-size: 13px; font-weight: 500; min-height: 36px; color: var(--text-muted); transition: background .15s ease, color .15s ease; }
.seg button:hover { color: var(--charcoal); }
.seg button.is-on { background: var(--charcoal); color: var(--lime); box-shadow: 0 8px 18px rgba(22, 22, 22, 0.12); }
.chart-split { display: grid; grid-template-columns: 280px 1fr; gap: 18px; align-items: center; }
.spend-legend div { display: flex; gap: 8px; align-items: center; margin: 8px 0; font-size: 14px; }
.spend-legend i { width: 10px; height: 10px; border-radius: 9999px; flex: 0 0 10px; }
.spend-legend span { flex: 1; }

.is-chat .page-head { display: none; }
.is-chat .main { display: flex; flex-direction: column; height: calc(100vh - var(--header)); min-height: 0; padding: 0; overflow: hidden; background: #fff; }
.chat-shell { display: flex; flex-direction: column; flex: 1; min-height: 0; background: #fff; }
.chat-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 52px; min-height: 52px; padding: 0 16px 0 20px; background: #fff; border-bottom: 1px solid #d9f0e4; flex-wrap: nowrap; }
.chat-bar strong { font-size: 15px; font-weight: 600; white-space: nowrap; }
.chat-bar-actions { position: relative; display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.chat-history { position: static; }
.chat-history > summary { list-style: none; cursor: pointer; border: 1px solid #9fd9c0; background: #fff; color: #062c22; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; line-height: 1.2; }
.chat-history > summary::-webkit-details-marker { display: none; }
.chat-history > summary:focus-visible { outline: 2px solid #0a5c45; outline-offset: 2px; }
.chat-history[open] > summary { background: #e8f8f1; border-color: #0a5c45; }
.chat-history-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: min(340px, calc(100vw - 32px)); max-height: min(360px, 60vh); overflow: auto; background: #fff; border: 1px solid #9fd9c0; border-radius: 12px; box-shadow: 0 12px 32px rgba(4, 53, 40, 0.14); padding: 6px; }
.text-btn { border: 1px solid #9fd9c0; background: #fff; color: #062c22; font-weight: 600; font-size: 13px; cursor: pointer; border-radius: 999px; padding: 6px 12px; white-space: nowrap; line-height: 1.2; }
.text-btn:hover { background: #e8f8f1; }
.chat-stream { flex: 1; overflow: auto; padding: 12px 16px 8px; }
.chat-stream-inner { width: min(740px, 100%); min-height: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 26px; }
.chat-empty { display: flex; flex-direction: column; align-items: center; text-align: center; margin: auto; padding: 24px 12px; max-width: 640px; }
.chat-empty h2 { margin: 14px 0 8px; font-size: 26px; font-weight: 600; letter-spacing: -0.02em; color: #062c22; font-family: var(--display); }
.chat-empty p { margin: 0; color: #3d5c50; line-height: 1.55; font-size: 16px; max-width: 38rem; }
.assist-mark { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 999px; background: #161616; color: #c4f45d; flex: 0 0 28px; }
.chat-empty .assist-mark { width: 40px; height: 40px; flex-basis: 40px; }
.turn { display: flex; gap: 14px; align-items: flex-start; font-size: 16px; line-height: 1.75; color: #062c22; }
.turn.user { justify-content: flex-end; }
.turn.user .turn-body { max-width: min(34rem, 86%); background: #eef8e4; color: #161616; border-radius: 18px; padding: 10px 14px; white-space: pre-wrap; }
.turn.assistant .turn-body { flex: 1; min-width: 0; padding-top: 2px; color: #0a3d30; }
.turn-body p { margin: 0 0 12px; }
.turn-body p:last-of-type { margin-bottom: 0; }
.stream-text { white-space: pre-wrap; }
.caret { display: inline-block; width: 2px; height: 1.05em; margin-left: 2px; background: #0a5c45; vertical-align: text-bottom; animation: caret-blink 1s steps(1) infinite; }
@keyframes caret-blink { 50% { opacity: 0; } }
.thinking { display: inline-flex; gap: 5px; height: 28px; align-items: center; }
.thinking i { width: 7px; height: 7px; border-radius: 999px; background: #8e8e8e; animation: thinking 1.1s infinite ease-in-out; }
.thinking i:nth-child(2) { animation-delay: .15s; }
.thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes thinking { 0%, 80%, 100% { transform: translateY(0); opacity: .35; } 40% { transform: translateY(-3px); opacity: 1; } }
.turn-tools { display: flex; gap: 2px; margin-top: 6px; }
.icon-btn, .send { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 999px; border: 0; background: transparent; color: #062c22; cursor: pointer; }
.icon-btn:hover { background: #e8f8f1; }
.icon-btn.is-on, .icon-btn.is-speaking { background: #fee2e2; color: #b91c1c; }
.icon-btn.is-on { animation: mic-pulse 1.1s ease-out infinite; }
@keyframes mic-pulse { 0% { box-shadow: 0 0 0 0 rgba(185, 28, 28, 0.45); } 100% { box-shadow: 0 0 0 12px rgba(185, 28, 28, 0); } }
.listen-status { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0 0 8px; color: #b91c1c; font-size: 13px; font-weight: 600; }
.listen-status[hidden] { display: none; }
.listen-dot { width: 8px; height: 8px; border-radius: 999px; background: #dc2626; animation: mic-pulse 1.1s ease-out infinite; }
.send { background: #161616; color: #c4f45d; }
.send:hover, .send.is-stop { background: #000; }
.stream-prose { margin: 0; white-space: pre-wrap; }
.stream-caret { display: inline-block; width: 7px; height: 1em; margin-left: 3px; background: currentColor; opacity: 0.4; vertical-align: text-bottom; }
.chat-lines { margin: 10px 0 0; padding-left: 1.25em; }
.chat-lines li { margin: 4px 0; }
.chat-note { margin: 0; padding: 10px 12px; border-radius: 12px; background: #e8f8f1; color: #3d5c50; font-size: 13px; line-height: 1.45; }
.prompts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 22px; }
.prompts button { border: 1px solid #9fd9c0; background: #fff; border-radius: 999px; padding: 9px 14px; cursor: pointer; font-size: 14px; color: #062c22; }
.prompts button:hover { background: #e8f8f1; }
.composer { width: min(740px, calc(100% - 32px)); margin: 0 auto 18px; }
.composer-box { display: flex; flex-direction: column; gap: 6px; padding: 12px 12px 8px 16px; background: #fff; border: 1px solid rgba(22, 22, 22, 0.08); border-radius: 22px; box-shadow: 0 12px 28px rgba(22, 22, 22, 0.05); }
.composer-box:focus-within { border-color: transparent; outline: 2px solid #c4f45d; outline-offset: 2px; }
.composer textarea { width: 100%; min-height: 28px; max-height: 180px; border: 0; resize: none; padding: 6px 4px 0 0; background: transparent; line-height: 1.5; font-size: 16px; color: #062c22; }
.composer textarea:focus { outline: none; box-shadow: none; }
.composer-bar { display: flex; align-items: center; justify-content: space-between; }
.lang-pick select { height: 32px; border: 0; background: transparent; color: #3d5c50; font-size: 13px; padding: 0 4px 0 0; }
.composer-actions { display: flex; align-items: center; gap: 4px; }
.composer-note { margin: 8px 0 0; text-align: center; color: #5a7a6c; font-size: 12px; }
.chat-link { display: block; max-width: 100%; padding: 8px 10px; border-radius: 8px; color: #3d5c50; font-size: 13px; line-height: 1.35; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-link:hover { background: #e8f8f1; }
.chat-link.is-on { color: #062c22; font-weight: 600; background: #d9f0e4; }
.turn[dir="rtl"] .turn-body { font-family: "Noto Nastaliq Urdu", serif; line-height: 2.1; text-align: right; }
.turn.user[dir="rtl"] .turn-body { text-align: right; }
.chat-stat { margin: 12px 0; padding: 14px 16px; border-radius: 16px; background: #e8f8f1; max-width: 100%; }
.chat-stat span { display: block; color: #3d5c50; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; font-family: var(--font); }
.chat-stat strong { display: block; margin-top: 4px; font-size: 28px; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; font-family: "JetBrains Mono", ui-monospace, monospace; direction: ltr; text-align: left; }
.chat-chart { position: relative; width: 100%; max-width: 100%; margin: 12px 0; min-height: 220px; }
.chat-table-wrap { width: 100%; max-width: 100%; overflow-x: auto; margin: 12px 0; -webkit-overflow-scrolling: touch; }
.chat-table { width: 100%; border-collapse: collapse; font-size: 14px; direction: ltr; }
.chat-table th, .chat-table td { padding: 9px 10px; border-bottom: 1px solid #d9f0e4; text-align: left; white-space: nowrap; }
.chat-table th { color: #3d5c50; font-size: 12px; font-weight: 600; position: sticky; top: 0; background: #f3faf6; }
.chat-table td.num, .chat-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.follow-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.follow-chip:focus-visible, .clarify-chip:focus-visible, .reason-chip:focus-visible, .prompts button:focus-visible, .thumb:focus-visible, .reason-send:focus-visible, .text-btn:focus-visible, .send:focus-visible { outline: 2px solid #c4f45d; outline-offset: 2px; }
.follow-chip { border: 1px solid rgba(22, 22, 22, 0.08); background: #f7fbf8; border-radius: 999px; padding: 8px 12px; cursor: pointer; font-size: 14px; color: #2f6b45; max-width: 100%; text-align: start; }
.follow-chip:hover { background: #eef8e4; }
.clarify-chip { background: #fff; border-color: #c4f45d; color: #161616; font-weight: 600; }
.turn-feedback { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.thumb { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 1px solid transparent; border-radius: 999px; background: transparent; color: #3d5c50; cursor: pointer; }
.thumb:hover { background: #e8f8f1; }
.thumb.is-on { color: #161616; background: #eef8e4; border-color: #c4f45d; }
.feedback-reason { flex: 1 1 100%; display: grid; gap: 8px; margin-top: 4px; }
.feedback-reason[hidden] { display: none; }
.feedback-reason p { margin: 0; font-size: 14px; font-weight: 600; color: #062c22; }
.reason-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.reason-chip { border: 1px solid #9fd9c0; background: #fff; border-radius: 999px; padding: 6px 10px; cursor: pointer; font-size: 13px; color: #062c22; }
.reason-chip.is-on { border-color: #c4f45d; background: #eef8e4; }
.reason-label { display: grid; gap: 4px; font-size: 12px; color: #3d5c50; }
.reason-label input { border: 1px solid #9fd9c0; border-radius: 10px; padding: 8px 10px; font-size: 14px; color: #062c22; }
.reason-send { justify-self: start; border: 0; background: #161616; color: #c4f45d; border-radius: 999px; padding: 8px 14px; cursor: pointer; font-size: 14px; }
.feedback-thanks { font-size: 13px; color: #3d5c50; }
.chat-warn { margin: 8px 0 0; padding: 8px 10px; border-radius: 10px; background: #f3faf6; color: #3d5c50; font-size: 14px; border: 1px solid #9fd9c0; }
.turn.is-error .turn-body { color: #3f3f3f; }
.send:disabled, .composer textarea:disabled { opacity: 0.55; }
@media (max-width: 720px) {
  .chat-stream { padding: 12px 12px 8px; }
  .chat-stat strong { font-size: 22px; }
  .chat-bar { height: 52px; min-height: 52px; padding: 0 12px; align-items: center; flex-wrap: nowrap; }
  .composer { width: min(740px, calc(100% - 16px)); }
}

@media (max-width: 1100px) {
  .kpis, .stats, .chart-grid, .chart-split, .dash-grid, .dash-3, .metrics, .chart-trio, .reason-grid { grid-template-columns: 1fr 1fr; }
  .dash, .split, .help-grid, .login-body { grid-template-columns: 1fr; }
  .dash-3 .pie-card { grid-column: 1 / -1; }
  .login-side { display: none; }
  .login-card .budgetly-logo { display: flex; }
  .chart-box { height: 220px; }
  .chart-box.tall { height: 260px; }
  .chart-box.xl { height: 320px; }
}
@media (max-width: 860px) {
  .menu-btn { display: inline-flex; }
  .who, .scope-label small, .top-search { display: none; }
  .workspace { margin-left: 0; }
  .sidebar {
    width: min(256px, 88vw);
    transform: translateX(-105%);
    transition: transform .18s ease;
    border-radius: 0 24px 24px 0;
  }
  .nav-label, .nav-link span, .side-copy { display: initial; }
  .nav-link, .side-brand { justify-content: flex-start; }
  .nav-toggle:checked ~ .sidebar { transform: none; }
  .backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 40; display: none; }
  .nav-toggle:checked ~ .backdrop { display: block; }
  .main { padding: 1rem; }
  .page-head h1, .login-side h2, .login-card h1 { font-size: 24px; line-height: 32px; }
}
@media (max-width: 720px) {
  .composer { padding: 8px 10px 12px; }
  .turn.user .turn-body { max-width: 92%; }
  .dash-grid, .dash-3, .metrics, .chart-grid, .chart-trio, .kpis, .stats, .reason-grid { grid-template-columns: 1fr; }
  .chart-box.pie { width: 160px; height: 160px; }
  table.data td { height: 48px; }
}
@media (max-width: 640px) {
  .brand-copy { display: none; }
}
.follow-chip, .clarify-chip, .reason-chip { display: inline-flex; margin: 0 8px 8px 0; }
.work-status { margin: 8px 0 0; color: #3d5c50; font-size: 14px; }
.send.is-stop { width: auto; min-width: 72px; padding: 0 14px; background: #9b2c2c; color: #fff; font-weight: 600; }
.voice-lang select { height: 32px; border: 1px solid #9fd9c0; border-radius: 999px; background: #fff; color: #062c22; font-size: 13px; padding: 0 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.thumb.speak.is-on { color: #9b2c2c; background: #fde8e8; border-color: #e7c1c1; }
@media (max-width: 480px) {
  .composer { width: calc(100% - 16px); }
  .voice-lang select { max-width: 88px; }
  .turn-feedback { gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  .thinking i, .icon-btn.is-on, .listen-dot, .caret, .stream-caret { animation: none; }
}
@media print {
  .topbar, .sidebar, .backdrop, .filters, .filter-card, .help, .summary-card, .menu-btn, .report-actions, .tabs, .pager, .collapse-btn, .seg { display: none !important; }
  .workspace, .app, .main { display: block; margin: 0; padding: 0; }
  .report { border: 0; box-shadow: none; }
  body { background: white; }
}
