/* Gently design tokens — mirrors constants/theme.ts */
:root {
  --background-warm: #F9F7F2;
  --surface: #ffffff;
  --text-main: #393938;
  --text-secondary: #555555;
  --text-hierarchy-2: #9EA3B1;
  --text-inactive: #797877;
  --border-card: #E9E7E2;
  --shadow-border: #E9E7E2;
  --button-blue: #3670F4;
  --primary-light: #EEF4FD;
  --success: #1ad571;
  --success-dark: #129A50;
  --care-index-green: #3FBF6A;
  --accent-green: #7DC642;
  --accent-green-tone: #EBF5DC;
  --accent-green-border: #CDE6A8;
  --accent-coral: #F565A0;
  --accent-coral-tone: #FEE0EC;
  --accent-blue-tone: #D2EFFD;
  --accent-blue-border: #A3D8F4;
  --accent-purple-tone: #F8E5FE;
  --accent-purple: #C55EF0;
  --accent-purple-border: #E9C0F7;
  --accent-yellow: #F7D046;
  --accent-yellow-tone: #FFF6CC;
  --accent-yellow-border: #F5DF8D;
  --blue-500: #4FB2E5;
  --primary: #AACBF5;
  --tasks-hero-green: #A5D669;
  --urgency-bg: #FDECEC;
  --urgency-text: #B23B3B;
  --radius-xl: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --shadow-flat: 0 4px 0 var(--shadow-border);
  --shadow-card: 0 3px 0 #E4E4E4;
  --sidebar-w: 252px;
  --inst-accent: #C8102E;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 600;
  background: var(--background-warm);
  color: var(--text-main);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

ion-icon {
  display: block;
  pointer-events: none;
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border-card);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border-card);
  display: flex;
  align-items: center;
  gap: 10px;
}

.wordmark {
  height: 22px;
  width: auto;
}

.brand-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  background: var(--accent-green-tone);
  color: var(--success-dark);
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--accent-green-border);
}

.org-card {
  margin: 14px 12px 0;
  padding: 14px;
  border: 2px solid var(--border-card);
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, color-mix(in srgb, var(--inst-accent) 8%, var(--surface)), var(--surface));
  box-shadow: var(--shadow-flat);
}

.org-card h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 800;
}

.org-card p {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}

.demo-tag {
  display: inline-block;
  margin-top: 10px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: #9a6b1e;
  background: #FBF1DA;
  padding: 3px 8px;
  border-radius: 999px;
}

.cohort-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin: 14px 12px;
  padding: 4px;
  background: var(--background-warm);
  border: 2px solid var(--border-card);
  border-radius: 999px;
  box-shadow: var(--shadow-card);
}

.cohort-toggle button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  background: transparent;
  padding: 9px 10px;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  color: var(--text-inactive);
}

.cohort-toggle button .nav-emoji {
  font-size: 15px;
  line-height: 1;
}

.cohort-toggle button.active {
  background: var(--surface);
  color: var(--text-main);
  box-shadow: var(--shadow-card);
  border: 2px solid var(--border-card);
}

.nav-section {
  padding: 10px 16px 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--text-hierarchy-2);
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  border: 2px solid transparent;
  background: transparent;
  width: calc(100% - 16px);
  text-align: left;
}

.nav-emoji {
  width: 22px;
  flex-shrink: 0;
  font-size: 16px;
  line-height: 1;
  text-align: center;
}

.nav-item:hover {
  background: var(--background-warm);
}

.nav-item.active {
  background: var(--primary-light);
  border-color: var(--accent-blue-border);
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid var(--border-card);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}

.sidebar-footer ion-icon {
  font-size: 18px;
  color: var(--text-hierarchy-2);
}

.sidebar-footer .user-meta {
  flex: 1;
  min-width: 0;
}

.sidebar-footer .user-meta strong {
  display: block;
  color: var(--text-main);
  font-weight: 800;
  font-size: 13px;
}

