/* FILE: css/main.css */
/* Purpose: Complete stylesheet for ELWA Textile Personas dashboard */
/* Last updated: [date] */
/* Common edits: Change accent colours in :root, adjust font sizes, modify layout widths */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500&display=swap');

/* ============================================= */
/* DESIGN TOKENS                                 */
/* ============================================= */
:root {
  --navy: #1B4F72;
  --teal: #148F77;
  --coral: #E74C3C;
  --bg: #FAFAFA;
  --card-bg: #FFFFFF;
  --text: #2C3E50;
  --text-light: #5D6D7E;
  --border: #E8ECF0;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --font: 'DM Sans', sans-serif;
  /* Persona accents (also set inline on fragments) */
  --c1: #E8845A;
  --c2: #7B9EC4;
  --c3: #148F77;
  --c4: #9B7FC4;
}

/* ============================================= */
/* RESET & BASE                                  */
/* ============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* ============================================= */
/* TOP NAVIGATION BAR                            */
/* ============================================= */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1000;
}

.nav-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-shrink: 0;
}

.nav-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--navy);
}

.nav-org {
  font-size: 11px;
  color: var(--text-light);
}

.nav-centre {
  display: flex;
  gap: 2px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ============================================= */
/* TAB BUTTONS                                   */
/* ============================================= */
.tab-btn {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-light);
  background: transparent;
  border: none;
  padding: 16px 14px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color 150ms ease, border-color 150ms ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--tab-accent, var(--navy));
}

/* ============================================= */
/* EDIT TOGGLE & HELP BUTTONS                    */
/* ============================================= */
.edit-toggle-btn {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-light);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  cursor: pointer;
  transition: all 150ms ease;
}

.edit-toggle-btn:hover {
  border-color: var(--text-light);
}

.edit-toggle-btn.active {
  background: #FFF8F0;
  border-color: var(--c1);
  color: var(--c1);
}

.help-btn {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms ease;
}

.help-btn:hover {
  border-color: var(--text-light);
  color: var(--text);
}

/* ============================================= */
/* SESSION BANNER                                */
/* ============================================= */
.session-banner {
  position: fixed;
  top: 52px;
  left: 0;
  right: 0;
  background: #FFF8F0;
  border-bottom: 1px solid rgba(232, 132, 90, 0.3);
  color: var(--c1);
  font-size: 11px;
  font-weight: 500;
  text-align: center;
  padding: 6px;
  z-index: 999;
  display: none;
}

body.edit-mode .session-banner {
  display: block;
}

/* ============================================= */
/* MAIN CONTENT AREA                             */
/* ============================================= */
.main-content {
  margin-top: 52px;
  padding: 24px 20px 60px;
  min-height: calc(100vh - 52px);
}

body.edit-mode .main-content {
  margin-top: 78px; /* account for session banner */
}

/* ============================================= */
/* PERSONA FRAME (where persona fragments load)  */
/* ============================================= */
#persona-frame {
  max-width: 900px;
  margin: 0 auto;
  transition: opacity 150ms ease;
}

#persona-frame.loading {
  opacity: 0.3;
}

/* ============================================= */
/* PERSONA FRAGMENT — shared styles              */
/* ============================================= */
.persona-fragment {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* --- Zone 1: Header --- */
.persona-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding-bottom: 14px;
  border-bottom: 3px solid var(--accent, var(--navy));
}

.header-mark {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  cursor: default;
}

/* C1 mark: circle */
.header-mark.c1-mark {
  background: var(--c1);
  border-radius: 50%;
}
.header-mark.c1-mark::after {
  content: '';
  position: absolute;
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,0.5);
  border-radius: 50%;
  top: 8px; left: 18px;
}
.header-mark.c1-mark::before {
  content: '';
  position: absolute;
  width: 24px; height: 24px;
  background: rgba(255,255,255,0.25);
  border-radius: 50%;
  bottom: 10px; right: 10px;
}

/* C2 mark: square */
.header-mark.c2-mark {
  background: var(--c2);
  border-radius: 8px;
}
.header-mark.c2-mark::after {
  content: '';
  position: absolute;
  width: 48px; height: 3px;
  background: rgba(255,255,255,0.4);
  top: 28px;
}
.header-mark.c2-mark::before {
  content: '';
  position: absolute;
  width: 48px; height: 3px;
  background: rgba(255,255,255,0.25);
  bottom: 24px;
}

