:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --border: #dfe7f1;
    --border-strong: #c8d5e5;
    --text: #172033;
    --muted: #64748b;
    --primary: #1e5aa8;
    --primary-dark: #17467f;
    --primary-soft: #eef5ff;
    --success: #18794e;
    --success-soft: #ecfdf3;
    --danger: #b42318;
    --danger-soft: #fff2f0;
    --shadow: 0 18px 50px rgba(23, 54, 93, .08);
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-width: 320px;
    background:
        radial-gradient(circle at top left, rgba(30, 90, 168, .06), transparent 32rem),
        var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.55;
}

button,
input {
    font: inherit;
}

a {
    color: var(--primary);
}

.page-shell {
    width: min(1040px, calc(100% - 32px));
    margin: 28px auto 0;
}

.app-card {
    background: rgba(255, 255, 255, .96);
    border: 1px solid rgba(213, 224, 238, .9);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 34px;
}

.hero {
    text-align: center;
    max-width: 720px;
    margin: 0 auto 28px;
}

.brand-badge,
.section-kicker {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .1em;
    color: var(--primary);
}

.brand-badge {
    min-height: 28px;
    padding: 5px 10px;
    margin-bottom: 10px;
    border-radius: 999px;
    background: var(--primary-soft);
    border: 1px solid #dceafd;
}

.hero h1 {
    margin: 0;
    font-size: clamp(30px, 5vw, 42px);
    line-height: 1.12;
    letter-spacing: -.025em;
}

.hero p {
    margin: 10px auto 0;
    color: var(--muted);
    font-size: 16px;
}

.upload-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.upload-card {
    display: block;
    min-width: 0;
    padding: 20px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.upload-card:hover,
.upload-card:focus-within {
    border-color: #9dbde4;
    box-shadow: 0 10px 28px rgba(30, 90, 168, .08);
    transform: translateY(-1px);
}

.upload-card__top {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 15px;
}

.step-badge {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 10px;
    background: var(--primary);
    color: white;
    font-weight: 800;
}

.upload-card h2,
.quick-guide h2,
.export-panel h2,
.result-title {
    margin: 0;
    color: var(--text);
}

.upload-card h2 {
    font-size: 17px;
}

.upload-card p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 13px;
}

input[type="file"] {
    display: block;
    width: 100%;
    padding: 8px;
    color: #334155;
    background: #fff;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    cursor: pointer;
}

input[type="file"]::file-selector-button {
    margin-right: 10px;
    padding: 8px 12px;
    border: 0;
    border-radius: 8px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 700;
    cursor: pointer;
}

.file-state {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-state.is-selected {
    color: var(--success);
    font-weight: 700;
}

.quick-guide {
    margin-top: 18px;
    padding: 20px;
    border: 1px solid #dce7f4;
    border-radius: var(--radius-md);
    background: #fbfdff;
}

.quick-guide__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 12px;
}

.quick-guide h2,
.export-panel h2 {
    margin-top: 2px;
    font-size: 20px;
}

.sample-link {
    flex: 0 0 auto;
    text-decoration: none;
    font-size: 14px;
    font-weight: 750;
}

.sample-link:hover {
    text-decoration: underline;
}

.guide-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: guide;
}

.guide-steps li {
    counter-increment: guide;
    position: relative;
    min-height: 86px;
    padding: 12px 12px 12px 42px;
    border-radius: 10px;
    background: var(--surface-soft);
    color: #475569;
    font-size: 13px;
}

.guide-steps li::before {
    content: counter(guide);
    position: absolute;
    left: 12px;
    top: 12px;
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #dfeeff;
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 800;
}

.guide-steps b {
    color: #25334a;
}

.answer-preview {
    margin-top: 12px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
}

.answer-preview summary {
    width: fit-content;
    color: var(--primary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
}

.answer-preview__body {
    padding-top: 12px;
}

.answer-preview img {
    display: block;
    width: min(100%, 760px);
    max-height: 390px;
    object-fit: contain;
    margin: 0 auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: white;
}

.primary-action {
    text-align: center;
    margin: 24px 0 4px;
}

#btnProcess {
    min-width: 290px;
    min-height: 48px;
    padding: 12px 22px;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), #2a70c5);
    color: #fff;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(30, 90, 168, .2);
    transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}