.sidebar-footer .user-meta span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-chip {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 2px solid #E7E7E7;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.settings-chip ion-icon {
  font-size: 18px;
  color: #4B4B4B;
}

/* ── Main content ──────────────────────────────────────────────────────── */
.main {
  padding: 24px 28px 48px;
  max-width: 1180px;
}

.page { display: none; }
.page.active { display: block; }

.page-header {
  margin-bottom: 20px;
}

.page-header .eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-hierarchy-2);
  margin: 0 0 4px;
}

.page-header h1 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.3px;
  color: var(--text-main);
}

.page-header p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
}

/* ── KPI cards ─────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card {
  background: var(--surface);
  border: 2px solid var(--border-card);
  border-radius: var(--radius-xl);
  padding: 16px 18px;
  box-shadow: var(--shadow-flat);
}

.kpi-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-hierarchy-2);
  text-transform: uppercase;
}

.kpi-value {
  font-size: 32px;
  font-weight: 900;
  margin: 8px 0 4px;
  line-height: 1;
  color: var(--text-main);
}

.kpi-meta {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 800;
  color: var(--accent-green);
  background: var(--accent-green-tone);
  padding: 3px 8px;
  border-radius: 999px;
  margin-left: 8px;
  vertical-align: middle;
}

.kpi-delta ion-icon {
  font-size: 12px;
}

.kpi-icon {
  float: right;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
}

.kpi-icon ion-icon {
  font-size: 22px;
}

.kpi-icon.green {
  background: var(--accent-green-tone);
  border-color: var(--accent-green-border);
}
.kpi-icon.green ion-icon { color: var(--accent-green); }

.kpi-icon.coral {
  background: var(--accent-coral-tone);
  border-color: #F9B3CE;
}
.kpi-icon.coral ion-icon { color: var(--accent-coral); }

.kpi-icon.blue {
  background: var(--accent-blue-tone);
  border-color: var(--accent-blue-border);
}
.kpi-icon.blue ion-icon { color: var(--button-blue); }

.kpi-icon.purple {
  background: var(--accent-purple-tone);
  border-color: #E9C0F7;
}
.kpi-icon.purple ion-icon { color: var(--accent-purple); }

/* ── Chart cards ───────────────────────────────────────────────────────── */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.chart-grid.three { grid-template-columns: 1fr 1fr 1fr; }

.chart-card {
  background: var(--surface);
  border: 2px solid var(--border-card);
  border-radius: var(--radius-xl);
  padding: 16px 18px 12px;
  box-shadow: var(--shadow-flat);
}

.chart-card.wide { grid-column: span 2; }

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  gap: 12px;
}

.chart-title {
  font-size: 16px;
  font-weight: 900;
  color: var(--text-main);
}

.chart-sub {
  font-size: 12px;
  color: var(--text-hierarchy-2);
  font-weight: 700;
}

.chart-eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-hierarchy-2);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.chart-wrap { width: 100%; overflow: hidden; }
.chart-wrap svg { display: block; width: 100%; }

.legend-row {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 700;
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  margin-right: 5px;
}

/* ── Donut charts ──────────────────────────────────────────────────────── */
.donut-stack {
  display: flex;
  flex-direction: column;
  margin-top: 10px;
}

.donut-chart-wrap {
  display: flex;
  justify-content: center;
  padding: 6px 0 10px;
}

.donut-chart-wrap svg {
  width: 100%;
  max-width: 168px;
  height: auto;
  display: block;
}

.donut-legend {
  list-style: none;
  margin: 0;
  padding: 4px 0 0;
}

.donut-legend li {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-card);
}

.donut-legend li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.donut-legend .dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex-shrink: 0;
}

.donut-legend .label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.donut-legend .pct {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  min-width: 36px;
  text-align: right;
}

/* ── Onboarding insight panels ─────────────────────────────────────────── */
.onboarding-section {
  margin-top: 12px;
}

