* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: #f0f2f5;
    padding: 20px;
    color: #1a2c3e;
    overflow-x: hidden;
    overflow-y: auto;
}

.dashboard {
    max-width: 100%;
    margin: 0 auto;
}

.auto-resize {
    resize: none;
    overflow: hidden;
    min-height: 60px;
}

/* =========================================
   NAVBAR
========================================= */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
    background: #fff;
    padding: 8px 20px;
    border-radius: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 150px;
    height: 70px;
    background: #fff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-text {
    display: none;
}

/* =========================================
   MONTH SELECTOR
========================================= */
.month-selector {
    display: flex;
    gap: 8px;
    align-items: center;
    background: #f5f7fb;
    padding: 4px 12px;
    border-radius: 40px;
}

.month-selector button {
    background: none;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    color: #5a6e85;
}

.month-year-container {
    position: relative;
    display: inline-block;
}

.month-year {
    font-weight: 500;
    font-size: .8rem;
    min-width: 120px;
    text-align: center;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 20px;
    transition: background .2s;
}

.month-year:hover {
    background: #e0e5ec;
}

.month-year-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .15);
    padding: 12px;
    z-index: 200;
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 4px;
    min-width: 250px;
}

.month-year-dropdown select {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #e2e9f2;
    font-family: 'Inter', sans-serif;
    font-size: .7rem;
    flex: 1;
}

.apply-btn {
    padding: 6px 12px;
    border-radius: 8px;
    border: none;
    background: #1e2f3f;
    color: #fff;
    cursor: pointer;
    font-size: .7rem;
}

/* =========================================
   ADMIN
========================================= */
.admin-area {
    display: flex;
    gap: 8px;
    align-items: center;
}

.role-badge {
    background: #eef2f8;
    padding: 14px 10px;
    border-radius: 40px;
    font-size: .65rem;
}

.admin-btn {
    background: #eef2f8;
    border: none;
    padding: 15px 16px;
    border-radius: 40px;
    font-size: .7rem;
    cursor: pointer;
}

.admin-btn.active {
    background: #d9e2ef;
}

/* =========================================
   CALENDAR
========================================= */
.calendar-container {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .05);
    overflow-x: auto;
    overflow-y: auto;
    position: relative;
    max-height: calc(100vh - 150px);
    -webkit-overflow-scrolling: touch;
}

/* Убираем скроллбар у body, оставляем только в контейнере */
body {
    overflow-y: auto;
}

.calendar-table {
    width: 100%;
    min-width: 900px;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    font-size: .65rem;
}

/* Скрываем скроллбар в отчётах */
#reportModal .modal-card {
    overflow-y: visible;
}

#reportModal .modal-card::-webkit-scrollbar {
    display: none;
}

#reportModal .modal-card {
    scrollbar-width: none;
}

/* =========================================
   TABLE CELLS
========================================= */
.calendar-table th,
.calendar-table td {
    border: .5px solid #d5dce5;
    vertical-align: top;
    overflow: hidden;
}

.calendar-table th {
    padding: 8px 6px;
    font-weight: 600;
    font-size: .65rem;
    text-align: center;
    background: #f8fafc;
    border-bottom: 1.5px solid #aeb7c2;
    position: sticky;
    top: 0;
    z-index: 20;
}

