/* Общие стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--tg-theme-bg-color, #f5f5f5);
    color: var(--tg-theme-text-color, #000);
    padding: 16px;
    line-height: 1.5;
}

.container {
    max-width: 600px;
    margin: 0 auto;
}

h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 24px;
    text-align: center;
    color: var(--tg-theme-text-color, #000);
}

h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--tg-theme-text-color, #000);
}

/* Карточки */
.card {
    background: var(--tg-theme-secondary-bg-color, #fff);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.welcome-card {
    text-align: center;
    max-width: 400px;
    margin: 0 auto;
}

.welcome-card p {
    margin: 12px 0;
}

/* Меню-сетка */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.menu-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    padding: 20px;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 120px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.menu-card:active {
    transform: scale(0.95);
}

.menu-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.menu-card.disabled {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    opacity: 0.6;
    cursor: not-allowed;
}

.card-icon {
    font-size: 44px;
    filter: drop-shadow(0px 2px 4px rgba(0,0,0,0.2));
}

.card-icon-svg {
    width: 48px;
    height: 48px;
    filter: drop-shadow(0px 2px 4px rgba(0,0,0,0.2));
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    line-height: 1.3;
}

.card-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.3);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
}

/* Кнопки */
.btn-primary, .btn-secondary, .btn-success {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    margin-top: 8px;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
    width: auto;
    margin: 4px;
}

.btn-primary:active, .btn-secondary:active, .btn-success:active {
    opacity: 0.8;
}

