/* FFG Vehicle Health Check PWA — mobile-first styles.
 * Self-contained (no dependency on admin.css / ffg.css) so the service
 * worker can cache the shell as one tight bundle. */

:root {
  color-scheme: light;
  accent-color: #0e1ea0;
  --vhc-blue:       #0e1ea0;
  --vhc-blue-dark:  #0a1577;
  --vhc-blue-tint:  #eef0ff;
  --vhc-amber:      #fcb900;
  --vhc-text:       #1f2937;
  --vhc-muted:      #6b7280;
  --vhc-border:     #e2e6ee;
  --vhc-surface:    #ffffff;
  --vhc-bg:         #f5f7fb;
  --vhc-green:      #15803d;
  --vhc-green-tint: #d1fae5;
  --vhc-red:        #b91c1c;
  --vhc-red-tint:   #fee2e2;
  --vhc-amber-tint: #fff4d6;
  --vhc-shadow:     0 1px 2px rgba(15,23,42,.06), 0 6px 18px rgba(15,23,42,.1);
  --vhc-shadow-lg:  0 8px 16px rgba(13,24,111,.16), 0 24px 48px rgba(13,24,111,.14);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body.vhc {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--vhc-text);
  background: var(--vhc-bg);
  overscroll-behavior: contain;
  /* Safe-area handling for notched iPhones in standalone mode. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
input, button, select, textarea {
  font: inherit;
  background-color: #fff;
  color: var(--vhc-text);
}
button { cursor: pointer; }
img, svg { display: block; max-width: 100%; }

/* ====== Boot splash ====== */
.vhc-boot {
  height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--vhc-blue);
  color: #fff;
  font-weight: 600;
  letter-spacing: .02em;
}
.vhc-boot-logo { font-size: 22px; }
.vhc-boot-msg  { margin-top: .5rem; font-size: 13px; opacity: .8; }

/* ====== Top bar ====== */
.vhc-topbar {
  position: sticky; top: 0; z-index: 10;
  background: linear-gradient(180deg, var(--vhc-blue) 0%, var(--vhc-blue-dark) 100%);
  color: #fff;
  padding: .85rem 1rem;
  padding-top: max(.85rem, env(safe-area-inset-top));
  display: flex; align-items: center; gap: .75rem;
  box-shadow: 0 1px 0 rgba(0,0,0,.08), 0 4px 12px rgba(13,24,111,.25);
}
.vhc-topbar-back {
  background: rgba(255,255,255,.16);
  border: 0; color: #fff;
  width: 34px; height: 34px;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; line-height: 1;
}
.vhc-topbar-title { flex: 1; font-weight: 700; font-size: 16px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vhc-topbar-actions { display: flex; gap: .35rem; }
.vhc-pill {
  background: rgba(255,255,255,.18);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
}

/* ====== Generic layout ====== */
.vhc-page { padding: .75rem 1rem 6rem; max-width: 760px; margin: 0 auto; }
.vhc-card {
  background: var(--vhc-surface);
  border-radius: 14px;
  box-shadow: var(--vhc-shadow);
  padding: 1rem 1.1rem;
  margin: 0 0 .85rem;
}
.vhc-muted { color: var(--vhc-muted); }
.vhc-small { font-size: 13px; }

/* ====== Login (admin picker + PIN keypad) ====== */
.vhc-login {
  min-height: 100vh;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 1rem env(safe-area-inset-bottom);
  background: linear-gradient(180deg, var(--vhc-blue) 0%, var(--vhc-blue-dark) 100%);
  color: #fff;
}
.vhc-login-hero {
  text-align: center;
  padding: 2rem 0 1rem;
}
.vhc-login-hero h1 { margin: 0; font-size: 20px; letter-spacing: .04em; font-weight: 700; }
.vhc-login-hero p  { margin: .25rem 0 0; opacity: .85; font-size: 13px; }
.vhc-admin-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .6rem; margin-top: 1rem;
}
.vhc-admin-tile {
  background: rgba(255,255,255,.12);
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 1rem .75rem;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  min-height: 96px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .35rem;
}
.vhc-admin-tile small { font-size: 11px; font-weight: 500; opacity: .8; text-transform: uppercase; letter-spacing: .04em; }
.vhc-admin-tile:hover, .vhc-admin-tile:focus-visible { background: rgba(255,255,255,.22); }
.vhc-admin-tile.is-picked { background: var(--vhc-amber); color: #000; }

.vhc-pin-stage { padding: 1rem 0; text-align: center; }
.vhc-pin-stage h2 { margin: 0; font-size: 18px; font-weight: 600; }
.vhc-pin-dots {
  display: flex; justify-content: center; gap: 12px;
  margin: 1.25rem 0;
}
.vhc-pin-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: rgba(255,255,255,.18);
  border: 2px solid rgba(255,255,255,.4);
  transition: background .1s ease, border-color .1s ease;
}
.vhc-pin-dot.is-filled { background: #fff; border-color: #fff; }

.vhc-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 320px;
  margin: 0 auto;
}
.vhc-key {
  background: rgba(255,255,255,.12);
  color: #fff;
  border: 0;
  border-radius: 12px;
  font-size: 22px;
  font-weight: 600;
  min-height: 64px;
  display: flex; align-items: center; justify-content: center;
}
.vhc-key:active { background: rgba(255,255,255,.32); }
.vhc-key.is-fn { font-size: 14px; font-weight: 600; letter-spacing: .04em; }

