* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

h1 {
    color: #2c3e50;
    margin-bottom: 10px;
}

.subtitle {
    color: #7f8c8d;
    font-size: 1.1em;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tab {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: #ecf0f1;
    cursor: pointer;
    border-radius: 6px;
    font-size: 1em;
    transition: all 0.3s;
}

.tab:hover {
    background: #bdc3c7;
}

.tab.active {
    background: #3498db;
    color: white;
}

.view {
    display: none;
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.view.active {
    display: block;
}

.view h2 {
    color: #2c3e50;
    margin-bottom: 20px;
}

.info {
    color: #7f8c8d;
    margin-bottom: 15px;
    font-style: italic;
}

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-box input[type="text"] {
    flex: 1;
    padding: 12px;
    border: 2px solid #ecf0f1;
    border-radius: 6px;
    font-size: 1em;
}

.search-box input[type="number"] {
    width: 80px;
    padding: 12px;
    border: 2px solid #ecf0f1;
    border-radius: 6px;
    font-size: 1em;
}

.search-box button {
    padding: 12px 30px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    transition: background 0.3s;
}

.search-box button:hover {
    background: #2980b9;
}

.surveys-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.survey-card {
    padding: 20px;
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.survey-card:hover {
    border-color: #3498db;
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.2);
}

.survey-card.selected {
    border-color: #3498db;
    background: #ecf8ff;
}

.survey-card h3 {
    color: #2c3e50;
    margin-bottom: 10px;
}

.survey-card p {
    color: #7f8c8d;
    font-size: 0.9em;
}

.rounds-container {
    margin-bottom: 30px;
}

.rounds-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.round-btn {
    padding: 12px;
    background: #ecf0f1;
    border: 2px solid #bdc3c7;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s;
}

.round-btn:hover {
    background: #bdc3c7;
}

.round-btn.selected {
    background: #3498db;
    color: white;
    border-color: #2980b9;
}

.questions-container, .results-container {
    margin-top: 20px;
}

.question-item {
    padding: 15px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border-left: 4px solid #3498db;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.question-item:hover {
    background: #e9ecef;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.question-key {
    font-weight: bold;
    color: #3498db;
    font-size: 0.9em;
}

.question-title {
    font-weight: 600;
    color: #2c3e50;
    margin: 5px 0;
}

.question-text {
    color: #555;
    font-size: 0.95em;
    margin: 5px 0;
}

.question-meta {
    color: #7f8c8d;
    font-size: 0.85em;
    margin-top: 5px;
}

.similarity-score {
    display: inline-block;
    background: #27ae60;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    margin-left: 10px;
}

.topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.topic-btn {
    padding: 12px;
    background: #ecf0f1;
    border: 2px solid #bdc3c7;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s;
}

.topic-btn:hover {
    background: #bdc3c7;
}

.topic-btn.selected {
    background: #3498db;
    color: white;
    border-color: #2980b9;
}

dialog {
    margin: auto;
    padding: 30px;
    border: 0;
    border-radius: 8px;
    width: min(90%, 800px);
    max-height: 80vh;
    overflow-y: auto;
}

dialog::backdrop { background: rgba(0,0,0,0.5); }

button, select, input { font: inherit; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible {
    outline: 3px solid #195f8c;
    outline-offset: 3px;
}

button.question-item { display: block; width: 100%; text-align: left; border: 0; border-left: 4px solid #3498db; }
.question-item span { display: block; }
button.survey-card { text-align: left; background: white; }
.search-filters { display: flex; flex-wrap: wrap; gap: 16px; align-items: end; margin-bottom: 16px; }
.search-filters label { display: flex; flex-direction: column; gap: 4px; }
.search-filters select, .search-filters input, .search-filters button { padding: 8px; }
.search-filters input { width: 100px; }
.question-text, #question-detail { overflow-wrap: anywhere; }

@media (max-width: 600px) {
    .container, .view { padding: 12px; }
    .tabs { flex-wrap: wrap; }
    .tab { flex-basis: 40%; padding: 10px; }
    .surveys-grid { grid-template-columns: 1fr; }
    .search-box { flex-wrap: wrap; }
    .search-box input[type="text"] { min-width: 0; width: 100%; }
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

.answer-list {
    margin-top: 15px;
}

.answer-item {
    padding: 8px;
    margin: 5px 0;
    background: #f8f9fa;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
}

.answer-value {
    font-weight: bold;
    color: #3498db;
    min-width: 50px;
}

.answer-category {
    flex: 1;
    margin-left: 15px;
}

.missing-value {
    color: #e74c3c;
    font-style: italic;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
}

.error {
    background: #fee;
    border-left: 4px solid #e74c3c;
    padding: 15px;
    border-radius: 4px;
    color: #c0392b;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
}

.permission { border-top: 1px solid #ddd; margin-top: 1rem; }
.permission .muted { color: #555; }
