/* ================== БАЗОВІ НАЛАШТУВАННЯ ================== */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
    background: #0a0a0a;
    color: #e5e7eb;
}

/* Кастомний скроллбар */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #111;
}
::-webkit-scrollbar-thumb {
    background: #374151;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #4b5563;
}

/* ================== КАРТА ================== */
#map {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background: #000;
}

.leaflet-tile {
    filter: brightness(0.6) invert(1) contrast(3) hue-rotate(200deg) saturate(0.3) brightness(0.7);
}

/* СТИЛІ ДЛЯ ПОПАПІВ НА КАРТІ */
.custom-popup {
    font-family: 'Inter', sans-serif;
    color: #111;
    font-size: 14px;
    line-height: 1.4;
}
.custom-popup-title {
    font-size: 1.15em;
    font-weight: 700;
    display: block;
    margin-bottom: 4px;
}
.custom-popup-divider {
    border: 0;
    border-top: 1px solid #d1d5db;
    margin: 6px 0;
}
.custom-popup-date {
    color: #6b7280;
    font-size: 0.85em;
    display: block;
}

/* ================== ОВЕРЛЕЇ ================== */
.overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 10;
}
.overlay > * {
    pointer-events: auto;
}

/* ================== DATE SWITCH ================== */
.date-switch {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    background: rgba(17, 24, 39, 0.85);
    backdrop-filter: blur(8px);
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #374151;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    z-index: 100;
}
.date-btn {
    background: #1f2937;
    border: 1px solid #374151;
    color: #d1d5db;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.date-btn:hover {
    background: #374151;
    color: #fff;
}
.map-date {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    min-width: 95px;
    text-align: center;
    font-weight: 500;
    margin: 0 12px;
    color: #f3f4f6;
}

/* ================== FAB "Список" ================== */
.fab {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: #1f2937;
    color: #e5e7eb;
    border: 1px solid #374151;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    z-index: 110;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.fab:hover {
    background: #374151;
    border-color: #4b5563;
}

/* ================== ПАНЕЛЬ СПИСКУ ================== */
.list-panel {
    position: fixed;
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(12px);
    box-shadow: -4px 0 25px rgba(0, 0, 0, 0.7);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 120;
    display: flex;
    flex-direction: column;
}

@media (min-width: 901px) {
    .list-panel {
        top: 0;
        bottom: 0;
        right: 0;
        width: 420px;
        transform: translateX(0);
        border-left: 1px solid #374151;
    }
    .list-panel.hidden {
        transform: translateX(100%) !important;
    }
}

@media (max-width: 900px) {
    .list-panel {
        left: 0;
        right: 0;
        bottom: 0;
        height: 85vh;
        border-top: 1px solid #374151;
        border-radius: 12px 12px 0 0;
        transform: translateY(0);
    }
    .list-panel.hidden {
        transform: translateY(100%) !important;
    }
    .fab {
        top: 16px;
        right: 16px;
    }
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #374151;
    background: #111827;
    flex-shrink: 0;
}
.header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}
.status-indicator {
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 8px #ef4444;
}
.panel-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #f3f4f6;
}
.close-btn {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}
.close-btn:hover { color: #ef4444; }

/* ================== ПОШУК ================== */
.search-container {
    padding: 12px 20px;
    border-bottom: 1px solid #374151;
    flex-shrink: 0;
    background: #111827;
}
#searchInput {
    width: 100%;
    padding: 10px 14px;
    background: #1f2937;
    border: 1px solid #4b5563;
    border-radius: 4px;
    color: #e5e7eb;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}
#searchInput:focus { border-color: #60a5fa; }

/* ================== ТАБЛИЦЯ І ОБГОРТКА ================== */
.table-wrapper {
    flex: 1 1 auto;
    overflow-y: auto;
    background: #111827;
}

.houses-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.houses-table th,
.houses-table td {
    padding: 10px 16px;
    border-bottom: 1px solid #1f2937;
    text-align: left;
}
.houses-table th {
    background: #1f2937;
    position: sticky;
    top: 0;
    z-index: 5;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    box-shadow: 0 1px 0 #374151;
}
.houses-table tr {
    cursor: pointer;
    transition: background 0.15s;
}
.houses-table tr:hover {
    background: #1f2937;
}

/* Моноширинні колонки */
.houses-table td:nth-child(2),
.houses-table td:nth-child(4) {
    font-family: 'JetBrains Mono', monospace;
    color: #9ca3af;
}

/* --- СТИЛІ КОНТЕНТУ ТАБЛИЦІ (ЗАМІНА JS-INLINE СТИЛІВ) --- */
.empty-table-msg {
    text-align: center;
    padding: 2rem !important;
    color: #9ca3af;
}

.street-old {
    display: block;
    font-size: 0.85em;
    color: #6b7280;
    margin-top: 2px;
}

.status-cell {
    font-weight: 500;
}
.status-damaged {
    color: #f59e0b;
}
.status-destroyed {
    color: #ef4444;
}

/* ================== TG TOAST ================== */
#tg-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 320px;
    background: #1f2937;
    border-left: 4px solid #3b82f6;
    color: #e5e7eb;
    padding: 16px;
    border-radius: 4px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 130;
    font-size: 0.9rem;
    display: none;
    align-items: flex-start;
    justify-content: space-between;
}
.tg-content a {
    color: #60a5fa;
    text-decoration: none;
    font-weight: 600;
}
.tg-content a:hover { text-decoration: underline; }
#tg-toast-close {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0;
    margin-left: 10px;
}
#tg-toast-close:hover { color: #fff; }

@media (max-width: 500px) {
    #tg-toast {
        bottom: 90px;
        right: 16px;
        left: 16px;
        width: auto;
    }
}