:root {
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --green: #16a34a;
    --red: #dc2626;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-400: #94a3b8;
    --gray-600: #475569;
    --gray-900: #0f172a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--blue-dark);
    text-decoration: none;
}

.topbar nav { display: flex; gap: 0.25rem; flex-wrap: wrap; }

.topbar nav a {
    text-decoration: none;
    color: var(--gray-600);
    padding: 0.4rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
}

.topbar nav a.active,
.topbar nav a:hover {
    background: var(--gray-100);
    color: var(--blue-dark);
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.25rem;
}

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.75rem; }

.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert ul { margin: 0.25rem 0 0; padding-left: 1.25rem; }

.card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat {
    text-align: center;
}
.stat .value { font-size: 2rem; font-weight: 700; color: var(--blue-dark); }
.stat .label { color: var(--gray-600); font-size: 0.85rem; }

.btn {
    display: inline-block;
    padding: 0.55rem 1.1rem;
    border-radius: 0.5rem;
    border: none;
    background: var(--blue);
    color: white;
    text-decoration: none;
    font-size: 0.95rem;
    cursor: pointer;
}
.btn:hover { background: var(--blue-dark); }
.btn-secondary { background: var(--gray-200); color: var(--gray-900); }
.btn-secondary:hover { background: var(--gray-400); }
.btn-danger { background: var(--red); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.85rem; }

table { width: 100%; border-collapse: collapse; background: white; border-radius: 0.75rem; overflow: hidden; }
th, td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--gray-200); font-size: 0.9rem; }
th { background: var(--gray-100); font-weight: 600; }
tr:last-child td { border-bottom: none; }

.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-active { background: #dcfce7; color: #166534; }
.badge-inactive { background: #f1f5f9; color: var(--gray-600); }

form.inline { display: inline; }

.form-group { margin-bottom: 1rem; }
label { display: block; font-weight: 600; margin-bottom: 0.3rem; font-size: 0.9rem; }
input[type=text], input[type=number], input[type=search], textarea, select {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    font-size: 0.95rem;
    font-family: inherit;
}
textarea { min-height: 5rem; }
.checkbox-row { display: flex; align-items: center; gap: 0.5rem; }
.checkbox-row input { width: auto; }

.filters { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: end; }
.filters .form-group { margin-bottom: 0; min-width: 160px; }

.option-row { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.option-row .label-badge {
    width: 1.75rem; height: 1.75rem; border-radius: 50%;
    background: var(--gray-100); display: flex; align-items: center; justify-content: center;
    font-weight: 700; flex-shrink: 0;
}
.option-row input[type=radio] { width: auto; flex-shrink: 0; }

.question-card { border-left: 4px solid var(--gray-200); }
.question-card.correct { border-left-color: var(--green); }
.question-card.incorrect { border-left-color: var(--red); }
.question-meta { font-size: 0.8rem; color: var(--gray-600); margin-bottom: 0.5rem; }
.option-result { padding: 0.4rem 0.6rem; border-radius: 0.4rem; margin-bottom: 0.3rem; font-size: 0.9rem; }
.option-result.is-correct { background: #dcfce7; color: #166534; }
.option-result.is-selected-wrong { background: #fee2e2; color: #991b1b; }

.pagination { margin-top: 1rem; }
.empty-state { text-align: center; padding: 2rem; color: var(--gray-600); }

.score-big { font-size: 2.5rem; font-weight: 800; color: var(--blue-dark); text-align: center; }
.score-sub { text-align: center; color: var(--gray-600); margin-bottom: 1.5rem; }

@media (max-width: 600px) {
    .topbar { flex-direction: column; align-items: flex-start; }
}
