/* Escape Field App — built for a phone, in a truck, in sunlight, with gloves on.
   Brand: near-black #171205, gold #B8860B/#E4BA55, cream #FBF3DD. */

:root {
  --ink: #171205;
  --ink-2: #241d0c;
  --ink-3: #322912;
  --gold: #B8860B;
  --gold-lt: #E4BA55;
  --gold-dk: #8F6A08;
  --cream: #FBF3DD;
  --cream-dim: #C9C0A8;
  --muted: #9C9484;
  --ok: #4ea36a;
  --warn: #d98324;
  --bad: #c0453c;
  --tap: 56px;              /* nothing interactive is smaller than this */
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--ink);
  color: var(--cream);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overscroll-behavior-y: contain;
}

body { padding-bottom: env(safe-area-inset-bottom); }

.app { max-width: 640px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

/* ------------------------------------------------------------------ header */
header {
  position: sticky; top: 0; z-index: 20;
  background: var(--ink);
  border-bottom: 1px solid var(--ink-3);
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  display: flex; align-items: center; gap: 12px;
}
.brand { font-weight: 700; letter-spacing: .14em; font-size: 15px; color: var(--gold-lt); text-transform: uppercase; }
.spacer { flex: 1; }

.sync {
  font-size: 12px; padding: 6px 10px; border-radius: 999px;
  background: var(--ink-2); color: var(--cream-dim); border: 1px solid var(--ink-3);
  white-space: nowrap;
}
.sync.pending { color: #1d1607; background: var(--gold-lt); border-color: var(--gold-lt); font-weight: 700; }
.sync.offline { color: #fff; background: var(--bad); border-color: var(--bad); font-weight: 700; }

/* -------------------------------------------------------------------- main */
main { flex: 1; padding: 14px 16px 96px; }
h1 { font-size: 21px; margin: 4px 0 2px; }
.sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }

/* ------------------------------------------------------------------- cards */
.job {
  display: block; width: 100%; text-align: left;
  background: var(--ink-2); border: 1px solid var(--ink-3);
  border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
  color: inherit; font: inherit; cursor: pointer;
}
.job:active { background: var(--ink-3); }
.job-top { display: flex; align-items: flex-start; gap: 10px; }
.job-name { font-weight: 700; font-size: 17px; flex: 1; }
.job-meta { color: var(--muted); font-size: 14px; margin-top: 4px; }

.chip {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  padding: 5px 9px; border-radius: 999px; white-space: nowrap;
  background: var(--ink-3); color: var(--cream-dim);
}
.chip.on_my_way { background: var(--warn); color: #241a06; }
.chip.onsite, .chip.in_progress { background: var(--gold-lt); color: #241a06; }
.chip.complete { background: var(--ok); color: #06210f; }
.chip.cancelled { background: var(--bad); color: #fff; }
.chip.needs_return_visit { background: var(--gold-dk); color: #fff; }

/* ----------------------------------------------------------------- buttons */
button, .btn {
  min-height: var(--tap); border-radius: var(--radius); border: 0;
  font: inherit; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary { background: var(--gold); color: #1a1305; width: 100%; }
.btn-primary:active { background: var(--gold-dk); }
.btn-primary:disabled { background: var(--ink-3); color: var(--muted); }
.btn-ghost {
  background: transparent; color: var(--cream);
  border: 1px solid var(--ink-3); width: 100%;
}
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }

.actions { display: grid; gap: 10px; margin: 18px 0; }
.action { background: var(--ink-2); color: var(--cream); border: 1px solid var(--gold-dk); width: 100%; }
.action.next { background: var(--gold); color: #1a1305; border-color: var(--gold); font-size: 18px; min-height: 64px; }
.action:disabled { opacity: .4; }

/* ------------------------------------------------------------------ inputs */
input, textarea {
  width: 100%; min-height: var(--tap); padding: 14px;
  background: var(--ink-2); border: 1px solid var(--ink-3); border-radius: var(--radius);
  color: var(--cream); font: inherit;
}
input:focus, textarea:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }

/* ------------------------------------------------------------------ detail */
.panel {
  background: var(--ink-2); border: 1px solid var(--ink-3);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--gold-lt); margin: 0 0 10px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--ink-3); }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); font-size: 14px; }
.kv span:last-child { text-align: right; }

.back {
  background: none; color: var(--gold-lt); padding: 0; min-height: 40px;
  justify-content: flex-start; font-size: 15px;
}

/* ---------------------------------------------------------------- tab bar */
nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--ink-2); border-top: 1px solid var(--ink-3);
  padding-bottom: env(safe-area-inset-bottom);
  max-width: 640px; margin: 0 auto;
}
nav.tabs button {
  background: none; color: var(--muted); min-height: 62px;
  flex-direction: column; gap: 3px; font-size: 12px; font-weight: 600;
}
nav.tabs button.on { color: var(--gold-lt); }
nav.tabs .ico { font-size: 20px; }

/* ------------------------------------------------------------- pricebook */
.crumb { color: var(--gold-lt); font-size: 14px; margin-bottom: 10px; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--ink-2); border: 1px solid var(--ink-3);
  border-radius: var(--radius); padding: 14px; margin-bottom: 8px;
  color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.row:active { background: var(--ink-3); }
.row .grow { flex: 1; min-width: 0; }
.row .nm { font-weight: 600; }
.row .px { font-weight: 700; color: var(--gold-lt); white-space: nowrap; }
.row .sub2 { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* -------------------------------------------------------------- utilities */
.empty { text-align: center; color: var(--muted); padding: 48px 20px; }
.stale { background: var(--warn); color: #241a06; font-weight: 700;
         padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; font-size: 14px; }
.err { background: var(--bad); color: #fff; padding: 12px 14px; border-radius: var(--radius); margin: 10px 0; }
.center { min-height: 70vh; display: flex; flex-direction: column; justify-content: center; }
.hide { display: none !important; }

@media (prefers-reduced-motion: no-preference) {
  .job, .row { transition: background .12s ease; }
}

/* Offers — the tech raises a flag, the shop's automation sends the link. */
.offers { display: grid; gap: 8px; }
.offers button { min-height: 52px; }
.row .px.bad { color: var(--bad); font-size: 13px; }

/* Three tabs now: My Day · Clients · Pricebook */
nav.tabs { grid-template-columns: 1fr 1fr 1fr; }

/* Quantity stepper in the estimate/invoice builder. Big targets — this gets
   used with gloves on, standing up, one-handed. */
.row.builder { align-items: center; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 46px; min-height: 46px; border-radius: 10px;
  background: var(--ink-3); color: var(--gold-lt); font-size: 22px; font-weight: 700;
}
.stepper button:disabled { opacity: .3; }
.stepper .qty {
  min-width: 30px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------- job screen tab bar */
.jobtabs {
  display: flex; gap: 6px; overflow-x: auto; margin: 14px 0 16px;
  padding-bottom: 4px; scrollbar-width: none;
}
.jobtabs::-webkit-scrollbar { display: none; }
.jobtabs button {
  min-height: 44px; padding: 0 16px; border-radius: 999px; white-space: nowrap;
  background: var(--ink-2); color: var(--cream-dim);
  border: 1px solid var(--ink-3); font-size: 14px; font-weight: 600;
}
.jobtabs button.on { background: var(--gold); color: #1a1305; border-color: var(--gold); }

/* Customer stays pinned while the tabs change underneath it. */
.customer-head {
  position: sticky; top: 0; z-index: 10;
  background: var(--ink); padding-bottom: 8px;
  border-bottom: 1px solid var(--ink-3); margin-bottom: 4px;
}

/* Conversations */
.msg { max-width: 82%; padding: 10px 13px; border-radius: 16px; margin-bottom: 8px; font-size: 15px; }
.msg.in  { background: var(--ink-2); border: 1px solid var(--ink-3); border-bottom-left-radius: 5px; }
.msg.out { background: var(--gold-dk); color: #fff; margin-left: auto; border-bottom-right-radius: 5px; }
.msg.call { background: transparent; border: 1px dashed var(--ink-3); color: var(--muted);
            font-size: 13px; text-align: center; max-width: 100%; }
.msg .when { display: block; font-size: 11px; opacity: .7; margin-top: 4px; }
.composer { display: flex; gap: 8px; align-items: flex-end; margin-top: 12px; }
.composer textarea { flex: 1; min-height: 52px; }
.composer button { width: 84px; }

/* Membership */
.badge {
  display: inline-block; padding: 6px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 700; margin-right: 8px;
}
.badge.on  { background: var(--ok); color: #06210f; }
.badge.off { background: var(--ink-3); color: var(--muted); }
select {
  width: 100%; min-height: var(--tap); padding: 14px;
  background: var(--ink-2); border: 1px solid var(--ink-3);
  border-radius: var(--radius); color: var(--cream); font: inherit;
}
.check { display: flex; align-items: center; gap: 12px; min-height: 52px; }
.check input[type=checkbox] { width: 26px; height: 26px; min-height: 26px; accent-color: var(--gold); }

/* Equipment cards */
.unit { background: var(--ink-2); border: 1px solid var(--ink-3);
        border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.unit .t { font-weight: 700; margin-bottom: 6px; }
