* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #f0f2f5;
    padding: 20px;
}
.container {
    max-width: 100%;
    margin: 0 auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
}
.header {
    background: #0d2b4e;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}
.header h1 { font-size: 1.4em; margin-bottom: 5px; }
.export-btn {
    background: #25a366;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
}
.info {
    padding: 10px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    font-size: 12px;
}
.controls {
    padding: 12px 20px;
    background: white;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}
.region-select-wrapper {
    position: relative;
    min-width: 280px;
}
.region-select-input {
    padding: 6px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    width: 100%;
    font-size: 13px;
    background: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.region-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ced4da;
    border-radius: 4px;
    max-height: 350px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.region-dropdown.show { display: block; }
.region-search {
    padding: 8px;
    border-bottom: 1px solid #e9ecef;
    position: sticky;
    top: 0;
    background: white;
}
.region-search input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 12px;
}
.region-option {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    border-bottom: 1px solid #f0f0f0;
}
.region-option:hover { background: #e8f4f8; }
.region-option .region-code {
    font-size: 10px;
    color: #6c757d;
    margin-left: 8px;
}
.btn-group { display: flex; gap: 5px; }
.btn {
    padding: 6px 14px;
    border: 1px solid #6c757d;
    background: white;
    color: #6c757d;
    cursor: pointer;
    font-size: 12px;
    border-radius: 4px;
    transition: all 0.2s;
}
.btn.active {
    background: #0d2b4e;
    border-color: #0d2b4e;
    color: white;
}
.btn-refresh {
    background: #0d2b4e;
    border-color: #0d2b4e;
    color: white;
}
.filter-btn {
    background: #4a6fa5;
    border-color: #4a6fa5;
    color: white;
}
.display-panel {
    background: #f8f9fa;
    padding: 8px 20px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
}
.toggle-group {
    display: flex;
    gap: 15px;
    align-items: center;
}
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 8px;
}
.toggle-switch label {
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
}
.mode-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    padding-left: 15px;
    border-left: 1px solid #dee2e6;
}
.mode-label {
    font-size: 11px;
    color: #6c757d;
}
.mode-label.active { color: #25a366; font-weight: bold; }
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 22px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}
input:checked + .slider { background-color: #25a366; }
input:checked + .slider:before { transform: translateX(22px); }

.table-container {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 65vh;
    position: relative;
}

.stats-table {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 11px;
    width: 100%;
    min-width: 800px;
}
.stats-table th,
.stats-table td {
    border: 1px solid #dee2e6;
    padding: 8px 6px;
    vertical-align: top;
    background-color: white;
}
.stats-table th {
    background: #0d2b4e;
    color: white;
    text-align: center;
    font-weight: 600;
    font-size: 10px;
    position: sticky;
    top: 0;
    z-index: 10;
}
/* Фиксация первого столбца */
.stats-table th:first-child,
.stats-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 20;
    background-color: #f8f9fa;
}
.stats-table th:first-child {
    background: #0d2b4e;
    z-index: 30;
}
.stats-table td:first-child {
    background-color: #f8f9fa;
    font-weight: bold;
}
/* Дополнительные стили для предотвращения наезда контента */
.stats-table td:first-child,
.stats-table th:first-child {
    box-shadow: 2px 0 5px -2px rgba(0,0,0,0.1);
}
/* Стили для вложенных таблиц в ячейках */
.stats-table td .answer-table {
    width: 100%;
    border-collapse: collapse;
}
.stats-table td .answer-table td {
    border: none;
    padding: 4px 2px;
    background: transparent !important;
    position: static;
}
.stats-table td .answer-table td:first-child {
    position: static;
    background: transparent !important;
    box-shadow: none;
    width: 65%;
}
.stats-table td .answer-table td:last-child {
    text-align: right;
    white-space: nowrap;
}

.answer-count {
    font-size: 11px;
    font-weight: bold;
    color: #0d2b4e;
}
.answer-percent {
    font-size: 9px;
    color: #6c757d;
}
.average-box {
    background: #e8f4f8;
    padding: 4px 8px;
    margin-bottom: 6px;
    text-align: center;
    font-weight: bold;
    border-radius: 4px;
    font-size: 10px;
}
.footer {
    padding: 10px 20px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    font-size: 11px;
    text-align: center;
    color: #6c757d;
}

/* Анимированный прелоудер */
.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px;
    gap: 15px;
}
.loader {
    width: 45px;
    height: 45px;
    border: 4px solid #e9ecef;
    border-top: 4px solid #0d2b4e;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.loader-text {
    font-size: 13px;
    color: #6c757d;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}
.modal-content {
    background-color: white;
    margin: 5% auto;
    width: 90%;
    max-width: 700px;
    border-radius: 12px;
}
.modal-header {
    padding: 16px 20px;
    background: #0d2b4e;
    color: white;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
}
.close-modal {
    font-size: 28px;
    cursor: pointer;
    background: none;
    border: none;
    color: white;
}
.modal-body { padding: 20px; max-height: 60vh; overflow-y: auto; }
.questions-filter-list { display: flex; flex-direction: column; gap: 10px; }
.question-filter-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background: #f8f9fa;
}
.question-filter-item .q-badge {
    background: #0d2b4e;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
}
.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.modal-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}
.modal-btn-primary { background: #0d2b4e; color: white; }
.modal-btn-secondary { background: #e9ecef; color: #495057; }

@media (max-width: 768px) {
    body { padding: 10px; }
    .controls, .display-panel { flex-direction: column; align-items: stretch; }
    .mode-switch { margin-left: 0; border-left: none; padding-left: 0; justify-content: center; }
    .region-select-wrapper { width: 100%; }
}