/* ==========================================================================
   Design tokens
   ========================================================================== */
:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #f1f3f6;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #344054;
  --muted: #667085;
  --primary: #1e40af;
  --primary-hover: #1e3a8a;
  --primary-soft: #eef2ff;
  --on-primary: #ffffff;

  --dot-green: #16a34a;
  --dot-blue: #2563eb;
  --dot-amber: #d97706;
  --dot-gray: #98a2b3;

  --s1-bg: #fde3e1; --s1-fg: #b42318;
  --s2-bg: #feead2; --s2-fg: #b54708;
  --s3-bg: #fdf3c4; --s3-fg: #854a0e;
  --s4-bg: #d9f5e3; --s4-fg: #067647;
  --s5-bg: #0e8a4f; --s5-fg: #ffffff;

  --pdf-bg: #e4e7ec;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --font: "Inter", "Noto Sans Khmer", system-ui, -apple-system, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1117;
  --surface: #161b22;
  --surface-2: #1b2129;
  --surface-3: #212833;
  --border: #2a313c;
  --border-strong: #3a4350;
  --text: #e6edf3;
  --text-2: #c3cbd5;
  --muted: #8b949e;
  --primary: #7aa2ff;
  --primary-hover: #9bb9ff;
  --primary-soft: #1b2540;
  --on-primary: #0e1117;

  --dot-green: #3fb950;
  --dot-blue: #58a6ff;
  --dot-amber: #e3b341;
  --dot-gray: #6e7681;

  --s1-bg: #4a1a17; --s1-fg: #ffb4ab;
  --s2-bg: #4a2a0c; --s2-fg: #ffc98a;
  --s3-bg: #43380c; --s3-fg: #f5dc7a;
  --s4-bg: #11402a; --s4-fg: #8ee3b0;
  --s5-bg: #1fa463; --s5-fg: #ffffff;
  --pdf-bg: #0a0d12;
  --shadow: none;
}

/* ==========================================================================
   Base
   ========================================================================== */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img { max-width: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.3; color: var(--text); }
a { color: var(--primary); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.container { max-width: 1280px; margin: 0 auto; padding: 0 32px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ==========================================================================
   App bar (brand · tabs · actions) and page title
   ========================================================================== */
.app-bar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .app-bar {
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(12px); backdrop-filter: saturate(180%) blur(12px);
  }
}
.app-bar-inner {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 24px;
  min-height: 64px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--text); text-decoration: none; font-weight: 700; white-space: nowrap; }
.brand-photo {
  width: 38px; height: 38px; flex: none; border-radius: 50%;
  object-fit: cover; object-position: top; border: 2px solid var(--primary-soft);
}
.brand span:last-child { min-width: 0; line-height: 1.25; }
.brand small { display: block; overflow: hidden; text-overflow: ellipsis; font-size: 12px; font-weight: 500; color: var(--muted); line-height: 1.3; }

