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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 30px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.header h1 {
    font-size: 28px;
    color: #333;
}

.management-link {
    font-size: 13px;
    color: #9ca3af;
    text-decoration: none;
    transition: color 0.2s;
}

.management-link:hover {
    color: #6b7280;
    text-decoration: underline;
}

.controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-success {
    background: #10b981;
    color: white;
}

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

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

.btn-danger:hover {
    background: #dc2626;
}

.month-nav {
    display: flex;
    gap: 15px;
    align-items: center;
    font-size: 18px;
    font-weight: 600;
}

.month-nav button {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: none;
    background: #f3f4f6;
    cursor: pointer;
    font-size: 18px;
}

.month-nav button:hover {
    background: #e5e7eb;
}

.calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: #e5e7eb;
    border: 1px solid #e5e7eb;
    margin-bottom: 20px;
}

.calendar-header {
    background: #f9fafb;
    padding: 12px;
    text-align: center;
    font-weight: 600;
    color: #6b7280;
    font-size: 14px;
}

.calendar-day {
    background: white;
    min-height: 120px;
    padding: 8px;
    cursor: pointer;
    transition: background 0.2s;
    overflow: hidden;
}

.calendar-day:hover {
    background: #f9fafb;
}

.calendar-day.other-month {
    opacity: 0.3;
}

.calendar-day.today {
    background: #eff6ff;
}

.day-number {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 5px;
}

.event-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 6px;
    cursor: grab;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: all 0.2s;
}

.event-item:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

.event-item:active {
    cursor: grabbing;
}

.event-header {
    display: block;
    margin-bottom: 4px;
    /* Ограничение до 2 строк для всего блока */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.event-title {
    color: #1f2937;
    font-weight: 600;
    font-size: 14px;
    word-break: break-word;
    margin-right: 5px;
    display: inline;
}

.event-time {
    color: #6b7280;
    font-size: 12px;
    white-space: nowrap;
    display: inline;
}

.event-categories {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.event-category-badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.event-item:hover .event-category-badge {
    opacity: 1;
}

.categories-panel {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 15px;
    background: #f9fafb;
    border-radius: 8px;
}

.category-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    color: white;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.category-badge:hover {
    opacity: 0.8;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h2 {
    font-size: 22px;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6b7280;
}

.close-btn:hover {
    color: #374151;
}

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

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

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.category-autocomplete {
    position: relative;
}

.category-search-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
}

.category-dropdown {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    margin-bottom: 4px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.dropdown-item {
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: #f3f4f6;
}

.dropdown-item.disabled {
    color: #9ca3af;
    cursor: default;
}

.dropdown-item.disabled:hover {
    background: white;
}

.category-color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.selected-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    min-height: 30px;
}

.selected-category-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 13px;
    color: white;
    font-weight: 500;
}

.remove-category {
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.remove-category:hover {
    opacity: 1;
}

.color-picker {
    display: flex;
    gap: 10px;
    align-items: center;
}

.color-picker input[type="color"] {
    width: 50px;
    height: 40px;
    border: none;
    cursor: pointer;
}

.share-link {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding: 15px;
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 8px;
}

.share-link input {
    flex: 1;
    padding: 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
}

.drag-over {
    background: #dbeafe !important;
    border: 2px dashed #3b82f6 !important;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #f9fafb;
    border-radius: 6px;
    margin-bottom: 10px;
}

.category-name-input {
    font-weight: 600;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .header {
        flex-direction: column;
        align-items: stretch;
    }

    .header h1 {
        font-size: 22px;
        text-align: center;
    }

    .controls {
        flex-direction: column;
        width: 100%;
    }

    .month-nav {
        justify-content: center;
        font-size: 16px;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .calendar {
        grid-template-columns: 1fr;
        gap: 8px;
        background: transparent;
        border: none;
    }

    .calendar-header {
        display: none;
    }

    .calendar-day {
        min-height: auto;
        max-height: none;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 12px;
    }

    .calendar-day.other-month {
        display: none;
    }

    .day-number {
        font-size: 16px;
        margin-bottom: 8px;
        padding-bottom: 8px;
        border-bottom: 1px solid #e5e7eb;
    }

    .event-item {
        padding: 8px;
        margin-bottom: 6px;
    }

    .event-title {
        font-size: 13px;
        white-space: normal;
    }

    .share-link {
        flex-direction: column;
    }

    .share-link input {
        width: 100%;
    }

    .modal-content {
        width: 95%;
        padding: 20px;
    }

    .categories-panel {
        justify-content: center;
    }
}

.user-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    background: #f3f4f6;
    border-radius: 20px;
    font-size: 13px;
    color: #374151;
    font-weight: 500;
}

.btn-auth {
    padding: 6px 14px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background 0.2s;
}

.btn-auth:hover {
    background: #5568d3;
}