/* Trainability Assessment - mobile-first stylesheet */
:root {
  --ink: #1d2433;
  --muted: #5d6779;
  --line: #dde2ea;
  --bg: #f4f6f9;
  --card: #ffffff;
  --brand: #1f4e8c;
  --brand-dark: #163a69;
  --accent: #e8f0fb;
  --ok: #1d7a46;
  --ok-bg: #e5f4ec;
  --warn: #9a5b00;
  --warn-bg: #fdf1dc;
  --bad: #b3261e;
  --bad-bg: #fbe7e5;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* ---------- layout ---------- */
.topbar {
  background: var(--brand);
  color: #fff;
  padding: .7rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.topbar .brand { font-weight: 700; color: #fff; text-decoration: none; margin-right: auto; }
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.topbar nav a, .topbar nav button {
  color: #fff; text-decoration: none; padding: .35rem .6rem; border-radius: 6px;
  font-size: .9rem; background: none; border: 0; cursor: pointer; font: inherit;
}
.topbar nav a:hover, .topbar nav button:hover { background: rgba(255,255,255,.15); }

.wrap { max-width: 1040px; margin: 0 auto; padding: 1rem; }
.wrap.narrow { max-width: 560px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin-bottom: 1rem;
}
.grid { display: grid; gap: 1rem; }
@media (min-width: 720px) {
  .grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
}
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

/* ---------- stats ---------- */
.stat { text-align: left; }
.stat .num { font-size: 1.8rem; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: .85rem; }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; margin-bottom: .25rem; font-size: .92rem; }
.field { margin-bottom: .9rem; }
.field .help { color: var(--muted); font-size: .82rem; }
.field .errors { color: var(--bad); font-size: .85rem; margin: .2rem 0 0; padding: 0; list-style: none; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=search],
input[type=number], select, textarea {
  width: 100%;
  padding: .65rem .7rem;
  font: inherit;
  border: 1px solid #c4ccd8;
  border-radius: 8px;
  background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.checkbox { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; }
.checkbox input { margin-top: .3rem; width: 1.2rem; height: 1.2rem; flex: none; }
.code-input { font-size: 1.6rem !important; letter-spacing: .25em; text-align: center; text-transform: uppercase; }
.filters { display: grid; gap: .5rem; grid-template-columns: 1fr 1fr; }
@media (min-width: 720px) { .filters { grid-template-columns: repeat(5, auto); align-items: end; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  padding: .65rem 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  text-align: center;
}
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: #fff; color: var(--brand); }
.btn.secondary:hover { background: var(--accent); }
.btn.danger { background: #fff; color: var(--bad); border-color: var(--bad); }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.block { display: block; width: 100%; }
.btn.lg { padding: .9rem 1.2rem; font-size: 1.05rem; }
.btn.sm { padding: .3rem .6rem; font-size: .85rem; }

/* ---------- messages / badges ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: .7rem .9rem; border-radius: 8px; margin-bottom: .5rem; background: var(--accent); }
.messages .success { background: var(--ok-bg); color: var(--ok); }
.messages .error { background: var(--bad-bg); color: var(--bad); }
.messages .warning { background: var(--warn-bg); color: var(--warn); }

.badge {
  display: inline-block; padding: .1rem .5rem; border-radius: 99px; font-size: .78rem;
  font-weight: 600; background: var(--accent); color: var(--brand); white-space: nowrap;
}
.badge.draft, .badge.pending { background: var(--warn-bg); color: var(--warn); }
.badge.approved, .badge.completed { background: var(--ok-bg); color: var(--ok); }
.badge.returned, .badge.cancelled, .badge.retired { background: var(--bad-bg); color: var(--bad); }
.badge.in_progress { background: var(--accent); color: var(--brand); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tr.clickable:hover { background: #f8fafc; }
td.num, th.num { text-align: right; white-space: nowrap; }
.ok-text { color: var(--ok); font-weight: 600; }
.bad-text { color: var(--bad); font-weight: 600; }
.warn-text { color: var(--warn); font-weight: 600; }

/* ---------- score bars ---------- */
.bar { height: 10px; background: #e7ebf1; border-radius: 99px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--brand); }

/* ---------- test taking ---------- */
.exam-head {
  position: sticky; top: 0; z-index: 5;
  background: var(--brand); color: #fff;
  padding: .6rem 1rem;
  display: flex; align-items: center; gap: .75rem;
}
.exam-head .count { font-weight: 600; }
.exam-head .timer {
  margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 700;
  background: rgba(255,255,255,.15); padding: .2rem .6rem; border-radius: 6px;
}
.exam-head .timer.low { background: #c0392b; }
.progress { height: 4px; background: rgba(0,0,0,.08); }
.progress > span { display: block; height: 100%; background: #f2b134; }
.question-cat { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.question-stem { font-size: 1.12rem; margin: .4rem 0 1.1rem; white-space: pre-line; }
.question-img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 1rem; }
.options { display: grid; gap: .6rem; margin-bottom: 1.2rem; }
.option {
  display: flex; gap: .75rem; align-items: center;
  border: 2px solid var(--line); border-radius: 10px; padding: .8rem .9rem;
  background: #fff; cursor: pointer; font-weight: 400; font-size: 1.02rem; margin: 0;
}
.option input { width: 1.25rem; height: 1.25rem; flex: none; accent-color: var(--brand); }
.option .letter { font-weight: 700; color: var(--muted); width: 1.2rem; flex: none; }
.option:has(input:checked) { border-color: var(--brand); background: var(--accent); }
.option.correct, .option.correct:has(input:checked) { border-color: var(--ok); background: var(--ok-bg); font-weight: 600; }
.option.wrong, .option.wrong:has(input:checked) { border-color: var(--bad); background: var(--bad-bg); }
.option:has(input:disabled) { cursor: default; }
.feedback { padding: .7rem .9rem; border-radius: 8px; margin-bottom: 1rem; }
.feedback.ok { background: var(--ok-bg); color: var(--ok); }
.feedback.bad { background: var(--bad-bg); color: var(--bad); }
.practice-head { background: #3d5a80; }
.no-copy { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.away-warning { background: var(--warn-bg); color: var(--warn); border: 1px solid #e8c48a; padding: .7rem .9rem;
  border-radius: 8px; margin: .75rem 0; font-size: .92rem; font-weight: 600; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

.big-code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 3rem; font-weight: 700; letter-spacing: .3em; text-align: center;
  padding: 1rem; background: var(--accent); border-radius: var(--radius); color: var(--brand-dark);
}

/* ---------- review ---------- */
.opt-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.opt-list li { padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 8px; margin-bottom: .4rem; }
.opt-list li.correct { border-color: var(--ok); background: var(--ok-bg); font-weight: 600; }
.problem { background: var(--bad-bg); color: var(--bad); padding: .6rem .8rem; border-radius: 8px; margin-bottom: .5rem; }
.pagination { display: flex; gap: .5rem; align-items: center; margin-top: 1rem; }

/* ---------- print (result report) ---------- */
@media print {
  .topbar, .no-print, .messages { display: none !important; }
  body { background: #fff; font-size: 12pt; }
  .card { border: 1px solid #999; break-inside: avoid; }
  .wrap { max-width: none; padding: 0; }
  a { color: inherit; text-decoration: none; }
}

.rules-box { background: var(--warn-bg); border: 1px solid #e8c48a; border-radius: 8px; padding: .8rem 1rem; margin: 1rem 0; }
.rules-box h2 { color: var(--warn); margin-bottom: .3rem; }
.rules-box ul { margin: 0 0 .5rem; padding-left: 1.2rem; }
