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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f0f2f5;
    color: #333;
}

.page {
    display: none;
    min-height: 100vh;
}

.page.active {
    display: block;
}

/* Логин */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-box {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header i {
    font-size: 48px;
    color: #667eea;
    margin-bottom: 10px;
}

.login-header h1 {
    font-size: 24px;
    color: #333;
}

.login-header p {
    color: #666;
    font-size: 14px;
}

/* Формы */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 5px;
}

.form-group label i {
    margin-right: 8px;
    color: #667eea;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

/* Кнопки */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a67d8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: #48bb78;
    color: white;
}

.btn-success:hover {
    background: #38a169;
}

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

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

.btn-info {
    background: #63b3ed;
    color: white;
}

.btn-info:hover {
    background: #4299e1;
}

.btn-outline {
    background: transparent;
    border: 2px solid #e1e5e9;
    color: #555;
}

.btn-outline:hover {
    background: #f7fafc;
    border-color: #667eea;
    color: #667eea;
}

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

.btn-block {
    width: 100%;
    justify-content: center;
}

/* Шапка */
.app-header {
    background: white;
    border-bottom: 1px solid #e1e5e9;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    color: #667eea;
}

.logo i {
    font-size: 28px;
}

.version {
    font-size: 11px;
    color: #999;
    background: #f0f2f5;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    font-weight: 400;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #555;
}

.user-info i {
    font-size: 24px;
    color: #667eea;
}

/* Основной контент */
.app-main {
    padding: 24px 20px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Статистика */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: #ebf4ff;
    color: #667eea;
}

