/* Main Layout */
:root {
    --content-height-offset: 140px;
}
.sidebar {
    width: 260px;
    min-width: 100px;
    max-width: 500px;
    background: #f4f4f4;
    color: var(--primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 0;
    transition: background 0.3s, width 0.3s ease, margin-left 0.3s ease;
    border-right: 1px solid #ddd;
    position: relative;
    overflow: hidden;
}

.sidebar.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    border-right: none !important;
}

.sidebar.collapsed + #sidebar-resizer {
    display: none !important;
}

#sidebar-resizer {
    width: 5px;
    cursor: col-resize;
    background: transparent;
    transition: background 0.2s;
    z-index: 100;
}

#sidebar-resizer:hover, #sidebar-resizer.resizing {
    background: var(--accent);
}

/* Sidebar Components */
.school-switcher {
    width: 100%;
    position: relative;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
}

.active-school-display {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background 0.2s;
}

.active-school-display:hover {
    background: #f8f9fa;
}

.active-school-logo {
    width: 32px;
    height: 32px;
    background: white;
    border-radius: 50%;
    padding: 2px;
    box-shadow: 0 0 5px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.active-school-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.active-school-info {
    flex-grow: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    overflow: hidden;
}

.active-school-name {
    font-weight: bold;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--primary);
}

.school-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 1100;
    max-height: 400px;
    overflow-y: auto;
}

.school-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--text-color);
    transition: background 0.2s;
    border-bottom: 1px solid #f0f0f0;
}

.school-dropdown-item:hover {
    background: #f8f9fa;
}

.school-dropdown-item.active {
    background: #e3f2fd;
    font-weight: bold;
}

.school-dropdown-logo {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.school-dropdown-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sidebar-nav-container {
    flex-grow: 1;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.sidebar-nav a {
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    color: #444;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.9rem;
    border-left: 4px solid transparent;
}

.sidebar-nav a:hover {
    background: #e9e9e9;
    color: var(--accent);
}

.sidebar-nav a.active {
    background: #fff;
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: bold;
}

.sidebar-nav a i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.sidebar-user-container {
    width: 100%;
    border-top: 1px solid var(--border-color);
    background: #fff;
    margin-top: auto;
    position: relative;
}

.user-profile-bar {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background 0.2s;
    position: relative;
}

.user-profile-bar:hover {
    background: #f8f9fa;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.user-info {
    flex-grow: 1;
    overflow: hidden;
}

.user-name {
    font-weight: bold;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-color);
}

.user-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 6px rgba(0,0,0,0.1);
    z-index: 1100;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--text-color);
    transition: background 0.2s;
    cursor: pointer;
}

.user-menu-item:hover {
    background: #f8f9fa;
    color: var(--accent);
}

/* Accordion */
.nav-accordion {
    width: 100%;
    border-bottom: 1px solid #eee;
}

.nav-accordion-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    color: #444;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    border-left: 4px solid transparent;
}

.nav-accordion-header:hover {
    background: #e9e9e9;
    color: var(--accent);
}

.nav-accordion-header i:first-child {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.nav-accordion-header .chevron {
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform 0.3s;
}

.nav-accordion.active .nav-accordion-header {
    background: #fff;
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: bold;
}

.nav-accordion.active .nav-accordion-header .chevron {
    transform: rotate(180deg);
}

.nav-accordion-content {
    background: #fcfcfc;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

.nav-accordion.active .nav-accordion-content {
    max-height: 800px;
}

.nav-accordion-content a {
    padding: 0.75rem 1rem 0.75rem 3.5rem !important;
    font-size: 0.85rem;
    border-left: none !important;
    display: flex !important;
    align-items: center;
    gap: 1rem;
    color: #555 !important;
    text-decoration: none !important;
    width: 100%;
}

.nav-accordion-content a i {
    width: 16px !important;
    font-size: 0.9rem !important;
}

.nav-accordion-content a:hover, .nav-accordion-content a.active {
    background: #f0f0f0 !important;
    color: var(--accent) !important;
    font-weight: bold;
}

.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden; /* Prevent global scroll to keep topbar fixed */
    position: relative;
}

.topbar {
    height: 60px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    justify-content: space-between;
    width: 100%;
    color: var(--text-color);
    overflow: visible; /* Allow admin menu dropdowns to be visible */
    position: sticky;
    top: 0;
    z-index: 1000;
    flex-shrink: 0;
}

.nav-items {
    display: flex;
    gap: 1rem;
}

.nav-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 4px;
    color: var(--primary);
    text-decoration: none;
}

