:root {
  --ink: #1c2430;
  --slate: #48566b;
  --slate-light: #7c8aa0;
  --line: #dde2ea;
  --paper: #f6f7f9;
  --card: #ffffff;
  --accent: #2f5d9e;
  --accent-dark: #234878;
  --warn: #b5580d;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --radius: 10px;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
}

.hidden { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--ink);
  color: #fff;
  border-bottom: 3px solid var(--accent);
}
.topbar-staff { border-bottom-color: #6b7a94; }
.topbar-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand-block { display: flex; flex-direction: column; line-height: 1.3; }
.brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}
.brand-subtitle {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.6);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.timer {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-variant-numeric: tabular-nums;
  background: rgba(255,255,255,0.08);
  padding: 6px 14px;
  border-radius: 999px;
}
.timer #timer-label {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.65);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.timer #timer-value {
  font-size: 1.15rem;
  font-weight: 700;
}
.timer.warning { background: rgba(181, 88, 13, 0.35); }
.timer.critical { background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

.wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  margin: 0 auto;
  box-shadow: 0 1px 3px rgba(28,36,48,0.06);
}
.card-login {
  max-width: 740px;
  margin-top: 24px;
}
.login-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 14px;
}
.login-subtitle {
  color: var(--slate);
  font-size: 0.95rem;
  margin: 0 0 28px;
}
.login-field {
  margin-bottom: 34px;
}
.login-field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--slate);
  margin: 0 0 8px;
}
/* #screen-login scoping wins over the generic input[type="text"] rule below
   (which is what everywhere else - test-taking forms, admin dashboard -
   keeps using) without needing !important or touching that rule at all. */
#screen-login .login-input {
  width: 240px;
  max-width: 100%;
  height: 34px;
  padding: 6px 10px;
  border: 1px solid #333;
  border-radius: 2px;
  font-size: 0.9rem;
  background: #fff;
}
.btn-primary.login-submit {
  margin-top: 4px;
  padding: 10px 26px;
  border-radius: 6px;
}

