    :root {
      --green: #7a9e7e;
      --green-dark: #5a7e5f;
      --green-light: #c8dfc9;
      --bg: #f5f7f4;
      --white: #ffffff;
      --text: #2d3a2e;
      --text-light: #6b7c6e;
      --red: #e57373;
      --red-light: #fce8e8;
      --green-visio: #a78bfa;
      --green-visio-light: #ede9fe;
      --amber: #f59e0b;
      --amber-light: #fef9ec;
      --shadow: 0 2px 12px rgba(0,0,0,0.08);
      --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
      --radius: 14px;
      --radius-sm: 8px;
    }

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

    body {
      font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
      background: var(--bg);
      color: var(--text);
      min-height: 100dvh;
      -webkit-tap-highlight-color: transparent;
    }

    /* ===== STICKY TOP (header + stats + cours) ===== */
    .app-top {
      position: sticky;
      top: 0;
      z-index: 100;
      box-shadow: 0 2px 16px rgba(0,0,0,0.07);
    }

    /* ===== HEADER ===== */
    .header {
      background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
      color: white;
      padding: 10px 12px 8px;
    }
    .header-hero {
      display: flex;
      align-items: center;
      gap: 6px;
    }
    .course-hero-title {
      flex: 1;
      font-size: 15px;
      font-weight: 700;
      letter-spacing: -0.2px;
      text-align: center;
      line-height: 1.25;
      min-width: 0;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .header-actions {
      display: flex;
      align-items: center;
      gap: 4px;
      flex-shrink: 0;
    }
    .icon-btn {
      width: 34px; height: 34px;
      border-radius: 50%;
      border: none;
      background: rgba(255,255,255,0.2);
      color: white;
      font-size: 14px;
      cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      transition: background 0.2s;
    }
    .icon-btn:hover { background: rgba(255,255,255,0.3); }
    .icon-btn:active { transform: scale(0.95); }
    .save-dot {
      width: 8px; height: 8px;
      border-radius: 50%;
      background: rgba(255,255,255,0.5);
      flex-shrink: 0;
    }
    .save-dot.saved { background: #b9f6ca; }
    .save-dot.saving { background: #fff9c4; animation: pulse 0.8s infinite alternate; }
    .save-dot.error { background: #ffcdd2; }
    @keyframes pulse { from { opacity: 0.5; } to { opacity: 1; } }

    .header-sub {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      margin-top: 6px;
    }
    .week-label {
      font-size: 11px;
      font-weight: 500;
      opacity: 0.85;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .week-arrow {
      width: 32px; height: 32px;
      border-radius: 50%;
      border: 1.5px solid rgba(255,255,255,0.45);
      background: transparent;
      color: white;
      font-size: 13px;
      cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      flex-shrink: 0;
      transition: background 0.2s;
    }
    .week-arrow:hover { background: rgba(255,255,255,0.15); }
    .today-btn {
      padding: 3px 10px;
      border-radius: 12px;
      border: 1px solid rgba(255,255,255,0.5);
      background: rgba(255,255,255,0.12);
      color: white;
      font-size: 11px;
      font-weight: 700;
      cursor: pointer;
      flex-shrink: 0;
    }
    .today-btn:hover { background: rgba(255,255,255,0.22); }

    /* ===== COUNTERS ===== */
    .counters {
      background: var(--white);
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 0;
      padding: 6px 8px;
      border-bottom: 1px solid #e8efe5;
    }
    .counter-item {
      text-align: center;
      padding: 2px 4px;
      border-right: 1px solid #eef3ec;
    }
    .counter-item:last-child { border-right: none; }
    .counter-item .counter-num {
      font-size: 20px;
      font-weight: 700;
      color: var(--green-dark);
      line-height: 1.1;
    }
    .counter-item .counter-num.red { color: var(--red); }
    .counter-item .counter-num.purple { color: var(--green-visio); }
    .counter-item .counter-num.green { color: var(--green); }
    .counter-item .counter-label {
      font-size: 9px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.3px;
      color: var(--text-light);
      margin-top: 1px;
    }

    /* ===== COURSE TABS ===== */
    .course-tabs-scroll {
      background: var(--white);
      border-bottom: 1px solid #e8efe5;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: none;
    }
    .course-tabs-scroll::-webkit-scrollbar { display: none; }
    .course-tabs {
      display: flex;
      flex-wrap: nowrap;
      gap: 6px;
      padding: 8px 12px;
      min-width: min-content;
    }
    .course-tab {
      flex: 0 0 auto;
      padding: 6px 12px;
      border-radius: 20px;
      border: 1.5px solid #dde8da;
      background: var(--white);
      color: var(--text);
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.2s;
      text-align: center;
      white-space: nowrap;
    }
    .course-tab.active {
      background: var(--green);
      border-color: var(--green);
      color: white;
    }
    .course-tab:active { transform: scale(0.97); }

    /* ===== STUDENT LIST ===== */
    .student-list-wrap {
      padding: 0 0 72px;
    }
    .student-list {
      background: var(--white);
    }

    .student-row {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 7px 12px;
      border-bottom: 1px solid #eef3ec;
      border-left: 3px solid transparent;
      min-height: 44px;
    }
    .student-row.absent { border-left-color: var(--red); background: #fffafa; }
    .student-row.visio { border-left-color: var(--green-visio); background: #faf9ff; }

    .student-info { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
    .student-name {
      font-size: 14px;
      font-weight: 600;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .student-tag {
      flex-shrink: 0;
      font-size: 9px;
      font-weight: 700;
      padding: 1px 6px;
      border-radius: 8px;
      text-transform: uppercase;
      letter-spacing: 0.3px;
    }
    .tag-visio { color: var(--green-visio); }
    .tag-rattrapage { background: var(--amber-light); color: var(--amber); }
    .tag-essai { background: #e0f2fe; color: #0369a1; }
    .tag-carte { background: #f3e8ff; color: #7c3aed; }

    .student-actions {
      display: flex;
      gap: 4px;
      flex-shrink: 0;
    }
    .action-btn {
      width: 32px; height: 32px;
      border-radius: 8px;
      border: none;
      cursor: pointer;
      font-size: 12px;
      font-weight: 700;
      display: flex; align-items: center; justify-content: center;
      transition: transform 0.15s;
    }
    .action-btn:active { transform: scale(0.9); }
    .btn-present { background: var(--green-light); color: var(--green-dark); }
    .btn-present.active { background: var(--green); color: white; }
    .btn-absent { background: #fce8e8; color: var(--red); }
    .btn-absent.active { background: var(--red); color: white; }
    .btn-visio { background: var(--green-visio-light); color: var(--green-visio); }
    .btn-visio.active { background: var(--green-visio); color: white; }
    .btn-remove {
      background: #fce8e8;
      color: var(--red);
      width: 28px; height: 28px;
      font-size: 11px;
    }

    /* ===== ADD SECTION (repliée) ===== */
    .add-section {
      background: var(--white);
      border-top: 1px solid #e8efe5;
      margin-top: 8px;
    }
    .add-toggle {
      display: block;
      width: 100%;
      padding: 12px;
      border: none;
      background: var(--bg);
      color: var(--green-dark);
      font-size: 13px;
      font-weight: 700;
      cursor: pointer;
      font-family: inherit;
      text-align: center;
    }
    .add-section-body {
      display: none;
      padding: 12px 14px 14px;
    }
    .add-section.expanded .add-section-body { display: block; }
    .add-section.expanded .add-toggle { display: none; }
    .add-close-btn {
      display: block;
      width: 100%;
      padding: 8px;
      margin-top: 8px;
      border: none;
      background: none;
      color: var(--text-light);
      font-size: 12px;
      cursor: pointer;
      font-family: inherit;
    }

    .add-type-tabs {
      display: flex;
      gap: 6px;
      margin-bottom: 10px;
    }
    .add-type-tab {
      flex: 1;
      padding: 7px 6px;
      border-radius: 8px;
      border: 2px solid #dde8da;
      background: var(--white);
      font-size: 11px;
      font-weight: 700;
      color: var(--text-light);
      cursor: pointer;
      text-align: center;
      transition: all 0.2s;
    }
    .add-type-tab.active {
      border-color: var(--green);
      background: var(--green-light);
      color: var(--green-dark);
    }

    .add-form {
      display: flex;
      gap: 8px;
    }
    .add-form input {
      flex: 1;
      padding: 10px 14px;
      border-radius: 10px;
      border: 2px solid #dde8da;
      font-size: 14px;
      font-family: inherit;
      background: var(--bg);
      color: var(--text);
      outline: none;
      transition: border-color 0.2s;
    }
    .add-form input:focus { border-color: var(--green); }
    .add-form input::placeholder { color: #aab4ac; }
    .add-form .add-submit {
      padding: 10px 18px;
      border-radius: 10px;
      border: none;
      background: var(--green);
      color: white;
      font-size: 14px;
      font-weight: 700;
      cursor: pointer;
      white-space: nowrap;
      transition: background 0.2s, transform 0.15s;
    }
    .add-form .add-submit:active { transform: scale(0.95); background: var(--green-dark); }

    /* ===== MODAL ===== */
    .modal-overlay {
      position: fixed; inset: 0;
      background: rgba(0,0,0,0.4);
      z-index: 200;
      display: flex;
      align-items: flex-end;
      justify-content: center;
      padding: 0 0 20px;
    }
    .modal-overlay.hidden { display: none; }
    .modal {
      background: var(--white);
      border-radius: 20px 20px 0 0;
      width: 100%;
      max-width: 500px;
      padding: 20px 16px;
      box-shadow: 0 -8px 40px rgba(0,0,0,0.15);
      animation: slideUp 0.3s ease;
      max-height: 90dvh;
      overflow-y: auto;
    }
    @keyframes slideUp {
      from { transform: translateY(100%); opacity: 0; }
      to { transform: translateY(0); opacity: 1; }
    }
    .modal-handle {
      width: 40px; height: 4px;
      background: #dde8da;
      border-radius: 2px;
      margin: 0 auto 16px;
    }
    .modal-title {
      font-size: 18px;
      font-weight: 700;
      margin-bottom: 16px;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }
    .modal-close {
      width: 32px; height: 32px;
      border-radius: 50%;
      border: none;
      background: var(--bg);
      font-size: 18px;
      cursor: pointer;
      display: flex; align-items: center; justify-content: center;
    }

    /* Manage students */
    .manage-student-item {
      display: flex;
      align-items: center;
      padding: 10px 12px;
      border-radius: var(--radius-sm);
      margin-bottom: 6px;
      background: var(--bg);
      gap: 10px;
    }
    .manage-student-item .si-name {
      flex: 1;
      font-size: 14px;
      font-weight: 600;
    }
    .manage-student-item .si-remove {
      width: 30px; height: 30px;
      border-radius: 50%;
      border: none;
      background: #fce8e8;
      color: var(--red);
      font-size: 13px;
      cursor: pointer;
      display: flex; align-items: center; justify-content: center;
    }
    .add-permanent-form {
      display: flex;
      gap: 8px;
      margin-top: 12px;
    }
    .add-permanent-form input {
      flex: 1;
      padding: 10px 14px;
      border-radius: 10px;
      border: 2px solid #dde8da;
      font-size: 14px;
      font-family: inherit;
      background: var(--bg);
      outline: none;
    }
    .add-permanent-form input:focus { border-color: var(--green); }
    .add-permanent-form button {
      padding: 10px 16px;
      border-radius: 10px;
      border: none;
      background: var(--green);
      color: white;
      font-size: 13px;
      font-weight: 700;
      cursor: pointer;
    }

    /* Export/Import modal */
    .export-btn-large, .import-btn-large {
      display: block;
      width: 100%;
      padding: 16px;
      border-radius: var(--radius-sm);
      border: 2px solid #dde8da;
      background: var(--white);
      font-size: 14px;
      font-weight: 700;
      color: var(--text);
      cursor: pointer;
      margin-bottom: 10px;
      text-align: center;
      transition: border-color 0.2s, background 0.2s;
      font-family: inherit;
    }
    .export-btn-large:hover { border-color: var(--green); background: var(--green-light); }
    .import-btn-large:hover { border-color: var(--amber); background: var(--amber-light); }
    .import-btn-large { margin-top: 12px; }
    #file-import-input { display: none; }

    /* ===== TOAST ===== */
    .toast {
      position: fixed;
      bottom: 24px;
      left: 50%;
      transform: translateX(-50%) translateY(100px);
      background: var(--text);
      color: white;
      padding: 12px 20px;
      border-radius: 12px;
      font-size: 13px;
      font-weight: 600;
      z-index: 300;
      opacity: 0;
      transition: transform 0.3s, opacity 0.3s;
      pointer-events: none;
      white-space: nowrap;
    }
    .toast.show {
      transform: translateX(-50%) translateY(0);
      opacity: 1;
    }

    /* ===== EMPTY STATE ===== */
    .empty-state {
      text-align: center;
      padding: 40px 20px;
      color: var(--text-light);
    }
    .empty-state .es-icon { font-size: 40px; margin-bottom: 10px; }
    .empty-state p { font-size: 14px; }

    /* ===== LOGIN ===== */
    .login-overlay {
      position: fixed;
      inset: 0;
      z-index: 500;
      background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 24px;
    }
    .login-overlay.hidden { display: none; }
    .login-box {
      background: var(--white);
      border-radius: var(--radius);
      padding: 28px 24px;
      width: 100%;
      max-width: 360px;
      box-shadow: 0 12px 40px rgba(0,0,0,0.2);
    }
    .login-box h2 {
      font-size: 20px;
      font-weight: 700;
      text-align: center;
      margin-bottom: 8px;
      color: var(--text);
    }
    .login-box p {
      font-size: 13px;
      color: var(--text-light);
      text-align: center;
      margin-bottom: 20px;
      line-height: 1.45;
    }
    .login-box input[type="password"] {
      width: 100%;
      padding: 12px 14px;
      border-radius: 10px;
      border: 2px solid #dde8da;
      font-size: 16px;
      font-family: inherit;
      margin-bottom: 8px;
      outline: none;
    }
    .login-box input[type="password"]:focus { border-color: var(--green); }
    .login-error {
      font-size: 12px;
      color: var(--red);
      text-align: center;
      margin-bottom: 8px;
    }
    .login-error.hidden { display: none; }
    .login-submit {
      width: 100%;
      padding: 12px;
      border: none;
      border-radius: 10px;
      background: var(--green);
      color: white;
      font-size: 15px;
      font-weight: 700;
      cursor: pointer;
      font-family: inherit;
      margin-top: 4px;
    }
    .login-submit:active { background: var(--green-dark); }

    #app-root.locked { visibility: hidden; height: 100dvh; overflow: hidden; }
