/* PitCheck — mobile-first, dirty-hands UI.
   Design goals: huge tap targets, one-tap ratings, minimal typing,
   thumb-reachable actions, readable in a bright workshop. */

:root {
  --bg:        #eef2f6;
  --card:      #ffffff;
  --ink:       #0b1f33;
  --ink-soft:  #5b6b7b;
  --line:      #d7dee6;
  --brand:     #0b1f33;
  --brand-2:   #1763b6;
  --accent:    #ff7a00;   /* high-vis action colour */
  --good:      #1ca35a;
  --good-bg:   #e3f6ec;
  --warn:      #e08a00;
  --warn-bg:   #fdf0d9;
  --bad:       #d23b3b;
  --bad-bg:    #fbe4e4;
  --na:        #8794a1;
  --na-bg:     #eceff2;
  --radius:    16px;
  --tap:       58px;       /* minimum interactive height */
  --shadow:    0 2px 10px rgba(11,31,51,.08);
  --safe-bot:  env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 18px;
  line-height: 1.35;
  -webkit-text-size-adjust: 100%;
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 18px; }

/* ---------- App frame ---------- */
#app { max-width: 720px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(96px + var(--safe-bot)); }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--brand); color: #fff;
  padding: max(14px, env(safe-area-inset-top)) 16px 14px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow);
}
.topbar .brand { font-weight: 800; font-size: 20px; letter-spacing: .3px; }
.topbar .brand small { font-weight: 500; opacity: .7; font-size: 13px; display: block; }
.topbar .spacer { flex: 1; }
.iconbtn {
  background: rgba(255,255,255,.14); color: #fff; border: 0;
  width: 46px; height: 46px; border-radius: 12px; font-size: 22px;
  display: grid; place-items: center;
}
.iconbtn:active { background: rgba(255,255,255,.28); }

/* ---------- Generic cards ---------- */
.wrap { padding: 16px; }
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
}
.muted { color: var(--ink-soft); }
.center { text-align: center; }

