.stats-view {
      display: none;
      flex: 1;
      overflow: auto;
      padding: 14px;
      background: white;
    }

    .stats-view.active {
      display: block;
    }

    .group-view {
      min-height: 100vh;
      background: var(--soft);
      padding: 8px;
    }

    .group-shell {
      min-height: calc(100vh - 16px);
      background: white;
      border: 1px solid var(--line);
      border-radius: 8px;
      overflow: hidden;
      box-shadow: 0 8px 22px rgba(31, 41, 55, 0.08);
      display: grid;
      grid-template-rows: auto 1fr;
    }

    .group-content {
      display: grid;
      grid-template-columns: minmax(260px, 340px) 1fr;
      gap: 14px;
      padding: 14px;
    }

    .group-panel,
    .group-stage {
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fbfcfe;
      padding: 14px;
    }

    .student-checks {
      max-height: 360px;
      overflow: auto;
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
      gap: 8px;
      margin-top: 8px;
    }

    .student-toggle {
      border: 1px solid #9bd6ad;
      border-radius: 8px;
      background: #dcf5e3;
      color: #14532d;
      min-height: 42px;
      padding: 8px 10px;
      font-size: 13px;
      font-weight: 800;
      text-align: left;
      cursor: pointer;
    }

    .student-toggle.absent {
      border-color: #f5a6a6;
      background: #ffe1e1;
      color: #991b1b;
      text-decoration: line-through;
    }

    .student-toggle:focus {
      outline: 2px solid #5b9bd5;
      outline-offset: 2px;
    }

    .hidden-mode-panel {
      border: 1px solid #bfd0e2;
      border-radius: 8px;
      background: #f8fbff;
      padding: 10px;
      display: grid;
      gap: 10px;
    }

    .hidden-mode-panel.hidden {
      display: none;
    }

    .hidden-mode-card {
      width: min(980px, calc(100vw - 28px));
      max-height: calc(100vh - 36px);
      overflow: auto;
      border: 1px solid #d9e1ec;
      border-radius: 10px;
      background: white;
      box-shadow: 0 24px 70px rgba(15, 23, 42, 0.38);
      padding: 18px;
    }

    .hidden-mode-switch {
      display: grid;
      grid-template-columns: auto 1fr;
      gap: 8px;
      align-items: start;
      font-size: 13px;
      color: #344054;
      font-weight: 700;
    }

    .hidden-mode-switch input {
      margin-top: 2px;
    }

    .hidden-mode-switch.spaced {
      margin-top: 10px;
    }

    .achievement-zones {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 8px;
    }

    .achievement-zone {
      min-height: 150px;
      border: 1px dashed #9fb5ca;
      border-radius: 8px;
      background: white;
      padding: 8px;
    }

    .achievement-zone h3 {
      margin: 0 0 8px;
      color: var(--blue);
      font-size: 13px;
    }

    .achievement-chip {
      width: 100%;
      margin-bottom: 6px;
      border: 1px solid #dce3ee;
      border-radius: 7px;
      background: #eef5fb;
      color: #123d63;
      padding: 7px;
      font-size: 12px;
      font-weight: 800;
      text-align: left;
      cursor: grab;
    }

    .achievement-zone.drag-over {
      border-color: var(--blue);
      background: #eaf3ff;
    }

    .student-list-title {
      display: flex;
      justify-content: space-between;
      gap: 10px;
      align-items: center;
      margin-bottom: 8px;
      color: var(--blue);
      font-weight: 900;
    }

    .student-list-title span {
      color: var(--muted);
      font-size: 13px;
    }

    .participant-count {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      border: 1px solid #bfd0e2;
      border-radius: 999px;
      background: #eef5fb;
      color: var(--blue);
      padding: 6px 10px;
      font-size: 13px;
      font-weight: 900;
    }

    .group-animation {
      min-height: 210px;
      border: 1px dashed #b9c6d8;
      border-radius: 10px;
      background: linear-gradient(180deg, #f8fbff, #eef7f0);
      position: relative;
      overflow: hidden;
      margin-bottom: 14px;
    }

    .group-results-actions {
      display: none;
      justify-content: flex-end;
      gap: 8px;
      margin-bottom: 12px;
    }

    .group-actions {
      flex-wrap: wrap;
      align-items: stretch;
      margin-top: 12px;
    }

    .group-actions button {
      flex: 1 1 138px;
      min-width: 0;
      min-height: 42px;
      padding: 9px 10px;
      white-space: normal;
      line-height: 1.15;
    }

    .group-actions .primary {
      flex-basis: 150px;
    }

    .group-setup-notice {
      margin-top: 10px;
    }

    .group-animation-notice {
      margin: 14px;
    }

    .saved-groups-title {
      color: var(--blue);
      margin-top: 16px;
    }

    .saved-group-entry {
      margin-top: 7px;
    }

    .saved-group-delete {
      margin-top: 10px;
    }

    .group-results-footer {
      margin-top: 14px;
    }

    .group-view.results-mode .group-content {
      grid-template-columns: 1fr;
      min-height: calc(100vh - 112px);
    }

    .group-view.results-mode .group-panel,
    .group-view.results-mode .student-list-title,
    .group-view.results-mode .student-checks,
    .group-view.results-mode .group-stage > h3,
    .group-view.results-mode #savedGroupsList {
      display: none;
    }

    .group-view.results-mode .group-stage {
      min-height: calc(100vh - 132px);
      display: grid;
      grid-template-rows: auto minmax(260px, 0.75fr) 1fr;
    }

    .group-view.results-mode .group-results-actions {
      display: flex;
    }

    .group-view.results-mode .group-animation {
      min-height: 260px;
    }

    .group-view.results-mode .generated-groups {
      grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
      align-content: start;
    }

    .group-view.results-mode .group-card {
      font-size: 18px;
      padding: 18px;
    }

    .runner {
      position: absolute;
      width: 34px;
      height: 34px;
      border-radius: 999px;
      display: grid;
      place-items: center;
      color: white;
      font-weight: 900;
      background: var(--blue);
      animation: runAround 1.7s ease-in-out infinite alternate;
    }

    .runner.arriving {
      animation: arriveToGroup 0.95s ease-out forwards;
      box-shadow: 0 10px 20px rgba(31, 78, 121, 0.18);
    }

    @keyframes runAround {
      from { transform: translateX(-12px) translateY(0); }
      to { transform: translateX(42px) translateY(12px); }
    }

    @keyframes arriveToGroup {
      0% { transform: translate(-120px, 24px) scale(0.85); opacity: 0; }
      55% { transform: translate(8px, -8px) scale(1.08); opacity: 1; }
      100% { transform: translate(0, 0) scale(1); opacity: 1; }
    }

    .group-card.revealing {
      min-height: 116px;
      background: linear-gradient(180deg, #ffffff, #f7fbff);
    }

    .group-results-card {
      width: min(1280px, calc(100vw - 20px));
      max-height: calc(100vh - 20px);
      overflow: hidden;
      border: 1px solid #d9e1ec;
      border-radius: 10px;
      background: white;
      box-shadow: 0 24px 70px rgba(15, 23, 42, 0.38);
      padding: 18px;
      display: grid;
      grid-template-rows: auto minmax(0, 1fr) auto;
    }

    .modal-generated-groups {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
      gap: 12px;
      margin-top: 14px;
      overflow: auto;
      align-content: start;
    }

    .modal-generated-groups .group-card {
      position: relative;
      min-height: 120px;
      font-size: 16px;
      padding: 14px;
    }

    .modal-generated-groups .group-card.compact {
      min-height: 96px;
      padding: 10px;
      font-size: 14px;
    }

    .group-celebration {
      position: absolute;
      top: 10px;
      right: 10px;
      width: 34px;
      height: 34px;
      border-radius: 999px;
      display: grid;
      place-items: center;
      background: #e8f5ee;
      border: 1px solid #badfcc;
      font-size: 20px;
    }

    .separation-box {
      border: 1px solid #dce3ee;
      border-radius: 8px;
      background: white;
      padding: 10px;
      display: none;
      gap: 8px;
      box-shadow: 0 16px 38px rgba(15, 23, 42, 0.16);
      z-index: 20;
    }

    .separation-box.active {
      display: grid;
    }

    .separation-dropdown {
      position: relative;
      display: inline-flex;
    }

    .separation-dropdown .separation-box {
      position: absolute;
      left: 0;
      right: auto;
      top: calc(100% + 8px);
      width: min(420px, calc(100vw - 44px));
      max-height: min(80vh, calc(100vh - 90px));
      overflow: auto;
      transform-origin: top left;
    }

    .separation-controls {
      display: grid;
      grid-template-columns: 1fr;
      gap: 8px;
    }

    .separation-student-list {
      max-height: none;
      overflow: visible;
      display: grid;
      gap: 5px;
      border: 1px solid #dce3ee;
      border-radius: 8px;
      padding: 7px;
      background: #f8fafc;
    }

    .separation-student-option {
      min-height: 32px;
      border: 1px solid #d7e2ef;
      border-radius: 7px;
      background: white;
      color: #164266;
      font-weight: 800;
      text-align: left;
      padding: 7px 9px;
    }

    .separation-student-option.selected {
      background: var(--blue);
      color: white;
      border-color: var(--blue);
    }

    .separation-list {
      display: grid;
      gap: 6px;
    }

    .separation-item {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 8px;
      align-items: center;
      border: 1px solid #e5e7eb;
      border-radius: 7px;
      padding: 7px;
      background: #fbfcfe;
      font-size: 12px;
      font-weight: 800;
    }

    .group-member {
      opacity: 0;
      transform: translateY(8px);
      transition: opacity 0.55s ease, transform 0.55s ease;
      padding: 5px 0;
      border-bottom: 1px solid #eef2f6;
      font-weight: 800;
    }

    .group-member.visible {
      opacity: 1;
      transform: translateY(0);
    }

    .generated-groups {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
      gap: 10px;
    }

    .group-card {
      border: 1px solid #dce3ee;
      border-radius: 8px;
      background: white;
      padding: 12px;
    }

    .group-card h3 {
      margin: 0 0 8px;
      color: var(--blue);
    }

    .stats-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 12px;
    }

    .stats-grid.wide {
      grid-template-columns: repeat(3, minmax(0, 1fr));
      margin-bottom: 12px;
    }

    .stats-section-title {
      margin: 16px 0 8px;
      color: var(--blue);
      font-size: 18px;
    }

    .metric {
      border: 1px solid var(--line);
      border-radius: 8px;
      padding: 12px;
      background: linear-gradient(180deg, #ffffff, #f7fbff);
    }

    .metric span {
      display: block;
      color: var(--muted);
      font-size: 12px;
      font-weight: 700;
    }

    .metric strong {
      display: block;
      margin-top: 5px;
      color: var(--blue);
      font-size: 24px;
    }

    .detail-list {
      display: grid;
      gap: 7px;
      font-size: 12px;
    }

    .detail-list div {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      padding: 7px 8px;
      border-radius: 6px;
      background: #eef5fb;
    }

    .pie-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 12px;
      margin: 12px 0;
    }

    .pie-card {
      border: 1px solid var(--line);
      border-radius: 8px;
      padding: 12px;
      background: #fbfcfe;
    }

    .pie-card h3 {
      margin: 0 0 10px;
      font-size: 15px;
      color: var(--blue);
    }

    .pie-wrap {
      display: grid;
      grid-template-columns: 132px 1fr;
      align-items: center;
      gap: 12px;
    }

    .pie {
      width: 120px;
      height: 120px;
      border-radius: 50%;
      display: grid;
      place-items: center;
      background: #e5e7eb;
      box-shadow: inset 0 0 0 1px rgba(31, 78, 121, 0.16);
    }

    .pie::after {
      content: "";
      width: 58px;
      height: 58px;
      border-radius: 50%;
      background: white;
      box-shadow: 0 0 0 1px rgba(31, 78, 121, 0.12);
    }

    .legend {
      display: grid;
      gap: 6px;
      font-size: 12px;
    }

    .legend div {
      display: grid;
      grid-template-columns: 10px 1fr auto;
      gap: 7px;
      align-items: center;
    }

    .swatch {
      width: 10px;
      height: 10px;
      border-radius: 2px;
    }

    .stats-toolbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 12px;
      padding: 10px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #f8fafc;
    }

    .stats-toolbar strong {
      color: var(--blue);
    }

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

    .stats-export {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      justify-content: flex-end;
    }

    .stats-actions button {
      border: 1px solid #98b9d7;
      background: white;
      color: var(--blue);
      border-radius: 6px;
      padding: 8px 10px;
      font-weight: 700;
      cursor: pointer;
    }

    .stats-actions button.active {
      background: var(--blue);
      color: white;
      border-color: var(--blue);
    }

    .stat-card {
      border: 1px solid var(--line);
      border-radius: 8px;
      padding: 12px;
      background: #fbfcfe;
    }

    .stat-card h3 {
      margin: 0 0 10px;
      font-size: 15px;
      color: var(--blue);
    }

    .stat-line {
      display: grid;
      grid-template-columns: minmax(110px, 1fr) minmax(120px, 1.4fr) 32px;
      gap: 8px;
      align-items: center;
      margin: 7px 0;
      font-size: 12px;
    }

    .bar {
      height: 10px;
      background: #e5e7eb;
      border-radius: 999px;
      overflow: hidden;
    }

    .bar span {
      display: block;
      height: 100%;
      background: var(--blue);
    }

    .stat-alert {
      margin: 8px 0;
      padding: 8px;
      border-radius: 6px;
      background: #fff6d6;
      font-size: 12px;
      line-height: 1.35;
    }

