* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, sans-serif; background: #f4f7fb; color: #1f2937; }
.header { background: #0f766e; color: white; padding: 18px 30px; display: flex; justify-content: space-between; align-items: center; }
.header a { color: white; text-decoration: none; margin-left: 14px; font-weight: bold; }
.container { max-width: 1100px; margin: 30px auto; padding: 0 20px; }
.card { background: white; padding: 24px; border-radius: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.08); margin-bottom: 20px; }
h1, h2, h3 { margin-top: 0; }
.btn { display: inline-block; background: #0f766e; color: white; padding: 10px 14px; border-radius: 8px; text-decoration: none; border: none; cursor: pointer; font-size: 14px; }
.btn.secondary { background: #475569; }
.btn.danger { background: #dc2626; }
.btn.light { background: #e2e8f0; color: #111827; }
input, textarea, select { width: 100%; padding: 10px; margin: 7px 0 15px; border: 1px solid #cbd5e1; border-radius: 8px; }
textarea { min-height: 90px; }
table { width: 100%; border-collapse: collapse; background: white; }
th, td { padding: 12px; border-bottom: 1px solid #e5e7eb; text-align: left; vertical-align: top; }
th { background: #ecfdf5; }
.notice { padding: 12px; background: #dcfce7; border-left: 5px solid #16a34a; margin-bottom: 15px; }
.error { padding: 12px; background: #fee2e2; border-left: 5px solid #dc2626; margin-bottom: 15px; }
.question { border: 1px solid #e5e7eb; padding: 16px; border-radius: 10px; margin-bottom: 15px; background: #fff; }
.timer { position: sticky; top: 0; background: #111827; color: white; padding: 12px; text-align: center; font-size: 18px; z-index: 99; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }


/* User login and aligned exam choices */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: linear-gradient(135deg,#0f766e,#134e4a); }
.login-card { width: 100%; max-width: 440px; background: #fff; padding: 30px; border-radius: 18px; box-shadow: 0 16px 40px rgba(0,0,0,.18); }
.muted { color: #64748b; }
.btn.full { width: 100%; text-align: center; }
.header span { margin-right: 14px; }
.exam-card { border-left: 6px solid #0f766e; }
.question h3 { display: flex; gap: 8px; line-height: 1.45; }
.question .qnum { min-width: 34px; }
.choices { display: grid; gap: 10px; margin-top: 12px; }
.choices label { display: grid; grid-template-columns: 22px 34px 1fr; align-items: start; gap: 8px; padding: 10px 12px; border: 1px solid #e5e7eb; border-radius: 8px; cursor: pointer; line-height: 1.4; }
.choices label:hover { background: #f8fafc; }
.choices input[type="radio"] { width: auto; margin: 2px 0 0; }
.choice-letter { font-weight: bold; color: #0f766e; }
.success { padding: 12px; background: #dcfce7; border-left: 5px solid #16a34a; margin-bottom: 15px; }
.login-card.wide { max-width: 560px; }
.badge { display: inline-block; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: bold; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.pending { background: #fef3c7; color: #92400e; }
.checkline { display: flex; align-items: center; gap: 8px; margin: 8px 0 15px; }
.checkline input { width: auto; margin: 0; }
.notice a { word-break: break-all; }
.badge.off { background: #fee2e2; color: #991b1b; }
.lock-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.96); color: white; display: flex; align-items: center; justify-content: center; z-index: 9999; padding: 20px; }
.lock-box { width: 100%; max-width: 520px; background: white; color: #111827; padding: 30px; border-radius: 18px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.exam-locked { user-select: none; }
.exam-locked .question, .exam-locked .choices label { user-select: none; }

/* Stronger fullscreen lock mode */
.restore-overlay { background: rgba(127, 29, 29, .98); }
.danger-box { border-top: 8px solid #dc2626; }
.lock-overlay { backdrop-filter: blur(4px); }
.exam-locked { overflow-x: hidden; }

/* ---- Civil Service style categories ---- */
.parts-overview { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 0 0 16px; }
.part-chip { border: 1px solid #99f6e4; background: #f0fdfa; border-radius: 10px; padding: 10px 12px; text-align: center; line-height: 1.5; }
.part-header { background: #0f766e; color: #fff; padding: 14px 18px; border-radius: 10px; margin: 28px 0 14px; }
.part-header h2 { margin: 0; }
.part-header p { margin: 4px 0 0; color: #ccfbf1; }
.qtext { line-height: 1.5; }
.big-score { font-size: 54px; font-weight: bold; color: #0f766e; line-height: 1.1; }
.big-score span { font-size: 28px; color: #64748b; }
.big-badge { font-size: 16px; padding: 8px 22px; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.pending { background: #fef3c7; color: #92400e; }
.badge.off { background: #fee2e2; color: #991b1b; }
.cat-table td { vertical-align: middle; }
.cat-table .total-row td { background: #f8fafc; border-top: 2px solid #cbd5e1; }
.bar { background: #e5e7eb; border-radius: 999px; height: 12px; overflow: hidden; margin-bottom: 4px; }
.bar-fill { height: 100%; border-radius: 999px; background: #16a34a; }
.bar-fill.pending { background: #f59e0b; }
.bar-fill.off { background: #dc2626; }
@media print { .no-print, .header { display: none !important; } body { background: #fff; } .card { box-shadow: none; } }

/* ================= Mobile / tablet ================= */
html { -webkit-text-size-adjust: 100%; }
img { max-width: 100%; height: auto; }
@media (max-width: 900px) {
    .container { margin: 16px auto; padding: 0 12px; }
    .card { padding: 16px; border-radius: 12px; }
    .header { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
    .header a { margin-left: 0; margin-right: 12px; display: inline-block; padding: 6px 0; }
    .header > div { display: flex; flex-wrap: wrap; align-items: center; }
    h1 { font-size: 22px; } h2 { font-size: 19px; }
    /* tables scroll sideways instead of breaking the page */
    table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: normal; }
    th, td { padding: 9px 8px; font-size: 14px; }
    .cat-table { min-width: 0; }
    .cat-table .bar { min-width: 90px; }
    /* touch-friendly controls; 16px inputs stop iOS from zooming in */
    .btn { padding: 12px 16px; min-height: 44px; font-size: 15px; }
    input, textarea, select { font-size: 16px; padding: 12px; }
    .actions .btn { flex: 1 1 auto; text-align: center; }
    .login-page { padding: 14px; align-items: flex-start; padding-top: 6vh; }
    .login-card { padding: 22px; }
    /* exam */
    .timer { font-size: 13px; padding: 8px 6px; line-height: 1.5; }
    .question { padding: 12px; }
    .question h3 { font-size: 16px; }
    .choices label { grid-template-columns: 22px 28px 1fr; padding: 13px 10px; min-height: 48px; align-items: center; }
    .choices input[type="radio"] { width: 20px; height: 20px; }
    .part-header { padding: 12px 14px; margin: 22px 0 12px; }
    .part-header h2 { font-size: 18px; }
    .parts-overview { grid-template-columns: repeat(2, 1fr); }
    .big-score { font-size: 42px; } .big-score span { font-size: 22px; }
    .lock-box { padding: 22px; }
    .exam-locked { -webkit-touch-callout: none; }
}
@media (max-width: 480px) {
    .header strong { font-size: 15px; }
    .btn.full { font-size: 16px; }
}
