:root {
  --xbe-navy: #0e2440;
  --xbe-blue: #1f6feb;
  --xbe-blue-dark: #1a5fd0;
  --ink: #1c2430;
  --muted: #67727f;
  --line: #e3e8ef;
  --bg: #f5f7fa;
  --card: #ffffff;
  --green: #1f9d57;
  --green-bg: #e7f6ee;
  --red: #c33636;
  --red-bg: #fcebea;
  --amber-bg: #fff5e0;
  --amber: #9a6b00;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 30, 54, 0.08), 0 4px 16px rgba(16, 30, 54, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

h1 { font-size: 1.6rem; margin: 0 0 .4rem; }
h2 { font-size: 1.1rem; margin: 0; }
a { color: var(--xbe-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.tiny { font-size: .78rem; }

/* ---------- top bar ---------- */
.topbar {
  background: var(--xbe-navy);
  color: #fff;
}
.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: .65rem; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 30px; width: auto; display: block; }
.brand-text {
  font-weight: 600;
  padding-left: .65rem;
  border-left: 1px solid rgba(255, 255, 255, .25);
}
.topnav { display: flex; align-items: center; gap: 1rem; }
.topnav a { color: #cdd9ea; }
.topnav a:hover { color: #fff; }
.user-chip {
  background: rgba(255, 255, 255, .12);
  padding: .25rem .6rem;
  border-radius: 999px;
  font-size: .85rem;
}

/* ---------- layout ---------- */
.content {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  width: 100%;
  flex: 1;
}
.footer {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  color: var(--muted);
  font-size: .82rem;
  display: flex;
  gap: .5rem;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
.page-head { margin-bottom: 1.5rem; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: var(--xbe-blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .6rem 1.1rem;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--xbe-blue-dark); text-decoration: none; }
.btn-secondary { background: #eef2f7; color: var(--ink); }
.btn-secondary:hover { background: #e2e8f0; }
.btn-disabled, .btn:disabled {
  background: #e4e8ee; color: var(--muted); cursor: not-allowed;
}
.btn-link { color: #cdd9ea; }

/* small inline buttons used in the admin matrix row actions */
.admin-actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.inline-form { display: inline; margin: 0; }
.btn-sm {
  display: inline-flex;
  align-items: center;
  background: #eef2f7;
  color: var(--ink);
  border: none;
  border-radius: 6px;
  padding: .3rem .6rem;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-sm:hover { background: #e2e8f0; }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover { background: #f3c9c7; }
.row-actions { white-space: nowrap; }
.row-actions .inline-form { display: inline-block; margin: 0 .25rem 0 0; }

/* admin email-failures diagnostics panel */
.email-failures { margin-top: 1.25rem; }
.email-failures summary { color: var(--red); font-weight: 600; cursor: pointer; }
.failures { width: 100%; border-collapse: collapse; margin-top: .5rem; }
.failures th, .failures td {
  text-align: left;
  padding: .35rem .5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.failures td { word-break: break-word; }
.nowrap { white-space: nowrap; }

/* ---------- login ---------- */
.login-wrap { display: flex; justify-content: center; padding-top: 2rem; }
.login-card { max-width: 420px; text-align: center; }
.login-logo { height: 64px; width: auto; display: block; margin: 0 auto; }
.login-card h1 { margin-top: 1rem; }
.btn-google {
  width: 100%;
  justify-content: center;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  margin-top: 1.25rem;
}
.btn-google:hover { background: #f7f9fc; }
.g-logo {
  font-weight: 800;
  color: var(--xbe-blue);
  font-family: Georgia, serif;
}
.dev-login { width: 100%; justify-content: center; margin-top: .75rem; }

/* ---------- alerts ---------- */
.alert { border-radius: 8px; padding: .75rem 1rem; margin: 1rem 0; font-size: .92rem; }
.alert-error { background: var(--red-bg); color: var(--red); border: 1px solid #f3c9c7; }
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid #bfe6cf; }

/* ---------- progress summary ---------- */
.progress-summary { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.progress-bar {
  flex: 1; height: 10px; background: #e4e8ee; border-radius: 999px; overflow: hidden;
}
.progress-fill { height: 100%; background: var(--green); transition: width .3s ease; }
.progress-label { font-size: .85rem; color: var(--muted); white-space: nowrap; }

/* ---------- module list ---------- */
.module-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; }
.module-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
}
.module-card.module-locked { opacity: .65; }
.module-index {
  width: 36px; height: 36px; flex: none;
  border-radius: 8px;
  background: var(--xbe-navy);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.module-complete .module-index { background: var(--green); }
.module-locked .module-index { background: #aab4c0; }
.module-body { flex: 1; }
.module-meta { margin-top: .35rem; display: flex; align-items: center; gap: .6rem; }
.badge {
  font-size: .76rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px;
}
.badge-complete { background: var(--green-bg); color: var(--green); }
.badge-progress { background: #e7eefc; color: var(--xbe-blue); }
.badge-available { background: #eef2f7; color: var(--muted); }
.badge-locked { background: #eef2f7; color: var(--muted); }
.badge-invited { background: var(--amber-bg); color: var(--amber); margin-left: .4rem; }

/* ---------- admin: add-staff roster ---------- */
.add-staff { margin: 1rem 0 1.5rem; }
.add-staff summary { cursor: pointer; color: var(--xbe-blue); font-weight: 600; }
.add-staff-form { display: flex; gap: .6rem; align-items: flex-start; margin-top: .6rem; }
.add-staff-form textarea {
  flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: .6rem .75rem;
  font: inherit; resize: vertical;
}

/* ---------- module view ---------- */
.back-link { display: inline-block; margin-bottom: .75rem; font-size: .9rem; }
.video-wrap {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  margin: 1rem 0 1.5rem;
}
.video-wrap iframe {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
}
.quiz-card { max-width: 680px; }
.quiz-progress { font-size: .82rem; color: var(--muted); margin-bottom: .75rem; }
.quiz-form fieldset { border: none; padding: 0; margin: 0; }
.quiz-question { font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; padding: 0; }
.quiz-option {
  display: flex; align-items: center; gap: .7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .7rem .9rem;
  margin-bottom: .6rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.quiz-option:hover { border-color: var(--xbe-blue); background: #f7faff; }
.quiz-option input { accent-color: var(--xbe-blue); width: 18px; height: 18px; }
.quiz-submit { margin-top: .5rem; }
.quiz-actions { margin-top: .5rem; }

/* ---------- admin ---------- */
.admin-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.matrix { border-collapse: collapse; width: 100%; background: var(--card); }
.matrix th, .matrix td {
  border-bottom: 1px solid var(--line);
  padding: .6rem .75rem;
  text-align: center;
  font-size: .85rem;
}
.matrix thead th { background: #f0f3f8; color: var(--muted); font-weight: 600; }
.sticky-col { text-align: left !important; position: sticky; left: 0; background: var(--card); }
.matrix thead .sticky-col { background: #f0f3f8; }
.emp-name { font-weight: 600; }
.cell-mark { font-size: 1.1rem; display: block; }
.cell-complete .cell-mark { color: var(--green); }
.cell-in_progress .cell-mark { color: var(--xbe-blue); }
.cell-complete { background: var(--green-bg); }
.cell-in_progress { background: #eef4ff; }
.cell-sub { color: var(--muted); display: block; }
.legend { display: flex; gap: 1.25rem; flex-wrap: wrap; margin: 1rem 0; font-size: .85rem; color: var(--muted); align-items: center; }
.legend .cell-mark { display: inline; }
.module-key { margin-top: 1.5rem; }
.module-key summary { cursor: pointer; color: var(--xbe-blue); }
