/* ==========================================================================
   CAMS — dashboard styles
   No external fonts, no CDN, no build step. One file, cached with a version
   stamp so a phone never shows last week's colours (rule 11).
   ========================================================================== */

/* Rule 12: [hidden] needs teeth. Any component below that sets display:flex
   would otherwise sit on the page forever. */
[hidden] { display: none !important; }

:root {
  --brand: #0F766E;
  --brand-dark: #0B5A54;
  --brand-soft: #E6F4F2;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f6f8fa;
  --card: #ffffff;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --fail: #b91c1c;
  --fail-soft: #fee2e2;
  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --radius: 10px;
  --pad: 1.25rem;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }

code, .mono { font-family: var(--mono); font-size: .875em; }
code {
  background: #f1f5f9;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .1em .35em;
}

/* ---------- shell ------------------------------------------------------- */
.shell { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  display: flex; align-items: center; gap: 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: .75rem clamp(.75rem, 3vw, 1.5rem);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 650; font-size: 1.0625rem; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 auto;
  background: var(--brand); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: .875rem; letter-spacing: .02em;
}
.brand small { display: block; font-weight: 400; font-size: .75rem; color: var(--muted); line-height: 1.2; }

.topbar-spacer { flex: 1 1 auto; }

.who { display: flex; align-items: center; gap: .75rem; font-size: .875rem; color: var(--ink-2); }

.layout { display: flex; align-items: stretch; flex: 1 1 auto; }

.sidebar {
  flex: 0 0 232px;
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 1rem .75rem 2rem;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.nav-head {
  font-size: .6875rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); padding: 1rem .6rem .35rem; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: .55rem;
  padding: .5rem .6rem; border-radius: 8px;
  color: var(--ink-2); font-size: .9375rem;
}
.nav-item:hover { background: #f1f5f9; text-decoration: none; }
.nav-item.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.nav-item.disabled { color: #94a3b8; cursor: not-allowed; }
.nav-item.disabled:hover { background: transparent; }
.nav-item .soon {
  margin-left: auto; font-size: .625rem; text-transform: uppercase; letter-spacing: .06em;
  background: #f1f5f9; color: var(--muted); border-radius: 99px; padding: .1rem .4rem;
}

.main { flex: 1 1 auto; min-width: 0; padding: clamp(1rem, 2.5vw, 2rem); }
.main-inner { max-width: 1080px; margin: 0 auto; }

.page-head { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin: 0; font-size: .9375rem; }
.page-head .spacer { flex: 1 1 auto; }

/* ---------- cards ------------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--pad);
}
.card + .card { margin-top: 1rem; }
.card-head { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }
.card-head .spacer { flex: 1 1 auto; }
.card p:last-child { margin-bottom: 0; }

.grid { display: grid; gap: 1rem; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stat .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 1.75rem; font-weight: 650; letter-spacing: -.02em; margin-top: .15rem; }
.stat .hint { font-size: .8125rem; color: var(--muted); }

/* ---------- badges ------------------------------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .75rem; font-weight: 600;
  border-radius: 99px; padding: .15rem .55rem;
  border: 1px solid transparent; white-space: nowrap;
}
.badge.pass, .badge.ok   { background: var(--ok-soft);   color: var(--ok);   border-color: #bbf7d0; }
.badge.warn              { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.badge.fail              { background: var(--fail-soft); color: var(--fail); border-color: #fecaca; }
.badge.info              { background: var(--info-soft); color: var(--info); border-color: #bfdbfe; }
.badge.neutral           { background: #f1f5f9; color: var(--ink-2); border-color: var(--line); }

/* ---------- buttons ----------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 40px; padding: .5rem 1rem;
  border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; font-size: .9375rem;
  cursor: pointer;
}
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid rgba(15, 118, 110, .35); outline-offset: 2px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { background: var(--fail); border-color: var(--fail); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: #f1f5f9; }
.btn-lg { min-height: 48px; padding: .75rem 1.25rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .55; cursor: not-allowed; }

/* ---------- forms ------------------------------------------------------- */
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; font-size: .875rem; margin-bottom: .3rem; }
.field .hint { font-size: .8125rem; color: var(--muted); margin-top: .3rem; }

input[type="text"], input[type="password"], input[type="email"],
input[type="number"], input[type="date"], select, textarea {
  width: 100%; min-height: 44px;
  padding: .5rem .7rem;
  border: 1px solid #cbd5e1; border-radius: 8px;
  background: #fff; color: var(--ink);
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .16);
}

