/* SiteBakkie: one layout for every screen.
   Header · page title + one-line purpose · cards · one main action at the bottom.
   Light theme by default (readable in sunlight); dark theme is a setting. */
:root {
  --navy: #122433; --accent: #f26b1d; --accent-ink: #fff; --bg: #eef1f5; --card: #fff;
  --ink: #111c27; --muted: #566575; --line: #d9e0e8; --chip: #eef2f6; --chip-on: #0f2233; --chip-on-ink: #fff;
  --green: #138a4b; --green-bg: #e3f5ea; --amber: #b45d00; --amber-bg: #fff1dc; --red: #c8291d; --red-bg: #fde7e4;
  --grey: #8996a3; --grey-bg: #eef1f4; --rec: #d93a3a; --shadow: 0 1px 2px rgba(15,34,51,.06), 0 2px 8px rgba(15,34,51,.05);
}
:root[data-theme="dark"] {
  --bg: #0c131a; --card: #151f29; --ink: #e9eff5; --muted: #95a4b3; --line: #26333f; --chip: #1f2c38;
  --chip-on: #f26b1d; --green-bg: #0f2f20; --green: #4fd08a; --amber-bg: #3a2a0d; --amber: #ffbf5e;
  --red-bg: #3d1714; --red: #ff8a7d; --grey-bg: #1d2731; --shadow: none;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }

/* ---------- shell ---------- */
header { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; background: #fff; color: var(--navy); border-bottom: 1px solid #dfe5ec; }
header .brand-logo { height: 28px; width: auto; display: block; flex: none; }
header .brand-mark { height: 30px; width: auto; display: none; flex: none; }
@media (max-width: 480px) { header .brand-logo { display: none; } header .brand-mark { display: block; } }
header .site { flex: 1; min-width: 0; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: #eef2f6; border: 0; color: var(--navy); text-align: left; padding: 7px 10px; border-radius: 9px; width: auto; min-height: 0; }
.sync { font-size: 12px; font-weight: 700; padding: 5px 9px; border-radius: 99px; background: #24394d; color: #fff; white-space: nowrap; }
.sync.off { background: #7a4300; } .sync.pending { background: #9a5b00; } .sync.ok { background: #136b40; }
main { max-width: 680px; margin: 0 auto; padding: 14px 14px calc(env(safe-area-inset-bottom) + 160px); }
nav.bottom { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav.bottom a { text-align: center; padding: 8px 2px 7px; font-size: 12px; font-weight: 600; color: var(--muted); text-decoration: none; }
nav.bottom a span { display: block; font-size: 22px; line-height: 1.15; }
nav.bottom a.on { color: var(--accent); }
.fab { position: fixed; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 76px); z-index: 7; width: auto; min-height: 0;
  border-radius: 99px; padding: 15px 22px; font-size: 17px; font-weight: 800; background: var(--accent); color: #fff; border: 0;
  box-shadow: 0 6px 20px rgba(242,107,29,.4); }

/* ---------- page format ---------- */
.page-head { margin: 4px 0 14px; }
.page-head h1 { font-size: 24px; margin: 0; line-height: 1.2; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.page-head .back { display: inline-block; margin: 0 0 6px -8px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 22px 0 8px; }
h3 { font-size: 16px; margin: 10px 0 6px; }
.action-bar { position: fixed; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 62px); z-index: 4;
  padding: 10px 14px; background: linear-gradient(to top, var(--bg) 70%, transparent); }
.action-bar > div { max-width: 680px; margin: 0 auto; display: grid; gap: 8px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; }
.hidden { display: none !important; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
.card.tap { cursor: pointer; display: flex; align-items: center; gap: 12px; }
.card.tap .grow { flex: 1; min-width: 0; }
.card .ico { font-size: 26px; width: 38px; text-align: center; }
.row { display: flex; align-items: center; gap: 8px; } .between { justify-content: space-between; } .wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- forms ---------- */
input, textarea, select { width: 100%; font: inherit; font-size: 16px; padding: 12px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); margin: 4px 0 12px; }
input:focus, textarea:focus, select:focus { outline: 0; border-color: var(--accent); }
textarea { min-height: 90px; }
label { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin-top: 2px; }
label.check { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 500; color: var(--ink); padding: 10px 0; }
label.check input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--accent); }
button, .btn { display: block; font: inherit; font-weight: 600; border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  padding: 13px 16px; border-radius: 12px; width: 100%; cursor: pointer; text-align: center; text-decoration: none; min-height: 52px; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 800; font-size: 17px; }
button.dark { background: var(--navy); color: #fff; border-color: var(--navy); }
button.danger { background: var(--red); color: #fff; border-color: var(--red); font-weight: 800; }
button.link { background: none; border: 0; color: var(--accent); width: auto; padding: 8px; min-height: 0; display: inline; font-weight: 700; }
button.small { padding: 8px 12px; min-height: 0; width: auto; font-size: 14px; display: inline-block; }
button:disabled { opacity: .5; }

/* ---------- status ---------- */
.badge { display: inline-block; font-size: 12px; font-weight: 800; padding: 3px 9px; border-radius: 99px; background: var(--chip); color: var(--muted); white-space: nowrap; }
.badge.ok, .badge.green { background: var(--green-bg); color: var(--green); }
.badge.warn, .badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.bad, .badge.red { background: var(--red-bg); color: var(--red); }
.note { border-radius: 10px; padding: 11px 13px; margin: 8px 0; font-size: 15px; border-left: 5px solid; }
.note.warn { background: var(--amber-bg); color: var(--amber); border-color: var(--amber); }
.note.bad { background: var(--red-bg); color: var(--red); border-color: var(--red); }
.note.ok { background: var(--green-bg); color: var(--green); border-color: var(--green); }
.note.info { background: var(--grey-bg); color: var(--muted); border-color: var(--grey); }
.crit { color: var(--red); font-weight: 800; }

/* ---------- Site Board ---------- */
.summary { border-radius: 16px; padding: 16px; color: #fff; margin-bottom: 14px; }
.summary.red { background: var(--red); } .summary.amber { background: #c76a00; } .summary.green { background: var(--green); }
.summary h1 { margin: 0; font-size: 22px; }
.summary p { margin: 4px 0 10px; opacity: .95; }
.summary .counts { display: flex; gap: 8px; flex-wrap: wrap; }
.summary .counts span { background: rgba(255,255,255,.2); border-radius: 99px; padding: 4px 11px; font-weight: 800; font-size: 14px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 560px) { .tiles { grid-template-columns: 1fr 1fr 1fr; } }
.tile { border-radius: 14px; padding: 12px 12px 11px; cursor: pointer; border: 0; text-align: left; min-height: 112px;
  display: flex; flex-direction: column; gap: 4px; color: #fff; width: 100%; font-weight: 400; box-shadow: var(--shadow); }
.tile.red { background: var(--red); } .tile.amber { background: #c76a00; } .tile.green { background: var(--green); }
.tile.na { background: var(--grey-bg); color: var(--muted); }
.tile .t-top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 800; letter-spacing: .4px; opacity: .9; }
.tile .t-title { font-size: 16px; font-weight: 800; line-height: 1.2; }
.tile .t-detail { font-size: 13px; line-height: 1.3; opacity: .95; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tile .t-reg { margin-top: auto; font-size: 11px; opacity: .8; }
.fix { display: flex; align-items: center; gap: 12px; border-left: 6px solid var(--red); }
.fix.amber { border-left-color: #c76a00; }

/* ---------- lists, chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip { border: 1.5px solid var(--line); background: var(--chip); color: var(--ink); border-radius: 99px; padding: 8px 13px;
  font-size: 15px; font-weight: 600; width: auto; min-height: 0; display: inline-block; }
.chip.on { background: var(--chip-on); color: var(--chip-on-ink); border-color: var(--chip-on); }
.chip.unapproved::after { content: " ⚠"; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 11px 0; border-bottom: 1px solid var(--line); }
ul.plain li:last-child { border-bottom: 0; }
.list-item { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--chip); display: grid; place-items: center;
  font-weight: 800; color: var(--muted); flex: none; object-fit: cover; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.dot.red { background: var(--red); } .dot.amber { background: #c76a00; } .dot.green { background: var(--green); } .dot.na { background: var(--grey); }
.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--chip); padding: 4px; border-radius: 12px; margin: 0 0 12px; }
.tabs button { border: 0; padding: 10px 4px; font-size: 15px; background: transparent; border-radius: 9px; min-height: 0; }
.tabs button.on { background: var(--card); font-weight: 800; box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* ---------- recording, signatures ---------- */
.mic { width: 150px; height: 150px; border-radius: 50%; margin: 18px auto 10px; display: grid; place-items: center;
  background: var(--accent); color: #fff; border: 0; font-size: 54px; box-shadow: 0 8px 24px rgba(242,107,29,.35); }
.mic.rec { background: var(--rec); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.timer { font-variant-numeric: tabular-nums; color: var(--muted); text-align: center; }
.spinner { width: 50px; height: 50px; margin: 50px auto 16px; border: 5px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.answer { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.answer button { min-height: 48px; padding: 8px; font-weight: 800; }
.answer button.on.ok { background: var(--green); color: #fff; border-color: var(--green); }
.answer button.on.defect, .answer button.on.gap { background: var(--red); color: #fff; border-color: var(--red); }
.answer button.on.na { background: var(--grey); color: #fff; border-color: var(--grey); }
.sigimg { height: 36px; background: #fff; border-radius: 4px; }
.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.talk-text { font-size: 18px; line-height: 1.55; white-space: pre-wrap; }
.hazard { border-left: 3px solid var(--accent); padding-left: 10px; margin: 8px 0; font-size: 14px; }
.steps { display: flex; gap: 6px; margin: 4px 0 12px; }
.steps span { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.steps span.on { background: var(--accent); }
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 680px; border-radius: 18px 18px 0 0; padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px);
  max-height: 94vh; overflow: auto; }
.padwrap { position: relative; border: 2px dashed var(--line); border-radius: 12px; background: #fff; touch-action: none; }
.padwrap canvas { display: block; width: 100%; height: 190px; touch-action: none; }
.padwrap .hint { position: absolute; left: 12px; bottom: 8px; color: #9aa7b4; font-size: 13px; pointer-events: none; }
.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions-grid button { display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 92px; font-size: 15px; }
.actions-grid button span { font-size: 28px; }
.toast { position: fixed; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 140px); z-index: 30; background: var(--navy);
  color: #fff; border-radius: 12px; padding: 12px 14px; font-size: 15px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 656px; margin: 0 auto; }
.toast.bad { background: #b3261e; } .toast.ok { background: #12703f; }
table.simple { width: 100%; border-collapse: collapse; font-size: 14px; }
table.simple td { padding: 7px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
@media print { header, nav.bottom, .noprint, .fab, .action-bar { display: none !important; } main { padding: 0; } }
.qrgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.qrgrid .card { text-align: center; break-inside: avoid; }
.qrgrid img { width: 150px; height: 150px; }

/* password field with a show/hide button */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 70px; }
.pw-eye { position: absolute; right: 6px; top: calc(50% - 4px); transform: translateY(-50%); margin: 0; padding: 6px 10px; min-height: 0;
  background: transparent; border: 0; color: var(--muted); font-size: 14px; font-weight: 600; width: auto; }