.stat-card.status-new .stat-icon { background: #ebf8ff; color: #4299e1; }
.stat-card.status-work .stat-icon { background: #fefcbf; color: #d69e2e; }
.stat-card.status-done .stat-icon { background: #c6f6d5; color: #38a169; }
.stat-card.status-rejected .stat-icon { background: #fed7d7; color: #9b2c2c; }
.stat-card.status-deleted .stat-icon { background: #e2e8f0; color: #4a5568; }

.stat-value {
    font-size: 28px;
    font-weight: 700;
}

.stat-label {
    font-size: 13px;
    color: #666;
}

/* Управление */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 24px;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-left: auto;
}

.filters select {
    padding: 8px 14px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.filters select:focus {
    outline: none;
    border-color: #667eea;
}

/* Таблица */
.table-wrapper {
    background: white;
    border-radius: 12px;
    overflow-x: auto;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead {
    background: #f7fafc;
}

th {
    text-align: left;
    padding: 14px 16px;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #e1e5e9;
    white-space: nowrap;
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid #f0f2f5;
}

tr:hover {
    background: #f7fafc;
}

/* Бейджи */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-new { background: #ebf8ff; color: #2b6cb0; }
.badge-work { background: #fefcbf; color: #975a16; }
.badge-done { background: #c6f6d5; color: #276749; }
.badge-rejected { background: #fed7d7; color: #9b2c2c; }

.badge-type {
    background: #edf2f7;
    color: #4a5568;
}

.badge-type.connect { background: #e0f2fe; color: #0369a1; }
.badge-type.repair { background: #fce4ec; color: #9a1f3c; }

/* Действия */
.actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

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

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e1e5e9;
}

.modal-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #333;
}

.modal-close {
    font-size: 28px;
    cursor: pointer;
    color: #999;
    transition: color 0.3s;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 24px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e1e5e9;
}

/* Ошибки */
.error-message {
    background: #fed7d7;
    color: #c53030;
    padding: 12px;
    border-radius: 8px;
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Карточка */
.card-table {
    width: 100%;
    border-collapse: collapse;
}

.card-table tr {
    border-bottom: 1px solid #f0f2f5;
}

.card-table tr:last-child {
    border-bottom: none;
}

.card-table td {
    padding: 10px 8px;
    vertical-align: top;
}

.card-table .label {
    color: #666;
    font-weight: 600;
    width: 35%;
    font-size: 13px;
}

.card-content .modal-body {
    padding: 16px 24px;
}

/* Справочники */
.dict-item {
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
}

.dict-header {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    cursor: pointer;
    background: #f7fafc;
    transition: background 0.2s;
}

.dict-header:hover {
    background: #edf2f7;
}

.dict-header .dict-name {
    flex: 1;
    font-weight: 500;
}

.dict-header .dict-actions {
    display: flex;
    gap: 6px;
}

.dict-header .fa-chevron-right {
    margin-right: 10px;
    transition: transform 0.2s;
    color: #a0aec0;
}

.dict-children {
    padding: 8px 0 8px 0;
    background: white;
}

.district-item .dict-header {
    background: #ebf8ff;
}

.district-item .dict-header:hover {
    background: #bee3f8;
}

.settlement-item .dict-header {
    background: #f0fff4;
}

.settlement-item .dict-header:hover {
    background: #c6f6d5;
}

.street-item .dict-header {
    background: #faf5ff;
}

.street-item .dict-header:hover {
    background: #e9d8fd;
}

.street-item {
    margin-left: 20px;
}

/* Комментарии */
.comment-item {
    background: #f7fafc;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 12px;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.comment-header strong {
    color: #2d3748;
    font-size: 13px;
}

.comment-time {
    color: #a0aec0;
    font-size: 12px;
}

.comment-content {
    color: #4a5568;
    font-size: 14px;
    line-height: 1.5;
}

/* История */
.history-item {
    background: #f7fafc;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 12px;
    border-left: 4px solid #667eea;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.history-header strong {
    color: #2d3748;
    font-size: 13px;
}

.history-time {
    color: #a0aec0;
    font-size: 12px;
}

.history-status {
    font-weight: 600;
    color: #2d3748;
}

.history-comment {
    margin-top: 6px;
    color: #4a5568;
    font-size: 13px;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
}

/* Сотрудники */
.employee-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f7fafc;
    border-radius: 8px;
    margin-bottom: 8px;
}

.employee-info {
    flex: 1;
}

.employee-name {
    font-size: 15px;
    margin-bottom: 4px;
}

.employee-details {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: #666;
}

.employee-details i {
    margin-right: 4px;
    color: #667eea;
}

.text-center {
    text-align: center;
}

/* Адаптивность */
@media (max-width: 768px) {
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filters {
        margin-left: 0;
        flex-wrap: wrap;
    }
    
    .filters select {
        flex: 1;
        min-width: 120px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .header-content {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 0;
        gap: 12px;
    }
    
    .login-box {
        padding: 24px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    table {
        font-size: 12px;
    }
    
    th, td {
        padding: 10px 12px;
    }
}

/* Стили для поиска */
.search-container {
    padding: 10px 0;
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
    margin-bottom: 16px;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
}

.search-results {
    max-height: 400px;
    overflow-y: auto;
}

.search-hint {
    text-align: center;
    color: #999;
    padding: 30px 0;
    font-size: 14px;
}

.search-item {
    background: #f7fafc;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 8px;
    border-left: 4px solid #667eea;
    cursor: pointer;
    transition: background 0.2s;
}

.search-item:hover {
    background: #edf2f7;
}

.search-item .search-address {
    font-weight: 600;
    font-size: 16px;
    color: #2d3748;
}

.search-item .search-details {
    font-size: 13px;
    color: #718096;
    margin-top: 4px;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.search-item .search-status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
/* Статус сотрудника */
.status-active {
    color: #38a169;
    font-weight: 600;
}

.status-inactive {
    color: #e53e3e;
    font-weight: 600;
}

/* Действия с сотрудниками */
.employee-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.status-active {
    color: #38a169;
    font-weight: 600;
}

.status-inactive {
    color: #e53e3e;
    font-weight: 600;
}


/* Футер */
.app-footer {
    background: white;
    border-top: 1px solid #e1e5e9;
    padding: 16px 20px;
    text-align: center;
    margin-top: 30px;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: #718096;
}

.footer-content span {
    color: #4a5568;
}

.footer-content span:first-child {
    font-weight: 600;
    color: #667eea;
}

.search-item .search-status.new { background: #ebf8ff; color: #2b6cb0; }
.search-item .search-status.work { background: #fefcbf; color: #975a16; }
.search-item .search-status.done { background: #c6f6d5; color: #276749; }
.search-item .search-status.rejected { background: #fed7d7; color: #9b2c2c; }
