:root {
  --ink: #2b2b2b; --ink2: #4a4642; --mute: #625d56; --bg: #f3f1ec; --card: #fff; --line: #e3dfd6;
  --gold: #f2b01e; --gold-d: #c98d06; --green: #2e7d32; --red: #c62828; --blue: #1e5aa8;
  --r: 16px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- header / nav */
.top { position: sticky; top: 0; z-index: 20; background: var(--ink); color: #fff;
  padding: calc(var(--safe-t) + 8px) 16px 8px; display: flex; align-items: center; gap: 16px; }
.top .brand { height: 34px; }
.net { margin-left: auto; font-size: 14px; font-weight: 600; }
.net.off { background: var(--red); padding: 4px 10px; border-radius: 99px; }
.net.pend { background: var(--gold); color: var(--ink); padding: 4px 10px; border-radius: 99px; }
.tabs { display: flex; }
.tabs a { text-decoration: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 76px; padding: 6px 4px; font-size: 15px; font-weight: 700; color: #e4e0d8; }
.tabs a .ic { font-size: 22px; line-height: 1.1; }
.tabs a.on { color: var(--gold); }
@media (max-width: 799px) {
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--ink); justify-content: space-around;
    padding-bottom: var(--safe-b); border-top: 3px solid var(--gold); z-index: 30; }
  .tabs a { flex: 1; min-height: 64px; min-width: 0; font-size: 14px; }
  main { padding-bottom: calc(96px + var(--safe-b)) !important; }
}
@media (min-width: 800px) {
  .tabs a { flex-direction: row; gap: 6px; font-size: 16px; }
  .tabs a .ic { font-size: 18px; }
}

