  :root {
    --purple-dark: #4a2d6b;
    --purple-mid: #7b4fa6;
    --purple-light: #c9a0e0;
    --purple-pale: #ede0f7;
    --green-complete: #4caf72;
    --green-light: #c8f0d5;
    --white: #ffffff;
    --grey-light: #f5f5f5;
    --grey-border: #ddd;
    --text-dark: #1a1a1a;
    --text-mid: #444;
    --stage-bg: rgba(180,130,210,0.18);
    --stage-border: rgba(120,60,170,0.25);
    --modal-overlay: rgba(0,0,0,0.45);
    --font-main: 'Segoe UI', Arial, sans-serif;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    font-family: var(--font-main);
    background: #e8f0f7;
    color: var(--text-dark);
    min-height: 100vh;
  }

  /* ── TOP NAV ── */
  .top-nav {
    background: var(--purple-dark);
    display: flex;
    align-items: center;
    padding: 0 18px;
    height: 52px;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .logo {
    display: flex;
    align-items: center;
    gap: 3px;
    font-weight: 800;
    letter-spacing: 1px;
    margin-right: 16px;
    cursor: pointer;
  }
  .logo:hover { opacity: 0.85; }

  .nav-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
  }
  .nav-establishment {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.6);
    white-space: nowrap;
  }

  .nav-divider {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.25);
  }

  .nav-actions {
    display: flex;
    gap: 8px;
  }

  .nav-btn {
    background: rgba(255,255,255,0.16);
    border: 1px solid rgba(255,255,255,0.28);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
  }
  .nav-btn:hover { background: rgba(255,255,255,0.28); }

  /* ── LEARNER CONTEXT BANNER ── */
  .learner-context-banner {
    display: flex;
    align-items: center;
    position: relative;
    padding: 6px 8px;
    background: rgba(42, 157, 143, 0.08);
    border-top: 2px solid #2a9d8f;
    border-bottom: 2px solid #2a9d8f;
    flex-shrink: 0;
  }
  .learner-banner-title {
    position: absolute;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--purple-dark);
    letter-spacing: 0.2px;
    pointer-events: none;
  }
  .learner-close-btn {
    margin-left: auto;
    background: transparent;
    border: 1.5px solid rgba(74,45,107,0.35);
    border-radius: 8px;
    color: var(--purple-dark);
    padding: 5px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-main);
    transition: background 0.15s, border-color 0.15s;
    position: relative;
    z-index: 1;
    white-space: nowrap;
  }
  .learner-close-btn:hover { background: rgba(74,45,107,0.08); border-color: rgba(74,45,107,0.55); }

  /* ── PROFILES SUB-NAV ── */
  .profiles-subnav {
    background: var(--purple-pale);
    border-bottom: 1px solid var(--purple-light);
    padding: 0 16px;
    display: flex;
    align-items: stretch;
    gap: 2px;
    overflow-x: auto;
  }
  .profiles-tab {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 8px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--purple-dark);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
  }
  .profiles-tab:hover { background: rgba(74,45,107,0.1); }
  .profiles-tab.active { border-bottom-color: var(--purple-dark); background: rgba(74,45,107,0.08); }
  .profiles-subnav .print-btn { margin-left: auto; align-self: center; }

  /* ── SIDE NAV ── */
  .layout {
    display: flex;
    flex: 1;
    min-height: 0;
  }

  .side-nav {
    width: 130px;
    background: var(--purple-dark);
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 8px;
    flex-shrink: 0;
  }

  .side-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 8px;
    color: rgba(255,255,255,0.8);
    padding: 10px 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    transition: background 0.15s;
    text-align: center;
    line-height: 1.2;
  }

  .side-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }
  .side-btn.active { background: #fff; color: var(--purple-dark); }
  .side-btn .icon { font-size: 1.2rem; }

  /* ── MAIN COLUMN (right of side-nav) ── */
  .main-col {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  /* ── MAIN CONTENT ── */
  .main {
    flex: 1;
    overflow: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .learner-info {
    display: flex;
    gap: 24px;
    font-size: 0.82rem;
    color: var(--text-mid);
  }

  .learner-info span { font-weight: 600; color: var(--text-dark); }

  .print-btn {
    background: var(--green-complete);
    color: #fff;
    border: none;
    border-radius: 7px;
    padding: 7px 18px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
  }

  /* ── PROFILE GRID ── */
  .profile-grid-wrap {
    background: var(--white);
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.1);
    overflow-x: scroll;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 180px;
  }

  /* ── Profile layout: stage-column-first structure ─────────── */

  .profile-layout {
    position: relative;
    display: flex;
    flex-direction: row;
    gap: 20px;
    align-items: flex-start;
    background: var(--white);  /* fills flex-gap strips so nothing shows through on scroll */
  }

  /* ── Sticky left panel: strand labels column, scrolls with the grid ── */
  .sticky-left-panel {
    position: sticky;
    left: 0;
    z-index: 20;
    background: var(--white);
    display: flex;
    flex-direction: row;
    align-items: stretch;
    flex-shrink: 0;
    /* extend white infinitely left to mask overflow scroll artefacts */
    box-shadow: -9999px 0 0 9999px var(--white), 6px 0 8px rgba(0,0,0,0.07);
  }

  /* Preparation access button — sits in the strand-labels corner cell,
     teal-coloured, opens the prep modules popup. Only shown when the KSA
     has preparation modules. */
  .prep-access-btn {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 6px;
    padding: 6px 8px;
    background: #2a9d8f;
    color: #fff;
    font-family: inherit;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    text-align: center;
    line-height: 1.3;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .prep-access-btn:hover { background: #1d7a6e; }

  /* Prep modules modal — wider than the assessment modal to fit a row of buttons */
  .prep-modal { max-width: 680px; }

  .prep-module-group {
    margin-bottom: 20px;
  }
  .prep-module-group:last-child { margin-bottom: 0; }

  .prep-group-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: #2a9d8f;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 2px solid #2a9d8f;
  }

  .prep-module-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .prep-module-row .module-btn {
    flex: none;
    width: 130px;
  }

  /* Strand labels column — sticky behaviour handled by parent panel */
  .strand-labels-col {
    flex: 0 0 110px;
    background: var(--white);
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 4px;
  }

  .strand-labels-corner {
    flex-shrink: 0;
    min-height: 50px; /* approximate stage-header height — prevents prep button from flickering on render */
    /* exact height synced to .stage-header height by JS after layout settles */
  }

  .strand-label {
    background: var(--purple-dark);
    color: #fff;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 0.68rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.25;
    flex-shrink: 0;
    /* height synced per strand by JS */
  }

  /* Each stage is a self-contained rounded column */
  .stage-column {
    flex: 0 0 420px;
    display: flex;
    flex-direction: column;
    background: var(--purple-pale);
    border-radius: 12px;
    overflow: hidden;
  }

  .stage-header {
    background: var(--purple-mid);
    color: #fff;
    padding: 8px 6px;
    text-align: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
  }

  .stage-header:hover { background: var(--purple-dark); }

  .stage-title {
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.3;
  }

  .stage-sub {
    font-size: 0.65rem;
    font-weight: 400;
    opacity: 0.88;
    display: block;
    margin-top: 2px;
  }

  .stage-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px;
    flex: 1;
  }

  /* One zone per strand within a stage column */
  .strand-zone {
    display: flex;
    flex-direction: row;
    gap: 0;
    align-items: center;
    justify-content: center;
    padding: 3px;
    border-radius: 5px;
    flex-shrink: 0;
    /* height synced per strand by JS */
  }

  /* Pre-fork / post-merge zones on a branching strand: modules float at
     the vertical centre of the double-height row (the "main branch" line) */
  .strand-zone-main-branch {
    align-items: center;
    justify-content: center;
  }

  /* Branching strand zone: two path rows stacked, spaced around centre */
  .strand-zone-split {
    flex-direction: column;
    justify-content: space-evenly;
    align-items: stretch;   /* override inherited center so path rows fill zone width */
    gap: 3px;
  }

  /* Mixed zone: one stage column has BOTH shared modules and branching path rows.
     Used when the fork or merge point falls within a single stage column.
     Shared modules appear LEFT of path rows (fork) or RIGHT of path rows (merge).
     flex-direction: row puts sections side-by-side so the grid reads left-to-right. */
  .strand-zone-mixed {
    flex-direction: row;
    align-items: stretch;
    gap: 3px;
  }
  .mixed-shared-section {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    flex: 1;          /* equal share of column — prevents squashing when shared has many modules */
    min-width: 0;
  }
  .mixed-path-section {
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    align-items: stretch;
    gap: 3px;
    flex: 1;          /* fill remaining column width */
    min-width: 0;
  }

  /* Strand continuation name: sits inline in the module row like a module button,
     but styled as a strand label (dark purple, white text, uppercase).
     Used at the stage where a strand changes name (Reaching → Social Function). */
  .module-strand-name {
    flex: 1;
    min-width: 0;
    max-width: 122px;
    min-height: 44px;
    height: 44px;
    padding: 4px 3px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.25;
    white-space: normal;
    word-break: break-word;
    background: var(--purple-dark);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    flex-shrink: 0;
    position: relative; /* raises label above the connector overlay */
    z-index: 1;
  }

  .path-row {
    display: flex;
    flex-direction: row;
    gap: 0;
    align-items: center;
    justify-content: center;
    padding: 3px;
    border-radius: 4px;
    background: rgba(255,255,255,0.2);
    min-height: 36px;
  }

  /* (continuation zones now use plain .strand-zone with an inline .module-strand-name element) */

  /* ── Connector lines between sequential modules ──────────────── */
  .module-connector {
    flex: 0 0 20px;
    height: 2px;
    background: rgba(120, 60, 170, 0.35);
    align-self: center;
  }

  /* ── Cross-stage connector overlay ───────────────────────────── */
  .connector-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
  }

  .h-connector, .v-connector {
    position: absolute;
    background: rgba(120, 60, 170, 0.35);
    pointer-events: none;
  }

  .h-connector { height: 2px; }
  .v-connector { width:  2px; }

  /* (prep modules are accessed via the teal Preparation button in the strand labels corner) */

  /* ── Module buttons ─────────────────────────────────────────── */

  .module-btn {
    background: #fff;
    border: 1.5px solid rgba(120,60,170,0.3);
    border-radius: 5px;
    padding: 4px 3px;
    font-size: 0.62rem;
    font-weight: 600;
    cursor: pointer;
    line-height: 1.25;
    text-align: center;
    transition: all 0.15s;
    color: var(--text-dark);
    flex: 1;
    min-width: 0;
    max-width: 122px;
    min-height: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: normal;
    word-break: break-word;
    hyphens: auto;
    overflow: hidden;
  }

  .module-btn:hover {
    border-color: var(--purple-mid);
    background: var(--purple-pale);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(120,60,170,0.2);
  }

  .module-btn.complete {
    background: var(--green-light);
    border-color: var(--green-complete);
    color: #1a5c30;
  }

  /* ── MODAL ── */
  .modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-overlay);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }

  .modal-overlay.open {
    opacity: 1;
    pointer-events: all;
  }

  .modal {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 820px;
    max-height: 85vh;
    box-shadow: 0 8px 40px rgba(0,0,0,0.3);
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
  }

  .modal-overlay.open .modal { transform: scale(1); }

  .modal-header {
    background: var(--purple-mid);
    color: #fff;
    padding: 14px 20px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
  }

  .modal-meta { display: flex; flex-direction: column; gap: 4px; }

  .modal-module-name { font-size: 1.05rem; font-weight: 700; }

  .modal-tags { display: flex; gap: 6px; flex-wrap: wrap; }

  .modal-tag {
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.72rem;
    font-weight: 600;
  }

  .modal-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    border-radius: 6px;
    width: 30px; height: 30px;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .modal-close:hover { background: rgba(255,255,255,0.35); }

  .modal-body { padding: 18px 20px; overflow-y: auto; min-height: 0; }

  .help-body { display: flex; flex-direction: column; gap: 18px; }
  .help-section h3 { font-size: 0.95rem; color: var(--purple-dark); margin-bottom: 6px; }
  .help-section p { font-size: 0.86rem; color: var(--text-mid); line-height: 1.55; }
  .feedback-intro { font-size: 0.85rem; color: var(--text-mid); line-height: 1.5; margin: 0 0 16px; }

  .modal-section-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--purple-dark);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 2px solid var(--purple-pale);
  }

  .aq-row {
    display: grid;
    grid-template-columns: 1fr 80px 130px 200px;
    gap: 8px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.82rem;
  }

  .aq-row:last-child { border-bottom: none; }

  .aq-question { color: var(--text-mid); line-height: 1.4; }

  .aq-toggle {
    border: none;
    border-radius: 6px;
    padding: 6px 0;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    width: 100%;
  }

  .aq-toggle.yes { background: var(--green-complete); color: #fff; }
  .aq-toggle.no  { background: #e74c3c; color: #fff; }

  .aq-date { font-size: 0.75rem; color: #888; text-align: center; }

  .aq-comment {
    border: 1px solid var(--grey-border);
    border-radius: 5px;
    padding: 4px 7px;
    font-size: 0.78rem;
    width: 100%;
    font-family: var(--font-main);
    resize: none;
    height: 36px;
  }

  .aq-comment:focus { outline: none; border-color: var(--purple-mid); }

  .modal-score {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--grey-light);
    border-radius: 8px;
    margin-top: 14px;
    font-size: 0.82rem;
  }

  .modal-locked-warning {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fff8e1;
    border: 1px solid #f0c030;
    border-radius: 7px;
    font-size: 0.78rem;
    color: #7a5500;
    margin-bottom: 10px;
  }

  .modal-locked-warning.visible { display: flex; }

  .modal-locked-warning::before {
    content: '⚠';
    font-size: 1rem;
    flex-shrink: 0;
  }

  /* Preparation prerequisite warning — teal-themed, shown when prep modules are incomplete */
  .modal-prep-warning {
    display: none;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(42, 157, 143, 0.08);
    border: 1px solid #2a9d8f;
    border-radius: 7px;
    font-size: 0.78rem;
    color: #1d5c56;
    margin-bottom: 10px;
  }
  .modal-prep-warning.visible { display: flex; }
  .modal-prep-warning::before {
    content: '📋';
    font-size: 1rem;
    flex-shrink: 0;
  }
  /* Pill tags for strand names in prep modal and warnings */
  .prep-strand-pill {
    display: inline-block;
    background: rgba(42, 157, 143, 0.15);
    color: #1d5c56;
    border-radius: 20px;
    padding: 2px 9px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
  }
  /* Small "Open Preparation" link-button inside the warning */
  .prep-warning-link {
    background: none;
    border: none;
    color: #2a9d8f;
    font-size: 0.78rem;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
  }
  .prep-warning-link:hover { color: #1d7a6e; }

  .score-badge {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
  }

  .score-badge.complete { background: var(--green-complete); }
  .score-badge.partial  { background: #f39c12; }
  .score-badge.none     { background: #bbb; }

  .modal-footer {
    padding: 12px 20px;
    background: var(--grey-light);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
  }

  .btn-clear {
    background: #fff;
    border: 1.5px solid var(--grey-border);
    border-radius: 7px;
    padding: 8px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-mid);
  }

  .btn-clear:hover { border-color: #aaa; }

  .btn-complete-all {
    background: var(--purple-light);
    border: none;
    border-radius: 7px;
    padding: 8px 18px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    color: var(--purple-dark);
  }

  .btn-finished {
    background: var(--purple-dark);
    border: none;
    border-radius: 7px;
    padding: 8px 24px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    color: #fff;
  }

  .btn-finished:hover { background: var(--purple-mid); }

  /* ── LEGEND ── */
  .legend {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 8px 14px;
    background: #fff;
    border-radius: 8px;
    font-size: 0.78rem;
    color: var(--text-mid);
    flex-wrap: wrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  }

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

  .legend-dot {
    width: 14px; height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
  }

  /* ── HISTORICAL MODE ── */
  .legend-mode-area {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }
  .legend-hint { font-size: 0.75rem; color: #999; }

  .history-toggle-btn {
    font-size: 0.72rem; font-weight: 700;
    padding: 4px 10px; border-radius: 5px;
    border: 1.5px solid #c8820a; color: #7a5000;
    background: transparent; cursor: pointer;
    letter-spacing: 0.03em; white-space: nowrap;
  }
  .history-toggle-btn:hover { background: rgba(232,160,32,0.1); }

  .history-badge {
    display: none;
    font-size: 0.75rem; font-weight: 600;
    color: #7a5000; white-space: nowrap;
  }

  .snapshot-date-input {
    display: none;
    font-size: 0.75rem; padding: 3px 7px;
    border: 1.5px solid #c8820a; border-radius: 5px;
    color: #604010; background: #fffbf0; cursor: pointer;
  }

  .snapshot-status {
    font-size: 0.72rem; color: #a06010; font-style: italic;
    min-width: 60px;
  }

  /* Legend bar in historical mode (both the single-KSA grid and the All KSA
     Profiles overview share this toolbar styling) */
  #profileContent.historical-mode .legend,
  #profilesHomeContent.historical-mode .legend {
    background: #fffbf0;
    border: 1.5px solid #e8a020;
  }
  #profileContent.historical-mode .history-badge,
  #profilesHomeContent.historical-mode .history-badge       { display: inline-block; }
  #profileContent.historical-mode .snapshot-date-input,
  #profilesHomeContent.historical-mode .snapshot-date-input { display: block; }
  #profileContent.historical-mode .legend-hint,
  #profilesHomeContent.historical-mode .legend-hint         { display: none; }
  #profileContent.historical-mode .history-toggle-btn,
  #profilesHomeContent.historical-mode .history-toggle-btn {
    background: #e8a020; color: #fff; border-color: #e8a020;
  }

  /* Profile overview: spacing between the toolbar and the intro/table below —
     #profilesHomeContent is a plain block container, unlike #profileContent's
     flex layout which gets this gap for free. */
  #profilesHomeContent > .legend { margin-bottom: 16px; }

  /* Profile overview: amber top border in historical mode, matching the
     single-KSA grid's .profile-grid-wrap treatment */
  #profilesHomeContent.historical-mode .po-wrap {
    border-top: 3px solid #e8a020;
  }

  /* Best Fit Stage picker: no historical event log exists for it, so it's
     disabled (not hidden) with a caveat when viewing a past date. */
  .po-picker-sel:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background: #f5f3fa;
  }
  .po-picker-caveat {
    font-size: 0.68rem;
    color: #a06010;
    font-style: italic;
    margin-top: 4px;
    line-height: 1.3;
  }

  /* Profile grid amber top border in historical mode */
  #profileContent.historical-mode .profile-grid-wrap {
    border-top: 3px solid #e8a020;
    border-radius: 0 0 8px 8px;
  }
  /* stage headers are unchanged in historical mode — amber border is sufficient */

  /* Historical banner inside assessment modal */
  .modal-historical-banner {
    display: none;
    padding: 8px 12px;
    background: rgba(232, 160, 32, 0.1);
    border: 1px solid #e8a020;
    border-radius: 7px;
    font-size: 0.78rem; color: #7a5000;
    margin-bottom: 10px;
  }
  .modal-historical-banner.visible { display: block; }

  /* Disabled AQ toggles look muted in historical mode */
  .aq-toggle:disabled { opacity: 0.65; cursor: default; }
  .aq-comment[readonly] { background: #f8f8f8; color: #888; cursor: default; resize: none; }

  /* ── STAGE DESCRIPTOR MODAL ── */
  .stage-modal {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 560px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.3);
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.2s;
  }

  .modal-overlay.open .stage-modal { transform: scale(1); }

  .stage-modal-header {
    background: var(--purple-mid);
    color: #fff;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .stage-modal-title { font-size: 1.05rem; font-weight: 700; }
  .stage-modal-sub { font-size: 0.8rem; opacity: 0.85; margin-top: 2px; }

  .stage-modal-body { padding: 18px 20px; }

  .stage-description {
    font-size: 0.85rem;
    color: var(--text-mid);
    line-height: 1.55;
    margin-bottom: 14px;
  }

  .stage-behaviours-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--purple-dark);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 2px solid var(--purple-pale);
  }

  .stage-behaviours {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .stage-behaviour-tag {
    background: var(--purple-pale);
    color: var(--purple-dark);
    border-radius: 5px;
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 600;
  }

  /* ── HOME PAGE ── */
  #homeContent  { display: none; }
  #profilesHomeContent { display: none; }

  /* ── Profiles overview (three-column table) ── */
  .po-intro { font-size: 0.85rem; color: #888; margin-bottom: 16px; line-height: 1.55; }
  .po-wrap {
    background: #fff; border-radius: 10px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.08); border: 1.5px solid #ebe8f5; overflow: hidden;
    width: fit-content;
  }
  /* Column headers row */
  .po-col-hdrs {
    display: flex; flex-direction: row; align-items: center;
    gap: 16px; padding: 10px 18px 8px;
    border-bottom: 2px solid #ebe8f5; background: #faf8fd;
  }
  .po-col-hdr { font-size: 0.68rem; font-weight: 700; color: #aaa; text-transform: uppercase; letter-spacing: 0.06em; }
  .po-col-hdr-ksa  { flex: 0 0 150px; }
  .po-col-hdr-thumb  { flex: 0 0 620px; }
  .po-col-hdr-picker { flex: 0 0 195px; }
  /* Data rows */
  .po-row {
    display: flex; flex-direction: row; align-items: center;
    gap: 16px; padding: 14px 18px; border-bottom: 1px solid #f0edf8;
  }
  .po-row:last-child { border-bottom: none; }
  /* Column 1: KSA pill button */
  .po-ksa { flex: 0 0 150px; display: flex; align-items: center; justify-content: center; }
  .po-ksa-pill {
    width: 100%; background: var(--purple-dark); color: #fff;
    border: none; border-radius: 20px; padding: 10px 12px;
    font-size: 0.82rem; font-weight: 700; cursor: pointer;
    font-family: var(--font-main); text-align: center; line-height: 1.3;
    transition: background 0.15s;
  }
  .po-ksa-pill:hover { background: var(--purple-mid); }
  /* Column 2: profile thumbnail */
  .po-thumb { flex: 0 0 620px; }
  .po-thumb-wrap {
    border: 1px solid #ddd4f0; border-radius: 6px; overflow: hidden;
    cursor: pointer; transition: border-color 0.15s;
  }
  .po-thumb-wrap:hover { border-color: var(--purple-mid); }
  .po-thumb-hdr {
    display: grid; grid-template-columns: 22px repeat(7, 1fr);
    gap: 2px; padding: 2px 2px 0; background: #f3eefb;
  }
  .po-thumb-hdr-corner { /* blank — matches strand label column */ }
  .po-thumb-hdr-stage {
    background: var(--purple-mid); color: #fff;
    font-size: 0.58rem; font-weight: 700; text-align: center;
    padding: 5px 2px; border-radius: 3px 3px 0 0;
    white-space: normal; overflow-wrap: break-word; line-height: 1.25; hyphens: auto;
  }
  .po-thumb-body { display: flex; flex-direction: column; gap: 3px; padding: 3px; background: #f3eefb; }
  .po-strand-row { display: grid; grid-template-columns: 22px repeat(7, 1fr); gap: 2px; height: 26px; }
  .po-strand-label { background: var(--purple-dark); border-radius: 3px; }
  .po-stage-zone {
    background: var(--purple-pale); border-radius: 3px;
    display: flex; flex-direction: row; gap: 2px; align-items: center; justify-content: center; padding: 3px;
  }
  .po-mod { flex: 1; height: 100%; border-radius: 2px; background: #fff; border: 1px solid rgba(120,60,170,0.18); }
  .po-mod.complete { background: var(--green-light); border-color: var(--green-complete); }
  /* Column 3: stage picker */
  .po-picker { flex: 0 0 195px; display: flex; flex-direction: column; align-self: center; }
  .po-picker-sel {
    width: 100%; padding: 8px 10px; border: 1.5px solid var(--purple-light); border-radius: 7px;
    font-family: var(--font-main); font-size: 0.82rem; color: var(--text-dark); background: #fff; cursor: pointer;
  }
  .po-picker-sel:focus { border-color: var(--purple-mid); outline: none; box-shadow: 0 0 0 2px rgba(123,79,166,0.12); }

#profileContent { display: flex; flex-direction: column; gap: 14px; flex: 1; min-height: 0; }

  .home-grid {
    display: grid;
    grid-template-columns: 230px 1fr 340px;
    gap: 14px;
    align-items: start;
  }

  .home-card {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.1);
  }

  .home-card-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--purple-dark);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--purple-pale);
  }

  /* Learner info card */
  .learner-photo-wrap {
    display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 14px;
  }
  .learner-photo {
    width: 100%; aspect-ratio: 1; border-radius: 50%;
    background: var(--purple-pale); border: 3px solid var(--purple-light);
    display: flex; align-items: center; justify-content: center; cursor: pointer; overflow: hidden;
    position: relative; user-select: none;
  }
  .learner-photo img {
    /* Sizing/position is set inline by _positionPhotoImg() (js/profile-cards.js) —
       the image's real dimensions must stay reachable via pan/zoom, which an
       object-fit:cover crop here would permanently hide. */
    pointer-events: none;
  }
  .learner-photo.has-photo { cursor: grab; touch-action: none; }
  .learner-photo.has-photo:active { cursor: grabbing; }
  .learner-photo:not(.has-photo) {
    background: #fbf9fe;
    border: 2px dashed var(--purple-light);
    flex-direction: column;
    gap: 6px;
    transition: background 0.15s, border-color 0.15s;
  }
  .learner-photo:not(.has-photo):hover {
    background: var(--purple-pale);
    border-color: var(--purple-mid);
  }
  .learner-photo-empty-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #a878c8;
  }
  .learner-photo-btn {
    font-size: 0.72rem; color: var(--purple-mid); background: none;
    border: none; cursor: pointer; text-decoration: underline; padding: 0;
  }
  .learner-field { margin-bottom: 10px; }
  .learner-field-label {
    font-size: 0.67rem; font-weight: 700; color: #999;
    text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 2px;
  }
  .learner-field-value { font-size: 0.88rem; font-weight: 600; color: var(--text-dark); }

  /* Overall level card */
  .level-select-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
  .stage-badge-large {
    width: 56px; height: 56px; border-radius: 10px;
    background: var(--purple-mid); color: #fff;
    display: none; align-items: center; justify-content: center;
    font-size: 1.3rem; font-weight: 800; flex-shrink: 0; letter-spacing: -1px;
  }
  .home-select {
    border: 1.5px solid var(--grey-border); border-radius: 7px; padding: 6px 10px;
    font-size: 0.82rem; font-family: var(--font-main); color: var(--text-dark);
    background: #fff; cursor: pointer; width: 100%;
  }
  .home-select:focus { outline: none; border-color: var(--purple-mid); }
  .learner-profile-text {
    background: var(--purple-pale); border-radius: 8px; padding: 12px 14px;
    font-size: 0.8rem; line-height: 1.5; color: var(--text-mid);
    border-left: 3px solid var(--purple-mid); min-height: 70px;
  }
  .learner-profile-text.placeholder { color: #aaa; font-style: italic; }

  /* KSA level table */
  .ksa-level-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
  .ksa-level-table th {
    text-align: left; font-size: 0.68rem; font-weight: 700; color: #999;
    text-transform: uppercase; padding: 0 8px 6px; border-bottom: 2px solid var(--purple-pale);
  }
  .ksa-level-table td { padding: 6px 8px; border-bottom: 1px solid #f2f2f2; vertical-align: middle; }
  .ksa-level-table tr:last-child td { border-bottom: none; }
  .ksa-link { color: var(--purple-mid); text-decoration: none; font-weight: 600; font-size: 0.82rem; }
  .ksa-link:hover { text-decoration: underline; }
  .ksa-level-sel {
    border: 1.5px solid var(--grey-border); border-radius: 5px; padding: 4px 6px;
    font-size: 0.75rem; font-family: var(--font-main); background: #fff; cursor: pointer; width: 100%;
  }
  .ksa-level-sel:focus { outline: none; border-color: var(--purple-mid); }

  /* Star chart */
  .star-chart { width: 100%; border-collapse: collapse; font-size: 0.7rem; table-layout: fixed; }
  .star-chart th {
    text-align: center; padding: 3px 2px; font-weight: 700; color: var(--purple-dark);
    font-size: 0.62rem; vertical-align: bottom; line-height: 1.2;
  }
  .star-chart td {
    text-align: center; padding: 2px; border: 1px solid #ece6f0; height: 24px;
  }
  .star-stage-label {
    text-align: right !important; font-size: 0.67rem; color: var(--text-mid);
    font-weight: 600; padding-right: 8px !important; border: none !important;
    white-space: nowrap;
  }
  .star-filled { font-size: 0.9rem; color: #f0b800; line-height: 1; }

  .star-chart td.star-cell { cursor: pointer; transition: background 0.12s; }
  .star-chart td.star-cell:hover { background: var(--purple-pale); }

  .star-chart tfoot td {
    border: none;
    padding-top: 4px;
    text-align: center;
    vertical-align: top;
  }
  .star-ksa-btn {
    writing-mode: vertical-lr;
    transform: rotate(180deg);
    white-space: nowrap;
    background: var(--purple-pale);
    border: 1px solid var(--purple-light);
    color: var(--purple-dark);
    cursor: pointer;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 4px 3px;
    font-family: var(--font-main);
    border-radius: 4px;
    display: inline-block;
  }
  .star-ksa-btn:hover { background: var(--purple-light); }

  /* Learner summary text */
  .learner-summary { font-size: 0.72rem; line-height: 1.45; color: var(--text-dark); }
  .learner-summary-title {
    font-weight: 800; font-size: 0.8rem; margin-bottom: 8px;
    color: var(--purple-dark); border-bottom: 2px solid var(--purple-pale); padding-bottom: 5px;
  }
  .learner-summary-section { margin-bottom: 7px; }
  .learner-summary-head { font-weight: 700; margin-bottom: 3px; font-size: 0.72rem; }
  .learner-summary-head em { font-style: italic; font-weight: 700; }
  .learner-summary-list { padding-left: 13px; margin: 0; }
  .learner-summary-list li { margin-bottom: 1px; }

  /* Functional senses */
  .sense-block { margin-bottom: 14px; }
  .sense-block:last-child { margin-bottom: 0; }
  .sense-header-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
  .sense-header-row strong { font-size: 0.8rem; min-width: 52px; }
  .sense-display-row {
    display: flex; align-items: center; gap: 10px; padding: 6px 8px;
    background: var(--grey-light); border-radius: 8px; min-height: 52px;
  }
  .sense-icon-none {
    width: 44px; height: 44px; border-radius: 50%;
    background: #e0e0e0; border: 2px dashed #bbb; flex-shrink: 0;
  }
  .sense-icon-wrap { flex-shrink: 0; line-height: 0; }
  .sense-text { font-size: 0.8rem; color: var(--text-mid); line-height: 1.4; flex: 1; }
  .sense-text-placeholder { font-size: 0.8rem; color: #bbb; font-style: italic; flex: 1; }

  /* ── PRINT ── */
  @page {
    size: A4 landscape;
    margin: 0;
  }

  @media print {
    .top-nav, .side-nav, .print-btn, .legend, .learner-context-banner, .profiles-subnav { display: none !important; }
    .layout { display: block; }
    .main { padding: 6mm; }
    body { background: #fff; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
    .profile-grid-wrap { box-shadow: none; border: 1px solid #ddd; }
    .module-btn { break-inside: avoid; }
    .home-grid { gap: 6px; }
    .home-card { box-shadow: none; border: 1px solid #ddd; padding: 8px; }
    .learner-photo-btn, #photoUpload { display: none !important; }
    .home-select, .ksa-level-sel { display: none !important; }
    .sense-header-row select { display: none !important; }
    #loginScreen { display: none !important; }
  }

  /* ── Login screen ─────────────────────────────────────── */
  #loginScreen {
    position: fixed; inset: 0;
    background: linear-gradient(135deg, #3a1060 0%, #6a2fa0 100%);
    display: flex; align-items: center; justify-content: center;
    z-index: 9000;
  }
  .login-card {
    background: #f3f0f7;
    border-radius: 12px;
    padding: 40px 44px 36px;
    width: 360px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.28);
    display: flex; flex-direction: column; gap: 14px;
  }
  .login-logo {
    display: flex; align-items: center; justify-content: center;
    gap: 3px; margin-bottom: 2px;
  }
  .login-welcome {
    text-align: center; font-size: 1.1rem; font-weight: 700; color: #3a1060;
  }
  .login-sub {
    text-align: center; font-size: 0.85rem; color: #888; margin-top: -8px;
  }
  .login-field { display: flex; flex-direction: column; gap: 5px; }
  .login-field label { font-size: 0.8rem; font-weight: 600; color: #555; }
  .login-field input {
    padding: 9px 12px; border: 1.5px solid #ddd; border-radius: 6px;
    font-size: 0.95rem; outline: none; transition: border-color 0.15s;
  }
  .login-field input:focus { border-color: #7c3aed; }
  .login-btn {
    background: #7c3aed; color: #fff; border: none;
    padding: 11px; border-radius: 7px; font-size: 1rem; font-weight: 700;
    cursor: pointer; margin-top: 2px; transition: background 0.15s;
  }
  .login-btn:hover { background: #5b21b6; }
  .login-btn:disabled { background: #bbb; cursor: default; }
  .login-forgot { text-align: right; font-size: 0.8rem; }
  .login-forgot a { color: #7c3aed; text-decoration: none; }
  .login-forgot a:hover { text-decoration: underline; }
  .login-error {
    background: #fef2f2; border: 1px solid #fca5a5;
    color: #b91c1c; border-radius: 6px; padding: 8px 12px;
    font-size: 0.82rem;
  }
  .login-msg {
    background: #f0fdf4; border: 1px solid #86efac;
    color: #166534; border-radius: 6px; padding: 8px 12px;
    font-size: 0.82rem; text-align: center;
  }

  /* ── App shell flex column ─────────────────────────────── */
  #appShell {
    display: flex;
    flex-direction: column;
    height: 100vh;
  }

  /* ── DASHBOARD ─────────────────────────────────────────── */
  #dashboardView {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 32px 40px;
    background: #e8f0f7;
  }
  .dashboard-welcome {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--purple-dark);
    margin-bottom: 4px;
  }
  .dashboard-sub { font-size: 0.85rem; color: #777; margin-bottom: 24px; }
  .dashboard-tabs {
    display: flex;
    margin-bottom: 24px;
    border-bottom: 2px solid #ddd;
  }
  .dashboard-tab {
    padding: 9px 20px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: #888;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    background: none;
    font-family: var(--font-main);
    transition: color 0.15s;
  }
  .dashboard-tab:hover { color: var(--purple-dark); }
  .dashboard-tab.active { color: var(--purple-dark); border-bottom-color: var(--purple-dark); }
  .dashboard-group-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: #999;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin: 20px 0 10px;
  }
  .learner-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
    gap: 12px;
    margin-bottom: 8px;
  }
  .dash-learner-card {
    background: white;
    border-radius: 10px;
    padding: 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s;
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .dash-learner-card:hover { border-color: var(--purple-mid); }
  .learner-initials {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--purple-pale);
    color: var(--purple-dark);
    font-weight: 700;
    font-size: 0.9rem;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
  }
  .dash-card-info { flex: 1; min-width: 0; }
  .dash-card-name {
    font-weight: 600; font-size: 0.88rem; color: var(--text-dark);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .dash-card-level { font-size: 0.75rem; color: #999; margin-top: 2px; }
  .dash-card-arrow { color: #ccc; font-size: 1rem; flex-shrink: 0; }
  .dashboard-admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 12px;
    max-width: 720px;
  }
  .dash-admin-card {
    background: white; border-radius: 10px; padding: 18px 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    cursor: pointer; text-align: center;
    border: 1px solid #eee; transition: border-color 0.15s;
  }
  .dash-admin-card:hover { border-color: var(--purple-mid); }
  .dash-admin-card.disabled { opacity: 0.5; cursor: default; }
  .dash-admin-card.disabled:hover { border-color: #eee; }
  .dash-admin-icon { font-size: 1.8rem; margin-bottom: 8px; }
  .dash-admin-label { font-size: 0.82rem; font-weight: 600; color: var(--purple-dark); }
  .dash-admin-desc { font-size: 0.72rem; color: #888; margin-top: 4px; }

  /* Modal form fields (reuse login-field style, add label weight) */
  .modal-form-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
  .modal-form-field label { font-size: 0.8rem; font-weight: 600; color: #555; }
  .modal-form-field input, .modal-form-field select, .modal-form-field textarea {
    padding: 9px 12px; border: 1.5px solid #ddd; border-radius: 6px;
    font-size: 0.9rem; outline: none; transition: border-color 0.15s;
    font-family: var(--font-main);
  }
  .modal-form-field textarea { resize: vertical; }
  .modal-form-field input:focus, .modal-form-field select:focus, .modal-form-field textarea:focus { border-color: #7c3aed; }

  /* ── Nav user (top-right) ─────────────────────────────── */
  .nav-user-email {
    font-size: 0.8rem; color: rgba(255,255,255,0.9);
    max-width: 200px; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* ══════════════════════════════════════════════════════════════
     DASHBOARD — MAIN TAB BAR
  ══════════════════════════════════════════════════════════════ */
  .dash-main-tabs {
    display: flex;
    border-bottom: 2px solid #e5e0ef;
    background: white;
    position: sticky;
    top: 0;
    z-index: 10;
    margin: 0 -32px;   /* bleed to container edges */
    padding: 0 32px;
  }
  .dash-main-tab {
    padding: 11px 22px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: #999;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    background: none;
    font-family: var(--font-main);
    transition: color 0.15s;
    white-space: nowrap;
  }
  .dash-main-tab:hover { color: var(--purple-dark); }
  .dash-main-tab.active { color: var(--purple-dark); border-bottom-color: var(--purple-dark); }

  /* ══════════════════════════════════════════════════════════════
     DASHBOARD — CONTENT PANELS
  ══════════════════════════════════════════════════════════════ */
  .dash-panel { padding: 28px 0 16px; }
  .dash-panel-intro {
    font-size: 0.85rem;
    color: #888;
    margin: 0 0 22px;
    max-width: 640px;
    line-height: 1.55;
  }

  /* ══════════════════════════════════════════════════════════════
     HOME TAB
  ══════════════════════════════════════════════════════════════ */
  .dash-home-content { max-width: 860px; display: flex; flex-direction: column; gap: 20px; }

  /* Greeting strip */
  .home-greeting { padding: 6px 0 2px; }
  .home-greeting-name { font-size: 1.25rem; font-weight: 700; color: var(--purple-dark); }
  .home-greeting-context { font-size: 0.82rem; color: #888; margin-top: 3px; }

  /* Section title above learner table */
  .home-section-title {
    font-size: 0.78rem; font-weight: 700; color: #aaa;
    text-transform: uppercase; letter-spacing: 0.5px;
    margin-bottom: -10px;
  }

  /* Group header rows inside the learner table */
  .admin-list .home-group-row td {
    background: #ede9f6;
    font-size: 0.7rem;
    font-weight: 700;
    color: #7c5ca8;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 7px 14px;
    border-bottom: 1px solid #d8d0ed;
  }
  .admin-list .home-group-row:hover td { background: #ede9f6; }

  /* Open button on learner rows */
  .btn-open {
    background: none; border: 1.5px solid #c9c0e8; border-radius: 6px;
    padding: 4px 10px; font-size: 0.78rem; color: var(--purple-dark);
    cursor: pointer; transition: background 0.12s, border-color 0.12s;
    white-space: nowrap;
  }
  .btn-open:hover { background: #f0edf8; border-color: #a88fc8; }

  /* Help note */
  .dash-home-help {
    font-size: 0.82rem;
    color: #888;
    background: #faf9fc;
    border: 1.5px solid #ebe8f5;
    border-radius: 8px;
    padding: 13px 16px;
    line-height: 1.5;
  }

  /* ══════════════════════════════════════════════════════════════
     ADMIN SECONDARY TABS (pill style)
  ══════════════════════════════════════════════════════════════ */
  .admin-sub-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 20px 0 18px;
    border-bottom: 1.5px solid #ebe8f5;
    margin-bottom: 26px;
  }
  .admin-sub-tab {
    font-size: 0.81rem;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 20px;
    border: 1.5px solid #c9b8e0;
    color: #6b4a90;
    background: transparent;
    cursor: pointer;
    font-family: var(--font-main);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
  }
  .admin-sub-tab:hover { border-color: var(--purple-dark); background: rgba(74,45,107,0.06); }
  .admin-sub-tab.active { background: var(--purple-dark); border-color: var(--purple-dark); color: white; }

  /* ══════════════════════════════════════════════════════════════
     ADMIN SECTION LAYOUT
  ══════════════════════════════════════════════════════════════ */
  .admin-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
  }
  .admin-section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--purple-dark);
    margin-bottom: 3px;
  }
  .admin-section-sub { font-size: 0.82rem; color: #999; line-height: 1.4; }

  /* Primary action button (e.g. "+ Add Learner") */
  .btn-admin-action {
    flex-shrink: 0;
    padding: 8px 16px;
    background: var(--purple-dark);
    color: white;
    border: none;
    border-radius: 7px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-main);
    transition: background 0.15s;
    white-space: nowrap;
  }
  .btn-admin-action:hover { background: #3b1f57; }
  .btn-admin-action.secondary {
    background: transparent;
    border: 1.5px solid var(--purple-dark);
    color: var(--purple-dark);
  }
  .btn-admin-action.secondary:hover { background: rgba(74,45,107,0.07); }

  /* ══════════════════════════════════════════════════════════════
     ADMIN PLACEHOLDER ("coming soon") PANEL
  ══════════════════════════════════════════════════════════════ */
  .admin-coming-soon {
    text-align: center;
    padding: 52px 24px;
    border: 1.5px dashed #d8cfe8;
    border-radius: 10px;
    color: #bbb;
  }
  .admin-coming-soon-icon  { font-size: 1.9rem; margin-bottom: 12px; opacity: 0.6; }
  .admin-coming-soon-title { font-size: 0.9rem; font-weight: 600; color: #ccc; margin-bottom: 7px; }
  .admin-coming-soon-body  { font-size: 0.81rem; line-height: 1.55; max-width: 400px; margin: 0 auto; }

  /* ══════════════════════════════════════════════════════════════
     PLATFORM OWNER — school context banner + overview (Chunk F refactor)
  ══════════════════════════════════════════════════════════════ */

  /* Amber strip shown when PO is inside a school */
  .school-context-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 20px;
    background: #fffbeb;
    border-bottom: 2px solid #f59e0b;
    color: #78350f;
    font-size: 0.83rem;
    font-weight: 500;
    flex-shrink: 0;
  }
  .school-context-exit-btn {
    background: transparent;
    border: 1.5px solid #f59e0b;
    color: #92400e;
    border-radius: 5px;
    padding: 3px 12px;
    font-size: 0.77rem;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-main);
    white-space: nowrap;
    transition: background 0.13s;
  }
  .school-context-exit-btn:hover { background: #fef3c7; }

  /* PO overview dashboard */
  .po-overview-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 28px;
  }
  /* ── Import Learner Data section (PO Tools tab) ── */
  .po-import-section {
    background: #fff;
    border: 1.5px solid #c9c0e8;
    border-radius: 10px;
    padding: 22px 24px;
    box-shadow: 0 2px 8px rgba(74,45,107,0.09);
  }
  .po-import-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
  }
  .po-import-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 5px;
  }
  .po-import-sub {
    font-size: 0.86rem;
    color: #6b7280;
    max-width: 540px;
    line-height: 1.55;
  }

  /* Import modal styles */
  .import-step { display: none; }
  .import-step.active { display: block; }

  .import-summary-row {
    display: flex;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.88rem;
    align-items: flex-start;
  }
  .import-summary-row:last-child { border-bottom: none; }
  .import-summary-label {
    color: #6b7280;
    font-weight: 600;
    min-width: 160px;
    flex-shrink: 0;
  }
  .import-summary-value { color: #1f2937; flex: 1; }
  .import-status-ok    { color: #16a34a; font-weight: 600; }
  .import-status-warn  { color: #d97706; font-weight: 600; }
  .import-status-error { color: #dc2626; font-weight: 600; }

  .import-progress-wrap {
    text-align: center;
    padding: 36px 20px;
    color: #555;
    font-size: 0.92rem;
  }
  .import-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid #e0d4f0;
    border-top-color: var(--purple-mid);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 10px;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* ══════════════════════════════════════════════════════════════
     PLATFORM ADMIN — context-switch banner (Chunk F)
  ══════════════════════════════════════════════════════════════ */
  .plat-estab-banner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 11px 16px;
    margin-bottom: 14px;
    background: #fffbeb;
    border: 1.5px solid #fcd34d;
    border-radius: 8px;
    font-size: 0.84rem;
    color: #92400e;
  }

  /* ══════════════════════════════════════════════════════════════
     ADMIN SETTINGS PANEL (Chunk E)
  ══════════════════════════════════════════════════════════════ */
  .admin-settings-card {
    background: #fff;
    border: 1.5px solid #c9c0e8;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(74,45,107,0.09);
    padding: 22px 24px;
  }
  .admin-settings-card + .admin-settings-card { margin-top: 16px; }
  .admin-settings-card-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #9b70cc;
    margin-bottom: 14px;
  }
  .admin-settings-estab-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 6px;
  }
  .admin-settings-admins {
    font-size: 0.84rem;
    color: #6b7280;
    margin-bottom: 20px;
  }
  .admin-stats-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
  }
  .admin-stat-tile {
    flex: 1;
    min-width: 100px;
    background: #f5f2fb;
    border: 1.5px solid #e0d8f0;
    border-radius: 8px;
    padding: 14px 16px;
    text-align: center;
  }
  .admin-stat-tile--link {
    cursor: pointer; transition: background 0.13s, border-color 0.13s;
  }
  .admin-stat-tile--link:hover { background: #ede8f8; border-color: var(--purple-mid); }
  .admin-stat-num {
    font-size: 1.9rem;
    font-weight: 800;
    color: var(--purple-dark);
    line-height: 1;
    margin-bottom: 6px;
  }
  .admin-stat-lbl {
    font-size: 0.75rem;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.4px;
  }
  .admin-stat-sub {
    font-size: 0.72rem; color: #bbb; margin-top: 4px;
  }
  .admin-settings-card-desc {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 18px;
    line-height: 1.5;
  }
  .admin-access-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .admin-access-option {
    display: flex;
    align-items: flex-start;
    gap: 13px;
    padding: 14px 16px;
    border: 2px solid #e0d8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: #fdfcff;
  }
  .admin-access-option:hover { border-color: #c9b8e0; background: #faf8ff; }
  .admin-access-option.selected { border-color: var(--purple-dark); background: #f5f2fb; }
  .admin-access-option input[type="radio"],
  .admin-access-option input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
    accent-color: var(--purple-dark);
    width: 16px;
    height: 16px;
    cursor: pointer;
  }
  .admin-access-option-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .admin-access-option-desc {
    font-size: 0.82rem;
    color: #6b7280;
    line-height: 1.45;
  }
  .admin-access-default-pill {
    font-size: 0.68rem;
    font-weight: 600;
    background: #ede9fe;
    color: #6b4fa0;
    border: 1px solid #c9b8e0;
    border-radius: 10px;
    padding: 1px 8px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
  }

  /* ══════════════════════════════════════════════════════════════
     ADMIN EMPTY STATE
  ══════════════════════════════════════════════════════════════ */
  .admin-empty {
    text-align: center;
    padding: 48px 20px;
    color: #ccc;
    font-size: 0.87rem;
    font-style: italic;
  }

  /* ══════════════════════════════════════════════════════════════
     STATUS BADGES  (active / archived / inactive / role)
  ══════════════════════════════════════════════════════════════ */
  .status-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 9px;
    border-radius: 10px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
  }
  .status-badge.active   { background: #d1fae5; color: #065f46; }
  .status-badge.archived { background: #f3f4f6; color: #9ca3af; }
  .status-badge.inactive { background: #fee2e2; color: #b91c1c; }
  .status-badge.invited  { background: #fef3c7; color: #92400e; }
  .status-badge.admin    { background: #ede9fe; color: #5b21b6; }
  .status-badge.teacher  { background: #f0f9ff; color: #0369a1; }

  /* ══════════════════════════════════════════════════════════════
     ADMIN LIST VIEW  — shared foundation for Chunks B / C / D
  ══════════════════════════════════════════════════════════════ */
  .admin-list-wrap {
    border: 1.5px solid #c9c0e8;
    border-radius: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    background: #fff;
    box-shadow: 0 2px 8px rgba(74,45,107,0.09);
  }
  .admin-list { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
  .admin-list th {
    text-align: left;
    font-size: 0.7rem;
    font-weight: 700;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 14px;
    background: #f5f2fb;
    border-bottom: 1.5px solid #c9c0e8;
    white-space: nowrap;
  }
  .admin-list th.sortable { cursor: pointer; user-select: none; transition: background 0.12s, color 0.12s; }
  .admin-list th.sortable:hover { background: #ede8f8; color: #7c4fa0; }
  .admin-list th.sort-active { color: var(--purple-dark); }
  .admin-list td {
    padding: 11px 14px;
    border-bottom: 1px solid #ede9f6;
    vertical-align: middle;
    color: var(--text-dark);
  }
  .admin-list tr:last-child td { border-bottom: none; }
  .admin-list tbody tr:hover td { background: #faf8ff; }
  .admin-list .col-actions { text-align: right; white-space: nowrap; }
  .admin-list .col-check   { width: 38px; }
  .admin-list input[type="checkbox"] {
    cursor: pointer; accent-color: var(--purple-dark); width: 15px; height: 15px;
  }

  /* Home tab learner table only — avatar occupies 75% of row height (48px of 64px) */
  .home-learner-list td { padding-top: 8px; padding-bottom: 8px; }
  .home-row-avatar {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--purple-pale);
    color: var(--purple-dark);
    font-weight: 700;
    font-size: 0.9rem;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    position: relative;
  }
  .home-row-avatar.has-photo { background: none; }
  .home-row-avatar img {
    /* position:absolute + top/left:50% is required here — _positionPhotoImg()
       (js/profile-cards.js) centers the image with translate(-50%,-50%),
       which assumes that base positioning. Width/height/final transform are
       set inline by _positionHomeAvatars() (js/dashboard.js) once loaded. */
    position: absolute; top: 50%; left: 50%;
    pointer-events: none;
  }

  /* Per-row action buttons */
  .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
  .btn-row-action {
    font-size: 0.76rem;
    font-weight: 600;
    padding: 4px 11px;
    border-radius: 5px;
    border: 1.5px solid #c9b8e0;
    color: #6b4a90;
    background: transparent;
    cursor: pointer;
    font-family: var(--font-main);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
  }
  .btn-row-action:hover { background: var(--purple-dark); border-color: var(--purple-dark); color: white; }
  .btn-row-action.danger { border-color: #fca5a5; color: #dc2626; }
  .btn-row-action.danger:hover { background: #dc2626; border-color: #dc2626; color: white; }
  .btn-row-action.muted  { border-color: #e5e7eb; color: #aaa; }
  .btn-row-action.muted:hover  { background: #9ca3af; border-color: #9ca3af; color: white; }

  /* Group accordion cards */
  .admin-group-card {
    border: 1.5px solid #c9c0e8; border-radius: 10px; background: #fff;
    box-shadow: 0 2px 8px rgba(74,45,107,0.09); margin-bottom: 10px; overflow: hidden;
  }
  .admin-group-card:last-child { margin-bottom: 0; }
  .admin-group-header {
    display: flex; align-items: center; gap: 10px; padding: 12px 16px;
    cursor: pointer; user-select: none; background: #fff; transition: background 0.12s;
  }
  .admin-group-header:hover { background: #faf8ff; }
  .admin-group-chevron {
    font-size: 0.62rem; color: #ccc; transition: transform 0.2s; flex-shrink: 0;
  }
  .admin-group-card.expanded .admin-group-chevron { transform: rotate(90deg); color: var(--purple-dark); }
  .admin-group-name { font-weight: 700; font-size: 0.9rem; flex: 1; color: var(--text-dark); }
  .admin-group-count { font-size: 0.77rem; color: #bbb; white-space: nowrap; }
  .admin-group-body {
    display: none; border-top: 1.5px solid #ede9f6;
    padding: 12px 16px 14px; background: #fdfcff;
  }
  .admin-group-card.expanded .admin-group-body { display: block; }
  .admin-group-member {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 0; border-bottom: 1px solid #f0ecf8; font-size: 0.86rem;
  }
  .admin-group-member:last-of-type { border-bottom: none; margin-bottom: 4px; }
  .admin-group-member-name { flex: 1; }
  .admin-group-empty-msg { font-size: 0.82rem; color: #ccc; font-style: italic; margin: 0 0 10px; }
  .admin-group-add-row { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
  .admin-group-add-sel {
    flex: 1; padding: 7px 10px; border: 1.5px solid #d0c0e8; border-radius: 6px;
    font-size: 0.84rem; font-family: var(--font-main); color: #444;
    outline: none; background: #fff; cursor: pointer; transition: border-color 0.15s;
    min-width: 0;
  }
  .admin-group-add-sel:focus { border-color: var(--purple-dark); }
  .admin-group-rename-input {
    flex: 1; padding: 4px 9px; border: 1.5px solid var(--purple-dark); border-radius: 5px;
    font-size: 0.9rem; font-weight: 700; font-family: var(--font-main);
    color: var(--text-dark); outline: none; min-width: 0;
  }
  .admin-groups-create-row {
    display: flex; gap: 8px; align-items: center;
    margin-bottom: 16px; padding: 12px 14px;
    background: #f5f2fb; border: 1.5px solid #c9c0e8; border-radius: 8px;
  }
  .admin-groups-create-row input[type="text"] {
    flex: 1; padding: 7px 10px; border: 1.5px solid #d0c0e8; border-radius: 6px;
    font-size: 0.88rem; font-family: var(--font-main); outline: none;
    background: #fff; transition: border-color 0.15s; min-width: 0;
  }
  .admin-groups-create-row input[type="text"]:focus { border-color: var(--purple-dark); }

  /* Searchable add-learner widget */
  .admin-group-search-wrap { position: relative; flex: 1; min-width: 0; }
  .admin-group-search-results {
    display: none; position: absolute; top: calc(100% + 3px); left: 0; right: 0;
    background: #fff; border: 1.5px solid #c9c0e8; border-radius: 8px;
    box-shadow: 0 6px 16px rgba(74,45,107,0.15); z-index: 200;
    max-height: 200px; overflow-y: auto;
  }
  .admin-group-search-item {
    padding: 9px 14px; font-size: 0.84rem; cursor: pointer;
    border-bottom: 1px solid #f3f1f8; color: var(--text-dark); transition: background 0.1s;
  }
  .admin-group-search-item:last-child { border-bottom: none; }
  .admin-group-search-item:hover { background: #f3eeff; }
  .admin-group-search-noresult { padding: 10px 14px; font-size: 0.82rem; color: #bbb; font-style: italic; }

  /* Group member actions wrapper (holds Remove + Move buttons, or inline move select) */
  .admin-group-member-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

  /* ── Assign / manage-members checklist ─────────────────── */
  .assign-section-title {
    font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--purple-dark); margin: 16px 0 6px;
  }
  .assign-section-title:first-child { margin-top: 0; }
  .assign-checklist {
    border: 1.5px solid #e2d9f3; border-radius: 7px; overflow: hidden;
    max-height: 280px; overflow-y: auto;
  }
  .assign-checklist-item {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px;
    border-bottom: 1px solid #f3f0fa; cursor: pointer; transition: background 0.1s;
  }
  .assign-checklist-item:last-child { border-bottom: none; }
  .assign-checklist-item:hover { background: #f9f6ff; }
  .assign-checklist-item input[type=checkbox] {
    width: 16px; height: 16px; flex-shrink: 0;
    accent-color: var(--purple-mid); cursor: pointer;
  }
  .assign-checklist-item label {
    font-size: 0.86rem; color: var(--text-dark); cursor: pointer; flex: 1; margin: 0;
  }
  .assign-checklist-item .assign-sub {
    font-size: 0.75rem; color: #aaa; flex-shrink: 0;
  }
  .assign-empty { font-size: 0.82rem; color: #bbb; font-style: italic; padding: 10px 12px; }
  .assign-note {
    font-size: 0.76rem; color: #9ca3af; margin-top: 6px; line-height: 1.5;
  }

  /* Danger button — red destructive confirm */
  .btn-danger {
    background: #dc2626; color: #fff; border: 2px solid #dc2626;
    border-radius: 6px; padding: 9px 20px; font-size: 0.88rem; font-weight: 600;
    font-family: var(--font-main); cursor: pointer; transition: background 0.15s, border-color 0.15s;
  }
  .btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }

  /* Active / Archived filter buttons */
  .admin-filter-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
  .admin-filter-btn {
    padding: 5px 16px; border-radius: 20px; border: 1.5px solid #d0c0e8;
    background: #fff; color: #6b4fa0; font-size: 0.78rem; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
  }
  .admin-filter-btn.active { background: var(--purple-dark); color: #fff; border-color: var(--purple-dark); }
  .admin-filter-btn:hover:not(.active) { background: #f3eeff; border-color: #9b70cc; }

  .admin-search-input {
    width: 100%; max-width: 320px;
    padding: 8px 14px; border: 1.5px solid #ddd; border-radius: 20px;
    font-size: 0.85rem; outline: none; transition: border-color 0.15s;
    font-family: var(--font-main);
  }
  .admin-search-input:focus { border-color: #7c3aed; }

  .admin-pager {
    display: flex; align-items: center; justify-content: center; gap: 14px;
    margin-top: 16px;
  }
  .admin-pager-label { font-size: 0.8rem; color: #888; }
  .admin-pager .btn-row-action:disabled { opacity: 0.4; cursor: default; }
  .admin-pager .btn-row-action:disabled:hover { background: none; color: inherit; border-color: #ddd; }

  /* ── User Feedback inbox ── */
  .admin-list .col-read { width: 24px; padding-left: 16px; padding-right: 0; }
  .po-unread-dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background: #7c3aed;
  }
  .po-feedback-unread td { font-weight: 700; color: var(--text-dark); }
  .po-feedback-row, .po-schools-row { cursor: pointer; }

  /* Status shown and changed via one clickable badge, in both the table
     row and the detail modal — not a separate label + button. */
  .status-badge-btn {
    -webkit-appearance: none; appearance: none;
    border: none; font: inherit; font-size: inherit;
    cursor: pointer; transition: filter 0.15s;
  }
  .status-badge-btn:hover { filter: brightness(0.93); }

  /* ── Feedback detail modal ── */
  .fd-fields {
    display: flex; flex-direction: column; gap: 7px;
    margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid #eee;
  }
  .fd-row { display: flex; gap: 12px; font-size: 0.85rem; align-items: center; }
  .fd-label { flex: 0 0 110px; font-weight: 600; color: #999; }
  .fd-value { color: #333; }
  .fd-message-label { font-size: 0.78rem; font-weight: 700; color: #999; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 6px; }

  .fd-thread {
    margin-top: 22px; padding-top: 18px; border-top: 1px solid #eee;
    display: flex; flex-direction: column; gap: 10px;
  }
  .fd-thread-label { font-size: 0.78rem; font-weight: 700; color: #999; text-transform: uppercase; letter-spacing: 0.4px; }
  .fd-thread-item {
    background: #f3eeff; border-radius: 8px; padding: 10px 14px;
  }
  .fd-thread-date { font-size: 0.72rem; color: #7c4fa0; font-weight: 600; margin-bottom: 4px; }
  .fd-thread-message { font-size: 0.85rem; color: #333; white-space: pre-wrap; line-height: 1.5; }

  .fd-reply-section {
    margin-top: 22px; padding-top: 18px; border-top: 1px solid #eee;
    display: flex; flex-direction: column; gap: 8px;
  }
  .fd-reply-section label { font-size: 0.8rem; font-weight: 600; color: #555; }
  .fd-reply-section textarea {
    padding: 9px 12px; border: 1.5px solid #ddd; border-radius: 6px;
    font-size: 0.9rem; font-family: var(--font-main); resize: vertical; outline: none;
  }
  .fd-reply-section textarea:focus { border-color: #7c3aed; }

  /* Bulk action bar (appears when checkboxes ticked) */
  .bulk-action-bar {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    background: #ede9fe;
    border-bottom: 1.5px solid #c9b8e0;
    font-size: 0.81rem;
    font-weight: 600;
    color: var(--purple-dark);
  }
  .bulk-action-bar.visible { display: flex; }
  .bulk-action-bar .bulk-count { flex: 1; }

  /* ══════════════════════════════════════════════════════════════
     TABLET / PHONE — narrow-viewport layout fixes
     Scoped to real breakage found by testing actual iPad/iPhone
     dimensions, not guessed thresholds. Assessment grid itself is
     deliberately untouched here — it stays horizontal-scroll at any
     width (see .profile-grid-wrap flex/min-height above, which is
     an unconditional height fix, not gated to this section).
  ══════════════════════════════════════════════════════════════ */

  /* Learner Home info page: 230px/1fr/340px fixed-column grid overflows
     below ~900px (confirmed on iPad portrait 820px and iPhone both
     orientations) — stack to one column. Children's grid-column/grid-row
     are set inline by JS (js/profile-cards.js renderHome()); !important
     is required here to win over those inline styles without touching JS. */
  @media (max-width: 900px) {
    .home-grid {
      grid-template-columns: 1fr;
    }
    .home-grid > .home-card {
      grid-column: 1 !important;
      grid-row: auto !important;
    }
  }

  /* Module modal + learner banner: only broke on phone-portrait width
     (~393px) in testing — iPad (both orientations) and phone-landscape
     (~852px) were unaffected, so this breakpoint is intentionally tighter
     than the 900px one above. */
  @media (max-width: 600px) {
    /* aq-row's 4 fixed columns (1fr 80px 130px 200px) clip the Comments
       column almost entirely at this width. Reflow to question+response
       on one row, date and comment each spanning full width below. */
    .aq-row {
      grid-template-columns: 1fr 64px;
      row-gap: 4px;
    }
    .aq-date, .aq-comment {
      grid-column: 1 / -1;
    }
    /* The plain-text column-label header row doesn't map cleanly onto the
       reflowed 2-column + full-width-rows layout above — each field is
       self-descriptive without it (Yes/No colour, date text, comment
       placeholder), so hide rather than fight the grid for it. */
    #aqHeaderRow {
      display: none;
    }

    /* .learner-banner-title is absolutely centred across the full banner
       width and can visually collide with .learner-close-btn once the
       title text is long relative to viewport width. Let it flow in the
       flex row instead and truncate, rather than fighting for the centre. */
    .learner-banner-title {
      position: static;
      flex: 1;
      min-width: 0;
      text-align: left;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      padding-right: 8px;
    }
  }

  /* Side nav → horizontal bar under the banner, in portrait only. Real-device
     testing found this is a portrait-specific problem, not just a narrow-width
     one: iPad portrait (820px wide) is actually narrower than phone landscape
     (852px wide), so a plain max-width breakpoint can't separate "iPad
     portrait, wants this" from "phone landscape, already fine" — they'd both
     be caught or both excluded. `orientation: portrait` distinguishes them
     correctly regardless of absolute width; max-width: 900px is just a safety
     cap so a tall, narrow desktop window doesn't pick this up too. */
  @media (orientation: portrait) and (max-width: 900px) {
    .layout {
      flex-direction: column;
    }
    .side-nav {
      width: 100%;
      flex-direction: row;
      gap: 6px;
      padding: 8px;
    }
    .side-btn {
      flex: 1;
      padding: 6px 4px;
    }
  }

  /* Assessment grid: touch-only scroll hint. The grid stays horizontal-scroll
     at every width (no column narrowing — see .profile-grid-wrap above) since
     that's the lower-risk path agreed for the branching-strand grid; this is
     just a affordance so touch users know to swipe. Gated on touch capability,
     not viewport width, so mouse/desktop users never see it even in a
     narrowed window. */
  .legend-hint-touch { display: none; font-size: 0.75rem; color: #999; }
  @media (hover: none) and (pointer: coarse) {
    .legend-hint { display: none; }
    .legend-hint-touch { display: inline; }
  }