/* =========================================
   HEADER COLORS
========================================= */
.calendar-table th:nth-child(3) { background: #ffe5e5; }
.calendar-table th:nth-child(4) { background: #e5f4ff; }
.calendar-table th:nth-child(5) { background: #fff9d9; }
.calendar-table th:nth-child(6) { background: #e8ffe8; }
.calendar-table th:nth-child(7) { background: #f3e5ff; }
.calendar-table th:nth-child(8) { background: #ffe5f1; }
.calendar-table th:nth-child(9) { background: #ede1ff; }
.calendar-table th:last-child { background: #4a90e2 !important; color: #fff; }

/* =========================================
   STICKY COLUMNS
========================================= */
.calendar-table th:first-child {
    left: 0;
    z-index: 30;
}
.calendar-table th:nth-child(2) {
    left: 65px;
    z-index: 29;
}

.date-cell {
    position: sticky;
    left: 0;
    z-index: 10;
    background: #fff;
    text-align: center;
    vertical-align: middle;
    width: 65px;
    min-width: 65px;
}

.time-cell {
    position: sticky;
    left: 65px;
    z-index: 9;
    background: #fff;
    text-align: center;
    vertical-align: middle;
    width: 80px;
    min-width: 80px;
    font-size: .6rem;
    font-weight: 500;
    color: #4a627a;
}

/* =========================================
   DATE
========================================= */
.date-number {
    font-size: .8rem;
    font-weight: 700;
}

.date-weekday {
    font-size: .5rem;
    color: #7f8c9e;
    margin-top: 2px;
}

/* =========================================
   CELLS
========================================= */
.event-cell {
    padding: 2px;
    background: #fff;
    vertical-align: top;
    min-width: 150px;
    height: 32px;
}

.empty-cell {
    cursor: pointer;
    min-height: 28px;
}

.empty-cell:hover {
    background: #fff3cf;
}

/* =========================================
   EVENTS - ИСПРАВЛЕНИЯ
========================================= */
.event-block {
    position: relative;
    border-radius: 6px;
    padding: 4px;
    border-left: 2px solid;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
    transition: .15s ease;
    cursor: pointer;
    font-size: .6rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 38px;
}

.event-block:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
}

/* Название мероприятия - перенос длинных слов */
.event-title {
    font-weight: 650;
    font-size: .65rem;
    line-height: 1.25;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 2px;
}

/* Время и участники в одной строке */
.event-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-direction: row;
    gap: 4px;
    margin-top: 2px;
}

.event-time {
    font-size: .5rem;
    color: #1a2c3e;
    white-space: nowrap;
}

.event-participants {
    font-size: .5rem;
    color: #1a2c3e;
    white-space: nowrap;
    margin-left: auto;
}

/* Если мероприятие маленькое - делаем компактнее */
.event-block:has(.event-title:only-child) .event-details {
    margin-top: 0;
}

/* =========================================
   TOOLTIPS
========================================= */
.event-block[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    left: 0;
    bottom: calc(100% + 6px);
    background: #1e2a36;
    color: #ffecb3;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: .68rem;
    line-height: 1.35;
    width: max-content;
    max-width: 240px;
    white-space: normal;
    word-break: break-word;
    z-index: 999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .22);
    pointer-events: none;
}

/* =========================================
   EVENT COLORS
========================================= */
.event-color-1 { border-left-color: #8ba3c2; background: #A5B8D0; }
.event-color-2 { border-left-color: #4ab86a; background: #63DC90; }
.event-color-3 { border-left-color: #e6d48a; background: #FFF2CC; }
.event-color-4 { border-left-color: #6bc0c6; background: #8FD7DC; }
.event-color-5 { border-left-color: #d47070; background: #EA9999; }

/* =========================================
   WEEKEND
========================================= */
.weekend-date {
    background: #ffeae5;
}

.weekend-date .date-number {
    color: #c25a3a;
}

.weekend-row-bg td,
.weekend-row-bg th {
    background: #fff5f2 !important;
}

/* =========================================
   SEPARATOR
========================================= */
.day-separator td {
    border-top: 1.5px solid #25364a !important;
}

/* =========================================
   MODAL
========================================= */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, .4);
    backdrop-filter: blur(3px);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-card {
    background: #fff;
    border-radius: 28px;
    max-width: 550px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 0 20px 35px -12px rgba(0, 0, 0, .2);
}

/* Узкий скроллбар в модальном окне - НЕ выходит за скругления */
.modal-card::-webkit-scrollbar {
    width: 4px;
}

.modal-card::-webkit-scrollbar-track {
    background: #eef2f8;
    border-radius: 10px;
    margin: 20px 0;
}

.modal-card::-webkit-scrollbar-thumb {
    background: #b4c0d0;
    border-radius: 10px;
}

.modal-card::-webkit-scrollbar-thumb:hover {
    background: #8f9eb2;
}

.modal-card {
    scrollbar-width: thin;
    scrollbar-color: #b4c0d0 #eef2f8;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-weight: 600;
    font-size: .95rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #8f9eb2;
}

/* =========================================
   FORM - ВОЗВРАЩАЕМ НОРМАЛЬНЫЙ РАЗМЕР
========================================= */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.field.full {
    grid-column: span 2;
}

.field label {
    font-size: .55rem;
    font-weight: 500;
    color: #4b6b89;
}

.field input,
.field select,
.field textarea {
    padding: 8px 12px;
    border-radius: 16px;
    border: 1px solid #e2e9f2;
    font-family: 'Inter', sans-serif;
    font-size: .7rem;
    width: 100%;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

.field textarea {
    resize: vertical;
    min-height: 60px;
}

/* =========================================
   BUTTONS
========================================= */
.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #e2e9f2;
}

.btn {
    padding: 8px 16px;
    border-radius: 40px;
    font-weight: 500;
    font-size: .65rem;
    border: none;
    cursor: pointer;
    background: #eef2f8;
    transition: .2s;
}

.btn:hover {
    opacity: .85;
}

.btn-primary {
    background: #1e2f3f;
    color: #fff;
}

.btn-danger {
    background: #f3e2e2;
    color: #b16262;
}

/* =========================================
   MISC
========================================= */
.footer-note {
    text-align: center;
    margin-top: 12px;
    font-size: .55rem;
    color: #8d9bb0;
}

i {
    margin-right: 3px;
}

.location-subtitle {
    font-size: .55rem;
    font-weight: normal;
    display: block;
    color: #6c7a8e;
    margin-top: 3px;
}

.online-cell {
    background: #e8f4fd;
}

.locked-cell {
    background: #ffd9d9;
    color: #b33;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

/* =========================================
   iOS СТИЛЬ ЧЕКБОКСОВ 
========================================= */
.checkbox-ios {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    grid-column: span 2;
    height: 28px;
    position: relative;
    cursor: pointer;
    margin: 4px 0;
}

.checkbox-ios span:first-child {
    font-size: 0.75rem;
    font-weight: 500;
    color: #4b6b89;
}

.checkbox-ios .checkbox-ios-switch {
    position: relative;
    display: inline-block;
    box-sizing: border-box;
    width: 50px;
    height: 26px;
    border: 1px solid rgba(0, 0, 0, .1);
    border-radius: 25px;
    vertical-align: top;
    background: #eee;
    transition: .2s;
    flex-shrink: 0;
}

.checkbox-ios .checkbox-ios-switch:before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .2);
    transition: .2s;
}

.checkbox-ios input[type=checkbox] {
    display: block;
    width: 0;
    height: 0;
    position: absolute;
    z-index: -1;
    opacity: 0;
}

.checkbox-ios input[type=checkbox]:checked + .checkbox-ios-switch {
    background: limegreen;
}

.checkbox-ios input[type=checkbox]:checked + .checkbox-ios-switch:before {
    transform: translateX(24px);
}

.checkbox-ios input[type="checkbox"]:not(:disabled) + .checkbox-ios-switch {
    cursor: pointer;
    border-color: rgba(0, 0, 0, .3);
}

.checkbox-ios input[type=checkbox]:disabled + .checkbox-ios-switch {
    filter: grayscale(70%);
    border-color: rgba(0, 0, 0, .1);
}

/* =========================================
   ПОДСКАЗКИ КОММЕНТАРИЕВ 
========================================= */
.event-block {
    position: relative;
    cursor: pointer;
    overflow: visible !important;
    z-index: 1;
}

.event-block[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1e2a36;
    backdrop-filter: blur(8px);
    color: #ffecb3;
    font-size: 0.7rem;
    padding: 8px 12px;
    border-radius: 8px;
    white-space: normal;
    word-wrap: break-word;
    word-break: break-word;
    max-width: 280px;
    min-width: 120px;
    z-index: 999999 !important;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    margin-bottom: 8px;
    line-height: 1.4;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.event-block:hover {
    z-index: 99999;
}

/* Убираем overflow hidden который может обрезать подсказку */
.calendar-table td {
    overflow: visible !important;
}

.calendar-container {
    overflow-x: auto !important;
    overflow-y: auto !important;
}

/* Для мобильных - подсказки при нажатии */
@media (hover: none) and (pointer: coarse) {
    .event-block[data-tip]:active::after {
        content: attr(data-tip);
        position: absolute;
        bottom: 100%;
        left: 50%;
        transform: translateX(-50%);
        background: #1e2a36;
        backdrop-filter: blur(8px);
        color: #ffecb3;
        font-size: 0.65rem;
        padding: 6px 10px;
        border-radius: 8px;
        white-space: normal;
        word-wrap: break-word;
        max-width: 200px;
        z-index: 999999;
        pointer-events: none;
    }
}

/* =========================================
   ДОПОЛНИТЕЛЬНЫЕ СТИЛИ
========================================= */
#additionalLocationsContainer label {
    transition: background 0.2s;
}

#additionalLocationsContainer label:hover {
    background: #e0e5ec;
}

#additionalLocationsContainer input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin: 0;
}

#additionalDaysContainer label {
    transition: background 0.2s;
}

#additionalDaysContainer label:hover {
    background: #e0e5ec;
}

#additionalDaysContainer input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin: 0;
}

#addLocationsBtn, #addDaysBtn {
    transition: all 0.2s;
}

#addLocationsBtn:hover, #addDaysBtn:hover {
    opacity: 0.85;
}

/* =========================================
   МОБИЛЬНАЯ ВЕРСИЯ
========================================= */
@media (max-width: 768px) {
    body {
        padding: 8px;
    }

    .navbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px;
        border-radius: 16px;
    }

    .logo {
        justify-content: center;
    }

    .logo-icon {
        width: 90px;
        height: 45px;
    }

    .month-selector {
        width: 100%;
        justify-content: center;
    }

    .admin-area {
        width: 100%;
        justify-content: center;
    }

    .admin-btn,
    .role-badge {
        flex: 1;
        text-align: center;
        padding: 10px;
        font-size: .7rem;
    }

    .calendar-container {
        border-radius: 14px;
    }

    .calendar-table {
        min-width: 920px;
    }

    .calendar-table th {
        font-size: .55rem;
        padding: 6px 4px;
    }

    .event-title {
        font-size: .6rem;
        -webkit-line-clamp: 3;
    }

    .event-time,
    .event-participants {
        font-size: .45rem;
    }

    .modal {
        padding: 10px;
        align-items: flex-start;
        overflow-y: auto;
    }

    .modal-card {
        width: 100%;
        max-width: 100%;
        border-radius: 18px;
        padding: 14px;
        margin-top: 20px;
        max-height: none;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .field.full {
        grid-column: span 1;
    }

    .modal-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        padding: 12px;
    }

    .checkbox-ios .checkbox-ios-switch {
        width: 40px;
        height: 22px;
    }

    .checkbox-ios .checkbox-ios-switch:before {
        width: 16px;
        height: 16px;
        top: 2px;
        left: 2px;
    }

    .checkbox-ios input[type=checkbox]:checked + .checkbox-ios-switch:before {
        transform: translateX(18px);
    }

    .checkbox-ios span:first-child {
        font-size: 0.75rem;
    }

    .form-grid {
        grid-template-columns: 1fr !important;
    }

    .checkbox-ios {
        grid-column: span 1 !important;
    }

    .field.full {
        grid-column: span 1 !important;
    }
}

