/* ============================================================
   FIELDMARK — design tokens
   Palette: charcoal-navy ground, warm gold accent, muted pine
   secondary. Status colors read like a clipboard rating stamp,
   not a UI-kit default. Type: IBM Plex Sans (UI) + IBM Plex
   Mono (scores, readings, IDs) — instrumentation feel for a
   field-diagnostic tool.
   ============================================================ */

:root {
  --ink: #1C2B33;
  --ink-soft: #3B4A52;
  --paper: #F5F6F3;
  --paper-raised: #FFFFFF;
  --line: #DCDCD3;
  --muted: #74807E;
  --gold: #E8A33D;
  --pine: #3B6E71;

  --ok: #5B8266;
  --ok-bg: #E7EEE4;
  --concern: #C08A2E;
  --concern-bg: #F5EBD6;
  --action: #B0503A;
  --action-bg: #F5E1DA;

  --radius: 10px;
  --radius-lg: 16px;
  --font-ui: "IBM Plex Sans", -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--paper);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  padding-top: 56px;
  padding-bottom: 0;
}

button, input, select, textarea { font-family: inherit; font-size: 16px; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---- Top bar ---- */
.top-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 56px;
  background: var(--ink); color: #fff;
  display: flex; align-items: center; gap: 8px;
  padding: 0 8px; z-index: 40;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.top-title {
  flex: 1; font-weight: 600; font-size: 17px; letter-spacing: 0.2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.icon-btn {
  background: transparent; border: none; color: #fff;
  width: 40px; height: 40px; border-radius: 8px; font-size: 18px;
}
.icon-btn:active { background: rgba(255,255,255,0.12); }
.hidden { display: none !important; }

/* ---- Bottom nav ---- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; height: 72px;
  background: var(--paper-raised); border-top: 1px solid var(--line);
  display: flex; z-index: 40;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1; background: none; border: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 11px; font-weight: 500;
}
.nav-btn.active { color: var(--ink); }
.nav-ico { font-size: 18px; }

/* ---- Layout ---- */
#app { max-width: 640px; margin: 0 auto; padding: 16px 16px 120px; min-height: calc(100vh - 128px); }
.screen-header { margin-bottom: 16px; }
.screen-header h1 { font-size: 21px; margin: 0 0 4px; }
.screen-header p { margin: 0; color: var(--muted); font-size: 14px; }
.section-title {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); margin: 24px 0 10px;
}
.section-title:first-child { margin-top: 0; }

/* ---- Cards ---- */
.card {
  background: var(--paper-raised); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 16px; margin-bottom: 12px;
}
.card-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
}
.card.tappable { display: block; width: 100%; text-align: left; cursor: pointer; }
.card.tappable:active { background: #FBFAF7; }

/* ---- Job list ---- */
.job-card { display: flex; flex-direction: column; gap: 6px; }
.job-card .addr { font-weight: 600; font-size: 16px; }
.job-card .meta { color: var(--muted); font-size: 13px; }
.job-score-pill {
  font-family: var(--font-mono); font-weight: 600; font-size: 13px;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}

.fab {
  position: fixed; right: 20px; bottom: 92px; z-index: 41;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--gold); color: var(--ink); border: none;
  font-size: 28px; box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

/* ---- Forms ---- */
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
  margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.03em;
}
.input, textarea.input, select.input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fff; color: var(--ink);
}
textarea.input { resize: vertical; min-height: 70px; font-family: var(--font-ui); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.seg {
  display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.seg button {
  flex: 1; background: #fff; border: none; padding: 10px 6px; font-size: 13px; font-weight: 600;
  color: var(--muted); border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: none; }
.seg button.on-ok.selected { background: var(--ok-bg); color: var(--ok); }
.seg button.on-concern.selected { background: var(--concern-bg); color: var(--concern); }
.seg button.on-action.selected { background: var(--action-bg); color: var(--action); }
.seg button.on-yes.selected { background: var(--ok-bg); color: var(--ok); }
.seg button.on-no.selected { background: var(--action-bg); color: var(--action); }

/* ---- Buttons ---- */
.btn {
  border: none; border-radius: var(--radius); padding: 12px 18px;
  font-weight: 600; font-size: 15px;
}
.btn.primary { background: var(--ink); color: #fff; }
.btn.gold { background: var(--gold); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn.danger { background: var(--action-bg); color: var(--action); }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; }
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.wrap { flex-wrap: wrap; }
.flex1 { flex: 1; }

/* ---- Principle chip ---- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 600;
  padding: 4px 9px; border-radius: 999px; color: #fff;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,0.85); }

/* ---- Areas / findings ---- */
.area-card { border-left: 4px solid var(--pine); }
.finding-item {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-top: 10px;
}
.finding-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.hazard-tags { display: flex; gap: 6px; margin-top: 8px; }
.tag-toggle {
  font-size: 12px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; color: var(--muted); font-weight: 600;
}
.tag-toggle.on-chronic.selected { background: var(--concern-bg); color: var(--concern); border-color: var(--concern); }
.tag-toggle.on-acute.selected { background: var(--action-bg); color: var(--action); border-color: var(--action); }

/* ---- Photos ---- */
.photo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.photo-thumb { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: #eee; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb button {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(28,43,51,0.85); color: #fff; border: none; font-size: 12px; line-height: 1;
}
.photo-add {
  aspect-ratio: 1; border-radius: 8px; border: 1.5px dashed var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 22px; color: var(--muted); background: #FAFAF7;
}

/* ---- Readings ---- */
.reading-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.reading-row .input { font-family: var(--font-mono); }
.flag {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px;
}
.flag.flag-inrange { background: var(--ok-bg); color: var(--ok); }
.flag.flag-outrange { background: var(--action-bg); color: var(--action); }

/* ---- Standards ---- */
.std-entry { border-bottom: 1px solid var(--line); padding: 12px 0; }
.std-entry:last-child { border-bottom: none; }
.std-title { font-weight: 600; margin-bottom: 3px; }
.std-range { font-family: var(--font-mono); font-size: 12.5px; color: var(--pine); margin-top: 4px; }
.std-source { font-size: 12px; color: var(--muted); margin-top: 4px; }
.search-bar { margin-bottom: 14px; }

/* ---- Score summary ---- */
.score-hero {
  background: var(--ink); color: #fff; border-radius: var(--radius-lg);
  padding: 22px; text-align: center; margin-bottom: 16px;
}
.score-big { font-family: var(--font-mono); font-size: 44px; font-weight: 600; line-height: 1; }
.score-label { color: rgba(255,255,255,0.65); font-size: 12.5px; margin-top: 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.hazard-stats { display: flex; gap: 10px; margin-top: 16px; }
.hazard-stat { flex: 1; background: rgba(255,255,255,0.08); border-radius: 10px; padding: 10px; }
.hazard-stat .n { font-family: var(--font-mono); font-size: 20px; font-weight: 600; }
.hazard-stat .l { font-size: 11px; color: rgba(255,255,255,0.65); text-transform: uppercase; }

/* ---- Modal ---- */
.modal {
  position: fixed; inset: 0; background: rgba(28,43,51,0.55); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-card {
  background: #fff; border-radius: 16px 16px 0 0; padding: 18px; width: 100%; max-width: 640px;
  max-height: 90vh; overflow-y: auto;
}
.modal-card h3 { margin: 0 0 4px; }
#sigCanvas { width: 100%; height: 200px; border: 1px solid var(--line); border-radius: 10px; touch-action: none; background: #fff; margin: 10px 0; }

/* ---- Misc ---- */
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .big { font-size: 34px; margin-bottom: 10px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13.5px; z-index: 70;
}
.checklist-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.checklist-item:last-child { border-bottom: none; }
.checklist-item .yn { display: flex; gap: 6px; }
.yn-btn { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.yn-btn.selected.y { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.yn-btn.selected.n { background: var(--action-bg); color: var(--action); border-color: var(--action); }

@media (min-width: 640px) {
  .top-bar, .bottom-nav { max-width: 640px; left: 50%; transform: translateX(-50%); }
}