/* Password show/hide toggle - wraps any input[type=password] at runtime (see enablePasswordToggles in app.js/admin.js) */
.pw-wrap {
  position: relative;
  display: block;
}
.pw-wrap input {
  padding-right: 36px !important;
  box-sizing: border-box;
}
.pw-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--slate, #666);
  line-height: 0;
}
.pw-toggle:hover { color: #222; }
.pw-toggle svg { width: 18px; height: 18px; }

h1 { font-size: 1.5rem; margin: 0 0 6px; }
h2 { font-size: 1.25rem; margin: 0 0 6px; }
h3 { font-size: 1.1rem; margin: 0 0 8px; }
.muted { color: var(--slate); }
.warn { color: var(--warn); }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--slate);
  margin: 18px 0 6px;
}
input[type="text"], input[type="email"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn-primary, .btn-secondary {
  border: none;
  border-radius: 8px;
  padding: 11px 22px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; margin-top: 22px; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-primary:disabled { background: var(--slate-light); cursor: not-allowed; }
.btn-secondary { background: #eef1f5; color: var(--ink); }
.btn-secondary:hover { background: #e2e6ed; }
.btn-row { display: flex; gap: 12px; margin-top: 22px; }
.btn-row .btn-primary, .btn-row .btn-secondary {
  flex: 1;
  text-align: center;
  margin-top: 0; /* .btn-primary's own margin-top would otherwise misalign it against .btn-secondary in the same row */
}

.role-preview {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.role-preview-row { display: flex; justify-content: space-between; margin-bottom: 6px; }

.error {
  color: var(--danger);
  background: var(--danger-bg);
  padding: 10px 12px;
  border-radius: 8px;
  margin-top: 16px;
}

.section-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 28px;
  margin-bottom: 20px;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 16px;
}
.section-time {
  font-size: 0.8rem;
  color: var(--slate-light);
  white-space: nowrap;
}
.section-instructions { margin-bottom: 16px; }
.resource-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.resource-link:hover { text-decoration: underline; }

.question-block { margin-bottom: 22px; }
.question-text { font-weight: 500; margin-bottom: 8px; }
.question-extra { font-size: 0.85rem; color: var(--slate-light); margin-bottom: 8px; }
.file-status { font-size: 0.82rem; margin-top: 6px; color: var(--slate); }
.file-status.ok { color: #1a7a3c; }
.file-status.error { color: var(--danger); }

.submit-bar {
  position: sticky;
  bottom: 0;
  background: var(--paper);
  border-top: 1px solid var(--line);
  padding: 16px 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(28,36,48,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 26px 28px;
  max-width: 380px;
}

@media (max-width: 480px) {
  .card, .section-card { padding: 20px; }
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  font-size: 0.9rem;
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
}
.admin-table th { color: var(--slate); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.status-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.status-not-started { background: #eef1f5; color: var(--slate); }
.status-in-progress { background: #fef3e2; color: var(--warn); }
.status-submitted { background: #e5f5ea; color: #1a7a3c; }
.status-time-expired { background: var(--danger-bg); color: var(--danger); }

/* --- New in v2: guidance, watermark, external-test sections --- */
.watermark {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
  color: rgba(28,36,48,0.06);
  font-size: 0.8rem;
  line-height: 3.2;
  white-space: normal;
  word-break: break-all;
  padding: 20px;
  user-select: none;
}

.guidance-text {
  white-space: pre-wrap;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px;
  margin: 16px 0;
  font-size: 0.92rem;
  max-height: 340px;
  overflow-y: auto;
}

.ack-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 18px;
}
.ack-row input[type="checkbox"] { margin-top: 4px; width: 16px; height: 16px; }
.ack-label { font-weight: 500; color: var(--ink); margin: 0; }

.instructions-bar {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 10px 4px 16px;
}
.instructions-bar a { color: var(--accent); font-weight: 600; text-decoration: none; }
.instructions-bar a:hover { text-decoration: underline; }

.external-box {
  background: var(--paper);
  border: 1px dashed var(--slate-light);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.external-box .resource-link { margin-bottom: 6px; }

/* Disable text selection during the timed test to slightly raise the bar
   on casual copy/paste of the on-screen content (not a real protection -
   devtools bypass it trivially, see README). */
#screen-test { user-select: none; }
#screen-test textarea, #screen-test input { user-select: text; }

.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.tab-btn {
  border: none;
  background: none;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--slate);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel.hidden { display: none; }
.admin-table select, .admin-table input { padding: 6px 8px; font-size: 0.85rem; }
.small-btn { padding: 4px 10px; font-size: 0.8rem; }

.paste-zone {
  margin-top: 8px;
  padding: 18px;
  border: 2px dashed var(--slate-light);
  border-radius: 8px;
  text-align: center;
  color: var(--slate);
  font-size: 0.88rem;
  cursor: pointer;
  background: var(--paper);
}
.paste-zone:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
  color: var(--ink);
}

.logic-quiz-container { margin-bottom: 8px; }
.logic-prompt-image { max-width: 100%; margin: 10px 0; border: 1px solid var(--line); border-radius: 6px; }
.logic-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.logic-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.92rem;
}
.logic-option:has(input:checked) { border-color: var(--accent); background: rgba(47,93,158,0.06); }
.logic-option img { max-width: 140px; max-height: 120px; display: block; margin: 4px auto; }
.logic-prompt-image { max-width: 100%; width: 420px; margin: 12px 0; border: 1px solid var(--line); border-radius: 6px; display: block; }

.score-btn-group { display: flex; gap: 8px; margin-top: 6px; }
.score-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 8px 18px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--slate);
}
.score-btn:hover { border-color: var(--accent); }
.score-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.logic-subtimer {
  font-weight: 600;
  padding: 10px 14px;
  margin-bottom: 12px;
  border-radius: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
}
.logic-subtimer.warning { background: #fef3e2; color: var(--warn); border-color: var(--warn); }
.logic-subtimer.locked { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); font-weight: 700; }
.logic-option-letter {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--slate);
  min-width: 18px;
  text-align: center;
}
.logic-option.disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Sign-out button (candidate topbar) ─────────────────────────────── */
.btn-signout {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.55);
  color: #fff;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-signout:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.85);
}

/* ── Danger / destructive action button ────────────────────────────── */
.btn-danger {
  background: #fff0f0;
  border: 1px solid #e53e3e;
  color: #c53030;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s;
}
.btn-danger:hover {
  background: #ffe0e0;
}
.btn-danger.small-btn {
  padding: 4px 10px;
  font-size: 0.78rem;
}

/* --- Password show/hide toggle --- */
.password-field-wrapper {
  position: relative;
  display: block;
  width: 100%; /* matches full-width password inputs (e.g. the reset-password modal) */
}
/* Login page inputs are a fixed 240px box, not full-width - the wrapper
   must match that exactly, or the toggle button (anchored to the wrapper's
   edge) ends up floating past the visible input's actual right edge. */
#screen-login .password-field-wrapper { width: 240px; max-width: 100%; }
.password-field-wrapper input { padding-right: 38px !important; width: 100%; }
.password-toggle-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  padding: 4px 8px;
  color: var(--slate);
}
.password-toggle-btn:hover { color: var(--ink); }

/* Suppress Microsoft Edge's native password-reveal icon so it doesn't
   duplicate/collide with our own toggle button. Chrome has no equivalent
   native icon - if this icon still appears there, it's coming from a
   browser extension, which no page-level CSS/JS can remove. */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear {
  display: none;
}
