/* ===== Основные стили ===== */
* {
    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-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;
}

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

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

/* Если нужно, добавьте стили для иконок в кнопках */
.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
    min-width: 30px;
}

/* Контейнер для кнопок действий */
.actions-group {
    display: flex;
    gap: 5px;
    justify-content: center;
}

/* Вложения */
.attachment-item {
    margin: 5px 0;
    padding: 5px;
    background: #f8f9fa;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
}

.attachment-item a {
    text-decoration: none;
    color: #3498db;
}

.attachment-item a:hover {
    text-decoration: underline;
}

/* Форма загрузки вложений */
.upload-form {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 5px;
}

.upload-form input[type="file"] {
    flex: 1;
    min-width: 0;
    padding: 3px 5px;
    font-size: 11px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f8f9fa;
    width: auto;
}

.upload-form .btn-sm {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 3px 8px;
    font-size: 11px;
}

/* Нулевой баланс */
.zero-balance {
    color: #3498db; /* голубой */
    font-weight: bold;
}


/* Денежные суммы с крупной целой частью */
.money-integer {
    font-size: 1.1em;
    font-weight: bold;
}

.money-fraction {
    font-size: 0.75em;
    font-weight: normal;
    vertical-align: baseline;
}

/* Отображение переносов в примечаниях */
.note-text {
    white-space: pre-line;
    text-align: left;
    max-width: 200px;
    word-wrap: break-word;
}

/* Поле для загрузки файлов */
input[type="file"] {
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f8f9fa;
    width: 100%;
}

input[type="file"]:hover {
    background: #e9ecef;
}

.field-group small {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: #666;
}

/* Группировка по годам */
.year-group {
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
}

.year-group summary {
    padding: 12px 15px;
    background: #f8f9fa;
    cursor: pointer;
    font-weight: bold;
    color: #2c3e50;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
    list-style: none;
}

.year-group summary::-webkit-details-marker {
    display: none;
}

.year-group summary:hover {
    background: #e9ecef;
}

.year-group summary::before {
    content: '▶';
    margin-right: 10px;
    transition: transform 0.2s;
    display: inline-block;
    font-size: 12px;
}

.year-group[open] summary::before {
    transform: rotate(90deg);
}

.year-title {
    font-size: 16px;
}

.year-info {
    font-size: 14px;
    color: #666;
    font-weight: normal;
}

.year-group[open] summary {
    border-bottom: 1px solid #ddd;
}

.year-group table {
    margin: 0;
}

.year-group table th {
    background: #f8f9fa;
}

/* Меню навигации */
.main-menu {
    background: #34495e;
    padding: 10px;
    border-radius: 6px;
    margin: 15px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.main-menu a {
    color: white;
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 4px;
    transition: background 0.2s;
    font-size: 14px;
}

.main-menu a:hover {
    background: #2c3e50;
}

.main-menu a.active {
    background: #3498db;
    font-weight: bold;
}

/* Графики */
.chart-container {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.chart-wrapper {
    position: relative;
    height: 400px;
    width: 100%;
}

.chart-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.chart-btn {
    padding: 8px 16px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

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

.chart-btn.active {
    background: #2c3e50;
    font-weight: bold;
}

.chart-stats {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin: 15px 0;
}

.stat-box {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    min-width: 150px;
    text-align: center;
    flex: 1;
}

.stat-label {
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 20px;
    font-weight: bold;
    color: #2c3e50;
}

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

.login-box {
    background: white;
    padding: 30px 25px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    width: 320px;
    text-align: center;
}

.login-box h2 {
    margin: 0 0 20px;
    color: #2c3e50;
    font-size: 22px;
}

.login-field {
    margin-bottom: 15px;
    text-align: left;
}

.login-field label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: #555;
}

.login-field input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

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

.btn-login {
    width: 100%;
    padding: 10px;
    font-size: 16px;
    margin-top: 5px;
    background: #3498db;
    border: none;
    color: white;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.2s;
}

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

.error {
    background: #fdeaea;
    color: #e74c3c;
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 15px;
    font-size: 14px;
    border-left: 3px solid #e74c3c;
}

/* Поля калькулятора */
.calc-field {
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

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

/* Подсветка расчётных значений */
.calculated-cell {
    background-color: #fff9c4 !important; /* бледно-жёлтый */
}

.calc-label {
    font-size: 12px;
    color: #666;
    display: inline-block;
    margin-left: 5px;
    white-space: nowrap;
}

/* Таблица для ввода данных ЖКХ */
.calc-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.calc-table th {
    background: #f8f9fa;
    padding: 8px;
    text-align: center;
    font-size: 13px;
    color: #555;
    border-bottom: 2px solid #ddd;
}

.calc-table td {
    padding: 5px 8px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.calc-table td:first-child {
    text-align: left;
    font-weight: bold;
    color: #333;
    width: 35%;
}

.calc-table td:nth-child(2) {
    width: 40%;
}

.calc-table td:last-child {
    text-align: center;
    width: 25%;
}

.calc-table input[type="text"] {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

.calc-table textarea {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
    resize: vertical;
    min-height: 40px;
}

.calc-checkbox-cell {
    text-align: center !important;
}

.calc-checkbox-cell input[type="checkbox"] {
    margin: 0 3px 0 0;
    vertical-align: middle;
}

.calc-checkbox-cell label {
    font-size: 12px;
    color: #666;
    cursor: pointer;
    display: inline;
    vertical-align: middle;
    margin: 0;
}

/* Подсветка расчётных значений в таблице отображения */
.calculated-cell {
    background-color: #fff9c4 !important;
}
/* Контейнер вложений */
.attachment-item {
    margin: 3px 0;
    padding: 3px 5px;
    background: #f8f9fa;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    width: 100%;
    box-sizing: border-box;
}

.attachment-item a {
    text-decoration: none;
    color: #3498db;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
}

.attachment-item a:hover {
    text-decoration: underline;
}

/* Кнопка удаления вложения - компактная */
.attachment-item .btn-danger {
    flex-shrink: 0;
    width: auto;
    min-width: 25px;
    padding: 2px 5px;
    font-size: 10px;
    line-height: 1;
}

/* Компактная кнопка удаления вложения */
.delete-attachment-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 25px !important;
    min-width: 25px !important;
    max-width: 25px !important;
    height: 25px !important;
    padding: 0 !important;
    font-size: 12px !important;
    border-radius: 3px;
    background: #e74c3c !important;
    color: white !important;
    text-decoration: none;
    flex-shrink: 0;
    transition: background 0.2s;
    line-height: 1;
}

.delete-attachment-btn:hover {
    background: #c0392b !important;
}