    /* ===== Einheitliche Farbpalette (Corporate Design) ===== */
    :root {
      /* Primaer */
      --clr-primary: #1F4E79;
      --clr-primary-dark: #0d2540;
      --clr-primary-light: #e3f2fd;
      --clr-secondary: #1565c0;

      /* Status: Erfolg / Frei (sanftes Gruen) */
      --clr-success: #4caf50;
      --clr-success-dark: #2e5c31;
      --clr-success-light: #e8f5e9;
      --clr-success-hover: #c8e6c9;
      --clr-success-drag: #dcedc8;

      /* Status: Gefahr / Konflikt (sanftes Rot) */
      --clr-danger: #e57373;
      --clr-danger-dark: #8b3a3a;
      --clr-danger-light: #ffebee;
      --clr-danger-hover: #ffcdd2;

      /* Status: Warnung / Belegt (sanftes Gelb) */
      --clr-warning: #ffca28;
      --clr-warning-dark: #7a6520;
      --clr-warning-light: #fffde7;
      --clr-warning-hover: #fff9c4;
      --clr-warning-text: #5d4e1f;

      /* Status: Wegezeit / Lila */
      --clr-travel: #9c7cbf;
      --clr-travel-light: #f3e8ff;
      --clr-travel-pale: #ede0f7;
      --clr-travel-dark: #5e3d7a;

      /* Neutral / Grau */
      --clr-gray: #6c757d;
      --clr-gray-light: #e9ecef;
      --clr-gray-lighter: #f0f4f8;
      --clr-gray-dark: #495057;
      --clr-gray-border: #dee2e6;
      --clr-gray-muted: #adb5bd;

      /* Hintergrund */
      --clr-bg: #f5f5f5;
      --clr-bg-white: #ffffff;
      --clr-text: #333333;
      --clr-text-muted: #666666;

      /* Spezial */
      --clr-purple: #6f42c1;
      --clr-teal: #00838f;
      --clr-brown: #4e342e;
      --clr-cyan: #17a2b8;

      /* Gebäude-Palette (pastell, 11 Farben) */
      --clr-bld-1: #5b86b8;   /* Unterhaus - gedaempftes Blau */
      --clr-bld-2: #6d9a6d;   /* Mittelhaus - gedaempftes Gruen */
      --clr-bld-3: #b8863a;   /* Oberhaus - warmes Gold */
      --clr-bld-4: #7a9e5a;   /* Tannenhaus - Tannengruen */
      --clr-bld-5: #c4956a;   /* Akazienhaus - warmes Sand */
      --clr-bld-6: #7b8fb8;   /* Institut - Stahlblau */
      --clr-bld-7: #9a7eb5;   /* Musenhof - sanftes Lila */
      --clr-bld-8: #6a9aaa;   /* Bibliothek - Petrol */
      --clr-bld-9: #b07a8a;   /* Musikhaus - Altrose */
      --clr-bld-10: #7aab8e;  /* Sporthalle - Sportgruen */
      --clr-bld-11: #a08870;  /* Reithalle - Erd-/Sandton */
    }

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

    body {
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
      background: var(--clr-bg);
      color: var(--clr-text);
      font-size: 14px;
    }

    /* ===== Header ===== */
    .app-header {
      background: linear-gradient(135deg, #1F4E79 0%, #2a6298 100%);
      background: linear-gradient(90deg, #162f4a 0%, #1F4E79 30%, #2a6298 100%);
      color: white;
      height: 68px;
      display: flex;
      align-items: center;
      padding: 0 1rem;
      justify-content: space-between;
      position: sticky;
      top: 0;
      z-index: 100;
      box-shadow: 0 2px 8px rgba(31,78,121,0.25);
    }

    .header-left {
      display: flex;
      align-items: center;
      gap: 1rem;
    }

    .logo {
      height: 44px;
      width: auto;
      border-radius: 3px;
      object-fit: contain;
      display: block;
    }

    .header-title {
      font-size: 18px;
      font-weight: 600;
    }

    .header-right {
      text-align: right;
      font-size: 11px;
      line-height: 1.4;
    }

    /* Header: auf schmalen Bildschirmen umbrechen lassen */
    @media screen and (max-width: 1024px) {
      .app-header {
        height: auto;
        min-height: 50px;
        flex-wrap: wrap;
        padding: 6px 10px;
      }
      .header-right {
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 4px;
      }
      .header-title {
        font-size: 15px;
      }
    }

    /* ===== Tabs ===== */
    .tabs {
      display: flex;
      background: white;
      border-bottom: 1px solid #ddd;
      padding: 0;
      gap: 0;
      flex-wrap: wrap;
    }

    .tab-button {
      padding: 12px 16px;
      background: transparent;
      border: none;
      cursor: pointer;
      font-size: 13px;
      color: #666;
      border-bottom: 3px solid transparent;
      transition: all 0.2s;
      font-weight: 500;
    }

    .tab-button:hover {
      color: #1F4E79;
    }

    .tab-button.active {
      color: #1F4E79;
      border-bottom-color: transparent;
    }

    /* Tabs auf Tablets: gleichmaessig verteilt */
    @media screen and (max-width: 1024px) {
      .tabs {
        justify-content: stretch;
      }
      .tab-button {
        flex: 1 1 auto;
        text-align: center;
        padding: 10px 6px;
        font-size: 11px;
      }
    }
    @media screen and (max-width: 600px) {
      .tab-button {
        padding: 8px 4px;
        font-size: 10px;
      }
    }

    /* ===== Tab Content ===== */
    .tab-content {
      display: none;
      padding: 1.2rem;
      background: white;
    }

    .tab-content.active {
      display: block;
    }

    /* ===== Overview Table ===== */
    #overviewContainer {
      padding: 0;              /* kein Padding — verhindert Durchlauf-Artefakte an Rändern */
      overflow: auto;          /* beide Achsen scrollbar */
      max-height: calc(100vh - 180px); /* Sticky braucht begrenzten Container */
      background: white;
      border: 1px solid #ccc;
      border-radius: 4px;
    }

    #overviewTable {
      table-layout: auto;
      width: 100%;
      border-collapse: collapse;
      font-size: 11px;
    }

    #overviewTable th, #overviewTable td {
      border: 1px solid #ccc;
      text-align: center;
      overflow: hidden;
      white-space: nowrap;
      padding: 0;
    }

    /* Erste Spalte (Lehrernamen) — sticky beim horizontalen Scrollen */
    #overviewTable th:first-child, #overviewTable td:first-child {
      position: sticky;
      left: 0;
      z-index: 3;
      min-width: 200px;
      max-width: 260px;
      font-weight: 700;
      background: #f0f4f8;
      font-size: 13px;
      color: #1F4E79;
      text-align: left;
      padding: 4px 8px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      letter-spacing: 0.01em;
      /* Trennschatten nach rechts — sichert Ablesbarkeit beim horizontalen Scrollen */
      box-shadow: 2px 0 4px rgba(0,0,0,0.08);
      clip-path: inset(0 -6px 0 0); /* sichtbarer Schatten nur nach rechts */
    }

    /* Kopfzeile (Zeitslots) — sticky beim vertikalen Scrollen */
    #overviewTable thead th {
      position: sticky;
      top: 0;
      z-index: 4;
      background: #1F4E79;
      color: white;
      height: 36px;
      font-size: 12px;
      font-weight: 600;
      padding: 4px 3px;
      letter-spacing: 0.3px;
      /* Trennschatten nach unten — sichert Ablesbarkeit beim vertikalen Scrollen */
      box-shadow: 0 2px 4px rgba(0,0,0,0.15);
      clip-path: inset(0 0 -6px 0); /* sichtbarer Schatten nur nach unten */
    }

    /* Ecke oben-links: Lehrkraft-Header — über allem */
    #overviewTable thead th:first-child {
      z-index: 5;
      background: #162f4a;
      /* Schatten nach unten UND rechts */
      box-shadow: 2px 2px 4px rgba(0,0,0,0.18);
      clip-path: inset(0 -6px -6px 0);
    }

    #overviewTable thead th.pause-col {
      background: #5a6268;
      width: 12px;
      min-width: 12px;
      max-width: 12px;
      font-size: 0;
    }

    #overviewTable tbody td {
      height: 36px;
      cursor: pointer;
      font-size: 12px;
      line-height: 1.3;
      min-width: 40px;
      padding: 3px 4px;
    }

    #overviewTable tbody td.pause-col {
      background: #c8ccd0;
      cursor: default;
      min-width: 12px;
      max-width: 12px;
    }

    .cell-free { background: var(--clr-success-light); color: var(--clr-success-dark); font-weight: 500; }
    .cell-free:hover { background: var(--clr-success-hover); }
    .cell-booked { background: var(--clr-warning-light); color: var(--clr-warning-text); font-weight: 600; }
    .cell-booked:hover { background: var(--clr-warning-hover); }
    .building-separator td { cursor: default !important; border: none !important; }
    .building-separator:hover td { background: inherit !important; }
    .building-separator td[colspan] { background: linear-gradient(90deg, var(--bld-color, #6c757d) 0%, rgba(255,255,255,0) 100%) !important; }
    .cell-conflict { background: var(--clr-danger-light); color: var(--clr-danger-dark); font-weight: 700; }
    .cell-conflict:hover { background: var(--clr-danger-hover); }
    .cell-conflict[draggable="true"] { cursor: grab; }
    /* 2 Elternteile: gültige Parallelbuchung — blau statt rot */
    .cell-zwei-eltern { background: #dbeafe !important; color: #1d4ed8 !important; }
    .cell-zwei-eltern:hover { background: #bfdbfe !important; }
    .cell-blocked { background: var(--clr-gray-light); color: #777; font-weight: 400; cursor: not-allowed; }
    .cell-blocked:hover { background: var(--clr-gray-border); }
    .cell-pause { background: var(--clr-gray-border); color: var(--clr-gray-dark); font-weight: 600; font-size: 11px; }

    /* Drag & Drop */
    .cell-booked[draggable="true"] { cursor: grab; }
    .cell-booked[draggable="true"]:active { cursor: grabbing; }
    .drag-source { opacity: 0.4 !important; outline: 2px dashed #856404; }
    .drag-over { background: #c8e6c9 !important; outline: 2px solid #2e7d32; outline-offset: -2px; }
    /* Drag: erlaubte Zellen = gruen */
    .drag-allowed { background: var(--clr-success-drag) !important; outline: 1px dashed var(--clr-success); cursor: copy !important; }
    /* Drag: Zeitkonflikt = rot gestreift */
    .drag-blocked-time { background: repeating-linear-gradient(45deg, var(--clr-danger-hover), var(--clr-danger-hover) 4px, var(--clr-danger-light) 4px, var(--clr-danger-light) 8px) !important; cursor: not-allowed !important; }
    /* Drag: Wegezeit-Sperre = lila gestreift */
    .drag-blocked-weg { background: repeating-linear-gradient(45deg, var(--clr-travel-pale), var(--clr-travel-pale) 4px, var(--clr-travel-light) 4px, var(--clr-travel-light) 8px) !important; cursor: not-allowed !important; }
    /* Drag: belegte/gesperrte Zellen bleiben rot */
    .drag-active .cell-free:not(.drag-allowed):not(.drag-blocked-time):not(.drag-blocked-weg) { background: #e8f5e9 !important; }
    .drag-active .cell-booked:not(.drag-source), .drag-active .cell-conflict:not(.drag-source) { background: var(--clr-danger-hover) !important; cursor: not-allowed; }
    .drag-active .cell-blocked { background: #ffcdd2 !important; }

    /* Crosshair highlight */
    #overviewTable tbody tr.row-highlight td:first-child {
      background: #b8daff !important;
      font-weight: 700;
    }
    #overviewTable tbody tr.row-highlight td:not(:first-child):not(.pause-col) {
      box-shadow: inset 0 2px 0 #4a90d9, inset 0 -2px 0 #4a90d9;
    }
    #overviewTable td.col-highlight {
      box-shadow: inset 2px 0 0 #4a90d9, inset -2px 0 0 #4a90d9;
    }
    #overviewTable thead th.col-highlight {
      background: #3a7bd5 !important;
    }
    #overviewTable td.cell-active {
      outline: 3px solid #0d47a1 !important;
      outline-offset: -2px;
      z-index: 2;
      position: relative;
    }

    #overviewTooltip {
      display: none;
      position: fixed;
      background: rgba(31,78,121,0.95);
      color: white;
      padding: 6px 10px;
      border-radius: 4px;
      font-size: 12px;
      pointer-events: none;
      z-index: 1000;
      white-space: nowrap;
      box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    }

    #overviewStatus {
      margin-top: 0.5rem;
      padding: 0.5rem;
      font-size: 12px;
      color: #666;
      background: #f9f9f9;
      border: 1px solid #ddd;
    }

    /* ===== Buttons ===== */
    .btn {
      padding: 10px 16px;
      background: #1F4E79;
      color: white;
      border: none;
      border-radius: 6px;
      cursor: pointer;
      font-size: 13px;
      font-weight: 500;
      min-height: 44px;
      border-radius: 8px;
      transition: all 0.2s;
    }
    .btn:hover { background: #0d2540; }
    .btn-danger { background: #dc3545; }
    .btn-danger:hover { background: #c82333; }
    .btn-secondary { background: #6c757d; }
    .btn-secondary:hover { background: #5a6268; }
    .btn-success { background: #28a745; }
    .btn-success:hover { background: #218838; }
    .btn-sm { padding: 6px 12px; font-size: 12px; min-height: 40px; border-radius: 6px; }

    .btn-group {
      display: flex;
      gap: 0.5rem;
      margin-top: 0.5rem;
      flex-wrap: wrap;
    }

    /* ===== Forms & Inputs ===== */
    .form-section { margin-bottom: 1.5rem; }

    /* Accordion-Gruppen für Einstellungen */
    .settings-group {
      border: 1px solid #dee2e6;
      border-radius: 8px;
      margin-bottom: 1rem;
      background: #fafbfc;
    }
    .settings-group[open] {
      background: white;
    }
    .settings-group-title {
      padding: 12px 16px;
      font-size: 15px;
      font-weight: 700;
      color: #1F4E79;
      cursor: pointer;
      list-style: none;
      display: flex;
      align-items: center;
      gap: 8px;
      user-select: none;
    }
    .settings-group-title::-webkit-details-marker { display: none; }
    .settings-group-title::before {
      content: '▶';
      font-size: 11px;
      transition: transform 0.2s;
      color: #6c757d;
    }
    .settings-group[open] > .settings-group-title::before {
      transform: rotate(90deg);
    }
    .settings-group > .form-section {
      padding: 0 16px;
    }
    .settings-group > .form-section:last-of-type {
      padding-bottom: 16px;
    }

    .form-section-title {
      font-size: 14px;
      font-weight: 600;
      color: #1F4E79;
      margin-bottom: 0.5rem;
      border-bottom: 2px solid #1F4E79;
      padding-bottom: 0.3rem;
    }

    .form-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
      gap: 1rem;
      margin-bottom: 1rem;
    }

    .form-group {
      display: flex;
      flex-direction: column;
    }

    .form-group label {
      font-weight: 500;
      margin-bottom: 0.3rem;
      font-size: 12px;
      color: #555;
    }

    input[type="text"],
    input[type="time"],
    input[type="date"],
    input[type="number"],
    input[type="password"],
    input[type="datetime-local"],
    select,
    textarea {
      padding: 8px 10px;
      border: 1px solid #ccc;
      border-radius: 6px;
      font-size: 14px;
      font-family: inherit;
      min-height: 44px;
      border-radius: 8px;
    }

    input:focus, select:focus, textarea:focus {
      outline: none;
      border-color: var(--clr-primary);
      box-shadow: 0 0 0 3px rgba(31,78,121,0.2);
    }
    .btn:focus, .btn-sm:focus, button:focus, .tab-button:focus, a:focus {
      outline: 2px solid var(--clr-primary);
      outline-offset: 2px;
    }
    .btn:focus:not(:focus-visible), button:focus:not(:focus-visible) { outline: none; }

    textarea { resize: vertical; min-height: 60px; }

    /* ===== Autocomplete ===== */
    .autocomplete-container {
      position: relative;
      display: inline-block;
      width: 100%;
    }

    .autocomplete-input { width: 100%; }

    .autocomplete-dropdown {
      position: absolute;
      top: 100%;
      left: 0;
      right: 0;
      background: white;
      border: 1px solid #ccc;
      border-top: none;
      max-height: 200px;
      overflow-y: auto;
      z-index: 1000;
      display: none;
      box-shadow: 0 4px 12px rgba(0,0,0,0.15);
      border-radius: 0 0 6px 6px;
    }

    .autocomplete-dropdown.active { display: block; }

    .autocomplete-item {
      padding: 6px 8px;
      cursor: pointer;
      font-size: 12px;
      border-bottom: 1px solid #f0f0f0;
    }

    .autocomplete-item:hover,
    .autocomplete-item.selected {
      background: #e3f2fd;
    }

    .autocomplete-highlight {
      font-weight: 600;
      color: #1F4E79;
    }

    /* ===== Modal ===== */
    .modal {
      display: none;
      position: fixed;
      z-index: 2000;
      left: 0; top: 0;
      width: 100%; height: 100%;
      background: rgba(0,0,0,0.5);
      align-items: center;
      justify-content: center;
    }
    .modal.active { display: flex; }

    .modal-content {
      background: white;
      padding: 1.5rem;
      border-radius: 10px;
      max-width: 540px;
      width: 94%;
      box-shadow: 0 8px 30px rgba(0,0,0,0.25);
      max-height: 90vh;
      overflow-y: auto;
    }

    .modal-header {
      font-size: 16px;
      font-weight: 600;
      margin-bottom: 1rem;
      color: #1F4E79;
    }

    .modal-body { margin-bottom: 1rem; }

    .modal-footer {
      display: flex;
      gap: 6px;
      justify-content: flex-end;
      flex-wrap: wrap;
      margin-top: 1rem;
      padding-top: 0.75rem;
      border-top: 1px solid #eee;
    }
    .modal-footer .btn {
      font-size: 13px;
      padding: 8px 12px;
      min-height: 38px;
    }

    /* ===== Password Modal ===== */
    #passwordModal {
      background: #f0f4f8;
      top: 62px; height: calc(100% - 62px);
    }
    #passwordModal .modal-content {
      text-align: center;
      border-radius: 14px;
      box-shadow: 0 4px 24px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
      max-width: 440px;
    }

    #passwordLogo {
      height: 50px;
      width: auto;
      margin: 0 auto 1rem;
      display: block;
      object-fit: contain;
    }

    #passwordModal .modal-header { text-align: center; margin-bottom: 1.5rem; font-size: 1.1rem; }

    /* ===== Lists ===== */
    .data-list {
      max-height: 400px;
      overflow-y: auto;
      border: 1px solid #ddd;
      border-radius: 3px;
    }

    .list-item {
      display: flex;
      align-items: center;
      padding: 0.5rem;
      border-bottom: 1px solid #eee;
      gap: 0.5rem;
    }
    .list-item:last-child { border-bottom: none; }
    .list-item input, .list-item select { flex: 1; padding: 4px 6px; font-size: 12px; }
    .list-item button { padding: 4px 8px; font-size: 11px; }

    /* ===== Building Management ===== */
    .building-card {
      border: 1px solid #ddd;
      border-radius: 3px;
      margin-bottom: 0.5rem;
      padding: 0.75rem;
      background: #f9f9f9;
    }

    .building-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 0.5rem;
      font-weight: 600;
      color: #1F4E79;
    }

    .room-tags {
      display: flex;
      flex-wrap: wrap;
      gap: 0.3rem;
    }

    .room-tag {
      display: inline-flex;
      align-items: center;
      gap: 0.3rem;
      padding: 2px 8px;
      background: #e3f2fd;
      border: 1px solid #90caf9;
      border-radius: 12px;
      font-size: 11px;
    }

    .room-tag .remove-room {
      cursor: pointer;
      color: #dc3545;
      font-weight: bold;
      font-size: 14px;
      line-height: 1;
    }

    /* ===== Teacher Sheet ===== */
    .teacher-sheet { max-width: 900px; }
    .teacher-sheet table tbody tr:hover { background: #e3f2fd; }
    .teacher-sheet table tbody tr { transition: background 0.15s; }

    .teacher-info {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 1rem;
      margin-bottom: 1.5rem;
      padding: 1rem;
      background: #f9f9f9;
      border: 1px solid #ddd;
      border-radius: 3px;
    }

    .info-block { display: flex; flex-direction: column; }
    .info-label { font-weight: 600; font-size: 11px; color: #666; margin-bottom: 0.3rem; text-transform: uppercase; }
    .info-value { font-size: 14px; color: #333; }

    /* ===== Stats & Load Bars ===== */
    .stat-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
      gap: 1rem;
      margin-bottom: 1.5rem;
    }

    .stat-card {
      padding: 1rem;
      background: white;
      border: 1px solid #ddd;
      border-radius: 3px;
      text-align: center;
    }

    .stat-label { font-size: 11px; color: #666; text-transform: uppercase; margin-bottom: 0.5rem; font-weight: 600; }
    .stat-value { font-size: 24px; font-weight: 600; color: #1F4E79; }

    .teacher-load {
      display: flex;
      align-items: center;
      padding: 0.5rem;
      gap: 1rem;
      border-bottom: 1px solid #eee;
    }
    .teacher-load:last-child { border-bottom: none; }
    .teacher-load-name { flex: 0 0 180px; font-size: 12px; font-weight: 500; }

    .load-bar { flex: 1; height: 20px; background: #eee; border-radius: 3px; overflow: hidden; position: relative; }

    .load-bar-fill {
      height: 100%;
      background: #28a745;
      transition: all 0.3s;
      display: flex;
      align-items: center;
      justify-content: flex-end;
      padding-right: 4px;
      color: white;
      font-size: 10px;
      font-weight: 600;
    }
    .load-bar-fill.yellow { background: #ffc107; color: #333; }
    .load-bar-fill.red { background: #dc3545; }

    /* ===== Conflict Warning ===== */
    .conflict-warning {
      background: #f8d7da;
      border: 1px solid #f5c6cb;
      color: #721c24;
      padding: 0.75rem;
      border-radius: 3px;
      margin-top: 0.5rem;
      font-size: 12px;
    }

    /* ===== Read-Only Teacher View ===== */
    .readonly-view {
      max-width: 800px;
      margin: 2rem auto;
      padding: 1rem;
    }

    .readonly-header {
      display: flex;
      align-items: flex-start;
      gap: 1.5rem;
      margin-bottom: 1.5rem;
      border-bottom: 2px solid #1F4E79;
      padding-bottom: 1rem;
    }

    .readonly-logo {
      height: 60px; width: auto;
      border-radius: 5px;
      object-fit: contain;
      filter: brightness(0) invert(1);
      display: block;
      flex-shrink: 0;
    }

    /* Readonly-View responsive: Tablet-Portrait */
    @media screen and (max-width: 820px) {
      .readonly-view {
        margin: 0.5rem auto;
        padding: 0.5rem;
        max-width: 100%;
      }
      .readonly-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 0.75rem;
      }
      .readonly-logo {
        height: 48px;
      }
    }

    /* ===== Sync-Badge ===== */
    .sync-badge {
      font-size: 10px;
      margin-left: 6px;
      color: rgba(255,255,255,0.4);
      transition: color 0.3s;
      cursor: help;
    }
    .sync-badge.online { color: #4caf50; }
    .sync-badge.saved { color: #4caf50; animation: syncPulse 0.5s; }
    .sync-badge.loaded { color: #2196f3; animation: syncPulse 0.5s; }
    .sync-badge.error { color: #f44336; }
    @keyframes syncPulse { 0%{transform:scale(1)} 50%{transform:scale(1.5)} 100%{transform:scale(1)} }

    /* ===== Timer ===== */
    .timer-warning { color: #dc3545 !important; animation: timerBlink 0.5s ease-in-out infinite; }
    @keyframes timerBlink { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
    .timer-done { background: #dc3545 !important; border-color: #dc3545 !important; }
    .timer-done #roTimerDisplay { color: white !important; }
    .timer-done div { color: white !important; }

    /* ===== Map Markers ===== */
    .map-container {
      position: relative;
      display: inline-block;
      margin-top: 0.5rem;
      max-width: 700px;
      width: 100%;
    }

    .map-container img { width: 100%; display: block; border: 1px solid #ddd; border-radius: 3px; }

    .map-marker {
      position: absolute;
      width: 12px; height: 12px;
      background: #dc3545 !important;
      border: 2px solid #fff;
      border-radius: 50%;
      transform: translate(-50%, -50%);
      box-shadow: 0 1px 3px rgba(0,0,0,0.5);
      z-index: 10;
      animation: pulse 1.5s ease-in-out infinite;
      -webkit-print-color-adjust: exact;
      print-color-adjust: exact;
      color-adjust: exact;
    }

    .map-marker-label {
      position: absolute;
      transform: translate(2px, -50%);
      background: rgba(220,53,69,0.9) !important;
      color: white !important;
      font-size: 8px;
      font-weight: 600;
      padding: 1px 4px;
      border-radius: 2px;
      white-space: nowrap;
      z-index: 11;
      margin-left: 6px;
      -webkit-print-color-adjust: exact;
      print-color-adjust: exact;
      color-adjust: exact;
    }

    @keyframes pulse {
      0%, 100% { box-shadow: 0 0 0 0 rgba(220,53,69,0.5); }
      50% { box-shadow: 0 0 0 6px rgba(220,53,69,0); }
    }

    /* ===== Scharfschaltung / Live-Modus ===== */
    .header-live-btn {
      border: 2px solid rgba(255,255,255,0.5); border-radius: 8px; padding: 5px 14px;
      font-size: 12px; font-weight: 700; cursor: pointer;
      letter-spacing: 0.5px; transition: all 0.3s;
    }
    .header-live-btn.draft {
      background: rgba(108,117,125,0.8); color: white;
    }
    .header-live-btn.draft:hover {
      background: rgba(40,167,69,0.8);
      border-color: rgba(40,167,69,0.9);
    }
    .header-live-btn.live {
      background: #dc3545; color: white;
      border-color: #fff;
      animation: livePulse 1.5s ease-in-out infinite;
    }
    @keyframes livePulse {
      0%, 100% { box-shadow: 0 0 0 0 rgba(220,53,69,0.6); }
      50% { box-shadow: 0 0 0 6px rgba(220,53,69,0); }
    }

    .live-badge {
      display: inline-block;
      padding: 3px 10px;
      border-radius: 12px;
      font-size: 11px;
      font-weight: 600;
    }

    .live-badge-active { background: #dc3545; color: white; }
    .live-badge-draft { background: #6c757d; color: white; }

    .change-log-item {
      padding: 0.5rem;
      border-bottom: 1px solid #eee;
      font-size: 12px;
      display: flex;
      gap: 0.5rem;
      align-items: flex-start;
    }

    .change-time { color: #999; flex-shrink: 0; font-size: 11px; }

    /* ===== Tooltip-System (JS-basiert, bildschirmrandgerecht) ===== */
    /* Kein CSS ::after / ::before mehr — Position wird per JS berechnet */
    .tooltip-toggle-active { background: rgba(255,200,0,0.5) !important; border-color: rgba(255,200,0,0.7) !important; }

    #smartTooltipDiv {
      position: fixed;
      background: #333;
      color: #fff;
      padding: 6px 11px;
      border-radius: 4px;
      font-size: 11px;
      max-width: 300px;
      white-space: normal;
      line-height: 1.45;
      text-align: center;
      z-index: 9999;
      pointer-events: none;
      opacity: 0;
      transition: opacity 0.15s;
      box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    }
    #smartTooltipDiv.tt-visible { opacity: 1; }
    #smartTooltipDiv::after {
      content: '';
      position: absolute;
      border: 5px solid transparent;
    }
    /* Pfeil nach unten (Tooltip oberhalb des Elements) */
    #smartTooltipDiv.tt-above::after {
      top: 100%; left: 50%; transform: translateX(-50%);
      border-top-color: #333; border-bottom: none;
    }
    /* Pfeil nach oben (Tooltip unterhalb des Elements) */
    #smartTooltipDiv.tt-below::after {
      bottom: 100%; left: 50%; transform: translateX(-50%);
      border-bottom-color: #333; border-top: none;
    }

    /* ===== Print Header (Screen + Print) ===== */
    .print-header {
      display: flex;
      align-items: flex-start;
      gap: 1.5rem;
      margin-bottom: 1.5rem;
      border-bottom: 2px solid #1F4E79;
      padding-bottom: 1rem;
    }

    .print-logo {
      height: 70px; width: auto;
      max-width: 200px;
      border-radius: 3px;
      flex-shrink: 0;
      object-fit: contain;
    }

    .print-header-text h1 { font-size: 20px; color: #1F4E79; margin-bottom: 0.3rem; }
    .print-header-text p { font-size: 12px; color: #555; margin: 0.2rem 0; line-height: 1.5; }
    .print-header-text strong { color: #1F4E79; }

    /* ===== Animationen & Uebergaenge ===== */

    /* Sanftes Einblenden beim Seitenladen */
    @keyframes fadeInUp {
      from { opacity: 0; transform: translateY(12px); }
      to { opacity: 1; transform: translateY(0); }
    }

    /* Tab-Content sanft einblenden */
    .tab-content.active {
      animation: fadeInUp 0.25s ease-out;
    }

    /* Cards und Sektionen sanft einblenden */
    .form-section {
      transition: box-shadow 0.2s, transform 0.15s;
    }
    .form-section:hover {
      box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    }

    /* Stat-Cards im Dashboard */
    .stat-card {
      transition: transform 0.15s ease, box-shadow 0.2s;
    }
    .stat-card:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    }

    /* Buttons: sanfter Hover-Lift */
    .btn {
      transition: all 0.2s ease;
    }
    .btn:hover {
      transform: translateY(-1px);
      box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    }
    .btn:active {
      transform: translateY(0);
      box-shadow: none;
    }

    /* Collapsible-Body sanft oeffnen */
    .collapsible-body {
      animation: fadeInUp 0.2s ease-out;
    }

    /* Tab-Button Unterstrich-Animation */
    .tab-button {
      position: relative;
    }
    .tab-button::after {
      content: '';
      position: absolute;
      bottom: 0;
      left: 50%;
      width: 0;
      height: 3px;
      background: var(--clr-primary);
      transition: width 0.25s ease, left 0.25s ease;
      border-radius: 2px 2px 0 0;
    }
    .tab-button.active::after {
      width: 100%;
      left: 0;
    }
    .tab-button:hover::after {
      width: 60%;
      left: 20%;
    }

    /* Gebäude-Trennzeilen: sanft einblenden */
    .building-separator td {
      animation: fadeInUp 0.3s ease-out;
    }

    /* Booking-Modal sanft einblenden */
    .modal.active {
      animation: fadeInUp 0.2s ease-out;
    }

    /* Toast von unten einfliegen */
    @keyframes slideInUp {
      from { transform: translateY(20px); opacity: 0; }
      to { transform: translateY(0); opacity: 1; }
    }
    .toast {
      animation: slideInUp 0.3s ease-out;
    }

    /* Settings-Groups sanft oeffnen */
    .settings-group[open] > :not(summary) {
      animation: fadeInUp 0.2s ease-out;
    }

    /* Login-Modal Hintergrund sanft einblenden */
    #passwordModal {
      animation: fadeIn 0.3s ease-out;
    }
    @keyframes fadeIn {
      from { opacity: 0; }
      to { opacity: 1; }
    }

    /* Workflow-Schritte auf Dashboard: gestaffelt einblenden */
    #dashboardContent > div {
      animation: fadeInUp 0.3s ease-out both;
    }

    /* reduced-motion respektieren */
    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
      }
    }

    /* ===== Collapsible Sektionen ===== */
    .collapsible-section { margin-top: 1rem; }
    .collapsible-header {
      cursor: pointer; display: flex; align-items: center; gap: 10px;
      padding: 14px 16px; background: #f0f4f8; border-radius: 8px;
      font-weight: 700; font-size: 15px; color: #1F4E79;
      border: 1px solid #dee2e6; user-select: none;
      transition: background 0.15s;
    }
    .collapsible-header:hover { background: #e3ecf4; }
    .collapsible-header .arrow { transition: transform 0.2s; font-size: 12px; }
    .collapsible-section.collapsed .arrow { transform: rotate(-90deg); }
    .collapsible-body { padding: 16px 4px; }
    .collapsible-section.collapsed .collapsible-body { display: none; }

    /* ═══════════════════════════════════════════════════════════════════
       Druck-Overlay (Screen): Vollbild-Vorschau, was gedruckt wird.
       ═══════════════════════════════════════════════════════════════════ */
    .print-overlay {
      position: fixed; inset: 0;
      background: #e8eaed;
      z-index: 9999;
      overflow-y: auto;
      padding-bottom: 2rem;
    }
    .print-overlay-bar {
      position: sticky; top: 0;
      background: #0f2248;
      color: #fff;
      padding: 10px 16px;
      display: flex;
      gap: 10px;
      align-items: center;
      box-shadow: 0 2px 8px rgba(0,0,0,0.2);
      z-index: 10;
    }
    .print-overlay-bar .btn { min-height: 36px; }
    .print-overlay-content {
      max-width: 210mm;
      margin: 1rem auto;
    }
    body.print-overlay-active { overflow: hidden; }

    /* ═══════════════════════════════════════════════════════════════════
       Sheet-Layout (Screen): jedes A4-Blatt als Karte mit Schatten.
       Gleicher HTML-Code wird beim Drucken per @media print in echtes A4
       uebersetzt (2-Seiten-Layout pro Schüler/Lehrer für Duplex).
       ═══════════════════════════════════════════════════════════════════ */
    .sheet {
      background: #fff;
      width: 210mm;
      min-height: 297mm;
      margin: 0 auto 12mm;
      padding: 15mm 20mm 28mm 20mm;
      box-sizing: border-box;
      box-shadow: 0 2px 12px rgba(0,0,0,0.12);
      position: relative;
      font-family: 'Source Sans Pro', Arial, sans-serif;
      color: #222;
      font-size: 11pt;
      line-height: 1.35;
    }
    .sheet-header {
      text-align: center;
      border-bottom: 1.5pt solid #0f2248;
      padding-bottom: 6mm;
      margin-bottom: 6mm;
    }
    .sheet-topline {
      text-transform: uppercase;
      letter-spacing: 2px;
      font-size: 9pt;
      color: #7B7B7B;
      margin-bottom: 4mm;
    }
    .sheet-logo {
      width: 50mm;
      height: auto;
      max-height: 25mm;
      margin: 0 auto 4mm;
      display: block;
    }
    .sheet-title {
      font-size: 20pt;
      color: #0f2248;
      font-weight: 700;
      margin: 0 0 2mm;
      line-height: 1.15;
    }
    .sheet-subline {
      font-size: 11pt;
      color: #555;
    }
    .sheet-info-bar {
      background: #e8ecf4;
      color: #0f2248;
      font-weight: 600;
      font-size: 10pt;
      padding: 3mm 5mm;
      border-radius: 2mm;
      margin-bottom: 5mm;
      text-align: center;
    }
    .sheet-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 10.5pt;
      margin-bottom: 6mm;
    }
    .sheet-table thead tr {
      background: #0f2248;
      color: #fff;
    }
    .sheet-table th {
      padding: 2.5mm 3mm;
      text-align: left;
      font-weight: 600;
      font-size: 10pt;
      border: 0.5pt solid #0f2248;
    }
    .sheet-table td {
      padding: 2mm 3mm;
      border: 0.3pt solid #cfd8e0;
      vertical-align: top;
    }
    .sheet-table tbody tr:nth-child(even) { background: #f6f8fc; }
    .sheet-table .cell-time { font-weight: 600; white-space: nowrap; }
    .sheet-table .cell-location { font-size: 9.5pt; color: #333; }
    .sheet-table .cell-notes { font-size: 9.5pt; color: #444; }
    .sheet-table .klasse { color: #7B7B7B; font-size: 9pt; }
    .sheet-table .partner { color: #1d4ed8; font-size: 9.5pt; }
    .sheet-table .row-free { color: #adb5bd; }
    .sheet-table .row-blocked { background: #f1f3f5; color: #868e96; font-style: italic; }
    .sheet-table .row-booked { background: #fff; }
    .sheet-table .row-pause td {
      background: #dee2e6;
      text-align: center;
      font-weight: 600;
      color: #495057;
      font-size: 9.5pt;
      padding: 1.5mm;
    }
    .sheet-table .row-gap td {
      background: #f0f4f8;
      text-align: center;
      color: #6c757d;
      font-size: 9pt;
      font-style: italic;
      padding: 1.2mm;
    }
    .sheet-table .hinweis-far { color: #c62828; font-weight: 600; font-size: 9.5pt; }
    .sheet-table .hinweis-near { color: #856404; font-size: 9.5pt; }
    .sheet-turn-hint {
      margin-top: 4mm;
      padding: 3mm 5mm;
      background: #fff8e1;
      border: 1pt dashed #f0b400;
      border-radius: 2mm;
      text-align: center;
      font-weight: 700;
      color: #8a5a00;
      font-size: 11pt;
    }
    .sheet-turn-hint::before { content: '↪ '; font-size: 13pt; }
    .sheet-footer {
      position: absolute;
      left: 20mm;
      right: 20mm;
      bottom: 8mm;
      display: flex;
      gap: 4mm;
      align-items: flex-end;
      border-top: 0.5pt solid #c7cdd4;
      padding-top: 2.5mm;
    }
    .sheet-footer-address {
      flex: 1;
      font-size: 7.5pt;
      color: #7B7B7B;
      line-height: 1.4;
    }
    .sheet-footer-page {
      font-size: 7.5pt;
      color: #7B7B7B;
      white-space: nowrap;
    }
    /* Rückseite: Lageplan */
    .sheet-back .sheet-map-wrap { margin-top: 2mm; }
    .sheet-blank-duplex {
      display: flex !important;
      align-items: center;
      justify-content: center;
      color: #ccc;
      font-size: 13pt;
      font-style: italic;
      letter-spacing: 1px;
    }
    .sheet-blank-duplex::after { content: 'Leerseite — Duplex-Ausgleich'; }
    .sheet-map-legend {
      font-size: 10pt;
      color: #333;
      margin-bottom: 3mm;
      padding: 2mm 4mm;
      background: #fff4e5;
      border-left: 3pt solid #dc3545;
      border-radius: 2mm;
    }
    .sheet-map {
      width: 100%;
      background: #f4f6f8;
      border-radius: 2mm;
      overflow: hidden;
    }
    /* Inner-Wrapper wächst exakt auf Bildgröße — Marker relativ zum Bild */
    .sheet-map-inner {
      position: relative;
      width: 100%;
      display: block;
      line-height: 0;
    }
    .sheet-map img {
      width: 100%;
      display: block;
      height: auto;
    }
    .sheet-map-marker {
      position: absolute;
      width: 12px;
      height: 12px;
      background: #dc3545;
      border: 2px solid #fff;
      border-radius: 50%;
      transform: translate(-50%, -50%);
      box-shadow: 0 0 0 1px #dc3545;
    }
    .sheet-map-label {
      position: absolute;
      transform: translate(-50%, 8px);
      background: rgba(220, 53, 69, 0.92);
      color: #fff;
      padding: 1px 5px;
      border-radius: 2px;
      font-size: 8pt;
      font-weight: 600;
      white-space: nowrap;
    }

    /* ═══════════════════════════════════════════════════════════════════
       Print Styles — robustes A4-Layout ohne feste Hoehe, ohne absolute
       Positionierung. Browser verwaltet Seitenumbrueche natuerlich.
       ═══════════════════════════════════════════════════════════════════ */
    @media print {
      @page {
        size: A4 portrait;
        margin: 0;
      }
      html, body {
        background: #fff !important;
        margin: 0 !important; padding: 0 !important;
        font-family: 'Source Sans Pro', Arial, sans-serif;
      }

      /* Touch-Mode Overrides */
      body.touch-mode .btn, body.touch-mode button, body.touch-mode input,
      body.touch-mode select, body.touch-mode textarea, body.touch-mode .tab-button {
        min-height: auto !important; min-width: auto !important;
        font-size: inherit !important; padding: inherit !important;
      }

      .print-only { display: inline !important; }
      .no-print, .print-overlay-bar { display: none !important; }

      /* ─── Overlay-Modus: ALLES im Body ausblenden ausser Overlay ─── */
      body.print-overlay-active > * {
        display: none !important;
      }
      body.print-overlay-active > #printOverlay {
        display: block !important;
        position: static !important;
        background: #fff !important;
        overflow: visible !important;
        padding: 0 !important;
        margin: 0 !important;
        max-width: none !important;
      }
      body.print-overlay-active .print-overlay-content {
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
      }

      /* ─── Direkter Druck (ohne Overlay): bestehende Ansicht drucken ─── */
      body:not(.print-overlay-active) .app-header,
      body:not(.print-overlay-active) .tabs,
      body:not(.print-overlay-active) .tab-content:not(.active),
      body:not(.print-overlay-active) .print-overlay {
        display: none !important;
      }
      body:not(.print-overlay-active) .tab-content.active {
        display: block !important;
        padding: 0 !important;
      }

      /* ─── Sheet = eine Druckseite, Ränder im Sheet (Browser-Seitenzahl via @page margin:0 unterdrückt) ─── */
      .sheet {
        width: 210mm !important;
        max-width: 210mm !important;
        min-height: 297mm !important;
        max-height: 297mm !important;
        height: 297mm !important;
        margin: 0 !important;
        padding: 15mm 18mm 18mm 18mm !important;
        box-shadow: none !important;
        overflow: hidden !important;
        page-break-after: always !important;
        break-after: page !important;
        page-break-inside: avoid !important;
        break-inside: avoid-page !important;
        position: relative !important;
        box-sizing: border-box !important;
        background: #fff !important;
        display: flex !important;
        flex-direction: column !important;
      }
      .sheet:last-child {
        page-break-after: auto !important;
        break-after: auto !important;
      }

      /* ─── Logo im Druck hart begrenzen (!important gegen img-native-size) ─── */
      .sheet .sheet-logo,
      img.sheet-logo {
        width: 50mm !important;
        max-width: 50mm !important;
        max-height: 22mm !important;
        height: auto !important;
        display: block !important;
        margin: 0 auto 3mm !important;
      }

      /* ─── Kopf kompakt, zentriert ─── */
      .sheet-header {
        text-align: center !important;
        border-bottom: 1pt solid #0f2248 !important;
        padding-bottom: 4mm !important;
        margin-bottom: 5mm !important;
        flex-shrink: 0 !important;
      }
      .sheet-topline {
        font-size: 8pt !important;
        color: #7B7B7B !important;
        letter-spacing: 1.5pt !important;
        margin-bottom: 3mm !important;
        text-transform: uppercase !important;
      }
      .sheet-title {
        font-size: 16pt !important;
        color: #0f2248 !important;
        font-weight: 700 !important;
        margin: 0 0 1.5mm 0 !important;
        line-height: 1.15 !important;
      }
      .sheet-subline {
        font-size: 10pt !important;
        color: #555 !important;
      }

      /* ─── Info-Bar ─── */
      .sheet-info-bar {
        background: #e8ecf4 !important;
        color: #0f2248 !important;
        font-size: 9.5pt !important;
        padding: 2mm 4mm !important;
        border-radius: 1.5mm !important;
        margin-bottom: 4mm !important;
        text-align: center !important;
        font-weight: 600 !important;
        flex-shrink: 0 !important;
      }

      /* ─── Termintabelle kompakt für volle Kalender ─── */
      .sheet-table { font-size: 9.5pt !important; width: 100% !important; border-collapse: collapse !important; margin-bottom: 4mm !important; flex-shrink: 1 !important; overflow: hidden !important; }
      .sheet-table thead tr { background: #0f2248 !important; color: #fff !important; }
      .sheet-table th { padding: 1.5mm 2.5mm !important; font-size: 9pt !important; font-weight: 600 !important; text-align: left !important; border: 0.3pt solid #0f2248 !important; }
      .sheet-table td { padding: 1.2mm 2.5mm !important; border: 0.2pt solid #cfd8e0 !important; vertical-align: top !important; }
      .sheet-table tbody tr:nth-child(even) { background: #f6f8fc !important; }
      .sheet-table tr { page-break-inside: avoid !important; break-inside: avoid !important; }

      /* ─── Bitte-wenden-Hinweis ─── */
      .sheet-turn-hint {
        flex-shrink: 0 !important;
        margin-top: 3mm !important;
        padding: 2.5mm 4mm !important;
        background: #fff8e1 !important;
        border: 0.8pt dashed #f0b400 !important;
        border-radius: 1.5mm !important;
        text-align: center !important;
        font-weight: 700 !important;
        color: #8a5a00 !important;
        font-size: 10pt !important;
      }

      /* ─── Adress-Footer: ans Ende des Flex-Containers schieben ─── */
      .sheet-footer {
        position: static !important;
        display: flex !important;
        gap: 4mm !important;
        align-items: flex-end !important;
        border-top: 0.4pt solid #c7cdd4 !important;
        padding-top: 2mm !important;
        margin-top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        flex-shrink: 0 !important;
      }
      .sheet-footer-address {
        flex: 1 !important;
        font-size: 7pt !important;
        color: #7B7B7B !important;
        line-height: 1.35 !important;
      }
      .sheet-footer-page {
        font-size: 7pt !important;
        color: #7B7B7B !important;
        white-space: nowrap !important;
      }

      /* ─── Einzeldruck Schülerblatt: Termine fließen natürlich ─── */
      .esp-sched-page {
        padding: 15mm 18mm 10mm 18mm !important;
        box-sizing: border-box !important;
        background: #fff !important;
        display: flex !important;
        flex-direction: column !important;
      }
      /* ─── Duplex-Leerseite: blanke Seite 4 nach 3-seitigem Schüler ─── */
      .sheet-blank-duplex {
        visibility: hidden !important;
      }
      /* ─── Fortsetzungsseite: expliziter Seitenwechsel ─── */
      .esp-sched-page-break {
        page-break-before: always !important;
        break-before: page !important;
      }
      /* ─── Karte immer auf neuer Seite ─── */
      .esp-map-page {
        padding: 15mm 18mm 18mm 18mm !important;
        box-sizing: border-box !important;
        background: #fff !important;
        page-break-before: always !important;
        break-before: page !important;
        min-height: 297mm !important;
        display: flex !important;
        flex-direction: column !important;
      }

      /* ─── Lageplan auf der Rückseite ─── */
      .sheet-map-wrap { margin-top: 2mm !important; flex: 1 1 auto !important; display: flex !important; flex-direction: column !important; overflow: hidden !important; }
      .sheet-map {
        width: 100% !important;
        background: #f4f6f8 !important;
        border-radius: 1.5mm !important;
        overflow: hidden !important;
        page-break-inside: avoid !important;
      }
      /* Inner-Wrapper: passt sich exakt der Bildgröße an → Marker korrekt positioniert */
      .sheet-map-inner {
        position: relative !important;
        width: 100% !important;
        display: block !important;
        line-height: 0 !important;
      }
      .sheet-map img { width: 100% !important; display: block !important; height: auto !important; max-height: 160mm !important; }
      .sheet-map-marker,
      .sheet-map-label,
      .sheet-map-legend {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
      }

      /* ─── Farben im Druck erzwingen ─── */
      .sheet-table thead tr,
      .sheet-info-bar,
      .sheet-turn-hint,
      .sheet-footer,
      .sheet-header {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
      }

      /* ─── Legacy-Listen (teachers, students, notes) ─── */
      .print-logo { width: 3cm; height: auto; max-height: 3cm; }
      .print-header-text h1 { font-size: 22px; }
      .map-marker {
        background: #dc3545 !important;
        border-color: #fff !important;
        width: 10px !important; height: 10px !important;
        -webkit-print-color-adjust: exact !important;
        animation: none !important;
      }
      .map-marker-label {
        background: rgba(220,53,69,0.9) !important;
        color: #fff !important;
        font-size: 7px !important;
        -webkit-print-color-adjust: exact !important;
      }
      .map-container img { -webkit-print-color-adjust: exact !important; }
    }

    /* ===== Utility ===== */
    .sr-only {
      position: absolute; width: 1px; height: 1px;
      padding: 0; margin: -1px; overflow: hidden;
      clip: rect(0,0,0,0); white-space: nowrap; border-width: 0;
    }

    .toast {
      position: fixed;
      bottom: 2rem;
      right: 2rem;
      padding: 1rem 1.5rem;
      border-radius: 5px;
      color: white;
      font-size: 13px;
      z-index: 5000;
      box-shadow: 0 4px 12px rgba(0,0,0,0.3);
      transition: opacity 0.3s;
    }
    .toast-success { background: #28a745; }
    .toast-error { background: #dc3545; }
    .toast-warning { background: #ffc107; color: #333; }

    /* ===== Touch-/Tablet-Modus ===== */
    /* !important auf allen Eigenschaften, da Inline-Styles ueberschrieben werden muessen */

    /* --- Buttons & Interaktive Elemente --- */
    body.touch-mode .btn,
    body.touch-mode .btn-sm,
    body.touch-mode button,
    body.touch-mode .readonly-view button,
    body.touch-mode #roViewToggle button,
    body.touch-mode #readonlyView button {
      min-height: 44px !important;
      min-width: 44px !important;
      font-size: 14px !important;
      padding: 10px 18px !important;
      line-height: 1.3 !important;
    }

    /* --- Tab-Buttons: groesser, aber kompakt genug für 2 Zeilen --- */
    body.touch-mode .tab-button {
      min-height: 48px !important;
      font-size: 13px !important;
      padding: 8px 10px !important;
      flex: 1 1 auto !important;
      text-align: center !important;
    }

    /* --- Formularfelder --- */
    body.touch-mode select,
    body.touch-mode input[type="text"],
    body.touch-mode input[type="email"],
    body.touch-mode input[type="password"],
    body.touch-mode input[type="date"],
    body.touch-mode input[type="time"],
    body.touch-mode input[type="number"],
    body.touch-mode textarea,
    body.touch-mode .readonly-view textarea,
    body.touch-mode #roSchedule textarea {
      min-height: 44px !important;
      font-size: 16px !important;
      padding: 8px 12px !important;
    }

    /* --- Autocomplete --- */
    body.touch-mode .autocomplete-item {
      min-height: 44px !important;
      padding: 10px 12px !important;
      font-size: 14px !important;
    }

    /* --- Header: hoeher und mehrzeilig --- */
    body.touch-mode .app-header {
      height: auto !important;
      min-height: 50px !important;
      padding: 8px 12px !important;
      flex-wrap: wrap !important;
    }
    body.touch-mode .header-left {
      flex: 0 0 auto;
    }
    body.touch-mode .header-right {
      flex: 1 1 100% !important;
      display: flex !important;
      flex-wrap: wrap !important;
      justify-content: flex-end !important;
      align-items: center !important;
      gap: 6px !important;
      margin-top: 4px !important;
    }
    body.touch-mode .header-right .btn,
    body.touch-mode .header-right .btn-sm,
    body.touch-mode .header-right button {
      min-height: 38px !important;
      font-size: 12px !important;
      padding: 6px 12px !important;
      white-space: nowrap !important;
    }
    body.touch-mode #headerInfo {
      flex: 1 1 100% !important;
      text-align: center !important;
      font-size: 12px !important;
      order: -1 !important;
    }
    body.touch-mode .header-live-btn {
      padding: 8px 16px !important;
      font-size: 13px !important;
    }

    /* --- Tabellen: groessere Zellen --- */
    body.touch-mode td, body.touch-mode th {
      padding: 10px 10px !important;
      font-size: 13px !important;
    }
    body.touch-mode .readonly-view td,
    body.touch-mode .readonly-view th {
      padding: 12px 10px !important;
      font-size: 14px !important;
    }

    /* --- Modals: Touch-optimierte Buttons --- */
    body.touch-mode .modal-content button,
    body.touch-mode .modal button {
      min-height: 44px !important;
      font-size: 14px !important;
      padding: 10px 18px !important;
    }
    body.touch-mode .modal-content {
      max-width: 95vw !important;
      max-height: 90vh !important;
      margin: 1rem !important;
    }

    /* --- Readonly-View (Lehrer-Ansicht) --- */
    body.touch-mode .readonly-header {
      flex-direction: column !important;
      text-align: center !important;
      gap: 0.75rem !important;
    }
    body.touch-mode .readonly-header h1 {
      font-size: 22px !important;
    }
    body.touch-mode .readonly-header p {
      font-size: 15px !important;
    }
    body.touch-mode .readonly-view {
      padding: 0.75rem !important;
    }

    /* --- Übersichts-Tabelle: Touch-Zellen --- */
    body.touch-mode #overviewTable tbody td {
      min-width: 44px !important;
      height: 40px !important;
      line-height: 1.3 !important;
      font-size: 11px !important;
      padding: 2px 3px !important;
    }
    body.touch-mode #overviewTable td:first-child {
      min-width: 160px !important;
      padding: 4px 8px !important;
      font-size: 13px !important;
    }
    body.touch-mode #overviewTable thead th {
      height: 36px !important;
      font-size: 11px !important;
      padding: 3px 2px !important;
      font-weight: 600 !important;
    }

    /* --- Links und Text groesser --- */
    body.touch-mode a {
      font-size: 14px !important;
    }

    /* --- Stammdaten-Tabellen: bessere Touch-Ziele --- */
    body.touch-mode .data-list td {
      padding: 8px 10px !important;
    }
    body.touch-mode .data-list input,
    body.touch-mode .data-list select {
      min-height: 40px !important;
      font-size: 14px !important;
    }

    /* ===== Tablet-Portrait ≤ 1024px (allgemein) ===== */
    @media screen and (max-width: 1024px) {
      /* Tabs: 2 Zeilen à 4 Tabs, damit alle auf einmal sichtbar sind */
      .tabs {
        flex-wrap: wrap !important;
      }
      .tab-button {
        flex: 0 0 25% !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
      }

      body.touch-mode .tabs {
        gap: 0 !important;
      }
      body.touch-mode .tab-button {
        font-size: 11px !important;
        padding: 6px 4px !important;
        min-height: 44px !important;
        flex: 0 0 25% !important;
        text-align: center !important;
      }
      body.touch-mode .header-title {
        font-size: 15px !important;
      }
      body.touch-mode .logo {
        height: 26px !important;
      }
      body.touch-mode .form-grid {
        grid-template-columns: 1fr !important;
      }

      /* Modals scrollbar-fähig auf Tablets */
      .modal-content {
        max-height: 88vh;
        overflow-y: auto;
      }

      /* Teacher-Info: 2 statt 3 Spalten */
      .teacher-info {
        grid-template-columns: 1fr 1fr !important;
      }

      /* Stat-Grid: 2 Spalten */
      .stat-grid {
        grid-template-columns: repeat(2, 1fr) !important;
      }
    }

    /* ===== Tablet-Portrait ≤ 820px (iPad Portrait, Android Tablet Hochformat) ===== */
    @media screen and (max-width: 820px) {
      /* Header: Logo + Titel kompakter, Buttons kleiner */
      .app-header {
        padding: 5px 8px !important;
      }
      .header-title {
        font-size: 14px !important;
      }
      .logo {
        height: 26px !important;
      }
      /* Header-Right: Buttons umbrechen, Abmelden ans Ende */
      .header-right {
        gap: 4px !important;
      }
      /* Header-Buttons nur als Emoji + sehr kurzer Text */
      #headerInfo {
        display: none !important; /* Platz sparen, Info ist im Dashboard sichtbar */
      }

      body.touch-mode .app-header {
        padding: 5px 8px !important;
      }
      body.touch-mode .header-title {
        font-size: 13px !important;
      }
      body.touch-mode .tab-button {
        font-size: 10px !important;
        padding: 5px 2px !important;
        min-height: 40px !important;
      }
      body.touch-mode .tab-content {
        padding: 0.5rem !important;
      }
      body.touch-mode .readonly-view {
        margin: 0.25rem !important;
        padding: 0.5rem !important;
      }
      body.touch-mode .readonly-view td,
      body.touch-mode .readonly-view th {
        padding: 10px 6px !important;
        font-size: 13px !important;
      }
      body.touch-mode .modal-content {
        margin: 0.5rem !important;
        padding: 0.75rem !important;
      }

      /* Teacher-Info: 1 Spalte auf sehr schmalem Portrait */
      .teacher-info {
        grid-template-columns: 1fr !important;
      }

      /* Load-bar auf schmalem Portrait kleiner */
      .teacher-load-name {
        flex: 0 0 130px !important;
        font-size: 11px !important;
      }
    }

    /* ===== Tablet-Querformat ≥ 1025px ===== */
    @media screen and (min-width: 1025px) {
      /* Tabs: eine Zeile, alle nebeneinander */
      .tab-button {
        flex: 1 1 auto !important;
        white-space: nowrap !important;
      }

      body.touch-mode .tab-button {
        font-size: 13px !important;
        padding: 10px 12px !important;
      }
      /* Header-Right: bleibt in einer Zeile, kein Umbruch auf voller Breite */
      body.touch-mode .header-right {
        flex: 0 1 auto !important;
        flex-wrap: nowrap !important;
        margin-top: 0 !important;
      }
      body.touch-mode #headerInfo {
        flex: 0 1 auto !important;
        order: 0 !important;
        display: block !important;
      }
      /* Teacher-Info: 3 Spalten im Querformat */
      .teacher-info {
        grid-template-columns: repeat(3, 1fr) !important;
      }
    }

    /* ===== Tablet-Querformat schmal (z.B. iPad mini Querformat ≈ 1024px) ===== */
    @media screen and (min-width: 821px) and (max-width: 1024px) {
      /* Tabs: eine Zeile mit je 12.5% Breite */
      .tab-button {
        flex: 0 0 12.5% !important;
      }
      body.touch-mode .tab-button {
        flex: 0 0 12.5% !important;
        font-size: 10px !important;
        padding: 8px 2px !important;
      }
      /* Teacher-Info: 2 Spalten auf schmalen Querformaten */
      .teacher-info {
        grid-template-columns: 1fr 1fr !important;
      }
    }

    /* ===== Automatische Touch-Erkennung für Geraete ohne praezisen Pointer ===== */
    @media (pointer: coarse) {
      .btn, .btn-sm, button:not(.tab-button) {
        min-height: 44px !important;
      }
      .tab-button {
        min-height: 44px !important;
        padding: 6px 10px !important;
      }
      select, input[type="text"], input[type="email"],
      input[type="password"], input[type="date"],
      input[type="time"], input[type="number"], textarea {
        min-height: 44px !important;
        font-size: 16px !important;
      }
      .autocomplete-item {
        min-height: 44px !important;
        padding: 10px 12px !important;
      }
      td, th {
        padding: 8px 8px !important;
      }
      /* Header darf umbrechen */
      .app-header {
        height: auto !important;
        min-height: 50px !important;
        flex-wrap: wrap !important;
      }
    }