/* C3 mark: organic */
.header-mark.c3-mark {
  background: var(--c3);
  border-radius: 50% 50% 50% 8px;
}
.header-mark.c3-mark::after {
  content: '';
  position: absolute;
  width: 28px; height: 28px;
  border: 2.5px solid rgba(255,255,255,0.4);
  border-radius: 50%;
  top: 14px; left: 22px;
}
.header-mark.c3-mark::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  bottom: 14px; left: 16px;
}

/* C4 mark: rotated square */
.header-mark.c4-mark {
  background: var(--c4);
  border-radius: 12px;
  transform: rotate(8deg);
}
.header-mark.c4-mark::after {
  content: '';
  position: absolute;
  width: 40px; height: 40px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-radius: 8px;
  transform: rotate(-8deg);
}
.header-mark.c4-mark::before {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
  bottom: 10px; right: 10px;
  transform: rotate(-8deg);
}

/* Header mark with uploaded image */
.header-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.header-text h1 {
  font-size: 26px;
  font-weight: 500;
  color: var(--navy);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.header-text .subtitle {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 3px;
}

.header-text .cluster-size {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent, var(--navy));
  background: rgba(27, 79, 114, 0.1); /* fallback — overridden per-persona via inline style */
  padding: 3px 10px;
  border-radius: 3px;
}

/* --- Zone labels (shared) --- */
.zone-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-light);
  margin-bottom: 6px;
}

/* --- Zone 2: Behaviour Snapshot --- */
.snapshot {
  background: #F7F9FB;
  border-radius: 6px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.snapshot-item {
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.45;
  padding-left: 14px;
  position: relative;
}

.snapshot-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent, var(--navy));
}

/* C2 square bullet */
.persona-fragment[data-persona="C2"] .snapshot-item::before {
  border-radius: 2px;
}

/* C4 diamond bullet */
.persona-fragment[data-persona="C4"] .snapshot-item::before {
  border-radius: 2px;
  transform: rotate(45deg);
}

/* --- Zone 3: Three-column cards --- */
.three-col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

.col-card {
  background: #F7F9FB;
  border-radius: 6px;
  padding: 12px 14px;
  border-top: 3px solid var(--navy);
}

.col-card.motivations {
  border-top-color: var(--accent, var(--navy));
}

.col-card.needs {
  border-top-color: var(--teal);
}

/* Override for C3: needs card uses orange */
.persona-fragment[data-persona="C3"] .col-card.needs {
  border-top-color: var(--c1);
}