.tabs {
  display: flex; gap: 2px; min-width: 0; overflow-x: auto; align-self: stretch;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.nav-link {
  display: flex; align-items: center; gap: 4px; padding: 0 12px;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14.5px; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.nav-link:hover { color: var(--text); border-bottom-color: var(--border-strong); }
.nav-link[aria-current="page"] { color: var(--primary); border-bottom-color: var(--primary); }
.nav-external { margin-left: 6px; padding-left: 16px; position: relative; }
.nav-external::before {
  content: ""; position: absolute; left: 0; top: 50%; width: 1px; height: 18px; margin-top: -9px; background: var(--border-strong);
}
.nav-ext-ico { width: 13px; height: 13px; flex: none; opacity: .8; }

.header-actions { display: flex; gap: 8px; align-items: center; }

.page-title { padding: 32px 0 8px; }
.doc-page .page-title .container { max-width: calc(880px + 64px); } /* line up with the document below */
.eyebrow { margin: 0 0 4px; color: var(--primary); font-size: 14px; font-weight: 600; }
.page-title h1 { font-size: 28px; font-weight: 700; letter-spacing: -.01em; }
.subtitle { margin: 6px 0 0; color: var(--muted); font-size: 15px; }

/* ==========================================================================
   Buttons & inputs
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 8px; border: 1px solid transparent;
  font: 600 14px var(--font); cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-3); color: var(--text); }
.btn-icon { width: 40px; height: 40px; padding: 0; background: var(--surface); color: var(--muted); border-color: var(--border-strong); border-radius: 10px; }
.btn-icon:hover { background: var(--surface-3); color: var(--text); }
.btn-icon svg { width: 18px; height: 18px; }
.btn:disabled { opacity: .6; cursor: progress; }

/* Export buttons: one joined group with file-type icons */
.export-group {
  display: inline-flex; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow);
}
.btn-export {
  height: 38px; padding: 0 16px 0 12px; gap: 8px;
  border: 0; border-radius: 0; background: transparent; color: var(--text); font-weight: 600;
}
.btn-export + .btn-export { border-left: 1px solid var(--border-strong); }
.btn-export:hover { background: var(--surface-3); }
.btn-export:active { background: var(--border); }
.btn-export:focus-visible { outline-offset: -3px; }
.btn-ico { width: 20px; height: 20px; flex: none; }
.btn:focus-visible, .nav-link:focus-visible, .input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.input {
  height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text); font: 14.5px var(--font);
}
.toolbar { display: grid; grid-template-columns: 1fr 240px; gap: 12px; margin-bottom: 14px; }

/* ==========================================================================
   Sections
   ========================================================================== */
.block { margin-bottom: 36px; }
.block-head { margin-bottom: 14px; }
.block-head h2 { font-size: 19px; font-weight: 700; }
.block-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

/* ==========================================================================
   KPI page — profile & summary
   ========================================================================== */