.section-head {
  margin-bottom: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 2px solid var(--border-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-flat);
}

.section-head .eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-hierarchy-2);
  margin: 0 0 4px;
}

.section-head h2 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 900;
  color: var(--text-main);
}

.section-lead {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.45;
  max-width: 640px;
}

.insight-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.insight-panel {
  background: linear-gradient(135deg, color-mix(in srgb, var(--panel-accent-tone, var(--accent-green-tone)) 55%, var(--surface)), var(--surface));
  border: 2px solid var(--panel-accent-border, var(--accent-green-border));
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  box-shadow: var(--shadow-flat);
  --panel-accent: var(--accent-green);
  --panel-accent-tone: var(--accent-green-tone);
  --panel-accent-border: var(--accent-green-border);
}

.insight-panel[data-accent="blue"] {
  --panel-accent: var(--button-blue);
  --panel-accent-tone: var(--accent-blue-tone);
  --panel-accent-border: var(--accent-blue-border);
}

.insight-panel[data-accent="coral"] {
  --panel-accent: var(--accent-coral);
  --panel-accent-tone: var(--accent-coral-tone);
  --panel-accent-border: #F9B3CE;
}

.insight-panel[data-accent="purple"] {
  --panel-accent: var(--accent-purple);
  --panel-accent-tone: var(--accent-purple-tone);
  --panel-accent-border: var(--accent-purple-border);
}

.insight-panel[data-accent="yellow"] {
  --panel-accent: var(--accent-yellow);
  --panel-accent-tone: var(--accent-yellow-tone);
  --panel-accent-border: var(--accent-yellow-border);
}

.insight-panel[data-accent="care"] {
  --panel-accent: var(--care-index-green);
  --panel-accent-tone: #E8F7EE;
  --panel-accent-border: #B8E8C8;
}

.insight-head {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--panel-accent-border) 65%, var(--border-card));
}

.insight-head .chart-eyebrow {
  color: var(--panel-accent);
}

.insight-title {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 900;
  color: var(--text-main);
  letter-spacing: -0.2px;
}

.insight-action {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.5;
  padding: 11px 13px;
  background: color-mix(in srgb, var(--panel-accent-tone) 70%, var(--surface));
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-accent-border);
}

.insight-action strong {
  color: var(--panel-accent);
  font-weight: 800;
}

.insight-split {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: center;
}

.insight-chart {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: var(--surface);
  border: 2px solid var(--border-card);
  border-radius: 50%;
  width: 280px;
  height: 280px;
  box-shadow: var(--shadow-card);
  flex-shrink: 0;
}

.insight-chart svg {
  width: 248px;
  height: 248px;
  display: block;
}

.insight-legend {
  list-style: none;
  margin: 0;
  padding: 2px 0 0;
  max-height: 280px;
  overflow-y: auto;
}

.insight-legend li {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-card);
}

.insight-legend li:last-child {
  border-bottom: 0;
}

.insight-legend .dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(57, 57, 56, 0.08);
}

.insight-legend .label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.35;
}

.insight-legend .pct {
  font-size: 13px;
  font-weight: 800;
  color: var(--panel-accent);
  font-variant-numeric: tabular-nums;
  min-width: 38px;
  text-align: right;
}

@media (max-width: 720px) {
  .insight-split {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .insight-chart {
    margin: 0 auto;
    width: 240px;
    height: 240px;
    padding: 12px;
  }

  .insight-chart svg {
    width: 212px;
    height: 212px;
  }

  .insight-legend {
    width: 100%;
    max-height: none;
  }
}

.split-bar {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  margin: 14px 0 8px;
  border: 1px solid var(--border-card);
}

.split-bar span { height: 100%; }

.split-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 700;
}

