/* ==========================================================================
   Shared styling: the admin console, the candidate dashboard and both sign-in
   screens. No build step - this file is served as it is.
   ========================================================================== */

:root {
    --navy: #1b3a6b;
    --navy-dark: #142c52;
    --blue: #2c6ecb;
    --blue-light: #e8f0fc;
    --line: #d8dfe8;
    --line-soft: #eaeff5;
    --ink: #1c2430;
    --ink-soft: #5b6879;
    --muted: #7d8998;
    --paper: #ffffff;
    --shell: #f2f5f9;
    --green: #2e9b52;
    --red: #d0342c;
    --amber: #b8860b;
    --purple: #7a3fa8;
    --radius: 6px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--shell);
}

a {
    color: var(--blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1,
h2,
h3,
h4 {
    margin: 0 0 12px;
    line-height: 1.3;
}

h1 {
    font-size: 22px;
}

h2 {
    font-size: 18px;
}

h3 {
    font-size: 15px;
}

/* --- App chrome ---------------------------------------------------------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 0 20px;
    height: 54px;
    background: var(--navy);
    color: #fff;
}

.topbar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
}

.topbar .brand:hover {
    text-decoration: none;
}

.topbar .brand .mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.16);
    font-size: 14px;
}

.topbar nav {
    display: flex;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
}

.topbar nav a {
    padding: 7px 13px;
    border-radius: 4px;
    color: #d6e1f0;
    font-size: 13.5px;
    white-space: nowrap;
}

.topbar nav a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    text-decoration: none;
}

.topbar nav a.is-active {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-weight: 600;
}

.topbar .session {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    white-space: nowrap;
}

.topbar .session form {
    margin: 0;
}

.linkish {
    padding: 0;
    border: 0;
    background: none;
    color: #d6e1f0;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    text-decoration: underline;
}

.linkish:hover {
    color: #fff;
}

.page {
    max-width: 1320px;
    margin: 0 auto;
    padding: 22px 20px 60px;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.page-head .sub {
    margin-top: 2px;
    color: var(--ink-soft);
    font-size: 13.5px;
}

.page-head .actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.crumb {
    margin-bottom: 6px;
    font-size: 12.5px;
    color: var(--muted);
}

/* --- Surfaces ------------------------------------------------------------ */

.card {
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
}

.card > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 13px 18px;
    border-bottom: 1px solid var(--line-soft);
    font-weight: 600;
}

.card > .body {
    padding: 18px;
}

.card > .body.tight {
    padding: 0;
}

.grid {
    display: grid;
    gap: 16px;
}

.grid.cols-2 {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.grid.cols-3 {
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.grid.cols-4 {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.stat {
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--blue);
    border-radius: var(--radius);
    background: var(--paper);
}

.stat .value {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--navy);
}

.stat .label {
    margin-top: 3px;
    font-size: 12.5px;
    color: var(--ink-soft);
}

.stat.green {
    border-left-color: var(--green);
}

.stat.green .value {
    color: var(--green);
}

.stat.red {
    border-left-color: var(--red);
}

.stat.red .value {
    color: var(--red);
}

.stat.amber {
    border-left-color: var(--amber);
}

.stat.amber .value {
    color: var(--amber);
}

.stat.purple {
    border-left-color: var(--purple);
}

.stat.purple .value {
    color: var(--purple);
}

/* --- Tables -------------------------------------------------------------- */

.table-wrap {
    overflow-x: auto;
}

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

table.data th,
table.data td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line-soft);
    text-align: left;
    vertical-align: middle;
}

table.data th {
    background: #f7f9fc;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--ink-soft);
    white-space: nowrap;
}

table.data tbody tr:hover {
    background: #fafcfe;
}

table.data td.num,
table.data th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

table.data .row-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--muted);
}

.empty .big {
    margin-bottom: 6px;
    font-size: 15px;
    color: var(--ink-soft);
}

/* --- Forms --------------------------------------------------------------- */

.field {
    margin-bottom: 15px;
}

.field label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 600;
    color: #33414f;
}

.field .hint {
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="search"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: #fff;
    font: inherit;
    font-size: 13.5px;
    color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
    outline: 0;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(44, 110, 203, 0.15);
}

textarea {
    min-height: 90px;
    resize: vertical;
    line-height: 1.6;
}

.field.invalid input,
.field.invalid select,
.field.invalid textarea {
    border-color: var(--red);
}

.error-text {
    margin-top: 4px;
    font-size: 12.5px;
    color: var(--red);
}

.check {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin-bottom: 10px;
    font-size: 13.5px;
    cursor: pointer;
}