.back-btn {
    background: none;
    border: none;
    color: var(--tg-theme-link-color, #667eea);
    font-size: 16px;
    padding: 8px 0;
    margin-bottom: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Формы */
input[type="text"],
input[type="number"],
input[type="date"],
textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 12px;
    background: var(--tg-theme-bg-color, #fff);
    color: var(--tg-theme-text-color, #000);
}

textarea {
    resize: vertical;
    font-family: inherit;
}

.char-counter {
    text-align: right;
    font-size: 14px;
    color: #7f8c8d;
    margin-top: -8px;
    margin-bottom: 12px;
}

.date-input {
    width: auto;
    min-width: 150px;
    margin: 0;
}

/* Списки заявок */
.tasks-list {
    margin-top: 16px;
}

.task-item, .manager-task-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    border-left: 4px solid #667eea;
}

.manager-task-item {
    border-left-width: 6px;
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.task-number {
    font-weight: 700;
    font-size: 16px;
    color: #2c3e50;
}

.task-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-review {
    background: #fff3cd;
    color: #856404;
}

.status-active {
    background: #d1ecf1;
    color: #0c5460;
}

.status-done {
    background: #d4edda;
    color: #155724;
}

.task-body {
    color: #495057;
    font-size: 14px;
}

.task-body p {
    margin: 8px 0;
}

.task-date {
    font-size: 13px;
    color: #6c757d;
    margin-top: 8px;
}

.task-planned {
    font-size: 13px;
    color: #0c5460;
    font-weight: 600;
    margin-top: 4px;
}

.task-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #dee2e6;
    align-items: center;
}

/* Фильтры статусов */
.status-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.filter-btn {
    padding: 8px 16px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn.active {
    background: #667eea;
    color: white;
}

.filter-btn:active {
    transform: scale(0.95);
}

/* Контакты */
.contacts-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.contact-item {
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.contact-item.emergency {
    background: #fff5f5;
    border-left-color: #e74c3c;
}

.contact-label {
    font-size: 13px;
    color: #6c757d;
    margin-bottom: 4px;
}

.contact-value {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}

.contact-value a {
    color: #667eea;
    text-decoration: none;
}

.contact-value a:active {
    opacity: 0.7;
}

/* Вспомогательные классы */
.hint {
    color: #6c757d;
    font-size: 14px;
    text-align: center;
    padding: 20px;
}

.loading {
    color: #6c757d;
    font-size: 14px;
    text-align: center;
    padding: 20px;
}

.error-message {
    background: #fff5f5;
    color: #e74c3c;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.screen {
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Адаптивность */
@media (max-width: 400px) {
    .menu-grid {
        grid-template-columns: 1fr;
    }
    
    .status-filters {
        flex-direction: column;
    }
    
    .filter-btn {
        width: 100%;
    }
}
.card-icon-lucide {
    width: 48px;
    height: 48px;
    stroke-width: 2;
    color: white;
    filter: drop-shadow(0px 2px 4px rgba(0,0,0,0.2));
}

.reasoning-input {
    width: 100%;
    margin-top: 8px;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    background: var(--bg-color);
}


/* Workload Card */
.card-badge.badge-low {
    background: #d4edda;
    color: #155724;
}

.card-badge.badge-normal {
    background: #d1ecf1;
    color: #0c5460;
}

.card-badge.badge-medium {
    background: #fff3cd;
    color: #856404;
}

.card-badge.badge-high {
    background: #f8d7da;
    color: #721c24;
}

.card-badge.badge-critical {
    background: #d32f2f;
    color: white;
}

/* Heatmap container */
.heatmap-container {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px 0;
}

/* Labels */
.heatmap-labels {
    display: flex;
    flex-direction: column;
    gap: 3px;
    justify-content: space-around;
    padding-right: 8px;
    padding-top: 20px; /* Отступ для месяцев */
}

.day-label {
    height: 12px;
    font-size: 10px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    font-weight: 500;
}

/* Grid wrapper */
.heatmap-grid-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

/* Month headers */
.heatmap-months {
    display: flex;
    gap: 3px;
    margin-bottom: 4px;
}

.month-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: left;
    padding-left: 2px;
}

/* Grid */
.heatmap-grid {
    display: flex;
    gap: 3px;
}

.heatmap-week {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.heatmap-weeks {
    display: flex;
    gap: 3px;
}

.heatmap-day {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: transform 0.2s;
}

.heatmap-day:not(.heatmap-empty):hover {
    transform: scale(1.3);
    z-index: 10;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.heatmap-day.heatmap-empty {
    background: transparent !important;
    border: none;
}

.workload-score {
    font-size: 24px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 8px;
}

.workload-score.workload-low {
    background: #d4edda;
    color: #155724;
}

.workload-score.workload-normal {
    background: #d1ecf1;
    color: #0c5460;
}

.workload-score.workload-medium {
    background: #fff3cd;
    color: #856404;
}

.workload-score.workload-high {
    background: #f8d7da;
    color: #721c24;
}

.workload-score.workload-critical {
    background: #d32f2f;
    color: white;
}

/* Heatmap info */
.heatmap-info {
    text-align: center;
    margin-bottom: 24px;
}

.heatmap-info h3 {
    margin: 0 0 8px 0;
}

/* Legend */
.heatmap-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 12px;
    color: var(--text-secondary);
}

.legend-colors {
    display: flex;
    gap: 3px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}
/* Модалки */
.modal {
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--tg-theme-secondary-bg-color, #fff);
    max-width: 90%;
    max-height: 80vh;
    padding: 24px;
    border-radius: 12px;
    overflow-y: auto;
}

.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.duplicates-list {
    margin: 16px 0;
    max-height: 50vh;
    overflow-y: auto;
}

.duplicate-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    border-left: 4px solid #667eea;
}

.duplicate-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.similarity-badge {
    background: #667eea;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.duplicate-desc {
    font-size: 14px;
    color: #495057;
    margin: 0;
}

#validationHint {
    background: #fff3cd;
    color: #856404;
    padding: 8px;
    border-radius: 6px;
    margin-top: 8px;
    font-size: 13px;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:active {
    opacity: 0.8;
}
/* Два бейджа на одной карточке */
.card-badge-efficiency {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(239, 83, 80, 0.3); /* Красноватый */
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
}

.card-badge-workload {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.3);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
}

/* Стили для эффективности */
.badge-efficiency-high {
    background: #42a5f5 !important;
    color: white;
}

.badge-efficiency-good {
    background: #90caf9 !important;
    color: #1565c0;
}

.badge-efficiency-medium {
    background: #fff3cd !important;
    color: #856404;
}

.badge-efficiency-low {
    background: #ffcc80 !important;
    color: #e65100;
}

.badge-efficiency-critical {
    background: #ef5350 !important;
    color: white;
}

/* Скор эффективности */
.efficiency-score {
    font-size: 24px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 8px;
}

.efficiency-score.efficiency-high {
    background: #42a5f5;
    color: white;
}

.efficiency-score.efficiency-good {
    background: #90caf9;
    color: #1565c0;
}

.efficiency-score.efficiency-medium {
    background: #fff3cd;
    color: #856404;
}

.efficiency-score.efficiency-low {
    background: #ffcc80;
    color: #e65100;
}

.efficiency-score.efficiency-critical {
    background: #ef5350;
    color: white;
}

/* Карточки метрик */
.efficiency-card,
.workload-card {
    margin-bottom: 24px;
}
/* Контейнер для двух бейджей */
.dual-badges {
    position: absolute;
    top: 8px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start; /* Выравнивание по верху */
    padding: 0 8px;
    pointer-events: none;
    z-index: 10; /* Контейнер выше остальных элементов */
}

/* Левый бейдж (эффективность) */
.card-badge-left {
    background: rgba(239, 83, 80, 0.9) !important;
    color: white !important;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    z-index: 2; /* Выше правого */
    position: relative; /* Для работы z-index */
    flex-shrink: 0; /* Не сжимается */
    margin-left: 12px; /* 👈 Смещение вправо */
}

/* Правый бейдж (загруженность) */
.card-badge-right {
    background: rgba(255, 255, 255, 0.3);
    color: inherit;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    z-index: 1; /* Ниже левого */
    position: relative; /* Для работы z-index */
    flex-shrink: 0; /* Не сжимается */
/*    margin-right: 16px;  👈 Симметричное смещение */
}

/* Цвета для эффективности (левый бейдж) */
.badge-efficiency-high {
    background: #42a5f5 !important;
    color: white !important;
}

.badge-efficiency-good {
    background: #90caf9 !important;
    color: #1565c0 !important;
}

.badge-efficiency-medium {
    background: #ffa726 !important;
    color: white !important;
}

.badge-efficiency-low {
    background: #ff7043 !important;
    color: white !important;
}

.badge-efficiency-critical {
    background: #ef5350 !important;
    color: white !important;
}

/* Цвета для загруженности (правый бейдж) - существующие */
.card-badge.badge-low {
    background: #d4edda !important;
    color: #155724 !important;
}

.card-badge.badge-normal {
    background: #d1ecf1 !important;
    color: #0c5460 !important;
}

.card-badge.badge-medium {
    background: #fff3cd !important;
    color: #856404 !important;
}

.card-badge.badge-high {
    background: #f8d7da !important;
    color: #721c24 !important;
}

.card-badge.badge-critical {
    background: #d32f2f !important;
    color: white !important;
}

/* Residents Heatmap Styles */
.entrances-heatmap-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.entrance-heatmap-card {
    background: var(--tg-theme-secondary-bg-color, #fff);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.entrance-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
}

.entrance-number {
    font-size: 16px;
    font-weight: 700;
    color: #2c3e50;
}

.entrance-range {
    font-size: 11px;
    color: #7f8c8d;
}

/* Wrapper для heatmap и overlay процента */
.entrance-heatmap-wrapper {
    position: relative;
    display: inline-block;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 8px;
}

.entrance-heatmap {
    display: grid;
    gap: 2px;
}

.heatmap-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    background: #ecf0f1;
    transition: transform 0.2s, background 0.2s;
    cursor: pointer;
}

.heatmap-dot.connected {
    background: #27ae60;
    box-shadow: 0 0 4px rgba(39, 174, 96, 0.5);
}

.heatmap-dot:hover {
    transform: scale(1.4);
    z-index: 10;
}

/* Процент поверх heatmap с прозрачностью 25% */
.entrance-percentage-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 32px;
    font-weight: 700;
    color: #dd3322;
    opacity: 0.45;
    pointer-events: none;
    user-select: none;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}

.entrance-stats {
    font-size: 13px;
    color: #7f8c8d;
    font-weight: 600;
    text-align: center;
}

/* Адаптивность для мобильных */
@media (max-width: 400px) {
    .entrances-heatmap-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .entrance-percentage-overlay {
        font-size: 28px;
    }
}