/* Khyber Pakhtunkhwa Youth Transitions dashboard
   Layout: a slim masthead with section tabs; one content column (max 1180px) of cards; two-column grids that stack
   below 820px. Colour: a civic blue accent on warm neutrals; chart series share one palette. */
:root {
  --bg: #f6f6f3; --surface: #fcfcfb; --surface-2: #f0efea; --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781; --grid: #e1e0d9; --line: #c3c2b7;
  --accent: #2a78d6; --accent-ink: #ffffff; --accent-soft: #e4eefb;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #6250d6;
  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #3987e5; --seq-5: #256abf; --seq-6: #184f95; --seq-7: #0d366b;
  --nocov: #e6e5df; --shadow: 0 1px 2px rgba(11, 11, 11, 0.06), 0 4px 14px rgba(11, 11, 11, 0.05);
  --chip-good-bg: rgba(12, 163, 12, 0.14); --chip-good-fg: #0a6b0a; --chip-warn-bg: rgba(250, 178, 25, 0.24); --chip-warn-fg: #7a5200; --chip-crit-bg: rgba(208, 59, 59, 0.16); --chip-crit-fg: #9c2727;
  --font-display: "IBM Plex Serif", Georgia, "Times New Roman", serif; --font-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif; --font-mono: "IBM Plex Mono", Menlo, Consolas, monospace;
  --radius: 6px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f0e; --surface: #1a1a19; --surface-2: #242423; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #8f8d86; --grid: #2c2c2a; --line: #383835;
    --accent: #3987e5; --accent-ink: #ffffff; --accent-soft: #1e2f45;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #9085e9;
    --seq-1: #1b2a3f; --seq-2: #1e3d63; --seq-3: #225088; --seq-4: #2a66ad; --seq-5: #3a7fd0; --seq-6: #6ea2e6; --seq-7: #a7c8f2;
    --nocov: #2a2a28; --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.35); --chip-good-bg: rgba(12, 163, 12, 0.22); --chip-good-fg: #7ddc7d; --chip-warn-bg: rgba(250, 178, 25, 0.22); --chip-warn-fg: #f3c664; --chip-crit-bg: rgba(208, 59, 59, 0.24); --chip-crit-fg: #f08686; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0f0e; --surface: #1a1a19; --surface-2: #242423; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #8f8d86; --grid: #2c2c2a; --line: #383835;
  --accent: #3987e5; --accent-ink: #ffffff; --accent-soft: #1e2f45;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #9085e9;
  --seq-1: #1b2a3f; --seq-2: #1e3d63; --seq-3: #225088; --seq-4: #2a66ad; --seq-5: #3a7fd0; --seq-6: #6ea2e6; --seq-7: #a7c8f2;
  --nocov: #2a2a28; --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.35); --chip-good-bg: rgba(12, 163, 12, 0.22); --chip-good-fg: #7ddc7d; --chip-warn-bg: rgba(250, 178, 25, 0.22); --chip-warn-fg: #f3c664; --chip-crit-bg: rgba(208, 59, 59, 0.24); --chip-crit-fg: #f08686; color-scheme: dark;
}
* { box-sizing: border-box; }
html { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; margin: 0; text-wrap: balance; }
h2 { font-size: 1.45rem; } h3 { font-size: 1.1rem; } h4 { font-size: 0.95rem; font-family: var(--font-body); font-weight: 600; }
p { margin: 0 0 0.75em; max-width: 72ch; }
.muted { color: var(--muted); } .small { font-size: 0.85rem; } .tnum { font-variant-numeric: tabular-nums; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* masthead */
.mast { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 9; background: var(--surface); border-bottom: 1px solid var(--grid); }
.mast-inner { max-width: 1180px; margin: 0 auto; padding-block: 10px 0; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 24px; }
.topband { background: #ffffff; border-bottom: 1px solid var(--grid); }
.topband-inner { max-width: 1180px; margin: 0 auto; padding-block: 8px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.brand { display: flex; flex-direction: column; gap: 2px; padding-bottom: 10px; min-width: 0; }
.brand .title { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; }
.brand .sub { font-size: 0.78rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.06em; }
.partners { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, 1fr); align-items: center; column-gap: 28px; }
.partners > * { min-width: 0; }
.partners img { display: block; width: auto; height: auto; max-width: 100%; }
.partners a.lg-left { display: block; line-height: 0; justify-self: start; max-width: 100%; }
.lg-left img { max-height: 56px; } .lg-centre { justify-self: center; max-height: 50px; } .lg-right { justify-self: end; max-height: 54px; }
@media (max-width: 820px) { .partners { column-gap: 16px; } .lg-left img { max-height: 44px; } .lg-centre { max-height: 40px; } .lg-right { max-height: 42px; } }
@media (max-width: 520px) { .partners { display: flex; justify-content: space-between; gap: 12px; } .partners > * { flex: 0 1 auto; } .partners a.lg-left { max-width: 31%; } .partners .lg-centre { max-width: 35%; } .partners .lg-right { max-width: 20%; max-height: 32px; } }
nav.tabs { display: flex; gap: 2px; flex-wrap: wrap; margin-left: auto; }
nav.tabs a { padding: 8px 12px 10px; border-bottom: 3px solid transparent; color: var(--ink-2); font-weight: 500; font-size: 0.92rem; border-radius: 4px 4px 0 0; }
nav.tabs a:hover { text-decoration: none; background: var(--surface-2); }
nav.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }
/* content */
main { max-width: 1180px; margin: 0 auto; padding-block: 20px 48px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.view[hidden] { display: none !important; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 14px; }
.section-head p { margin: 0; color: var(--ink-2); max-width: 80ch; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.map-split { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
@media (max-width: 820px) { .grid.cols-2, .grid.cols-3, .grid.cols-4, .grid.map-split { grid-template-columns: 1fr; } }
@media (min-width: 520px) and (max-width: 820px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.card { background: var(--surface); border: 1px solid var(--grid); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.card.flat { box-shadow: none; }
.card h3 { margin-bottom: 4px; }
.card .lead { color: var(--ink-2); font-size: 0.9rem; margin-bottom: 10px; }
.tile { background: var(--surface); border: 1px solid var(--grid); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile .label { font-size: 0.78rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.05em; }
.tile .value { font-size: 1.7rem; font-weight: 600; line-height: 1.15; font-family: var(--font-display); }
.tile .value small { font-size: 0.95rem; font-weight: 500; color: var(--ink-2); font-family: var(--font-body); }
.tile .note { font-size: 0.82rem; color: var(--muted); }
.tile.accent { border-color: var(--accent); background: var(--accent-soft); }
.chart { width: 100%; height: 340px; min-width: 0; }
.chart.tall { height: 440px; } .chart.short { height: 260px; } .chart.map { height: 520px; }
@media (max-width: 820px) { .chart.map { height: 420px; } .chart { height: 300px; } }
.controls { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; margin-bottom: 12px; }
.control { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.control label { font-size: 0.78rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.05em; }
select, input[type="number"] { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px; min-width: 150px; max-width: 100%; }
select.wide { min-width: 280px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.seg button { background: var(--surface); border: 0; padding: 6px 10px; cursor: pointer; color: var(--ink-2); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; padding: 6px 0; }
.btn { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 6px 10px; cursor: pointer; font-size: 0.88rem; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.range { display: flex; align-items: center; gap: 10px; }
.range input[type="range"] { width: 180px; max-width: 100%; accent-color: var(--accent); }
.range output { min-width: 3.5em; font-variant-numeric: tabular-nums; font-weight: 600; }
/* tables */
.tablewrap { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: 0.86rem; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
table.data th { background: var(--surface-2); color: var(--ink-2); font-weight: 600; text-align: right; position: sticky; top: 0; }
table.data th:first-child, table.data td:first-child { text-align: left; white-space: normal; min-width: 11em; }
table.data tr.group td { background: var(--surface-2); font-weight: 600; text-align: left; color: var(--ink-2); }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: var(--accent-soft); }
table.data tr.sel td { background: var(--accent-soft); }
.chip { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em; vertical-align: middle; }
.chip.f0 { background: var(--chip-good-bg); color: var(--chip-good-fg); } .chip.f1 { background: var(--chip-warn-bg); color: var(--chip-warn-fg); } .chip.f2 { background: var(--chip-crit-bg); color: var(--chip-crit-fg); } .chip.f3 { background: var(--surface-2); color: var(--muted); }
.chip.type1 { background: rgba(27, 175, 122, 0.18); color: inherit; } .chip.type2 { background: rgba(42, 120, 214, 0.18); } .chip.type3 { background: rgba(237, 161, 0, 0.22); } .chip.type4 { background: rgba(235, 104, 52, 0.2); }
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 0.8rem; font-weight: 600; }
.status i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.82rem; color: var(--ink-2); margin: 4px 0 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 10px; border-radius: 2px; display: inline-block; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 0.9rem; }
.kv dt { color: var(--ink-2); } .kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.bar { height: 10px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bar b { display: block; height: 100%; background: var(--accent); }
.domains { display: grid; grid-template-columns: 9em 1fr 3em; gap: 6px 10px; align-items: center; font-size: 0.88rem; }
.note { font-size: 0.82rem; color: var(--muted); margin-top: 8px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; margin: 6px 0; }
.toast { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 4px; font-size: 0.88rem; opacity: 0; transition: opacity 0.2s; pointer-events: none; }
.toast.show { opacity: 1; }
.district-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; }
.district-head h2 { font-size: 1.7rem; }
.crumb { font-size: 0.88rem; color: var(--ink-2); margin-bottom: 8px; }
.footer { max-width: 1180px; margin: 0 auto; padding-block: 18px 28px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); font-size: 0.82rem; color: var(--muted); border-top: 1px solid var(--grid); }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.keylist { display: grid; gap: 8px; } .keylist li { margin: 0; }
ul.plain { padding-left: 1.2em; margin: 0; } ul.plain li { margin-bottom: 4px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }


/* Directorate-first institutional identity and contact footer */
.topband { background: #fff; border-bottom: 1px solid #e7e2ec; }
.institution-row { display:flex; align-items:center; justify-content:space-between; gap:22px; min-height:94px; }
.directorate-brand { display:flex; align-items:center; gap:14px; min-width:0; color:#39245f; text-decoration:none; }
.directorate-brand:hover { text-decoration:none; }
.directorate-brand img { display:block; width:min(314px, 34vw); height:auto; max-height:76px; object-fit:contain; object-position:left center; }
.directorate-caption { display:flex; flex-direction:column; gap:3px; padding-left:14px; border-left:1px solid #ded8e8; line-height:1.25; }
.directorate-caption strong { color:#39245f; font-size:.76rem; letter-spacing:.035em; text-transform:uppercase; }
.directorate-caption span { color:#514568; font-size:.88rem; font-weight:600; }
.partner-block { display:flex; flex-direction:column; align-items:flex-end; gap:7px; }
.partner-heading { color:#716a7d; font-size:.68rem; font-weight:600; letter-spacing:.075em; text-transform:uppercase; }
.partner-logos { display:flex; align-items:center; gap:22px; }
.partner-item { display:flex; align-items:center; gap:8px; color:#514568; font-size:.76rem; font-weight:600; white-space:nowrap; }
.partner-item img { display:block; width:42px; height:42px; object-fit:contain; }
.partner-item:last-child img { width:58px; height:42px; }
.mast { background:#fff; }
.mast-inner { align-items:center; padding-top:12px; }
.brand { padding-bottom:10px; }
.brand .title { color:#30204f; }
.brand .sub { color:#514568; }
.brand .sub-detail { color:#77717e; font-size:.72rem; letter-spacing:.025em; margin-top:3px; }
.portal-home { display:inline-flex; align-items:center; justify-content:center; gap:6px; margin-left:auto; padding:9px 14px; border:1px solid #4b2c78; border-radius:5px; color:#ffffff; background:#4b2c78; font-size:.84rem; font-weight:600; white-space:nowrap; transition:background .18s ease, border-color .18s ease; }
.portal-home:hover { color:#ffffff; background:#0d9fa5; border-color:#0d9fa5; text-decoration:none; }
nav.tabs { margin-left:0; }
nav.tabs a.active { border-bottom-color:#43296d; }
.footer { color:#625d69; border-top:1px solid #ddd7e5; }
.footer-intro { display:flex; flex-direction:column; gap:4px; padding-bottom:16px; margin-bottom:16px; border-bottom:1px solid var(--grid); }
.footer-intro strong { color:#39245f; font-family:var(--font-display); font-size:1.05rem; }
.footer-contacts { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
.footer-contact { background:var(--surface); border:1px solid var(--grid); border-radius:6px; padding:14px 16px; min-width:0; }
.footer-contact h3 { color:#39245f; margin-bottom:8px; font-size:.95rem; }
.footer-contact p { margin-bottom:8px; }
.footer-contact p:last-child { margin-bottom:0; }
.footer-bottom { margin-top:16px; padding-top:12px; border-top:1px solid var(--grid); font-size:.76rem; }
@media (max-width:900px) {
  .institution-row { align-items:flex-start; flex-direction:column; padding-block:12px; gap:10px; }
  .directorate-brand img { width:min(290px,58vw); }
  .partner-block { align-items:flex-start; width:100%; }
  .partner-logos { gap:18px; }
  .mast-inner { align-items:flex-start; }
  .portal-home { margin-left:0; }
  nav.tabs { margin-left:0; width:100%; }
}
@media (max-width:600px) {
  .directorate-brand { gap:8px; }
  .directorate-brand img { width:48vw; max-height:58px; }
  .directorate-caption { padding-left:8px; }
  .directorate-caption strong { font-size:.61rem; }
  .directorate-caption span { font-size:.72rem; }
  .partner-heading { font-size:.61rem; }
  .partner-item { font-size:.68rem; white-space:normal; }
  .partner-item img { width:34px; height:34px; }
  .partner-item:last-child img { width:48px; height:34px; }
  .brand .title { font-size:1.12rem; }
  .brand .sub { font-size:.7rem; }
  .brand .sub-detail { font-size:.66rem; }
  nav.tabs a { padding:7px 9px 8px; font-size:.82rem; }
  .footer-contacts { grid-template-columns:1fr; }
}
