/* NewGen Journeyman - one stylesheet for login, admin and the student app.
   Brand: navy #0B2536, rust #C43E29, grey #414042.  No inline styles anywhere. */

:root {
  --navy: #0B2536;
  --navy-soft: #123448;
  --navy-faint: #1B4257;
  --rust: #C43E29;
  --rust-dark: #A53521;
  --grey: #414042;
  --ink: #22303B;
  --muted: #6B7A87;
  --line: #E3E9ED;
  --bg: #F4F6F8;
  --card: #FFFFFF;
  --ok: #1E8A4C;
  --ok-soft: #E2F3E9;
  --warn: #B7791F;
  --warn-soft: #FBF0DC;
  --bad: #C43E29;
  --bad-soft: #FBE7E2;
  --field: #FFFFFF;
  --hover: #F6F8FA;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(11, 37, 54, 0.06), 0 4px 16px rgba(11, 37, 54, 0.07);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}
h1, h2, h3, h4 { color: var(--navy); line-height: 1.2; margin: 0 0 0.5rem; }
a { color: var(--rust-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.05s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--rust); color: #fff; }
.btn-primary:hover { background: var(--rust-dark); }
.btn-primary:disabled { background: #D9A79E; cursor: not-allowed; }
.btn-ghost { background: var(--field); color: var(--navy); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--navy); }
.btn-mini { padding: 0.2rem 0.6rem; font-size: 0.82rem; background: var(--field); color: var(--navy); border-color: var(--line); }
.btn-block { display: block; width: 100%; text-align: center; }
.btn-big { padding: 0.95rem 1.1rem; font-size: 1.08rem; border-radius: 14px; }

/* ------------------------------------------------------------- fields */
.field { display: block; margin-bottom: 0.9rem; }
.field-label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--muted); margin-bottom: 0.25rem; }
input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--navy-faint);
  outline-offset: 0;
  border-color: var(--navy-faint);
}
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--rust); }
input[type="file"] { padding: 0.4rem; }
.input-big, .select-big { padding: 0.85rem 0.9rem; font-size: 1.05rem; border-radius: 12px; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.field-hint { font-size: 0.85rem; color: var(--muted); margin: 0.3rem 0 0.9rem; }
.field-center { text-align: center; }
.check-inline { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.92rem; color: var(--ink); }

/* ------------------------------------------------------------ flashes */
.flash {
  border-radius: 10px;
  padding: 0.7rem 1rem;
  margin-bottom: 1rem;
  font-weight: 500;
  border: 1px solid transparent;
}
.flash-ok { background: var(--ok-soft); color: var(--ok); border-color: #BFE3CD; }
.flash-warn { background: var(--warn-soft); color: var(--warn); border-color: #EBD5AC; }
.flash-error { background: var(--bad-soft); color: var(--bad); border-color: #F0C4BA; }

/* ------------------------------------------------------------- badges */
.badge {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-valid, .badge-confirmed { background: var(--ok-soft); color: var(--ok); }
.badge-out_of_radius, .badge-pending { background: var(--warn-soft); color: var(--warn); }
.badge-no_gps, .badge-rejected { background: var(--bad-soft); color: var(--bad); }
.badge-unverified { background: #E8ECF0; color: var(--muted); }
.badge-phase-training { background: #E3EDF5; color: var(--navy); }
.badge-phase-apprenticeship { background: var(--warn-soft); color: var(--warn); }
.badge-phase-incubator { background: var(--ok-soft); color: var(--ok); }
.badge-phase-exited { background: #E8ECF0; color: var(--muted); }

/* -------------------------------------------------------------- login */
.login-page { background: var(--navy); min-height: 100vh; }
.login-wrap {
  max-width: 380px;
  margin: 0 auto;
  padding: 8vh 1.2rem 2rem;
  text-align: center;
}
.login-logo { width: 150px; margin-bottom: 1rem; }
.login-title { color: #fff; font-size: 2rem; letter-spacing: 0.04em; margin-bottom: 0.2rem; }
.login-tag { color: #9FB4C2; margin: 0 0 1.6rem; font-size: 0.95rem; }
.login-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem;
  text-align: left;
}

/* -------------------------------------------------------- admin shell */
.admin-body { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width 0.22s ease;
}
.nav-collapse {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: -13px;
  z-index: 50;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--navy);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  padding: 0;
}
.nav-collapse svg { width: 14px; height: 14px; transition: transform 0.22s ease; }
.sidebar { position: sticky; }
.sidebar-brand { display: block; padding: 1.2rem 1rem 0.9rem; text-align: center; }
.sidebar-brand img.brand-full { width: 100%; display: block; }
.sidebar-brand img.brand-mini { display: none; width: 34px; margin: 0 auto; }
.sidebar-app {
  display: block;
  text-align: center;
  color: #9FB4C2;
  font-size: 0.78rem;
  letter-spacing: 0.34em;
  text-indent: 0.34em; /* balances the tracking so the text sits truly centred */
  text-transform: uppercase;
  margin-top: 0.5rem;
}
.sidebar-nav { display: flex; flex-direction: column; padding: 0.6rem 0.6rem; gap: 2px; flex: 1; overflow-y: auto; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: #C9D6DF;
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  font-weight: 500;
  white-space: nowrap;
}
.sidebar-nav a svg { width: 19px; height: 19px; flex-shrink: 0; }
.sidebar-nav a:hover { background: var(--navy-soft); color: #fff; text-decoration: none; }
.sidebar-nav a.is-active { background: var(--rust); color: #fff; }
.sidebar-foot {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--navy-soft);
}
.foot-clock { display: flex; flex-direction: column; align-items: center; text-align: center; }
.clock-time {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;  /* stops the width jitter each minute */
}
.clock-date { color: #C9D6DF; font-size: 0.82rem; margin-top: 0.1rem; }
.clock-zone {
  color: #7E93A3;
  font-size: 0.66rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin-top: 0.15rem;
}
html.nav-compact .clock-date, html.nav-compact .clock-zone { display: none; }
html.nav-compact .clock-time { font-size: 0.95rem; }
html.nav-compact .sidebar-foot { padding: 0.8rem 0.3rem; }
.foot-user {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: #C9D6DF;
  font-size: 0.88rem;
  font-weight: 600;
  min-width: 0;
}
.foot-user:hover { color: #fff; text-decoration: none; }
.foot-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.foot-avatar-blank { background: var(--rust); color: #fff; font-size: 0.9rem; font-weight: 700; }
.foot-name { overflow: hidden; text-overflow: ellipsis; }
.foot-actions { display: flex; gap: 0.25rem; }
.foot-btn {
  background: none;
  border: 0;
  color: #9FB4C2;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 8px;
  display: inline-flex;
}
.foot-btn:hover { background: var(--navy-soft); color: #fff; text-decoration: none; }
.foot-btn svg { width: 18px; height: 18px; }
.icon-sun { display: none; }
html.dark .icon-sun { display: block; }
html.dark .icon-moon { display: none; }

/* Compact sidebar: icons only */
html.nav-compact .sidebar { width: 68px; }
html.nav-compact .nav-collapse svg { transform: rotate(180deg); }
html.nav-compact .brand-full,
html.nav-compact .sidebar-app,
html.nav-compact .sidebar-nav a span { display: none; }
html.nav-compact .brand-mini { display: block; }
html.nav-compact .sidebar-nav a { justify-content: center; padding: 0.6rem 0; }
html.nav-compact .sidebar-nav { overflow-x: hidden; }


.admin-main { flex: 1; padding: 1.6rem 2rem 3rem; min-width: 0; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 1.5rem; }
.page-sub { color: var(--muted); }
.page-actions { display: flex; gap: 0.6rem; align-items: center; }

.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1.2rem;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.panel-head h2 { margin: 0; font-size: 1.05rem; }
.panel-actions { display: flex; gap: 0.6rem; align-items: center; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; align-items: start; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }

/* --------------------------------------------------------- stat cards */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.2rem;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem 1rem;
  display: block;
  color: inherit;
}
.stat-card:hover { text-decoration: none; }
.stat-value { display: block; font-size: 1.7rem; font-weight: 700; color: var(--navy); }
.stat-of { font-size: 1rem; color: var(--muted); font-weight: 500; margin-left: 0.35rem; }
.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat-warn .stat-value { color: var(--rust); }

/* -------------------------------------------------------------- table */
.panel { overflow-x: auto; }   /* wide tables scroll rather than crush */
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; min-width: 520px; }
.table th {
  text-align: left;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--line);
}
.table td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.row-muted { opacity: 0.5; }
.empty { color: var(--muted); padding: 0.6rem; }
.cell-avatar { width: 44px; }
.cell-actions form { display: flex; gap: 0.4rem; }
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.avatar-blank { background: var(--navy); color: #fff; font-size: 0.8rem; font-weight: 600; }
.xp-pos { color: var(--ok); font-weight: 600; }
.xp-neg { color: var(--bad); font-weight: 600; }

/* ------------------------------------------------------------ filters */
.filter-bar {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar input, .filter-bar select { width: auto; min-width: 140px; }
.filter-inline { margin-bottom: 0; }

/* ---------------------------------------------------------------- map */
.dash-map { height: 420px; border-radius: 10px; }
.pick-map { height: 260px; border-radius: 10px; margin-bottom: 0.8rem; }
.pick-map-tall { height: 360px; }
.map-legend { display: flex; gap: 1rem; margin-top: 0.6rem; flex-wrap: wrap; font-size: 0.84rem; color: var(--muted); }
.legend-item::before {
  content: "";
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 0.35rem;
}
.legend-valid::before { background: var(--ok); }
.legend-out::before { background: var(--warn); }
.legend-nogps::before { background: var(--bad); }
.legend-unverified::before { background: var(--muted); }

/* -------------------------------------------------------------- forms */
.form-grid { display: block; }
.form-section { border: 0; border-top: 1px solid var(--line); margin: 0 0 0.6rem; padding: 1rem 0 0.4rem; }
.form-section:first-child { border-top: 0; padding-top: 0; }
.form-section legend {
  font-weight: 700;
  color: var(--navy);
  padding-right: 0.6rem;
  font-size: 1rem;
}
.form-actions { display: flex; gap: 0.7rem; padding-top: 0.4rem; }
.rule-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.55rem; }
.rule-points { width: 90px; text-align: right; }

/* ------------------------------------------------------ student lists */
.pill-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.45rem; }
.pill {
  display: inline-block;
  background: var(--hover);
  color: var(--navy);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.86rem;
  font-weight: 500;
}
.pill:hover { background: var(--line); text-decoration: none; }
.pill-warn { background: var(--warn-soft); color: var(--warn); }

/* ------------------------------------------------------------ profile */
.profile-grid { display: grid; grid-template-columns: 340px 1fr; gap: 1.2rem; align-items: start; }
@media (max-width: 1000px) { .profile-grid { grid-template-columns: 1fr; } }
.profile-photo {
  width: 110px; height: 110px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--hover);   /* so a photo with transparency still reads as a disc */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.8rem;
}
.profile-photo-blank { background: var(--navy); color: #fff; font-size: 2rem; font-weight: 700; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 1rem; margin: 0; }
.kv dt { color: var(--muted); font-size: 0.85rem; }
.kv dd { margin: 0; font-weight: 500; }
.kv-row { grid-template-columns: auto 1fr auto 1fr; }
@media (max-width: 800px) { .kv-row { grid-template-columns: auto 1fr; } }
.readiness { margin-bottom: 1rem; }
.readiness-value { font-size: 2rem; font-weight: 700; color: var(--navy); margin-right: 0.4rem; }
.readiness-label { color: var(--muted); font-size: 0.88rem; }
.readiness-verdict { color: var(--muted); font-size: 0.9rem; margin: 0.5rem 0 0; }
.meter { height: 10px; background: #E8ECF0; border-radius: 999px; overflow: hidden; margin-top: 0.6rem; }
.meter-fill { height: 100%; border-radius: 999px; width: 0; transition: width 0.6s ease; }
.meter-ok { background: var(--ok); }
.meter-part { background: var(--rust); }
.award-form h3, .absence-form h3 { font-size: 0.95rem; margin-bottom: 0.6rem; }
.absence-form { margin-bottom: 1rem; }

/* ------------------------------------------------------- catalogue ui */
.catalogue-block { border-top: 1px solid var(--line); padding-top: 0.9rem; margin-top: 0.9rem; }
.catalogue-block:first-of-type { border-top: 0; margin-top: 0; }
.catalogue-block h3 { font-size: 0.95rem; }
.catalogue-list { list-style: none; padding: 0; margin: 0 0 0.6rem; }
.catalogue-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0;
  border-bottom: 1px dashed var(--line);
  font-size: 0.92rem;
}
.catalogue-add { display: flex; gap: 0.6rem; }
.catalogue-add input { flex: 1; }

/* -------------------------------------------------------- task detail */
.task-list { list-style: none; padding: 0; margin: 0; }
.task-list li { padding: 0.3rem 0 0.3rem 1.4rem; position: relative; }
.task-list li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.62rem;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ok);
}
.task-list li.task-other::before { background: var(--warn); }
.task-note { color: var(--muted); font-size: 0.85rem; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.7rem; }
.photo-grid img { width: 100%; height: 140px; object-fit: cover; border-radius: 8px; }

/* ------------------------------------------------------- parent sheet */
.report-sheet { max-width: 820px; }
.report-head { display: flex; align-items: center; gap: 1.4rem; border-bottom: 3px solid var(--rust); padding-bottom: 1rem; margin-bottom: 1.2rem; }
.report-logo { width: 220px; }
.report-title h2 { margin-bottom: 0.15rem; }
.report-title p { margin: 0; color: var(--muted); }
.report-block { margin-bottom: 1.4rem; }
.report-block h3 { border-left: 4px solid var(--rust); padding-left: 0.6rem; }
.report-day { margin-bottom: 0.9rem; }
.report-day h4 { margin-bottom: 0.2rem; }
.report-cat { margin: 0.15rem 0; font-size: 0.93rem; }
.report-foot { border-top: 1px solid var(--line); padding-top: 0.8rem; color: var(--muted); font-size: 0.85rem; text-align: center; }

@media print {
  .sidebar, .print-hide, .flash { display: none !important; }
  .admin-main { padding: 0; }
  body { background: #fff; }
  .panel { box-shadow: none; margin: 0; }
}

/* ---------------------------------------------------- student app ui */
.app-body {
  background: var(--bg);
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(66px + env(safe-area-inset-bottom));
}
.app-top {
  background: var(--navy);
  padding: 0.7rem 1rem calc(0.7rem);
  padding-top: calc(0.7rem + env(safe-area-inset-top));
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 900;
}
.app-top-logo { height: 30px; }
.app-main { flex: 1; padding: 1.1rem 1rem 1.6rem; }
.app-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 520px;
  margin: 0 auto;
  background: #fff;
  border-top: 1px solid var(--line);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 1000;
}
.app-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 0.5rem 0 0.45rem;
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 600;
}
.app-nav a:hover { text-decoration: none; }
.app-nav a.is-active { color: var(--rust); }
.app-nav-icon { line-height: 0; }
.app-nav-icon svg { width: 22px; height: 22px; }

.page-head-app { margin-bottom: 1rem; }
.page-head-app h1 { font-size: 1.4rem; margin-bottom: 0.15rem; }

.hero {
  background: var(--navy);
  background: linear-gradient(150deg, var(--navy) 0%, var(--navy-faint) 100%);
  border-radius: 16px;
  color: #fff;
  padding: 1.2rem 1.2rem 1.1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.hero-greet { margin: 0; color: #9FB4C2; font-size: 0.9rem; }
.hero-day { color: #fff; font-size: 1.35rem; margin: 0.1rem 0 0.7rem; }
.hero-xp { display: flex; align-items: baseline; gap: 0.4rem; }
.hero-xp-value { font-size: 1.9rem; font-weight: 800; color: #fff; }
.hero-xp-label { color: #9FB4C2; font-weight: 600; letter-spacing: 0.1em; }
.hero-streak {
  margin-left: auto;
  background: var(--rust);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 700;
}

.action-card {
  display: block;
  border-radius: 16px;
  padding: 1.05rem 1.2rem;
  margin-bottom: 0.8rem;
  box-shadow: var(--shadow);
}
.action-card:hover { text-decoration: none; }
.action-title { display: block; font-weight: 700; font-size: 1.05rem; }
.action-sub { display: block; font-size: 0.86rem; margin-top: 0.15rem; }
.action-primary { background: var(--rust); color: #fff; }
.action-primary .action-sub { color: #F5D9D2; }
.action-secondary { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.action-secondary .action-sub { color: var(--muted); }
.action-done { background: var(--ok-soft); color: var(--ok); border: 1px solid #BFE3CD; }
.action-done .action-sub { color: #4E8A66; }
/* A flagged check-in must not look like a successful one. */
.action-flagged { background: var(--warn-soft); color: var(--warn); border: 1px solid #EBD5AC; }
.action-flagged .action-sub { color: #99691B; }
.action-neutral { background: var(--hover); color: var(--navy); border: 1px solid var(--line); }
.action-neutral .action-sub { color: var(--muted); }
html.dark .action-flagged .action-sub { color: #D9A85E; }
html.dark .action-neutral { color: var(--ink); }

.card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.05rem 1.2rem;
  margin-bottom: 0.9rem;
}
.card-title { font-size: 1rem; margin-bottom: 0.6rem; }
.card-link { display: flex; justify-content: space-between; align-items: center; color: var(--navy); font-weight: 600; }
.card-link:hover { text-decoration: none; }
.chev { color: var(--muted); font-size: 1.3rem; }

.xp-list { list-style: none; margin: 0; padding: 0; }
.xp-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0;
  border-bottom: 1px dashed var(--line);
  font-size: 0.92rem;
}
.xp-list li:last-child { border-bottom: 0; }

/* -------------------------------------------------- student check-in */
.mode-tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;   /* every tab exactly the same width */
  align-items: stretch;     /* and the same height, however the text wraps */
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.mode-tab { display: flex; }
.mode-tab input { position: absolute; opacity: 0; }
.mode-tab span {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.6rem 0.35rem;
  min-height: 3.1rem;
  font-weight: 600;
  font-size: 0.86rem;
  line-height: 1.2;
  color: var(--muted);
  cursor: pointer;
  hyphens: auto;
}
.mode-tab input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; }
.mode-panel { margin-bottom: 0.6rem; }
.is-hidden { display: none; }

.gps-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem 1rem;
  margin: 0.6rem 0 1rem;
  font-size: 0.92rem;
  color: var(--muted);
}
.gps-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--warn); flex-shrink: 0; }
.gps-dot.gps-ok { background: var(--ok); }
.gps-dot.gps-bad { background: var(--bad); }

/* --------------------------------------------------- student report */
.chip-group { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0.3rem 0 0.4rem; }
.chip input { position: absolute; opacity: 0; }
.chip span {
  display: inline-block;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
}
.chip input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; }
.tick-group { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.7rem; }
.tick {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: #F8FAFB;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
  cursor: pointer;
}
.tick input { width: 18px; height: 18px; flex-shrink: 0; }
.tick:has(input:checked) { background: #FDF1EE; border-color: var(--rust); }

/* --------------------------------------------------- student history */
.history-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.8rem; }
.history-site { color: var(--muted); font-size: 0.85rem; }
.history-cat { font-size: 0.9rem; margin: 0.35rem 0; }

/* --------------------------------------------------- student journey */
.journey-steps { list-style: none; margin: 0; padding: 0; }
.journey-steps li {
  position: relative;
  padding: 0 0 1.1rem 1.9rem;
}
.journey-steps li::before {
  content: "";
  position: absolute;
  left: 0.42rem; top: 1.2rem; bottom: 0;
  width: 2px;
  background: var(--line);
}
.journey-steps li:last-child::before { display: none; }
.journey-steps li::after {
  content: "";
  position: absolute;
  left: 0; top: 0.28rem;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--line);
}
.journey-steps li.is-done::after { background: var(--ok); border-color: var(--ok); }
.journey-steps li.is-now::after { background: var(--rust); border-color: var(--rust); }
.journey-step-title { display: block; font-weight: 700; color: var(--navy); }
.journey-step-sub { display: block; font-size: 0.85rem; color: var(--muted); }
.photo-picker { display: inline-block; position: relative; cursor: pointer; }
.photo-picker input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-picker-badge {
  position: absolute;
  right: 2px;
  bottom: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--rust);
  color: #fff;
  border: 3px solid var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-picker-badge svg { width: 16px; height: 16px; }
.photo-hint { color: var(--muted); font-size: 0.82rem; margin: 0.1rem 0 0.6rem; }

.profile-center { text-align: center; }
.profile-center .hero-xp { justify-content: center; }
/* The hero XP styles assume the navy hero; on a white card the value
   must flip to navy or it disappears. */
.profile-center .hero-xp-value { color: var(--navy); }
.profile-center .hero-xp-label { color: var(--muted); }
.profile-name { margin-bottom: 0.1rem; }
.profile-meta { color: var(--muted); margin-top: 0; }

/* ------------------------------------------------- small screen admin */
@media (max-width: 840px) {
  .admin-body { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .admin-main { padding: 1rem; }
  .profile-grid { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------- presence and rows */
.presence {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.5rem;
  vertical-align: middle;
  flex-shrink: 0;
}
.presence-online { background: #2BB463; box-shadow: 0 0 7px 1px rgba(43, 180, 99, 0.75); }
.presence-away { background: #E0A93E; box-shadow: 0 0 7px 1px rgba(224, 169, 62, 0.7); }
.presence-offline { background: var(--bad); box-shadow: 0 0 6px 1px rgba(196, 62, 41, 0.55); }
.presence-never, .presence-none { background: #A6B2BC; }

.tip { position: relative; }
.tip:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  bottom: calc(100% + 7px);
  z-index: 200;
  background: var(--navy);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.3rem 0.6rem;
  border-radius: 7px;
  white-space: nowrap;
  box-shadow: var(--shadow);
  pointer-events: none;
}

.row-link { cursor: pointer; }
.row-link:hover td { background: var(--hover); }

/* --------------------------------------------------------- export bar */
.export-actions { display: flex; gap: 0.5rem; margin-left: auto; }

/* ---------------------------------------------------------- dark mode */
html.dark {
  --grey: #C4C9CE;
  --ink: #DCE3E9;
  --muted: #93A1AD;
  --line: #2B333B;
  --bg: #17191D;
  --card: #1F242A;
  --field: #262C33;
  --hover: #262D34;
  --ok-soft: rgba(30, 138, 76, 0.18);
  --warn-soft: rgba(183, 121, 31, 0.18);
  --bad-soft: rgba(196, 62, 41, 0.16);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 18px rgba(0, 0, 0, 0.35);
}
html.dark body { background: var(--bg); }
html.dark h1, html.dark h2, html.dark h3, html.dark h4 { color: #E8EDF2; }
html.dark a { color: #E07B5F; }
html.dark .sidebar { background: #10151B; }
html.dark .sidebar-nav a:hover { background: #1B222B; }
html.dark .sidebar-foot { border-top-color: #1B222B; }
html.dark .foot-btn:hover { background: #1B222B; }
html.dark .nav-collapse { background: var(--card); color: var(--ink); border-color: var(--line); }
html.dark .btn-ghost, html.dark .btn-mini { color: var(--ink); }
html.dark .btn-ghost:hover { border-color: var(--muted); }
html.dark .badge-valid, html.dark .badge-confirmed { color: #5BC98B; }
html.dark .badge-out_of_radius, html.dark .badge-pending { color: #E6B45C; }
html.dark .badge-no_gps, html.dark .badge-rejected { color: #E58973; }
html.dark .badge-unverified, html.dark .badge-phase-exited { background: #262D34; color: var(--muted); }
html.dark .badge-phase-training { background: rgba(60, 120, 170, 0.2); color: #7FB3DA; }
html.dark .badge-phase-apprenticeship { color: #E6B45C; }
html.dark .badge-phase-incubator { color: #5BC98B; }
html.dark .flash-ok { color: #5BC98B; border-color: rgba(43, 180, 99, 0.35); }
html.dark .flash-warn { color: #E6B45C; border-color: rgba(224, 169, 62, 0.35); }
html.dark .flash-error { color: #E58973; border-color: rgba(196, 62, 41, 0.4); }
html.dark .stat-value { color: #E8EDF2; }
html.dark .stat-warn .stat-value { color: #E07B5F; }
html.dark .avatar-blank, html.dark .profile-photo-blank { background: #2E3944; }
html.dark .meter { background: #262D34; }
html.dark .pill { color: var(--ink); }
html.dark .pill:hover { background: #2E353D; }
html.dark .pill-warn { background: var(--warn-soft); color: #E6B45C; }
html.dark .readiness-value { color: #E8EDF2; }
html.dark .tip:hover::after { background: #060A0E; }
html.dark input:focus, html.dark select:focus, html.dark textarea:focus {
  outline-color: #3E5A70;
  border-color: #3E5A70;
}
html.dark .dash-map, html.dark .pick-map { filter: brightness(0.9) saturate(0.85); }
html.dark ::placeholder { color: #6C7883; }

/* -------------------------------------------------------------- charts */
/* One palette, used by donut slices (fill) and bars (background), so a
   category keeps its colour wherever it appears. */
.ch-1 { --ch: #C43E29; }
.ch-2 { --ch: #0B2536; }
.ch-3 { --ch: #2E7DA6; }
.ch-4 { --ch: #E0A93E; }
.ch-5 { --ch: #2BB463; }
.ch-6 { --ch: #7A5AA8; }
.ch-7 { --ch: #5B7183; }
.ch-8 { --ch: #D2755A; }
.ch-fill { fill: var(--ch); stroke: var(--card); stroke-width: 1.5; }
.ch-bg { background: var(--ch); }

.chart-row {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  flex-wrap: wrap;
}
.donut { width: 190px; height: 190px; flex-shrink: 0; }
.donut-total {
  fill: var(--navy);
  font-size: 26px;
  font-weight: 700;
  text-anchor: middle;
  font-family: var(--font);
}
.donut-cap {
  fill: var(--muted);
  font-size: 11px;
  text-anchor: middle;
  font-family: var(--font);
  letter-spacing: 0.08em;
}
html.dark .donut-total { fill: #E8EDF2; }

.chart-legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 190px; }
.chart-legend li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.28rem 0;
  font-size: 0.9rem;
  border-bottom: 1px dashed var(--line);
}
.chart-legend li:last-child { border-bottom: 0; }
.key { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.key-label { flex: 1; }
.key-value { font-weight: 600; color: var(--navy); white-space: nowrap; }
.key-pct { color: var(--muted); font-weight: 500; font-size: 0.84rem; }
html.dark .key-value { color: #E8EDF2; }

.bar-list { list-style: none; margin: 0; padding: 0; }
.bar-list li {
  display: grid;
  grid-template-columns: minmax(90px, 34%) 1fr auto;
  align-items: center;
  gap: 0.7rem;
  padding: 0.3rem 0;
  font-size: 0.9rem;
}
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--hover); border-radius: 999px; height: 12px; overflow: hidden; }
.bar-fill { display: block; height: 100%; width: 0; border-radius: 999px; transition: width 0.6s ease; }
.bar-value { font-weight: 600; color: var(--navy); min-width: 2.4rem; text-align: right; }
html.dark .bar-value { color: #E8EDF2; }

.column-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  height: 200px;
  padding-top: 1.2rem;
  overflow-x: auto;
}
.column {
  flex: 1;
  min-width: 42px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 0.3rem;
}
.column-value { font-size: 0.78rem; font-weight: 700; color: var(--navy); }
html.dark .column-value { color: #E8EDF2; }
.column-bar {
  width: 100%;
  max-width: 46px;
  height: 0;
  background: var(--rust);
  border-radius: 6px 6px 0 0;
  transition: height 0.6s ease;
}
.column-label { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }

/* --------------------------------------------------- install prompt */
.install-banner {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  background: var(--navy-faint);
  color: #fff;
  padding: 0.7rem 1rem;
  font-size: 0.86rem;
}
.install-text { flex: 1; min-width: 160px; }
.install-actions { display: flex; gap: 0.4rem; }

/* ------------------------------------------------- topbar and account */
.topbar {
  position: sticky;
  top: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  min-height: 52px;
  margin: -1.6rem -2rem 1rem;
  padding: 0.5rem 2rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }
.user-trigger {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.28rem 0.75rem 0.28rem 0.28rem;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  color: var(--navy);
  transition: border-color 0.15s;
}
.user-trigger:hover { border-color: var(--navy-faint); }
.topbar-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--hover);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.topbar-avatar-blank { background: var(--rust); color: #fff; font-size: 0.86rem; font-weight: 700; }
.topbar-name { font-size: 0.9rem; }
.topbar-chev { width: 15px; height: 15px; color: var(--muted); transition: transform 0.2s; }
.user-trigger[aria-expanded="true"] .topbar-chev { transform: rotate(180deg); }
html.dark .topbar { background: var(--bg); }
html.dark .user-trigger { color: var(--ink); }

.drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(11, 37, 54, 0.4);
  z-index: 900;
}
.user-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  max-width: 88vw;
  background: var(--card);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 28px rgba(11, 37, 54, 0.16);
  z-index: 950;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.24s ease;
}
.user-drawer.is-open { transform: translateX(0); }
/* is-hidden only removes it from the tree once the slide has finished */
.user-drawer.is-hidden { visibility: hidden; }
.user-drawer.is-open.is-hidden { visibility: visible; }

.drawer-head {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 1.2rem 1.1rem 1rem;
  border-bottom: 1px solid var(--line);
}
.drawer-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--hover);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.drawer-avatar-blank { background: var(--rust); color: #fff; font-size: 1.3rem; font-weight: 700; }
.drawer-who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.drawer-name { font-weight: 700; color: var(--navy); }
html.dark .drawer-name { color: #E8EDF2; }
.drawer-role { font-size: 0.82rem; color: var(--muted); }
.drawer-email { font-size: 0.8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.drawer-close {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 7px;
  display: inline-flex;
}
.drawer-close:hover { background: var(--hover); color: var(--navy); }
.drawer-close svg { width: 18px; height: 18px; }

.drawer-links { display: flex; flex-direction: column; padding: 0.6rem 0.6rem; gap: 2px; flex: 1; }
.drawer-links a, .drawer-link-btn {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.75rem;
  border-radius: 9px;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.drawer-links a:hover, .drawer-link-btn:hover { background: var(--hover); text-decoration: none; }
.drawer-links svg { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.drawer-signout {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.9rem 1.35rem;
  border-top: 1px solid var(--line);
  color: var(--rust-dark);
  font-weight: 600;
}
.drawer-signout:hover { background: var(--hover); text-decoration: none; }
.drawer-signout svg { width: 18px; height: 18px; }

@media (max-width: 840px) {
  .topbar { margin: -1rem -1rem 1rem; padding: 0.5rem 1rem; }
  .topbar-name { display: none; }
}
