:root {
  --navy: #102a43;
  --blue: #1d5d91;
  --blue-soft: #eaf3fb;
  --ink: #243b53;
  --muted: #627d98;
  --line: #d9e2ec;
  --surface: #ffffff;
  --canvas: #f5f8fb;
  --internal: #eff7ff;
  --external: #fff8eb;
  --warning: #fff4d6;
  --danger: #b42318;
  --confirmed: #147d64;
  --shadow: 0 8px 24px rgba(16, 42, 67, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
button { cursor: pointer; }
a.button-link { text-decoration: none; }
.shell { max-width: 1500px; margin: 0 auto; padding: 28px 24px 64px; }
header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 20px;
  margin-bottom: 24px;
}
.eyebrow { color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1 { color: var(--navy); font-size: clamp(28px, 4vw, 42px); line-height: 1.1; margin: 6px 0 8px; }
.subtitle { color: var(--muted); margin: 0; max-width: 720px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.button {
  display: inline-block; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--navy);
  font-weight: 700; padding: 10px 14px; transition: .15s ease;
}
.button:hover { border-color: var(--blue); color: var(--blue); transform: translateY(-1px); }
.button.primary { background: var(--blue); border-color: var(--blue); color: white; }
.button.primary:hover { background: #174d78; color: white; }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 18px;
}
.upload-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.upload-card { border: 1px dashed #9fb3c8; border-radius: 10px; padding: 18px; background: #fbfdff; }
.upload-card.ready { border-style: solid; border-color: #53a99a; background: #f5fcfa; }
.upload-card h2 { font-size: 17px; margin: 0 0 5px; color: var(--navy); }
.upload-card p { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.file-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
input[type=file] { width: 100%; color: var(--muted); font-size: 13px; }
.status { color: var(--confirmed); font-size: 13px; font-weight: 700; margin-top: 10px; min-height: 20px; }
.controls { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.target-control { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.target-control label { margin: 0; cursor: pointer; }
.target-control input { width: 20px; height: 20px; margin: 0; accent-color: var(--blue); cursor: pointer; }
label { display: block; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .04em; margin-bottom: 7px; text-transform: uppercase; }
select, .search {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--ink);
  min-height: 42px; padding: 9px 12px; outline: none;
}
select:focus, .search:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29, 93, 145, .12); }
.search-wrap { position: relative; }
.search-wrap .search { padding-right: 36px; }
.search-clear { position: absolute; right: 8px; top: 8px; border: 0; background: none; color: var(--muted); font-size: 20px; line-height: 24px; }
.notice { display: none; margin: 18px 0 0; border-radius: 8px; padding: 12px 14px; background: var(--warning); color: #7a4f01; }
.notice.visible { display: block; }
.notice strong { color: #6b4300; }
.notice ul { margin: 6px 0 0 18px; padding: 0; }
.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty strong { display: block; color: var(--navy); font-size: 20px; margin-bottom: 6px; }
.org-heading { margin: 30px auto 14px; width: 100%; }
.director-section + .director-section { margin-top: 36px; }
.director-frame, .family-frame, .pm-block { border: 1px solid #b9d0e5; border-radius: 12px; background: rgba(255,255,255,.72); }
.director-frame { width: fit-content; max-width: 100%; margin: 0 auto; padding: 14px 18px; text-align: center; }
.org-heading h2 { color: var(--navy); margin: 0; font-size: 21px; }
.org-heading p { color: var(--muted); margin: 3px 0 0; }
.result-count { color: var(--muted); font-size: 13px; margin-top: 6px; text-align: center; }
.portfolio { display: flex; flex-direction: column; gap: 16px; }
.family-layout { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; align-items: start; }
.family-frame { min-width: 0; margin: 0; padding: 14px; grid-column: span 5; }
.family-title { color: var(--blue); font-size: 16px; margin: 0 0 14px; text-align: center; }
.pm-block { min-width: 0; padding: 12px; }
.po-grid { display: contents; }
.hierarchy-title { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; text-align: center; }
.pm-title, .po-title { display: flex; align-items: center; justify-content: center; gap: 9px; color: var(--navy); margin: 0 0 10px; text-align: center; }
.pm-title { font-size: 15px; }
.po-title { color: var(--blue); font-size: 16px; margin-top: 16px; }
.label-chip { border-radius: 999px; background: var(--blue-soft); color: var(--blue); padding: 3px 9px; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.fte-summary { --fte-size: 12px; display: inline-flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: center; font-size: var(--fte-size); font-weight: 800; }
.fte-excluded { display: inline-flex; align-items: center; gap: inherit; flex-wrap: wrap; border-left: 1px solid #9fb3c8; padding-left: 7px; margin-left: 2px; }
.fte-pill { border-radius: 999px; padding: 3px 8px; white-space: nowrap; }
.fte-total { background: #e6eef6; color: var(--navy); }
.fte-internal { background: #d9ecff; color: #155b8d; }
.fte-external { background: #fff0c9; color: #8b5e00; }
.fte-not-confirmed { background: #eadcff; color: #6842a5; }
.fte-frozen { background: #ffd9df; color: #a61b35; }
.fte-target { background: #e3e7eb; color: #405465; }
.squad-grid { display: grid; min-width: 0; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 10px; align-items: start; }
.squad { min-width: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; page-break-inside: avoid; break-inside: avoid; }
.squad-head { background: #f8fbfe; border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: center; }
.squad-head h5 { color: var(--navy); font-size: 13px; margin: 0; overflow-wrap: anywhere; }
.squad-po { color: var(--blue); font-size: 11px; font-weight: 700; margin: 3px 0 5px; }
.squad-metrics { display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; }
.squad-metrics .fte-pill { font-size: 10px; padding: 2px 6px; }
.people { display: flex; flex-direction: column; gap: 5px; padding: 7px; }
.member-box { display: flex; min-width: 0; flex-direction: column; gap: 4px; padding: 6px; border: 1px solid #c9d8e6; border-radius: 7px; }
.member-box.internal-box { background: var(--internal); border-color: #b8d8f1; }
.member-box.external-box { background: var(--external); border-color: #efd28d; }
.member-box.not-confirmed-box { background: #f4edff; border-color: #b794d6; }
.member-box.frozen-box { background: #fff0f1; border-color: #d98998; }
.member-box.target-box { background: #edf0f2; border-color: #aebbc4; }
.member-box-title { display: flex; justify-content: space-between; align-items: center; color: var(--navy); font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.member-count { border-radius: 999px; padding: 1px 6px; background: rgba(255,255,255,.7); font-size: 10px; }
.person { border: 0; border-radius: 0; padding: 2px 0; background: transparent; }
.person.external, .person.non-confirmed { border: 0; background: transparent !important; }
.person.highlight { outline: 3px solid #f6c344; outline-offset: 2px; animation: glow 1.4s ease-in-out 2; }
@keyframes glow { 50% { box-shadow: 0 0 0 7px rgba(246,195,68,.25); } }
.person-name { color: var(--navy); font-size: 11.5px; font-weight: 800; line-height: 1.2; overflow-wrap: anywhere; }
.person-meta { color: var(--muted); font-size: 10.5px; line-height: 1.2; margin-top: 2px; overflow-wrap: anywhere; }
.person-meta span + span::before { content: "·"; margin: 0 4px; color: #9fb3c8; }
.person-status { display: inline-block; border-radius: 999px; background: #c62828; color: white; font-size: 10px; font-weight: 800; padding: 2px 6px; }
.country-flag { font-size: 14px; line-height: 1; }
.chapter-icon { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 17px; padding: 0 3px; border-radius: 999px; font-size: 9px; font-weight: 900; letter-spacing: .02em; line-height: 1; margin: 0 4px 0 2px; vertical-align: -3px; }
.chapter-icon.chapter-0 { background: #d9ecff; color: #155b8d; }
.chapter-icon.chapter-1 { background: #ffe5b4; color: #8b5e00; }
.chapter-icon.chapter-2 { background: #eadcff; color: #6842a5; }
.chapter-icon.chapter-3 { background: #d8f3e7; color: #147d64; }
.chapter-icon.chapter-4 { background: #ffd9df; color: #a61b35; }
.chapter-icon.chapter-5 { background: #e3e7eb; color: #405465; }
.chapter-icon.chapter-6 { background: #dff3f5; color: #14727a; }
.chapter-icon.chapter-7 { background: #f0e1d2; color: #80552e; }
.empty-box { color: var(--muted); font-size: 10px; font-style: italic; }
.allocation-share { color: var(--blue); font-size: 11px; font-weight: 800; margin-left: 5px; }
.no-members { color: var(--muted); font-size: 13px; font-style: italic; padding: 3px 2px; }
.notice-dismiss { float: right; border: 0; background: transparent; color: #7a4f01; font-size: 20px; line-height: 1; padding: 0 2px; }
.loading { display: none; color: var(--blue); font-weight: 700; margin-top: 12px; }
.loading.visible { display: block; }
.upload-date { color: var(--muted); font-size: 12px; margin-top: 4px; overflow-wrap: anywhere; }
footer { color: var(--muted); font-size: 12px; margin-top: 28px; text-align: center; }
.help-shell { max-width: 940px; padding-bottom: 80px; }
.help-nav { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0 20px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; font-weight: 700; }
.help-nav a, .help-contents a { color: var(--blue); }
.help-intro { max-width: 65ch; margin: 0 0 20px; color: var(--muted); }
.help-contents { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 14px; font-weight: 700; }
.help-section { padding: 24px 0; border-bottom: 1px solid var(--line); }
.help-section h2 { margin: 0 0 12px; color: var(--navy); font-size: 22px; }
.help-section p { max-width: 76ch; margin: 0 0 14px; }
.help-legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 26px; }
.help-legend-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); min-width: 0; }
.help-legend-item > :first-child { flex: 0 0 auto; }
.help-swatch { display: inline-flex; justify-content: center; min-width: 96px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.help-swatch.internal-box { background: var(--internal); border-color: #b8d8f1; }
.help-swatch.external-box { background: var(--external); border-color: #efd28d; }
.help-swatch.not-confirmed-box { background: #f4edff; border-color: #b794d6; }
.help-highlight { outline: 3px solid #f6c344; outline-offset: -2px; background: white; }
.help-warning { background: var(--warning); color: #7a4f01; }
.help-chapters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 26px; margin: 0 0 16px; }
.help-chapters > div { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.help-chapters dt { min-width: 38px; }
.help-chapters dd { margin: 0; }
.help-chapters .chapter-icon { vertical-align: middle; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.view-switch { display: flex; width: fit-content; max-width: 100%; gap: 2px; margin: 18px 0; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.view-switch label { position: relative; margin: 0; font-size: 12px; letter-spacing: 0; text-transform: none; cursor: pointer; }
.view-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.view-switch span { display: block; padding: 8px 14px; border-radius: 5px; }
.view-switch input:checked + span { color: white; background: var(--blue); }
.view-switch input:focus-visible + span { outline: 3px solid #f6c344; outline-offset: 2px; }
.portfolio-section, .chapter-section { min-width: 0; margin-top: 24px; }
.portfolio-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px 0; border-bottom: 2px solid #9fb3c8; }
.portfolio-heading h2 { margin: 0; color: var(--navy); font-size: 20px; overflow-wrap: anywhere; }
.portfolio-heading .fte-summary { margin-left: auto; }
.org-heading h3 { color: var(--navy); margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.manager-layout { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; align-items: start; }
.chapter-people { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 12px; align-items: start; padding: 12px 0; }
.chapter-people .person + .person { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 4px; }
.person-squad { font-weight: 700; }
#output .fte-summary .fte-pill.fte-total { font-size: calc(var(--fte-size) + 1pt); }
.squad-metrics .fte-summary { --fte-size: 10px; }
@media screen {
  .portfolio-shell { max-width: 1800px; padding-inline: 16px; }
  #output .org-heading { margin: 20px auto 10px; }
  #output .director-section + .director-section { margin-top: 24px; }
  #output .director-frame { padding: 8px 12px; }
  #output .org-heading h2 { font-size: 17px; }
  #output .org-heading p { font-size: 12px; }
  #output .director-frame, #output .family-frame, #output .pm-block, #output .squad { border-radius: 8px; }
  #output .family-layout, #output .portfolio { gap: 8px; }
  #output .family-frame { padding: 8px; }
  #output .family-title { font-size: 13px; margin-bottom: 7px; overflow-wrap: anywhere; }
  #output .pm-block { padding: 6px; }
  #output .pm-title { font-size: 12px; gap: 4px; margin-bottom: 6px; flex-wrap: wrap; overflow-wrap: anywhere; }
  #output .label-chip { font-size: 9px; padding: 2px 5px; letter-spacing: 0; }
  #output .fte-summary { --fte-size: 10px; font-size: var(--fte-size); gap: 3px; }
  #output .squad-metrics .fte-summary { --fte-size: 9px; }
  #output .fte-pill { padding: 2px 5px; }
  #output .squad-grid { grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 6px; }
  #output .squad-head { padding: 5px 6px; }
  #output .squad-head h5 { font-size: 12px; }
  #output .squad-po { font-size: 10px; margin: 2px 0 3px; overflow-wrap: anywhere; }
  #output .squad-metrics .fte-pill { font-size: 9px; padding: 1px 4px; }
  #output .people { padding: 4px; gap: 3px; }
  #output .member-box { padding: 4px; gap: 2px; }
  #output .member-box-title { font-size: 9px; letter-spacing: 0; }
  #output .member-count { font-size: 9px; padding-inline: 4px; }
  #output .person { font-size: 11px; line-height: 1.2; }
  #output .person-name { display: inline; font-size: 11px; }
  #output .person-meta { display: inline; font-size: 10px; margin: 0 0 0 4px; }
  #output .allocation-share { font-size: 10px; margin-left: 3px; }
  #output .person-status { display: table; margin-top: 2px; font-size: 9px; padding: 1px 4px; }
}
@media screen and (min-width: 1440px) {
  #output .family-frame.single-squad-family { grid-column: span 1 !important; }
}
@media (max-width: 800px) {
  .shell { padding: 20px 14px 48px; }
  header { flex-direction: column; }
  .actions { justify-content: flex-start; }
  .upload-grid, .controls { grid-template-columns: 1fr; }
  .org-heading { text-align: center; }
  .family-layout { grid-template-columns: 1fr; }
  .family-frame { grid-column: span 1 !important; }
  .portfolio-heading .fte-summary { margin-left: 0; }
  .portfolio-heading h2 { width: 100%; }
  .manager-layout { grid-template-columns: 1fr; }
  .manager-layout > .pm-block { grid-column: 1 !important; }
  .help-legend, .help-chapters { grid-template-columns: 1fr; }
  .help-legend-item { align-items: flex-start; }
}
@media print {
  @page { size: landscape; margin: 8mm; }
  html, body { width: 100%; background: white; }
  body { color: #102a43; font-size: 10px; }
  .shell { width: 100%; max-width: none; padding: 0; }
  header, .panel, footer, .notice, .view-switch, .org-heading .result-count { display: none !important; }
  .org-heading { display: block; margin: 0 0 8px; max-width: none; }
  .director-section + .director-section { margin-top: 12px; }
  .portfolio-section + .portfolio-section { break-before: page; }
  .portfolio-heading { break-after: avoid; padding: 6px 0; }
  .portfolio-heading h2 { font-size: 17px; }
  .chapter-section, .chapter-people, .chapter-people .member-box { break-inside: auto; }
  .chapter-people { display: block; }
  .chapter-people .member-box { display: block; margin: 6px 0; }
  .chapter-people .member-box-title { break-after: avoid; }
  .person { break-inside: avoid; }
  .manager-layout { display: block; }
  .org-heading h2 { font-size: 17px; }
  .director-frame { max-width: 100%; padding: 6px 10px; box-shadow: none; }
  .portfolio { display: block; }
  .family-layout { display: block; }
  .family-frame {
    width: 100%; max-width: none; margin: 0 0 8px; padding: 7px;
    box-shadow: none; break-inside: auto; page-break-inside: auto;
  }
  .family-title { font-size: 13px; margin-bottom: 6px; }
  .pm-block {
    width: 100%; margin: 0 0 7px; padding: 6px;
    box-shadow: none; break-inside: auto; page-break-inside: auto;
  }
  .pm-title { font-size: 12px; margin-bottom: 6px; }
  .po-grid { display: contents; }
  .squad-grid {
    display: grid; width: 100%;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px; align-items: start;
  }
  .squad { min-width: 0; box-shadow: none; }
  .squad-head { padding: 5px 6px; }
  .squad-head h5 { font-size: 10px; }
  .squad-po { font-size: 9px; margin: 2px 0 3px; }
  .squad-metrics { gap: 2px; }
  .squad-metrics .fte-pill { font-size: 8px; padding: 1px 4px; }
  .squad-metrics .fte-summary { --fte-size: 8px; }
  .people { padding: 4px; gap: 3px; }
  .member-box { padding: 3px; gap: 2px; }
  .member-box-title { font-size: 8px; }
  .member-count { font-size: 8px; }
  .person { padding: 1px 0; }
  .person-name { font-size: 9px; }
  .person-meta { font-size: 8px; }
  .person-status { font-size: 8px; padding: 1px 4px; }
  .chapter-icon { min-width: 19px; height: 14px; font-size: 8px; margin-right: 2px; }
  .allocation-share { font-size: 9px; margin-left: 2px; }
}
