.touch-tooltip {
    position: relative;
    display: inline-flex;
    cursor: default;
    outline: none;
    margin-left: 0.25rem;
}

.touch-tooltip .touch-tooltip-text {
    visibility: hidden;
    background-color: var(--text-dark);
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 0.35rem 0.6rem;
    position: absolute;
    z-index: 100;
    bottom: 140%;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 0.75rem;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.2s, bottom 0.2s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.touch-tooltip .touch-tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: var(--text-dark) transparent transparent transparent;
}

.touch-tooltip:hover .touch-tooltip-text,
.touch-tooltip:focus .touch-tooltip-text,
.touch-tooltip:active .touch-tooltip-text {
    visibility: visible;
    opacity: 1;
    bottom: 160%;
}
.dashboard-layout {
    min-height: 100vh;
    background-color: var(--bg-gray);
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--white);
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2.5rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0 !important;
}

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

.topbar-logo-icon {
    width: 36px;
    height: 36px;
    background: var(--primary-blue);
    color: var(--white);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
}

.topbar-brand {
    font-size: 1.875rem;
    font-weight: 800;
    color: var(--text-dark);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.profile-logout-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-right: 1.5rem;
    border-right: 1px solid var(--border-color);
}

.user-name {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-dark);
}

.user-role {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    justify-content: flex-end;
}

.status-dot {
    width: 6px;
    height: 6px;
    background-color: #8B5CF6;
    /* Purple dot for admin */
    border-radius: 50%;
    display: inline-block;
}

.logout-btn {
    background: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    transition: color 0.2s;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
}

.logout-btn:hover {
    color: var(--danger-red);
}

