/* --- Общие сбросы --- */
* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
}

/* Контейнер */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Шапка */
header {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e8e8e8;
}

header h1 { 
    font-size: 26px; 
    color: #1a1a2e; 
    margin: 0 0 5px 0;
}
.subtitle { 
    color: #888; 
    font-size: 14px; 
    margin: 0;
}

/* Фильтры */
.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    padding: 15px 20px;
    background: #ffffff;
    border-radius: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1 1 180px;
    min-width: 140px;
}

.filter-group label {
    font-weight: 600;
    color: #333;
    font-size: 13px;
}

.filter-group input {
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    width: 100%;
    transition: border-color 0.3s;
    background: #fafafa;
}

.filter-group input:focus {
    border-color: #667eea;
    outline: none;
    background: #fff;
}

#filter-button, #refresh-button {
    padding: 10px 28px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

#filter-button {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

#filter-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

#refresh-button {
    background: #2d3436;
    color: white;
}

#refresh-button:hover {
    background: #1a1a2e;
}

/* Статистика */
.stats {
    padding: 12px 20px;
    background: #ffffff;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.stat-item {
    display: flex;
    gap: 8px;
    font-size: 14px;
    color: #555;
}
.stat-value { 
    font-weight: 700; 
    color: #1a1a2e; 
}

/* ============================================================ */
/* ТАБЛИЦА - ДЕСКТОПНАЯ ВЕРСИЯ                                  */
/* ============================================================ */
#zone-table-wrapper {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    overflow: hidden;
    padding: 0;
}

.pricelist-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.pricelist-table th, 
.pricelist-table td {
    border: 1px solid #e8e8e8;
    padding: 12px 15px;
    text-align: center;
}

.pricelist-table thead tr:first-child th {
    background: #f8f9fa;
    font-weight: 700;
    color: #1a1a2e;
    font-size: 15px;
}

.pricelist-table thead tr:last-child th {
    background: #f0f0f0;
    font-weight: 600;
    color: #444;
    font-size: 13px;
}

.pricelist-table tbody td:first-child {
    text-align: left !important;
    padding-left: 20px !important;
    font-weight: 600;
    color: #1a1a2e;
}

.registrar-header {
    font-size: 15px;
    font-weight: 700;
}

.price-cell {
    font-weight: 600;
    color: #2d3436;
    font-size: 14px;
}

.price-cell .rub {
    font-weight: 400;
    color: #888;
    font-size: 0.85em;
}

.price-cell .empty {
    color: #ccc;
    font-size: 0.9em;
}

.pricelist-table tbody tr:nth-child(odd) {
    background: #fafafa;
}
.pricelist-table tbody tr:nth-child(even) {
    background: #ffffff;
}
.pricelist-table tbody tr:hover {
    background: #f0f4ff;
}

/* ============================================================ */
/* МОБИЛЬНАЯ ВЕРСИЯ - КАРТОЧКИ                                  */
/* ============================================================ */

@media (max-width: 768px) {
    .container {
        padding: 12px 10px;
    }

    header h1 {
        font-size: 20px;
    }
    
    .subtitle {
        font-size: 13px;
    }
    
    .filters {
        padding: 12px 15px;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .filter-group {
        flex: none;
        width: 100%;
        min-width: 0;
    }

    .filter-group input {
        font-size: 16px;
        padding: 12px 14px;
    }

    #filter-button, #refresh-button {
        width: 100%;
        padding: 14px;
        text-align: center;
        font-size: 15px;
    }
    
    .stats {
        padding: 10px 15px;
        font-size: 13px;
    }
    
    .stat-item {
        font-size: 13px;
    }
    
    /* ===== ПРЕВРАЩАЕМ ТАБЛИЦУ В КАРТОЧКИ ===== */
    #zone-table-wrapper {
        background: transparent;
        box-shadow: none;
        border-radius: 0;
        padding: 0;
    }
    
    .pricelist-table {
        display: block;
        border: none;
    }
    
    .pricelist-table thead {
        display: none;
    }
    
    .pricelist-table tbody {
        display: block;
    }
    
    .pricelist-table tbody tr {
        display: block;
        background: #ffffff !important;
        border-radius: 12px;
        box-shadow: 0 2px 12px rgba(0,0,0,0.08);
        margin-bottom: 16px;
        padding: 16px;
        border: 1px solid #e8e8e8;
        transition: all 0.2s;
    }
    
    .pricelist-table tbody tr:hover {
        box-shadow: 0 4px 20px rgba(0,0,0,0.12);
        transform: translateY(-2px);
    }
    
    .pricelist-table tbody tr td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border: none;
        border-bottom: 1px solid #f0f0f0;
        text-align: right;
        font-size: 14px;
        background: transparent !important;
    }
    
    .pricelist-table tbody tr td:last-child {
        border-bottom: none;
    }
    
    /* Первая колонка - зона */
    .pricelist-table tbody tr td:first-child {
        font-size: 18px;
        font-weight: 700;
        color: #1a1a2e;
        padding: 0 0 12px 0;
        border-bottom: 2px solid #667eea;
        justify-content: flex-start;
        text-align: left;
    }
    
    /* Добавляем лейблы для всех остальных колонок */
    .pricelist-table tbody tr td:not(:first-child)::before {
        content: attr(data-label);
        font-weight: 600;
        color: #666;
        font-size: 13px;
        text-align: left;
    }
    
    .pricelist-table tbody tr td:not(:first-child) {
        padding: 8px 0;
        gap: 10px;
    }
    
    /* Цены */
    .price-cell {
        font-size: 15px;
        font-weight: 700;
        color: #2d3436;
    }
    
    .price-cell .rub {
        font-size: 0.8em;
    }
    
    .price-cell .empty {
        color: #bbb;
        font-size: 0.9em;
    }
}

