:root {
  --navy: #0b3d63;
  --navy-dark: #082c48;
  --navy-light: #12507f;
  --gold: #d4a017;
  --gold-light: #f2c14e;
  --bg: #f4f6f9;
  --bg-subtle: #eaeff4;
  --card: #ffffff;
  --border: #e3e8ee;
  --border-strong: #cfd8e3;
  --text: #1c2733;
  --muted: #64748b;
  --muted-2: #9aa7b8;
  --success: #1a8f4c;
  --success-light: #e9f8ef;
  --danger: #c0392b;
  --danger-light: #fdecea;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 2px 10px rgba(11, 61, 99, 0.06);
  --shadow-hover: 0 8px 24px rgba(11, 61, 99, 0.12);
  --shadow-lg: 0 16px 40px rgba(11, 61, 99, 0.22);
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
}

* { box-sizing: border-box; }

/* Dark mode is toggled by setting data-theme="dark" on <html> — done by
   theme-init.js before first paint (from a saved choice, or the visitor's
   OS-level preference if they haven't chosen yet), and flipped afterward by
   the theme toggle button in the header (see renderNav() in app.js). Only
   the surface/text colors change here; the navy/gold brand colors stay the
   same so the site is still recognizably "TRA SACCOS" in either mode. */
html[data-theme="dark"] {
  --bg: #10161d;
  --bg-subtle: #161d26;
  --card: #1a222c;
  --border: #2a3542;
  --border-strong: #3a4757;
  --text: #e7ecf2;
  --muted: #9aa7b8;
  --muted-2: #7a8798;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}
html[data-theme="dark"] input, html[data-theme="dark"] textarea, html[data-theme="dark"] select { background: #131a22; color: var(--text); }
html[data-theme="dark"] input:focus, html[data-theme="dark"] textarea:focus, html[data-theme="dark"] select:focus { background: #171f28; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ---------- Hero header ---------- */
header.hero {
  background:
    radial-gradient(circle at 15% 20%, rgba(212, 160, 23, 0.16) 0%, transparent 42%),
    radial-gradient(circle at 85% 0%, rgba(255, 255, 255, 0.08) 0%, transparent 38%),
    linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%);
  color: #fff;
  padding: 48px 24px 56px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 18px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--gold);
  color: var(--navy-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

header.hero h1 {
  font-size: 32px;
  margin: 0 0 10px;
  font-weight: 800;
}

header.hero p.tagline {
  font-size: 16px;
  color: #cfe0ee;
  max-width: 560px;
  margin: 0 auto;
}

.hero-accent {
  height: 4px;
  width: 72px;
  background: var(--gold);
  border-radius: 2px;
  margin: 18px auto 0;
}

/* ---------- Auth nav (top-right of hero) ---------- */
.auth-nav {
  position: absolute;
  top: 20px;
  right: 24px;
  display: flex;
  gap: 14px;
  align-items: center;
}
.auth-nav a, .auth-nav button.link-btn {
  color: #eaf2fa;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
}
.auth-nav a:hover, .auth-nav button.link-btn:hover { color: var(--gold-light); text-decoration: underline; }
.auth-nav .welcome { color: #cfe0ee; font-size: 13.5px; }
@media (max-width: 600px) {
  .auth-nav { position: static; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
}

/* ---------- Theme toggle ---------- */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #eaf2fa;
  cursor: pointer;
  transition: background 0.15s var(--ease);
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.22); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn .sun { display: none; }
html[data-theme="dark"] .icon-btn .sun { display: block; }
html[data-theme="dark"] .icon-btn .moon { display: none; }

/* ---------- Language toggle (reuses .icon-btn's sizing/hover, just adds
   text styling since it shows "EN"/"SW" instead of an SVG icon) ---------- */
.lang-toggle { font-size: 11px; font-weight: 700; letter-spacing: 0.3px; width: auto; min-width: 30px; padding: 0 8px; }

/* ---------- Notification bell / list ---------- */
.notif-item {
  padding: 10px 12px;
  border-radius: 8px;
  background: #f6f9fc;
  border: 1px solid var(--border);
  margin-bottom: 8px;
  font-size: 13.5px;
}
.notif-item.unread { border-left: 3px solid var(--gold); background: #fffdf6; }
.notif-item .notif-time { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---------- Repeater rows (education / experience / certifications) ---------- */
.repeater-row {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  background: #fbfcfd;
  position: relative;
}
.repeater-row .remove-row {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: var(--danger);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  margin: 0;
  padding: 4px 8px;
}
.add-row-btn {
  background: #eef4f9;
  color: var(--navy);
  border: 1.5px dashed var(--navy-light);
  font-weight: 700;
  width: 100%;
  margin-top: 4px;
}
.add-row-btn:hover { background: #e2edf5; }

/* ---------- Compact spreadsheet-style entry tables (education / certifications) ---------- */
.entry-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
  font-size: 13.5px;
}
.entry-table th, .entry-table td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  vertical-align: middle;
}
.entry-table th {
  background: #eef4f9;
  color: var(--navy);
  font-weight: 700;
  font-size: 12.5px;
}
.entry-table td input, .entry-table td select {
  width: 100%;
  padding: 6px 7px;
  font-size: 13px;
  border: 1px solid transparent;
  background: #fbfcfd;
  margin: 0;
}
.entry-table td input:focus { border-color: var(--navy-light); background: #fff; }
.entry-table td input[type="file"] { padding: 3px; background: transparent; }
.entry-table .remove-row {
  background: none;
  border: none;
  color: var(--danger);
  font-weight: 700;
  cursor: pointer;
  padding: 4px 8px;
  margin: 0;
}
@media (max-width: 700px) {
  .entry-table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* Month+year picker pair for the education/certification "Years" columns —
   two native <input type="month"> fields side by side instead of a single
   free-text field validated by regex. */
.year-picker-pair {
  display: flex;
  align-items: center;
  gap: 4px;
}
.year-picker-pair .years-from,
.year-picker-pair .years-to {
  width: auto;
  min-width: 0;
  flex: 1 1 0;
}
.year-picker-sep {
  color: var(--muted);
  flex-shrink: 0;
  font-size: 12px;
}

.step-indicator {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}
.step-indicator .active { color: var(--navy); }

.preview-block {
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
}
.preview-block:last-child { border-bottom: none; }
.preview-block .k { font-weight: 700; color: var(--navy); font-size: 13px; }
.preview-block .v { font-size: 14px; margin-top: 2px; }

/* ---------- Layout ---------- */
.container {
  max-width: 860px;
  margin: -28px auto 0;
  padding: 0 24px 48px;
  position: relative;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

h2 {
  margin-top: 0;
  font-size: 19px;
  color: var(--navy);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 22px;
  font-weight: 800;
  color: var(--navy);
  margin: 0 0 18px;
}

.count-badge {
  background: var(--gold);
  color: var(--navy-dark);
  font-size: 13px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
}

/* ---------- Job cards ---------- */
.job-list { display: grid; gap: 14px; }

.job-card {
  cursor: pointer;
  transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
  border-left: 4px solid transparent;
}
.job-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
  border-left-color: var(--gold);
}

.job-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--navy);
}
.job-meta {
  color: var(--muted);
  font-size: 13.5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.job-meta .dot { color: var(--border); margin: 0 2px; }
.job-meta .meta-icon {
  display: inline-flex;
  width: 13px;
  height: 13px;
  vertical-align: -2px;
  margin-right: 3px;
  color: var(--muted-2);
}
.job-card-arrow {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--muted-2);
  transition: transform 0.18s var(--ease), color 0.18s var(--ease);
  margin-top: 4px;
}
.job-card:hover .job-card-arrow { transform: translateX(3px); color: var(--gold); }

.badge-row { display: flex; gap: 8px; flex-wrap: wrap; }

.job-req-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #eef4f9;
  color: var(--navy);
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid #dbe7f0;
}

.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: capitalize;
  background: var(--bg-subtle);
  color: var(--muted);
}
.status-badge.applied { background: #eef1ff; color: #2454ff; }
.status-badge.screening { background: #fff6e0; color: #b5750a; }
.status-badge.interview { background: #e6f0ff; color: #1a5fd1; }
.status-badge.offer { background: var(--success-light); color: var(--success); }
.status-badge.shortlisted { background: #eef7ff; color: #0a6ebd; }
.status-badge.hired { background: #d9f4e4; color: #10693a; }
.status-badge.rejected { background: var(--danger-light); color: var(--danger); }
.status-badge.withdrawn { background: var(--bg-subtle); color: var(--muted); }

/* ---------- Application status timeline (replaces the plain badge for the
   normal applied -> ... -> hired path; rejected/withdrawn still use the
   badge above, unchanged) ---------- */
.status-timeline {
  display: flex;
  align-items: flex-start;
  gap: 2px;
  margin: 10px 0 4px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.status-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 64px;
  position: relative;
}
.status-step::before {
  content: '';
  position: absolute;
  top: 5px;
  left: -50%;
  width: 100%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.status-step:first-child::before { display: none; }
.status-step.done::before { background: var(--success); }
.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--bg, #fff);
  position: relative;
  z-index: 1;
}
.status-step.done .status-dot { background: var(--success); }
.status-step.current .status-dot { background: var(--navy); box-shadow: 0 0 0 3px var(--success-light); }
.status-step-label {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 5px;
  text-align: center;
  white-space: nowrap;
}
.status-step.done .status-step-label { color: var(--success); }
.status-step.current .status-step-label { color: var(--navy); font-weight: 700; }
@media (max-width: 480px) {
  .status-step-label { font-size: 9.5px; }
}

.type-tag {
  display: inline-block;
  background: var(--navy);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 3px 10px;
  border-radius: 999px;
}

/* ---------- Forms ---------- */
label { display: block; font-size: 13.5px; font-weight: 700; color: var(--navy); margin: 16px 0 6px; }
label:first-of-type { margin-top: 0; }

input, textarea, select {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-size: 14.5px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  background: #fbfcfd;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--navy-light);
  box-shadow: 0 0 0 3px rgba(11, 61, 99, 0.1);
  background: #fff;
}
textarea { resize: vertical; }

/* Keyboard-only focus ring for everything else that's clickable — links,
   buttons, the icon-only password-toggle, etc. Browsers already do this to
   some degree, but only for :focus-visible (keyboard nav) keeps mouse
   clicks from showing a distracting ring while still giving keyboard/screen
   reader users a clear, visible landing spot. */
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--navy-light);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Skip-to-content link — invisible until a keyboard user tabs to it, so
   they don't have to tab through the whole nav/hero on every single page
   just to reach the actual content. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--navy-dark);
  color: #fff;
  padding: 10px 16px;
  z-index: 1000;
  border-radius: 0 0 8px 0;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus {
  left: 0;
}

.field-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Compact 2-column field grid, used to keep long forms (e.g. registration)
   short and easy to scan instead of one long vertical stack of inputs. */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
.form-grid .field { margin-top: 16px; }
.form-grid .field:nth-child(1),
.form-grid .field:nth-child(2) { margin-top: 0; }
.form-grid .field.full { grid-column: 1 / -1; }
.form-grid .field label { margin: 0 0 6px; }
.form-grid .password-field { position: relative; }
.form-grid .password-field .toggle-pw {
  position: absolute;
  right: 10px;
  top: 32px;
  background: none;
  border: none;
  padding: 4px;
  margin: 0;
  color: var(--muted-2);
  cursor: pointer;
  display: flex;
}
.form-grid .password-field .toggle-pw:hover { color: var(--navy); }
.form-grid .password-field input { padding-right: 38px; }
@media (max-width: 520px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .field:nth-child(2) { margin-top: 16px; }
}

button {
  background: var(--navy);
  color: white;
  border: none;
  padding: 13px 26px;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 22px;
  transition: background 0.15s ease, transform 0.1s ease;
}
button:hover { background: var(--navy-light); }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- Alerts ---------- */
.alert {
  padding: 13px 16px;
  border-radius: 9px;
  font-size: 14px;
  margin: 14px 0;
  border-left: 4px solid transparent;
}
.alert.error { background: #fdecea; color: var(--danger); border-left-color: var(--danger); }
.alert.success { background: #e9f8ef; color: var(--success); border-left-color: var(--success); }
.alert.info { background: #fff7e6; color: #a15c00; border-left-color: #e6a400; }

.back-link {
  /* .container has a -28px top margin so the first card overlaps the hero
     banner for a layered look — that's fine when the first child is a
     padded .card, but a bare link with no top space of its own gets tucked
     underneath the hero and disappears. This margin cancels that overlap
     just for the back-link, so it clears the hero and is actually visible. */
  margin-top: 28px;
  color: var(--navy);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 14px;
}
.back-link:hover { text-decoration: underline; }

.hint { font-size: 13.5px; color: var(--muted); }
.hidden { display: none !important; }

/* ---------- How to Apply guide ---------- */
.guide-intro h2 { margin-top: 0; }
.guide-step {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
}
.guide-step:last-child { border-bottom: none; padding-bottom: 4px; }
.guide-step:first-child { padding-top: 4px; }
.guide-step-number {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
}
.guide-step-body { flex: 1; min-width: 0; }
.guide-step-body h3 { margin: 2px 0 8px; font-size: 16px; color: var(--navy); }
.guide-step-body p { margin: 0 0 14px; font-size: 14.5px; line-height: 1.55; }
.guide-shot {
  max-width: 100%;
  height: auto;
  min-height: 40px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: block;
}
html[data-theme="dark"] .guide-step-number { background: var(--gold); color: var(--navy-dark); }

/* ---------- Footer ---------- */
footer.site-footer {
  text-align: center;
  padding: 28px 24px 40px;
  color: var(--muted);
  font-size: 13px;
}
footer.site-footer .footer-name { color: var(--navy); font-weight: 700; }

/* ---------- Empty / skeleton loading states ---------- */
.empty-state {
  text-align: center;
  padding: 44px 20px;
  color: var(--muted);
}
.empty-state .icon { width: 42px; height: 42px; margin: 0 auto 12px; color: var(--muted-2); }
.empty-state .title { font-weight: 700; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.empty-state .desc { font-size: 13.5px; }

.skeleton {
  background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--border) 37%, var(--bg-subtle) 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
.skeleton-line { height: 13px; margin-bottom: 9px; }

/* ---------- Toasts ---------- */
#toastStack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 340px;
}
.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--navy);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 13px 15px;
  font-size: 13.5px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toast-in 0.25s var(--ease);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast .toast-icon { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.info .toast-icon { color: var(--navy); }
.toast .toast-close {
  margin: 0;
  background: none;
  border: none;
  color: var(--muted);
  padding: 0;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  box-shadow: none;
}
.toast.leaving { animation: toast-out 0.2s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* ---------- Confirm modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 20, 32, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  animation: overlay-in 0.15s var(--ease);
  padding: 20px;
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px 26px;
  max-width: 380px;
  width: 100%;
  animation: modal-in 0.2s var(--ease);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-box h3 { margin: 0 0 8px; font-size: 16.5px; color: var(--navy); }
.modal-box p { margin: 0 0 18px; font-size: 13.5px; color: var(--muted); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.modal-actions button { margin-top: 0; padding: 10px 20px; }
.modal-actions button.danger { background: var(--danger); }

@media (max-width: 600px) {
  #toastStack { left: 12px; right: 12px; max-width: none; }
  header.hero { padding: 36px 18px 48px; }
  header.hero h1 { font-size: 26px; }
  .container { padding: 0 14px 40px; }
  .card { padding: 18px; }
}