.nav-item:hover {
    background: #eee;
}

.content {
    flex: 1;
    padding: 1.5rem 1.5rem 0.5rem 1.5rem;
    overflow-y: auto;
    overflow-x: auto; /* allow horizontal scrolling if necessary */
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 100%;
}

.user-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
}

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

.topbar-title-container h1 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--primary);
    white-space: nowrap;
}

/* Announcement Header Styles */
#announcement-header-container {
    background: #fffdeb;
    border-bottom: 1px solid #ffeeba;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    overflow: hidden;
    height: 46px; /* 60px Topbar + 46px = 106px, passend zur Sidebar-Header-Höhe */
}

.announcement-wrapper {
    display: flex;
    align-items: center;
    height: 100%;
    width: 100%;
}

.announcement-text-single {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    overflow: hidden;
    font-size: 1.2rem;
}

.announcement-title {
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 120px);
}

.more-link {
    font-size: 0.9rem;
    text-decoration: underline;
    font-weight: bold;
    color: var(--accent);
    white-space: nowrap;
    flex-shrink: 0;
}

.announcement-wrapper:hover .more-link {
    color: var(--primary);
}

.hidden-mobile {
    display: block;
}

.show-mobile {
    display: none !important;
}

@media (max-width: 767px) {
    .hidden-mobile {
        display: none !important;
    }
    .show-mobile {
        display: block !important;
    }
}

.hamburger-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #2c3e50; /* Explizite dunkle Farbe statt nur Variable */
    cursor: pointer;
    padding: 0.5rem;
}

#sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1500; /* Higher than topbar to darken it too */
}

/* Responsive adjustments */
@media (max-width: 767px) {
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        z-index: 1600; /* Higher than backdrop */
        width: 260px !important;
        transition: left 0.3s ease;
    }

    .sidebar.mobile-active {
        left: 0;
    }

    #sidebar-resizer {
        display: none;
    }

    .active-school-name {
        display: block;
    }

    .nav-item span {
        display: none;
    }

    .content {
        padding: 0.75rem 0.75rem 0.25rem 0.75rem;
    }
    :root {
        --content-height-offset: 80px;
    }
}

/* Mailbox Client Layout — Weg 2: Desktop 3-Spalten, Tablet Drawer, Phone Stack+Bottom-Nav */
#mailbox-backdrop {
    display: none;
}

.mailbox-client {
    display: flex;
    height: calc(100vh - 160px);
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    position: relative;
}

.mailbox-folders-pane {
    width: 250px;
    background: #f8f9fa;
    border-right: 1px solid #eee;
    overflow-y: auto;
    flex-shrink: 0;
    transition: transform 0.25s ease, width 0.25s ease;
}

.mailbox-main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.mailbox-header-inner {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 0.75rem;
}

.mailbox-header-start {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    flex-shrink: 0;
}

.mailbox-folder-title {
    min-width: 0;
    max-width: 12rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1.1rem;
}

.mailbox-search {
    flex: 1;
    position: relative;
    min-width: 8rem;
}

.mailbox-search-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
}

.mailbox-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.mailbox-more {
    position: relative;
}

.mailbox-more-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    min-width: 12rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.35rem;
    z-index: 1300;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.mailbox-more-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    border: none;
    background: transparent;
    padding: 0.65rem 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #334155;
    cursor: pointer;
    text-align: left;
}

.mailbox-more-item:hover,
.mailbox-more-item.is-active {
    background: #f1f5f9;
    color: var(--accent, #2c5aa0);
}

.mailbox-list-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid #eee;
    background: #fafbfc;
}

.mailbox-list-toolbar .mail-sort-control {
    width: 100%;
    max-width: 16rem;
}

.mailbox-select-hint {
    flex: 1;
    min-width: 10rem;
    font-size: 0.75rem !important;
}

.mail-view-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.mail-view-actions-primary {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.mail-view-more {
    position: relative;
}

.mail-view-more-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    min-width: 13rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.35rem;
    z-index: 1300;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.mailbox-bottom-nav {
    display: none;
}

.mailbox-header .mail-hamburger-btn,
.mailbox-header .mail-hamburger-btn i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    min-height: 2.5rem;
    padding: 0.45rem 0.65rem;
    background: transparent !important;
    border: none !important;
    color: #2c3e50 !important;
    font-size: 1.25rem;
    cursor: pointer;
}

.mailbox-header .mail-hamburger-btn:hover,
.mailbox-header .mail-hamburger-btn:hover i {
    color: #1a252f !important;
    background: transparent !important;
}

