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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    color: #333;
    min-height: 100vh;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-left h1 {
    font-size: 1.8em;
    font-weight: 700;
}

.user-info {
    font-size: 0.9em;
    opacity: 0.9;
}

.user-role {
    font-weight: 600;
}

.main-nav {
    background: white;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    gap: 0;
    padding: 0 30px;
}

/* Banner Announcement */
.banner-announcement {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
    padding: 12px 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 100;
}

.banner-announcement:hover {
    background: linear-gradient(135deg, #ff5252 0%, #e53935 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.banner-content {
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.banner-icon {
    font-size: 1.2em;
    flex-shrink: 0;
    margin-right: 15px;
    z-index: 3;
    position: relative;
}

.banner-text {
    font-weight: 600;
    font-size: 1em;
    animation: scroll-banner 30s linear infinite;
    display: inline-block;
    white-space: nowrap;
    flex: 1;
}

@keyframes scroll-banner {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-33.333%);
    }
}

.banner-announcement::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 50px;
    background: linear-gradient(to right, rgba(255, 107, 107, 1), rgba(255, 107, 107, 0));
    z-index: 2;
    pointer-events: none;
}

.banner-announcement::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 50px;
    background: linear-gradient(to left, rgba(255, 107, 107, 1), rgba(255, 107, 107, 0));
    z-index: 2;
    pointer-events: none;
}

