/* ----------  Basis  ---------- */
:root {
    --primary: #2E75B6;
    --primary-dark: #22588A;
    --text: #1d1f23;
    --muted: #6b7280;
    --border: #d9dde3;
    --bg: #f5f7fa;
    --card: #fff;
    --danger: #c0392b;
    --success: #1e8e3e;
    --warning: #e67e22;
}
* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    font-size: 16px;
}
h1, h2, h3 { margin-top: 0; color: var(--text); }
a { color: var(--primary); }

.brand-mark {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    letter-spacing: 2px;
    padding: 4px 12px;
    border-radius: 3px;
    font-size: 14px;
    text-transform: uppercase;
}
.brand-mark.small { font-size: 11px; padding: 3px 8px; }

.muted { color: var(--muted); }
.mono  { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }

/* ----------  Buttons  ---------- */
.btn-primary {
    background: var(--primary);
    color: #fff;
    border: 0;
    padding: 12px 22px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-large { padding: 16px 32px; font-size: 17px; }
.btn-small {
    display: inline-block;
    background: #eef1f5;
    color: var(--text);
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
}
.btn-small:hover { background: #e3e7ed; }
.btn-danger {
    background: #fbeaea;
    color: var(--danger);
    border-color: #f1b5b0;
}
.btn-danger:hover { background: #f6dcdc; }

/* ----------  Alerts  ---------- */
.alert { padding: 12px 16px; border-radius: 6px; margin: 16px 0; }
.alert-error { background: #fdecec; color: #8a2020; border: 1px solid #f5c6c6; }
.alert-ok    { background: #eaf7ee; color: #205f2c; border: 1px solid #b7e3c1; }
.alert ul { margin: 0; padding-left: 20px; }

/* ============================================================
   START / BEDANKT PAGINA
   ============================================================ */
.page-start {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    background: linear-gradient(180deg, #eef3f9 0%, #f5f7fa 100%);
}
.card {
    background: var(--card);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,.08);
    max-width: 620px;
    width: 100%;
    padding: 40px;
}
.brand { text-align: center; margin-bottom: 28px; }
.brand h1 { font-size: 26px; margin: 16px 0 4px; }
.brand .sub { color: var(--muted); font-size: 15px; margin: 0; }

.intro { margin-bottom: 28px; }
.intro p { margin: 0 0 12px; }
.intro .note {
    background: #f4f8fc;
    border-left: 3px solid var(--primary);
    padding: 12px 14px;
    margin-top: 16px;
    color: #555;
    font-size: 14px;
    border-radius: 0 4px 4px 0;
}

.facts { list-style: none; padding: 0; margin: 16px 0; }
.facts li {
    padding: 8px 0;
    border-bottom: 1px solid #eef1f5;
    font-size: 15px;
}
.facts li:last-child { border-bottom: 0; }

.start-form label {
    display: block;
    margin-bottom: 18px;
}
.start-form span {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 14px;
}
.start-form input[type="text"],
.start-form input[type="email"] {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 15px;
    font-family: inherit;
}
.start-form input:focus {
    outline: 0;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(46,117,182,.15);
}
.start-form .code-input {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 20px;
    letter-spacing: 3px;
    text-align: center;
    text-transform: uppercase;
}
.start-form button { width: 100%; }

.footer {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid #eef1f5;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

/* ============================================================
   TEST PAGINA
   ============================================================ */
.page-test { background: var(--bg); }

.test-header {
    position: sticky; top: 0; z-index: 40;
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.test-header-inner {
    max-width: 860px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}
.test-header-left .test-title { font-weight: 600; margin-top: 4px; }
.test-header-left .candidate-name { font-size: 13px; color: var(--muted); margin-top: 2px; }

.test-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Timer */
.timer {
    background: #eef3f9;
    border: 1px solid #cfdbe8;
    border-radius: 8px;
    padding: 6px 14px;
    min-width: 130px;
    text-align: center;
    transition: background .3s, border-color .3s, color .3s;
}
.timer-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.timer-value { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 22px; font-weight: 600; letter-spacing: 1px; }

.timer.warn {
    background: #fff4e4; border-color: #f0c38a; color: #8a5a1a;
}
.timer.urgent {
    background: #fde7e7; border-color: #efaca8; color: #8a2a2a;
    animation: pulse 1.2s infinite;
}
.timer.overtime {
    background: #c0392b; border-color: #a82b20; color: #fff;
    animation: pulse 1.2s infinite;
}
@keyframes pulse {
    0%,100% { transform: scale(1); }
    50%     { transform: scale(1.04); }
}

/* Auto-save indicator */
.save-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
    background: #f5f7fa;
    border: 1px solid #e3e7ed;
    border-radius: 6px;
    padding: 6px 10px;
    max-width: 230px;
}
.save-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #bbb;
    flex-shrink: 0;
}
.save-indicator.saving  .save-dot { background: var(--warning); animation: pulse 1s infinite; }
.save-indicator.saved   .save-dot { background: var(--success); }
.save-indicator.error   .save-dot { background: var(--danger); animation: pulse .8s infinite; }
.save-indicator.error   .save-text { color: var(--danger); font-weight: 600; }

.test-main {
    max-width: 860px;
    margin: 0 auto;
    padding: 24px 20px 80px;
}

.question-block {
    background: #fff;
    border-radius: 8px;
    padding: 28px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
}
.question-block h2 {
    margin-top: 0;
    font-size: 20px;
    color: var(--primary);
    border-bottom: 1px solid #eef1f5;
    padding-bottom: 12px;
    margin-bottom: 16px;
}
.question-block .intro {
    margin-bottom: 16px;
    color: #333;
    line-height: 1.6;
}
.question-block .code {
    background: #f4f6f8;
    border: 1px solid #e3e7ed;
    border-radius: 6px;
    padding: 14px;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 13px;
    overflow-x: auto;
    margin: 12px 0 16px;
    white-space: pre;
}

.field { margin-bottom: 20px; }
.field:last-child { margin-bottom: 0; }
.field label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 15px;
}
.field textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 15px;
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
    min-height: 100px;
}
.field textarea:focus {
    outline: 0;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(46,117,182,.15);
}

.submit-row {
    text-align: center;
    padding: 24px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-top: 24px;
}
.submit-note {
    margin-top: 0;
    color: var(--muted);
    font-size: 14px;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal.is-visible {
    display: flex;
}
.modal-inner {
    background: #fff;
    border-radius: 10px;
    padding: 36px 48px;
    text-align: center;
    max-width: 420px;
}

/* ============================================================
   ADMIN PAGINA
   ============================================================ */
.page-admin { background: var(--bg); }

.admin-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}
.admin-header {
    padding-bottom: 20px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
}
.admin-header h1 { margin: 10px 0 4px; font-size: 24px; }
.admin-header .back {
    font-size: 14px;
    color: var(--muted);
    text-decoration: none;
}
.admin-header .meta {
    color: var(--muted);
    font-size: 13px;
    margin-top: 6px;
}

.admin-section {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
}
.admin-section h2 {
    margin-top: 0;
    font-size: 17px;
    color: var(--text);
    padding-bottom: 10px;
    border-bottom: 1px solid #eef1f5;
    margin-bottom: 16px;
}
.count { color: var(--muted); font-weight: 400; font-size: 15px; }

.inline-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
.inline-form input[type="text"],
.inline-form input[type="email"] {
    flex: 1 1 180px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}
.inline-form input:focus {
    outline: 0; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(46,117,182,.15);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.admin-table th {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 2px solid var(--border);
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.admin-table td {
    padding: 10px;
    border-bottom: 1px solid #eef1f5;
    vertical-align: top;
}
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table .small { font-size: 12px; }
.admin-table .actions { text-align: right; }
.admin-table .actions form { display: inline; margin-left: 4px; }

.empty {
    padding: 24px;
    text-align: center;
    color: var(--muted);
    font-style: italic;
}

.pill {
    display: inline-block;
    padding: 3px 10px;
    font-size: 11px;
    border-radius: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.pill-issued    { background: #eef3f9; color: var(--primary); }
.pill-started   { background: #fff4e4; color: #8a5a1a; }
.pill-submitted { background: #eaf7ee; color: #205f2c; }
.pill-revoked   { background: #f4f5f7; color: #888; text-decoration: line-through; }

/* Answer view */
.answer-block {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 16px;
}
.answer-block h2 {
    font-size: 17px;
    color: var(--primary);
    border-bottom: 1px solid #eef1f5;
    padding-bottom: 8px;
    margin-bottom: 14px;
}
.intro-small { color: var(--muted); font-size: 13px; margin-bottom: 10px; white-space: pre-wrap; }
.code-small {
    background: #f4f6f8;
    padding: 10px;
    font-size: 12px;
    border-radius: 4px;
    overflow-x: auto;
    white-space: pre;
    font-family: ui-monospace, Menlo, Consolas, monospace;
}
.answer { margin-bottom: 18px; }
.answer:last-child { margin-bottom: 0; }
.answer .q { font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.answer .a {
    background: #fafbfc;
    border-left: 3px solid var(--primary);
    padding: 10px 14px;
    white-space: pre-wrap;
    font-size: 14px;
    border-radius: 0 4px 4px 0;
}
.answer .a.empty { color: var(--muted); font-style: italic; border-left-color: #ccc; }

/* Responsive */
@media (max-width: 720px) {
    .card { padding: 28px 22px; }
    .test-header-inner { padding: 10px 14px; }
    .test-header-right { width: 100%; justify-content: space-between; }
    .question-block { padding: 20px 18px; }
    .question-block h2 { font-size: 18px; }
    .admin-section { padding: 16px; }
    .admin-table { font-size: 12px; }
    .admin-table th, .admin-table td { padding: 6px; }
}
