/* ===== Основные стили ===== */
* {
    box-sizing: border-box;
}

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

/* ===== Контейнер ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ===== Шапка ===== */
.header {
    background: #2c3e50;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header .user-info {
    font-size: 16px;
}

/* ===== Блок сальдо ===== */
.balance-box {
    padding: 10px 25px;
    border-radius: 6px;
    font-size: 22px;
    font-weight: bold;
    min-width: 250px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.balance-advance {
    background-color: #27ae60;
    color: white;
}

.balance-debt {
    background-color: #e74c3c;
    color: white;
}

/* ===== Кнопка выхода ===== */
.logout {
    color: white;
    text-decoration: none;
    background: #e74c3c;
    padding: 8px 16px;
    border-radius: 4px;
    transition: background 0.2s;
}

.logout:hover {
    background: #c0392b;
}

/* ===== Блоки контента ===== */
.block {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.block h3 {
    margin-top: 0;
    color: #2c3e50;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

/* ===== Flex-контейнер ===== */
.flex {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.flex > div {
    flex: 1;
    min-width: 320px;
}

/* ===== Таблицы ===== */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

th, td {
    border: 1px solid #ddd;
    padding: 8px 10px;
    text-align: center;
    font-size: 14px;
}

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

tr:nth-child(even) {
    background: #f8f9fa;
}

tr:hover {
    background: #f0f0f0;
}

.small-table td {
    padding: 6px 8px;
}

.small-table td:first-child {
    text-align: left;
    font-weight: bold;
    width: 50%;
}

.small-table input {
    width: 100%;
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* ===== Формы ===== */
.field-group {
    margin-bottom: 15px;
}

.field-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

.field-group input,
.field-group select,
.field-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52,152,219,0.2);
}

.field-group textarea {
    height: 60px;
    resize: vertical;
    font-family: inherit;
}

.period-select {
    font-size: 14px;
}

/* ===== Кнопки ===== */
.btn {
    display: inline-block;
    padding: 8px 16px;
    background: #3498db;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.btn:hover {
    background: #2980b9;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-warning {
    background: #f39c12;
}

.btn-warning:hover {
    background: #e67e22;
}

.btn-cancel {
    background: #95a5a6;
}

.btn-cancel:hover {
    background: #7f8c8d;
}

.btn-danger {
    background: #e74c3c;
}

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

.btn-group {
    margin-top: 20px;
    display: flex;
    gap: 10px;
}

/* ===== Сообщения ===== */
.error {
    color: #e74c3c;
    background: #fdeaea;
    padding: 10px 15px;
    border-radius: 4px;
    margin: 10px 0;
    border-left: 4px solid #e74c3c;
}

.success {
    color: #27ae60;
    background: #eafaf1;
    padding: 10px 15px;
    border-radius: 4px;
    margin: 10px 0;
    border-left: 4px solid #27ae60;
}

/* ===== Статистика ===== */
.year-link {
    margin-right: 10px;
}

.positive-balance {
    color: #27ae60;
    font-weight: bold;
}

.negative-balance {
    color: #e74c3c;
    font-weight: bold;
}

/* ===== Страница входа ===== */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
}

.login-form {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    width: 350px;
}

.login-form h2 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    margin-top: 15px;
    font-weight: bold;
    color: #555;
}

.login-form input {
    width: 100%;
    padding: 10px;
    margin-top: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.login-form input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52,152,219,0.2);
}

.login-form .btn {
    width: 100%;
    margin-top: 20px;
    padding: 10px;
    font-size: 16px;
}

.login-form .error {
    text-align: center;
    margin-bottom: 0;
}

/* ===== Страницы редактирования ===== */
.edit-container {
    max-width: 550px;
    margin: 30px auto;
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.edit-container h2 {
    margin-top: 0;
    color: #2c3e50;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

/* ===== Адаптивность ===== */
@media (max-width: 768px) {
    body {
        margin: 10px;
    }
    
    .header {
        flex-direction: column;
        text-align: center;
    }
    
    .balance-box {
        width: 100%;
    }
    
    .flex {
        flex-direction: column;
    }
    
    .flex > div {
        min-width: 100%;
    }
    
    table {
        font-size: 12px;
    }
    
    th, td {
        padding: 6px 4px;
    }
    
    .btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* Подсветка ненулевой корректировки */
.adjustment-nonzero {
    background-color: #ffb7c6 !important;
    font-weight: bold;
}