.mailbox-vacation-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    padding: 0.45rem 0.75rem;
}

.mailbox-vacation-label {
    font-size: 0.9rem;
    font-weight: 500;
}

#btn-mail-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    min-height: 2.5rem;
    padding: 0.45rem 0.65rem;
}

.mailbox-actions .btn-primary {
    color: #fff !important;
}

.mailbox-actions .btn-primary i {
    color: #fff !important;
}

/* Tablet + Phone: Ordner als Drawer (iPad-Leitlayout) */
@media (max-width: 1199px) {
    body.module-mailbox .mailbox-folders-resizer {
        display: none !important;
    }

    .mailbox-folders-pane {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 1200;
        width: min(320px, 86vw) !important;
        max-width: 320px;
        background: white;
        transform: translateX(-100%);
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.1);
        border-right: none;
    }

    .mailbox-folders-pane.collapsed {
        width: min(320px, 86vw) !important;
    }

    .mailbox-folders-pane.active {
        transform: translateX(0);
    }

    #mailbox-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 1150;
        display: none;
    }

    #mailbox-backdrop.active {
        display: block;
    }

    .mailbox-client {
        border-radius: 0;
        height: calc(100vh - 100px);
    }

    .mailbox-list-pane {
        flex: 0 0 42%;
        max-width: 420px;
    }

    .mailbox-content-pane {
        flex: 1;
        min-width: 0;
    }
}

@media (max-width: 767px) {
    body.module-mailbox .topbar {
        display: none !important;
    }

    body.module-mailbox .content {
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }

    .mailbox-client {
        height: 100dvh;
        min-height: 100dvh;
        border-radius: 0;
        box-shadow: none;
        flex-direction: column;
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0));
    }

    .mailbox-main-area {
        flex: 1;
        min-height: 0;
    }

    .mailbox-list-pane {
        flex: 1;
        max-width: none;
        width: 100%;
    }

    .mailbox-compose-label {
        display: none;
    }

    .mailbox-vacation-label {
        display: none;
    }

    .mailbox-header-inner {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .mailbox-search {
        order: 3;
        flex: 1 1 100%;
        min-width: 100%;
    }

    .mailbox-bottom-nav {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1100;
        height: calc(56px + env(safe-area-inset-bottom, 0));
        padding: 0 0.25rem env(safe-area-inset-bottom, 0);
        background: #fff;
        border-top: 1px solid #e5e7eb;
        justify-content: space-around;
        align-items: stretch;
    }

    .mailbox-bottom-nav-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.15rem;
        border: none;
        background: transparent;
        color: #64748b;
        font-size: 0.65rem;
        padding: 0.35rem;
        cursor: pointer;
        min-height: 44px;
    }

    .mailbox-bottom-nav-btn i {
        font-size: 1.15rem;
    }

    .mailbox-bottom-nav-btn--primary {
        color: var(--accent, #2c5aa0);
        font-weight: 600;
    }

    /* Mehr-Menü über Bottom-Nav verankern */
    .mailbox-more-menu {
        position: fixed;
        left: 0.75rem;
        right: 0.75rem;
        bottom: calc(64px + env(safe-area-inset-bottom, 0));
        top: auto;
        min-width: 0;
    }

    .fa-solid, .fas {
        font-weight: 900 !important;
        display: inline-block !important;
        min-width: 1em;
        text-align: center;
    }
}

.mailbox-folders-pane.collapsed {
    width: 0 !important;
    border-right: none !important;
}

.mailbox-folders-resizer {
    width: 4px;
    cursor: col-resize;
    background: #eee;
    transition: background 0.2s;
    z-index: 10;
    flex-shrink: 0;
}

.mailbox-folders-resizer:hover, .mailbox-folders-resizer.resizing {
    background: var(--accent);
}

.mailbox-panes-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.account-sidebar-section {
    border-bottom: 1px solid #e0e0e0;
}

.account-sidebar-header {
    padding: 0.8rem 1rem;
    font-weight: bold;
    font-size: 0.85rem;
    color: #444;
    background: #eceef1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.account-sidebar-header .btn-icon {
    color: #888;
    opacity: 0.6;
    transition: all 0.2s;
}

.account-sidebar-header .btn-icon:hover {
    color: var(--accent);
    opacity: 1;
    transform: rotate(30deg);
}

.account-folder-list {
    padding: 0.2rem 0;
}

.folder-item {
    padding: 0.6rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #555;
    transition: all 0.2s;
    font-size: 0.95rem;
    position: relative;
}