.vhc-login-msg {
  text-align: center;
  margin-top: 1rem;
  min-height: 1.2rem;
  font-size: 14px;
  color: #ffe4c8;
}

/* ====== Sheet list ====== */
.vhc-filter-row {
  display: flex; gap: 4px;
  background: var(--vhc-blue-tint);
  border-radius: 999px;
  padding: 4px;
  margin: 0 0 .75rem;
}
.vhc-filter-btn {
  flex: 1;
  border: 0; background: transparent;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px; font-weight: 600;
  color: var(--vhc-blue);
}
.vhc-filter-btn.is-on { background: var(--vhc-blue); color: #fff; box-shadow: 0 1px 4px rgba(14,30,160,.4); }

.vhc-sheet-card {
  background: var(--vhc-surface);
  border-radius: 14px;
  box-shadow: var(--vhc-shadow);
  padding: 0;
  margin: 0 0 .65rem;
  overflow: hidden;
  text-decoration: none; color: inherit;
  display: block;
  border-left: 4px solid var(--vhc-blue);
}
.vhc-sheet-card.is-mine { border-left-color: var(--vhc-green); }
.vhc-sheet-card-body { padding: .85rem 1rem; }
.vhc-sheet-card .reg {
  display: inline-block;
  background: var(--vhc-amber); color: #000;
  font-family: 'Charles Wright', 'Arial Black', sans-serif;
  font-weight: 700; letter-spacing: 1.5px;
  padding: 2px 8px;
  border: 1.5px solid #000;
  border-radius: 4px;
  font-size: 14px;
}
.vhc-sheet-card .veh { font-size: 13px; color: var(--vhc-muted); margin-left: .5rem; }
.vhc-sheet-card .cust { font-size: 15px; font-weight: 600; margin: .35rem 0 .2rem; }
.vhc-sheet-card .meta { display: flex; flex-wrap: wrap; gap: .35rem .75rem; font-size: 12.5px; color: var(--vhc-muted); }
.vhc-sheet-card .meta strong { color: var(--vhc-text); font-weight: 600; }
.vhc-sheet-card .pill-row { margin-top: .4rem; display: flex; gap: .3rem; flex-wrap: wrap; }
.vhc-pill-tag {
  display: inline-block; padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
  background: var(--vhc-blue-tint); color: var(--vhc-blue-dark);
}
.vhc-pill-tag.is-warn  { background: var(--vhc-amber-tint); color: #6b4500; }
.vhc-pill-tag.is-mine  { background: var(--vhc-green-tint); color: var(--vhc-green); }

.vhc-empty {
  text-align: center; padding: 3rem 1rem; color: var(--vhc-muted);
}

/* ====== Sheet detail ====== */
.vhc-veh-card {
  display: flex; gap: 1rem; align-items: center;
  background: var(--vhc-surface);
  border-radius: 14px;
  box-shadow: var(--vhc-shadow);
  padding: .85rem 1rem;
  margin: 0 0 .75rem;
}
.vhc-veh-card .reg-big {
  display: inline-block;
  background: var(--vhc-amber); color: #000;
  font-family: 'Charles Wright', 'Arial Black', sans-serif;
  font-weight: 700; letter-spacing: 2px;
  padding: 4px 10px;
  border: 2px solid #000;
  border-radius: 4px;
  font-size: 18px;
}
.vhc-veh-card .veh-info { flex: 1; }
.vhc-veh-card .veh-info-line { font-size: 14px; color: var(--vhc-muted); }
.vhc-veh-card .veh-info-line strong { color: var(--vhc-text); font-weight: 600; }

.vhc-section { margin-bottom: 1.25rem; }
.vhc-section-title {
  margin: 0 0 .5rem;
  font-size: 13px; font-weight: 700;
  color: var(--vhc-blue);
  text-transform: uppercase; letter-spacing: .04em;
}
.vhc-item {
  background: var(--vhc-surface);
  border-radius: 12px;
  box-shadow: var(--vhc-shadow);
  padding: .85rem 1rem;
  margin: 0 0 .5rem;
}
.vhc-item-label { font-weight: 600; margin: 0 0 .5rem; font-size: 15px; }
.vhc-sev-row { display: flex; gap: 6px; flex-wrap: wrap; }
.vhc-sev-btn {
  flex: 1; min-width: 78px;
  background: #f3f4f6;
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 10px 8px;
  font-size: 12.5px; font-weight: 700;
  color: var(--vhc-muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.vhc-sev-btn.is-on { background: #fff; box-shadow: inset 0 0 0 2px currentColor, 0 2px 6px rgba(0,0,0,.08); }
.vhc-sev-btn[data-sev="ok"]         { color: var(--vhc-green); }
.vhc-sev-btn[data-sev="monitoring"] { color: #b45309; }
.vhc-sev-btn[data-sev="advisory"]   { color: #b45309; }
.vhc-sev-btn[data-sev="fault"]      { color: var(--vhc-red); }
.vhc-sev-btn[data-sev="not_done"]   { color: var(--vhc-muted); }
.vhc-sev-btn.is-on[data-sev="ok"]         { background: var(--vhc-green-tint); }
.vhc-sev-btn.is-on[data-sev="monitoring"] { background: var(--vhc-amber-tint); }
.vhc-sev-btn.is-on[data-sev="advisory"]   { background: var(--vhc-amber-tint); }
.vhc-sev-btn.is-on[data-sev="fault"]      { background: var(--vhc-red-tint); }
.vhc-sev-btn.is-on[data-sev="not_done"]   { background: #e5e7eb; }

.vhc-item-notes {
  width: 100%;
  margin-top: .55rem;
  border: 1px solid var(--vhc-border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  min-height: 38px;
  resize: vertical;
}

/* Photo strip + camera button under each item */
.vhc-photo-strip {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: .55rem;
}
.vhc-photo-strip:empty { margin-top: 0; }
.vhc-photo-tile {
  display: block;
  width: 72px; height: 54px;
  border-radius: 6px;
  overflow: hidden;
  background: #e5e7eb;
  border: 1px solid var(--vhc-border);
}
.vhc-photo-tile img {
  width: 100%; height: 100%; object-fit: cover;
}
.vhc-photo-tile.is-pending { position: relative; }
.vhc-photo-tile.is-pending::after {
  content: '⏳';
  position: absolute; right: 2px; bottom: 2px;
  width: 18px; height: 18px;
  background: rgba(13, 24, 111, .85);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; line-height: 1;
}
.vhc-photo-tile.is-failed {
  outline: 2px solid var(--vhc-red);
}
.vhc-photo-tile.is-failed::after {
  content: '!';
  position: absolute; right: 2px; bottom: 2px;
  width: 18px; height: 18px;
  background: var(--vhc-red);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; line-height: 1;
}
.vhc-photo-btn {
  margin-top: .5rem;
  background: var(--vhc-blue-tint);
  color: var(--vhc-blue);
  border: 1px solid var(--vhc-border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  width: 100%;
}
.vhc-photo-btn:disabled { opacity: .55; }

/* Extras subsection — visually distinct (gold) so it stands out from the
 * regular template items. */
.vhc-extras-section .vhc-section-title { color: #8a5a00; }
.vhc-extra-row {
  background: var(--vhc-surface);
  border-radius: 12px;
  box-shadow: var(--vhc-shadow);
  padding: .8rem 1rem;
  margin: 0 0 .5rem;
  display: flex; align-items: center; gap: .75rem;
  border-left: 4px solid var(--vhc-amber);
}
.vhc-extra-row.is-confirmed { background: var(--vhc-green-tint); border-left-color: var(--vhc-green); }
.vhc-extra-row.is-confirmed .vhc-extra-name { text-decoration: line-through; color: #064e3b; }
.vhc-extra-name { flex: 1; font-weight: 600; }
.vhc-extra-toggle {
  background: var(--vhc-blue);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
}
.vhc-extra-row.is-confirmed .vhc-extra-toggle { background: var(--vhc-green); }

/* Save status pill — anchored bottom-centre, updates as ops flush. */
.vhc-status-pill {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 1rem);
  background: rgba(15,23,42,.85);
  color: #fff;
  font-size: 12.5px;
  padding: 6px 14px;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
  z-index: 30;
  pointer-events: none;
  transition: opacity .2s ease;
  opacity: 0;
}
.vhc-status-pill.is-visible { opacity: 1; }
.vhc-status-pill.is-error { background: var(--vhc-red); }

/* Footer action bar (Complete / Sign off) */
.vhc-footer-bar {
  position: sticky; bottom: 0;
  background: var(--vhc-surface);
  padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--vhc-border);
  display: flex; gap: .5rem;
  margin-top: 1rem;
}
.vhc-btn {
  flex: 1;
  background: var(--vhc-blue);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 700;
}
.vhc-btn.is-ghost { background: #fff; color: var(--vhc-blue); border: 1px solid var(--vhc-border); }
.vhc-btn.is-danger { background: var(--vhc-red); }
.vhc-btn:disabled { opacity: .5; }

/* ====== Extras-confirmation modal ====== */
.vhc-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(13,24,111,.55);
  z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  padding: env(safe-area-inset-top) 1rem env(safe-area-inset-bottom);
}
.vhc-modal {
  background: #fff;
  border-radius: 18px 18px 0 0;
  width: 100%; max-width: 600px;
  padding: 1.25rem 1rem 1.5rem;
  box-shadow: var(--vhc-shadow-lg);
  max-height: 90vh; overflow-y: auto;
}
@media (min-width: 520px) {
  .vhc-modal-backdrop { align-items: center; }
  .vhc-modal { border-radius: 18px; }
}
.vhc-modal h2 { margin: 0 0 .4rem; font-size: 17px; font-weight: 700; }
.vhc-modal p  { margin: 0 0 .85rem; font-size: 13.5px; color: var(--vhc-muted); }
.vhc-modal .vhc-extra-row { margin-bottom: .5rem; }
.vhc-modal-action { display: flex; gap: .5rem; margin-top: .5rem; }

/* ====== Minor utilities ====== */
.vhc-hidden { display: none !important; }