/* ── Tables ────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border: 2px solid var(--border-card);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-flat);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-card);
}

th {
  background: var(--background-warm);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-hierarchy-2);
  font-weight: 800;
}

td { font-weight: 600; color: var(--text-secondary); }
td strong { color: var(--text-main); font-weight: 800; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
}

.badge.active {
  background: var(--primary-light);
  color: var(--button-blue);
}

.badge.completed {
  background: var(--accent-green-tone);
  color: var(--success-dark);
}

.badge.risk {
  background: var(--urgency-bg);
  color: var(--urgency-text);
}

.module-dots { display: flex; gap: 4px; }

.module-dot {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  border: 2px solid var(--border-card);
  font-size: 11px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-hierarchy-2);
  background: var(--surface);
}

.module-dot.done {
  background: var(--accent-green-tone);
  border-color: var(--accent-green);
  color: var(--success-dark);
}

/* ── AI chat ───────────────────────────────────────────────────────────── */
.ai-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 12px;
}

.chat-box {
  background: var(--surface);
  border: 2px solid var(--border-card);
  border-radius: var(--radius-xl);
  min-height: 420px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-flat);
}

.chat-messages {
  flex: 1;
  padding: 18px;
  overflow-y: auto;
}

.msg {
  max-width: 85%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
}

.msg.user {
  background: var(--button-blue);
  color: #fff;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.msg.ai {
  background: var(--background-warm);
  border: 1px solid var(--border-card);
  color: var(--text-secondary);
  border-bottom-left-radius: 4px;
}

.msg.ai strong {
  color: var(--text-main);
  font-weight: 800;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border-card);
}

.chat-input-row input {
  flex: 1;
  border: 2px solid var(--border-card);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  font-weight: 600;
  background: var(--background-warm);
  color: var(--text-main);
}

.chat-input-row input:focus {
  outline: none;
  border-color: var(--button-blue);
}

.chat-input-row button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--button-blue);
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow-flat);
}

.chat-input-row button ion-icon {
  font-size: 18px;
  color: #fff;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.info-card {
  background: var(--surface);
  border: 2px solid var(--border-card);
  border-radius: var(--radius-xl);
  padding: 14px;
  box-shadow: var(--shadow-flat);
}

.info-card.accent-green {
  border-color: var(--accent-green-border);
  background: linear-gradient(135deg, var(--accent-green-tone), var(--surface));
}

.info-card h4 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 900;
  color: var(--text-main);
}

.info-card p {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  line-height: 1.45;
}

.stat-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.stat-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-card);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.stat-list li strong {
  color: var(--text-main);
  font-weight: 900;
}