main { max-width: 1100px; margin: 0 auto; padding: 14px 14px 40px; }
h1 { font-size: 26px; margin: 6px 0 4px; line-height: 1.2; }
h2 { font-size: 19px; margin: 22px 0 8px; display: flex; align-items: center; gap: 8px; }
h2 .r { margin-left: auto; font-size: 15px; }
.sub { color: var(--ink2); margin: 0 0 6px; }
.muted { color: var(--mute); font-size: 16px; }
.row { display: flex; gap: 10px; align-items: center; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.right { text-align: right; }
.hidden { display: none !important; }

/* ---------- buttons */
.btn { display: flex; align-items: center; justify-content: center; gap: 10px; border: 0; border-radius: var(--r);
  min-height: 60px; padding: 12px 18px; font-size: 19px; font-weight: 700; background: var(--card); color: var(--ink);
  box-shadow: 0 1px 0 var(--line), 0 2px 6px rgba(0,0,0,.06); cursor: pointer; text-decoration: none; text-align: center; }
.btn:active { transform: scale(.98); }
.btn .ic { font-size: 26px; }
.btn.gold { background: var(--gold); }
.btn.dark { background: var(--ink); color: #fff; }
.btn.green { background: var(--green); color: #fff; }
.btn.red { background: var(--red); color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; border: 2px solid var(--line); }
.btn.small { min-height: 44px; font-size: 16px; padding: 8px 14px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn.huge { min-height: 96px; font-size: 26px; border-radius: 22px; }
.btn[disabled] { opacity: .5; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tile { flex-direction: column; min-height: 104px; font-size: 17px; gap: 6px; }
.tile .ic { font-size: 34px; }
.linkbtn { background: none; border: 0; color: var(--blue); font-weight: 600; padding: 6px; cursor: pointer; font-size: 16px; }

/* ---------- cards / lists */
.card { background: var(--card); border-radius: var(--r); padding: 14px 16px; box-shadow: 0 1px 0 var(--line); margin-bottom: 10px; }
a.card { display: block; text-decoration: none; }
.jobcard h3 { margin: 0 0 2px; font-size: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 15px; background: var(--bg); border-radius: 99px; padding: 3px 10px; font-weight: 600; color: var(--ink2); }
.chip.gold { background: #fdecc2; color: #7a5600; }
.chip.green { background: #dcefdc; color: var(--green); }
.chip.red { background: #f8dada; color: var(--red); }
.chip.blue { background: #dbe7f7; color: var(--blue); }
.list .item { display: flex; gap: 10px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list .item:last-child { border-bottom: 0; }
.list .item .grow > div:first-child { font-weight: 600; }
.amt { font-weight: 700; white-space: nowrap; }
.seg { display: flex; background: #e6e2d9; border-radius: 14px; padding: 4px; gap: 4px; margin: 10px 0; }
.seg button { flex: 1; border: 0; background: none; border-radius: 10px; min-height: 46px; font-weight: 700; font-size: 16px; color: var(--ink2); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* ---------- on site banner */
.onsite { background: var(--green); color: #fff; border-radius: 22px; padding: 16px; margin-bottom: 14px; }
.onsite .t { font-size: 15px; font-weight: 600; opacity: .9; }
.onsite .j { font-size: 22px; font-weight: 800; margin: 2px 0 2px; }
.onsite .clock { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; }
.checkin-wrap { margin: 14px 0; }

/* ---------- stats */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 800px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--card); border-radius: var(--r); padding: 14px; box-shadow: 0 1px 0 var(--line); }
.stat .l { font-size: 14px; color: var(--ink2); font-weight: 600; }
.stat .v { font-size: 26px; font-weight: 800; margin-top: 2px; }
.stat.red .v { color: var(--red); }
.stat.green .v { color: var(--green); }

/* ---------- forms */
label.f { display: block; margin: 12px 0 0; font-size: 15px; font-weight: 600; color: var(--ink2); }
.in { width: 100%; border: 2px solid var(--line); border-radius: 12px; padding: 12px; font-size: 18px; background: #fff; min-height: 52px; }
.in:focus { outline: none; border-color: var(--gold); }
textarea.in { min-height: 120px; resize: vertical; }
.search { margin: 4px 0 12px; }
.money-in { display: flex; align-items: center; border: 2px solid var(--line); border-radius: 12px; background: #fff; }
.money-in span { padding-left: 12px; font-weight: 700; color: var(--ink2); }
.money-in input { border: 0; min-height: 48px; width: 100%; padding: 10px; font-size: 18px; background: transparent; }
.money-in input:focus { outline: none; }

/* ---------- modal sheet */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(20px + var(--safe-b)); }
@media (min-width: 800px) { .modal { align-items: center; } .sheet { border-radius: 22px; } }
.sheet h2 { margin-top: 0; font-size: 22px; }
.mic { width: 120px; height: 120px; border-radius: 50%; border: 0; background: var(--gold); font-size: 52px; margin: 10px auto; display: block; }
.mic.live { background: var(--red); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(198,40,40,.5)} 70%{box-shadow:0 0 0 22px rgba(198,40,40,0)} 100%{box-shadow:0 0 0 0 rgba(198,40,40,0)} }
.hint { text-align: center; color: var(--ink2); font-size: 15px; }
.spinner { width: 46px; height: 46px; border: 5px solid #ddd; border-top-color: var(--gold); border-radius: 50%; animation: spin 1s linear infinite; margin: 18px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(100px + var(--safe-b)); z-index: 60;
  background: var(--ink); color: #fff; padding: 14px 20px; border-radius: 14px; font-weight: 600; max-width: 92vw; text-align: center;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); }

/* ---------- doc editor */
.line-row { display: grid; grid-template-columns: 1fr 140px 52px; gap: 8px; align-items: start; margin-bottom: 8px; }
.line-row textarea { min-height: 52px; }
.del { border: 0; background: none; font-size: 22px; color: var(--red); min-height: 52px; cursor: pointer; }
.total-box { background: var(--ink); color: #fff; border-radius: var(--r); padding: 14px 16px; margin: 14px 0; }
.total-box .big { font-size: 28px; font-weight: 800; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.thumbs a, .thumbs div { aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #ddd; display: flex; align-items: center;
  justify-content: center; text-align: center; font-size: 12px; padding: 4px; text-decoration: none; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- desktop job layout */
@media (min-width: 900px) {
  .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
  .jobs-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .jobs-grid .card { margin: 0; }
}
.login { max-width: 420px; margin: 8vh auto; }
.login img { width: 220px; display: block; margin: 0 auto 20px; }
table.t { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--r); overflow: hidden; }
table.t td, table.t th { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 15px; }
table.t th { background: #ebe7de; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--ink2); }
table.t td.n, table.t th.n { text-align: right; }
.pending { opacity: .65; font-style: italic; }

/* ---------- review fixes (1 Dec) */
.stat .l { font-size: 15px; }
.linkbtn { font-size: 17px; min-height: 44px; }
.toast { display: flex; align-items: center; gap: 14px; }
.toast-btn { background: var(--gold); color: var(--ink); border: 0; border-radius: 10px; font-weight: 800; font-size: 18px; min-height: 44px; padding: 6px 18px; }
.kbmic { background: #fff; border: 3px dashed var(--gold); border-radius: 16px; padding: 14px; text-align: center; font-size: 19px; font-weight: 700; margin-bottom: 10px; }
.kbmic .kbkey { display: inline-block; background: var(--ink); color: #fff; border-radius: 8px; padding: 0 8px; }
.kbmic small { font-weight: 400; font-size: 15px; color: var(--ink2); }
details.office { margin-top: 26px; }
details.office summary { font-weight: 700; font-size: 17px; padding: 14px; background: #e6e2d9; border-radius: 12px; cursor: pointer; }
details.office .card { margin-top: 10px; }
.del { font-size: 24px; }
/* invoice lines: on phones put the text full width and the price + bin underneath */
@media (max-width: 600px) {
  .line-row { grid-template-columns: 1fr 52px; background: #fff; border-radius: 12px; padding: 8px; }
  .line-row textarea { grid-column: 1 / -1; min-height: 70px; }
}
.seg button { font-size: 16px; }
/* messages sit just under the header so they never cover the big buttons */
.toast { top: calc(var(--safe-t) + 60px); bottom: auto; left: 12px; right: 12px; transform: none; max-width: 640px; margin: 0 auto;
  justify-content: space-between; text-align: left; font-size: 17px; padding: 12px 16px; border-left: 6px solid var(--gold); }
/* places, before/after */
a.card.place { border-left: 6px solid var(--gold); margin: 8px 0 10px; }
.btn.tile.ba { background: #fff7e0; }
.ba-h { font-weight: 800; letter-spacing: .06em; color: var(--ink2); font-size: 14px; margin-bottom: 6px; }
.ba-img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 12px; display: block; }
.ba-del { position: absolute; top: 6px; right: 6px; border: 0; background: rgba(0,0,0,.6); color: #fff; border-radius: 10px; width: 40px; height: 40px; font-size: 22px; }
.where { background: #fff; border: 3px solid var(--gold); border-radius: 18px; padding: 14px; margin-bottom: 14px; }
.where .t { font-size: 14px; font-weight: 800; color: var(--gold-d); letter-spacing: .04em; }
.tabs a { position: relative; }
.tbadge { position: absolute; top: 4px; right: 18%; background: var(--red); color: #fff; border-radius: 99px; font-size: 12px; font-weight: 800; min-width: 20px; height: 20px; line-height: 20px; padding: 0 5px; text-align: center; }
@media (min-width: 800px) { .tbadge { position: static; margin-left: 2px; } }

/* long unbroken words (part numbers, pasted links) must wrap, never widen the phone screen */
h1, h2, .card, .item, .sub, .where, .onsite, .chip, .linkbtn, textarea, .grow { overflow-wrap: anywhere; min-width: 0; }
html, body { max-width: 100%; overflow-x: hidden; }
.btn { white-space: normal; overflow-wrap: anywhere; max-width: 100%; min-width: 0; text-align: center; }
.row > *, .grid2 > *, .grid3 > * { min-width: 0; }

/* 'To get' list on a job: big tick boxes for dusty thumbs */
.list .item.need { align-items: center; }
.need .tick { flex: none; width: 48px; height: 48px; border-radius: 12px; border: 3px solid var(--mute); background: #fff;
  font-size: 28px; font-weight: 800; color: #fff; line-height: 1; padding: 0; }
.need.got .tick { background: var(--green); border-color: var(--green); }
.need .grow { cursor: pointer; padding: 6px 0; }
.need.got .grow > div:first-child { text-decoration: line-through; color: #888; font-weight: 400; }