.profile {
  margin: 20px 0 16px; padding: 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 32px; align-items: start;
}
.profile-main { display: flex; gap: 18px; align-items: center; }
.avatar {
  border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 700;
}
.avatar-lg { width: 72px; height: 72px; font-size: 22px; }
img.avatar { object-fit: cover; object-position: top; border: 1px solid var(--border); }
.profile-name { font-size: 21px; font-weight: 700; }
.profile-position { color: var(--text-2); }
.profile-summary { margin: 16px 0 0; color: var(--text-2); }
.facts { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; padding-left: 32px; border-left: 1px solid var(--border); }
.facts dt { color: var(--muted); font-size: 13.5px; }
.facts dd { margin: 1px 0 0; font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 36px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.stat-label { color: var(--muted); font-size: 14px; font-weight: 500; }
.stat-value { font-size: 30px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; line-height: 1.3; }
.stat-value small { font-size: 15px; font-weight: 500; color: var(--muted); }
.stat-sub { color: var(--text-2); font-size: 13.5px; margin-top: 2px; }

/* List panel (responsibilities, growth) */
.resp-list, .growth-list {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.resp, .growth { display: flex; gap: 16px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.resp:last-of-type, .growth:last-child { border-bottom: 0; }
.resp-num {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 13px;
}
.resp-body { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 4px 32px; }
.resp-head { display: contents; }
.resp-head h3 { font-size: 16px; font-weight: 600; grid-column: 1; }
.resp-pct { grid-column: 2; grid-row: 1; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.resp-body .bar { grid-column: 2; grid-row: 2; align-self: start; margin-top: 6px; }
.resp-body p { grid-column: 1; margin: 0; color: var(--text-2); font-size: 14.5px; }
.resp-body .tags { grid-column: 1; }
.resp-total { margin: 0; padding: 12px 22px; text-align: right; background: var(--surface-2); border-top: 1px solid var(--border); font-size: 14px; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { padding: 2px 9px; border-radius: 6px; background: var(--surface-3); font-size: 13px; color: var(--text-2); }
.bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: var(--primary); }

.growth-icon {
  flex: none; width: 30px; height: 30px; padding: 6px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
}
.growth h3 { font-size: 16px; font-weight: 600; }
.growth p { margin: 2px 0 0; color: var(--text-2); font-size: 14.5px; }

/* Ratings & scores */
.rating { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.score {
  display: inline-grid; place-items: center;
  min-width: 36px; height: 32px; padding: 0 8px; border-radius: 8px;
  font-weight: 700; font-variant-numeric: tabular-nums;
}
.score.na { color: var(--muted); font-weight: 500; background: var(--surface-3); }
.s1 { background: var(--s1-bg); color: var(--s1-fg); }
.s2 { background: var(--s2-bg); color: var(--s2-fg); }
.s3 { background: var(--s3-bg); color: var(--s3-fg); }
.s4 { background: var(--s4-bg); color: var(--s4-fg); }
.s5 { background: var(--s5-bg); color: var(--s5-fg); }

/* ==========================================================================
   KPI table
   ========================================================================== */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow-x: auto; box-shadow: var(--shadow);
}
.kpi-table { width: 100%; border-collapse: collapse; min-width: 760px; font-size: 14.5px; }
.kpi-table th, .kpi-table td { border-bottom: 1px solid var(--border); padding: 14px 16px; vertical-align: top; text-align: left; }
.kpi-table thead th { background: var(--surface-2); color: var(--muted); font-size: 13.5px; font-weight: 600; }
.kpi-table th.center { text-align: center; }
.kpi-table tbody tr:hover td:not(.project-cell) { background: var(--surface-2); }
.kpi-table td.score-cell { text-align: center; vertical-align: middle; width: 160px; }
.kpi-table td.role-cell { width: 230px; color: var(--text-2); }
.role-cell .tags { margin-top: 6px; }
.release-to { margin-top: 6px; font-size: 13.5px; }
.score-label { margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.score-cell .num { font-weight: 700; font-variant-numeric: tabular-nums; margin-right: 6px; }

.project-cell { width: 200px; border-right: 1px solid var(--border); background: var(--surface-2); }
.project-name { font-weight: 700; font-size: 15.5px; }
.project-desc { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.project-avg { margin-top: 12px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.project-avg .num { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.project-avg .lbl { font-size: 13px; color: var(--muted); }

.feature-title { font-weight: 600; }
.feature-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; font-size: 13px; color: var(--muted); }
.feature-desc { margin-top: 6px; color: var(--text-2); max-width: 720px; }

/* Status: neutral label with a coloured dot */
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; color: var(--text-2); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--dot-gray); }
.status.released::before, .status.live::before { background: var(--dot-green); }
.status.in-progress::before, .status.maintenance::before { background: var(--dot-blue); }
.status.staging::before, .status.planned::before { background: var(--dot-amber); }

.kpi-table tfoot td { background: var(--surface-2); font-weight: 700; border-bottom: 0; }
.empty { text-align: center; padding: 24px; }

/* Scoring guide */
.rubric { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.rubric-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; gap: 12px; }
.rubric-item .score { flex: none; }
.rubric-item strong { display: block; font-size: 14.5px; }
.rubric-item p { margin: 2px 0 0; color: var(--text-2); font-size: 13.5px; }

/* ==========================================================================
   Staff profile & job description (Word-style document)
   ========================================================================== */
.doc {
  max-width: 880px; margin: 20px auto 48px; padding: 56px 64px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px; box-shadow: var(--shadow);
  font-family: Calibri, Carlito, "Segoe UI", "Inter", "Noto Sans Khmer", sans-serif;
  font-size: 15px; line-height: 1.5; color: var(--text);
}
.doc p { margin: 0; }
.doc strong { font-weight: 700; }
.doc a { color: inherit; }
.doc-part-break { margin-top: 56px; padding-top: 48px; border-top: 1px dashed var(--border-strong); }
.doc-title { text-align: center; font-size: 20px; font-weight: 700; margin-bottom: 18px; }
.doc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.doc-gap { margin-top: 14px !important; }
.doc-photo { width: 112px; height: 142px; flex: none; object-fit: cover; object-position: top; border: 1px solid var(--primary); }
.doc-rule { border: 0; border-top: 1.5px solid var(--primary); margin: 14px 0 6px; }
.doc-h { font-size: 15px; font-weight: 700; margin: 18px 0 6px; break-after: avoid; }
.doc-p { margin-bottom: 8px !important; }
.doc-justify { text-align: justify; }
.doc .i1 { margin-left: 24px; }
.doc .i2 { margin-left: 48px; }
.doc-list { margin: 4px 0 8px; padding-left: 24px; }
.doc-list.i1 { margin-left: 24px; }
.doc-list.i2 { margin-left: 48px; }
.doc-list li { margin: 3px 0; padding-left: 4px; }
.doc-list li::marker { color: var(--text); }
.doc-lines { margin-bottom: 8px; }
.doc-info { border-collapse: collapse; margin-bottom: 4px; }
.doc-info th { text-align: left; font-weight: 700; padding: 2px 16px 2px 0; white-space: nowrap; vertical-align: top; }
.doc-info td { padding: 2px 0; }
.doc-info td::before { content: ": "; }

/* Resume */
.rs-head { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.rs-name { font-size: 30px; font-weight: 700; line-height: 1.15; letter-spacing: -.01em; }
.rs-headline { margin-top: 4px !important; font-size: 17px; font-weight: 700; color: var(--primary); }
.rs-focus { color: var(--muted); }
.rs-contacts { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px 22px; color: var(--text-2); }
.rs-contacts a { text-decoration: none; }
.rs-contacts a:hover { color: var(--primary); text-decoration: underline; }
.rs-target { margin-top: 14px !important; padding: 8px 12px; background: var(--primary-soft); border-left: 3px solid var(--primary); }
.rs-section {
  margin: 22px 0 8px; padding-bottom: 3px; border-bottom: 1.5px solid var(--primary);
  color: var(--primary); font-size: 14px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; break-after: avoid;
}
.rs-highlights { color: var(--text-2); }
.rs-entry { margin-top: 10px; break-inside: avoid; break-after: avoid; }
.rs-entry-top { display: flex; justify-content: space-between; gap: 16px; }
.rs-entry-top span { color: var(--muted); white-space: nowrap; }
.rs-org { color: var(--muted); font-style: italic; }
.rs-entry + .doc-list { margin-top: 4px; }
.doc-compact { margin-bottom: 3px !important; }
.doc-table-wrap { overflow-x: auto; margin: 8px 0 4px 24px; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.doc-table th, .doc-table td { border: 1px solid var(--border-strong); padding: 6px 10px; text-align: left; vertical-align: top; }
.doc-table th { background: var(--primary-soft); font-weight: 700; }
.doc-table td:first-child { white-space: nowrap; }
.doc-source { margin: 6px 0 4px 24px !important; font-size: 13.5px; font-style: italic; color: var(--muted); }
.doc-source a { color: var(--primary); font-style: normal; }
.doc-cols-2 { columns: 2; column-gap: 32px; }
.doc-cols-2 li { break-inside: avoid; }

/* ==========================================================================
   Document / PDF preview switch and PDF viewer
   ========================================================================== */
.page-title-inner { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }

.segmented {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 10px;
}
.segmented button {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px;
  border: 0; border-radius: 7px; background: transparent; color: var(--muted);
  font: 600 13.5px var(--font); white-space: nowrap; cursor: pointer;
  transition: background .15s, color .15s;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .14); }
.segmented button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.segmented svg { width: 16px; height: 16px; flex: none; }

@media screen {
  .pdf-mode .doc { display: none; }
  .pdf-mode .page-title .container { max-width: 1280px; } /* line up with the wider viewer */
}
.pdf-view { margin: 20px 0 48px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--pdf-bg); }
.pdf-toolbar {
  position: sticky; top: var(--bar-h, 64px); z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 10px 14px;
  background: var(--surface); border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0;
}
.pdf-zoom { display: inline-flex; overflow: hidden; border: 1px solid var(--border-strong); border-radius: 8px; }
.btn-tool {
  height: 32px; min-width: 36px; padding: 0 10px; border: 0;
  background: var(--surface); color: var(--text-2); font: 600 15px var(--font); font-variant-numeric: tabular-nums; cursor: pointer;
}
.btn-tool + .btn-tool { border-left: 1px solid var(--border-strong); }
.btn-tool:hover { background: var(--surface-3); color: var(--text); }
.btn-tool:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.pdf-zoom-label { min-width: 64px; font-size: 13.5px; }
.pdf-page-info { margin-left: auto; color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
#pdf-download .btn-ico { width: 18px; height: 18px; }

.pdf-sidebar-toggle { display: inline-grid; place-items: center; border: 1px solid var(--border-strong); border-radius: 8px; }
.pdf-sidebar-toggle svg { width: 18px; height: 18px; }
.pdf-sidebar-toggle[aria-expanded="true"] { background: var(--primary-soft); color: var(--primary); }

/* Page thumbnails: a sticky column beside the pages, scrolling on its own */
.pdf-body { display: grid; grid-template-columns: 164px minmax(0, 1fr); }
.thumbs-collapsed .pdf-body { grid-template-columns: minmax(0, 1fr); }
.thumbs-collapsed .pdf-thumbs { display: none; }
.pdf-thumbs {
  position: sticky; top: calc(var(--bar-h, 64px) + var(--pdf-toolbar-h, 53px)); align-self: start;
  max-height: calc(100vh - var(--bar-h, 64px) - var(--pdf-toolbar-h, 53px));
  display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 18px 10px;
  overflow-y: auto; scrollbar-width: thin;
  background: var(--surface-2); border-right: 1px solid var(--border);
}
.pdf-thumb {
  display: flex; flex-direction: column; align-items: center; gap: 6px; flex: none; padding: 6px;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted);
  font: 600 12px var(--font); font-variant-numeric: tabular-nums; cursor: pointer;
}
.pdf-thumb canvas { display: block; width: 120px; height: auto; background: #fff; border-radius: 2px; box-shadow: 0 0 0 1px var(--border-strong), 0 2px 6px rgba(0, 0, 0, .08); }
.pdf-thumb:hover { background: var(--surface-3); color: var(--text); }
.pdf-thumb[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.pdf-thumb[aria-current="page"] canvas { box-shadow: 0 0 0 2px var(--primary); }
.pdf-thumb:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

.pdf-stage { position: relative; min-height: 60vh; padding: 28px 24px 36px; overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }
.pdf-view:not(.thumbs-collapsed) .pdf-stage { border-bottom-left-radius: 0; }
.pdf-status { margin: 48px 0; text-align: center; color: var(--muted); }
/* max-content + auto margins centre the pages, and still allow scrolling sideways when zoomed in */
.pdf-pages { display: grid; grid-template-columns: var(--page-w, 794px); gap: 24px; width: max-content; margin: 0 auto; }
.pdf-pages.spread { grid-template-columns: repeat(2, var(--page-w, 560px)); gap: 24px 20px; }
.pdf-page { position: relative; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 10px 28px rgba(0, 0, 0, .10); }
.pdf-page canvas { display: block; width: 100%; height: 100%; }

/* ==========================================================================
   Misc
   ========================================================================== */
.load-error { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-top: 24px; max-width: 760px; }
.load-error h2 { font-size: 18px; margin-bottom: 8px; }
.page-footer { color: var(--muted); font-size: 13px; padding-top: 4px; padding-bottom: 40px; }

.signatures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; margin-top: 20px; }
.sig { padding-top: 40px; border-bottom: 1px solid #000; }
.sig-label { margin-top: 6px; font-size: 12px; }
.print-only { display: none; }

/* ==========================================================================
   Responsive
   ========================================================================== */
/* Screen only, so these never change the printed / PDF layout. */

/* Tablets: tabs move to their own scrollable row */
@media screen and (max-width: 1000px) {
  .app-bar-inner { grid-template-columns: minmax(0, 1fr) auto; gap: 0 16px; min-height: 60px; }
  .tabs {
    grid-column: 1 / -1; grid-row: 2; height: 46px; margin: 0 -12px; padding: 0 28px 0 4px;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }
}

/* Tablets and small laptops */
@media screen and (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rubric { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile { grid-template-columns: 1fr; gap: 20px; }
  .facts { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 20px 0 0; border-left: 0; border-top: 1px solid var(--border); }
}

/* KPI table becomes one card per project */
@media screen and (max-width: 900px) {
  .table-wrap { overflow: visible; background: none; border: 0; border-radius: 0; box-shadow: none; }
  .kpi-table { display: block; min-width: 0; }
  .kpi-table thead { display: none; }
  .kpi-table tbody, .kpi-table tfoot {
    display: block; margin-bottom: 12px; overflow: hidden;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  }
  .kpi-table tr { display: block; }
  .kpi-table tbody tr + tr { border-top: 1px solid var(--border); }
  .kpi-table th, .kpi-table td { display: block; width: auto !important; border: 0; padding: 12px 18px 0; }
  .kpi-table td:last-child { padding-bottom: 16px; }
  .kpi-table tbody tr:hover td:not(.project-cell) { background: none; }
  .kpi-table td[data-label]::before {
    content: attr(data-label); display: block; margin-bottom: 4px;
    color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  }
  .kpi-table td.project-cell { padding: 14px 18px; border-bottom: 1px solid var(--border); }
  .project-avg { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 8px; }
  .project-avg .num { font-size: 18px; }
  .kpi-table td.score-cell { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; text-align: left; }
  .kpi-table td.score-cell::before { flex-basis: 100%; margin-bottom: 0; }
  .kpi-table td.score-cell .score-label { margin-top: 0; }
  .kpi-table tfoot tr { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
  .kpi-table tfoot td { padding: 14px 18px !important; }
}

/* Phones */
@media screen and (max-width: 720px) {
  body { font-size: 14.5px; }
  .container { padding: 0 16px; }
  .tabs { margin: 0 -16px; padding: 0 28px 0 8px; }
  .nav-link { padding: 0 10px; font-size: 14px; }
  .page-title { padding: 22px 0 4px; }
  .page-title h1 { font-size: 22px; }
  .subtitle { font-size: 14px; }
  .block { margin-bottom: 28px; }
  .block-head h2 { font-size: 18px; }

  .profile { margin-top: 14px; padding: 18px; }
  .avatar-lg { width: 60px; height: 60px; }
  .profile-name { font-size: 19px; }
  .profile-summary { margin-top: 12px; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
  .facts dt { font-size: 12.5px; }
  .stats { gap: 10px; margin-bottom: 28px; }
  .stat { padding: 14px 16px; }
  .stat-value { font-size: 24px; }
  .stat-label { font-size: 13px; }
  .stat-sub { font-size: 12.5px; }

  .resp, .growth { padding: 16px; gap: 12px; }
  .resp-body { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; }
  .resp-head h3 { grid-column: 1; }
  .resp-pct { grid-column: 2; grid-row: 1; }
  .resp-body .bar { grid-column: 1 / -1; grid-row: 2; margin-top: 0; }
  .resp-body p, .resp-body .tags { grid-column: 1 / -1; }
  .resp-total { padding: 12px 16px; }
  .rubric, .toolbar { grid-template-columns: 1fr; }
  .rubric-item { padding: 14px; }

  /* Documents go edge to edge, like a page in a reading app */
  .doc { margin: 12px -16px 32px; padding: 24px 18px; border-left: 0; border-right: 0; border-radius: 0; font-size: 14.5px; }
  .doc-part-break { margin-top: 36px; padding-top: 32px; }
  .doc-title { font-size: 18px; }
  .doc-top { flex-direction: column-reverse; gap: 16px; }
  .doc-photo { width: 96px; height: 122px; }
  .rs-head { flex-direction: column-reverse; align-items: flex-start; gap: 16px; }
  .rs-entry-top { flex-direction: column; gap: 0; }
  .rs-entry-top span { white-space: normal; }
  .rs-name { font-size: 25px; }
  .rs-contacts { flex-direction: column; gap: 2px; }
  .doc-cols-2 { columns: 1; }
  .doc-table-wrap, .doc-source { margin-left: 0 !important; }
  .doc .i1, .doc-list.i1 { margin-left: 4px; }
  .doc .i2, .doc-list.i2 { margin-left: 12px; }
  .doc-list { padding-left: 20px; }
  .doc-justify { text-align: left; }

  /* Details table: label above value */
  .doc-info, .doc-info tbody, .doc-info tr, .doc-info th, .doc-info td { display: block; }
  .doc-info tr + tr { margin-top: 8px; }
  .doc-info th { padding: 0; color: var(--muted); font-size: 12.5px; font-weight: 600; white-space: normal; }
  .doc-info td { padding: 0; font-weight: 600; }
  .doc-info td::before { content: none; }

  /* Data tables: one card per row, column name beside each value */
  .doc-table-wrap { overflow: visible; }
  .doc-table, .doc-table tbody, .doc-table tr, .doc-table td { display: block; }
  .doc-table thead { display: none; }
  .doc-table tr { padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 8px; break-inside: avoid; }
  .doc-table tr + tr { margin-top: 8px; }
  .doc-table td, .doc-table td:first-child {
    display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 10px;
    padding: 2px 0; border: 0; white-space: normal;
  }
  .doc-table td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; font-weight: 600; padding-top: 1px; }

  /* Document / PDF preview */
  /* Page actions stack under the title, full width */
  .page-actions { width: 100%; }
  .page-actions .view-switch, .page-actions .export-group { display: flex; flex: 1 1 100%; }
  .view-switch button, .page-actions .btn-export { flex: 1; justify-content: center; }
  .pdf-view { margin: 12px -16px 32px; border-left: 0; border-right: 0; border-radius: 0; }
  .pdf-toolbar { gap: 8px 10px; padding: 10px 12px; border-radius: 0; }
  .pdf-toolbar .segmented button { padding: 0 10px; }
  .pdf-page-info { flex: 1; font-size: 13px; }
  #pdf-download { height: 34px; padding: 0 12px; }
  .pdf-stage { padding: 16px 12px 24px; border-radius: 0; }
  /* Thumbnails become a strip above the pages that scrolls sideways */
  .pdf-body { display: block; }
  .pdf-thumbs {
    position: static; max-height: none; flex-direction: row; align-items: flex-start; gap: 6px;
    padding: 8px 12px; overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid var(--border);
  }
  .pdf-thumb { padding: 4px; gap: 4px; }
  .pdf-thumb canvas { width: 60px; }
  .pdf-pages { gap: 14px; }
  .pdf-pages.spread { gap: 14px 8px; }
}

/* Small phones */
@media screen and (max-width: 420px) {
  .brand-photo { width: 34px; height: 34px; }
  .header-actions { gap: 6px; }
  .btn-icon { width: 38px; height: 38px; }
  .facts { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 22px; }
  #pdf-download { font-size: 13px; }
  .pdf-toolbar .segmented svg { display: none; }
}

/* ==========================================================================
   Print / PDF (always light)
   ========================================================================== */
@page { size: A4 landscape; margin: 12mm; }
@media print {
  :root, :root[data-theme] {
    color-scheme: light;
    --bg: #fff; --surface: #fff; --surface-2: #f5f6f8; --surface-3: #eef0f3;
    --border: #cfd5dd; --border-strong: #9aa5b5;
    --text: #000; --text-2: #222; --muted: #555; --shadow: none;
    --primary: #1e40af; --primary-soft: #eef2ff; --on-primary: #fff;
    --dot-green: #16a34a; --dot-blue: #2563eb; --dot-amber: #d97706; --dot-gray: #98a2b3;
    --s1-bg: #fde3e1; --s1-fg: #b42318;
    --s2-bg: #feead2; --s2-fg: #b54708;
    --s3-bg: #fdf3c4; --s3-fg: #854a0e;
    --s4-bg: #d9f5e3; --s4-fg: #067647;
    --s5-bg: #0e8a4f; --s5-fg: #ffffff;
  }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { font-size: 11px; line-height: 1.45; background: #fff; }
  .no-print, .load-error { display: none !important; }
  .print-only { display: grid; }
  .container { max-width: none; padding: 0; }

  .page-title { padding: 0 0 10px; margin-bottom: 12px; border-bottom: 2px solid var(--primary); }
  .page-title h1 { font-size: 20px; color: var(--primary); }
  .eyebrow { font-size: 11px; }
  .subtitle { font-size: 11px; margin-top: 2px; }

  .profile { margin: 0 0 10px; padding: 12px 14px; gap: 16px; }
  .avatar-lg { width: 44px; height: 44px; font-size: 14px; }
  .profile-name { font-size: 16px; }
  .profile-summary { margin-top: 6px; }
  .facts { gap: 6px 16px; padding-left: 16px; }
  .stats { margin-bottom: 12px; gap: 10px; }
  .stat { padding: 6px 10px; }
  .stat-value { font-size: 16px; margin-top: 0; }
  .stat-label, .stat-sub { font-size: 10px; }

  .block { margin-bottom: 14px; }
  .block-head { margin-bottom: 6px; break-inside: avoid; break-after: avoid; }
  .block-head h2 { font-size: 14px; }
  .block-head p { font-size: 10px; }

  .resp, .growth { padding: 7px 12px; gap: 10px; break-inside: avoid; }
  .resp-num { width: 20px; height: 20px; font-size: 10px; }
  .resp-head h3, .growth h3 { font-size: 12px; }
  .resp-body { grid-template-columns: minmax(0, 1fr) 140px; gap: 2px 20px; }
  .resp-body p, .growth p { font-size: 10.5px; }
  .resp .tags { display: none; }
  .resp-total { padding: 5px 12px; font-size: 10.5px; }
  .growth-icon { width: 22px; height: 22px; padding: 4px; }
  .tags { margin-top: 4px; }
  .tag { font-size: 10px; padding: 1px 6px; }

  .table-wrap { overflow: visible; border-radius: 0; }
  .kpi-table { min-width: 0; font-size: 11px; }
  .kpi-table thead th { font-size: 10.5px; }
  .kpi-table th, .kpi-table td { padding: 6px 8px; }
  .kpi-table tr { break-inside: avoid; }
  .kpi-table tfoot { display: table-row-group; }
  .feature-desc { max-width: none; }
  .project-name { font-size: 12px; }
  .project-desc, .release-to, .feature-meta, .score-label, .status { font-size: 10px; }
  .page-footer { display: none; }
  .score { height: 24px; min-width: 28px; }
  .matrix-block { break-before: page; }
  .rubric-block, .growth-block { break-inside: avoid; }
  .rubric { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .rubric-item { padding: 8px; break-inside: avoid; }
  .rubric-item strong { font-size: 11px; }
  .rubric-item p { font-size: 10px; }
  .signatures { break-inside: avoid; }
  .doc .signatures { margin-top: 6px; }
  .doc .sig { padding-top: 26px; }

  .doc-page .page-title { display: none; }
  .doc { max-width: none; margin: 0; padding: 0; border: 0; border-radius: 0; font-size: 10pt; line-height: 1.25; }
  .doc-part-break { margin-top: 0; padding-top: 0; border-top: 0; break-before: page; }
  .doc-title { font-size: 14pt; margin-bottom: 12px; }
  .doc-photo { width: 92px; height: 118px; }
  .doc-h { margin: 10px 0 3px; }
  .doc-p { margin-bottom: 6px !important; }
  .doc-list { margin: 2px 0 6px; }
  .doc-list li { margin: 1px 0; break-inside: avoid; }
  .doc-lines { margin-bottom: 4px; }
  .rs-entry { margin-top: 7px; }
  .rs-name { font-size: 20pt; }
  .doc-table { font-size: 9.5pt; }
  .doc-table th, .doc-table td { padding: 3px 6px; }
  .doc-table tr { break-inside: avoid; }
  .rs-section { margin: 10px 0 4px; font-size: 10.5pt; }
  .rs-target { margin-top: 8px !important; padding: 4px 8px; }
}
