/**
 * Стили для тарифного калькулятора МКД
 */

:root {
    --primary: #1a5276;
    --primary-light: #2980b9;
    --secondary: #27ae60;
    --accent: #e74c3c;
    --warning: #f39c12;
    --bg: #f5f6fa;
    --card-bg: #ffffff;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --border: #e0e0e0;
    --border-light: #ecf0f1;
    --group-1: #e8f4f8;
    --group-2: #fff3e0;
    --group-3: #e8f5e9;
    --group-4: #fce4ec;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.12);
    --radius: 8px;
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
}

/* ===== ШАПКА ===== */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-top {
    max-width: 1400px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.header h1 {
    font-size: 18px;
    font-weight: 600;
}

.header-house-info {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.header-house-info label {
    font-size: 12px;
    opacity: 0.9;
}

.header-house-info .value {
    font-weight: 700;
    font-size: 16px;
    margin-left: 5px;
}

.header-house-info input[type="number"] {
    width: 100px;
    padding: 4px 8px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    background: rgba(255,255,255,0.15);
    color: white;
    font-size: 14px;
    font-weight: 600;
}

.header-house-info input[type="number"]::placeholder {
    color: rgba(255,255,255,0.6);
}

/* ===== НАВИГАЦИЯ ===== */
.nav-bar {
    background: rgba(0,0,0,0.1);
    border-top: 1px solid rgba(255,255,255,0.1);
}

.nav-bar-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.nav-item {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 10px 16px;
    font-size: 13px;
    border-bottom: 3px solid transparent;
    transition: var(--transition);
    white-space: nowrap;
}

.nav-item:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.nav-item.active {
    color: white;
    border-bottom-color: #f39c12;
    font-weight: 600;
}

/* ===== КОНТЕНТ ===== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.page-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ===== КАРТОЧКИ ===== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 14px 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 15px;
    font-weight: 600;
}

.card-header .subtitle {
    font-size: 12px;
    opacity: 0.85;
}

.card-body {
    padding: 0;
}

/* ===== ТАБЛИЦЫ ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th {
    background: #f8f9fa;
    padding: 10px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: #f8fbff;
}

.data-table tbody td {
    padding: 8px 12px;
    font-size: 13px;
    vertical-align: middle;
}

.data-table .group-header {
    background: linear-gradient(90deg, #e8f4f8 0%, #f0f7fb 100%);
    font-weight: 600;
}

.data-table .group-header td {
    padding: 10px 12px;
    color: var(--primary);
    border-top: 2px solid var(--primary-light);
}

.data-table .total-row {
    background: linear-gradient(90deg, #fff8e1 0%, #fffde7 100%);
    font-weight: 700;
}

.data-table .total-row td {
    color: #e65100;
    border-top: 2px solid var(--warning);
    font-size: 14px;
}

.data-table .grand-total {
    background: linear-gradient(90deg, #e8f5e9 0%, #f1f8e9 100%);
    font-weight: 700;
}

.data-table .grand-total td {
    color: var(--secondary);
    border-top: 2px solid var(--secondary);
    font-size: 15px;
}

.data-table .subtotal-row {
    background: #f5f5f5;
    font-weight: 600;
}

.data-table .subtotal-row td {
    border-top: 1px solid var(--border);
}

/* ===== РЕДАКТИРУЕМЫЕ ЯЧЕЙКИ ===== */
.editable {
    cursor: pointer;
    position: relative;
    min-width: 80px;
}

.editable:hover {
    background: #fff9c4;
    outline: 1px dashed var(--warning);
}

.editable input {
    width: 100%;
    padding: 4px 6px;
    border: 2px solid var(--primary-light);
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    text-align: right;
    background: white;
}

.editable-text:hover {
    background: #fff9c4;
    outline: 1px dashed var(--warning);
    cursor: text;
}

.editable-text input {
    width: 100%;
    padding: 4px 6px;
    border: 2px solid var(--primary-light);
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    text-align: left;
    background: white;
}

/* ===== ИТОГОВАЯ ПАНЕЛЬ ===== */
.summary-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.summary-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}

.summary-card.green { border-left-color: var(--secondary); }
.summary-card.orange { border-left-color: var(--warning); }
.summary-card.red { border-left-color: var(--accent); }

.summary-card .label {
    font-size: 11px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.summary-card .value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.summary-card .sub {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 2px;
}

/* ===== КНОПКИ ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

.btn-success {
    background: var(--secondary);
    color: white;
}

.btn-success:hover {
    background: #219a52;
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

.btn-danger {
    background: var(--accent);
    color: white;
}

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

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

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ===== МОДАЛЬНЫЕ ОКНА ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: var(--radius);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    transform: translateY(-20px);
    transition: var(--transition);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 16px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
    line-height: 1;
}

.modal-close:hover {
    color: var(--accent);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ===== ФОРМЫ ===== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.15);
}

/* ===== СПИСОК ДОМОВ ===== */
.houses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.house-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    border: 2px solid transparent;
    cursor: pointer;
}

.house-card:hover {
    box-shadow: var(--shadow-hover);
    border-color: var(--primary-light);
}

.house-card.active {
    border-color: var(--secondary);
}

.house-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.house-card h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary);
}

.house-card .address {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 2px;
}

.house-card .area {
    font-size: 14px;
    font-weight: 600;
    color: var(--secondary);
    margin-top: 8px;
}

.house-actions {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

/* ===== УТИЛИТЫ ===== */
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-mono { font-family: 'Courier New', monospace; }
.text-muted { color: var(--text-light); }
.text-success { color: var(--secondary); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--accent); }

.mt-1 { margin-top: 5px; }
.mt-2 { margin-top: 10px; }
.mb-2 { margin-bottom: 10px; }
.mb-3 { margin-bottom: 15px; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.badge-primary { background: #e3f2fd; color: var(--primary); }
.badge-success { background: #e8f5e9; color: var(--secondary); }
.badge-warning { background: #fff3e0; color: #e65100; }

/* ===== СООБЩЕНИЯ ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 15px;
    font-size: 13px;
}

.alert-success { background: #e8f5e9; color: #2e7d32; border-left: 4px solid var(--secondary); }
.alert-error { background: #ffebee; color: #c62828; border-left: 4px solid var(--accent); }
.alert-info { background: #e3f2fd; color: var(--primary); border-left: 4px solid var(--primary-light); }

/* ===== СПИННЕР ===== */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ddd;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== АДАПТИВНОСТЬ ===== */
@media (max-width: 768px) {
    .header-top {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .nav-bar-inner {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    .summary-panel {
        grid-template-columns: 1fr 1fr;
    }
    
    .data-table {
        font-size: 12px;
    }
    
    .data-table thead th,
    .data-table tbody td {
        padding: 6px 8px;
    }
    
    .container {
        padding: 10px;
    }
    
    .houses-grid {
        grid-template-columns: 1fr;
    }
}

@media print {
    .header, .nav-bar, .btn, .house-actions {
        display: none !important;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }
    
    body {
        background: white;
    }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}