.suggest-btn {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 2px solid var(--border-card);
  background: var(--background-warm);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 6px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

.suggest-btn ion-icon {
  font-size: 16px;
  color: var(--button-blue);
  flex-shrink: 0;
  margin-top: 1px;
}

.suggest-btn:hover {
  border-color: var(--button-blue);
  background: var(--primary-light);
}

/* ── Resource cards ────────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.resource-card {
  background: var(--surface);
  border: 2px solid var(--border-card);
  border-radius: var(--radius-xl);
  padding: 16px;
  box-shadow: var(--shadow-flat);
}

.resource-card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.resource-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--primary-light);
  border: 1px solid var(--accent-blue-border);
}

.resource-icon ion-icon {
  font-size: 22px;
  color: var(--button-blue);
}

.resource-card h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 900;
  color: var(--text-main);
}

.resource-card p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
  line-height: 1.45;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  border: 0;
  font-family: inherit;
}

.btn ion-icon { font-size: 18px; }

.btn.primary {
  background: var(--button-blue);
  color: #fff;
  box-shadow: var(--shadow-flat);
}

.btn.secondary {
  background: var(--surface);
  border: 2px solid var(--border-card);
  color: var(--text-main);
  box-shadow: var(--shadow-card);
}

.note {
  background: var(--primary-light);
  border: 2px solid var(--accent-blue-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 16px;
  line-height: 1.45;
}

.note code {
  font-size: 12px;
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border-card);
}

/* Customisation — editor + app preview */
.hub-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  padding: 14px 16px;
  background: var(--surface);
  border: 2px solid var(--border-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

.hub-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hub-toolbar-actions .btn { margin-top: 0; }

.hub-status {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

.hub-status-dirty { color: var(--urgency-text); }
.hub-status-draft { color: var(--button-blue); }
.hub-status-live { color: var(--success-dark); }

.customisation-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 24px;
  align-items: start;
}

.hub-editor-panel {
  min-width: 0;
}

.hub-editor {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hub-edit-block {
  background: var(--surface);
  border: 2px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}

.hub-edit-block-primary {
  border-color: color-mix(in srgb, var(--inst-accent, #C8102E) 22%, var(--border-card));
}

.hub-edit-block-head { margin-bottom: 14px; }

.hub-acc-group .hub-edit-title,
.hub-acc-group-solo .hub-acc-item { margin-top: 0; }

.hub-acc-group .hub-edit-desc { margin-bottom: 12px; }

.hub-accordion {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hub-acc-item {
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  background: var(--background-warm);
  overflow: hidden;
}

.hub-acc-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
}

.hub-acc-trigger:hover { background: color-mix(in srgb, var(--surface) 70%, var(--background-warm)); }

.hub-acc-emoji {
  font-size: 18px;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.hub-acc-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hub-acc-text strong {
  font-size: 14px;
  font-weight: 900;
  color: var(--text-main);
}

.hub-acc-text small {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.hub-acc-chevron {
  font-size: 18px;
  color: var(--text-hierarchy-2);
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.hub-acc-item.is-open .hub-acc-chevron { transform: rotate(180deg); }

.hub-acc-body {
  padding: 0 14px 14px;
  border-top: 1px solid var(--border-card);
}

.hub-acc-body[hidden] { display: none; }

.hub-acc-empty {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.hub-edit-repeat-compact {
  padding: 10px;
  margin-bottom: 8px;
}

.hub-edit-repeat-compact textarea,
.hub-edit-repeat-compact input,
.hub-edit-repeat-compact select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-card);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  background: var(--surface);
}

.hub-inline-title {
  flex: 1;
  font-weight: 800 !important;
}

.hub-edit-grid-3 {
  grid-template-columns: 100px 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.hub-contact-subtitle-input { margin-top: 0; }

.hub-edit-title {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 900;
  color: var(--text-main);
}

.hub-edit-desc {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.45;
}

.hub-edit-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 16px 0 10px;
  font-size: 13px;
  font-weight: 900;
  color: var(--text-main);
}

.hub-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.hub-field span {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-hierarchy-2);
  letter-spacing: 0.3px;
}

.hub-field input,
.hub-field textarea,
.hub-field select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border-card);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  background: var(--background-warm);
}

.hub-field textarea { resize: vertical; min-height: 72px; }

.hub-field input:focus,
.hub-field textarea:focus,
.hub-field select:focus {
  outline: none;
  border-color: var(--button-blue);
  background: var(--surface);
}

.hub-edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.hub-edit-repeat {
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  background: var(--background-warm);
}

.hub-edit-repeat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.hub-edit-repeat-label {
  font-size: 12px;
  font-weight: 900;
  color: var(--text-main);
}

.hub-edit-link-btn {
  border: 0;
  background: none;
  padding: 0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  color: var(--button-blue);
  cursor: pointer;
}

.hub-policy-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }

.hub-policy-empty {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.hub-policy-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  background: var(--background-warm);
}

.hub-policy-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hub-policy-icon ion-icon {
  font-size: 18px;
  color: var(--button-blue);
}

.hub-policy-body { flex: 1; min-width: 0; }

.hub-policy-title {
  font-size: 14px;
  font-weight: 900;
  color: var(--text-main);
}

.hub-policy-meta {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hub-policy-replace {
  flex-shrink: 0;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  color: var(--button-blue);
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--accent-blue-border);
  background: var(--surface);
}

.hub-policy-replace:hover { background: var(--primary-light); }

.hub-policy-add-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.hub-policy-upload { cursor: pointer; }

.hub-policy-add-btn {
  margin-top: 0;
  pointer-events: none;
}

.hub-policy-link-field {
  margin-bottom: 0;
  min-width: 200px;
  flex: 1;
}

.hub-policy-link-field select {
  padding: 10px 12px;
  border: 2px solid var(--border-card);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  background: var(--background-warm);
}

.hub-preview-column {
  position: sticky;
  top: 16px;
}

.hub-preview-note {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.45;
}

.hub-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  max-width: 360px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--text-main);
  color: var(--surface);
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(57, 57, 56, 0.2);
}

.hub-toast.hidden { display: none; }

/* Institution hub preview (matches app Partner support) */
.hub-preview-shell {
  max-width: 420px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-card);
  background: var(--background-warm, #F7F5F0);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.hub-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-hairline, #E9E7E2);
}

.hub-preview-label {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-hierarchy-2, #6B6A68);
}

.hub-preview-screen {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-main);
}

