:root {
    /* Brand: deep royal blue - structure, actions, data */
    --primary: #243B8F;
    --primary-dark: #1A2C6E;
    --primary-light: #3A55B0;

    /* Brand: warm cream - the signature accent moment (active nav), not a
       backdrop. Full-strength cream behind everything all day is what was
       making the page feel dizzying - reserved for small, deliberate spots. */
    --cream: #FFF0C9;

    /* Neutral surfaces - plain neutral gray, no warm tint at all */
    --bg: #F5F6F8;
    --card: #FFFFFF;
    --surface-tint: #E9EDFB;        /* soft primary-tinted block: KPI cards, info cards, hover/expanded rows */
    --surface-tint-strong: #D5DEF6; /* stronger tint: hover-on-tint, focus rings */
    --surface-wash: rgba(36, 59, 143, .06); /* subtle hover wash on white rows */

    /* Text */
    --text: #21264A;
    --text-muted: #676C88;

    /* Borders (warm-neutral - reads clean on both white and cream) */
    --border: #E8DFC7;
    --border-strong: #D9CBA0;

    /* Semantic status - distinct from brand blue on purpose, so "saved" / "locked" / "needs attention" read at a glance */
    --success: #128066;
    --success-tint: #DFF3EA;
    --success-tint-strong: #CBEBDD;
    --warning: #B4780A;
    --warning-tint: #FCEED3;
    --danger: #C1352E;
    --danger-tint: #FBE6E4;
    --info: #3B62D6;
    --info-tint: #E7ECFB;
    --confirmed: #6D3FB0;
    --confirmed-tint: #EEE7FA;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(33, 38, 74, .06), 0 10px 28px rgba(33, 38, 74, .10);
    --font-display: 'Poppins', sans-serif;
    --font-body: 'Inter', sans-serif;
  }

  * { box-sizing: border-box; }
  html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
  }
  h1, h2 { font-family: var(--font-display); color: var(--primary); margin: 0; }
  button { font-family: var(--font-body); cursor: pointer; }

  /* Consistent, visible focus for every interactive element - keyboard
     users get the same brand-tinted ring everywhere, not the mismatched
     browser default. */
  a:focus-visible, button:focus-visible, input:focus-visible,
  select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--surface-tint-strong);
  }

  .view { min-height: 100vh; }
  .view[hidden] { display: none !important; }

  /* ---------- LOADING ---------- */
  .view-loading {
    display: flex; align-items: center; justify-content: center;
    background: var(--primary);
  }
  .view-loading-spinner {
    width: 32px; height: 32px; border-radius: 50%;
    border: 3px solid rgba(255,255,255,.25); border-top-color: #fff;
    animation: spin .7s linear infinite;
  }

  /* ---------- LOGIN ---------- */
  .view-login {
    display: flex; align-items: center; justify-content: center;
    background: var(--bg);
    padding: 24px;
  }
  .login-split {
    display: flex; width: 100%; max-width: 1040px; min-height: 620px;
    background: var(--card); border-radius: var(--radius); overflow: hidden;
    box-shadow: 0 20px 60px rgba(33, 38, 74, .18);
  }

  .login-illustration-panel {
    flex: 1 1 46%; position: relative; overflow: hidden;
    background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 100%);
    display: flex; flex-direction: column; justify-content: flex-end;
    padding: 48px 44px; color: #fff;
  }
  .login-illustration-graphic { position: absolute; inset: 0; z-index: 0; }
  .login-illustration-graphic svg { width: 100%; height: 100%; display: block; }
  .login-illustration-text { position: relative; z-index: 1; }
  .login-illustration-text h2 { color: #fff; font-size: 25px; line-height: 1.32; margin: 0 0 10px; }
  .login-illustration-text p { color: rgba(255,255,255,.8); font-size: 13.5px; line-height: 1.55; margin: 0; max-width: 300px; }
  .login-illustration-dots { position: relative; z-index: 1; display: flex; gap: 6px; margin-top: 26px; }
  .login-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.35); transition: all .2s ease; }
  .login-dot.active { background: var(--cream); width: 20px; border-radius: 4px; }

  .login-form-panel {
    flex: 1 1 54%; display: flex; align-items: center; justify-content: center;
    padding: 48px 40px; background: #fff;
  }
  .login-form-inner { width: 100%; max-width: 340px; }
  .login-form-logo { width: 100%; height: auto; display: block; margin-bottom: 22px; }
  .login-welcome { font-size: 24px; margin: 0 0 6px; }
  .login-welcome-sub { color: var(--text-muted); font-size: 13.5px; margin: 0 0 28px; }
  .login-help-text { text-align: center; font-size: 12.5px; color: var(--text-muted); margin: 18px 0 0; }

  @media (max-width: 768px) {
    .login-split { flex-direction: column; min-height: 0; box-shadow: none; border-radius: 0; }
    .login-illustration-panel { display: none; }
    .login-form-panel { padding: 48px 24px; min-height: 100vh; }
  }

  #login-form label {
    display: block; font-size: 13px; font-weight: 600; color: var(--text);
    margin-bottom: 14px;
  }
  #login-form input {
    width: 100%; margin-top: 6px; padding: 11px 13px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 14.5px; font-family: var(--font-body); color: var(--text);
    transition: border-color .15s, box-shadow .15s;
  }
  #login-form input:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--surface-tint);
  }
  .field-error {
    background: var(--danger-tint); color: var(--danger); border: 1px solid #F3C6C2;
    padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px;
    margin-bottom: 14px;
  }

  /* ---------- BUTTONS ---------- */
  .btn {
    border: none; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px;
    padding: 11px 18px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    transition: transform .05s, background .15s, box-shadow .15s;
  }
  .btn:active { transform: scale(.98); }
  .btn-primary {
    background: var(--primary); color: #fff;
    position: relative; overflow: hidden; isolation: isolate;
  }
  .btn-primary::before {
    content: ''; position: absolute; inset: 0; background: var(--primary-dark);
    transform: translateX(-100%); transition: transform .3s ease; z-index: -1;
  }
  .btn-primary:not(:disabled):hover::before { transform: translateX(0); }
  .btn-primary:disabled { background: #A9B4DE; cursor: not-allowed; }
  .btn-block { width: 100%; margin-top: 4px; }
  .btn-ghost { background: transparent; color: #fff; border: 1.5px solid rgba(255,255,255,.35); }
  .btn-ghost:hover { background: rgba(255,255,255,.1); }
  .btn-link { background: none; color: var(--primary); font-weight: 600; padding: 4px 0; font-size: 13.5px; }
  .btn-link:hover { text-decoration: underline; }
  .btn-secondary { background: #fff; color: var(--primary); border: 1.5px solid var(--border); padding: 8px 14px; font-size: 13px; }
  .btn-secondary:hover { border-color: var(--primary); }
  .btn-confirm { background: var(--success-tint); color: var(--success); border: 1.5px solid transparent; padding: 8px 14px; font-size: 13px; }
  .btn-confirm:hover:not(:disabled) { background: var(--success-tint-strong); }
  .btn-confirm:disabled { background: #F2EFE3; color: var(--text-muted); cursor: default; }
  .btn-unlock { background: var(--warning-tint); color: #8A5C08; border: 1.5px solid transparent; padding: 8px 14px; font-size: 13px; }
  .btn-unlock:hover:not(:disabled) { background: #F9E3B4; }
  .btn-unlock:disabled { background: #F2EFE3; color: var(--text-muted); cursor: default; }

  .spinner {
    width: 15px; height: 15px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
    animation: spin .7s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  .view-app { display: flex; align-items: stretch; }

  /* ---------- SIDEBAR ---------- */
  .sidebar {
    width: 240px; flex: 0 0 240px; background: var(--primary); color: #fff;
    display: flex; flex-direction: column; padding: 22px 18px;
    position: sticky; top: 0; height: 100vh;
  }
  .sidebar-brand {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 0 4px; margin-bottom: 28px; text-align: center;
  }
  .sidebar-logo-wrap { width: 60%; }
  .sidebar-logo { width: 100%; height: auto; display: block; }
  .sidebar-brand-label {
    font-family: var(--font-display); font-weight: 600; font-size: 12.5px; color: rgba(255,255,255,.8);
  }
  .sidebar-profile { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 28px; }
  .sidebar-avatar { margin-bottom: 10px; }
  .sidebar-avatar .avatar-img,
  .sidebar-avatar .avatar-fallback { width: 56px; height: 56px; font-size: 19px; }
  .sidebar-name { font-weight: 600; font-size: 14px; }
  .sidebar-branch { font-size: 11.5px; color: rgba(255,255,255,.6); margin-top: 2px; }

  .sidebar-bottom-group { flex: 1; display: flex; flex-direction: column; }
  .sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
  .nav-btn {
    background: none; border: none; color: rgba(255,255,255,.75); text-align: left;
    padding: 11px 14px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px;
    display: flex; align-items: center; gap: 12px;
    transition: background .15s, color .15s;
  }
  .nav-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
  /* Soft, not a solid color block: translucent white fill (reads gentle
     on the blue sidebar) with a thin cream edge as the one brand touch. */
  .nav-btn.active {
    background: rgba(255,255,255,.14); color: #fff;
    border-left: 3px solid var(--cream); padding-left: 11px;
  }
  .nav-btn.nav-btn-disabled { color: rgba(255,255,255,.4); }
  .nav-btn.nav-btn-disabled.active { background: rgba(255,255,255,.12); color: rgba(255,255,255,.6); }
  .nav-icon {
    display: block; width: 19px; height: 19px; object-fit: contain; flex-shrink: 0;
    opacity: .75; transition: opacity .15s;
  }
  .nav-btn:hover .nav-icon, .nav-btn.active .nav-icon { opacity: 1; }
  .nav-soon-badge {
    display: inline-block; font-size: 9.5px; font-weight: 700; letter-spacing: .04em;
    text-transform: uppercase; background: rgba(255,255,255,.15); color: rgba(255,255,255,.75);
    border-radius: 999px; padding: 2px 7px; margin-left: 6px; vertical-align: middle;
  }

  .sidebar-logout {
    justify-content: flex-start; margin-top: auto;
  }

  /* ---------- TAB PANELS ---------- */
  .tab-panel[hidden] { display: none !important; }

  /* ---------- CONTENT (widescreen, not a narrow centered column) ---------- */
  .main-content { flex: 1; min-width: 0; padding: 32px 40px 100px; max-width: 1600px; margin: 0 auto; }
  .panel {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 32px 36px; width: 100%;
    border-top: 3px solid var(--cream); /* signature brand edge on every tab */
  }
  .panel h2 { font-size: 19px; margin-bottom: 4px; }
  .panel-sub { color: var(--text-muted); font-size: 13.5px; margin: 0 0 20px; }

  .reveal-block { animation: fadeIn .25s ease; margin-top: 24px; }
  @keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

  /* ---------- OVERVIEW ---------- */
  .overview-hero {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 20px; flex-wrap: wrap; margin-bottom: 8px;
  }
  .overview-eyebrow { font-size: 14px; color: var(--text-muted); margin: 0; font-weight: 600; }
  .overview-greeting { font-size: 30px; margin: 2px 0 0; }
  .overview-term { max-width: 200px; margin-top: 0; }

  .stat-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px;
    margin: 24px 0 8px;
  }
  .stat-card {
    background: var(--surface-tint); border-radius: var(--radius-sm); padding: 18px 20px;
    display: flex; flex-direction: column; justify-content: center; gap: 4px;
    border-left: 3px solid var(--cream);
  }
  .stat-card-hero {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff;
  }
  .stat-hero-value { font-family: var(--font-display); font-size: 34px; font-weight: 700; }
  .stat-hero-label { font-size: 12.5px; color: rgba(255,255,255,.85); }
  .stat-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; color: var(--primary); }
  .stat-label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }

  .stat-card-sls { gap: 10px; }
  .stat-sls-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
  .stat-sls-grade-select {
    padding: 4px 8px; border: 1.5px solid var(--border); border-radius: 6px;
    font-size: 12.5px; font-weight: 600; font-family: var(--font-body); color: var(--text); background: #fff;
  }
  .stat-sls-grade-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--surface-tint); }
  .stat-sls-terms { display: flex; gap: 18px; flex-wrap: wrap; }
  .stat-sls-term { display: flex; flex-direction: column; gap: 2px; }
  .stat-sls-term-label { font-size: 11.5px; color: var(--text-muted); font-weight: 600; }
  .stat-sls-term-value { font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--primary); }

  .chart-list { display: flex; flex-direction: column; gap: 12px; }
  .chart-row { display: flex; align-items: center; gap: 12px; }
  .chart-row-label { flex: 0 0 160px; font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chart-row-track { flex: 1; height: 10px; background: var(--border); border-radius: 999px; overflow: hidden; }
  .chart-row-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s ease; }
  .chart-row-value { flex: 0 0 42px; text-align: right; font-size: 13px; font-weight: 700; color: var(--primary); }

  .select-hint {
    margin: 8px 2px 0; font-size: 12.5px; font-weight: 600; color: var(--primary);
    min-height: 1em;
  }

  .assessment-divider { height: 1px; background: var(--border); margin: 4px 0 22px; }

  .filter-row { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-end; }
  .filter-row .select-label { flex: 0 0 240px; }
  .filter-row .select-label-class { flex: 1 1 380px; max-width: 480px; }
  .filter-row .select-label-term { flex: 1 1 200px; max-width: 240px; }
  .filter-row .info-cards { flex: 1; min-width: 260px; margin-bottom: 0; }

  .select-label { display: block; font-weight: 600; font-size: 13px; margin-top: 4px; }
  .select-label-term { max-width: 220px; }
  .select-label select {
    width: 100%; margin-top: 7px; padding: 11px 13px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 14.5px; font-family: var(--font-body); color: var(--text); background: #fff;
    text-overflow: ellipsis; overflow: hidden; white-space: nowrap;
  }
  .select-label select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--surface-tint); }
  .select-label select:disabled { background: #F5F3E9; color: var(--text-muted); cursor: not-allowed; }

  .review-name-filter-label { flex: 1 1 240px; max-width: 300px; }
  .review-name-filter-label input {
    width: 100%; margin-top: 7px; padding: 11px 13px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 14.5px; font-family: var(--font-body); color: var(--text); background: #fff;
  }
  .review-name-filter-label input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--surface-tint); }
  .review-name-filter-label input:disabled { background: #F5F3E9; color: var(--text-muted); cursor: not-allowed; }

  .info-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 22px; }
  .info-card {
    background: var(--surface-tint); border-radius: var(--radius-sm); padding: 12px 14px;
    display: flex; flex-direction: column; gap: 3px; justify-content: center;
  }
  .info-label { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--primary); }
  .info-value { font-size: 14.5px; font-weight: 600; color: var(--primary-dark); }

  /* ---------- STUDENT PROFILE (Scoring) ---------- */
  .student-profile { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; }
  .student-avatar { flex: 0 0 auto; }
  .avatar-img {
    width: 108px; height: 108px; border-radius: 50%; object-fit: cover;
    border: 3px solid var(--cream);
  }
  .avatar-fallback {
    width: 108px; height: 108px; border-radius: 50%; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 700; font-size: 36px;
  }
  .student-avatar.avatar-clickable { cursor: pointer; position: relative; border-radius: 50%; }
  .student-avatar.avatar-clickable::after {
    content: '\270E'; position: absolute; inset: 0; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0); color: #fff; font-size: 28px; opacity: 0;
    transition: opacity .15s, background .15s;
  }
  .student-avatar.avatar-clickable:hover::after { opacity: 1; background: rgba(0,0,0,.45); }

  .photo-crop-viewport {
    width: 240px; height: 240px; margin: 0 auto 20px; border-radius: 50%;
    overflow: hidden; position: relative; cursor: grab; background: #E9EDFB;
    touch-action: none;
  }
  .photo-crop-viewport.dragging { cursor: grabbing; }
  .photo-crop-viewport img { position: absolute; top: 0; left: 0; user-select: none; }

  .student-profile-info { flex: 1; min-width: 260px; }
  .student-profile-info h2 { font-size: 20px; margin-bottom: 12px; }
  .student-profile-info .info-cards { margin-bottom: 0; grid-template-columns: repeat(4, 1fr); }

  .section-label {
    font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    color: var(--text-muted); margin: 24px 0 10px;
  }

  .growth-summary-header {
    display: flex; align-items: center; justify-content: space-between; width: 100%;
    background: none; border: none; padding: 0; margin: 0; cursor: pointer; font: inherit; color: inherit;
  }
  .growth-summary-header .section-label { margin: 24px 0 0; }

  /* ---------- SUBJECT BUTTON GRID ---------- */
  .subject-buttons {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px;
    margin-top: 24px;
  }
  .subject-btn {
    background: #fff; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    padding: 14px 16px; font-weight: 600; font-size: 14px; color: var(--text); text-align: left;
    transition: border-color .15s, box-shadow .15s, transform .05s, background .15s, color .15s;
  }
  .subject-btn:hover { border-color: var(--primary); box-shadow: 0 4px 14px rgba(36,59,143,.14); }
  .subject-btn:active { transform: scale(.98); }
  .subject-btn.selected { background: var(--primary); border-color: var(--primary); color: #fff; }

  /* ---------- DASHBOARD STUDENT LIST ---------- */
  .student-list { display: flex; flex-direction: column; gap: 10px; }
  .student-row {
    border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 13px 16px;
    transition: background .15s ease, border-color .15s ease;
  }
  .student-row.is-expanded { background: var(--surface-tint); border-color: var(--primary); }
  .student-row-main { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
  .student-name-btn {
    background: none; border: none; padding: 8px; margin: -8px; border-radius: var(--radius-sm); cursor: pointer; text-align: left;
    display: flex; align-items: center; gap: 10px; color: inherit; font: inherit;
    flex: 1; min-width: 0;
  }
  .student-name-btn:hover { background: var(--surface-wash); }
  .student-name-btn:hover .student-name { text-decoration: underline; }
  .expand-toggle { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
  .expand-toggle-label { font-size: 11.5px; font-weight: 700; color: var(--primary); white-space: nowrap; }
  .expand-chevron {
    font-size: 18px; color: var(--text-muted); transition: transform .15s ease, background .15s ease, color .15s ease;
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 50%; background: var(--bg); flex-shrink: 0;
  }
  .expand-chevron.open { transform: rotate(180deg); background: var(--primary); color: #fff; }
  .student-name-btn:hover .expand-chevron,
  .subject-avg-row-main:hover .expand-chevron { background: var(--surface-tint); color: var(--primary); }
  .student-name-btn:hover .expand-chevron.open,
  .subject-avg-row-main:hover .expand-chevron.open { background: var(--primary); color: #fff; }
  .student-info { display: flex; flex-direction: column; gap: 6px; min-width: 160px; }
  .student-name { font-weight: 600; font-size: 14.5px; }
  .badge-row { display: flex; gap: 6px; flex-wrap: wrap; }
  .progress-badge {
    display: inline-block; width: fit-content; padding: 3px 9px; border-radius: 999px;
    background: var(--warning-tint); color: #8A5C08; font-size: 11.5px; font-weight: 700;
  }
  .progress-badge.done { background: var(--success-tint); color: var(--success); }
  .progress-badge.confirmed { background: var(--confirmed-tint); color: var(--confirmed); }
  .student-actions { display: flex; gap: 8px; flex-shrink: 0; }

  /* ---------- STUDENT SUBJECT / MLS ACCORDION (Class Roster drill-down) ---------- */
  .student-expand-panel { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
  .student-expand-panel[hidden] { display: none; }

  /* ---------- ANIMATED REPORT CARD (Growth Summary / Next Steps / Student Report) ----------
     Height is driven purely by grid-template-rows 0fr -> 1fr (no JS
     measurement, no max-height guess) so the intrinsic content height
     is always respected and the spring easing can overshoot cleanly. */
  .report-expand-panel {
    display: grid; grid-template-rows: 0fr;
    margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
    transition: grid-template-rows .5s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  .report-expand-panel.expanded { grid-template-rows: 1fr; }
  .report-expand-inner { overflow: hidden; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
  .report-expand-inner > .char-counter,
  .report-expand-inner > .report-save-bar,
  .report-expand-inner > .save-status.locked {
    opacity: 0; transition: opacity .3s ease;
  }
  .report-expand-panel.expanded .report-expand-inner > .char-counter,
  .report-expand-panel.expanded .report-expand-inner > .report-save-bar,
  .report-expand-panel.expanded .report-expand-inner > .save-status.locked {
    opacity: 1; transition-delay: .35s;
  }

  /* ---------- SCORING RUBRIC CHEATSHEET ---------- */
  .rubric-cheatsheet {
    margin-top: 20px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
  }
  .rubric-cheatsheet[open] { border-color: var(--border-strong); }
  .rubric-cheatsheet-summary {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    list-style: none;
  }
  .rubric-cheatsheet-summary::-webkit-details-marker { display: none; }
  .rubric-cheatsheet-summary .section-label { margin: 0; }
  .rubric-cheatsheet-chevron {
    font-size: 16px; color: var(--text-muted); flex-shrink: 0;
    transition: transform .15s ease;
  }
  .rubric-cheatsheet[open] .rubric-cheatsheet-chevron { transform: rotate(180deg); }

  .rubric-cheatsheet-body { display: flex; flex-direction: column; padding: 4px 16px 14px; }
  .rubric-item {
    display: grid;
    grid-template-columns: 190px 1fr 1fr;
    gap: 12px 18px;
    align-items: start;
    padding: 14px 0;
    border-top: 1px solid var(--border);
  }
  .rubric-item:first-child { border-top: none; }

  .rubric-item-head { display: flex; flex-direction: column; gap: 4px; }
  .rubric-score {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 999px;
    font-family: var(--font-display); font-weight: 700; font-size: 14px;
    color: #fff; background: var(--primary);
  }
  .rubric-score-1 { background: #8A5C08; }
  .rubric-score-2 { background: var(--warning); }
  .rubric-score-3 { background: var(--primary-light); }
  .rubric-score-4 { background: var(--success); }

  .rubric-level { font-weight: 700; font-size: 13.5px; color: var(--text); }
  .rubric-shortdesc { font-size: 12px; color: var(--text-muted); }

  .rubric-rule { display: flex; gap: 8px; }
  .rubric-rule-lang {
    flex-shrink: 0;
    font-size: 10px; font-weight: 700; letter-spacing: .04em;
    color: var(--primary);
    border: 1px solid var(--surface-tint-strong);
    background: var(--surface-tint);
    border-radius: 4px;
    padding: 1px 5px;
    height: fit-content;
  }
  .rubric-rule p { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--text); }

  /* Score meaning, reused everywhere an average appears (overall summary,
     subject rows, MLA rows) - pairs the raw number with what it means so
     "avg 3" always reads as "avg 3 · Developing", never a bare digit. */
  .score-tier-pill {
    display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
    font-size: 11px; font-weight: 700; white-space: nowrap;
  }
  .score-tier-1 { background: var(--danger-tint); color: #A32A24; }
  .score-tier-2 { background: var(--warning-tint); color: #8A5C08; }
  .score-tier-3 { background: var(--info-tint); color: var(--info); }
  .score-tier-4 { background: var(--success-tint); color: var(--success); }
  .score-tier-none { background: #F2EFE3; color: var(--text-muted); }

  .overall-avg-summary {
    display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff;
    border-radius: var(--radius-sm); padding: 16px 18px;
  }
  .overall-avg-left { display: flex; flex-direction: column; gap: 4px; max-width: 340px; }
  .overall-avg-title { font-size: 13px; font-weight: 700; }
  .overall-avg-note { font-size: 11.5px; color: rgba(255,255,255,.75); line-height: 1.4; }
  .overall-avg-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
  .overall-avg-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; line-height: 1; }
  .overall-avg-count { font-size: 11.5px; color: rgba(255,255,255,.75); white-space: nowrap; }

  .subjects-breakdown-label, .mls-breakdown-label {
    font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    color: var(--text-muted); margin: 6px 0 0;
  }

  .subject-avg-row { background: #FAF6EA; border-radius: var(--radius-sm); border: 1px solid var(--border); transition: background .15s ease, border-color .15s ease; }
  .subject-avg-row.is-expanded { background: #fff; border-color: var(--info); }
  .subject-avg-row-main {
    display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
    padding: 14px; cursor: pointer; background: none; border: none; width: 100%; text-align: left; font: inherit; color: inherit;
    border-radius: var(--radius-sm); transition: background .15s ease;
  }
  .subject-avg-row-main:hover { background: #F2EFE0; }
  .subject-avg-left { display: flex; flex-direction: column; gap: 2px; }
  .subject-avg-name { font-weight: 600; font-size: 13.5px; }
  .subject-avg-count { font-size: 11.5px; color: var(--text-muted); }
  .subjects-breakdown-header { display: flex; align-items: baseline; justify-content: space-between; margin: 24px 0 10px; gap: 12px; }
  .subjects-breakdown-header .section-label { margin: 0; }
  .subjects-breakdown-avg-label {
    font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    color: var(--text-muted); white-space: nowrap;
  }
  .subject-avg-right { display: flex; align-items: center; gap: 8px; }
  .subject-avg-score { font-family: var(--font-display); font-weight: 700; font-size: 16px; color: var(--primary); }

  .mls-expand-panel { padding: 4px 14px 12px; display: flex; flex-direction: column; gap: 6px; }
  .mls-expand-panel[hidden] { display: none; }
  .mls-row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 9px 12px; background: #fff; border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
  }
  .mls-row-left { display: flex; flex-direction: column; gap: 1px; }
  .mls-row-name { font-weight: 600; }
  .mls-row-count { font-size: 11px; color: var(--text-muted); }
  .mls-row-right { display: flex; align-items: center; gap: 8px; }
  .mls-row-score { font-weight: 700; color: var(--primary); }
  .mls-empty, .subject-avg-empty { font-size: 12.5px; color: var(--text-muted); padding: 6px 14px 10px; }

  /* ---------- OVERVIEW: AVERAGE SCORE PER SLS ---------- */
  .overview-drilldown-divider { height: 1px; background: var(--border); margin: 26px 0 22px; }
  .stat-grid-hero-only { margin-top: 22px; }

  .sls-header-label {
    font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--primary);
    display: block;
  }
  .sls-subject-header { margin: 18px 0 4px; }
  .sls-header-name { font-size: 20px; margin: 2px 0 0; color: var(--primary); }

  .sls-avg-list { display: flex; flex-direction: column; gap: 22px; margin-top: 10px; }

  .mla-group {
    border: 1.5px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff;
  }
  .mla-group-header {
    display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
    background: #FAF6EA; padding: 12px 18px; border-bottom: 1.5px solid var(--border);
  }
  .mla-header-name { font-size: 15px; margin: 1px 0 0; color: var(--primary); }
  .mla-group-avg { font-size: 12.5px; font-weight: 700; color: var(--primary); background: var(--surface-tint); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
  .mla-group-avg.muted { color: var(--text-muted); background: #F2EFE3; }

  .mla-group-items { display: flex; flex-direction: column; }
  .sls-avg-row {
    display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
    padding: 14px 18px; border-top: 1px solid var(--border);
  }
  .mla-group-items .sls-avg-row:first-child { border-top: none; }
  .sls-avg-text { min-width: 220px; max-width: 560px; flex: 1; }
  .sls-avg-id { font-size: 11px; font-weight: 700; color: var(--text-muted); letter-spacing: .03em; }
  .sls-avg-desc { font-size: 13.5px; margin-top: 3px; line-height: 1.45; }

  .sls-avg-scorebox { flex: 0 0 auto; width: 150px; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
  .sls-avg-score-value { font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--primary); line-height: 1; }
  .sls-avg-score-value.muted { color: var(--text-muted); font-size: 17px; }
  .sls-avg-score-sub { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
  .sls-avg-progress-track { width: 100%; height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
  .sls-avg-progress-fill { height: 100%; background: var(--primary); border-radius: 999px; }
  .sls-avg-progress-label { font-size: 10.5px; color: var(--text-muted); margin-top: 3px; white-space: nowrap; }

  /* ---------- SLS CRITERIA + SCORE PICKER ---------- */
  .criteria-list { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
  .criteria-row {
    border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 16px 18px;
    display: flex; flex-direction: column; gap: 14px;
  }
  .criteria-row.locked { background: #FFFBF2; border-color: #F3DDA0; }
  .criteria-text { max-width: 720px; }
  .criteria-id-row { display: flex; align-items: center; gap: 8px; }
  .criteria-id { font-size: 11px; font-weight: 700; color: var(--text-muted); letter-spacing: .03em; }
  .saved-tag {
    display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 700;
    color: var(--success); background: var(--success-tint); padding: 2px 7px; border-radius: 999px;
  }
  .saved-tag::before { content: "✓"; }
  .locked-tag {
    display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 700;
    color: #8A5C08; background: var(--warning-tint); padding: 2px 7px; border-radius: 999px;
  }
  .locked-tag::before { content: "🔒"; }
  .criteria-desc { font-size: 16px; margin-top: 2px; line-height: 1.4; }

  .score-picker { display: flex; gap: 8px; flex-wrap: wrap; }
  .score-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px;
    width: 118px; padding: 10px 8px; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
    background: #fff; color: var(--text);
    transition: border-color .15s, background .15s, transform .05s;
  }
  .score-btn:hover { border-color: var(--primary); }
  .score-btn:active { transform: scale(.96); }
  .score-btn.selected { background: var(--primary); border-color: var(--primary); }
  .score-btn:disabled { opacity: .55; cursor: not-allowed; }
  .score-btn:disabled:hover { border-color: var(--border); }
  .score-num { font-family: var(--font-display); font-weight: 700; font-size: 20px; color: var(--primary); line-height: 1; }
  .score-label {
    font-size: 11.5px; font-weight: 600; color: var(--text); text-align: center; line-height: 1.15;
    min-height: 2.4em; display: flex; align-items: center; justify-content: center;
  }
  .score-desc {
    font-size: 10.5px; color: var(--text-muted); text-align: center; line-height: 1.2;
    min-height: 2.4em; display: flex; align-items: center; justify-content: center;
  }
  .score-btn.selected .score-num,
  .score-btn.selected .score-label { color: #fff; }
  .score-btn.selected .score-desc { color: rgba(255,255,255,.7); }

  .save-bar {
    position: sticky; bottom: 0; background: rgba(255, 240, 201, .85); backdrop-filter: blur(6px);
    margin: 22px -36px -32px; padding: 16px 36px; border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; border-radius: 0 0 var(--radius) var(--radius);
  }
  .save-status { font-size: 12.5px; color: var(--text-muted); }

  /* Plain (non-sticky) save row for report/summary boxes embedded mid-
     panel - .save-bar is deliberately sticky+negative-margined for the
     one bottom-of-panel scoring bar only; reusing it elsewhere makes it
     stick to the viewport and overlap whatever comes after it. */
  .report-save-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px;
  }
  .report-save-bar[hidden] { display: none; }
  .scroll-to-save-btn { display: none; } /* mobile media query re-enables this when .visible is set (higher specificity already wins) */
  .save-status.ok { color: var(--success); font-weight: 600; }
  .save-status.locked { color: var(--warning); font-weight: 600; }
  .save-status.unsaved { color: var(--warning); font-weight: 600; }

  .empty-state {
    background: #FFF8EC; border: 1px solid #F3DDA0; color: #8A5C08;
    border-radius: var(--radius-sm); padding: 14px 16px; font-size: 13.5px; margin-top: 10px;
  }

  .loading-row {
    display: flex; align-items: center; gap: 14px; padding: 16px;
    color: var(--text-muted); font-size: 13.5px;
  }
  /* HTML: <div class="loader"></div> — bouncing-bars loader, recolored to brand primary */
  .loader {
    width: 28px; height: 14px; background: var(--primary);
    position: relative; flex: 0 0 auto;
    animation: l9-0 1.5s infinite linear;
  }
  .loader:before,
  .loader:after {
    content: ""; position: absolute; background: inherit;
    bottom: 100%; width: 50%; height: 100%;
    animation: inherit; animation-name: l9-1;
  }
  .loader:before { left: 0; transform-origin: bottom left; --s: -1; }
  .loader:after { right: 0; transform-origin: bottom right; }
  @keyframes l9-0 {
    0%, 10%   { transform: translateY(0%)    scaleY(1); }
    49.99%    { transform: translateY(-50%)  scaleY(1); }
    50%       { transform: translateY(-50%)  scaleY(-1); }
    90%, 100% { transform: translateY(-100%) scaleY(-1); }
  }
  @keyframes l9-1 {
    10%, 90% { transform: rotate(0deg); }
    50%      { transform: rotate(calc(var(--s, 1) * 180deg)); }
  }

  .save-confirm-banner {
    background: var(--success-tint); border: 1px solid #B7E0CE; color: var(--success);
    border-radius: var(--radius-sm); padding: 12px 16px; font-size: 13.5px; font-weight: 600;
    margin-bottom: 16px;
  }

  .toast {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-20px);
    background: var(--primary); color: #fff; padding: 12px 20px; border-radius: var(--radius-sm);
    font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow);
    opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 999;
  }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
  .toast.error { background: var(--danger); }

  /* ---------- TABLET ---------- */
  /* ---------- CONFIRMATION MODAL ---------- */
  .modal-overlay {
    position: fixed; inset: 0; background: rgba(26,44,110,.55); backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px;
  }
  .modal-overlay[hidden] { display: none; }
  .modal-box {
    background: #fff; border-radius: var(--radius); padding: 26px 26px 22px; max-width: 440px; width: 100%;
    box-shadow: 0 20px 50px rgba(26,44,110,.28); animation: fadeIn .18s ease;
  }
  .modal-title { font-size: 17px; margin: 0 0 10px; color: var(--primary); }
  .modal-message { font-size: 13.5px; color: var(--text-muted); line-height: 1.55; margin: 0 0 22px; }
  .modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

  /* ---------- SLS SCORE REVIEW PAGE ---------- */
  .review-back-btn { margin-bottom: 12px; }
  .review-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
  .review-header h2 { font-size: 21px; margin: 0; }
  .review-term-hint { margin: 4px 2px 18px; font-size: 12.5px; font-weight: 600; color: var(--primary); }

  .review-content { display: flex; flex-direction: column; gap: 22px; }
  .review-subject-group { border: 1.5px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; }
  .review-subject-header {
    display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
    background: #FAF6EA; padding: 12px 18px; border-bottom: 1.5px solid var(--border);
  }
  .review-subject-header h3 { font-size: 15px; margin: 0; color: var(--primary); }
  .review-subject-progress { font-size: 12px; font-weight: 700; color: var(--text-muted); }

  .review-item-row {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; flex-wrap: wrap;
    padding: 14px 18px; border-top: 1px solid var(--border);
  }
  .review-subject-group .review-item-row:first-of-type { border-top: none; }
  .review-item-text { display: flex; flex-direction: column; gap: 3px; min-width: 220px; max-width: 460px; flex: 1; }
  .review-item-id { font-size: 11px; font-weight: 700; color: var(--text-muted); letter-spacing: .03em; }
  .review-item-desc { font-size: 13.5px; line-height: 1.45; }

  .review-term-grid { display: grid; grid-template-columns: repeat(4, minmax(96px, 1fr)); gap: 8px; flex: 0 0 auto; }
  .review-term-cell {
    display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 8px 10px;
    border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: #FAF6EA;
  }
  .review-term-cell.current-term { border-color: var(--primary); background: var(--surface-tint); }
  .review-term-label { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
  .review-term-cell.current-term .review-term-label { color: var(--primary); }

  .review-status-na {
    display: inline-flex; align-items: center; font-size: 11px; font-weight: 700;
    color: var(--text-muted); background: #F2EFE3; padding: 3px 9px; border-radius: 999px; white-space: nowrap;
  }
  .review-status-missing {
    display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700;
    color: #A32A24; background: var(--danger-tint); padding: 3px 8px; border-radius: 999px; white-space: nowrap;
  }
  .review-status-icon { font-size: 11px; }

  /* ---------- REVIEW SLS: FLAT TABLE ---------- */
  .review-table-wrap {
    border: 1.5px solid var(--border); border-radius: var(--radius); overflow: auto;
    max-height: 70vh; margin-top: 14px;
  }
  .review-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 920px; }
  .review-table thead th {
    position: sticky; top: 0; z-index: 2; background: var(--primary); color: #fff;
    text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    padding: 12px 14px; white-space: nowrap; border-bottom: 1px solid rgba(255,255,255,.15);
  }
  .review-table tbody td {
    padding: 11px 14px; vertical-align: top; border-bottom: 1px solid var(--border); background: #fff;
  }
  .review-row-alt td { background: #FAF6EA; }
  .review-row-group-start td { border-top: 1.5px solid var(--border); }
  .review-td-id { font-weight: 700; color: var(--text-muted); font-size: 12px; vertical-align: middle; white-space: nowrap; }
  .review-td-name { font-weight: 600; color: var(--primary); vertical-align: middle; white-space: nowrap; }
  .review-td-subject { font-weight: 600; white-space: nowrap; }
  .review-td-desc { min-width: 260px; max-width: 380px; }
  .review-td-sls-id { display: block; font-size: 10.5px; font-weight: 700; color: var(--text-muted); letter-spacing: .03em; margin-bottom: 2px; }
  .review-td-sls-desc { display: block; line-height: 1.4; }
  .review-td-term { text-align: center; min-width: 108px; }
  .review-table-loading { text-align: center; padding: 32px 16px; color: var(--text-muted); font-size: 13px; }

  /* ---------- SEARCHABLE CLASS COMBOBOX ---------- */
  .combobox { position: relative; }
  .combobox-input {
    width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 14px; font-family: inherit; color: var(--text); background: #fff;
  }
  .combobox-input:focus { outline: none; border-color: var(--primary); }
  .combobox-input:disabled { background: var(--bg); color: var(--text-muted); cursor: not-allowed; }
  .combobox-list {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
    background: #fff; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    max-height: 260px; overflow-y: auto; box-shadow: var(--shadow);
  }
  .combobox-item { padding: 10px 14px; font-size: 13.5px; cursor: pointer; }
  .combobox-item:hover, .combobox-item-active { background: var(--surface-tint); }
  .combobox-empty { padding: 10px 14px; font-size: 13px; color: var(--text-muted); }

  /* ---------- STUDENT REPORT / GROWTH SUMMARY TEXTAREAS ---------- */
  .report-textarea {
    width: 100%; min-height: 160px; padding: 12px 14px; border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); font-size: 14px; font-family: inherit; color: var(--text);
    background: #fff; resize: vertical;
  }
  /* Subject Summary stays at the base size - its PDF template has a fixed-size
     text box already sized for 300 chars at this font; only these three boxes
     (none of them exported into a fixed template slot) get the smaller size. */
  #growth-summary-text, #next-steps-text, .portfolio-section-card .report-textarea {
    font-size: 10pt;
  }
  .report-textarea:focus { outline: none; border-color: var(--primary); }
  .report-textarea:read-only { background: var(--bg); color: var(--text-muted); cursor: not-allowed; }
  .report-textarea.bullet-textarea { line-height: 1.6; }
  .char-counter {
    font-size: 12px; color: var(--text-muted); text-align: right; margin-top: 6px;
  }
  .char-counter.low { color: var(--warning); font-weight: 600; }

  /* ---------- PORTFOLIO ---------- */
  .portfolio-student-header { display: flex; gap: 16px; align-items: center; margin-bottom: 20px; }
  .portfolio-student-header h2 { font-size: 19px; }

  .portfolio-sections {
    display: flex; flex-direction: column; gap: 20px;
  }
  .portfolio-section-card {
    background: #fff; border: 1.5px solid var(--border); border-radius: var(--radius);
    padding: 20px; display: flex; flex-direction: column;
  }
  .portfolio-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
  .portfolio-section-badge {
    font-family: var(--font-display); font-weight: 700; font-size: 12.5px; letter-spacing: .03em; text-transform: uppercase;
    color: var(--primary); background: var(--surface-tint); padding: 4px 10px; border-radius: 999px;
  }

  .portfolio-photo-area { display: flex; gap: 20px; margin-bottom: 16px; flex-wrap: wrap; align-items: flex-start; }
  .portfolio-photo-preview {
    width: 260px; max-width: 100%; aspect-ratio: 4 / 3; flex: 1 1 260px; border-radius: var(--radius-sm);
    background: var(--bg); border: 1.5px dashed var(--border-strong);
    display: flex; align-items: center; justify-content: center; overflow: hidden;
  }
  .portfolio-photo-img { width: 100%; height: 100%; object-fit: cover; }
  .portfolio-photo-placeholder { font-size: 12px; color: var(--text-muted); text-align: center; padding: 8px; line-height: 1.4; }
  .portfolio-photo-controls { flex: 1 1 200px; min-width: 180px; display: flex; flex-direction: column; gap: 6px; justify-content: center; }
  .portfolio-upload-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: fit-content; }
  /* The upload control is a <label>, so :disabled on its input can't grey it
     out - the portfolio window lock adds this class instead. */
  .portfolio-upload-btn.is-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
  .portfolio-photo-hint { font-size: 11.5px; color: var(--text-muted); margin: 0; }
  /* Sits above a narrative textarea telling the teacher what to write -
     same quiet treatment as .portfolio-photo-hint, just placed before an
     input instead of after a button. */
  .field-hint { font-size: 14px; color: var(--text-muted); margin: 0 0 6px; }
  .portfolio-photo-error { font-size: 12px; color: var(--danger); margin: 0; font-weight: 600; }
  .photo-error-hint { display: inline-block; margin-top: 2px; color: var(--text-muted); font-weight: 400; }

  .portfolio-section-card .select-label { margin-top: 4px; }
  .portfolio-section-card .char-counter { margin-bottom: 4px; }

  @media (max-width: 560px) {
    .portfolio-photo-area { flex-direction: column; }
    .portfolio-photo-preview { width: 100%; flex-basis: auto; }
    .portfolio-photo-controls { width: 100%; }
  }

  /* ---------- OVERVIEW DASHBOARD (dropdown-free redesign) ---------- */
  .stat-grid-kpi { margin-top: 22px; }

  .overview-section-card {
    background: #fff; border: 1.5px solid var(--border); border-top: 3px solid var(--cream); border-radius: var(--radius);
    padding: 22px 24px; margin-top: 22px;
  }
  .overview-section-title { font-size: 17px; margin: 0 0 18px; color: var(--primary); }

  /* Total Student by Rubric */
  .rubric-chart-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px;
  }
  .rubric-term-card {
    border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 16px;
    display: flex; flex-direction: column; align-items: center;
  }
  .rubric-term-title { font-size: 13px; font-weight: 700; color: var(--primary); margin: 0 0 14px; }
  .rubric-bars { display: flex; align-items: flex-end; gap: 10px; height: 140px; width: 100%; justify-content: center; }
  .rubric-bar-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; flex: 1 1 0; min-width: 0; }
  .rubric-bar-value { font-size: 12px; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
  .rubric-bar { width: 100%; max-width: 34px; border-radius: 5px 5px 0 0; min-height: 3px; transition: height .3s ease; }
  .rubric-bar-tier1 { background: var(--danger); }
  .rubric-bar-tier2 { background: var(--warning); }
  .rubric-bar-tier3 { background: var(--info); }
  .rubric-bar-tier4 { background: var(--success); }
  .rubric-bar-label { font-size: 9.5px; color: var(--text-muted); font-weight: 600; margin-top: 8px; text-align: center; line-height: 1.25; white-space: nowrap; }

  /* Progress Bar SLS Completeness */
  .completeness-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 22px;
  }
  .completeness-term-col { display: flex; flex-direction: column; gap: 10px; }
  .completeness-term-title { font-size: 13px; font-weight: 700; color: var(--primary); margin: 0 0 2px; text-align: center; }
  .completeness-row { display: flex; align-items: center; gap: 10px; }
  .completeness-label { flex: 0 0 108px; font-size: 12px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* Neutral gray track (not the warm border tint) so colored fills stand
     out clearly instead of blending into a muddy brown-on-brown. */
  .completeness-track { flex: 1; height: 18px; background: #E7E9EF; border-radius: 5px; overflow: hidden; position: relative; }
  .completeness-fill { height: 100%; border-radius: 5px; transition: width .3s ease, background .3s ease; }
  .completeness-fill-zero { background: #DDE0E7; }
  .completeness-fill-low { background: #E2564F; }
  .completeness-fill-mid { background: #F2A93B; }
  .completeness-fill-full { background: var(--success); }
  .completeness-pct {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: 10.5px; font-weight: 700; color: var(--text);
    /* Label spans both the neutral track and the colored fill at once -
       a halo keeps it readable against either, since a single flat color
       can't hit AA contrast on both a light track and a mid-tone fill. */
    text-shadow: 0 0 3px rgba(255,255,255,.9), 0 0 3px rgba(255,255,255,.9);
  }

  @media (max-width: 1024px) {
    .main-content { padding: 24px 22px 100px; }
    .panel { padding: 26px 24px; }
    .save-bar { margin: 22px -24px -26px; padding: 16px 24px; }
    .filter-row .select-label,
    .filter-row .select-label-class,
    .filter-row .select-label-term { flex: 1 1 200px; }
    .student-profile-info .info-cards { grid-template-columns: repeat(2, 1fr); }
    .overview-greeting { font-size: 26px; }
  }

  .sidebar-collapse-toggle { display: none; } /* only shown in the tablet range below */

  /* ---------- TABLET: collapsible icon-only sidebar ----------
     Desktop (above 1024px) keeps the sidebar always open - untouched.
     Phones (640px and below) use the separate bottom-dock layout further
     below - untouched. This range only: sidebar defaults to a narrow icon
     rail; the toggle button (hidden everywhere else) expands it back to
     the full labeled sidebar, and collapses it again on a second click. */
  @media (min-width: 641px) and (max-width: 1024px) {
    .sidebar-collapse-toggle {
      display: flex; align-items: center; justify-content: center;
      width: 30px; height: 30px; align-self: flex-end; margin-bottom: 14px; flex-shrink: 0;
      background: rgba(255,255,255,.08); border: none; border-radius: var(--radius-sm);
      color: #fff; cursor: pointer; transition: background .15s;
    }
    .sidebar-collapse-toggle:hover { background: rgba(255,255,255,.16); }
    .sidebar-collapse-toggle svg { width: 18px; height: 18px; }

    /* flex-basis alone drives width here (flex-shrink/grow are 0 from the
       base rule) - do NOT also set width alongside it. Declaring both on
       the same flex item is what caused this to get stuck on whichever
       value computed first, ignoring later class-based changes. */
    .sidebar {
      width: auto; flex-basis: 76px; padding: 18px 12px;
      transition: flex-basis .2s ease;
    }
    .sidebar.sidebar-expanded { flex-basis: 240px; padding: 22px 18px; }

    /* Visually hidden (not display:none) so the label is still announced
       to screen readers even while the rail shows icons only. */
    .sidebar:not(.sidebar-expanded) .sidebar-brand-label,
    .sidebar:not(.sidebar-expanded) .sidebar-name,
    .sidebar:not(.sidebar-expanded) .sidebar-branch,
    .sidebar:not(.sidebar-expanded) .nav-label {
      position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
      overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
    }
    .sidebar:not(.sidebar-expanded) .nav-btn,
    .sidebar:not(.sidebar-expanded) .sidebar-logout {
      justify-content: center; padding: 11px 8px; gap: 0;
    }
    .sidebar:not(.sidebar-expanded) .sidebar-avatar .avatar-img,
    .sidebar:not(.sidebar-expanded) .sidebar-avatar .avatar-fallback {
      width: 40px; height: 40px; font-size: 15px;
    }
  }

  /* ---------- MOBILE ---------- */
  @media (max-width: 640px) {
    .view-app { flex-direction: column; }
    .sidebar {
      width: 100%; flex-basis: auto; height: auto; position: relative;
      flex-direction: column; padding: 0; gap: 0;
    }
    .sidebar-brand {
      flex-direction: row; gap: 8px; width: auto; margin-bottom: 0;
      padding: 10px 16px; justify-content: flex-start;
    }
    .sidebar-logo-wrap { width: 40px; flex-shrink: 0; }
    .sidebar-brand-label { display: none; }
    /* The right side of the header bar was empty once the desktop profile
       block got hidden - show just the teacher's avatar there instead of
       leaving dead space, name/branch stay hidden to keep it compact. */
    .sidebar-profile {
      position: absolute; top: 10px; right: 16px; bottom: auto;
      margin-bottom: 0; width: auto;
    }
    .sidebar-name, .sidebar-branch { display: none; }
    .sidebar-profile .sidebar-avatar { margin-bottom: 0; }
    .sidebar-profile .avatar-img,
    .sidebar-profile .avatar-fallback { width: 40px; height: 40px; font-size: 15px; }

    /* The nav + sign out become ONE floating dock detached from the
       screen edges, like Instagram/Facebook's mobile tab bar - always
       visible, no scrolling needed to reach any item. Active tab is a
       filled rounded-square chip behind just the icon, plus a small dot
       underneath, rather than tinting the whole cell. */
    .sidebar-bottom-group {
      position: fixed; left: 12px; right: 12px;
      bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 100;
      flex: initial; flex-direction: row; background: var(--primary);
      border-radius: 22px; box-shadow: 0 8px 24px rgba(33,38,74,.32);
      padding: 6px 4px;
    }
    .sidebar-nav { flex-direction: row; flex: 1; justify-content: space-around; gap: 0; }
    .nav-btn, .sidebar-logout {
      display: flex; flex-direction: column; align-items: center; justify-content: center;
      gap: 4px; padding: 8px 10px; white-space: nowrap;
    }
    .nav-btn.active { background: none; border-left: none; padding-left: 10px; }
    .nav-btn::after, .sidebar-logout::after {
      content: ''; width: 5px; height: 5px; border-radius: 50%;
      background: var(--cream); opacity: 0; transition: opacity .15s;
    }
    .nav-btn.active::after { opacity: 1; }
    .nav-icon {
      width: 22px; height: 22px; padding: 6px; border-radius: 10px;
      box-sizing: content-box; transition: opacity .15s, background .15s;
    }
    /* Soft translucent chip, matching the desktop active-nav treatment -
       not a solid cream block, which read as too loud/vivid. */
    .nav-btn.active .nav-icon { background: rgba(255,255,255,.2); }
    .nav-label { display: none; }
    .sidebar-logout { margin-top: 0; flex: 0 0 auto; border: none; }
    .sidebar-logout .nav-icon { opacity: .75; }
    .sidebar-logout:hover .nav-icon { opacity: 1; }

    /* Reserve space so page content never sits hidden behind the fixed
       bottom bar. */
    .main-content { padding: 4px 14px calc(84px + env(safe-area-inset-bottom, 0px)); }
    .panel { padding: 20px 16px; }
    .save-bar { position: static; margin: 18px -16px -20px; padding: 14px 16px; }
    .scroll-to-save-btn {
      display: none; position: fixed; right: 16px;
      bottom: calc(96px + env(safe-area-inset-bottom, 0px));
      width: 50px; height: 50px; border-radius: 50%; border: none;
      background: var(--primary); box-shadow: 0 4px 14px rgba(36,59,143,.45);
      align-items: center; justify-content: center; z-index: 90; cursor: pointer;
    }
    .scroll-to-save-btn svg { width: 22px; height: 22px; }
    .scroll-to-save-btn.visible { display: flex; }
    .info-cards { grid-template-columns: 1fr 1fr; }
    .filter-row { gap: 14px; }
    .filter-row .select-label,
    .filter-row .select-label-class,
    .filter-row .select-label-term { flex: 1 1 100%; }
    .filter-row .info-cards { flex: 1 1 100%; }
    .select-label-term { max-width: none; }
    .overview-hero { flex-direction: column; align-items: flex-start; }
    .overview-greeting { font-size: 24px; }
    .chart-row-label { flex-basis: 100px; }
    .student-row { flex-direction: column; align-items: flex-start; }
    .student-actions { width: 100%; }
    .student-actions .btn { flex: 1; }
    .subject-buttons { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
    .score-btn { width: calc(50% - 4px); }
    /* rubric cheatsheet: one stacked column per level on phones */
    .rubric-item { grid-template-columns: 1fr; gap: 8px; }
    .rubric-item-head { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
    .rubric-cheatsheet-body { padding-left: 12px; padding-right: 12px; }
    .avatar-img, .avatar-fallback { width: 84px; height: 84px; font-size: 27px; }
    .student-profile-info .info-cards { grid-template-columns: 1fr 1fr; }
    .review-term-grid { grid-template-columns: repeat(2, 1fr); width: 100%; }
    .review-item-row { flex-direction: column; }
    .review-header { flex-direction: column; }
  }
