/* HVIQ Jointing Training Platform — core styles
   Brand: slate #2E4B54, teal #4FC1C1, dark teal #168587, amber #D98E2B (hold points/warnings)
   Mobile/tablet first, large touch targets for gloved hands. */

:root {
  /* FathomIQ-family palette: navy chrome, blue primary, teal brand accent */
  --navy: #16294b;
  --navy-700: #1e3a63;
  --slate: #16294b;        /* headings & chrome (navy) */
  --slate-900: #0c1830;    /* darkest navy */
  --teal: #37d3c2;         /* brand accent — logo, highlights */
  --teal-dark: #1e8fce;    /* primary interactive — buttons, links, active nav */
  --primary-hover: #1a7cb4;
  --amber: #e0930a;        /* hold points / warnings */
  --amber-soft: #fbf0dc;
  --ok: #12a66b;
  --ok-soft: #e4f6ee;
  --bad: #db5a4b;
  --bad-soft: #fbe7e4;
  --ink: #16243a;
  --muted: #5d6b82;
  --line: #e1e7ef;
  --bg: #f3f6fb;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(19, 35, 64, .05), 0 8px 24px rgba(19, 35, 64, .06);
  --shadow-lg: 0 2px 6px rgba(19, 35, 64, .08), 0 20px 44px rgba(19, 35, 64, .10);
  --tap: 48px; /* minimum touch target */
  --head: 'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
  --body: 'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* ensure the hidden attribute always wins over display rules */
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3, h4 { font-family: var(--head); color: var(--slate); line-height: 1.2; margin: 0 0 .4em; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
a { color: var(--teal-dark); }
p { margin: 0 0 1rem; }
small { color: var(--muted); }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: .5rem;
  background: var(--slate); color: #fff;
  padding: .5rem .75rem; min-height: 56px;
  position: sticky; top: 0; z-index: 30;
  padding-top: calc(.5rem + env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: .55rem; color: #fff; text-decoration: none; min-width: 0; }
.brand-text { font-family: var(--head); font-weight: 600; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark {
  font-family: var(--head); font-weight: 700; letter-spacing: .5px;
  background: var(--teal); color: var(--slate-900);
  padding: .2rem .45rem; border-radius: 8px; font-size: .95rem; line-height: 1;
}
.brand-mark span { color: var(--teal-dark); }
.brand-mark.big { font-size: 1.6rem; padding: .4rem .7rem; }
.brand-logo { width: 30px; height: 30px; border-radius: 8px; flex: 0 0 auto; display: block; }
.brand-logo.big { width: 76px; height: 76px; border-radius: 18px; margin: 0 auto .5rem; }
.login-eyebrow { font-family: var(--head); font-size: .72rem; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--teal-dark); margin: 0 0 .15rem; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.whoami { font-size: .85rem; opacity: .9; white-space: nowrap; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; }
.offline-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 2px rgba(255,255,255,.25); }
.offline-dot.off { background: var(--amber); }

/* ---------- Shell / nav ---------- */
.shell { display: flex; min-height: calc(100vh - 56px); }
.sidenav {
  width: 240px; flex: 0 0 240px; background: var(--navy);
  border-right: 0; padding: .9rem .7rem;
  display: flex; flex-direction: column; gap: 3px;
}
.sidenav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.sidenav a {
  display: flex; align-items: center; gap: .7rem;
  min-height: var(--tap); padding: .55rem .75rem; border-radius: 11px;
  color: #b9c9e4; text-decoration: none; font-weight: 550;
  transition: background .14s ease, color .14s ease;
}
.sidenav a .ic { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; flex: 0 0 auto; color: #8fa3c6; }
.sidenav a .ic svg { width: 20px; height: 20px; display: block; }
.sidenav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidenav a:hover .ic { color: #fff; }
.sidenav a.active { background: var(--teal-dark); color: #fff; font-weight: 650; box-shadow: 0 6px 16px rgba(30,143,206,.32); }
.sidenav a.active .ic { color: #fff; }
.nav-footer { margin-top: auto; padding-top: .75rem; border-top: 1px solid rgba(255,255,255,.1); }
.nav-course { font-size: .78rem; color: #8fa3c6; }
.nav-course strong { display: block; color: #e7edf6; font-size: .82rem; margin-bottom: .1rem; }

.menu-toggle { display: none; }
.scrim { display: none; }

.content { flex: 1 1 auto; padding: 1rem; max-width: 980px; margin: 0 auto; width: 100%; outline: none; }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--body); font-size: 1rem; font-weight: 600;
  min-height: var(--tap); padding: .6rem 1.1rem; border-radius: 10px;
  border: 1px solid transparent; cursor: pointer; background: #e9eef0; color: var(--slate);
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  transition: filter .12s ease, background .12s ease;
}
.btn:active { filter: brightness(.96); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--teal-dark); color: #fff; }
.btn-secondary { background: var(--slate); color: #fff; }
.btn-amber { background: var(--amber); color: #3b2708; }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,.4); color: #fff; }
.btn-outline { background: #fff; border-color: var(--line); color: var(--slate); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-sm { min-height: 38px; padding: .35rem .7rem; font-size: .88rem; }
.btn-block { display: flex; width: 100%; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; }

.iconbtn {
  background: transparent; border: 0; color: #fff; font-size: 1.4rem;
  min-width: var(--tap); min-height: var(--tap); border-radius: 10px; cursor: pointer;
}

/* ---------- Cards / layout ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem; margin: 0 0 1rem; min-width: 0;
}
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.tile { transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease; }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: #c7d6ef; }
.tile-ic { width: 30px; height: 30px; color: var(--teal-dark); }
.tile-ic svg { width: 30px; height: 30px; display: block; }
.induction-art { line-height: 0; background: var(--navy); }
.induction-art svg { display: block; width: 100%; }
.narration { background: #eef3fb; border-left: 3px solid var(--teal-dark); padding: .6rem .8rem; border-radius: 0 8px 8px 0; font-size: 1rem; color: #28364f; line-height: 1.5; }
.opt-row:hover { border-color: var(--teal-dark); }
.page-head { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head .grow { flex: 1 1 260px; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.muted { color: var(--muted); }
.spacer { height: 1rem; }
.center { text-align: center; }

/* ---------- Tags / chips ---------- */
.tag {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .75rem; font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
  padding: .2rem .5rem; border-radius: 999px; background: #e9eef0; color: var(--slate);
}
.tag.critical { background: var(--amber-soft); color: #8a4b05; }
.tag.hold { background: var(--amber); color: #3b2708; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.teal { background: #dbf3f3; color: var(--teal-dark); }

/* ---------- Forms ---------- */
.field { display: block; margin: 0 0 .9rem; }
.field > span { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; color: var(--slate); }
input, select, textarea {
  font-family: var(--body); font-size: 1rem; width: 100%;
  min-height: var(--tap); padding: .55rem .65rem; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink);
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(55,211,194,.4); border-color: var(--teal-dark); }
.inline-fields { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.form-error { background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: .6rem .8rem; margin-bottom: .8rem; font-weight: 600; }
.check-row { display: flex; align-items: center; gap: .6rem; min-height: var(--tap); }
.check-row input[type=checkbox] { width: 24px; height: 24px; min-height: 24px; flex: 0 0 auto; }

/* ---------- Steps (joint report) ---------- */
.step {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
  margin: 0 0 .8rem; overflow: hidden;
}
.step.is-critical { border-left: 5px solid var(--amber); }
.step.is-hold { box-shadow: 0 0 0 2px var(--amber) inset; }
.step-head { display: flex; gap: .7rem; align-items: flex-start; padding: .8rem; cursor: pointer; }
.step-no { font-family: var(--head); font-weight: 700; color: var(--teal-dark); min-width: 2.6rem; }
.step-title { flex: 1 1 auto; min-width: 0; }
.step-tags { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .35rem; }
.step-body { padding: 0 .8rem .8rem; border-top: 1px dashed var(--line); }
.step-figure { flex: 0 0 248px; width: 248px; min-height: 80px; max-height: 240px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #fff; display: flex; align-items: center; justify-content: center; cursor: zoom-in; }
.step-figure img { width: 100%; height: auto; max-height: 240px; object-fit: contain; display: block; }
.step-figure.empty { min-height: 96px; background: repeating-linear-gradient(45deg, #f3f6f7, #f3f6f7 6px, #eef3f4 6px, #eef3f4 12px); border-style: dashed; }
.step-figure.none { min-height: 96px; background: #f7f9f9; border-style: dashed; border-color: #e3e9ea; cursor: default; }
.step-figure.none .ph { color: #9aa7ab; font-style: italic; }
.step-figure .ph { color: var(--muted); font-size: .72rem; line-height: 1.3; text-align: center; padding: 4px; }
.step-figure .ph .fn { margin-top: 3px; font-size: .6rem; opacity: .8; word-break: break-all; }
@media (max-width: 680px) { .step-figure { flex-basis: 150px; width: 150px; } .step-figure .ph .fn { display: none; } }
.step-done { background: var(--ok); color: #fff; }
.why { background: var(--amber-soft); border-radius: 10px; padding: .55rem .7rem; font-size: .9rem; color: #6b3d05; margin: .5rem 0; }
.why strong { color: #8a4b05; }
.status-pills { display: flex; gap: .5rem; flex-wrap: wrap; margin: .6rem 0; }
.status-pills label {
  display: inline-flex; align-items: center; gap: .4rem; min-height: var(--tap);
  padding: .4rem .8rem; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; background: #fff;
}
.status-pills input { width: auto; min-height: auto; }
.status-pills label.sel-done { border-color: var(--ok); background: var(--ok-soft); }
.status-pills label.sel-na { border-color: var(--muted); background: #eef1f2; }
.status-pills label.sel-dev { border-color: var(--bad); background: var(--bad-soft); }

/* Hold point banner */
.holdbar {
  display: flex; align-items: center; gap: .7rem; flex-wrap: wrap;
  background: var(--amber); color: #3b2708; border-radius: 10px; padding: .6rem .8rem; margin: .6rem 0;
}
.holdbar.signed { background: var(--ok-soft); color: var(--ok); }
.holdbar .hp-name { font-weight: 700; }

/* Photos */
.photo-row { display: flex; gap: .6rem; flex-wrap: wrap; margin: .5rem 0; }
.photo-thumb { position: relative; width: 92px; height: 92px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb .photo-missing { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; text-align: center; font-size: .65rem; color: var(--muted); background: #eef3f4; padding: 4px; }
.photo-thumb button { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 50%; width: 26px; height: 26px; cursor: pointer; }
.photo-add {
  width: 92px; height: 92px; border-radius: 10px; border: 2px dashed var(--line);
  background: #fff; display: flex; align-items: center; justify-content: center; flex-direction: column;
  cursor: pointer; color: var(--muted); font-size: .75rem; gap: .2rem;
}
.photo-add span { font-size: 1.5rem; line-height: 1; }
.photo-hint { font-size: .85rem; color: #3a5560; background: #eef6f6; border-left: 3px solid var(--teal-dark); padding: .4rem .6rem; border-radius: 6px; margin: .15rem 0 .5rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); border: 1px solid var(--line); }
table.data { width: 100%; border-collapse: collapse; background: var(--card); min-width: 520px; }
table.data th, table.data td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--line); font-size: .92rem; vertical-align: top; }
table.data th { background: #eef3f4; color: var(--slate); position: sticky; top: 0; }
table.data tr:last-child td { border-bottom: 0; }

/* Progress */
.progress { height: 10px; border-radius: 999px; background: #e3eaec; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--teal-dark); }

/* Big result */
.result-banner { border-radius: var(--radius); padding: 1.4rem; text-align: center; margin-bottom: 1rem; }
.result-banner.pass { background: var(--ok-soft); border: 2px solid var(--ok); }
.result-banner.fail { background: var(--bad-soft); border: 2px solid var(--bad); }
.result-banner .verdict { font-family: var(--head); font-size: 2.2rem; font-weight: 700; }
.result-banner.pass .verdict { color: var(--ok); }
.result-banner.fail .verdict { color: var(--bad); }
.result-banner .score { font-size: 1.1rem; color: var(--slate); }

/* ---------- Login ---------- */
.login { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(150deg, var(--navy) 0%, var(--navy-700) 100%); padding: 1.5rem; z-index: 60; }
.login-card { background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); padding: 1.6rem; width: 100%; max-width: 380px; text-align: center; }
.login-card h1 { font-size: 1.35rem; margin: .7rem 0 .2rem; }
.login-sub { color: var(--muted); font-size: .9rem; margin-bottom: 1rem; }
.login-card .field { text-align: left; }
.login-hint { font-size: .82rem; color: var(--muted); margin: .9rem 0 0; }
.login-foot { color: rgba(255,255,255,.8); font-size: .8rem; margin-top: 1.2rem; text-align: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--slate-900); color: #fff; padding: .7rem 1.1rem; border-radius: 10px;
  box-shadow: var(--shadow-lg); z-index: 80; font-weight: 600; max-width: 90vw;
}
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(29,43,48,.55); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 70; }
.modal { background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; padding: 1.2rem; }
.modal h3 { margin-top: 0; }

/* ---------- Responsive: drawer nav ---------- */
@media (max-width: 820px) {
  .menu-toggle { display: inline-flex; }
  .brand-text { display: none; }
  .sidenav {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50; width: 260px; flex-basis: 260px;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg);
    padding-top: calc(.75rem + env(safe-area-inset-top));
  }
  .app.nav-open .sidenav { transform: translateX(0); }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.35); }
  .content { padding: .8rem; }
}
@media (max-width: 420px) {
  .brand-text { display: none; }
  .whoami { display: none; } /* who you are is shown on Home; saves topbar room for Back + Sign out */
}
