* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #e0f7fa 0%, #bbdefb 100%);
    color: #2c3e50;
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Стили авторизации */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.auth-container {
    background: white;
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 450px;
    overflow: hidden;
}

.app-header {
    background: linear-gradient(120deg, #1a237e 0%, #283593 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

h1 {
    font-size: 2.2rem;
    margin-bottom: 10px;
}

.app-description {
    font-size: 1.1rem;
    opacity: 0.9;
}

.auth-form {
    padding: 30px;
}

.form-group {
    margin-bottom: 25px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #3949ab;
}

input {
    width: 100%;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

input:focus {
    border-color: #3949ab;
    outline: none;
    box-shadow: 0 0 0 3px rgba(57, 73, 171, 0.2);
}

.password-container {
    position: relative;
}

.toggle-password {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #777;
}

.btn {
    width: 100%;
    padding: 16px;
    background: #3949ab;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
}

.btn:hover {
    background: #303f9f;
    transform: translateY(-2px);
}

.error-message {
    background: #ffebee;
    color: #c62828;
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
    display: none;
    border-left: 5px solid #c62828;
}

.loader {
    text-align: center;
    padding: 20px;
    display: none;
}

.loader-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3949ab;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Основной контент */
.main-content {
    display: block;
}

.user-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-avatar {
    width: 50px;
    height: 50px;
    background: #3949ab;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    font-weight: bold;
}

.logout-btn {
    background: #f44336;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s;
}

.logout-btn:hover {
    background: #d32f2f;
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    flex-wrap: wrap;
    gap: 15px;
}

.sheet-selector {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.sheet-button {
    padding: 12px 25px;
    background: #5c6bc0;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sheet-button:hover {
    background: #3f51b5;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.sheet-button.active {
    background: #283593;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.last-updated {
    color: #666;
    font-style: italic;
}

.table-container {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

th, td {
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px solid #eaeaea;
}

th {
    background-color: #3949ab;
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
    cursor: pointer;
    transition: background 0.2s;
}

/* Колонка действий */
.actions-col {
    position: sticky;
    left: 0;
    z-index: 5;
    background: #3949ab;
    min-width: 160px;
}

tr {
    font-size: 12px;
}

th:hover {
    background-color: #303f9f;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    min-width: 100px;
}

.info-icon {
    cursor: help;
    font-size: 14px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.info-icon:hover {
    opacity: 1;
}

.tooltip {
    position: absolute;
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    z-index: 100;
    max-width: 300px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

tr:nth-child(even) {
    background-color: #f9f9f9;
}

tr:hover {
    background-color: #f1f8ff;
}

.data-loader {
    text-align: center;
    padding: 40px 20px;
    display: none;
}

.data-loader-spinner {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3949ab;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.data-error {
    background: #ffebee;
    color: #c62828;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: none;
    border-left: 5px solid #c62828;
}

footer {
    text-align: center;
    padding: 20px;
    color: #666;
    font-size: 0.9rem;
    margin-top: 30px;
}

@media (max-width: 768px) {
    .controls {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .sheet-selector {
        width: 100%;
        justify-content: center;
    }
    
    th, td {
        padding: 12px 15px;
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    .auth-form {
        padding: 20px;
    }
}

/* Специальные стили для сложной таблицы 2_ЗОРФВД */
#dataTable.zorfvd-table {
    font-size: 11px;
    border-collapse: collapse;
}

#dataTable.zorfvd-table th {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    padding: 8px 10px;
    text-align: center;
    vertical-align: middle;
    border: 1px solid #bdc3c7;
    font-weight: 500;
}

#dataTable.zorfvd-table td {
    padding: 6px 8px;
    border: 1px solid #ddd;
    text-align: center;
    vertical-align: middle;
}

#dataTable.zorfvd-table tr:nth-child(even) {
    background-color: #f8f9fa;
}

#dataTable.zorfvd-table tr:hover {
    background-color: #e9ecef;
}

/* Стили для заголовков разных уровней */
#dataTable.zorfvd-table thead tr:first-child th {
    background: linear-gradient(135deg, #1a237e, #283593);
    font-weight: bold;
    font-size: 12px;
}

#dataTable.zorfvd-table thead tr:nth-child(2) th {
    background: linear-gradient(135deg, #3949ab, #3f51b5);
    font-weight: 600;
}

#dataTable.zorfvd-table thead tr:nth-child(3) th,
#dataTable.zorfvd-table thead tr:nth-child(4) th {
    background: #5c6bc0;
    font-weight: 500;
}

/* Первая колонка с описанием */
#dataTable.zorfvd-table td:first-child {
    background: #fff;
    position: sticky;
    left: 0;
    z-index: 3;
    min-width: 160px;
}

a {
    text-decoration: none; /* Убирает подчеркивание у ссылок */
}

.form-field .invalid { border: 1px solid #b00020 !important; background: #fff6f6; }

/* Числовые данные */
#dataTable.zorfvd-table td:not(:first-child) {
    font-family: 'Courier New', monospace;
    min-width: 60px;
}

/* Кнопки действий в первой колонке */
.row-actions {
    white-space: nowrap;
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 4;
}

.action-btn {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
    background: #fafafa;
    cursor: pointer;
    font-size: 12px;
    margin-right: 6px;
}

.action-btn.edit { border-color: #1976d2; color: #1976d2; }
.action-btn.delete { border-color: #d32f2f; color: #d32f2f; }

/* Модальное окно */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: #fff;
    border-radius: 12px;
    width: 95%;
    max-width: 900px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #3949ab;
    color: #fff;
}

.close-btn {
    background: transparent;
    color: #fff;
    border: none;
    font-size: 24px;
    cursor: pointer;
}

.modal-body {
    padding: 20px;
    max-height: 70vh;
    overflow: auto;
}

.form-field {
    margin-bottom: 16px;
}

.form-field label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    margin-top: 8px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Сетка для больших форм */
.modal-body #addRecordForm {
    display: grid;
    grid-template-columns: repeat(2, minmax(240px, 1fr));
    gap: 16px 20px;
}

@media (max-width: 900px) {
    .modal-body #addRecordForm {
        grid-template-columns: 1fr;
    }
}

/* Поля с суффиксом % */
.percent-wrapper {
    position: relative;
}
.percent-wrapper input[type="number"] {
    padding-right: 28px;
}
.percent-wrapper .suffix {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
}

/* Улучшаем видимость для маленьких экранов */
.table-container {
    overflow-x: auto;
    max-width: 100%;
    margin: 5px 0;
    border: 1px solid #ddd;
    border-radius: 8px;
}

/* Подсветка заголовков при наведении */
#dataTable.zorfvd-table th:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Иконки информации в заголовках */
.info-icon {
    margin-left: 5px;
    font-size: 10px;
    opacity: 0.7;
}

.info-icon:hover {
    opacity: 1;
}

/* Стили для объединенных ячеек */
.colspan-3 { grid-column: span 3; }
.colspan-2 { grid-column: span 2; }
.rowspan-2 { grid-row: span 2; }

