:root {
    --bg: #0f172a;
    --panel: #111827;
    --card: #ffffff;
    --muted: #64748b;
    --text: #0f172a;
    --gold: #d4af37;
    --gold-dark: #a77c16;
    --danger: #dc2626;
    --success: #16a34a;
    --border: #e5e7eb;
    --soft: #f8fafc;
    --shadow: 0 24px 80px rgba(0,0,0,.26);
}
* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: Tahoma, Arial, sans-serif;
    background: radial-gradient(circle at top, #1e293b 0, #0f172a 46%, #020617 100%);
    color: var(--text);
}
a { color: #1d4ed8; text-decoration: none; }
a:hover { text-decoration: underline; }
.shell { width: min(1120px, calc(100% - 24px)); margin: 0 auto; }
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 0;
    color: #fff;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    color: #111827;
    background: linear-gradient(135deg, #f8e08e, var(--gold));
    box-shadow: 0 10px 30px rgba(212, 175, 55, .28);
}
.admin-nav { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.admin-nav a, .link-button {
    color: #fff;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 999px;
    padding: 8px 12px;
    background: rgba(255,255,255,.06);
    font: inherit;
    cursor: pointer;
}
.link-button:hover, .admin-nav a:hover { background: rgba(255,255,255,.14); text-decoration: none; }
.inline-form { display: inline; margin: 0; }
.main { padding: 18px 0 42px; }
.footer { color: rgba(255,255,255,.62); padding: 22px 0 36px; text-align: center; }
.card {
    background: var(--card);
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 26px;
    padding: clamp(18px, 3vw, 34px);
    box-shadow: 0 24px 80px rgba(0,0,0,.26);
    margin-bottom: 18px;
}
.card h1 { margin: 0 0 18px; font-size: clamp(24px, 4vw, 36px); letter-spacing: -0.04em; }
.card h2 { margin-top: 0; font-size: 22px; }
.lead { color: #334155; line-height: 2; font-size: 17px; }
.muted { color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }
.stat {
    background: var(--soft);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 16px;
}
.stat b { display: block; font-size: 28px; margin-top: 8px; }
label { display: block; font-weight: 700; margin-bottom: 8px; }
input[type="text"], input[type="password"], input[type="number"], input[type="file"], textarea, select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    font: inherit;
    background: #fff;
    color: var(--text);
}
textarea { min-height: 130px; resize: vertical; line-height: 1.8; }
.form-row { margin-bottom: 16px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    border: 0;
    border-radius: 14px;
    padding: 10px 18px;
    background: var(--gold);
    color: #111827;
    font-weight: 800;
    font: inherit;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(212, 175, 55, .22);
}
.btn:hover { background: #f0c84b; text-decoration: none; }
.btn-secondary { background: #e2e8f0; box-shadow: none; color: #0f172a; }
.btn-danger { background: var(--danger); color: #fff; box-shadow: none; }
.btn-success { background: var(--success); color: #fff; box-shadow: none; }
.flash { padding: 14px 16px; border-radius: 16px; margin-bottom: 16px; border: 1px solid transparent; }
.flash-error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.flash-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.flash-info { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--border); text-align: right; vertical-align: top; }
th { color: #475569; font-size: 13px; background: #f8fafc; }
.badge { display: inline-block; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 800; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.progress { height: 12px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin: 14px 0 8px; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-dark), var(--gold)); }
.question-card { max-width: 860px; margin-inline: auto; }
.question-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.question-text { font-size: 20px; line-height: 2; font-weight: 800; margin-bottom: 16px; }
.question-image { max-width: 100%; border-radius: 18px; border: 1px solid var(--border); margin: 10px 0 18px; }
.options { display: grid; gap: 12px; margin-top: 18px; }
.option-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #fff;
    cursor: pointer;
}
.option-item:hover { border-color: var(--gold); background: #fffdf3; }
.option-item input { width: 20px; height: 20px; }
.option-label { font-weight: 900; color: var(--gold-dark); min-width: 22px; }
.option-image { max-width: min(260px, 100%); max-height: 180px; object-fit: contain; border-radius: 14px; border: 1px solid var(--border); }
.certificate {
    position: relative;
    overflow: hidden;
    min-height: 520px;
    text-align: center;
    border: 8px double var(--gold);
    background: linear-gradient(135deg, #fff, #fff7dc);
}
.certificate h1 { color: var(--gold-dark); font-size: clamp(30px, 5vw, 54px); }
.certificate .score { font-size: 40px; font-weight: 900; }
.watermark::after {
    content: "PREVIEW";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    transform: rotate(-24deg);
    font-size: clamp(70px, 16vw, 180px);
    font-weight: 900;
    color: rgba(220, 38, 38, .12);
    pointer-events: none;
}
.low-quality { filter: grayscale(.35); opacity: .86; }
.copy-box { direction: ltr; text-align: left; font-family: monospace; background: #f8fafc; border: 1px solid var(--border); border-radius: 14px; padding: 12px; overflow-x: auto; }
.preview-thumb { max-width: 90px; max-height: 70px; border-radius: 10px; border: 1px solid var(--border); }
.hr { border: 0; border-top: 1px solid var(--border); margin: 22px 0; }
@media (max-width: 820px) {
    .topbar { align-items: flex-start; flex-direction: column; }
    .grid { grid-template-columns: 1fr; }
    .col-3, .col-4, .col-6, .col-8, .col-12 { grid-column: 1; }
    .card { border-radius: 20px; }
    th, td { white-space: nowrap; }
    .question-text { font-size: 18px; }
}
@media print {
    body { background: #fff; }
    .topbar, .footer, .no-print, .flash { display: none !important; }
    .shell { width: 100%; }
    .card { box-shadow: none; border: 0; }
    .certificate { min-height: 720px; }
}

.recommendation-box {
    margin: 18px 0;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #fffdf3;
    line-height: 2;
}
.recommendation-link { font-weight: 900; }
.certificate-preview {
    position: relative;
    margin: 18px auto;
    max-width: 920px;
    text-align: center;
    border-radius: 22px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #fff;
}
.certificate-preview img {
    display: block;
    width: 100%;
    height: auto;
}
.certificate-image-card { max-width: 980px; margin-inline: auto; }
.certificate-details {
    display: grid;
    gap: 8px;
    margin-top: 16px;
    line-height: 1.9;
}
.certificate-fail::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .06);
    pointer-events: none;
}
.certificate-fail-label {
    position: absolute;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%);
    padding: 10px 18px;
    border-radius: 999px;
    background: rgba(153, 27, 27, .92);
    color: #fff;
    font-weight: 900;
}
.question-card {
    animation: questionEnter .32s ease both;
    transition: transform .18s ease, opacity .18s ease;
}
.question-card.is-leaving {
    opacity: 0;
    transform: translateY(10px) scale(.985);
}
@keyframes questionEnter {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}
.motivation-modal {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(15, 23, 42, .58);
    opacity: 0;
    visibility: hidden;
    z-index: 50;
    transition: opacity .2s ease, visibility .2s ease;
}
.motivation-modal.is-visible {
    opacity: 1;
    visibility: visible;
}
.motivation-dialog {
    position: relative;
    width: min(680px, 100%);
    max-height: 88vh;
    overflow: auto;
    padding: 24px;
    border-radius: 24px;
    background: #fff;
    box-shadow: var(--shadow);
    transform: translateY(12px) scale(.98);
    transition: transform .2s ease;
}
.motivation-modal.is-visible .motivation-dialog { transform: translateY(0) scale(1); }
.modal-close {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    font-size: 24px;
    background: #f1f5f9;
}
.motivation-items { display: grid; gap: 16px; }
.motivation-item {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #fffdfa;
}
.motivation-item h2 { margin: 8px 0; }
.motivation-item p { line-height: 2; margin-bottom: 0; }
.motivation-image {
    display: block;
    width: 100%;
    max-height: 320px;
    object-fit: contain;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: #fff;
}
@media (prefers-reduced-motion: reduce) {
    .question-card,
    .question-card.is-leaving,
    .motivation-modal,
    .motivation-dialog {
        animation: none;
        transition: none;
    }
}

.certificate-rendered-image {
    background: #fff;
}
.certificate-generated-watermark::after {
    content: none !important;
}
.certificate-generated-watermark img {
    image-rendering: auto;
}

.exam-timer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 12px 0 16px;
    padding: 14px 16px;
    border: 1px solid #f6d365;
    border-radius: 18px;
    background: linear-gradient(135deg, #fff7d6, #fff);
}
.exam-timer span {
    color: #7c580d;
    font-weight: 800;
}
.exam-timer strong {
    direction: ltr;
    font-family: monospace;
    font-size: 28px;
    color: #111827;
}
.exam-timer.is-warning {
    border-color: #fca5a5;
    background: #fff1f2;
}
.exam-timer.is-warning strong,
.exam-timer.is-expired strong {
    color: #b91c1c;
}
.exam-timer.is-expired {
    border-color: #fecaca;
    background: #fef2f2;
}

.admin-form-section {
    margin: 22px 0;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: #fff;
}
.admin-form-section > h2 {
    margin: 0 0 12px;
}
.compact-option {
    min-height: 46px;
    padding: 10px 12px;
}
.upload-preview,
.upload-preview-empty {
    display: grid;
    place-items: center;
    min-height: 120px;
    margin-bottom: 10px;
    border: 1px dashed var(--border);
    border-radius: 16px;
    background: #f8fafc;
    color: var(--muted);
    overflow: hidden;
}
.upload-preview img {
    display: block;
    width: 100%;
    max-height: 180px;
    object-fit: contain;
}
.sticky-actions {
    position: sticky;
    bottom: 10px;
    z-index: 5;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(255,255,255,.96);
    backdrop-filter: blur(8px);
}