.folder-item-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-item-count {
    flex-shrink: 0;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    color: #888;
    margin-left: 0.25rem;
}

.folder-item-count.has-unread {
    color: var(--accent, #2c5aa0);
    font-weight: 600;
}

.folder-item-menu {
    opacity: 0;
    padding: 0.15rem 0.35rem !important;
    margin-left: 0.15rem;
}

.folder-item:hover .folder-item-menu,
.folder-item.active .folder-item-menu {
    opacity: 1;
}

.folder-item:hover {
    background: #eee;
    color: var(--accent);
}

.folder-item.active {
    background: #fff;
    color: var(--accent);
    font-weight: bold;
    border-right: 3px solid var(--accent);
}

.folder-tree-node {
    display: flex;
    flex-direction: column;
}

.folder-children {
    margin-left: 1rem;
    border-left: 1px solid #ddd;
}

.folder-toggle {
    cursor: pointer;
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.folder-toggle.collapsed {
    transform: rotate(-90deg);
}

.mailbox-list-pane {
    position: relative;
    width: 350px;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.mail-bulk-bar:not(.hidden) {
    display: block;
    flex-shrink: 0;
    z-index: 3;
}

.mail-thread-btn-label {
    margin-left: 0.15rem;
}

.mailbox-content-pane {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.mailbox-header {
    padding: 1rem;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fcfcfc;
}

.mail-sort-control {
    min-width: 170px;
}

.mail-sort-select {
    font-size: 0.85rem;
    padding: 0.35rem 0.5rem;
    height: auto;
}

.mail-list {
    flex: 1;
    overflow-y: auto;
}

.mailbox-list-pane.mail-list-refreshing::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent, #2563eb), transparent);
    animation: mail-list-refresh 1.2s ease-in-out infinite;
    z-index: 2;
    pointer-events: none;
}

@keyframes mail-list-refresh {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.mail-item {
    padding: 1rem;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    transition: background 0.2s;
}

.mail-item:hover {
    background: #f9f9f9;
}

.mail-item.active {
    background: #eef6ff;
    border-left: 4px solid var(--accent);
}

.mail-item.selected {
    background: color-mix(in srgb, var(--accent, #2563eb) 14%, #fff);
    box-shadow: inset 3px 0 0 var(--accent, #2563eb);
}

.mail-item.selected.unseen {
    background: color-mix(in srgb, var(--accent, #2563eb) 14%, #fff);
}

.mail-item-select-mark {
    display: none;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 999px;
    background: var(--accent, #2563eb);
    color: #fff;
    font-size: 0.65rem;
    flex-shrink: 0;
}

.mail-item.selected .mail-item-select-mark {
    display: inline-flex;
}

.mail-list--selecting .mail-item {
    user-select: none;
    -webkit-user-select: none;
}

.mail-item.unseen {
    background: #fff;
    font-weight: bold;
}

.mail-item-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
    color: #666;
}

.mail-item-from {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mail-item--nested {
    padding-left: 2.25rem;
    background: #fafbfc;
}

.mail-item-subject {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #333;
}

.mail-bulk-bar {
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    background: #f8fafc;
    padding: 0.45rem 0.75rem;
}

.mail-bulk-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
}

.mail-bulk-count {
    font-size: 0.85rem;
    font-weight: 600;
    color: #6b7280;
}

.mail-bulk-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    align-items: center;
}

.mail-thread {
    border-bottom: 1px solid #eee;
}

.mail-thread .mail-item {
    border-bottom: none;
}

.mail-thread-head {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.75rem 0;
}

.mail-thread-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 600;
    font-size: 0.8rem;
}

.mail-thread-count {
    background: #e5e7eb;
    border-radius: 999px;
    padding: 0.05rem 0.45rem;
    font-size: 0.72rem;
}

.mail-thread-unseen {
    background: var(--accent, #2563eb);
    color: #fff;
    border-radius: 999px;
    padding: 0.05rem 0.4rem;
    font-size: 0.7rem;
    font-weight: 700;
}

.mailbox-actions .btn.is-active {
    color: var(--accent, #2563eb);
    background: color-mix(in srgb, var(--accent, #2563eb) 12%, #fff);
}

.mail-content-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ccc;
    text-align: center;
}

.mail-content-view {
    padding: 2rem;
}

.mail-view-body img {
    max-width: 100% !important;
    height: auto !important;
}

.mail-view-header h2 {
    margin: 1rem 0 0.5rem 0;
}

.mail-meta {
    color: #666;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.mail-body {
    margin-top: 2rem;
    line-height: 1.6;
    color: #444;
}

/* Mailbox Enhancements */
.mailbox-header select.form-control {
    font-size: 0.85rem;
    padding: 4px 8px;
    height: auto;
}

.special-search-box {
    background: #f8f9fa;
    border-color: #dee2e6 !important;
}

/* Compose — compact recipient layout */
.mail-compose {
    max-width: 920px;
    margin: 0 auto;
    padding: 1.25rem 1.35rem 1.5rem;
}

.mail-compose-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.mail-compose-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
}

.mail-compose-meta {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.mail-compose-row {
    display: grid;
    grid-template-columns: 3.25rem minmax(0, 1fr);
    gap: 0.65rem;
    align-items: start;
}

.mail-compose-label {
    padding-top: 0.55rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted, #6b7280);
    text-align: right;
}

.mail-compose-field {
    position: relative;
    min-width: 0;
    max-width: 36rem;
}

.mail-compose-field--recipients {
    max-width: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem 0.6rem;
    align-items: flex-start;
}

.mail-compose-field--recipients .mail-compose-chips {
    flex: 1 1 16rem;
    min-width: 0;
    max-width: 36rem;
}

.mail-compose-from {
    max-width: 36rem;
}

.mail-compose-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    min-height: 2.35rem;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 6px;
    background: #fff;
    cursor: text;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.mail-compose-chips:focus-within {
    border-color: var(--accent, #2563eb);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #2563eb) 18%, transparent);
}

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

.mail-compose-chip-input {
    border: none;
    outline: none;
    flex: 1 1 8rem;
    min-width: 7rem;
    background: transparent;
    font: inherit;
    padding: 0.2rem 0.15rem;
}

.mail-compose-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    padding-top: 0.15rem;
}

.mail-compose-chip {
    border: 1px solid var(--border-color, #d1d5db);
    background: #fff;
    color: var(--text-color, #374151);
    border-radius: 999px;
    padding: 0.25rem 0.7rem;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.3;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.mail-compose-chip.is-active,
.mail-compose-chip[aria-pressed="true"],
.mail-compose-chip[aria-expanded="true"] {
    border-color: var(--accent, #2563eb);
    color: var(--accent, #2563eb);
    background: color-mix(in srgb, var(--accent, #2563eb) 10%, #fff);
}

.mail-compose-dropdown {
    position: relative;
    width: 100%;
    max-width: 36rem;
    flex: 1 1 100%;
}

.mail-compose-school {
    grid-column: 1 / -1;
    margin: 0.25rem 0 0.35rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    background: linear-gradient(180deg, #fafbfc 0%, #f4f6f8 100%);
}

.mail-compose-school-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.mail-compose-target {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.85rem;
}

.mail-compose-target-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted, #6b7280);
    margin-right: 0.25rem;
}

.mail-compose-target-btn {
    border: 1px solid var(--border-color, #d1d5db);
    background: #fff;
    border-radius: 6px;
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.mail-compose-target-btn.is-active {
    border-color: var(--accent, #2563eb);
    background: var(--accent, #2563eb);
    color: #fff;
}

.mail-compose-school-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.mail-compose-school-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
}

.mail-compose-school-field label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted, #6b7280);
    margin: 0;
}

.mail-compose-school-field--wide {
    grid-column: 1 / -1;
    position: relative;
}

.mail-compose-school-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

.mail-compose-school-results {
    margin-top: 0.75rem;
    max-height: 220px;
}

.mail-compose-extras {
    margin-top: 0.85rem;
}

.mail-compose-attach {
    max-width: 36rem;
}

.mail-compose-editor {
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 6px;
    background: #fff;
    overflow: hidden;
}

.mail-compose-editor #mail-editor-container {
    min-height: 280px;
}

.mail-compose-editor.is-quill {
    border: none;
}

.mail-compose-fallback-editor {
    min-height: 280px;
    height: 100%;
    border: none;
    resize: vertical;
    width: 100%;
    padding: 1rem;
}

.mail-compose-signature {
    margin: 0.85rem 0;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 6px;
    background: #f9fafb;
    font-size: 0.85rem;
    max-height: 160px;
    overflow-y: auto;
}

.mail-compose-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.mail-compose-footer-primary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

@media (max-width: 900px) {
    .mail-compose-school-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 720px) {
    .mail-compose {
        padding: 1rem;
        max-width: none;
    }

    .mail-compose-row {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }

    .mail-compose-label {
        text-align: left;
        padding-top: 0;
    }

    .mail-compose-field,
    .mail-compose-field--recipients .mail-compose-chips,
    .mail-compose-from,
    .mail-compose-attach,
    .mail-compose-dropdown {
        max-width: none;
    }

    .mail-compose-school-grid {
        grid-template-columns: 1fr;
    }

    .mail-compose-school-split {
        grid-template-columns: 1fr;
    }

    .mail-compose-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .mail-compose-footer-primary .btn,
    .mail-compose-footer > .btn {
        width: 100%;
        justify-content: center;
    }
}

.search-results-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #eee;
    background: white;
    border-radius: 4px;
}

.list-group-item {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #eee;
}

.list-group-item:last-child {
    border-bottom: none;
}

.list-group-item:hover {
    background: #f0f7ff;
}

.grid-2-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

@media (max-width: 600px) {
    .grid-2-col, .grid-3-col { grid-template-columns: 1fr; }
}

.mailbox-client .folder-item i {
    width: 20px;
    text-align: center;
}

/* Modal and Utility */
.pointer { cursor: pointer; }
.margin-y-1 { margin-top: 1rem; margin-bottom: 1rem; }
.padding-1 { padding: 1rem; }
.rounded { border-radius: 4px; }
.border { border: 1px solid #ddd; }
.hidden { display: none !important; }

.search-dropdown ul {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    list-style: none;
    padding: 0;
    margin: 0;
    z-index: 1000;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.search-dropdown li {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.search-dropdown li:hover {
    background: #f0f7ff;
}

/* Besitzer-Autocomplete: fixed Portal am body (kein Clipping durch Editor-Panels) */
.form-owner-results-portal {
    position: fixed;
    z-index: 10000;
    max-height: 280px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ccd;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.form-owner-results-portal ul {
    list-style: none;
    margin: 0;
    padding: 0;
    position: static !important;
}
.form-owner-results-portal li {
    padding: 0.6rem 0.85rem;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    background: #fff;
}
.form-owner-results-portal li:hover {
    background: #eef5ff;
}

/* Mobile Utilities */
.show-mobile { display: none; }

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

@media (max-width: 767px) {
    .mailbox-list-pane { width: 100%; }
    .hidden-mobile { display: none !important; }
    .show-mobile { display: block !important; }

    .mail-content-view { padding: 1rem; }

    .mail-view-header .flex-between {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .mail-view-header .mail-view-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
        width: 100%;
        justify-content: flex-start;
    }

    .mail-view-header .mail-view-actions .btn {
        padding: 0.5rem;
        font-size: 0.8rem;
        min-height: 44px;
    }

    .mail-view-body img {
        max-width: 100% !important;
        height: auto !important;
    }
}

.document-name {
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* Buttons */
.btn-icon {
    background: transparent;
    border: none;
    color: #666;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 5px;
}

.btn-icon:hover { color: var(--accent); }

/* Calendar Styles */
.calendar-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.calendar-item {
    display: flex;
    padding: 1rem;
    gap: 1.5rem;
    align-items: flex-start;
}

.calendar-item-date {
    background: #f8f9fa;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 0.5rem;
    min-width: 60px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.date-day {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent);
    line-height: 1;
}

.date-month {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #666;
    margin-top: 2px;
}

.calendar-item-info {
    flex: 1;
}

.calendar-item-summary {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--primary);
    margin-bottom: 0.3rem;
}

.calendar-item-location {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.3rem;
}

.calendar-item-desc {
    font-size: 0.9rem;
    color: #888;
    line-height: 1.4;
}

.appointment-preview-item {
    display: flex;
    gap: 0.8rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
}

.appointment-date {
    font-weight: bold;
    color: var(--accent);
    min-width: 45px;
}

.appointment-summary {
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.clickable { cursor: pointer; }
.clickable:hover { background: #f8f9fa; }

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    position: relative;
}

.modal-header {
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    cursor: pointer;
    font-size: 1.5rem;
    color: #999;
}

.modal-body {
    line-height: 1.6;
}

.modal-footer {
    margin-top: 2rem;
    text-align: right;
}


/* Settings & Password Change */
.btn-secondary {
    background: #6c757d;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

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

.margin-top-1 {
    margin-top: 1rem;
}

.input-group-password {
    position: relative;
    margin-bottom: 1rem;
    max-width: 300px;
}

.input-group-password input {
    width: 100%;
    padding: 10px;
    padding-right: 40px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #666;
}

.status-success {
    color: #1b5e20;
    padding: 10px;
    background: #e8f5e9;
    border-radius: 4px;
    margin-top: 10px;
    border: 1px solid #c8e6c9;
    line-height: 1.45;
}

.status-error {
    color: #5d4345;
    padding: 10px;
    background: #fdecea;
    border-radius: 4px;
    margin-top: 10px;
    border: 1px solid #f5c2c0;
    line-height: 1.45;
}

.sidebar-divider {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: #999;
    padding: 1.5rem 1.5rem 0.5rem 1.5rem;
    font-weight: bold;
    letter-spacing: 1px;
}

.sidebar-header-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem 1.5rem 0.5rem 1.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #999;
    font-weight: bold;
    letter-spacing: 1px;
}

.sidebar-header-item i {
    width: 20px;
    text-align: center;
}

.sidebar-school-selector {
    padding: 0.5rem 0;
    width: 100%;
}

.school-selector-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1.5rem;
    color: #444;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
    border-left: 4px solid transparent;
}

.school-selector-item:hover {
    background: #e9e9e9;
    color: var(--accent);
}

.school-selector-item.active {
    background: #fff;
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: bold;
}

.school-selector-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 4px;
    background: white;
    border: 1px solid #eee;
}

.school-selector-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.school-selector-code {
    font-size: 0.9rem;
    font-weight: bold;
    width: 40px;
}

.school-selector-name {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Admin Specific Sidebar & Menu Styles */
.admin-school-item {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    gap: 1rem;
    text-decoration: none;
    color: var(--primary);
    transition: all 0.2s;
    width: 100%;
}

.admin-school-item:hover {
    background: rgba(0,0,0,0.05);
}

.admin-school-item.active {
    background: #fff;
    border-left: 4px solid var(--accent);
}

.school-selector-icon-large {
    width: 60px;
    height: 60px;
    background: white;
    border-radius: 12px;
    padding: 5px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.school-selector-icon-large img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.school-code-large {
    font-weight: bold;
    font-size: 1.1rem;
}

/* Admin Menu Mode in Announcement Container */
#announcement-header-container.admin-menu-mode {
    padding: 0;
    height: auto;
    min-height: 46px;
    overflow: visible; /* CRITICAL: Must be visible for dropdowns */
    position: relative;
    z-index: 900;
}

.admin-menu-tree {
    display: flex;
    align-items: stretch;
    height: 100%;
    width: 100%;
    overflow: visible; /* Fix clipping of absolute dropdowns */
}

.admin-menu-item {
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
    border-right: 1px solid rgba(0,0,0,0.05);
    font-size: 0.95rem;
    color: #444;
    height: 46px;
    white-space: nowrap;
}

.admin-menu-item:hover {
    background: rgba(0,0,0,0.05);
    color: var(--accent);
}

.admin-menu-item i {
    font-size: 1.1rem;
}

/* Hierarchical Menu Styles */
.admin-menu-category {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    height: 46px;
    cursor: pointer;
    border-right: 1px solid rgba(0,0,0,0.05);
    white-space: nowrap;
    font-size: 0.95rem;
    color: #444;
    transition: background 0.2s;
}

.admin-menu-category:hover {
    background: rgba(0,0,0,0.05);
    color: var(--accent);
}

.admin-menu-category i.fa-chevron-down {
    font-size: 0.7rem;
    margin-left: 0.5rem;
    opacity: 0.6;
}

.admin-menu-dropdown {
    display: none;
    position: absolute;
    top: 46px;
    left: 0;
    background: white;
    min-width: 220px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 2000;
    border: 1px solid #ddd;
    border-radius: 0 0 6px 6px;
    overflow: hidden;
}

.admin-menu-category:hover .admin-menu-dropdown,
.admin-menu-category.active .admin-menu-dropdown {
    display: block;
}

.admin-menu-category.active {
    background: rgba(0,0,0,0.08);
    color: var(--accent);
}

.admin-menu-dropdown-item {
    padding: 0.85rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    color: #444;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.admin-menu-dropdown-item:last-child {
    border-bottom: none;
}

.admin-menu-dropdown-item:hover {
    background: #f8f9fa;
    color: var(--accent);
    padding-left: 1.75rem;
}

.admin-menu-dropdown-item i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

/* Adjustments for active school in admin mode */
.sidebar.admin-mode .active-school-container {
    flex-direction: row;
    padding: 1rem 1.5rem;
    justify-content: flex-start;
    gap: 1rem;
}

.sidebar.admin-mode .active-school-logo {
    width: 60px;
    height: 60px;
}

.sidebar.admin-mode .active-school-name {
    font-size: 1.1rem;
    margin-top: 0;
}

.btn-group.scroll-x {
    display: flex !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    flex-wrap: nowrap !important;
    border-radius: 4px;
    padding-bottom: 5px;
}

.btn-group.scroll-x .btn {
    flex: 0 0 auto;
    white-space: nowrap;
    min-width: 100px;
    text-align: center;
}

.table-responsive {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    border: 1px solid #eee;
    background: linear-gradient(to right, white 30%, rgba(255,255,255,0)), linear-gradient(to right, rgba(255,255,255,0), white 70%) 0 100%, radial-gradient(farthest-side at 0 50%, rgba(0,0,0,0.2), rgba(0,0,0,0)), radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,0.2), rgba(0,0,0,0)) 0 100%;
    background-repeat: no-repeat;
    background-color: white;
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
}

.timetable-table {
    min-width: 800px;
    width: 100%;
}

.timetable-table th,
.timetable-table td {
    text-align: center;
    vertical-align: middle;
}

/* Mobile Stacked Layout for Compact Substitution View */
@media (max-width: 767px) and (orientation: portrait) {
    .timetable-table.is-compact {
        min-width: 0 !important;
        width: 100% !important;
    }
    
    .timetable-table.is-compact thead {
        display: none !important;
    }
    
    .timetable-table.is-compact tr {
        display: flex !important;
        flex-wrap: wrap !important;
        flex-direction: row !important;
        border-bottom: 2px solid var(--accent) !important;
        padding: 0.5rem 0 !important;
        gap: 0;
    }
    
    .timetable-table.is-compact td {
        display: block !important;
        border: none !important;
        padding: 0.2rem 0.5rem !important;
        text-align: left !important;
        white-space: nowrap !important;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Row 1: Std., Zeit, Fach, Klasse, Raum */
    .timetable-table.is-compact td:nth-child(1) { /* Std. */
        width: 10% !important;
        font-weight: bold;
        color: var(--primary);
    }
    .timetable-table.is-compact td:nth-child(2) { /* Zeit */
        width: 20% !important;
        color: #666;
        font-size: 0.75rem;
        white-space: nowrap !important;
    }
    .timetable-table.is-compact td:nth-child(3) { /* Fach */
        width: 30% !important;
        font-weight: bold;
        color: var(--accent);
    }
    .timetable-table.is-compact td:nth-child(4) { /* Klasse */
        width: 20% !important;
        color: var(--primary);
        font-size: 0.85rem;
    }
    .timetable-table.is-compact td:nth-child(5) { /* Raum */
        width: 20% !important;
        font-weight: bold;
        color: #444;
    }

    /* Row 2: Art, Info */
    .timetable-table.is-compact td:nth-child(6) { /* Art */
        width: 45% !important;
        border-top: 1px solid #f0f0f0 !important;
        padding-top: 0.4rem !important;
    }
    .timetable-table.is-compact td:last-child { /* Info */
        width: 55% !important;
        border-top: 1px solid #f0f0f0 !important;
        padding-top: 0.4rem !important;
        background: #f8f9fa;
        font-style: italic;
        font-size: 0.85rem;
        white-space: normal !important;
        padding: 0.4rem 0.5rem !important;
    }
    
    /* Ausblenden von Abwesend/Lehrkraft in der Kompakt-Kurzübersicht Handy falls vorhanden */
    /* (Diese Spalten 5/6 bei substitutions.js schieben wir ggf. raus oder verbergen sie) */
    .timetable-table.is-compact.table-mini td:nth-child(5),
    .timetable-table.is-compact.table-mini td:nth-child(6) {
        /* display: none !important; */ /* Optional: falls es zu voll wird */
    }
    
    .timetable-table.is-compact .badge {
        font-size: 0.9rem;
        padding: 0.4rem 0.8rem;
    }
}
    .content {
        padding: 0.75rem 0.75rem 0.5rem 0.75rem !important;
    }

    .card {
        padding: 1rem !important;
    }

    .card.no-padding {
        padding: 0 !important;
    }
    
    .substitution-controls .flex-row {
        flex-direction: column;
        align-items: stretch !important;
    }
    
    .substitution-controls .margin-left-auto {
        margin-left: 0 !important;
        margin-top: 0.75rem;
        padding: 0.5rem;
        background: #f8f9fa;
        border-radius: 4px;
        display: flex;
        justify-content: center;
    }
}
