* {
    box-sizing: border-box;
}

:root {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #182230;
    background: #f4f7fb;
    line-height: 1.5;
}

body {
    margin: 0;
    min-height: 100vh;
}

a {
    color: #245bb5;
}

code {
    background: #f0f3f7;
    padding: 2px 6px;
    border-radius: 6px;
}

.topbar {
    min-height: 64px;
    padding: 12px 5vw;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar nav {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.topbar a {
    text-decoration: none;
}

.brand {
    color: #172033;
    font-weight: 850;
    font-size: 1.15rem;
}

.container {
    width: min(100%, 98vw);
    margin: auto;
}

.card {
    min-width: 0;
    background: #fff;
    border: 1px solid #e3e8ef;
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 14px 38px rgba(28, 39, 60, 0.07);
}

.narrow, .hero, .result-card {
    max-width: 1100px;
    margin: 50px auto;
}

.eyebrow {
    color: #245bb5;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 800;
    font-size: .78rem;
}

h1, h2 {
    line-height: 1.15;
}

.stack {
    display: grid;
    gap: 12px;
}

label {
    font-weight: 700;
}

input, textarea, select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    border: 1px solid #cdd6e2;
    background: #fff;
    border-radius: 10px;
    padding: 12px 14px;
    font: inherit;
}

textarea {
    resize: vertical;
}

button, .button-link {
    appearance: none;
    border: 0;
    border-radius: 10px;
    padding: 12px 18px;
    background: #245bb5;
    color: white;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

button:hover, .button-link:hover {
    filter: brightness(.96);
}

.secondary {
    background: #526175;
}

.danger {
    background: #bd3737;
}

.flash {
    padding: 12px 15px;
    border-radius: 10px;
    background: #fff4cc;
    border: 1px solid #ead382;
    margin-bottom: 18px;
}

.flash.error {
    background: #fee7e7;
    border-color: #efa6a6;
}

.flash.success {
    background: #e3f8eb;
    border-color: #9bdbb1;
}

.muted {
    color: #69788d;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.checkbox-row input {
    width: auto;
}

.actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.dashboard-actions {
    flex-wrap: nowrap;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.question-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
    gap: 24px;
    align-items: start;
}

.schedule-fields {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
    gap: 16px;
}

.schedule-fields label {
    display: block;
    margin-bottom: 8px;
}

.schedule-fields > div,
.dashboard-section-heading > * {
    min-width: 0;
}

.schedule-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.stats {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.stat {
    display: grid;
    gap: 6px;
}

.stat strong {
    font-size: 2rem;
}

.stat span {
    color: #69788d;
}

.page-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dashboard-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.dashboard-section-heading h2,
.dashboard-section-heading p {
    margin: 0;
}

.quiz-container {
    max-width: 850px;
}

.quiz-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 16px;
}

.timer-box {
    text-align: right;
}

.timer {
    font-size: 2.7rem;
    line-height: 1;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.progress {
    height: 8px;
    background: #dfe6ef;
    border-radius: 100px;
    overflow: hidden;
    margin-bottom: 18px;
}

.progress-bar {
    height: 100%;
    width: 0;
    background: #245bb5;
    transition: width .25s ease;
}

.question-title {
    font-size: clamp(1.4rem, 4vw, 2rem);
}

.options {
    display: grid;
    gap: 12px;
    margin: 24px 0;
}

.option-card {
    display: grid;
    grid-template-columns: auto auto 1fr;
    align-items: center;
    gap: 12px;
    padding: 15px;
    border: 1px solid #d7dfe9;
    border-radius: 12px;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}

.option-card:hover, .option-card.selected {
    border-color: #245bb5;
    background: #f1f6ff;
}

.option-card input {
    width: auto;
}

.option-key {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #e7eefb;
    font-weight: 900;
}

.save-status {
    min-height: 24px;
    font-size: .92rem;
}

.result-card {
    text-align: center;
}

.score {
    font-size: 3rem;
    line-height: 1;
    font-weight: 900;
    margin: 25px 0;
}

.score span {
    font-size: .5em;
    color: #69788d;
}

.score.compact {
    margin: 0;
    font-size: 2.25rem;
}

.result-heading {
    margin-bottom: 18px;
}

.table-card {
    margin-top: 24px;
}

.table-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 10px;
    border-bottom: 1px solid #e6ebf1;
    text-align: left;
    vertical-align: top;
}

th {
    color: #607086;
    font-size: .9rem;
}

.badge {
    display: inline-block;
    padding: 4px 9px;
    border-radius: 999px;
    background: #e9edf3;
    color: #46566d;
    font-weight: 800;
    font-size: .8rem;
}

.badge.success {
    background: #def7e8;
    color: #17613b;
}

.badge.error {
    background: #fee7e7;
    color: #9f2525;
}

.row-actions {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
}

.row-actions form {
    margin: 0;
}

.small-btn {
    padding: 7px 10px;
    font-size: .85rem;
}

@media (max-width: 800px) {
    body {
        font-size: .92rem;
    }

    .topbar {
        flex-wrap: wrap;
        padding: 10px 3vw;
    }

    .topbar nav {
        width: 100%;
        gap: 8px 14px;
    }

    .topbar nav a {
        font-size: .88rem;
    }

    .container {
        width: min(94vw, 1100px);
        margin: 24px auto;
    }

    .card {
        padding: 16px;
        border-radius: 12px;
    }

    h1 {
        font-size: 1.7rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    input, textarea, select {
        padding: 9px 11px;
        border-radius: 8px;
        font-size: .92rem;
    }

    button, .button-link {
        padding: 9px 13px;
        border-radius: 8px;
        font-size: .92rem;
    }

    .dashboard-actions {
        flex-wrap: wrap;
    }

    .stats {
        grid-template-columns: 1fr 1fr;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .question-layout {
        grid-template-columns: 1fr;
    }

    .schedule-fields {
        grid-template-columns: 1fr;
    }

    .table-wrap table {
        min-width: 560px;
    }

    th, td {
        padding: 9px 8px;
    }
}

@media (max-width: 560px) {
    .container {
        margin: 22px auto;
    }

    .topbar {
        align-items: flex-start;
    }

    .brand {
        font-size: 1rem;
    }

    .dashboard-actions,
    .dashboard-section-heading,
    .schedule-buttons {
        flex-wrap: wrap;
    }

    .stats {
        grid-template-columns: 1fr;
    }

    .quiz-header {
        align-items: center;
    }

    .timer {
        font-size: 2.2rem;
    }

    .option-card {
        grid-template-columns: auto auto 1fr;
        padding: 12px;
    }

    .page-title {
        align-items: flex-start;
        gap: 16px;
    }
}