.dashboard-content {
    padding: 3rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.header-title-area {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.title-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.dashboard-title {
    font-size: 1.75rem;
    color: var(--text-dark);
    margin: 0;
}

.badge-secure {
    background-color: rgba(0, 95, 84, 0.15);
    color: #065F46;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    letter-spacing: 0.05em;
}

.dashboard-subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

.btn-secondary {
    background-color: var(--white);
    border: 1px solid var(--border-color);
    color: var(--text-dark);
    font-weight: 600;
    padding: 0.625rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-secondary:hover {
    border-color: #D1D5DB;
    background-color: var(--bg-gray);
}

.btn-primary-sm {
    background-color: var(--primary-blue);
    color: var(--white);
    font-weight: 600;
    padding: 0.625rem 1.25rem;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: all 0.2s;
    border: none;
}

.btn-primary-sm:hover {
    background-color: var(--primary-blue-hover);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border-color);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

.chart-legend {
    display: flex;
    gap: 1.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dark);
}

.legend-dot.red {
    color: #A03E21;
}

.legend-dot.green {
    color: #005F54;
}

/* Incident Reports Module UI */
.live-feed-badge {
    background-color: rgba(220, 38, 38, 0.15);
    color: #A03E21;
    font-size: 0.70rem;
    font-weight: 800;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    letter-spacing: 0.05em;
    display: inline-block;
}

.report-table-header {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1.5fr 2fr 1fr;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.donut-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

.donut-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 2rem;
    text-align: center;
}

.donut-container {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto;
    transform: translateY(-10%);
}

.donut-inner-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.donut-value {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
}

.donut-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

.alert-badge {
    background-color: rgba(220, 38, 38, 0.15);
    color: #A03E21;
    font-weight: 800;
    font-size: 0.8rem;
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    margin-top: 2rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    width: 100%;
    text-align: center;
    border: 1px solid #FEE2E2;
}

/* Detailed Staff Status Table */
.staff-status-section {
    background: var(--white);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.staff-status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.staff-header-text h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0 0 0.25rem 0;
}

.staff-header-text p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
}

.staff-header-actions {
    display: flex;
    gap: 1rem;
}

.btn-orange-action {
    background-color: #FF7F50;
    color: var(--white);
    border: none;
    font-weight: 600;
    padding: 0.75rem 1.25rem;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.btn-orange-action:hover {
    background-color: #EA580C;
}

.btn-blue-action {
    background-color: #2563EB;
    color: var(--white);
    border: none;
    font-weight: 600;
    padding: 0.75rem 1.25rem;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.btn-blue-action:hover {
    background-color: #1D4ED8;
}

.staff-table-header {
    display: grid;
    grid-template-columns: minmax(180px, 1.2fr) minmax(120px, 1fr) minmax(200px, 1.9fr) minmax(140px, 1.1fr) minmax(200px, 2.3fr) minmax(90px, 0.8fr);
    padding-bottom: 1rem;
    border-bottom: 1px solid #F3F4F6;
}

.staff-col-header {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.staff-row {
    display: grid;
    grid-template-columns: minmax(180px, 1.2fr) minmax(120px, 1fr) minmax(200px, 1.9fr) minmax(140px, 1.1fr) minmax(200px, 2.3fr) minmax(90px, 0.8fr);
    align-items: center;
    padding: 1.25rem 0;
    border-bottom: 1px solid #F3F4F6;
}

.staff-row:last-child {
    border-bottom: none;
}

.staff-employee-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.staff-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
}

.staff-avatar.blue {
    background-color: rgba(59, 130, 246, 0.15);
    color: #1D4ED8;
}

.staff-avatar.pink {
    background-color: #FCE7F3;
    color: #BE123C;
}

.staff-name-block {
    display: flex;
    flex-direction: column;
}

.staff-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

.staff-name.danger {
    color: #A03E21;
}

.staff-role-cell {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.staff-role-cell.admin-role {
    color: #8B5CF6;
}

.staff-location {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.staff-training-status {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.training-pill {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0 0.6rem;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    height: 28px;
    width: 280px;
    box-sizing: border-box;
}

.training-pill-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-dark);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 0.5rem;
}

.status-completed {
    font-size: 0.65rem;
    font-weight: 800;
    color: #005F54;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    width: 90px;
    flex-shrink: 0;
    text-align: left;
    display: inline-flex;
    justify-content: flex-start;
    padding-left: 20px;
    box-sizing: border-box;
}

.btn-more {
    background: var(--bg-gray);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0 0.6rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    height: 28px;
    box-sizing: border-box;
}

.btn-more:hover {
    background: var(--bg-gray);
}

.staff-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1.25rem;
    color: var(--text-muted);
    font-size: 1rem;
}

.staff-actions button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

.staff-actions button:hover {
    color: var(--primary-blue);
}

.staff-actions button:last-child:hover {
    color: #A03E21;
}

/* Search and Pagination Controls */
.search-input-container input:focus {
    outline: none;
    border-color: #6366F1 !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn-pagination:hover {
    background-color: var(--bg-gray) !important;
    color: var(--text-dark) !important;
}

.btn-pagination:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Accordion Dropdown Styles */
.training-accordion {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    width: 100%;
}

.training-accordion.expanded {
    max-height: 280px;
    overflow-y: auto;
    transition: max-height 0.3s ease-in;
}

.accordion-inner {
    padding: 0.5rem 0 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.accordion-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background-color: var(--bg-gray);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-size: 0.8125rem;
}

.accordion-item .ac-title {
    font-weight: 500;
    color: var(--text-dark);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 0.5rem;
}

.accordion-item .ac-status {
    font-weight: 700;
    font-size: 0.7rem;
    padding: 0.1rem 0;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.7);
    width: 90px;
    flex-shrink: 0;
    text-align: left;
    display: inline-flex;
    justify-content: flex-start;
    padding-left: 20px;
    box-sizing: border-box;
}

/* Bulk Reminder Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(17, 24, 39, 0.4);
    /* Dark semi-transparent */
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    overscroll-behavior: none;
    touch-action: none; /* Block background drag entirely on iOS */
}

.modal-overlay.active {
    opacity: 1;
}

.modal-card {
    background: var(--white);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    padding: 2rem;
    box-sizing: border-box;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    touch-action: auto; /* Reinstate dragging for the actual content card */
}

.modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.5rem;
    margin-right: -0.5rem;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.modal-overlay.active .modal-card {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    position: relative;
    margin-bottom: 1rem;
}

.modal-icon-container {
    background-color: #FFF7ED;
    /* Orange faint background */
    color: #EA580C;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-right: 1rem;
}

.modal-title {
    font-size: 1.25rem;
    color: var(--text-dark);
    margin: 0;
}

.btn-close-modal {
    position: absolute;
    right: -10px;
    top: -10px;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.2s;
}

.btn-close-modal:hover {
    color: var(--text-dark);
}

.modal-description {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-dark);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-textarea {
    resize: vertical;
}

.form-input:focus,
.form-textarea:focus {
    border-color: #6366F1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1rem;
    flex-shrink: 0;
}

.btn-outline {
    background: var(--white);
    border: 1px solid var(--border-color);
    color: #374151;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-outline:hover {
    background: var(--bg-gray);
    border-color: var(--text-muted);
}

/* --- Dashboard Mobile Responsiveness --- */
@media (max-width: 1024px) {
    .topbar {
        padding: 0 1.5rem;
    }

    .dashboard-content {
        padding: 1.5rem;
    }

    .dashboard-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1.5rem;
    }

    .header-title-area {
        width: 100%;
        align-items: flex-start !important;
    }

    .title-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem;
    }

    .header-actions {
        width: 100%;
        display: flex;
        flex-direction: column;
    }

    .btn-secondary,
    .btn-primary-sm {
        width: 100%;
        justify-content: center;
    }

    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }

    .card-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .chart-legend {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .staff-status-section {
        padding: 1rem;
        border: none;
        background: transparent;
        margin-top: 1rem;
    }

    .staff-status-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .staff-header-actions {
        width: 100%;
        flex-direction: column !important;
    }

    .staff-table-header {
        display: none !important;
    }

    .staff-row {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem !important;
        padding: 1.5rem !important;
        border: 1px solid var(--border-color) !important;
        border-radius: 12px !important;
        margin-bottom: 1rem !important;
        background: var(--white) !important;
        min-width: 0 !important;
    }

    .staff-employee-info,
    .staff-training-status,
    .staff-actions {
        width: 100% !important;
        justify-content: flex-start !important;
    }

    .staff-actions {
        padding-top: 1rem !important;
        border-top: 1px solid #F3F4F6 !important;
        justify-content: space-between !important;
    }
}

