:root {
  --primary: #0F4C5C; --primary-h: #0B3A47; --primary-soft: #E3EFF1;
  --accent: #B8893B; --accent-soft: #F5EBD8;
  --bg: #F7F5F0; --surface: #FFFFFF; --line: #E2DED5; --ink: #14212B; --muted: #556570;
  --pos: #1E7A4F; --neg: #B3261E; --heat: #C2571A; --cool: #2E6FA3;
  --warn-ink: #7A4F00; --warn-bg: #FFF4D6;
  --r-3: #B3261E; --r-2: #E07A5F; --r-1: #F2C4A8; --r0: #E7E5E0; --r1: #B9DCC8; --r2: #5FAF86; --r3: #1E7A4F;
  --radius: 10px; --shadow: 0 1px 2px rgba(20,33,43,.05), 0 6px 18px rgba(20,33,43,.05);
  --font: "IBM Plex Sans", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --font-head: "IBM Plex Sans", "Noto Kufi Arabic", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10181C; --surface: #18232A; --line: #2A3840; --ink: #E8EEF0; --muted: #A3B3BA;
    --primary-soft: #1B3640; --accent-soft: #3A3020; --warn-bg: #3A3016; --warn-ink: #F3D58A; --r0: #3A4448;
  }
}
* { 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; }
html[lang="ar"] body { font-family: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, sans-serif; line-height: 1.7; }
html[lang="ar"] h1, html[lang="ar"] h2 { font-family: "Noto Kufi Arabic", "IBM Plex Sans Arabic", sans-serif; }
h1 { font-size: 28px; line-height: 1.25; margin: 0 0 8px; font-weight: 700; }
h2 { font-size: 20px; line-height: 1.35; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 16px; margin: 0 0 8px; font-weight: 600; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.skip:focus { width: auto; height: auto; clip-path: none; top: 12px; inset-inline-start: 12px; z-index: 5000; background: var(--surface); padding: 8px; }
html, body { overflow-x: hidden; }
.seg { direction: ltr; }
bdi.n { unicode-bidi: isolate; direction: ltr; }

button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--primary); background: var(--primary); color: #fff; padding: 8px 16px; font-weight: 500; }
button:hover { background: var(--primary-h); }
button.ghost { background: transparent; color: var(--primary); }
button.ghost:hover { background: var(--primary-soft); }
button.small { padding: 4px 10px; font-size: 13px; }
button.danger { border-color: var(--line); background: transparent; color: var(--neg); }
button.linkish { background: none; border: none; color: inherit; text-decoration: underline; padding: 0; font-weight: 600; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); width: 100%; }
label { display: block; font-weight: 600; margin: 12px 0 4px; font-size: 14px; }

