* {
    box-sizing: border-box;
}
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
}
.container {
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    background: white;
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1), 0 4px 12px rgba(0,0,0,0.05);
    padding: 30px 32px 40px 32px;
    transition: all 0.3s ease;
}
h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-weight: 600;
    font-size: 1.8rem;
    color: #1a2a3a;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 15px;
}
.status {
    padding: 14px 20px;
    border-radius: 16px;
    margin-bottom: 24px;
    font-weight: 600;
    color: white;
    background: #ff9800;
    font-size: 1.1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.2s;
}
.current-action {
    background: #f1f3f5;
    padding: 14px 20px;
    border-radius: 16px;
    margin-bottom: 28px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    border-left: 5px solid #0078c1;
    color: #2c3e50;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.stats {
    display: flex;
    gap: 24px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}
.stat-card {
    background: #f8f9fa;
    border-radius: 20px;
    padding: 16px 28px;
    flex: 1;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    transition: transform 0.2s;
}
.stat-card:hover {
    transform: translateY(-3px);
}
.stat-card h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    color: #495057;
    letter-spacing: 0.5px;
}
.stat-card .value {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 8px 0 0;
    color: #0078c1;
    line-height: 1;
}
.table-wrapper {
    overflow-x: auto;
    border-radius: 20px;
    margin-top: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border: 1px solid #e9ecef;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: white;
}
th {
    background-color: #0078c1;
    color: white;
    padding: 14px 12px;
    font-weight: 600;
    font-size: 14px;
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap;
}
td {
    padding: 12px;
    border-bottom: 1px solid #e9ecef;
    vertical-align: middle;
    word-break: break-word;
    background-color: white;
    transition: background-color 0.2s ease;
}
tr:hover td {
    background-color: #f0f7ff;
}
.name-cell {
    line-height: 1.4;
}
.moved-badge {
    display: inline-block;
    background-color: #dc3545;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 30px;
    white-space: nowrap;
    letter-spacing: 0.3px;
    margin-left: 8px;
    vertical-align: middle;
}
.phone-list {
    margin: 0;
    padding: 0;
    list-style: none;
}
.phone-list li {
    white-space: nowrap;
    margin-bottom: 4px;
    font-family: monospace;
    font-size: 12px;
}
.phone-list li:last-child {
    margin-bottom: 0;
}
.website-cell {
    white-space: pre-line;
    font-family: monospace;
    font-size: 12px;
    line-height: 1.4;
}
.coordinates-cell {
    white-space: pre-line;
    font-family: monospace;
    font-size: 12px;
    line-height: 1.4;
}
.download-btn {
    display: inline-block;
    margin-top: 28px;
    background: #28a745;
    color: white;
    padding: 12px 28px;
    text-decoration: none;
    border-radius: 40px;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.download-btn:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.1);
}
.new-btn {
    background: #6c757d;
    display: inline-block;
    padding: 8px 20px;
    border-radius: 40px;
    text-decoration: none;
    color: white;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}
.new-btn:hover {
    background: #5a6268;
    transform: translateY(-1px);
}
.stop-btn {
    background-color: #dc3545;
    border: none;
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 40px;
    cursor: pointer;
    color: white;
    transition: all 0.2s;
    white-space: nowrap;
}
.stop-btn:hover {
    background-color: #c82333;
    transform: translateY(-1px);
}
.refresh {
    color: #6c757d;
    font-size: 0.8rem;
    margin-top: 20px;
    text-align: center;
}
.button-group {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: nowrap;
    flex-shrink: 0;
}
.no-data {
    padding: 40px;
    text-align: center;
    color: #6c757d;
}
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }
    h2 {
        font-size: 1.4rem;
        flex-direction: column;
        align-items: stretch;
    }
    .button-group {
        flex-wrap: wrap;
        justify-content: flex-start;
    }
    .stats {
        gap: 12px;
    }
    .stat-card .value {
        font-size: 1.8rem;
    }
}
input, button {
    font-size: 1em;
    padding: 10px;
    margin: 5px 0;
    width: 100%;
    box-sizing: border-box;
}
button {
    background: #0078c1;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}
button:hover {
    background: #005f8c;
}
.note {
    font-size: 0.9em;
    color: #555;
    margin-top: 15px;
}
.error {
    color: red;
    margin-top: 10px;
}
select[size] {
    max-height: 250px;
    overflow-y: auto;
}

/* Стили для автокомплита и фильтрации */
.search-box {
    margin-bottom: 8px;
}
.search-box input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
}
.autocomplete-container {
    position: relative;
}
.autocomplete-items {
    position: absolute;
    border: 1px solid #d4d4d4;
    border-bottom: none;
    border-top: none;
    z-index: 99;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 300px;
    overflow-y: auto;
    background: white;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.autocomplete-items div {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #e9ecef;
    font-size: 14px;
}
.autocomplete-items div:hover {
    background-color: #e9ecef;
}
.autocomplete-items .territory-region {
    font-size: 12px;
    color: #6c757d;
    margin-left: 10px;
}
.territory-type-badge {
    background: #e2f0ff;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 10px;
    margin-left: 8px;
}

/* Стили для иерархического выбора */
.hierarchy-container {
    background: #f8f9fa;
    border-radius: 16px;
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-start;
}
.hierarchy-level {
    display: flex;
    flex-direction: column;
    min-width: 200px;
    background: white;
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.hierarchy-label {
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 5px;
}
.hierarchy-select {
    padding: 8px 10px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    background: white;
    font-size: 14px;
    min-width: 180px;
}
.warning-message {
    font-size: 12px;
    color: #dc3545;
    margin-top: 5px;
}