.nav-tab {
    background: none;
    border: none;
    padding: 15px 25px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.nav-tab:hover {
    color: #667eea;
    background: #f8f9fa;
}

.nav-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.main-content {
    flex: 1;
    padding: 30px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    /* Ensure main content doesn't prevent scrolling */
    overflow: visible;
    position: relative;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

/* Calendar Controls */
.calendar-controls {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

.view-selector {
    display: flex;
    gap: 5px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.view-btn {
    background: white;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    font-weight: 600;
    color: #666;
    transition: all 0.3s;
}

.view-btn:hover {
    background: #f8f9fa;
}

.view-btn.active {
    background: #667eea;
    color: white;
}

.date-navigation {
    display: flex;
    align-items: center;
    gap: 15px;
}

.nav-btn {
    background: #f8f9fa;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5em;
    color: #667eea;
    transition: all 0.3s;
}

.nav-btn:hover {
    background: #e0e0e0;
    transform: scale(1.1);
}

#currentPeriod {
    font-size: 1.2em;
    font-weight: 600;
    min-width: 200px;
    text-align: center;
}

.filters {
    display: flex;
    gap: 10px;
    margin-left: auto;
}

.filter-select,
.filter-input {
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.9em;
}

.filter-input {
    min-width: 200px;
}

/* Calendar Container */
.calendar-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: auto;
    position: relative;
    max-height: calc(100vh - 200px);
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
}

/* Month view specific styling - ensure it's contained and scrollable */
.calendar-container > .calendar-grid {
    overflow: visible;
    min-height: min-content;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: #e0e0e0;
    position: relative;
    overflow: visible;
}

.day-header {
    background: #667eea;
    color: white;
    padding: 15px;
    text-align: center;
    font-weight: 600;
    font-size: 0.9em;
}

.calendar-day {
    background: white;
    min-height: 120px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: visible;
}

/* Month view is read-only - calendar-grid indicates month view */
.calendar-container > .calendar-grid .calendar-day {
    cursor: default;
}

.calendar-container > .calendar-grid .calendar-day:hover {
    cursor: default;
}

.calendar-day:hover {
    background: #f8f9fa;
    z-index: 1;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.calendar-day .event-dot.user-tooltip-trigger:hover {
    z-index: 99999;
    position: relative;
}

.calendar-day.other-month {
    background: #f9f9f9;
    color: #bbb;
}

.calendar-day.today {
    background: #e3f2fd;
    border: 2px solid #667eea;
}

.day-number {
    font-weight: 600;
    font-size: 1em;
    margin-bottom: 5px;
}

.day-events {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow: visible;
}

.event-dot {
    color: white;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.75em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    position: relative;
}

/* Event dots in month view are read-only */
.calendar-container > .calendar-grid .event-dot {
    cursor: default;
}

.calendar-container > .calendar-grid .event-dot:hover {
    cursor: default;
}

.event-dot.user-tooltip-trigger {
    overflow: visible;
    position: relative;
}

.event-dot.user-tooltip-trigger > span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-dot.user-tooltip-trigger .user-tooltip {
    left: 50%;
    top: calc(100% + 8px);
    bottom: auto;
    transform: translateX(-50%);
    z-index: 99999 !important;
}

.event-dot.user-tooltip-trigger .user-tooltip::before {
    left: 50%;
    bottom: 100%;
    top: auto;
    right: auto;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: #333;
    border-right-color: transparent;
    border-top-color: transparent;
}

.event-dot:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Week View */
.week-view {
    display: grid;
    grid-template-columns: 100px repeat(7, 1fr);
    gap: 1px;
    background: #e0e0e0;
}

.week-time-slot {
    background: #f8f9fa;
    padding: 10px;
    text-align: center;
    font-weight: 600;
    font-size: 0.9em;
}

.week-day-header {
    background: #667eea;
    color: white;
    padding: 15px;
    text-align: center;
    font-weight: 600;
}

.week-day-cell {
    background: white;
    min-height: 60px;
    padding: 5px;
}

/* Day View */
.day-view {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 1px;
    background: #e0e0e0;
}

.day-time-slot {
    background: #f8f9fa;
    padding: 15px;
    text-align: center;
    font-weight: 600;
    border-bottom: 1px solid #e0e0e0;
}

.day-events-column {
    background: white;
}

.day-event-block {
    padding: 10px;
    margin: 5px;
    border-radius: 5px;
    color: white;
    font-size: 0.9em;
}

/* Admin View */
.admin-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.admin-section h2 {
    margin-bottom: 15px;
    color: #333;
}

.admin-list {
    display: grid;
    gap: 10px;
}

.admin-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid #667eea;
    transition: all 0.2s;
}

.draggable-user {
    cursor: move;
    position: relative;
}

.draggable-user:hover {
    background: #f0f0f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.draggable-user.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.draggable-user.drag-over {
    border-top: 3px solid #667eea;
}

.draggable-user.drag-over-above {
    border-top: 3px solid #667eea;
    margin-top: -3px;
    padding-top: 18px;
}

.draggable-user.drag-over-below {
    border-bottom: 3px solid #667eea;
    margin-bottom: -3px;
    padding-bottom: 18px;
}

.drag-handle {
    cursor: grab;
    padding: 5px 10px;
    margin-right: 10px;
    color: #999;
    font-size: 1.2em;
    user-select: none;
    display: flex;
    align-items: center;
    touch-action: none;
    flex-shrink: 0;
}

.drag-handle:active {
    cursor: grabbing;
}

.drag-handle:hover {
    color: #667eea;
}

.draggable-user:hover .drag-handle {
    color: #667eea;
}

.draggable-user .admin-item-actions {
    pointer-events: auto;
}

.draggable-user.dragging .admin-item-actions {
    pointer-events: none;
}

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

.admin-item-actions {
    display: flex;
    gap: 10px;
}

.error-message {
    background: #fee;
    color: #c33;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
}

/* Requests View */
.requests-controls {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.requests-list {
    display: grid;
    gap: 15px;
}

.request-item {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #667eea;
}

.request-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.request-status {
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
}

.request-status.pending {
    background: #ffc107;
    color: #333;
}

.request-status.approved {
    background: #28a745;
    color: white;
}

.request-status.denied {
    background: #dc3545;
    color: white;
}

.request-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.3s;
    max-height: 90vh;
    overflow-y: auto;
}

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

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    margin: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.close:hover,
.close:focus {
    color: #000;
    background: #f0f0f0;
    transform: scale(1.1);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 25px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
    transform: translateY(-2px);
}

.btn-warning {
    background: #ffc107;
    color: #212529;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

.btn-warning:hover {
    background: #e0a800;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

#todayBtn,
#refreshBtn {
    min-width: 100px;
    width: auto;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

/* Matrix View */
.matrix-view {
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 300px);
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.matrix-container {
    display: inline-block;
    min-width: 100%;
}

.matrix-header {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f8f9fa;
    border-bottom: 2px solid #e0e0e0;
}

.matrix-corner {
    width: 200px;
    min-width: 200px;
    padding: 15px;
    font-weight: 600;
    background: #667eea;
    color: white;
    position: sticky;
    left: 0;
    z-index: 11;
    border-right: 2px solid #5568d3;
}

.matrix-date-header {
    min-width: 100px;
    padding: 10px 5px;
    text-align: center;
    border-right: 1px solid #e0e0e0;
    background: #f8f9fa;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.matrix-date-header:hover {
    background: #e9ecef;
}

.matrix-date-header.today {
    background: #e3f2fd;
    border-bottom: 3px solid #667eea;
}

.matrix-day-name {
    font-size: 0.85em;
    color: #666;
    text-transform: uppercase;
}

.matrix-day-num {
    font-size: 1.1em;
    color: #333;
    margin-top: 5px;
}

.matrix-row {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
    transition: background 0.2s;
}

.matrix-row:hover {
    background: #f8f9fa;
}

.matrix-user-cell {
    width: 200px;
    min-width: 200px;
    padding: 12px 15px;
    background: white;
    border-right: 2px solid #e0e0e0;
    position: sticky;
    left: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    justify-content: center;
    font-weight: 600;
    color: #333;
    overflow: visible;
}

.matrix-user-name {
    font-size: 0.95em;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.user-tooltip-trigger {
    position: relative;
    cursor: help;
    display: inline-block;
    overflow: visible !important;
    width: 100%;
}

.user-tooltip-trigger > span {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.user-tooltip {
    display: none;
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background-color: #333;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9em;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    text-align: left;
    line-height: 1.6;
    min-width: 180px;
    max-width: 250px;
    word-wrap: break-word;
    white-space: normal;
}

.user-tooltip-trigger:hover .user-tooltip {
    display: block;
}

.user-tooltip::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: #333;
}

.matrix-user-badge {
    font-size: 0.8em;
    color: #666;
    margin-top: 3px;
}

.matrix-cell {
    min-width: 100px;
    width: 100px;
    padding: 12px 8px;
    text-align: center;
    border-right: 1px solid #e0e0e0;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85em;
    word-wrap: break-word;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60px;
}

.matrix-cell:hover {
    transform: scale(1.05);
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.matrix-cell.has-status {
    font-weight: 600;
}

.matrix-cell:empty {
    background: #fafafa;
}

.matrix-cell:empty:hover {
    background: #f0f0f0;
}

.matrix-cell {
    position: relative;
}

.matrix-cell.has-note {
    position: relative;
}

.note-indicator {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.2);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.matrix-cell:not(.has-status) .note-indicator {
    background: #667eea;
    border: 1px solid #5568d3;
}

/* Holiday styles */
.holiday-cell {
    font-size: 0.85em;
    font-weight: 600;
    color: #856404;
}

.holiday-day {
    background: #fff3cd !important;
    border-left: 3px solid #ffc107;
}

.holiday-indicator {
    font-size: 0.75em;
    font-weight: 600;
    color: #856404;
    text-align: center;
    margin-top: 3px;
    margin-bottom: 3px;
    padding: 2px 4px;
    background: rgba(255, 193, 7, 0.2);
    border-radius: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Responsive */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        padding: 15px 20px;
    }
    
    .header-left {
        flex-direction: column;
        gap: 10px;
    }
    
    .header-left h1 {
        font-size: 1.4em;
    }
    
    .header-right {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .header-right .btn {
        width: 100%;
    }
    
    .main-nav {
        padding: 0 10px;
        overflow-x: auto;
    }
    
    .nav-tab {
        padding: 12px 15px;
        font-size: 0.9em;
        white-space: nowrap;
    }
    
    .main-content {
        padding: 15px;
        /* Ensure main content doesn't prevent scrolling on mobile */
        overflow: visible;
        min-height: auto;
    }
    
    .banner-announcement {
        padding: 10px 15px;
        font-size: 0.9em;
    }
    
    .banner-icon {
        font-size: 1em;
    }
    
    .banner-text {
        font-size: 0.85em;
    }
    
    .calendar-controls {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }
    
    .view-selector {
        width: 100%;
        display: flex;
    }
    
    .view-btn {
        flex: 1;
        padding: 12px 15px;
        font-size: 0.9em;
    }
    
    .date-navigation {
        width: 100%;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    
    #currentPeriod {
        min-width: auto;
        width: 100%;
        text-align: center;
        font-size: 1em;
        margin: 5px 0;
    }
    
    .nav-btn {
        width: 45px;
        height: 45px;
        font-size: 1.3em;
    }
    
    #todayBtn,
    #refreshBtn {
        width: 100%;
        margin-top: 5px;
        min-width: auto;
    }
    
    .filters {
        width: 100%;
        margin-left: 0;
        flex-direction: column;
        gap: 10px;
    }
    
    .filter-select,
    .filter-input {
        width: 100%;
        padding: 12px;
        font-size: 1em;
    }
    
    .filter-input {
        min-width: auto;
    }
    
    .calendar-container {
        border-radius: 8px;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-x pan-y;
        max-height: calc(100vh - 180px);
        /* Ensure the calendar is scrollable on mobile */
        position: relative;
        overscroll-behavior: contain;
    }
    
    /* Month view calendar container - ensure proper scrolling */
    .calendar-container > .calendar-grid {
        overflow: visible;
        min-height: min-content;
        touch-action: auto;
    }
    
    /* Prevent vertical scrolling issues on mobile */
    .calendar-grid {
        touch-action: pan-x pan-y;
    }
    
    .calendar-grid {
        grid-template-columns: repeat(7, 1fr);
        font-size: 0.85em;
        min-width: 100%;
        gap: 0;
    }
    
    .day-header {
        padding: 10px 3px;
        font-size: 0.75em;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .calendar-day {
        min-height: 70px;
        padding: 4px 2px;
        font-size: 0.75em;
    }
    
    .day-number {
        font-size: 0.9em;
        margin-bottom: 2px;
        font-weight: 700;
    }
    
    .holiday-indicator {
        font-size: 0.65em;
        padding: 1px 2px;
        margin-top: 2px;
        margin-bottom: 2px;
    }
    
    .event-dot {
        font-size: 0.6em;
        padding: 2px 3px;
        margin-bottom: 2px;
        line-height: 1.2;
        max-width: 100%;
        word-break: break-word;
        overflow-wrap: break-word;
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .day-events {
        gap: 2px;
    }
    
    .matrix-view {
        max-height: calc(100vh - 400px);
    }
    
    .matrix-corner {
        width: 150px;
        min-width: 150px;
        padding: 10px;
        font-size: 0.85em;
    }
    
    .matrix-user-cell {
        width: 150px;
        min-width: 150px;
        padding: 10px;
        font-size: 0.85em;
    }
    
    .matrix-cell {
        min-width: 80px;
        width: 80px;
        padding: 8px 5px;
        font-size: 0.75em;
        min-height: 50px;
    }
    
    .matrix-date-header {
        min-width: 80px;
        padding: 8px 5px;
        font-size: 0.8em;
    }
    
    .admin-section {
        padding: 15px;
    }
    
    .admin-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .admin-item-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 20px 15px;
        max-height: 90vh;
        overflow-y: auto;
        border-radius: 15px;
        position: relative;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    
    .modal-content h2 {
        font-size: 1.3em;
        margin-bottom: 15px;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 10px;
        margin-top: 20px;
    }
    
    .form-actions .btn {
        width: 100%;
        padding: 12px;
        font-size: 1em;
    }
    
    /* Info modal specific styles for mobile */
    #infoModal .modal-content {
        padding: 25px 20px;
        text-align: center;
    }
    
    #infoModal #infoModalContent {
        padding: 15px 0;
    }
    
    #infoModal #infoModalMessage {
        font-size: 1em;
        line-height: 1.6;
        text-align: center;
        padding: 10px 0;
        word-wrap: break-word;
        overflow-wrap: break-word;
        margin: 0;
    }
    
    #infoModal .form-actions {
        margin-top: 25px;
        padding-top: 15px;
    }
    
    /* Close button improvements for mobile */
    .close {
        font-size: 32px;
        width: 36px;
        height: 36px;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Tooltip adjustments for mobile */
    .user-tooltip {
        min-width: 200px;
        max-width: 90vw;
        font-size: 0.85em;
        padding: 10px 12px;
    }
    
    .event-dot.user-tooltip-trigger .user-tooltip {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        max-width: min(280px, 85vw);
    }
    
    /* Matrix view mobile improvements */
    .matrix-view {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-height: calc(100vh - 350px);
        touch-action: pan-x pan-y;
    }
    
    .matrix-header {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-x;
    }
    
    /* Improve button touch targets on mobile */
    .btn {
        min-height: 44px;
        -webkit-tap-highlight-color: rgba(102, 126, 234, 0.2);
    }
    
    /* Improve filter select touch targets */
    .filter-select,
    .filter-input {
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    .app-header {
        padding: 10px 15px;
    }
    
    .header-left h1 {
        font-size: 1.2em;
    }
    
    .main-content {
        padding: 10px;
    }
    
    .calendar-controls {
        padding: 10px;
        gap: 10px;
    }
    
    .view-btn {
        padding: 10px 12px;
        font-size: 0.85em;
    }
    
    .nav-btn {
        width: 40px;
        height: 40px;
        font-size: 1.2em;
    }
    
    #currentPeriod {
        font-size: 0.9em;
    }
    
    .matrix-corner {
        width: 120px;
        min-width: 120px;
        padding: 8px;
        font-size: 0.75em;
    }
    
    .matrix-user-cell {
        width: 120px;
        min-width: 120px;
        padding: 8px;
        font-size: 0.75em;
    }
    
    .matrix-cell {
        min-width: 70px;
        width: 70px;
        padding: 6px 4px;
        font-size: 0.7em;
        min-height: 45px;
    }
    
    .matrix-date-header {
        min-width: 70px;
        padding: 6px 4px;
        font-size: 0.75em;
    }
    
    .calendar-day {
        min-height: 55px;
        padding: 3px 2px;
    }
    
    .day-number {
        font-size: 0.85em;
        margin-bottom: 1px;
    }
    
    .holiday-indicator {
        font-size: 0.6em;
        padding: 1px 2px;
    }
    
    .event-dot {
        font-size: 0.55em;
        padding: 2px 3px;
        line-height: 1.1;
        -webkit-line-clamp: 1;
    }
    
    .day-events {
        gap: 1px;
    }
    
    .day-header {
        padding: 8px 2px;
        font-size: 0.7em;
    }
    
    /* Modal improvements for small screens */
    .modal {
        padding: 10px;
    }
    
    .modal-content {
        width: 98%;
        margin: 2% auto;
        padding: 20px 15px;
        max-height: 95vh;
        border-radius: 12px;
        position: relative;
    }
    
    #infoModal .modal-content {
        padding: 30px 20px;
    }
    
    #infoModal #infoModalMessage {
        font-size: 0.95em;
        padding: 15px 0;
    }
    
    .modal-content h2 {
        font-size: 1.2em;
        margin-bottom: 12px;
    }
    
    /* Tooltip improvements for very small screens */
    .user-tooltip {
        max-width: 95vw;
        font-size: 0.8em;
        padding: 8px 10px;
    }
    
    .event-dot.user-tooltip-trigger .user-tooltip {
        max-width: min(250px, 90vw);
    }
    
    /* Calendar controls spacing */
    #refreshBtn {
        margin-top: 5px;
    }
    
    #todayBtn,
    #refreshBtn {
        width: 100%;
        min-width: auto;
    }
    
    /* Close button for very small screens */
    .close {
        font-size: 28px;
        width: 32px;
        height: 32px;
    }
    
    /* Improve touch targets */
    .event-dot,
    .calendar-day {
        -webkit-tap-highlight-color: rgba(102, 126, 234, 0.2);
    }
    
    /* Prevent text selection on calendar days in month view */
    .calendar-container > .calendar-grid .calendar-day {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
}

/* Timeframe and multiple events styling */
.matrix-cell.has-multiple-events {
    position: relative;
}

.matrix-cell.has-multiple-events::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    border: 1px solid currentColor;
}

.event-dot .time-range {
    font-size: 0.85em;
    opacity: 0.9;
    margin-left: 4px;
}

/* Ensure timeframe text is visible in matrix cells */
.matrix-cell.has-status {
    font-size: 0.85em;
    line-height: 1.2;
    padding: 4px 2px;
    white-space: normal;
    word-wrap: break-word;
}

/* Day entries modal styling */
.day-entry-item {
    transition: background-color 0.2s;
}

.day-entry-item:hover {
    background-color: #f0f0f0 !important;
}