/* IMPORTANT: FORCED MOBILE OVERRIDES AT END OF FILE */
@media (max-width: 1024px) {
    .dashboard-header {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        margin-bottom: 2rem !important;
        gap: 1rem !important;
    }

    .header-title-area,
    .title-row,
    .header-actions {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        margin-bottom: 0.5rem !important;
    }

    .btn-secondary,
    .btn-primary-sm {
        display: block !important;
        width: 100% !important;
        margin-bottom: 0.5rem !important;
        text-align: center !important;
    }

    .dashboard-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        width: 100% !important;
    }

    .card {
        width: 100% !important;
        margin-bottom: 1.5rem !important;
        padding: 1.25rem !important;
        min-width: 0 !important;
        overflow: hidden !important;
    }

    .staff-status-section {
        display: block !important;
        width: 100% !important;
        overflow-x: hidden !important;
        padding: 1rem !important;
        background: transparent !important;
        border: none !important;
    }

    .staff-status-header,
    .staff-header-actions {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
    }
}/* Export Dropdown Styles */
.dropdown-container .dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    background-color: var(--white);
    min-width: 180px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    z-index: 100;
    overflow: hidden;
}

.dropdown-container .dropdown-menu.show {
    display: block;
    animation: fadeInDown 0.2s ease forwards;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.875rem 1rem;
    border: none;
    background: none;
    text-align: left;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-dark);
}

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

.dropdown-item:hover {
    background-color: var(--bg-gray);
    color: var(--primary-blue);
}

/* --- Widget Container Constraint Minimization --- */
.widget-container.is-collapsed > div:first-child,
.card.is-collapsed > div:first-child {
    margin-bottom: 0 !important;
    border-bottom: none !important;
}
.widget-container.is-collapsed .widget-content,
.card.is-collapsed .widget-content {
    display: none !important;
}

@media (max-width: 1024px) {
    #training-completion-pane,
    #global-compliance-pane {
        width: 100% !important;
        border-right: none !important;
        border-left: none !important;
    }

    .inbox-split-pane {
        display: block !important;
        height: auto !important;
        min-height: 600px;
    }

    #inbox-thread-list {
        max-height: none !important;
        min-height: 600px !important;
        border-right: none !important;
        border-bottom: none !important;
        width: 100% !important;
    }

    #inbox-active-thread {
        display: none !important;
        min-height: 600px;
        width: 100% !important;
    }

    /* Screen Swipe Matrix */
    .inbox-split-pane.thread-active #inbox-thread-list {
        display: none !important;
    }

    .inbox-split-pane.thread-active #inbox-active-thread {
        display: flex !important;
        animation: fadeIn 0.2s ease forwards;
    }

    .mobile-back-btn {
        display: flex !important;
    }
}

.mobile-back-btn {
    display: none !important;
}

.inbox-split-pane {
    display: grid;
    grid-template-columns: 320px 1fr;
    flex: 1;
    background: #FAFBFD;
    height: 500px;
}

.inbox-header-title {
    font-size: 1.25rem;
}

.inbox-header-subtitle {
    font-size: 0.85rem;
}

