* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #F5F5F5;
    font-size: 14px;
}

.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667EEA 0%, #764BA2 100%);
}

.login-container {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.login-form h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #333;
    font-size: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: #667EEA;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
}

.header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #ddd;
}

.header-top {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.header h1 {
    color: #333;
    font-size: 1.5rem;
    text-align: center;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
}

.time-period {
    margin-bottom: 1.5rem;
    text-align: center;
}

.time-period h2 {
    color: #555;
    font-size: 1.25rem;
}

.alert {
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
    text-align: center;
}

.alert-info {
    background-color: #D1ECF1;
    border: 1px solid #BEE5EB;
    color: #0C5460;
}

.alert-error {
    background-color: #F8D7DA;
    border: 1px solid #F5C6CB;
    color: #721C24;
}

.alert-success {
    background-color: #D4EDDA;
    border: 1px solid #C3E6CB;
    color: #155724;
}

.attendance-table-container {
    overflow-x: auto;
    margin-bottom: 2rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    -webkit-overflow-scrolling: touch;
}

.attendance-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.attendance-table th,
.attendance-table td {
    padding: 0.5rem;
    text-align: center;
    border: 1px solid #ddd;
    font-size: 0.9rem;
}

.attendance-table th {
    background-color: #F8F9FA;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.employee-header {
    position: sticky;
    left: 0;
    background-color: #F8F9FA;
    z-index: 11;
    min-width: 120px;
}

.date-header {
    min-width: 100px;
}

.date-header.week-first { /* цвет для первых N недель */ }
.date-header.week-rest  { background-color: #EDF39E !important; /* цвет для остальных */ }

.employee-name-cell {
    position: sticky;
    left: 0;
    background-color: white;
    z-index: 5;
    min-width: 120px;
}

.employee-name {
    font-weight: 500;
    text-align: left;
    padding: 0.25rem;
}

.attendance-cell-container {
    min-width: 130px;
}

.attendance-cell {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-height: 80px;
    justify-content: center;
}

.attendance-btn {
    padding: 6px 10px;
    border: 2px solid #28A745;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.3s ease;
    width: 100%;
    text-align: center;
    min-height: 36px;
}

.attendance-btn.present {
    background-color: #28A745;
    color: white;
}

.attendance-btn.absent {
    background-color: white;
    color: #DC3545;
    border-color: #DC3545;
}

.attendance-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.attendance-btn:active:not(:disabled) {
    transform: translateY(0);
}

.absence-reason-container {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.absence-reason-select {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.8rem;
    min-height: 32px;
}

.other-reason-input {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.8rem;
}

.attendance-cell.disabled .attendance-btn {
    opacity: 0.6;
    cursor: not-allowed;
}

.attendance-cell.disabled .attendance-btn:hover {
    transform: none;
    box-shadow: none;
}

.employee-row.current-user {
    background-color: #E8F5E9 !important;
}

.employee-row.current-user .employee-name-cell {
    background-color: #D4EDDA;
    font-weight: 600;
    color: #155724;
}

.employee-row {
    transition: all 0.2s ease;
}

.employee-row:hover {
    background-color: #E8F9FA;
}

.you-indicator {
    font-size: 0.7em;
    color: #28A745;
    font-weight: 600;
    margin-left: 4px;
    background: rgba(40, 167, 69, 0.1);
    padding: 1px 4px;
    border-radius: 8px;
    border: 1px solid rgba(40, 167, 69, 0.3);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 2rem;
    justify-content: center;
}

#logoutBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    line-height: 1.2;
    padding: 0.5rem 1rem;
    text-decoration: none;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 5px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.3s;
    min-height: 40px;
    flex: 1;
    min-width: 140px;
    text-align: center;
}

.btn-primary {
    background-color: #007bff;
    color: white;
}

.btn-primary:hover {
    background-color: #0056b3;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #545b62;
}

.btn-success {
    background-color: #28a745;
    color: white;
}

.btn-warning {
    background-color: #ffc107;
    color: #212529;
}

.btn-info {
    background-color: #17a2b8;
    color: white;
}

.legend {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    font-size: 0.9rem;
    text-align: left; /* Выравнивание по левому краю */
}

.legend h3 {
    margin-bottom: 0.75rem;
    color: #333;
    text-align: left;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.5rem;
}

.status-present,
.status-absent {
    padding: 4px 8px;
    border: 2px solid #28a745;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    width: 90px;
    text-align: center;
}

.status-present {
    background-color: #28a745;
    color: white;
}

.status-absent {
    background-color: white;
    color: #dc3545;
    border-color: #dc3545;
}

/* Админ-панель стили */
.admin-panel {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 1.5rem;
}

.admin-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.admin-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.admin-section h4 {
    margin-bottom: 0.75rem;
    color: #555;
    font-size: 1rem;
}

.admin-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.checkbox-row {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.input-button-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.input-button-group .form-control {
    flex: 1;
    min-width: 60px;
    padding: 0.5rem;
}

.result-message {
    margin-top: 0.5rem;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

/* Мобильные стили */
@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }

    .header h1 {
        font-size: 1.25rem;
    }

    .user-info {
        font-size: 0.9rem;
    }

    .time-period h2 {
        font-size: 1.1rem;
    }

    .attendance-table th,
    .attendance-table td {
        padding: 0.35rem;
        font-size: 0.8rem;
    }

    .employee-header,
    .employee-name-cell {
        min-width: 100px;
    }

    .date-header {
        min-width: 90px;
    }

    .date-header.week-first { /* цвет для первых N недель */ }
    .date-header.week-rest  { background-color: #EDF39E !important; /* цвет для остальных */ }

    .attendance-cell-container {
        min-width: 110px;
    }

    .attendance-btn {
        padding: 4px 6px;
        font-size: 0.75rem;
        min-height: 32px;
    }

    .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
        min-width: 120px;
    }

    .admin-panel {
        padding: 0.75rem;
    }

    .admin-section h4 {
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 13px;
    }

    .header-top {
        gap: 0.75rem;
    }

    .header h1 {
        font-size: 1.1rem;
    }

    .time-period h2 {
        font-size: 1rem;
    }

    .attendance-table {
        min-width: 500px;
    }

    .attendance-table th,
    .attendance-table td {
        padding: 0.25rem;
        font-size: 0.75rem;
    }

    .employee-header,
    .employee-name-cell {
        min-width: 80px;
    }

    .date-header {
        min-width: 70px;
        font-size: 0.7rem;
    }

    .date-header.week-first { /* цвет для первых N недель */ }
    .date-header.week-rest  { background-color: #EDF39E !important; /* цвет для остальных */ }

    .attendance-cell-container {
        min-width: 90px;
    }

    .attendance-btn {
        font-size: 0.7rem;
        min-height: 28px;
    }

    .absence-reason-select,
    .other-reason-input {
        font-size: 0.7rem;
        padding: 3px 4px;
    }

    .btn {
        min-width: 100px;
        font-size: 0.8rem;
        padding: 0.35rem 0.6rem;
    }

    .actions {
        gap: 0.35rem;
    }

    .legend {
        padding: 0.75rem;
    }

    .legend h3 {
        font-size: 0.95rem;
    }

    .status-present,
    .status-absent {
        width: 80px;
        font-size: 0.75rem;
    }

    .admin-panel h3 {
        font-size: 1.1rem;
    }
}

/* Стили для выходных дней */
.weekend-day {
    background-color: #fff3cd !important;
}

.weekend-day::before {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 6px;
    height: 6px;
    background-color: #ffc107;
    border-radius: 50%;
}

.attendance-btn.weekend {
    background-color: #ffeaa7 !important;
    border-color: #fdcb6e !important;
    color: #2d3436 !important;
}

.attendance-cell.weekend-disabled .attendance-btn {
    opacity: 0.7;
    cursor: not-allowed;
}

.attendance-cell.weekend-disabled .absence-reason-select {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Улучшения для очень маленьких экранов */
@media (max-width: 360px) {
    .container {
        padding: 0.25rem;
    }

    .btn {
        min-width: 90px;
        font-size: 0.75rem;
        padding: 0.3rem 0.5rem;
    }

    .user-info {
        font-size: 0.8rem;
    }
}

/* Базовые стили для кнопки сохранения */
#saveBtn {
    transition: all 0.3s ease;
    position: relative;
}

/* Стили по умолчанию (когда нет изменений) */
.save-btn-default {
    background-color: #6c757d !important;
    color: white;
    transform: none;
    box-shadow: none;
}

/* Активное состояние при наличии изменений */
.save-btn-active {
    background-color: #28a745 !important;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
    animation: pulse 2s infinite;
    font-weight: 600;
}

/* Плавающий эффект для десктопов */
@media (min-width: 769px) {
    .save-btn-active {
        position: relative;
        z-index: 100;
    }

    /* Создаем эффект "всплывания" над другими элементами */
    .save-btn-active:hover {
        transform: translateY(-3px) scale(1.02);
        box-shadow: 0 6px 16px rgba(40, 167, 69, 0.5);
    }
}

/* Пульсирующая анимация */
@keyframes pulse {
    0% {
        box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(40, 167, 69, 0.7);
    }
    100% {
        box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
    }
}

/* На мобильных устройствах делаем кнопку фиксированной внизу */
@media (max-width: 768px) {
    .actions {
        position: relative;
        padding-bottom: 0;
    }

    .save-btn-active {
        position: fixed;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%) translateY(-2px);
        width: 90%;
        max-width: 300px;
        z-index: 1000;
        box-shadow: 0 4px 20px rgba(40, 167, 69, 0.6);
        border: 2px solid white;
        animation: mobile-pulse 2s infinite;
        font-size: 1rem;
        padding: 0.75rem;
    }

    /* Увеличиваем отступ снизу для контейнера, чтобы контент не перекрывался фиксированной кнопкой */
    .container {
        padding-bottom: 80px;
    }

    /* Специальная анимация для мобильных */
    @keyframes mobile-pulse {
        0% {
            box-shadow: 0 4px 15px rgba(40, 167, 69, 0.5);
        }
        50% {
            box-shadow: 0 4px 25px rgba(40, 167, 69, 0.8);
        }
        100% {
            box-shadow: 0 4px 15px rgba(40, 167, 69, 0.5);
        }
    }
}

/* Для очень маленьких экранов */
@media (max-width: 480px) {
    .save-btn-active {
        bottom: 15px;
        width: 95%;
        font-size: 0.9rem;
        padding: 0.7rem;
    }

    .container {
        padding-bottom: 70px;
    }
}

/* Дополнительный визуальный индикатор */
.save-btn-active::before {
    content: '●';
    display: inline-block;
    margin-right: 8px;
    animation: blink 1.5s infinite;
    font-size: 0.8em;
}

@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0.3;
    }
}

/* Плавное появление/исчезновение */
#saveBtn {
    transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Стили для кастомного чекбокса */
.custom-checkbox {
    display: block;
    position: relative;
    padding-left: 35px;
    margin-bottom: 12px;
    cursor: pointer;
    font-size: 16px;
    user-select: none;
}

/* Скрываем нативный чекбокс */
.custom-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

/* Создаем кастомный чекбокс */
.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 25px;
    width: 25px;
    background-color: #eee;
    border-radius: 4px;
    border: 2px solid #ccc;
    transition: all 0.3s ease;
}

/* Добавляем галочку при выборе */
.custom-checkbox input:checked ~ .checkmark:after {
    content: "";
    position: absolute;
    display: block;
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
}

/* Меняем цвет при выборе */
.custom-checkbox input:checked ~ .checkmark {
    background-color: #007bff;
    border-color: #007bff;
}

/* Стиль для текста метки */
.checkbox-label {
    vertical-align: middle;
    margin-left: 5px;
}