.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 20px; background: var(--primary); color: #fff; position: sticky; top: 0; z-index: 1000; }
.brand { display: flex; align-items: baseline; gap: 8px; background: none; border: none; padding: 0; color: #fff; }
.logo { font-family: "Noto Kufi Arabic", sans-serif; font-weight: 700; font-size: 22px; }
.logo-en { font-weight: 700; font-size: 18px; letter-spacing: .3px; }
.demo-tag { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; background: var(--accent); color: #1B1300; padding: 2px 7px; border-radius: 99px; align-self: center; }
.tagline { opacity: .8; font-size: 13px; }
.spacer { flex: 1; }
.project-name { opacity: .9; font-size: 13px; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .lang, .topbar .menu-btn { background: transparent; border-color: rgba(255,255,255,.55); padding: 5px 12px; }
.menu-btn { display: none; }
.demo-banner { background: var(--warn-bg); color: var(--warn-ink); padding: 7px 20px; font-size: 13px; border-bottom: 1px solid #EAD9A6; }

.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; padding: 20px 24px 60px; max-width: 1440px; margin: 0 auto; align-items: start; }
.sidenav { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 2px; }
.sidenav .nh { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin: 14px 10px 4px; }
.sidenav a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; cursor: pointer; font-size: 14px; }
.sidenav a:hover { background: var(--primary-soft); }
.sidenav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.sidenav .dot { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; background: var(--r0); color: var(--ink); flex: none; }
.sidenav .dot.done { background: var(--pos); color: #fff; }
.sidenav a.active .dot { background: var(--primary); color: #fff; }
main { min-width: 0; outline: none; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.tight { padding: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.page-head { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.page-head > div:first-child { flex: 1; min-width: 260px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; background: var(--r0); font-size: 12.5px; }
.chip.grade-A { background: #D3ECDD; color: #12512F; } .chip.grade-B { background: #DCE8F5; color: #1D4A75; }
.chip.grade-C { background: #F5EBD8; color: #6B4A0E; } .chip.grade-E { background: #F3DCDA; color: #7C1F1A; }
.chip.st-committed { background: var(--primary-soft); color: var(--primary); } .chip.st-funded { background: #D3ECDD; color: #12512F; } .chip.st-aspirational { background: var(--accent-soft); color: #6B4A0E; }
.notice { background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: 10px 12px; font-size: 13.5px; }

/* stepper */
.stepper { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 18px; counter-reset: s; }
.stepper li { flex: 1; }
.stepper button { width: 100%; background: var(--surface); color: var(--ink); border: 1px solid var(--line); text-align: start; padding: 8px 12px; display: flex; gap: 8px; align-items: center; font-size: 13.5px; }
.stepper button .dot { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; background: var(--r0); flex: none; }
.stepper button.done .dot { background: var(--pos); color: #fff; }
.stepper button[aria-current="step"] { border-color: var(--primary); box-shadow: inset 0 -3px 0 var(--primary); font-weight: 600; }
.stepper button[aria-current="step"] .dot { background: var(--primary); color: #fff; }
.step-nav { display: flex; justify-content: space-between; margin-top: 8px; }

/* KPI strip */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); position: relative; }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; display: flex; gap: 6px; align-items: center; }
html[lang="ar"] .kpi .label { text-transform: none; letter-spacing: 0; font-size: 13px; }
.kpi .value { font-size: 28px; font-weight: 700; color: var(--primary); line-height: 1.2; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 14px; font-weight: 500; color: var(--muted); }
.kpi .sub { font-size: 12.5px; color: var(--muted); }
.info { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--muted); color: var(--muted); background: none; padding: 0; font-size: 11px; line-height: 1; display: inline-grid; place-items: center; }
.info:hover { background: var(--primary-soft); }
.rangebar { position: relative; height: 6px; background: var(--r0); border-radius: 99px; margin: 8px 0 4px; }
.rangebar span { position: absolute; top: 0; bottom: 0; background: #9DC3CC; border-radius: 99px; }
.rangebar i { position: absolute; top: -3px; width: 4px; height: 12px; background: var(--primary); border-radius: 2px; }
.scorebar { height: 6px; background: var(--r0); border-radius: 99px; margin-top: 8px; overflow: hidden; }
.scorebar span { display: block; height: 100%; background: var(--accent); }

/* hero */
.hero { background: linear-gradient(135deg, #0F4C5C 0%, #145F6E 60%, #1C6F6A 100%); color: #F4F1EA; border: none; padding: 36px; }
.hero .kicker { text-transform: uppercase; letter-spacing: 1.5px; font-size: 12px; color: #E9CF9B; font-weight: 600; }
html[lang="ar"] .hero .kicker { letter-spacing: 0; font-size: 13px; }
.hero h1 { font-size: 32px; max-width: 820px; margin: 8px 0 12px; color: #fff; }
.hero p { max-width: 780px; color: #D9E6E8; font-size: 16px; }
.hero .steps { display: flex; gap: 12px; flex-wrap: wrap; margin: 18px 0 22px; }
.hero .steps div { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); border-radius: 10px; padding: 10px 14px; display: flex; gap: 10px; align-items: center; }
.hero .steps b { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #1B1300; display: inline-grid; place-items: center; }
.hero button { background: var(--accent); border-color: var(--accent); color: #1B1300; font-weight: 600; }
.hero button.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.6); }
.hero .src { font-size: 12.5px; color: #B9CED2; margin-top: 16px; }
.entry { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.entry button { all: unset; cursor: pointer; display: block; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; background: var(--surface); }
.entry button:hover, .entry button:focus-visible { border-color: var(--primary); box-shadow: var(--shadow); }
.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.proj { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--surface); display: flex; flex-direction: column; gap: 8px; }
.proj h3 { margin: 0; }

/* rating control */
.seg { display: inline-grid; grid-template-columns: repeat(7, 34px); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: none; border-inline-end: 1px solid var(--line); border-radius: 0; background: var(--surface); color: var(--ink); padding: 0; height: 30px; font-size: 12.5px; font-weight: 500; position: relative; }
.seg button:last-child { border-inline-end: none; }
.seg button:hover { background: var(--primary-soft); }
.seg button[aria-checked="true"] { color: #fff; font-weight: 700; }
.seg button[aria-checked="true"][data-v="-3"] { background: var(--r-3); } .seg button[aria-checked="true"][data-v="-2"] { background: #C8553D; }
.seg button[aria-checked="true"][data-v="-1"] { background: #D98C6F; } .seg button[aria-checked="true"][data-v="0"] { background: #8A9196; }
.seg button[aria-checked="true"][data-v="1"] { background: #5FA37F; } .seg button[aria-checked="true"][data-v="2"] { background: #2F8A5C; }
.seg button[aria-checked="true"][data-v="3"] { background: var(--r3); }
.seg button.sugg::after { content: ""; position: absolute; inset: 2px; border: 2px dashed var(--cool); border-radius: 4px; pointer-events: none; }
.seg.small { grid-template-columns: repeat(7, 28px); } .seg.small button { height: 26px; font-size: 12px; }
.scale-legend { display: flex; gap: 14px; align-items: center; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.scale-legend i { display: inline-block; width: 14px; height: 10px; border-radius: 3px; vertical-align: middle; margin-inline-end: 4px; }
details.theme { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 10px; }
details.theme > summary { list-style: none; cursor: pointer; padding: 14px 18px; display: flex; gap: 12px; align-items: center; font-weight: 600; }
details.theme > summary::-webkit-details-marker { display: none; }
details.theme > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
html[dir="rtl"] details.theme > summary::before { content: "◂"; }
details.theme[open] > summary::before { transform: rotate(90deg); }
html[dir="rtl"] details.theme[open] > summary::before { transform: rotate(-90deg); }
.det { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; padding: 12px 18px; border-top: 1px solid var(--line); align-items: center; }
.det.off { opacity: .45; }
.det .name { font-weight: 600; } .det .prompt { color: var(--muted); font-size: 13px; }
.det .sg { font-size: 12.5px; color: var(--cool); margin-top: 3px; }
.det .ctl { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.toggle { font-size: 12.5px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; font-weight: 400; margin: 0; cursor: pointer; }
.toggle input { width: auto; }
.mini { height: 6px; width: 90px; background: var(--r0); border-radius: 99px; overflow: hidden; display: inline-block; }
.mini span { display: block; height: 100%; }

/* actions */
.action { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 12px; }
.action .head { display: flex; gap: 10px; align-items: center; padding: 14px 16px; flex-wrap: wrap; }
.action .head .title { flex: 1; min-width: 200px; font-weight: 600; }
.action .body { border-top: 1px solid var(--line); padding: 12px 16px 16px; }
.impact { display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.impact:last-child { border-bottom: none; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* results */
.summary { font-size: 17px; line-height: 1.6; }
.bars .b { display: grid; grid-template-columns: minmax(140px, 1.2fr) 2fr 110px; gap: 10px; align-items: center; padding: 6px 0; font-size: 14px; }
.bars .track { height: 10px; background: var(--r0); border-radius: 99px; position: relative; overflow: hidden; }
.bars .track span { position: absolute; inset-inline-start: 0; top: 0; bottom: 0; background: var(--primary); border-radius: 99px; }
.bars .track span.neg { background: var(--neg); }
.bars .v { text-align: end; font-variant-numeric: tabular-nums; }
details.sec { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 12px; }
details.sec > summary { list-style: none; cursor: pointer; padding: 16px 20px; font-weight: 600; font-size: 16px; display: flex; gap: 10px; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::after { content: "+"; margin-inline-start: auto; color: var(--muted); }
details.sec[open] > summary::after { content: "–"; }
details.sec > .inner { padding: 0 20px 20px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: start; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12.5px; color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--surface); }
td.n, th.n { text-align: end; font-variant-numeric: tabular-nums; }
tr.grp th { color: var(--primary); font-size: 13px; background: var(--primary-soft); }
.delta.pos { color: var(--pos); font-weight: 600; } .delta.neg { color: var(--neg); font-weight: 600; }
.tag-insufficient { color: var(--muted); font-style: italic; }
.chart-box { position: relative; height: 300px; } .chart-box.tall { height: 380px; }
.toggle-view { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.toggle-view button { border: none; border-radius: 0; background: var(--surface); color: var(--ink); padding: 7px 14px; }
.toggle-view button[aria-pressed="true"] { background: var(--primary); color: #fff; }
.clickable { cursor: pointer; text-decoration: underline dotted; background: none; border: none; color: inherit; padding: 0; font: inherit; text-align: start; }

/* map */
.map-wrap { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; }
#map { height: 600px; border-radius: var(--radius); border: 1px solid var(--line); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 13px; }
.legend label { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; margin: 0; cursor: pointer; }
.legend input { width: auto; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.reach { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.reach div { border-radius: 8px; padding: 10px; }
.reach .w { background: #E4EEF7; color: #173E5F; } .reach .s { background: #FBE6D8; color: #6E2E0A; }
.reach b { display: block; font-size: 22px; }
.basemap { filter: grayscale(.85) brightness(1.05) contrast(.92); }

.drawer { position: fixed; top: 0; inset-inline-end: 0; height: 100%; width: 460px; max-width: 94vw; background: var(--surface); border-inline-start: 1px solid var(--line); box-shadow: -6px 0 24px rgba(0,0,0,.14); padding: 24px; overflow: auto; z-index: 4000; visibility: hidden; transform: translateX(105%); transition: transform .2s; }
html[dir="rtl"] .drawer { transform: translateX(-105%); }
.drawer.open { visibility: visible; transform: none !important; }
.drawer .close { float: inline-end; }
.tour { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); width: min(560px, calc(100vw - 32px)); background: var(--surface); border: 2px solid var(--primary); border-radius: 14px; padding: 16px 18px; z-index: 3000; box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.tour h3 { margin: 4px 0 6px; color: var(--primary); } .tour p { margin: 0 0 12px; }
.tour-step { font-size: 12px; color: var(--muted); }

@media (max-width: 1100px) {
  .kpis, .grid4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid3, .map-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 12px 16px 60px; }
  .sidenav { display: none; position: static; }
  .sidenav.open { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
  .menu-btn { display: inline-block; }
  .tagline, .project-name, .logo-en { display: none; }
  .grid2, .entry, .det { grid-template-columns: 1fr; }
  .det .ctl { align-items: flex-start; }
  .stepper button span.lbl { display: none; }
  .hero { padding: 24px; } .hero h1 { font-size: 24px; }
  #map { height: 60vh; }
  .bars .b { grid-template-columns: 1fr 1.2fr 80px; }
  .kpi .value { font-size: 22px; }
}
@media print {
  .sidenav, .topbar, .demo-banner, .drawer, .no-print, .stepper, .step-nav, .tour { display: none !important; }
  .layout { grid-template-columns: 1fr; padding: 0; }
  details.sec { break-inside: avoid; } details.sec > .inner { display: block !important; }
  .card { box-shadow: none; }
}