.check input {
    width: 16px;
    height: 16px;
    margin: 2px 0 0;
    flex-shrink: 0;
    accent-color: var(--blue);
    cursor: pointer;
}

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filters .field {
    margin: 0;
    min-width: 170px;
}

/* --- Buttons ------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: var(--blue);
    color: #fff;
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: filter 0.12s;
}

.btn:hover {
    filter: brightness(0.93);
    text-decoration: none;
    color: #fff;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-ghost {
    background: #fff;
    border-color: var(--line);
    color: var(--ink);
}

.btn-ghost:hover {
    color: var(--ink);
    background: #f7f9fc;
}

.btn-green {
    background: var(--green);
}

.btn-red {
    background: var(--red);
}

.btn-amber {
    background: var(--amber);
}

.btn-purple {
    background: var(--purple);
}

.btn-sm {
    padding: 6px 11px;
    font-size: 12.5px;
}

.btn-block {
    width: 100%;
}

/* --- Badges -------------------------------------------------------------- */

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    background: #eef2f7;
    color: #4a5768;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.badge.green {
    background: #e4f5ea;
    color: #1f7a3f;
}

.badge.red {
    background: #fdeceb;
    color: #b02a22;
}

.badge.amber {
    background: #fdf4e1;
    color: #8a6508;
}

.badge.blue {
    background: var(--blue-light);
    color: #1f4f96;
}

.badge.purple {
    background: #f2e9fa;
    color: #61308a;
}

/* --- Alerts -------------------------------------------------------------- */

.alert {
    margin-bottom: 16px;
    padding: 12px 16px;
    border: 1px solid;
    border-left-width: 4px;
    border-radius: 5px;
    font-size: 13.5px;
}

.alert.success {
    border-color: #a9dbbb;
    border-left-color: var(--green);
    background: #eff9f2;
    color: #1c6b39;
}

.alert.error {
    border-color: #f2b8b4;
    border-left-color: var(--red);
    background: #fdf0ef;
    color: #9e2620;
}

.alert.info {
    border-color: #b7d0f0;
    border-left-color: var(--blue);
    background: #f0f6fe;
    color: #1f4f96;
}

.alert.warn {
    border-color: #f0d69a;
    border-left-color: var(--amber);
    background: #fdf8ec;
    color: #7d5c07;
}

.alert ul {
    margin: 8px 0 0;
    padding-left: 20px;
}

.alert li {
    margin-bottom: 3px;
}

/* --- Sign-in ------------------------------------------------------------- */

.auth-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background: linear-gradient(150deg, var(--navy) 0%, var(--navy-dark) 55%, #0d1d38 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.32);
    overflow: hidden;
}

.auth-card .head {
    padding: 26px 30px 20px;
    text-align: center;
    border-bottom: 1px solid var(--line-soft);
}

.auth-card .head .mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-bottom: 12px;
    border-radius: 12px;
    background: var(--blue-light);
    font-size: 24px;
}

.auth-card .head h1 {
    margin-bottom: 4px;
    font-size: 19px;
    color: var(--navy);
}

.auth-card .head p {
    margin: 0;
    font-size: 13px;
    color: var(--ink-soft);
}

.auth-card .body {
    padding: 24px 30px 28px;
}

.auth-card .foot {
    padding: 14px 30px;
    background: #f7f9fc;
    border-top: 1px solid var(--line-soft);
    font-size: 12.5px;
    color: var(--ink-soft);
    text-align: center;
}

/* --- Candidate dashboard ------------------------------------------------- */

.exam-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--blue);
    border-radius: var(--radius);
    background: #fff;
    margin-bottom: 12px;
}

.exam-card .title {
    font-size: 15.5px;
    font-weight: 700;
    color: var(--navy);
}

.exam-card .facts {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 6px;
    font-size: 12.5px;
    color: var(--ink-soft);
}

.exam-card.done {
    border-left-color: var(--green);
}

.exam-card.closed {
    border-left-color: var(--muted);
    opacity: 0.85;
}

/* --- Result summary ------------------------------------------------------ */

.score-hero {
    padding: 26px 22px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--navy), #2a5da8);
    color: #fff;
    text-align: center;
}

.score-hero .score {
    font-size: 42px;
    font-weight: 700;
    line-height: 1.1;
}

.score-hero .of {
    font-size: 15px;
    opacity: 0.82;
}

.score-hero .pct {
    margin-top: 8px;
    font-size: 14px;
    opacity: 0.9;
}

.review-q {
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--muted);
    border-radius: var(--radius);
    background: #fff;
    margin-bottom: 12px;
}