/* =========================================
   МАЛЕНЬКИЕ ТЕЛЕФОНЫ
========================================= */
@media (max-width: 480px) {
    .calendar-table {
        min-width: 860px;
    }

    .event-title {
        font-size: .52rem;
    }

    .event-time,
    .event-participants {
        font-size: .42rem;
    }

    .month-selector button {
        width: 30px;
        height: 30px;
    }
}

/* =========================================
   ОТЧЁТ - ПОЛНОЕ ИСПРАВЛЕНИЕ
========================================= */

#reportModal .modal-card {
    max-width: 95vw;
    width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 85vh;
    padding: 15px;
}

/* Стили скролла для отчёта */
#reportModal .modal-card::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

#reportModal .modal-card::-webkit-scrollbar-track {
    background: #eef2f8;
    border-radius: 10px;
}

#reportModal .modal-card::-webkit-scrollbar-thumb {
    background: #b4c0d0;
    border-radius: 10px;
}

/* Таблица отчёта */
#reportModal table {
    width: 100%;
    min-width: 550px;
    border-collapse: collapse;
    font-size: 0.7rem;
}

#reportModal th,
#reportModal td {
    padding: 8px 10px;
    border: 1px solid #ddd;
    text-align: left;
    vertical-align: middle;
}

#reportModal th {
    background: #f8fafc;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

#reportModal input[type="number"] {
    width: 70px;
    padding: 5px;
    text-align: center;
    border-radius: 8px;
    border: 1px solid #cfdde8;
}

/* Мобильная версия отчёта */
@media (max-width: 768px) {
    #reportModal .modal-card {
        padding: 10px;
        max-width: 98vw;
    }
    
    #reportModal table {
        min-width: 480px;
        font-size: 0.65rem;
    }
    
    #reportModal th,
    #reportModal td {
        padding: 6px 8px;
    }
    
    #reportModal input[type="number"] {
        width: 55px;
        padding: 3px;
        font-size: 0.6rem;
    }
}