/* Reset + base */
*, *::before, *::after { box-sizing: border-box; }
html { font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
body { margin: 0; background: #f5f7fb; color: #1a1f2e; line-height: 1.55; }
img { max-width: 100%; }
a { color: #1d4ed8; text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }

/* Header */
.site-header { background: #1e293b; color: #fff; padding: 0.8rem 0; box-shadow: 0 2px 8px rgba(0,0,0,0.07); }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { color: #fff; font-weight: 700; font-size: 1.1rem; }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.nav a { color: #cbd5e1; }
.nav a:hover { color: #fff; }
.nav .admin-link { color: #fbbf24; font-weight: 600; }
.btn-link { background: none; border: 0; color: #cbd5e1; cursor: pointer; font-size: 0.9rem; padding: 0; }
.btn-link:hover { color: #fff; text-decoration: underline; }
.inline-form { display: inline; margin: 0; }

.site-footer { margin-top: 4rem; padding: 1.5rem 0; color: #64748b; text-align: center; }
.main-content { padding: 2rem 1rem 4rem; }

/* Cards */
.card { background: #fff; border-radius: 10px; padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.text-center { text-align: center; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 1rem; }
.form label { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 500; font-size: 0.95rem; }
.form input[type="text"], .form input[type="password"], .form input[type="date"], .form input[type="email"], .form textarea, .form select {
  width: 100%; padding: 0.6rem 0.75rem; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 1rem; background: #fff; font-family: inherit;
}
.form textarea { resize: vertical; min-height: 70px; }
.form-narrow { max-width: 420px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: end; }
.form-grid button { grid-column: 1 / -1; justify-self: start; }
.form-inline { display: flex; flex-wrap: wrap; align-items: end; gap: 0.5rem; margin-bottom: 1rem; }
.form-inline label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.9rem; }
.checkbox-row { flex-direction: row !important; align-items: center; gap: 0.5rem !important; }

/* Buttons */
.btn { display: inline-block; padding: 0.55rem 1.1rem; background: #e2e8f0; color: #0f172a; border: 0; border-radius: 6px; cursor: pointer; text-align: center; font-weight: 500; font-size: 0.95rem; font-family: inherit; }
.btn:hover { background: #cbd5e1; text-decoration: none; }
.btn-primary { background: #1d4ed8; color: #fff; }
.btn-primary:hover { background: #1e40af; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-block { display: block; width: 100%; }
.btn-lg { padding: 0.85rem 1.5rem; font-size: 1.05rem; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.85rem; }

/* Login */
.login-wrap { display: flex; justify-content: center; align-items: center; min-height: 60vh; }
.login-wrap .card { max-width: 380px; width: 100%; }

/* Welcome */
.welcome h1 { margin-top: 0; }
.lead { color: #475569; font-size: 1.05rem; }
.muted { color: #64748b; }

/* Tiles grid */
.grid { display: grid; gap: 1rem; }
.grid-tests { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 2rem; }
.test-tile { display: block; background: #fff; padding: 1.2rem; border-radius: 10px; border: 1px solid #e2e8f0; color: #1a1f2e; transition: transform 0.1s, box-shadow 0.1s, border-color 0.1s; }
.test-tile:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.08); border-color: #1d4ed8; }
.tile-icon { font-size: 1.8rem; margin-bottom: 0.5rem; }
.tile-title { font-weight: 700; margin-bottom: 0.2rem; }
.tile-meta { font-size: 0.85rem; color: #64748b; }
.tile-primary { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }
.tile-primary .tile-meta { color: #c7d2fe; }
.tile-primary:hover { background: #1e40af; color: #fff; }
.tile-resume { background: #fbbf24; color: #0f172a; border-color: #fbbf24; }

/* Tables */
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.05); margin-bottom: 1.5rem; }
.table th, .table td { padding: 0.65rem 0.8rem; text-align: left; border-bottom: 1px solid #e2e8f0; font-size: 0.95rem; }
.table th { background: #f1f5f9; font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }

/* Badges */
.badge { display: inline-block; padding: 0.2rem 0.55rem; border-radius: 999px; background: #e2e8f0; color: #334155; font-size: 0.8rem; font-weight: 600; }
.badge-pass { background: #dcfce7; color: #166534; }
.badge-fail { background: #fee2e2; color: #991b1b; }
.badge-warn { background: #fef3c7; color: #92400e; }

/* Flash */
.flash { padding: 0.7rem 1rem; border-radius: 8px; margin-bottom: 1.2rem; }
.flash-error { background: #fee2e2; color: #991b1b; }
.flash-success { background: #dcfce7; color: #166534; }
.flash-info { background: #dbeafe; color: #1e3a8a; }

/* Test runner */
.test-wrap { background: #fff; border-radius: 10px; padding: 1.5rem; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.test-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 1rem; margin-bottom: 1rem; border-bottom: 1px solid #e2e8f0; font-size: 0.95rem; }
.timer-wrap { font-variant-numeric: tabular-nums; font-weight: 700; color: #1d4ed8; font-size: 1.1rem; }
.timer-low { color: #dc2626 !important; }
.question-card { padding: 0.5rem 0 1.5rem; }
.question-text { font-size: 1.15rem; margin: 0 0 0.5rem; line-height: 1.4; }
.question-ref { font-size: 0.85rem; color: #64748b; margin: 0 0 1.2rem; }
.option { display: flex; gap: 0.7rem; padding: 0.7rem 0.9rem; border: 2px solid #e2e8f0; border-radius: 8px; cursor: pointer; margin-bottom: 0.6rem; transition: background 0.1s, border-color 0.1s; }
.option:hover { background: #f1f5f9; }
.option-selected { background: #dbeafe; border-color: #1d4ed8; }
.option input[type="radio"] { margin-top: 0.25rem; }
.option-letter { font-weight: 700; min-width: 1.5rem; }
.option-text { flex: 1; }
.test-nav { display: flex; justify-content: space-between; gap: 1rem; padding-top: 1rem; border-top: 1px solid #e2e8f0; margin-top: 1rem; }

.single-variant { background: #f1f5f9; padding: 1rem; border-radius: 8px; border-left: 4px solid #1d4ed8; }

.question-pager { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 1rem 0; justify-content: center; }
.pager-dot { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; background: #fff; border: 2px solid #cbd5e1; color: #64748b; font-weight: 600; text-decoration: none; font-size: 0.9rem; }
.pager-dot:hover { text-decoration: none; border-color: #1d4ed8; }
.pager-dot.answered { background: #dbeafe; color: #1e3a8a; border-color: #93c5fd; }
.pager-dot.current { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }

.submit-section-form { margin-top: 1rem; }

/* Result */
.result-card { padding: 2rem 1.5rem; }
.result-score { font-size: 3rem; font-weight: 700; margin: 0.5rem 0; color: #1d4ed8; }
.result-percent { font-size: 1.5rem; margin-bottom: 1.5rem; }
.result-percent .badge { font-size: 0.9rem; margin-left: 0.5rem; vertical-align: middle; }
.result-meta { margin-bottom: 0.5rem; }
.section-breakdown { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center; padding: 1rem; background: #f1f5f9; border-radius: 8px; margin: 1rem 0; }
.section-cell { font-size: 1rem; }
.result-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; margin-top: 1.5rem; }

/* Wrong answers */
.wrong-card { border-left: 4px solid #dc2626; }
.wrong-card-header { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
.wrong-line { margin: 0.5rem 0; padding: 0.5rem 0.8rem; border-radius: 6px; }
.wrong-line-bad { background: #fee2e2; color: #991b1b; }
.wrong-line-good { background: #dcfce7; color: #166534; }

/* Page header */
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-header h1 { margin: 0; }

/* Admin */
.option-edit { display: grid; grid-template-columns: 80px 1fr; gap: 0.5rem; align-items: start; padding: 0.5rem 0; border-bottom: 1px dashed #e2e8f0; }
.radio-correct { display: flex; align-items: center; gap: 0.3rem; font-weight: 600; }
.danger-zone { border: 1px solid #fecaca; }

/* History */
.history-section h2 { margin-top: 2rem; }

/* Responsive */
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .test-header { font-size: 0.9rem; }
  .question-text { font-size: 1rem; }
  .test-nav { flex-direction: column; }
  .test-nav .btn { width: 100%; }
  .pager-dot { width: 30px; height: 30px; font-size: 0.8rem; }
  .result-score { font-size: 2.2rem; }
  .header-inner { flex-direction: column; align-items: flex-start; }
  .nav { width: 100%; flex-wrap: wrap; }
  .table { font-size: 0.85rem; }
  .table th, .table td { padding: 0.4rem 0.5rem; }
}
