:root {
  --pine: #1e3d2b;
  --pine-deep: #142a1e;
  --pine-soft: #2c5440;
  --cream: #f7f2e3;
  --cream-dark: #ece3cb;
  --paper: #fffdf6;
  --ink: #22281f;
  --muted: #6d7263;
  --rust: #c2703d;
  --rust-dark: #a05728;
  --moss: #5c7a5e;
  --line: #d9d0b8;
  --danger: #a63d2f;
  --ok: #2f6f4f;
  --radius: 14px;
  --tap: 48px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; font-size: 16px; }
button { touch-action: manipulation; cursor: pointer; }
a { color: var(--pine); }
svg { vertical-align: -0.12em; }

/* ---------- App frame ---------- */
.app { max-width: 720px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  background: var(--pine);
  color: var(--cream);
  padding: 14px 16px 10px;
  position: sticky; top: 0; z-index: 20;
  box-shadow: 0 2px 10px rgba(20,42,30,.25);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand h1 { font-size: 20px; margin: 0; letter-spacing: .5px; font-weight: 800; }
.brand small { display: block; font-size: 11px; font-weight: 600; letter-spacing: 2px; opacity: .75; }
.tabs { display: flex; gap: 6px; margin-top: 10px; }
.tab {
  flex: 1; min-height: var(--tap);
  background: transparent; border: 2px solid transparent; border-radius: 10px;
  color: var(--cream); font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  opacity: .75;
}
.tab svg { width: 18px; height: 18px; }
.tab.active { background: rgba(247,242,227,.14); border-color: rgba(247,242,227,.35); opacity: 1; }
main { flex: 1; padding: 14px 14px 90px; }

/* ---------- Cards / sections ---------- */
.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(34,40,31,.06);
}
.card h2 { margin: 0 0 10px; font-size: 15px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--pine); }
.card h3 { margin: 14px 0 8px; font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; }
.muted { color: var(--muted); font-size: 14px; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- Buttons ---------- */
.btn {
  min-height: var(--tap); padding: 12px 18px; border-radius: 12px;
  border: 2px solid var(--pine); background: var(--pine); color: var(--cream);
  font-weight: 800; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn svg { width: 19px; height: 19px; }
.btn.block { width: 100%; }
.btn.secondary { background: transparent; color: var(--pine); }
.btn.rust { background: var(--rust); border-color: var(--rust); }
.btn.rust:active { background: var(--rust-dark); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.small { min-height: 40px; padding: 8px 12px; font-size: 14px; }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn:disabled { opacity: .45; }

/* ---------- Status pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
  padding: 5px 11px; border-radius: 999px; white-space: nowrap;
}
.pill.scheduled { background: #efe3c2; color: #7a5c14; }
.pill.enroute { background: #f5d9b8; color: #8a4d12; }
.pill.onsite { background: #d7e8d2; color: #2f6f4f; }
.pill.complete { background: var(--pine); color: var(--cream); }
.pill.sample { background: #e3e3e3; color: #555; }

/* ---------- Job board ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; }
.chip {
  flex: none; min-height: 44px; padding: 10px 16px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--paper); font-weight: 700; font-size: 14px; color: var(--ink);
}
.chip.active { background: var(--pine); border-color: var(--pine); color: var(--cream); }
.jobcard { display: block; width: 100%; text-align: left; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.jobcard .jc-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.jobcard .jc-name { font-weight: 800; font-size: 17px; }
.jobcard .jc-rv { color: var(--muted); font-size: 14px; margin-bottom: 4px; }
.jobcard .jc-rv svg { width: 16px; height: 16px; vertical-align: -3px; }
.jobcard .jc-meta { display: flex; gap: 12px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.jobcard .jc-meta span { display: inline-flex; align-items: center; gap: 5px; }
.jobcard .jc-meta svg { width: 14px; height: 14px; }
.empty { text-align: center; padding: 34px 20px; color: var(--muted); }
.empty svg { width: 44px; height: 44px; opacity: .4; margin-bottom: 10px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; color: var(--pine); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; min-height: var(--tap); padding: 12px 14px;
  border: 2px solid var(--line); border-radius: 10px; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--pine); }
.field textarea { min-height: 84px; resize: vertical; }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.f3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* ---------- Lists (parts, labor, photos) ---------- */
.item { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: none; }
.item .grow .t { font-weight: 700; }
.item .grow .s { font-size: 13px; color: var(--muted); }
.iconbtn {
  width: var(--tap); height: var(--tap); flex: none; border-radius: 10px;
  border: 2px solid var(--line); background: #fff; display: inline-flex; align-items: center; justify-content: center;
}
.iconbtn svg { width: 20px; height: 20px; }
.iconbtn.danger { color: var(--danger); border-color: #e5c4bd; }
.total { display: flex; justify-content: space-between; font-weight: 800; font-size: 17px; padding: 12px 0 2px; }

/* ---------- Photos ---------- */
.photogrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.photo { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); aspect-ratio: 1; background: var(--cream-dark); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .cap { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(20,42,30,.82); color: var(--cream); font-size: 11px; padding: 4px 6px; }
.photo .del { position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border-radius: 8px; border: none; background: rgba(20,42,30,.8); color: #fff; font-size: 15px; line-height: 1; }
.tagbtns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tagbtn { min-height: 40px; padding: 6px 12px; border-radius: 999px; border: 2px solid var(--line); background: #fff; font-size: 13px; font-weight: 700; }
.tagbtn.sel { border-color: var(--pine); background: var(--pine); color: var(--cream); }

/* ---------- Timer ---------- */
.timerbar { display: flex; align-items: center; gap: 10px; background: var(--pine); color: var(--cream); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.timerbar .time { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.timerbar .btn { margin-left: auto; }

/* ---------- Signature ---------- */
.sigpad { width: 100%; height: 150px; border: 2px dashed var(--line); border-radius: 10px; background: #fff; touch-action: none; }
.sigwrap { position: relative; }
.sigwrap .clear { position: absolute; top: 8px; right: 8px; }

/* ---------- Packet (screen) ---------- */
.packet { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 20px 18px; }
.packet .p-head { border-bottom: 3px solid var(--pine); padding-bottom: 12px; margin-bottom: 14px; }
.packet .p-head h2 { margin: 0; font-size: 22px; color: var(--pine); }
.packet .p-sec { margin-bottom: 16px; }
.packet .p-sec h4 { margin: 0 0 8px; font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--pine); border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.packet table { width: 100%; border-collapse: collapse; font-size: 14px; }
.packet th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 6px 4px; border-bottom: 1px solid var(--line); }
.packet td { padding: 7px 4px; border-bottom: 1px solid #eee5cf; vertical-align: top; }
.packet .r { text-align: right; font-variant-numeric: tabular-nums; }
.packet .p-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.packet .p-photos figure { margin: 0; }
.packet .p-photos img { width: 100%; border-radius: 6px; border: 1px solid var(--line); display: block; }
.packet .p-photos figcaption { font-size: 12px; color: var(--muted); padding: 4px 2px; }
.packet .sigimg { max-width: 260px; border-bottom: 1px solid var(--ink); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 10px; font-size: 14px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; }

/* ---------- Dashboard ---------- */
.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .v { font-size: 26px; font-weight: 800; color: var(--pine); font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 130px; padding-top: 10px; }
.bar { flex: 1; background: var(--pine-soft); border-radius: 5px 5px 0 0; min-height: 4px; position: relative; }
.bar span { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); }

/* ---------- Reminders ---------- */
.rem { display: flex; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rem:last-child { border: none; }
.rem .grow { min-width: 0; }
.rem .iconbtn, .rem a.iconbtn { flex: none; }
.duebadge { flex: none; }
.duebadge { flex: none; width: 58px; text-align: center; border-radius: 10px; padding: 8px 4px; font-weight: 800; font-size: 12px; line-height: 1.25; }
.duebadge.over { background: #f3d9d2; color: var(--danger); }
.duebadge.soon { background: #f5e8c8; color: #7a5c14; }
.duebadge.ok { background: #d7e8d2; color: #2f6f4f; }

/* ---------- Misc ---------- */
.backlink { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; color: var(--pine); font-weight: 800; min-height: 44px; padding: 6px 0; font-size: 15px; }
.backlink svg { width: 18px; height: 18px; }
.sectionhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sectionhead h2 { margin: 0; font-size: 22px; color: var(--pine); font-weight: 800; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--pine-deep); color: var(--cream); padding: 13px 20px; border-radius: 12px;
  font-weight: 700; opacity: 0; transition: all .25s; z-index: 100; pointer-events: none;
  max-width: calc(100vw - 40px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.fab {
  position: fixed; right: 18px; bottom: 20px; width: 62px; height: 62px; border-radius: 50%;
  background: var(--rust); border: none; color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(194,112,61,.5); z-index: 30;
}
.fab svg { width: 28px; height: 28px; }
.hiddenfile { display: none; }
.steprow { display: flex; gap: 8px; margin: 12px 0; }
.stepbtn { flex: 1; min-height: 52px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font-weight: 800; font-size: 13px; color: var(--muted); }
.stepbtn.done { border-color: var(--pine); background: var(--pine); color: var(--cream); }
.stepbtn.now { border-color: var(--rust); color: var(--rust); }

@media print {
  .topbar, .noprint, .fab, .toast, .backlink { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .packet { border: none; }
}

/* sample banner */
.samplebar { background: #e8e2cf; border: 1px dashed var(--muted); border-radius: 10px; padding: 10px 14px; font-size: 13px; color: var(--muted); margin-bottom: 12px; display: flex; gap: 10px; align-items: center; }
.samplebar svg { width: 24px; height: 24px; flex: none; }
.samplebar button { margin-left: auto; }