/* ---------- messages ---------------------------------------------------- */
.flash {
  display: flex; gap: .6rem; align-items: flex-start;
  border-radius: 8px; padding: .75rem 1rem; margin-bottom: 1rem;
  border: 1px solid; font-size: .9375rem;
}
.flash.ok    { background: var(--ok-soft);   border-color: #bbf7d0; color: #14532d; }
.flash.warn  { background: var(--warn-soft); border-color: #fde68a; color: #78350f; }
.flash.error { background: var(--fail-soft); border-color: #fecaca; color: #7f1d1d; }

/* ---------- tables ------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9375rem; }
table.data th, table.data td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- doctor ------------------------------------------------------ */
.doctor-row { border-top: 1px solid var(--line); padding: .85rem 0; display: grid; grid-template-columns: 92px 1fr; gap: .9rem; }
.doctor-row:first-of-type { border-top: 0; }
.doctor-row .detail { color: var(--ink-2); font-size: .9375rem; }
.doctor-row .fix { margin-top: .35rem; font-size: .875rem; color: var(--warn); }
.doctor-row.fail .fix { color: var(--fail); }
.verdict { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.verdict .big { font-size: 1.125rem; font-weight: 650; }

.steps { list-style: none; margin: .5rem 0 0; padding: 0; }
.steps li { display: flex; gap: .6rem; padding: .35rem 0; align-items: baseline; }
/* A numbered walk-through (the tablet instructions), as opposed to a list of
   problems, which is what .steps is usually for. */
.steps.ordered { counter-reset: step; }
.steps.ordered li { counter-increment: step; }
.steps.ordered li::before {
  content: counter(step);
  flex: 0 0 1.55rem; height: 1.55rem; border-radius: 999px;
  background: var(--brand-tint, #E6F4F1); color: var(--brand-dark, #0B5A54);
  font-size: .78rem; font-weight: 700; display: grid; place-items: center;
}

/* ---------- auth shell -------------------------------------------------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: var(--bg); }
.auth-card { width: 100%; max-width: 26rem; }
.auth-card .card { padding: 1.75rem; }
.auth-brand { display: flex; align-items: center; gap: .7rem; justify-content: center; margin-bottom: 1.25rem; }
.auth-brand .brand-mark { width: 42px; height: 42px; font-size: 1rem; border-radius: 11px; }
.auth-foot { text-align: center; color: var(--muted); font-size: .8125rem; margin-top: 1rem; }

/* ---------- verify page -------------------------------------------------- */
.plain-list { list-style: none; margin: .4rem 0 0; padding: 0; }
.plain-list li {
  padding: .2rem 0; border-bottom: 1px dashed var(--line); word-break: break-all;
}
.plain-list li:last-child { border-bottom: 0; }

/* ---------- misc -------------------------------------------------------- */
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.tiny { font-size: .8125rem; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.divider { height: 1px; background: var(--line); margin: 1rem 0; border: 0; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; font-size: .9375rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty h2 { color: var(--ink); }


/* ---------- session banner ---------------------------------------------- */
.session-banner {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  background: var(--brand-soft);
  border: 1px solid #cfe8e4;
  border-radius: var(--radius);
  padding: .55rem .9rem;
  margin-bottom: 1.25rem;
  font-size: .9375rem;
}
.session-banner .sb-main { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.session-banner .sb-label {
  font-size: .6875rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--brand-dark); font-weight: 700;
}
.session-banner .sb-link { margin-left: auto; font-weight: 600; }

/* ---------- readiness list ---------------------------------------------- */
.check-list { list-style: none; margin: 0; padding: 0; }
.check-list li {
  display: grid; grid-template-columns: 74px 1fr; gap: .75rem;
  padding: .55rem 0; border-top: 1px solid var(--line); align-items: start;
}
.check-list li:first-child { border-top: 0; }
.check-list .what { font-weight: 600; }
.check-list .how { color: var(--muted); font-size: .875rem; }

/* ---------- inline forms in tables -------------------------------------- */
.table-actions { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.table-actions form { margin: 0; }
.btn-sm { min-height: 32px; padding: .2rem .6rem; font-size: .8125rem; border-radius: 6px; }

/* ---------- checklist preview ------------------------------------------- */
.checklist { width: 100%; border-collapse: collapse; font-size: .875rem; margin-top: .5rem; }
.checklist th, .checklist td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--line); }
.checklist th { font-size: .6875rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.checklist td.num { text-align: right; font-variant-numeric: tabular-nums; width: 7rem; }

/* ---------- import preview ---------------------------------------------- */
.preview-table { font-size: .875rem; }
.preview-table tr.problem td { background: var(--fail-soft); }
.preview-table tr.problem td.reason { color: var(--fail); font-weight: 500; }
.stats-strip { display: flex; gap: 1.5rem; flex-wrap: wrap; margin: 0 0 1rem; }
.stats-strip div { font-size: .9375rem; }
.stats-strip strong { display: block; font-size: 1.25rem; }

/* ---------- PIN panel --------------------------------------------------- */
.pin-panel {
  border: 2px solid var(--brand);
  background: var(--brand-soft);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}
.pin-value {
  font-family: var(--mono);
  font-size: 2rem; font-weight: 700; letter-spacing: .3em;
  color: var(--brand-dark);
  margin: .35rem 0;
}

/* ---------- report -------------------------------------------- */
.report-head { border-bottom: 2px solid var(--brand); padding-bottom: .75rem; margin-bottom: 1rem; }
.report-head h1 { margin-bottom: .15rem; }
.grade { font-weight: 700; }
.grade.distinction { color: var(--ok); }
.grade.credit { color: var(--info); }
.grade.pass { color: var(--ink-2); }
.grade.fail { color: var(--fail); }
nowrap { white-space: nowrap; }

@media (max-width: 780px) {
  .layout { flex-direction: column; }
  .sidebar { flex: 1 1 auto; border-right: 0; border-bottom: 1px solid var(--line); padding-bottom: .75rem; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .nav-head { width: 100%; padding-top: .5rem; }
  .nav-item { padding: .45rem .55rem; }
  .nav-item .soon { display: none; }
  .who .name { display: none; }
  .doctor-row { grid-template-columns: 1fr; gap: .3rem; }
}

@media print {
  /* Banners and buttons are noise on paper, with one exception: a warning that
     explains why an action is refused is the reason somebody printed the page.
     Anything marked .keep stays. */
  .topbar, .sidebar, .flash:not(.keep), .btn:not(.keep) { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #cbd5e1; }
}

/* ---------------------------------------------------------------------------
   Candidate photographs (added after the first live install)
   A photograph is compared against a face at arm's length, so it is shown at a
   size a person can actually use, on a plain ground, with no border games.
   --------------------------------------------------------------------------- */
.photo-panel { display: flex; align-items: flex-start; gap: 1.25rem; flex-wrap: wrap; }
.photo-panel .passport {
  display: block;
  width: 150px; height: 187px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line, #e2e8f0);
  background: #f8fafc;
}
.photo-panel .no-photo {
  display: flex; align-items: center; justify-content: center;
  width: 150px; height: 187px;
  border-radius: 6px;
  border: 1px dashed var(--line, #cbd5e1);
  background: #f8fafc;
  color: #64748b;
  font-size: .8rem;
  text-align: center;
  padding: .5rem;
}
.photo-col { width: 56px; }
.photo-thumb { display: inline-block; line-height: 0; border-radius: 4px; overflow: hidden; }
.photo-thumb img { display: block; width: 40px; height: 50px; object-fit: cover; border-radius: 4px; }
.photo-thumb.none {
  width: 40px; height: 50px; line-height: 50px; text-align: center;
  border: 1px dashed var(--line, #cbd5e1); border-radius: 4px;
  color: #94a3b8; text-decoration: none; font-size: .8rem;
}
/* On paper a photograph is evidence; keep it in the printed attendance list. */
@media print {
  .photo-thumb img, .photo-panel .passport { display: block !important; }
}
