:root {
  --bg-page: #FAFAF7;
  --bg-card: #FFFFFF;
  --text: #1A1A1A;
  --text-muted: rgba(26, 26, 26, 0.7);
  --text-faint: rgba(26, 26, 26, 0.5);
  --border: rgba(0, 0, 0, 0.55);
  --border-thin: rgba(0, 0, 0, 0.3);
  --line: rgba(0, 0, 0, 0.4);
  --line-thin: rgba(0, 0, 0, 0.2);
  --accent: #B74747;
  --neutral-fill: #E8E6DE;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 32px 24px 48px;
  background: var(--bg-page);
  color: var(--text);
  font-family: 'Roboto', system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.container { max-width: 1200px; margin: 0 auto; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 24px;
  margin-bottom: 16px;
}
.breadcrumb {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  text-decoration: none;
}
.breadcrumb:hover { color: var(--text); text-decoration: underline; }

#user-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
#user-bar button {
  font: inherit;
  text-transform: uppercase;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 12px;
  cursor: pointer;
}
#user-bar button:hover { background: var(--neutral-fill); }

header { text-align: center; margin-bottom: 32px; }
.logos {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 28px;
}
.logos .logo { height: 104px; width: auto; }
.page-title {
  margin: 20px 0 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.page-subtitle {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--text-muted);
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-thin);
  border-radius: 12px;
  padding: 40px 24px;
}

#chart { position: relative; }

/* Two equal, labeled bands — "Executive Leadership" and "Functions" — each with
   a centered subhead floating on a dotted rule. Deliberately NOT tiers: the
   bands read as peers, not a top-down reporting ladder. */
.band {
  position: relative;
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px dotted var(--border-thin);
}
.band:first-child { margin-top: 8px; }
.section-tag {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border-thin);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 14px;
  border-radius: 20px;
  white-space: nowrap;
}

/* Executive Leadership band: Steve, Tom, Matt, Lauren as peer boxes in one row.
   No connector lines, no vertical drop — this enumerates the key exec roles. */
.exec-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
  gap: 12px;
}
/* An exec box matches .function-box dimensions so leadership and functions read
   as peers. Those carrying a `detail` are <button>s that open the role fly-out. */
.exec-box {
  font: inherit;
  color: inherit;
  width: 200px;
  padding: 10px 8px;
  min-height: 70px;
  border-radius: 8px;
  border: 1px solid var(--border);
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
button.exec-box { cursor: pointer; transition: box-shadow 0.15s ease, transform 0.15s ease; }
button.exec-box:hover { box-shadow: 0 3px 10px rgba(0, 0, 0, 0.14); transform: translateY(-1px); }
button.exec-box:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.exec-box .title { font-size: 13px; font-weight: 500; line-height: 1.25; word-break: break-word; }
.exec-box .person { font-size: 11px; color: var(--text-muted); margin-top: 6px; line-height: 1.3; }
/* The CEO is the anchor of the band — a slightly stronger border, no ladder. */
.exec-box.is-ceo { border-width: 2px; }

/* Functions row */
.functions {
  display: grid;
  grid-template-columns: repeat(var(--fn-count, 7), 1fr);
  gap: 8px;
  align-items: start;
}

.function-col {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  position: relative;
}

.function-box {
  padding: 10px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  text-align: center;
  /* Tall enough to fit a two-line name (e.g. "Real Estate Development") so every
     box is the same height and the subfunction pill rows line up across columns. */
  min-height: 84px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.function-box .name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  word-break: break-word;
}
.function-box .lead {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.3;
  word-break: break-word;
}
/* When a function carries a `detail`, the box renders as a clickable button
   into the role fly-out. Same affordance as the office boxes; no CTA text. */
button.function-box {
  font: inherit;
  color: inherit;
  width: 100%;
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
button.function-box:hover { box-shadow: 0 3px 10px rgba(0, 0, 0, 0.14); transform: translateY(-1px); }
button.function-box:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Mini connector between function box and subfunctions */
.sub-line {
  width: 1px;
  height: 12px;
  background: var(--line-thin);
  margin: 0 auto;
}

.subfunctions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sub-pill {
  padding: 6px 8px;
  border-radius: 5px;
  border: 1px solid var(--border-thin);
  font-size: 11px;
  text-align: center;
  line-height: 1.25;
  word-break: break-word;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

footer {
  margin-top: 24px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
}
.as-of { margin-top: 8px; color: var(--text-faint); font-size: 13px; }

/* ============ RESPONSIVE: collapse to vertical below 720px ============ */
@media (max-width: 720px) {
  body { padding: 20px 12px 32px; }
  .chart-card { padding: 24px 16px; }

  /* Leadership band stacks vertically */
  .exec-row {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }
  .exec-box { width: 100%; max-width: 320px; }

  /* Each function becomes a horizontal row */
  .functions {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .function-col {
    display: grid;
    grid-template-columns: minmax(140px, 1fr) 2fr;
    gap: 10px;
    align-items: start;
  }
  .function-box {
    min-height: 0;
    padding: 12px 10px;
  }
  .function-box .name { font-size: 15px; }
  .function-box .lead { font-size: 12px; margin-top: 4px; }

  .sub-line { display: none; }
  .subfunctions {
    gap: 4px;
  }
  .sub-pill {
    font-size: 12px;
    text-align: left;
    padding: 8px 12px;
    justify-content: flex-start;
  }
}

@media (max-width: 480px) {
  .function-col {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

/* ============ Role fly-out dialog ============ */
.flyout {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}
.flyout.open { opacity: 1; visibility: visible; }

.flyout-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 26, 26, 0.45);
}

.flyout-panel {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px 28px 24px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  transform: translateY(12px) scale(0.98);
  transition: transform 0.18s ease;
}
.flyout.open .flyout-panel { transform: translateY(0) scale(1); }

.flyout-close {
  position: absolute;
  top: 12px;
  right: 14px;
  font: inherit;
  font-size: 22px;
  line-height: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.flyout-close:hover { background: var(--neutral-fill); color: var(--text); }
.flyout-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.flyout-person {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}
.flyout-title {
  margin: 2px 0 12px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--accent);
}
.flyout-summary {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
}
.flyout-scope {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.scope-item {
  position: relative;
  padding-left: 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
}
.scope-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}
.scope-item strong { color: var(--text); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .flyout, .flyout-panel, .exec-box, button.function-box { transition: none; }
  .flyout-panel { transform: none; }
}
