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

body {
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
    padding: 20px;
}

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

/* Стили для шапки с авторизацией */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

.header h1 {
    margin-bottom: 0;
}

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

.auth-form {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.auth-form select, .auth-form input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    min-width: 120px;
}

.auth-form select:focus, .auth-form input:focus {
    outline: none;
    border-color: #007bff;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

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

.user-details span {
    font-weight: bold;
}

.user-details .user-name {
    color: #28a745;
}

.user-details .admin-badge {
    background-color: #dc3545;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

.btn-auth {
    background-color: #007bff;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.btn-auth:hover {
    background-color: #0056b3;
}

.btn-logout {
    background-color: #6c757d;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.btn-logout:hover {
    background-color: #5a6268;
}

/* Затемнение контента для неавторизованных */
.content {
    transition: opacity 0.3s;
}

.content.disabled {
    opacity: 0.5;
    pointer-events: none;
    user-select: none;
}

.auth-message {
    text-align: center;
    padding: 40px;
    background-color: #f8f9fa;
    border-radius: 8px;
    margin: 20px 0;
    color: #6c757d;
    font-size: 16px;
}

.form-container {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 6px;
    margin-bottom: 30px;
}

.form-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.form-group {
    flex: 1;
    min-width: 150px;
}

/* Настройка ширины полей формы */
.form-group:nth-child(1) { /* № протокола */
    min-width: 80px;
    max-width: 100px;
    flex: 0 1 auto;
}

.form-group:nth-child(2) { /* Название протокола */
    flex: 1 1 250px;
    min-width: 200px;
}

.form-group:nth-child(3) { /* Объект */
    flex: 1 1 250px;
    min-width: 200px;
}

.form-group:nth-child(4) { /* Отдел */
    min-width: 100px;
    max-width: 130px;
    flex: 0 1 auto;
}

.form-group:nth-child(5) { /* Отв. лицо */
    min-width: 130px;
    max-width: 160px;
    flex: 0 1 auto;
}

.form-group:nth-child(6) { /* Кнопки */
    min-width: 120px;
    flex: 0 1 auto;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
    font-size: 14px;
    white-space: nowrap;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #007bff;
}

#protocol_number {
    background-color: #f0f0f0;
    cursor: not-allowed;
    font-weight: 500;
    color: #495057;
    text-align: center;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s;
}

.btn-primary {
    background-color: #007bff;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,123,255,0.3);
}

.btn-primary:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

.btn-edit {
    background-color: #28a745;
    color: white;
    padding: 5px 10px;
    font-size: 14px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.btn-edit:hover:not(:disabled) {
    background-color: #218838;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(40,167,69,0.3);
}

.btn-delete {
    background-color: #dc3545;
    color: white;
    padding: 5px 10px;
    font-size: 14px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.btn-delete:hover:not(:disabled) {
    background-color: #c82333;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(220,53,69,0.3);
}

.btn-cancel {
    background-color: #6c757d;
    color: white;
}

.btn-cancel:hover:not(:disabled) {
    background-color: #5a6268;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(108,117,125,0.3);
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    table-layout: auto;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

/* Настройка ширины столбцов таблицы */
th:nth-child(1), td:nth-child(1) { /* № протокола */
    width: auto;
    white-space: nowrap;
}

th:nth-child(2), td:nth-child(2) { /* Дата ввода */
    width: auto;
    white-space: nowrap;
}

th:nth-child(3), td:nth-child(3) { /* Название протокола */
    width: 100%;
    min-width: 200px;
}

th:nth-child(4), td:nth-child(4) { /* Объект */
    width: auto;
    white-space: nowrap;
    min-width: 120px;
}

th:nth-child(5), td:nth-child(5) { /* Отдел */
    width: auto;
    white-space: nowrap;
}

th:nth-child(6), td:nth-child(6) { /* Отв. лицо */
    width: auto;
    white-space: nowrap;
}

th:nth-child(7), td:nth-child(7) { /* Действия */
    width: auto;
    white-space: nowrap;
    min-width: 80px;
}

td:nth-child(3) {
    max-width: 400px;
    white-space: normal;
    word-wrap: break-word;
}

td:nth-child(3):hover {
    background-color: #e9ecef;
    cursor: help;
}

th {
    background-color: #f8f9fa;
    font-weight: bold;
    color: #555;
}

tr:hover {
    background-color: #f5f5f5;
}

.actions {
    display: flex;
    gap: 5px;
    justify-content: flex-start;
}

.error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 20px;
    border: 1px solid #f5c6cb;
    animation: slideIn 0.3s ease;
}

.success-message {
    background-color: #d4edda;
    color: #155724;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 20px;
    border: 1px solid #c3e6cb;
    animation: slideIn 0.3s ease;
}

.info-message {
    background-color: #cce5ff;
    color: #004085;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 20px;
    border: 1px solid #b8daff;
    animation: slideIn 0.3s ease;
}

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

/* Для мобильных устройств */
@media (max-width: 992px) {
    .form-group:nth-child(1),
    .form-group:nth-child(4),
    .form-group:nth-child(5),
    .form-group:nth-child(6) {
        min-width: 100%;
        max-width: 100%;
        flex: 1 1 100%;
    }
    
    .form-group:nth-child(2),
    .form-group:nth-child(3) {
        min-width: 100%;
        flex: 1 1 100%;
    }
    
    td:nth-child(3) {
        max-width: 200px;
    }
    
    .auth-container {
        width: 100%;
    }
    
    .auth-form {
        width: 100%;
    }
    
    .auth-form select, .auth-form input {
        flex: 1;
    }
    
    .user-info {
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 15px;
    }
    
    .auth-container {
        width: 100%;
    }
    
    .auth-form {
        width: 100%;
    }
    
    .user-info {
        width: 100%;
        justify-content: center;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .form-group {
        width: 100%;
        min-width: 100% !important;
        max-width: 100% !important;
    }
    
    th, td {
        padding: 8px;
        font-size: 14px;
    }
    
    th:nth-child(1), td:nth-child(1),
    th:nth-child(2), td:nth-child(2),
    th:nth-child(3), td:nth-child(3),
    th:nth-child(4), td:nth-child(4),
    th:nth-child(5), td:nth-child(5),
    th:nth-child(6), td:nth-child(6),
    th:nth-child(7), td:nth-child(7) {
        width: auto;
        white-space: normal;
        min-width: auto;
        max-width: none;
    }
}

/* Стили для выпадающих списков */
select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    padding-right: 32px;
}