:root {
    --app-bg: #f5f7fb;
    --app-surface: #ffffff;
    --app-text: #17202e;
    --app-muted: #667085;
    --app-border: #d9e0ea;
    --app-primary: #2563eb;
    --app-primary-soft: #dbeafe;
    --app-green: #16a34a;
    --app-green-soft: #dcfce7;
    --app-red: #dc2626;
    --app-red-soft: #fee2e2;
    --app-grey: #e5e7eb;
    --app-grey-text: #4b5563;
    --app-blue: #1d4ed8;
    --app-blue-soft: #dbeafe;
    --app-warning: #b45309;
    --app-warning-soft: #fef3c7;
}

* {
    letter-spacing: 0;
}

body {
    min-height: 100vh;
    background: var(--app-bg);
    color: var(--app-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-navbar {
    background: #182033;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-navbar .navbar-brand,
.app-navbar .nav-link {
    color: #ffffff;
}

.app-navbar .nav-link {
    opacity: 0.82;
}

.app-navbar .nav-link:hover,
.app-navbar .nav-link:focus {
    color: #ffffff;
    opacity: 1;
}

.navbar-toggler {
    border-color: rgba(255, 255, 255, 0.25);
}

.navbar-toggler-icon {
    filter: invert(1);
}

.app-container {
    max-width: 1440px;
}

.app-page {
    padding: 28px 0 48px;
}

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.page-heading h1,
.login-card h1 {
    margin: 0;
    font-size: 2rem;
    line-height: 1.15;
    font-weight: 750;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--app-primary);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.app-card {
    border: 1px solid var(--app-border);
    border-radius: 8px;
    box-shadow: 0 16px 40px rgba(17, 24, 39, 0.07);
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.section-title h2 {
    margin: 0;
    font-size: 1.08rem;
    line-height: 1.25;
    font-weight: 750;
}

.section-subtitle {
    color: var(--app-muted);
    font-size: 0.92rem;
}

.compact-alert {
    padding: 10px 12px;
    font-size: 0.92rem;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid var(--app-border);
    border-radius: 999px;
    background: #ffffff;
    color: var(--app-muted);
    font-size: 0.9rem;
    font-weight: 650;
    white-space: nowrap;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: var(--app-warning);
}

.status-pill.is-published .status-dot {
    background: var(--app-green);
}

.status-pill.is-open .status-dot {
    background: var(--app-primary);
}

.option-stack {
    display: grid;
    gap: 10px;
}

.answer-option {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #ffffff;
}

.answer-option:hover {
    border-color: rgba(37, 99, 235, 0.45);
    background: #fbfdff;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(110px, 1fr));
    gap: 12px;
}

.stat-tile {
    min-height: 78px;
    padding: 12px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #fbfcfe;
}

.stat-tile span {
    display: block;
    color: var(--app-muted);
    font-size: 0.78rem;
    font-weight: 650;
}

.stat-tile strong {
    display: block;
    margin-top: 8px;
    font-size: 1.35rem;
    line-height: 1;
    font-weight: 800;
}

.legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px 12px;
    color: var(--app-muted);
    font-size: 0.86rem;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid rgba(17, 24, 39, 0.1);
}

.matrix-scroll {
    width: 100%;
    overflow: auto;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #ffffff;
}

.matrix-grid {
    display: grid;
    grid-template-columns: repeat(var(--matrix-columns), 42px);
    gap: 6px;
    min-width: max-content;
    padding: 12px;
}

.matrix-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    aspect-ratio: 1 / 1;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #111827;
    font-size: 0.72rem;
    font-weight: 750;
    line-height: 1;
    cursor: pointer;
    transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.matrix-cell:hover,
.matrix-cell:focus {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(17, 24, 39, 0.14);
    outline: none;
}

.status-unanswered {
    background: var(--app-grey);
    color: var(--app-grey-text);
    border-color: #d1d5db;
}

.status-answered {
    background: var(--app-blue-soft);
    color: var(--app-blue);
    border-color: #93c5fd;
}

.status-correct {
    background: var(--app-green-soft);
    color: var(--app-green);
    border-color: #86efac;
}

.status-wrong {
    background: var(--app-red-soft);
    color: var(--app-red);
    border-color: #fca5a5;
}

.login-shell {
    min-height: calc(100vh - 160px);
    display: grid;
    place-items: center;
}

.login-card {
    width: min(100%, 420px);
}

.message-stack {
    margin-bottom: 18px;
}

.option-admin-list {
    display: grid;
    gap: 10px;
    margin: 16px 0 0;
    padding: 0;
    list-style: none;
}

.option-row {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) repeat(4, 38px);
    gap: 8px;
    align-items: center;
}

.option-order {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    color: var(--app-muted);
    background: #f8fafc;
    font-weight: 750;
}

.icon-button {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.icon-button svg,
.btn svg {
    width: 17px;
    height: 17px;
    stroke-width: 2.2;
}

.action-grid {
    display: grid;
    gap: 10px;
}

.detail-list {
    display: grid;
    gap: 10px;
    margin: 0;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--app-border);
}

.detail-row:last-child {
    border-bottom: 0;
}

.detail-row span {
    color: var(--app-muted);
}

.detail-row strong {
    text-align: right;
}

@media (max-width: 1199px) {
    .stats-grid {
        grid-template-columns: repeat(3, minmax(110px, 1fr));
    }
}

@media (max-width: 767px) {
    .app-page {
        padding-top: 20px;
    }

    .page-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .page-heading h1,
    .login-card h1 {
        font-size: 1.65rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stat-tile {
        min-height: 72px;
    }

    .stat-tile strong {
        font-size: 1.16rem;
    }

    .legend {
        justify-content: flex-start;
    }

    .option-row {
        grid-template-columns: 36px minmax(0, 1fr) repeat(2, 36px);
    }

    .option-row .option-save,
    .option-row .option-delete {
        grid-row: 2;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .matrix-grid {
        grid-template-columns: repeat(var(--matrix-columns), 38px);
    }

    .matrix-cell {
        width: 38px;
        font-size: 0.68rem;
    }
}