.review-q.correct {
    border-left-color: var(--green);
}

.review-q.wrong {
    border-left-color: var(--red);
}

.review-q .stem {
    margin: 8px 0 12px;
    line-height: 1.7;
    white-space: pre-wrap;
}

.review-q .opt {
    padding: 7px 11px;
    border: 1px solid var(--line-soft);
    border-radius: 4px;
    margin-bottom: 5px;
    font-size: 13.5px;
}

.review-q .opt.is-correct {
    border-color: #a9dbbb;
    background: #eff9f2;
}

.review-q .opt.is-chosen-wrong {
    border-color: #f2b8b4;
    background: #fdf0ef;
}

.review-q .explain {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 4px;
    background: #f7f9fc;
    font-size: 13px;
    color: #40506a;
}

/* --- Import review ------------------------------------------------------- */

.staged {
    border: 1px solid var(--line);
    border-left: 4px solid var(--green);
    border-radius: var(--radius);
    background: #fff;
    margin-bottom: 14px;
}

.staged.has-issues {
    border-left-color: var(--red);
}

.staged > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 15px;
    border-bottom: 1px solid var(--line-soft);
    background: #f7f9fc;
    font-size: 13px;
    font-weight: 600;
}

.staged > .body {
    padding: 15px;
}

.staged .issues {
    margin: 0 0 12px;
    padding: 9px 12px 9px 30px;
    border-radius: 4px;
    background: #fdf0ef;
    color: #9e2620;
    font-size: 12.5px;
}

.opt-row {
    display: grid;
    grid-template-columns: 34px 1fr 70px;
    gap: 9px;
    align-items: center;
    margin-bottom: 7px;
}

.opt-row .letter {
    font-weight: 700;
    color: var(--navy);
    text-align: center;
}

.opt-row .key {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 12px;
    color: var(--ink-soft);
    cursor: pointer;
}

/* --- Pagination ---------------------------------------------------------- */

.pagination-wrap {
    padding: 12px 18px;
    border-top: 1px solid var(--line-soft);
}

.pagination-wrap nav {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    font-size: 13px;
}

.pagination-wrap svg {
    width: 16px;
    height: 16px;
}

.pagination-wrap a,
.pagination-wrap span[aria-current] {
    padding: 5px 10px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #fff;
}

.pagination-wrap span[aria-current] {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
    font-weight: 600;
}

/* --- Odds and ends ------------------------------------------------------- */

.muted {
    color: var(--muted);
}

.small {
    font-size: 12.5px;
}

.mono {
    font-family: "Consolas", "Courier New", monospace;
}

.nowrap {
    white-space: nowrap;
}

.right {
    text-align: right;
}

.center {
    text-align: center;
}

.mt-0 {
    margin-top: 0;
}

.mb-0 {
    margin-bottom: 0;
}

.mb-1 {
    margin-bottom: 8px;
}

.mb-2 {
    margin-bottom: 16px;
}

.mt-2 {
    margin-top: 16px;
}

.flex {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.flex-between {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.divider {
    height: 1px;
    margin: 16px 0;
    background: var(--line-soft);
}

.scroll-box {
    max-height: 420px;
    overflow-y: auto;
}

@media (max-width: 760px) {
    .topbar {
        height: auto;
        flex-wrap: wrap;
        padding: 10px 14px;
    }

    .page {
        padding: 16px 14px 50px;
    }
}

/* --- Waiting for a scheduled exam to open -------------------------------- */

.countdown {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 5px 12px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--blue-light);
    color: #1f4f96;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}

.countdown strong {
    font-family: "Consolas", "Courier New", monospace;
    font-size: 13.5px;
    font-variant-numeric: tabular-nums;
}

.countdown.is-imminent {
    border-color: #f0d69a;
    background: #fdf8ec;
    color: #7d5c07;
}

/* A button that is only waiting for the clock should not look broken. */
.btn:disabled {
    opacity: 1;
    background: #eef2f7;
    border-color: var(--line);
    color: var(--muted);
    cursor: not-allowed;
}

.btn-ghost:disabled {
    background: #f7f9fc;
}

/* --- Password fields ------------------------------------------------------ */

/* The input keeps the full width of every other field; the reveal button sits
   on top of its right-hand padding rather than taking a column of its own. */
.password-field {
    position: relative;
}

.password-field input {
    padding-right: 62px;
}

.password-field .peek {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    padding: 4px 7px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--blue);
    cursor: pointer;
}

.password-field .peek:hover {
    background: var(--blue-light);
}

.password-field .peek:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 1px;
}