.hub-preview {
  --hub-accent: var(--inst-accent, #C8102E);
  --hub-accent-14: color-mix(in srgb, var(--hub-accent) 14%, transparent);
  --hub-accent-18: color-mix(in srgb, var(--hub-accent) 18%, transparent);
  --hub-card-border: var(--border-card);
  --hub-gradient-start: var(--surface);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 520px;
}

.hub-hero {
  border-radius: var(--radius-lg);
  border: 2px solid var(--hub-card-border);
  background: linear-gradient(135deg, var(--hub-gradient-start) 0%, var(--surface) 100%);
  box-shadow: var(--shadow-flat);
  padding: 16px;
}

.hub-hero-eyebrow {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--text-hierarchy-2, #6B6A68);
  margin-bottom: 12px;
}

.hub-hero-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hub-logo-wrap {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  border: 2px solid var(--border-card);
  background: var(--surface);
  box-shadow: var(--shadow-flat);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hub-logo-wrap img {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.hub-hero-text { flex: 1; }

.hub-hero-name {
  font-size: 22px;
  font-weight: 900;
  line-height: 1.25;
  color: var(--text-main);
  margin-bottom: 6px;
}

.hub-hero-intro {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text-secondary);
}

.hub-block { display: flex; flex-direction: column; gap: 8px; }

.hub-block-title {
  font-size: 18px;
  font-weight: 900;
  color: var(--text-main);
}

.hub-card {
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-card);
  background: var(--surface);
  box-shadow: var(--shadow-flat);
  overflow: hidden;
}

.hub-card-flush { padding: 0; }

.hub-event-row,
.hub-resource-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  background: transparent;
  text-align: left;
  font-family: inherit;
  cursor: default;
}

.hub-event-row-border,
.hub-resource-row {
  border-bottom: 1px solid var(--border-hairline, #E9E7E2);
}

.hub-resource-row:last-child { border-bottom: 0; }

.hub-event-row[data-event-url] { cursor: pointer; }
.hub-event-row[data-event-url]:hover { opacity: 0.85; }

.hub-event-icon,
.hub-resource-icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--hub-accent-18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.hub-event-icon ion-icon {
  font-size: 18px;
  color: var(--hub-accent);
}

.hub-resource-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--hub-accent-14);
  margin-top: 0;
}

.hub-resource-icon span { font-size: 20px; }

.hub-event-body,
.hub-resource-body {
  flex: 1;
  min-width: 0;
}

.hub-event-title,
.hub-resource-title {
  font-size: 14px;
  font-weight: 900;
  color: var(--text-main);
}

.hub-resource-title { font-size: 15px; }

.hub-event-meta,
.hub-resource-category {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-hierarchy-2, #6B6A68);
}

.hub-resource-category {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.8px;
}