/* --- Per-persona accent overrides for bg tints --- */
.persona-fragment[data-persona="C1"] .cluster-size { background: rgba(232,132,90,0.1); color: #E8845A; }
.persona-fragment[data-persona="C1"] .intervention { background: rgba(232,132,90,0.06); border-color: rgba(232,132,90,0.25); }
.persona-fragment[data-persona="C1"] .intervention h3 { color: #E8845A; }

.persona-fragment[data-persona="C2"] .cluster-size { background: rgba(123,158,196,0.12); color: #7B9EC4; }
.persona-fragment[data-persona="C2"] .intervention { background: rgba(123,158,196,0.06); border-color: rgba(123,158,196,0.25); }
.persona-fragment[data-persona="C2"] .intervention h3 { color: #7B9EC4; }

.persona-fragment[data-persona="C3"] .cluster-size { background: rgba(20,143,119,0.1); color: #148F77; }
.persona-fragment[data-persona="C3"] .intervention { background: rgba(20,143,119,0.05); border-color: rgba(20,143,119,0.25); }
.persona-fragment[data-persona="C3"] .intervention h3 { color: #148F77; }

.persona-fragment[data-persona="C4"] .cluster-size { background: rgba(155,127,196,0.1); color: #9B7FC4; }
.persona-fragment[data-persona="C4"] .intervention { background: rgba(155,127,196,0.05); border-color: rgba(155,127,196,0.25); }
.persona-fragment[data-persona="C4"] .intervention h3 { color: #9B7FC4; }
.persona-fragment[data-persona="C4"] .key-insight { background: rgba(155,127,196,0.08); border-color: #9B7FC4; }
.persona-fragment[data-persona="C4"] .key-insight strong { color: #9B7FC4; }

/* --- Per-persona accent for metric values, bullets, arrows --- */
.persona-fragment[data-persona="C1"] .metric-value { color: #E8845A; }
.persona-fragment[data-persona="C1"] .snapshot-item::before { background: #E8845A; }
.persona-fragment[data-persona="C1"] .hmw-list li::before { color: #E8845A; }
.persona-fragment[data-persona="C1"] .col-card.motivations { border-top-color: #E8845A; }
.persona-fragment[data-persona="C1"] .col-card.motivations h3 { color: #E8845A; }

.persona-fragment[data-persona="C2"] .metric-value { color: #7B9EC4; }
.persona-fragment[data-persona="C2"] .snapshot-item::before { background: #7B9EC4; }
.persona-fragment[data-persona="C2"] .hmw-list li::before { color: #7B9EC4; }
.persona-fragment[data-persona="C2"] .col-card.motivations { border-top-color: #7B9EC4; }
.persona-fragment[data-persona="C2"] .col-card.motivations h3 { color: #7B9EC4; }

.persona-fragment[data-persona="C3"] .metric-value { color: #148F77; }
.persona-fragment[data-persona="C3"] .snapshot-item::before { background: #148F77; }
.persona-fragment[data-persona="C3"] .hmw-list li::before { color: #148F77; }
.persona-fragment[data-persona="C3"] .col-card.motivations { border-top-color: #148F77; }
.persona-fragment[data-persona="C3"] .col-card.motivations h3 { color: #148F77; }

.persona-fragment[data-persona="C4"] .metric-value { color: #9B7FC4; }
.persona-fragment[data-persona="C4"] .snapshot-item::before { background: #9B7FC4; }
.persona-fragment[data-persona="C4"] .hmw-list li::before { color: #9B7FC4; }
.persona-fragment[data-persona="C4"] .col-card.motivations { border-top-color: #9B7FC4; }
.persona-fragment[data-persona="C4"] .col-card.motivations h3 { color: #9B7FC4; }

.col-card h3 {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--navy);
  margin-bottom: 8px;
}

.col-card.motivations h3 { color: var(--accent, var(--navy)); }
.col-card.needs h3 { color: var(--teal); }
.persona-fragment[data-persona="C3"] .col-card.needs h3 { color: var(--c1); }

.col-card ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.col-card li {
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text);
}

/* --- Zone 4: Journey Strip --- */
.journey-section {
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
}

.journey-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  position: relative;
}

.journey-strip::before {
  content: '';
  position: absolute;
  top: 14px;
  left: 5%;
  right: 5%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}

.journey-stage {
  text-align: center;
  position: relative;
  z-index: 1;
}

.stage-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 500;
  color: white;
}

.stage-dot.friction { background: var(--coral); }
.stage-dot.circular { background: var(--teal); }
.stage-dot.neutral { background: var(--text-light); }

.stage-label {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--navy);
  margin-bottom: 4px;
}

.stage-desc {
  font-size: 10.5px;
  color: var(--text-light);
  line-height: 1.35;
  padding: 0 4px;
}

.signal-tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 3px;
  margin-top: 4px;
}

.signal-tag.friction {
  background: rgba(231,76,60,0.1);
  color: var(--coral);
}

.signal-tag.circular {
  background: rgba(20,143,119,0.1);
  color: var(--teal);
}

.signal-tag.neutral {
  background: rgba(93,109,126,0.1);
  color: var(--text-light);
}

.signal-tag.accent {
  background: rgba(155, 127, 196, 0.12);
  color: var(--accent, var(--text-light));
}

/* --- Data panel (collapsible) --- */
.data-panel-toggle {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-light);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  cursor: pointer;
  margin-top: 12px;
  transition: all 150ms ease;
}

.data-panel-toggle:hover {
  border-color: var(--text-light);
}

.data-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 300ms ease, padding 300ms ease;
  padding: 0 0;
}

.data-panel.expanded {
  max-height: 600px;
  padding: 16px 0 0;
}

.metric-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.metric-card {
  background: #F7F9FB;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
}

.metric-card .metric-value {
  font-size: 20px;
  font-weight: 500;
  color: var(--accent, var(--navy));
  line-height: 1.2;
}

.metric-card .metric-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-light);
  margin-top: 2px;
}

.metric-card .metric-note {
  font-size: 10px;
  color: var(--text-light);
  margin-top: 4px;
  font-style: italic;
}

.persona-chart-wrap {
  height: 200px;
  position: relative;
}

/* --- Zone 5: Intervention box --- */
.intervention {
  background: rgba(27, 79, 114, 0.06);
  border: 1.5px solid rgba(27, 79, 114, 0.25);
  border-radius: 6px;
  padding: 14px 16px;
}

.intervention h3 {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent, var(--navy));
  margin-bottom: 6px;
}

.intervention .framing {
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 10px;
}

.hmw-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hmw-list li {
  font-size: 11.5px;
  color: var(--text);
  line-height: 1.4;
  padding-left: 12px;
  position: relative;
}

.hmw-list li::before {
  content: '\2192';
  position: absolute;
  left: 0;
  color: var(--accent, var(--navy));
  font-weight: 500;
}

/* Additionality flag (C2) */
.additionality-flag {
  background: rgba(231,76,60,0.06);
  border-left: 3px solid var(--coral);
  padding: 8px 12px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text);
  line-height: 1.4;
  border-radius: 0 4px 4px 0;
}

.additionality-flag strong {
  color: var(--coral);
  font-weight: 500;
}

/* Key insight (C4) */
.key-insight {
  background: rgba(27, 79, 114, 0.08);
  border-left: 3px solid var(--accent, var(--navy));
  padding: 8px 12px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text);
  line-height: 1.4;
  border-radius: 0 4px 4px 0;
}

.key-insight strong {
  color: var(--accent, var(--navy));
  font-weight: 500;
}

/* --- Zone 6: Contrast footer --- */
.contrast {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  font-size: 11px;
  color: var(--text-light);
  font-style: italic;
  line-height: 1.45;
}

/* --- Zone 7: Qualitative notes --- */
.qual-notes-zone {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.qual-notes-zone textarea {
  width: 100%;
  min-height: 80px;
  font-family: var(--font);
  font-size: 12px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  resize: vertical;
  background: #FDFDFD;
  line-height: 1.5;
  transition: border-color 150ms ease;
}

.qual-notes-zone textarea:focus {
  outline: none;
  border-color: var(--accent, var(--navy));
}

/* ============================================= */
/* EDIT MODE STATES                              */
/* ============================================= */
body.edit-mode [data-editable="true"] {
  background: #FFFBF5;
  border-bottom: 1px dashed rgba(232,132,90,0.5);
  cursor: text;
  transition: background 150ms ease;
}

body.edit-mode [data-editable="true"]:hover {
  background: #FFF5E8;
}

body.edit-mode [data-editable="true"]:focus {
  outline: none;
  background: #FFF0DD;
  border-bottom-color: var(--c1);
}

body.edit-mode .header-mark[data-image-zone="true"] {
  cursor: pointer;
  outline: 2px dashed rgba(232,132,90,0.4);
  outline-offset: 2px;
}

body.edit-mode .header-mark[data-image-zone="true"]:hover {
  outline-color: var(--c1);
}

/* ============================================= */
/* COMPARE VIEW                                  */
/* ============================================= */
.compare-view {
  max-width: 1100px;
  margin: 0 auto;
}

.compare-header {
  margin-bottom: 24px;
}

.compare-header h2 {
  font-size: 22px;
  font-weight: 500;
  color: var(--navy);
}

.compare-subtitle {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 4px;
}

.compare-summary-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.compare-summary-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  border-top: 3px solid var(--card-accent, var(--navy));
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.compare-summary-card h3 {
  font-size: 14px;
  font-weight: 500;
  color: var(--navy);
  margin-bottom: 2px;
}

.compare-summary-card .card-framing {
  font-size: 11px;
  color: var(--text-light);
  line-height: 1.4;
  margin-bottom: 6px;
}

.compare-summary-card .card-stat {
  font-size: 11px;
  color: var(--text);
}

.compare-summary-card .card-stat strong {
  color: var(--card-accent, var(--navy));
}

.compare-chart-container {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.compare-chart-container canvas {
  width: 100% !important;
}

/* Journey comparison table */
.compare-journey-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.journey-compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

.journey-compare-table th {
  font-weight: 500;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 2px solid var(--border);
  font-size: 11px;
}

.journey-compare-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.journey-compare-table .signal-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.journey-compare-table .signal-dot.friction { background: var(--coral); }
.journey-compare-table .signal-dot.circular { background: var(--teal); }
.journey-compare-table .signal-dot.neutral { background: var(--text-light); }

/* Cross-cutting threads */
.cross-cutting-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.thread-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.thread-item:last-child {
  border-bottom: none;
}

.thread-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--navy);
  margin-bottom: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.thread-title::before {
  content: '\25B6';
  font-size: 8px;
  color: var(--text-light);
  transition: transform 200ms ease;
}

.thread-item.expanded .thread-title::before {
  transform: rotate(90deg);
}

.thread-body {
  font-size: 12px;
  color: var(--text);
  line-height: 1.55;
  max-height: 0;
  overflow: hidden;
  transition: max-height 300ms ease;
}

.thread-item.expanded .thread-body {
  max-height: 300px;
  margin-top: 6px;
}

.thread-tags {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.thread-tag {
  font-size: 9px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 3px;
  background: #F0F0F0;
  color: var(--text-light);
}

/* ============================================= */
/* HELP OVERLAY                                  */
/* ============================================= */
.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
}

.help-overlay.visible {
  display: flex;
}

.help-panel {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 32px 36px;
  max-width: 560px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.help-close {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 24px;
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  line-height: 1;
}

.help-panel h2 {
  font-size: 20px;
  font-weight: 500;
  color: var(--navy);
  margin-bottom: 6px;
}

.help-intro {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 20px;
}

.help-panel h3 {
  font-size: 13px;
  font-weight: 500;
  color: var(--navy);
  margin-top: 16px;
  margin-bottom: 4px;
}

.help-panel p {
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.5;
}

.help-panel kbd {
  display: inline-block;
  font-family: var(--font);
  font-size: 10px;
  background: #F0F0F0;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
}

.help-panel code {
  font-size: 11px;
  background: #F0F0F0;
  padding: 1px 5px;
  border-radius: 3px;
}

/* ============================================= */
/* ERROR STATE                                   */
/* ============================================= */
.load-error {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
  font-size: 13px;
}

.load-error strong {
  display: block;
  font-size: 16px;
  color: var(--text);
  margin-bottom: 8px;
}

/* ============================================= */
/* PRINT                                         */
/* ============================================= */
@media print {
  .top-nav, .session-banner, .help-overlay,
  .data-panel-toggle, .data-panel, .qual-notes-zone,
  .nav-right { display: none !important; }

  .main-content { margin-top: 0; padding: 0; }

  .persona-fragment {
    box-shadow: none;
    border: none;
    padding: 18mm 20mm;
    max-width: none;
  }

  body { background: white; }
}

/* ============================================= */
/* RESPONSIVE (for 1280 / 1440)                  */
/* ============================================= */
@media screen and (max-width: 1000px) {
  .nav-centre { gap: 0; }
  .tab-btn { padding: 16px 8px; font-size: 11px; }
}

@media screen and (max-width: 800px) {
  .three-col { grid-template-columns: 1fr; }
  .journey-strip { grid-template-columns: 1fr; gap: 12px; }
  .journey-strip::before { display: none; }
  .snapshot { grid-template-columns: 1fr; }
  .compare-summary-row { grid-template-columns: 1fr 1fr; }
}


/* ============================================= */
/* AGE FILTER TOGGLE                             */
/* ============================================= */
.age-filter {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: 12px;
}

.age-filter-label {
  font-size: 10px;
  color: var(--text-light);
  margin-right: 4px;
}

.age-filter-btn {
  font-family: var(--font);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-light);
  background: transparent;
  border: 1px solid var(--border);
  padding: 4px 10px;
  cursor: pointer;
  transition: all 150ms ease;
}

.age-filter-btn:first-of-type { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.age-filter-btn:last-of-type { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: none; }

.age-filter-btn.active {
  background: rgba(20, 143, 119, 0.1);
  border-color: var(--teal);
  color: var(--teal);
}

.age-filter-btn:hover:not(.active) {
  border-color: var(--text-light);
}

/* ============================================= */
/* UNDER-45 BANNER                               */
/* ============================================= */
.u45-banner {
  position: fixed;
  top: 52px;
  left: 0;
  right: 0;
  background: rgba(20, 143, 119, 0.08);
  border-bottom: 1px solid rgba(20, 143, 119, 0.2);
  color: var(--teal);
  font-size: 11px;
  font-weight: 500;
  text-align: center;
  padding: 5px;
  z-index: 998;
  display: none;
}

/* ============================================= */
/* DEMOGRAPHICS ZONE (Zone 8)                    */
/* ============================================= */
.demographics-zone {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.zone-label-note {
  font-size: 10px;
  color: var(--text-light);
  font-style: italic;
  margin-bottom: 12px;
}

.demo-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.demo-chart-wrap {
  background: #F7F9FB;
  border-radius: 6px;
  padding: 12px 14px;
  height: 180px;
  position: relative;
}

.demo-chart-title {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-light);
  margin-bottom: 8px;
}

.demo-contrast-note {
  font-size: 11px;
  color: var(--text-light);
  font-style: italic;
  line-height: 1.45;
  margin-top: 10px;
}

/* ============================================= */
/* FACTORS VIEW                                  */
/* ============================================= */
.factors-view {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 0;
}

.factors-header {
  margin-bottom: 24px;
}

.factors-header h2 {
  font-size: 22px;
  font-weight: 500;
  color: var(--navy);
}

.factors-subtitle {
  font-size: 12px;
  color: var(--text-light);
  line-height: 1.5;
  margin-top: 6px;
}

/* Factor cards */
.factor-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 14px;
  border-left: 8px solid var(--factor-accent, var(--navy));
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.factor-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.factor-id {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-light);
}

.factor-variance {
  font-size: 10px;
  color: var(--text-light);
}

.confidence-badge {
  font-size: 9px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.confidence-high {
  background: rgba(20,143,119,0.1);
  color: var(--teal);
}

.confidence-medium {
  background: rgba(232,132,90,0.1);
  color: #E8845A;
}

.factor-name {
  font-size: 16px;
  font-weight: 500;
  color: var(--navy);
  margin-bottom: 10px;
}

.factor-loadings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 10px;
}

.factor-loadings-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-light);
  margin-bottom: 6px;
}

.loading-tag {
  display: inline-block;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 3px;
  margin: 2px 4px 2px 0;
  font-family: monospace;
  line-height: 1.6;
}

.loading-tag.positive { background: rgba(20,143,119,0.08); color: var(--teal); }
.loading-tag.negative { background: rgba(231,76,60,0.08); color: var(--coral); }
.loading-tag.neutral { background: #F0F0F0; color: var(--text-light); }

.factor-relevance {
  font-size: 11px;
  color: var(--text-light);
  line-height: 1.45;
  margin-bottom: 8px;
}

.factor-clusters {
  display: flex;
  gap: 6px;
}

.cluster-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

/* Factor heatmap chart container */
.factor-heatmap-container {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  height: 280px;
}

/* Methodology accordion */
.methodology-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.methodology-toggle {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--navy);
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 0;
}

.methodology-toggle::before {
  content: '\25B6';
  font-size: 8px;
  color: var(--text-light);
  transition: transform 200ms ease;
}

.methodology-section.expanded .methodology-toggle::before {
  transform: rotate(90deg);
}

.methodology-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 300ms ease;
}

.methodology-section.expanded .methodology-body {
  max-height: 600px;
  margin-top: 12px;
}

.methodology-body p {
  font-size: 12px;
  color: var(--text);
  line-height: 1.55;
  margin-bottom: 10px;
}

/* ============================================= */
/* U45 SAMPLE CAVEAT                             */
/* ============================================= */
.u45-sample-caveat {
  font-size: 10px;
  color: #E8845A;
  font-style: italic;
  margin-top: 4px;
  padding: 3px 8px;
  background: rgba(232, 132, 90, 0.08);
  border-radius: 3px;
  display: inline-block;
}

/* ============================================= */
/* COMPARE DEMOGRAPHIC SECTION                   */
/* ============================================= */
.compare-demo-section {
  max-width: 900px;
  margin: 0 auto 32px;
  padding: 0 16px;
}

.compare-section-header {
  margin-bottom: 16px;
}

.compare-demo-note {
  font-size: 11px;
  color: var(--text-light);
  font-style: italic;
  margin-top: 4px;
}

.compare-demo-subtitle {
  font-size: 11px;
  color: var(--text-light);
  margin: -4px 0 8px;
  line-height: 1.4;
}

.demo-compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.demo-compare-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.demo-compare-card--wide {
  grid-column: 1 / -1;
}

.demo-compare-title {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-light);
  margin-bottom: 10px;
}

.demo-compare-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.demo-compare-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-light);
}

.demo-compare-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ============================================= */
/* RESPONSIVE                                    */
/* ============================================= */
@media screen and (max-width: 800px) {
  .demo-charts-grid { grid-template-columns: 1fr; }
  .demo-compare-grid { grid-template-columns: 1fr; }
  .demo-compare-card--wide { grid-column: auto; }
  .factor-loadings-grid { grid-template-columns: 1fr; }
  .age-filter { display: none; }
}

@media print {
  .age-filter, .u45-banner, .factors-view { display: none !important; }
}

/* ============================================= */
/* OVERVIEW TAB                                  */
/* ============================================= */

#overview-view {
  max-width: 900px;
  margin: 0 auto;
}

#overview-view .overview-header {
  padding: 0 0 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
}

#overview-view .overview-header h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
}

.overview-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
}

/* Proportion bar */
.proportion-section {
  padding: 1.5rem 0 0.5rem;
}

.proportion-bar-wrap {
  max-width: 100%;
}

.proportion-bar {
  display: flex;
  height: 36px;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.pb-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
  cursor: default;
}

.pb-segment:hover {
  opacity: 0.85;
}

.pb-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255,255,255,0.92);
  white-space: nowrap;
  padding: 0 4px;
}

/* Hide label text if segment too narrow to fit */
.pb-segment[style*="width:12"] .pb-label,
.pb-segment[style*="width:1"] .pb-label {
  display: none;
}

.proportion-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.proportion-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.proportion-legend em {
  font-style: normal;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.pl-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* 2x2 Matrix */
.matrix-section {
  padding: 1.5rem 0 0;
}

.matrix-layout {
  display: grid;
  grid-template-columns: 28px 1fr;
  grid-template-rows: auto 32px;
  gap: 0;
  max-width: 100%;
}

.matrix-y-axis {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}

.matrix-y-axis .axis-title {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.matrix-y-axis .axis-pole {
  font-size: 0.67rem;
  color: var(--text-muted);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  text-align: center;
}

.matrix-plot-wrap {
  grid-column: 2;
  grid-row: 1;
  position: relative;
}

#bubble-matrix {
  width: 100%;
  height: auto;
  display: block;
}

.matrix-quadrant-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.ql {
  position: absolute;
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.35;
  opacity: 0.65;
}

.ql-tl { top: 6px; left: 6px; }
.ql-tr { top: 6px; right: 6px; text-align: right; }
.ql-bl { bottom: 6px; left: 6px; }
.ql-br { bottom: 6px; right: 6px; text-align: right; }

.matrix-x-axis {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 0;
}

.matrix-x-axis .axis-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.axis-pole {
  font-size: 0.67rem;
  color: var(--text-muted);
}

/* Insight cards */
.matrix-insight-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1rem 0 2rem;
  max-width: 100%;
}

.matrix-insight {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.1rem;
}

.insight-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.matrix-insight p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin: 0 0 0.5rem;
}

.matrix-insight p:last-child { margin-bottom: 0; }
.matrix-insight strong { color: var(--text-primary); font-weight: 600; }

@media (max-width: 560px) {
  .matrix-insight-row { grid-template-columns: 1fr; }
}

.interventions-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  opacity: 0.75;
  border-left: 1px solid rgba(0,0,0,0.08);
  margin-left: 4px;
  padding-left: 12px;
}
.interventions-link:hover { opacity: 1; }