/* ---------- Buttons ---------- */
.btn {
  width: 100%; min-height: var(--tap); border: 0; border-radius: 14px;
  font-size: 19px; font-weight: 700; padding: 0 18px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:active { filter: brightness(.92); }
.btn.dark { background: var(--brand); color: #fff; }
.btn.ghost { background: #fff; color: var(--brand); border: 2px solid var(--line); }
.btn.sm { min-height: 46px; font-size: 16px; width: auto; padding: 0 16px; }
.btn:disabled { opacity: .5; }

/* ---------- Home / list ---------- */
.hero { padding: 22px 16px 6px; }
.hero h1 { margin: 0 0 4px; font-size: 26px; }
.list-item {
  display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit;
}
.list-item .plate-chip {
  background: var(--ink); color: #ffd400; font-weight: 800; letter-spacing: 1px;
  border-radius: 8px; padding: 8px 10px; min-width: 86px; text-align: center;
  border: 2px solid #000; font-size: 18px;
}
.list-item .meta { flex: 1; min-width: 0; }
.list-item .meta b { display: block; font-size: 18px; }
.list-item .meta span { color: var(--ink-soft); font-size: 14px; }
.badge { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.badge.draft { background: var(--warn-bg); color: var(--warn); }
.badge.done  { background: var(--good-bg); color: var(--good); }
.empty { text-align: center; color: var(--ink-soft); padding: 50px 20px; }
.empty .big { font-size: 56px; }

/* ---------- Section nav (chips) ---------- */
.secnav {
  position: sticky; top: 72px; z-index: 20; background: var(--bg);
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.secnav::-webkit-scrollbar { display: none; }
.secnav button {
  white-space: nowrap; border: 0; background: #fff; color: var(--ink-soft);
  border-radius: 999px; padding: 10px 16px; font-weight: 700; font-size: 15px;
  box-shadow: var(--shadow);
}
.secnav button.active { background: var(--brand); color: #fff; }
.secnav button .dot { color: var(--good); }

/* ---------- Section header ---------- */
.sec-head { display: flex; align-items: center; gap: 10px; margin: 4px 2px 12px; }
.sec-head h2 { margin: 0; font-size: 22px; }
.sec-head .ico { font-size: 26px; }
.sec-head .spacer { flex: 1; }

/* ---------- Check rows (the heart of it) ---------- */
.check { padding: 14px 0; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: 0; }
.check .label { font-weight: 700; margin-bottom: 10px; font-size: 18px; }
.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chip {
  min-height: var(--tap); border-radius: 12px; border: 2px solid var(--line);
  background: #fff; color: var(--ink-soft); font-weight: 800; font-size: 16px;
}
.chip:active { transform: scale(.97); }
.chip.on.good { background: var(--good-bg); border-color: var(--good); color: var(--good); }
.chip.on.warn { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.chip.on.bad  { background: var(--bad-bg);  border-color: var(--bad);  color: var(--bad);  }
.chip.on.na   { background: var(--na-bg);   border-color: var(--na);   color: var(--na);   }

.row-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.notes { width: 100%; margin-top: 10px; border: 2px solid var(--line); border-radius: 12px;
         padding: 12px; min-height: 52px; resize: vertical; }

/* numeric stepper for tyre tread etc */
.num { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.num button { width: var(--tap); height: var(--tap); border-radius: 12px; border: 2px solid var(--line);
              background: #fff; font-size: 28px; font-weight: 800; color: var(--brand); }
.num input { flex: 1; text-align: center; min-height: var(--tap); border: 2px solid var(--line);
             border-radius: 12px; font-size: 24px; font-weight: 800; }
.num .unit { color: var(--ink-soft); font-weight: 700; min-width: 34px; }

/* ---------- Field inputs ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 700; margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%; min-height: var(--tap); border: 2px solid var(--line);
  border-radius: 12px; padding: 12px 14px;
}
.field textarea { min-height: 96px; }
.field input[readonly] { background: #f4f7fa; color: var(--ink); }
.field .from-api { font-size: 12px; color: var(--brand-2); font-weight: 700; }

/* ---------- Plate / chassis lookup block ---------- */
.idtoggle { display: flex; gap: 0; margin-bottom: 12px; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; }
.idtoggle .seg { flex: 1; min-height: 48px; border: 0; background: #fff; color: var(--ink-soft); font-weight: 800; font-size: 16px; }
.idtoggle .seg.on { background: var(--brand); color: #fff; }
.platebox { display: flex; gap: 10px; }
.platebox input {
  flex: 1; text-transform: uppercase; letter-spacing: 3px; font-weight: 800;
  font-size: 26px; text-align: center; min-height: 66px; border: 3px solid var(--ink);
  border-radius: 14px; background: #fffbe6;
}
.lookup-status { margin-top: 10px; font-weight: 700; min-height: 22px; }
.lookup-status.err { color: var(--bad); }
.lookup-status.ok  { color: var(--good); }

/* ---------- Photos ---------- */
.photogrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.photogrid .thumb { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #000; }
.photogrid .thumb img { width: 100%; height: 100%; object-fit: cover; }
.photogrid .thumb .del { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.6);
                         color: #fff; border: 0; width: 30px; height: 30px; border-radius: 999px; font-size: 16px; }
.addphoto { aspect-ratio: 1; border: 2px dashed var(--brand-2); border-radius: 12px; background: #f4f9ff;
            color: var(--brand-2); font-weight: 800; font-size: 30px; display: grid; place-items: center; }

/* ---------- Signature ---------- */
.sigpad { width: 100%; height: 200px; border: 2px solid var(--line); border-radius: 12px; background: #fff; touch-action: none; }

/* ---------- Bottom bar ---------- */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: #fff; border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + var(--safe-bot));
  display: flex; gap: 10px; max-width: 720px; margin: 0 auto;
}
.bottombar .btn { flex: 1; }

/* progress bar under topbar */
.progress { height: 6px; background: var(--line); }
.progress > div { height: 100%; background: var(--good); transition: width .25s; }

/* fab on home */
.fab {
  position: fixed; right: 18px; bottom: calc(20px + var(--safe-bot)); z-index: 40;
  background: var(--accent); color: #fff; border: 0; border-radius: 999px;
  height: 64px; padding: 0 24px; font-size: 19px; font-weight: 800;
  box-shadow: 0 6px 18px rgba(255,122,0,.4); display: flex; align-items: center; gap: 10px;
}

.toast {
  position: fixed; left: 50%; bottom: calc(100px + var(--safe-bot)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-weight: 700; z-index: 60; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* review/print */
@media print {
  .topbar, .secnav, .bottombar, .fab, .row-actions { display: none !important; }
  body { background: #fff; }
}