.hub-event-location {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-secondary);
  margin-top: 2px;
}

.hub-event-desc,
.hub-resource-summary {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-secondary);
  margin-top: 4px;
}

.hub-resource-summary {
  color: var(--text-hierarchy-2, #6B6A68);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hub-event-pin {
  font-size: 18px;
  color: var(--text-hierarchy-2, #6B6A68);
  flex-shrink: 0;
}

.hub-resource-row {
  align-items: center;
  cursor: pointer;
}

.hub-resource-row:hover { opacity: 0.85; }

.hub-resource-chevron {
  font-size: 22px;
  font-weight: 900;
  color: var(--text-hierarchy-2, #6B6A68);
  line-height: 1;
}

.hub-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.hub-modal.hidden { display: none; }

.hub-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(57, 57, 56, 0.45);
}

.hub-modal-panel {
  position: relative;
  width: min(420px, 100%);
  max-height: min(90vh, 820px);
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-card);
  background: var(--background-warm, #F7F5F0);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hub-modal-chrome {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 8px;
  background: var(--background-warm, #F7F5F0);
}

.hub-back-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: inherit;
}

.hub-back-btn ion-icon {
  font-size: 22px;
  color: var(--text-main);
}

.hub-modal-title {
  flex: 1;
  margin: 0;
  font-size: 15px;
  font-weight: 900;
  text-align: center;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hub-modal-spacer { width: 44px; flex-shrink: 0; }

.hub-detail-body {
  overflow-y: auto;
  padding: 0 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hub-detail-hero {
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-card);
  background: var(--surface);
  box-shadow: var(--shadow-flat);
  padding: 16px;
}

.hub-detail-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--hub-accent-14);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

.hub-detail-icon span { font-size: 24px; }

.hub-detail-category {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.8px;
  color: var(--text-hierarchy-2, #6B6A68);
}

.hub-detail-title {
  font-size: 22px;
  font-weight: 900;
  line-height: 1.25;
  color: var(--text-main);
  margin-top: 4px;
}

.hub-detail-summary {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text-secondary);
  margin-top: 6px;
}

.hub-detail-section { display: flex; flex-direction: column; gap: 8px; }

.hub-detail-label {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.8px;
  color: var(--hub-accent);
  padding-left: 4px;
}

.hub-detail-card {
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-card);
  background: var(--surface);
  box-shadow: var(--shadow-flat);
  padding: 16px;
}

.hub-detail-card p {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text-main);
}

.hub-detail-card p strong { font-weight: 900; }

.hub-detail-card-flush { padding: 0; }

.hub-contact-row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
}

.hub-contact-row-border {
  border-bottom: 1px solid var(--border-hairline, #E9E7E2);
}

.hub-contact-icon {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--hub-accent-18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hub-contact-icon ion-icon {
  font-size: 18px;
  color: var(--hub-accent);
}

.hub-contact-icon-mail {
  background: transparent;
}

.hub-contact-mail {
  font-size: 28px;
  color: var(--button-blue);
}

.hub-contact-text { flex: 1; min-width: 0; }

.hub-contact-label {
  font-size: 14px;
  font-weight: 900;
  color: var(--text-heading, var(--text-main));
  line-height: 1.35;
}

.hub-contact-subtitle {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, var(--text-secondary));
  line-height: 1.35;
}

.hub-contact-chevron {
  font-size: 16px;
  color: var(--text-muted, var(--text-secondary));
  flex-shrink: 0;
}

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .kpi-grid, .chart-grid, .chart-grid.three, .ai-layout { grid-template-columns: 1fr; }
  .chart-card.wide { grid-column: span 1; }
  .customisation-layout { grid-template-columns: 1fr; }
  .hub-preview-column { position: static; }
  .hub-toolbar-actions { width: 100%; }
  .hub-edit-grid { grid-template-columns: 1fr; }
  .hub-edit-grid-3 { grid-template-columns: 1fr; }
}
