* {
    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: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

header p {
    font-size: 1.2em;
    opacity: 0.9;
}

main {
    padding: 30px;
    flex: 1;
}

/* ФИО секция */
.fio-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 25px;
    border: 2px solid #e9ecef;
}

.form-group-inline {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.form-group-inline label {
    font-weight: 600;
    color: #2c3e50;
    min-width: 80px;
}

.form-group-inline input {
    flex: 1;
    min-width: 300px;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group-inline input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* Заголовок мероприятий */
.events-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #667eea;
}

.events-header h2 {
    color: #2c3e50;
    font-size: 1.8em;
}

/* Контейнер мероприятий */
#eventsContainer {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 25px;
}

/* Карточка мероприятия */
.event-card {
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
    transition: all 0.3s;
}

.event-card:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.12);
    border-color: #667eea;
}

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e9ecef;
}

.event-number {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 6px 15px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.95em;
}

.btn-remove {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-remove:hover {
    background: #c0392b;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(231, 76, 60, 0.3);
}

/* Сетка полей мероприятия */
.event-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
}

.grid-item {
    display: flex;
    flex-direction: column;
}

.grid-item.full-width {
    grid-column: 1 / -1;
}

.grid-item label {
    font-size: 0.85em;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
}

.grid-item input[type="text"],
.grid-item select,
.grid-item textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.grid-item input:focus,
.grid-item select:focus,
.grid-item textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.grid-item textarea {
    resize: vertical;
    min-height: 40px;
}

.grid-item .error {
    font-size: 12px;
    color: #e74c3c;
    margin-top: 4px;
    min-height: 16px;
}

/* Секция даты */
.date-section {
    display: flex;
    flex-direction: column;
}

.date-options {
    display: flex;
    gap: 10px;
    align-items: center;
}

.date-options select {
    min-width: 150px;
}

.date-inputs-container {
    margin-top: 8px;
}

.date-input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.range-pair {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.date-input {
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    width: 100%;
}

.date-input[readonly] {
    background: #f8f9fa;
    cursor: not-allowed;
}

/* Горизонтальное расположение промежутка дат */
.range-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.range-inline input {
    flex: 1;
    min-width: 140px;
}

.date-separator {
    font-weight: bold;
    color: #555;
    white-space: nowrap;
}

.range-errors {
    display: flex;
    gap: 15px;
    margin-top: 8px;
}

.range-errors .error {
    flex: 1;
    font-size: 12px;
    color: #e74c3c;
    min-height: 16px;
    display: block;
}

/* Кнопки действий */
.btn-primary,
.btn-success,
.btn-secondary {
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn-success {
    background: linear-gradient(135deg, #27ae60 0%, #219653 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.4);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.6);
}

/* Форма и действия */
.form-actions {
    margin-top: 30px;
    text-align: center;
}

.form-actions-bottom {
    text-align: center;
    margin-top: 20px;
    padding: 15px 0;
}

/* Сообщения */
.messages {
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.alert {
    padding: 15px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.alert i {
    font-size: 1.2em;
    min-width: 24px;
}

.alert-success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.alert-error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.alert {
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.alert.show {
    opacity: 1;
    transform: translateY(0);
}

/* Иконки для сообщений */
.alert-success i::before { content: "✓"; }
.alert-error i::before { content: "✗"; }

footer {
    background: #2c3e50;
    color: white;
    text-align: center;
    padding: 20px;
    font-size: 14px;
    margin-top: auto;
}

/* Адаптивность */
@media (max-width: 1200px) {
    .event-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
    
    .form-group-inline input {
        min-width: 250px;
    }
}

@media (max-width: 992px) {
    .container {
        padding: 15px;
    }
    
    .fio-section {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    main {
        padding: 20px;
    }
    
    .event-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
    
    .date-options {
        flex-direction: column;
        align-items: stretch;
    }
    
    .events-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px !important;
        width: 100% !important;
    }
    
    .fio-section {
        padding: 10px !important;
    }
    
    main {
        padding: 15px !important;
    }
    
    .event-card {
        padding: 10px !important;
        margin: 0 5px !important;
    }
    
    .form-group-inline input {
        min-width: 100% !important;
    }
    
    .grid-item input[type="text"],
    .grid-item select,
    .grid-item textarea {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .event-grid {
        grid-template-columns: 1fr !important;
    }
}

input, select, textarea, .grid-item {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

@media (max-width: 480px) {
    .container {
        padding: 5px !important;
    }
    
    .form-group-inline {
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    .event-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    
    .date-options {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    .range-inline {
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    .date-separator {
        display: none !important;
    }
}

/* Устраняем горизонтальную прокрутку */
body {
    overflow-x: hidden !important;
}

/* Добавляем для контейнера, чтобы он занимал всю ширину экрана на мобильных */
.container {
    width: 100% !important;
    padding: 10px !important;
}

@media (max-width: 320px) {
    .container {
        padding: 5px 8px !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .fio-section,
    .event-card {
        padding: 8px 10px !important;
        margin: 0 5px !important;
    }
    
    .form-group-inline input,
    .grid-item input[type="text"],
    .grid-item select,
    .grid-item textarea {
        width: 100% !important;
        max-width: 100% !important;
        padding: 8px 10px !important;
        font-size: 13px !important;
    }
    
    .btn-primary,
    .btn-success {
        width: 100% !important;
        padding: 10px 15px !important;
        font-size: 14px !important;
    }
    
    .event-number {
        font-size: 0.8em !important;
        padding: 3px 8px !important;
    }
    
    .btn-remove {
        padding: 5px 10px !important;
        font-size: 12px !important;
    }
    
    .date-options {
        flex-direction: column !important;
    }
}

/* Анимация для сообщений */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert.show {
    animation: fadeIn 0.3s ease;
}

/* Стили для ошибок */
.grid-item input.error,
.grid-item select.error {
    border-color: #e74c3c !important;
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.2) !important;
}