/* --- Mobile Top Navigation Overrides --- */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }

    .caregiver-inbox-minimize {
        position: absolute !important;
        right: 1.5rem !important;
        top: calc(1.5rem - 10px) !important;
    }

    .inbox-header-title {
        font-size: 1rem !important;
    }
    
    .inbox-header-subtitle {
        font-size: 0.725rem !important;
        line-height: 1.25 !important;
    }

    .topbar-right {
        display: flex;
        align-items: center;
        gap: 1.5rem;
    }

    .action-circle-btn {
        padding: 0 !important;
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
        flex-shrink: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        border-radius: 50%;
        margin-right: 0px !important;
    }

    .tour-topbar-btn {
        color: var(--primary-blue);
    }

    .profile-logout-group {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 0.5rem 0;
    }

    html, body, #app {
        width: 100% !important;
        max-width: 100vw !important;
        position: relative;
        overflow-x: hidden !important; /* Terminate horizontal scrolling universally */
    }

    .topbar {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: space-between !important;
        align-items: center !important;
        height: auto !important;
        padding: 1rem 1.25rem !important;
        gap: 0 !important; /* Using break constraints instead */
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Inject a CSS-based flex wrap boundary to explicitly separate the top header row from the user action row */
    .topbar::after {
        content: "";
        width: 100%;
        order: 3 !important;
        border-bottom: 1px solid var(--border-color);
        margin: 0.75rem 0 0.5rem 0;
    }

    .topbar-left {
        order: 1 !important;
        width: auto !important;
        max-width: 45% !important; /* Strictly constrain width so it never wraps against the right item */
        justify-content: flex-start !important;
        flex-shrink: 1 !important;
    }
    
    .topbar-brand {
        font-size: 1.2rem !important; /* Shrunk slightly more to fit safely */
        margin-left: -0.25rem !important;
        white-space: nowrap !important;
    }

    .topbar-right {
        display: contents !important; /* Flattens children entirely up to the parent .topbar */
    }

    .lang-dropdown-wrapper {
        order: 2 !important;
        width: auto !important;
        max-width: 52% !important; /* Unconditionally cap width to ensure flex survival */
        margin-top: 0 !important;
        border-top: none !important;
        padding-top: 0 !important;
        transform: scale(0.92) !important; /* Lightly compress to save intrinsic space */
        transform-origin: right center !important;
    }

    .lang-dropdown-wrapper .lang-dropdown-btn {
        justify-content: flex-end !important;
        white-space: nowrap !important;
        overflow: hidden !important;
    }

    .current-lang-text {
        font-size: 0.8rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Force the action buttons (Tour & Moon) to correctly hug the left axis on the bottom row */
    .action-circle-btn {
        order: 4 !important;
        margin-right: 0.5rem !important; /* Adds a bit of padding so they don't clump */
        transform: translateY(3px) !important; /* Hardcoded 3px baseline offset */
    }

    /* Shrink the profile shelf to natively fit the available flex space on the right of the bottom row */
    .profile-logout-group {
        order: 5 !important;
        flex: 1;
        width: auto !important;
        padding-bottom: 0 !important;
        border-bottom: none !important;
        margin-bottom: 0 !important;
        justify-content: flex-end !important;
        align-items: center !important; /* Force math vertical alignment */
    }

    .user-profile {
        padding-right: 0 !important;
        border-right: none !important;
        flex: 1 !important; /* Expand to fill the entire horizontal void between the moon and logout buttons */
        display: flex !important;
        align-items: center !important; /* Lock internal text items vertically */
        justify-content: flex-end !important;
        text-align: right !important;
        margin-right: 1rem !important;
    }

    .user-info {
        align-items: center !important; /* Override standard text alignment */
    }

    .lang-menu {
        width: calc(100vw - 2rem) !important;
        right: auto !important;
        left: 50% !important;
        transform: translate(-50%, -10px) !important;
        grid-template-columns: 1fr !important;
    }

    .lang-dropdown-wrapper.active .lang-menu {
        transform: translate(-50%, 0) !important;
    }

    /* --- Edge-to-Edge Mobile UI Unclamping --- */
    .dashboard-content {
        padding: 0 !important;
    }

    .widget-container {
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        box-shadow: none !important;
        margin-bottom: 0.5rem !important;
    }

    /* Active Thread Precision Unclamping */
    .thread-viewer-header-block {
        padding: 1rem !important;
    }

    .thread-viewer-body-block {
        padding: 0 !important;
        background: var(--white) !important;
        gap: 0 !important;
    }

    .thread-viewer-footer-block {
        padding: 1rem !important;
    }

    .msg-bubble-container {
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: none !important;
        border-top: 1px solid var(--border-color) !important;
        box-shadow: none !important;
    }

    .msg-bubble-header {
        padding: 0.75rem 1rem !important;
        background: var(--white) !important;
        border-bottom: none !important;
    }

    .msg-bubble-content {
        padding: 0.5rem 1rem 1.5rem 1rem !important;
    }

    .library-body {
        padding: 1rem !important;
    }

    .library-header {
        padding: 1.5rem 1rem !important;
    }
}

/* --- Export/Physical Print Abstraction Matrix --- */
@media print {
    .sidebar, .topbar, .btn-minimize-widget, .header-actions, .mobile-back-btn, #inbox-thread-list, .widget-container .library-actions {
        display: none !important;
    }

    body, .dashboard-layout, .dashboard-main, #app {
        background: var(--white) !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        display: block !important;
        color: black !important;
    }

    .widget-container {
        page-break-inside: avoid;
        break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid var(--border-color) !important;
        margin-bottom: 2rem !important;
    }

    .widget-content {
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
    }

    .dashboard-grid {
        display: block !important;
    }
}