#btnProcess:hover {
    transform: translateY(-1px);
    box-shadow: 0 13px 28px rgba(30, 90, 168, .25);
    filter: brightness(1.02);
}

#btnProcess:active {
    transform: translateY(0);
}

#btnProcess:disabled {
    opacity: .65;
    cursor: wait;
}

.primary-action p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.result-section {
    margin-top: 20px;
}

#result:empty {
    display: none;
}

.result-box,
.error-box,
.loading-box {
    padding: 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: white;
}

.loading-box {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--primary-dark);
    background: var(--primary-soft);
    border-color: #d7e8fc;
    font-weight: 700;
}

.loading-spinner {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    border: 3px solid rgba(30, 90, 168, .18);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-box {
    color: var(--danger);
    background: var(--danger-soft);
    border-color: #ffd3cc;
}

.result-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.result-title {
    font-size: 20px;
}

.success-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    color: var(--success);
    background: var(--success-soft);
    font-size: 12px;
    font-weight: 800;
}

.summary-container {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.summary-item {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-soft);
}

.summary-item h4 {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 11px;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.summary-item .value {
    color: var(--text);
    font-size: 23px;
    font-weight: 800;
}

.result-grid {
    display: grid;
    grid-template-columns: 1.25fr .75fr;
    gap: 14px;
}

.result-panel {
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
}

.result-panel h3 {
    margin: 0 0 10px;
    color: #334155;
    font-size: 15px;
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
}

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

th,
td {
    padding: 10px 11px;
    border-bottom: 1px solid #edf1f6;
    text-align: center;
    white-space: nowrap;
    font-size: 13px;
}

th {
    background: #f3f7fc;
    color: #41546d;
    font-weight: 750;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr:hover {
    background: #fbfdff;
}

.clo-detail {
    text-align: left;
    line-height: 1.7;
    white-space: normal;
}

.export-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-top: 18px;
    padding: 18px 20px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.export-panel p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.export-actions {
    display: flex;
    gap: 10px;
    flex: 0 0 auto;
}

.export-actions button {
    min-height: 42px;
    padding: 10px 16px;
    border: 1px solid var(--primary);
    border-radius: 10px;
    background: white;
    color: var(--primary-dark);
    font-weight: 750;
    cursor: pointer;
    transition: background .18s ease, color .18s ease, border-color .18s ease;
}

.export-actions button:not(:disabled):hover {
    background: var(--primary);
    color: white;
}

.export-actions button:disabled {
    border-color: #d4dce6;
    background: #eef2f6;
    color: #96a2b1;
    cursor: not-allowed;
}

.footer {
    padding: 18px 4px 24px;
    text-align: center;
    color: #7a8798;
    font-size: 12px;
    line-height: 1.65;
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.footer a {
    color: #55759a;
    text-decoration: none;
    font-weight: 700;
}

.footer a:hover {
    color: var(--primary);
    text-decoration: underline;
}

@media (max-width: 800px) {
    .page-shell {
        width: min(100% - 20px, 1040px);
        margin-top: 10px;
    }

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

    .hero {
        margin-bottom: 20px;
    }

    .upload-grid,
    .guide-steps,
    .result-grid {
        grid-template-columns: 1fr;
    }

    .guide-steps li {
        min-height: auto;
    }

    .quick-guide__header,
    .export-panel {
        align-items: flex-start;
        flex-direction: column;
    }

    .export-actions {
        width: 100%;
    }

    .export-actions button {
        flex: 1 1 0;
    }
}

@media (max-width: 520px) {
    .hero h1 {
        font-size: 30px;
    }

    .hero p {
        font-size: 14px;
    }

    .upload-card,
    .quick-guide {
        padding: 15px;
    }

    #btnProcess {
        width: 100%;
        min-width: 0;
    }

    .summary-container {
        grid-template-columns: 1fr;
    }

    .result-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .export-actions {
        flex-direction: column;
    }

    .export-actions button {
        width: 100%;
    }
}

/* =====================================================
   OCR / Số phách - V1.2
   ===================================================== */
.ocr-progress-box { overflow: hidden; }
.ocr-progress-track {
    height: 8px;
    background: #e8eef7;
    border-radius: 999px;
    overflow: hidden;
    margin: 14px 0 18px;
}
.ocr-progress-track span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #0ea5e9);
    border-radius: inherit;
    transition: width .2s ease;
}
.success-pill--working { background: #e8f2ff; color: #1d4ed8; }
.ocr-table th, .ocr-table td { vertical-align: middle; }
.ocr-thumb {
    width: 118px;
    max-width: 24vw;
    height: 43px;
    object-fit: cover;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #fff;
}
.ocr-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 7px;
    vertical-align: 1px;
}
.ocr-high { background: #16a34a; }
.ocr-medium { background: #eab308; }
.ocr-low { background: #dc2626; }
.ocr-summary-line {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 22px;
    margin: 14px 0 8px;
    padding: 12px 14px;
    background: #f8fafc;
    border: 1px solid #e5eaf1;
    border-radius: 12px;
    color: #475569;
}
.ocr-result-details {
    margin: 18px 0;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #fff;
    overflow: hidden;
}
.ocr-result-details > summary {
    cursor: pointer;
    padding: 13px 15px;
    font-weight: 700;
    background: #f8fafc;
}
.ocr-result-details .table-wrapper { margin: 0; border: 0; border-top: 1px solid #e2e8f0; border-radius: 0; }
.ocr-legend { margin: 10px 15px 14px; color: #64748b; font-size: .88rem; }

.ocr-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, .56);
    display: grid;
    place-items: center;
    padding: 18px;
    backdrop-filter: blur(3px);
}
.ocr-modal__card {
    width: min(520px, 100%);
    max-height: calc(100vh - 36px);
    overflow: auto;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 28px 70px rgba(15, 23, 42, .28);
    padding: 20px;
}
.ocr-modal__head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}
.ocr-modal__head h2 { margin: 4px 0 0; font-size: 1.35rem; }
.ocr-confidence {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 6px 10px;
    font-weight: 800;
    font-size: .9rem;
}
.ocr-confidence--low { color: #b91c1c; background: #fee2e2; }
.ocr-reason { color: #92400e; background: #fffbeb; border: 1px solid #fde68a; padding: 10px 12px; border-radius: 10px; }
.ocr-image-box {
    margin: 15px 0;
    border: 1px solid #dbe3ef;
    border-radius: 12px;
    overflow: hidden;
    background: #f8fafc;
}
.ocr-image-box img { display: block; width: 100%; min-height: 90px; object-fit: contain; image-rendering: auto; }
.ocr-image-missing { margin: 15px 0; padding: 18px; text-align: center; color: #64748b; background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 12px; }
.ocr-field { display: grid; gap: 7px; font-weight: 700; color: #334155; }
.ocr-field input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font: inherit;
    font-size: 1.18rem;
    letter-spacing: .04em;
}
.ocr-field input:focus { outline: 3px solid rgba(37, 99, 235, .14); border-color: #2563eb; }
.ocr-modal__actions { display: flex; justify-content: flex-end; margin-top: 14px; }
.ocr-confirm {
    border: 0;
    border-radius: 10px;
    background: #2563eb;
    color: #fff;
    padding: 11px 16px;
    font-weight: 800;
    cursor: pointer;
}
.ocr-hint { margin: 10px 0 0; color: #64748b; font-size: .86rem; }
.warning-box {
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid #fde68a;
    background: #fffbeb;
    color: #92400e;
    border-radius: 12px;
}

@media (max-width: 640px) {
    .ocr-modal__card { padding: 16px; border-radius: 14px; }
    .ocr-summary-line { display: grid; grid-template-columns: 1fr; gap: 5px; }
    .ocr-thumb { width: 92px; height: 36px; }
}

/* =====================================================
   Xác nhận SBD + ánh xạ mã đề - V1.3
   ===================================================== */
.review-panel { margin-top: 0; }
.review-description {
    margin: 10px 0 16px;
    color: #475569;
    line-height: 1.65;
}
.review-table-wrapper {
    max-height: min(58vh, 620px);
    overflow: auto;
}
.sbd-review-table thead th,
.compact-review-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8fafc;
}
.sbd-review-input,
.exam-map-select {
    width: 100%;
    min-width: 118px;
    padding: 9px 11px;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: #fff;
    color: #0f172a;
    font: inherit;
}
.sbd-review-input {
    font-weight: 800;
    letter-spacing: .04em;
}
.sbd-review-input:focus,
.exam-map-select:focus {
    outline: 3px solid rgba(37, 99, 235, .14);
    border-color: #2563eb;
}
.ocr-thumb--review {
    width: 150px;
    max-width: none;
    height: 50px;
}
.muted-cell { color: #94a3b8; }
.inline-error {
    margin: 10px 0 14px;
    padding: 10px 12px;
    border: 1px solid #fecaca;
    border-radius: 10px;
    background: #fef2f2;
    color: #b91c1c;
    font-weight: 700;
}
.review-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}
.primary-inline-action,
.secondary-action {
    border-radius: 10px;
    padding: 11px 16px;
    font-weight: 800;
    cursor: pointer;
}
.primary-inline-action {
    border: 1px solid #2563eb;
    background: #2563eb;
    color: #fff;
}
.secondary-action {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #475569;
}
.warning-pill {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 7px 11px;
    background: #fef3c7;
    color: #92400e;
    font-weight: 800;
    font-size: .86rem;
}
.compact-review-table { margin-top: 14px; }
.mapping-arrow {
    width: 48px;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 900;
    color: #64748b;
}
.exam-code-review select { cursor: pointer; }

@media (max-width: 640px) {
    .review-actions { flex-direction: column-reverse; }
    .review-actions button { width: 100%; }
    .review-table-wrapper { max-height: 65vh; }
    .ocr-thumb--review { width: 105px; height: 42px; }
    .sbd-review-input { min-width: 100px; }
}

/* ===== V1.4: nhiều UnT + log ===== */
.upload-grid--three{grid-template-columns:repeat(3,minmax(0,1fr))}.log-panel{margin-top:24px;padding:22px;border:1px solid #dfe5ee;border-radius:18px;background:#fff}.log-head{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:12px}.log-head h2{margin:3px 0 0}.log-box{height:220px;overflow:auto;background:#0f172a;color:#e5e7eb;border-radius:12px;padding:12px 14px;font:13px/1.55 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}.log-line{padding:3px 0;border-bottom:1px solid rgba(255,255,255,.06)}.log-line>span{color:#94a3b8}.log-warn{color:#fde68a}.log-error{color:#fecaca}.log-info{color:#bfdbfe}.log-empty{color:#94a3b8}.row-error{background:#fff1f2}.sbd-state{font-weight:600}.sbd-review-input{min-width:110px;padding:8px 10px;border:1px solid #cbd5e1;border-radius:8px}.warning-pill{display:inline-flex;padding:6px 10px;border-radius:999px;background:#fff7ed;color:#9a3412;font-weight:700;font-size:12px}.secondary-action{padding:8px 12px;border:1px solid #cbd5e1;background:#fff;border-radius:9px;cursor:pointer}.primary-inline-action{padding:9px 14px;border:0;background:#111827;color:#fff;border-radius:9px;cursor:pointer}.inline-error{margin:12px 0;padding:12px;background:#fff1f2;border:1px solid #fecdd3;border-radius:10px;color:#9f1239}.review-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:14px}@media(max-width:850px){.upload-grid--three{grid-template-columns:1fr}.log-head{align-items:flex-start;flex-direction:column}}

/* ===== V1.5: ảnh số phách + chỉnh mã đề trong bảng kiểm tra ===== */
.phach-thumb-review{
    display:block;
    width:150px;
    height:58px;
    object-fit:contain;
    border:1px solid #dbe3ef;
    border-radius:8px;
    background:#fff;
}
.exam-code-review-input{
    width:92px;
    min-width:82px;
    padding:8px 9px;
    border:1px solid #cbd5e1;
    border-radius:8px;
    background:#fff;
    font:inherit;
    font-weight:700;
    text-align:center;
}
.exam-code-review-input:focus{
    outline:3px solid rgba(37,99,235,.14);
    border-color:#2563eb;
}
@media(max-width:640px){.phach-thumb-review{width:110px;height:46px}.exam-code-review-input{width:80px}}

/* ===== V1.6: nhập/xem đáp án trực tiếp ===== */
.answer-source-switch{display:flex;gap:14px;flex-wrap:wrap;margin:0 0 10px;color:#334155;font-size:13px;font-weight:700}
.answer-source-switch label{display:flex;align-items:center;gap:6px;cursor:pointer}
.answer-source-switch input{accent-color:var(--primary)}
.answer-review-button{margin-top:10px;width:100%}
.direct-answer-panel{margin-top:18px;padding:20px;border:1px solid #cfe0f3;border-radius:var(--radius-md);background:#fbfdff}
.direct-answer-head{display:flex;justify-content:space-between;align-items:center;gap:16px;margin-bottom:14px}
.direct-answer-head h2{margin:2px 0 0;font-size:20px}
.direct-entry-grid{display:grid;grid-template-columns:160px 1fr 1fr;gap:12px;align-items:start}
.direct-entry-grid label{display:flex;flex-direction:column;gap:6px;font-size:13px;font-weight:700;color:#475569}
.direct-entry-grid input,.direct-entry-grid textarea,.paste-table-box textarea{width:100%;padding:10px;border:1px solid var(--border-strong);border-radius:10px;background:#fff;color:var(--text);font:inherit;resize:vertical}
.direct-actions{display:flex;align-items:center;gap:12px;margin-top:12px;flex-wrap:wrap}
.direct-summary{margin-top:12px;padding:10px 12px;border-radius:10px;background:#f1f5f9;color:#334155;font-size:13px}
.direct-summary .summary-chip{display:inline-flex;margin:3px 6px 3px 0;padding:5px 9px;border:1px solid #d9e3ee;border-radius:999px;background:#fff;font-weight:700}
.paste-table-box{margin-top:14px;border-top:1px dashed var(--border-strong);padding-top:12px}
.paste-table-box summary{cursor:pointer;font-weight:800;color:var(--primary-dark)}
.paste-table-box p{color:var(--muted);font-size:13px}
.paste-table-box button{margin-top:8px}
.answer-review-wrapper{max-height:60vh}
.answer-review-table{min-width:max-content}
.answer-review-table th{position:sticky;top:0;z-index:2}
.answer-review-table thead tr:nth-child(2) th{top:43px}
.answer-review-table input{width:72px;padding:6px;border:1px solid #cbd5e1;border-radius:7px;text-align:center}
.answer-review-table .answer-code-input{width:100px;font-weight:800}
.answer-review-table .clo-cell{width:88px}
.export-actions--three{grid-template-columns:repeat(3,minmax(0,1fr))}
@media(max-width:820px){.direct-entry-grid{grid-template-columns:1fr}.direct-answer-head{align-items:flex-start;flex-direction:column}.export-actions--three{grid-template-columns:1fr}}

/* =========================================================
   V1.7 - Nhập đáp án trực tiếp dạng bảng Excel
   ========================================================= */
.direct-answer-intro{margin:6px 0 0;color:#64748b;font-size:13px}
.direct-grid-toolbar{display:flex;align-items:center;gap:10px;flex-wrap:wrap;padding:12px 0 14px}
.direct-toolbar-group{display:flex;align-items:center;gap:7px}
.direct-toolbar-group label,.direct-toolbar-label{font-size:13px;font-weight:800;color:#334155}
.direct-toolbar-group input[type="number"]{width:82px;padding:8px 9px;border:1px solid #cbd5e1;border-radius:8px;background:#fff;font-weight:800;color:#0f172a}
.direct-toolbar-divider{width:1px;height:30px;background:#d9e1ea}
.direct-orientation-button.is-active{background:#1e293b;color:#fff;border-color:#1e293b}
.direct-grid-status{margin-left:auto;color:#64748b;font-size:13px;font-weight:800}
.direct-validation{display:flex;align-items:center;gap:9px;margin-bottom:10px;padding:9px 11px;border:1px solid #dbe3ec;border-radius:9px;background:#fff;color:#475569;font-size:12.5px;font-weight:700}
.direct-validation-dot{width:10px;height:10px;border-radius:50%;background:#94a3b8;flex:0 0 auto}
.direct-validation.is-ok{border-color:#bbf7d0;background:#f0fdf4;color:#166534}.direct-validation.is-ok .direct-validation-dot{background:#16a34a}
.direct-validation.is-error{border-color:#fecaca;background:#fff7f7;color:#991b1b}.direct-validation.is-error .direct-validation-dot{background:#dc2626}
.direct-validation-legend{margin-left:auto;display:flex;align-items:center;gap:5px;color:#64748b;font-weight:600}
.direct-validation-legend i{display:inline-block;width:12px;height:12px;border-radius:3px;border:1px solid #cbd5e1;margin-left:7px}
.direct-validation-legend .legend-missing{background:#fff7d6;border-color:#eab308}.direct-validation-legend .legend-invalid{background:#fee2e2;border-color:#dc2626}
.direct-grid-scroll{overflow:auto;max-height:590px;border:1px solid #d7dee7;border-radius:10px;background:#fff}
.direct-excel-grid{border-collapse:separate;border-spacing:0;width:100%;min-width:900px;table-layout:fixed}
.direct-excel-grid th,.direct-excel-grid td{height:36px;padding:0;border-right:1px solid #d1d5db;border-bottom:1px solid #d1d5db;text-align:center;background:#fff}
.direct-excel-grid thead th{position:sticky;top:0;z-index:4;background:#eef2f7;color:#172033;font-size:13px}
.direct-question-head,.direct-question-cell{position:sticky!important;left:0;z-index:5!important;width:62px;min-width:62px;background:#f8fafc!important;font-weight:800}
.direct-question-cell{z-index:2!important}
.direct-version-head{min-width:112px;padding:5px 4px!important}.direct-version-head--1{background:#edf9f1!important}.direct-version-head--2{background:#fff7e7!important}.direct-version-head--3{background:#f5f0ff!important}.direct-version-head--4{background:#edf7ff!important}
.direct-version-title{display:flex;align-items:center;justify-content:center;gap:5px}.direct-version-title span{font-size:11px;color:#64748b}.direct-version-subtitle{margin-top:3px;font-weight:800}
.direct-code-input{width:68px;padding:5px 4px;border:1px solid #b8c4d2;border-radius:6px;background:#fff;text-align:center;font-size:13px;font-weight:900;color:#172033;outline:none}
.direct-code-input--compact{width:76px}
.direct-grid-input{display:block;width:100%;height:35px;padding:4px 5px;border:0;outline:none;background:transparent;text-align:center;font:600 13px/1.2 inherit;color:#172033}
.direct-grid-input:focus,.direct-code-input:focus{box-shadow:inset 0 0 0 2px #2563eb;background:#eff6ff}
.direct-grid-input.is-missing,.direct-code-input.is-missing{background:#fff7d6!important;box-shadow:inset 0 0 0 1px #eab308;color:#854d0e}
.direct-grid-input.is-invalid,.direct-code-input.is-invalid{background:#fee2e2!important;box-shadow:inset 0 0 0 1px #dc2626;color:#991b1b}
.direct-excel-grid--horizontal{width:max-content;min-width:100%}.direct-excel-grid--horizontal th.direct-horizontal-question{width:54px;min-width:54px}.direct-excel-grid--horizontal td{width:54px;min-width:54px}
.direct-horizontal-label{position:sticky;left:0;z-index:3;width:126px!important;min-width:126px!important;background:#f8fafc!important;font-weight:800}.direct-horizontal-label span{margin-right:6px;font-size:11px;color:#64748b}
.direct-horizontal-label--clo{color:#475569}.direct-clo-row td{background:#fbfdff}
.direct-grid-note{margin:10px 0 0;color:#64748b;font-size:12.5px;line-height:1.5}
@media(max-width:820px){.direct-grid-status{width:100%;margin-left:0}.direct-toolbar-divider{display:none}.direct-validation-legend{display:none}}

/* ===== V1.8: xác nhận dữ liệu đáp án + thống kê CLO theo mã đề ===== */
.answer-data-summary{margin:12px 0 16px;padding:14px;border:1px solid #dbe3ec;border-radius:12px;background:#f8fafc}
.answer-data-summary-title{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:10px;color:#334155}
.answer-data-summary-title span{color:#64748b;font-size:13px;font-weight:800}
.answer-summary-table{margin:0;background:#fff}
.answer-summary-table th,.answer-summary-table td{text-align:center;white-space:nowrap}
.answer-summary-table td:first-child,.answer-summary-table th:first-child{text-align:left}
@media(max-width:640px){.answer-data-summary-title{align-items:flex-start;flex-direction:column}}