/* ============================================================ */
/* ПЛАНШЕТЫ (768px - 1024px)                                    */
/* ============================================================ */

@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding: 15px;
    }
    
    .pricelist-table {
        font-size: 13px;
    }
    
    .pricelist-table th, 
    .pricelist-table td {
        padding: 10px 12px;
    }
    
    .price-cell {
        font-size: 13px;
    }
}

/* ============================================================ */
/* ОЧЕНЬ МАЛЕНЬКИЕ ЭКРАНЫ (до 400px)                           */
/* ============================================================ */

@media (max-width: 400px) {
    .container {
        padding: 8px 6px;
    }
    
    header h1 {
        font-size: 18px;
    }
    
    .subtitle {
        font-size: 12px;
    }
    
    .filters {
        padding: 10px 12px;
        gap: 8px;
    }
    
    .filter-group input {
        padding: 10px 12px;
        font-size: 15px;
    }
    
    #filter-button, #refresh-button {
        padding: 12px;
        font-size: 14px;
    }
    
    .stats {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .stat-item {
        font-size: 12px;
    }
    
    .pricelist-table tbody tr {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .pricelist-table tbody tr td {
        padding: 6px 0;
        font-size: 13px;
    }
    
    .pricelist-table tbody tr td:first-child {
        font-size: 16px;
        padding-bottom: 10px;
    }
    
    .pricelist-table tbody tr td:not(:first-child)::before {
        font-size: 12px;
    }
    
    .price-cell {
        font-size: 14px;
    }
}

/* ============================================================ */
/* ТЕМНАЯ ТЕМА (опционально)                                    */
/* ============================================================ */

@media (prefers-color-scheme: dark) {
    body {
        background: #1a1a2e;
    }
    
    header h1 {
        color: #f0f0f0;
    }
    
    .subtitle {
        color: #aaa;
    }
    
    .filters,
    .stats,
    #zone-table-wrapper {
        background: #2d2d44;
    }
    
    .filter-group label {
        color: #e0e0e0;
    }
    
    .filter-group input {
        background: #3d3d55;
        border-color: #555;
        color: #f0f0f0;
    }
    
    .filter-group input:focus {
        border-color: #667eea;
        background: #4a4a66;
    }
    
    .pricelist-table th,
    .pricelist-table td {
        border-color: #444;
    }
    
    .pricelist-table thead tr:first-child th {
        background: #3d3d55;
        color: #f0f0f0;
    }
    
    .pricelist-table thead tr:last-child th {
        background: #35354a;
        color: #ddd;
    }
    
    .pricelist-table tbody td:first-child {
        color: #f0f0f0;
    }
    
    .pricelist-table tbody tr:nth-child(odd) {
        background: #2d2d44;
    }
    .pricelist-table tbody tr:nth-child(even) {
        background: #33334a;
    }
    .pricelist-table tbody tr:hover {
        background: #3d3d66;
    }
    
    .price-cell {
        color: #e0e0e0;
    }
    
    .price-cell .rub {
        color: #aaa;
    }
    
    .price-cell .empty {
        color: #666;
    }
    
    .stat-item {
        color: #ccc;
    }
    .stat-value {
        color: #f0f0f0;
    }
    
    /* Мобильные карточки в темной теме */
    @media (max-width: 768px) {
        .pricelist-table tbody tr {
            background: #2d2d44 !important;
            border-color: #444;
        }
        
        .pricelist-table tbody tr td {
            border-bottom-color: #444;
        }
        
        .pricelist-table tbody tr td:first-child {
            color: #f0f0f0;
            border-bottom-color: #667eea;
        }
        
        .pricelist-table tbody tr td:not(:first-child)::before {
            color: #aaa;
        }
    }
}

/* ============================================================ */
/* ПЕЧАТЬ                                                        */
/* ============================================================ */

@media print {
    #filter-button, 
    #refresh-button, 
    .filters {
        display: none !important;
    }
    
    .pricelist-table {
        font-size: 12px;
    }
    
    .pricelist-table th, 
    .pricelist-table td {
        padding: 6px 10px;
    }
    
    #zone-table-wrapper {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}