/* Max Tech — field-ticket look: warm neutral ground, ink text, safety-orange actions */
:root {
  --brand: #C2410C;
  --brand-press: #A8380A;
  --ink: #16181B;
  --ground: #F4F2EE;
  --muted: #5E5A53;
  --line: #DEDAD2;
  --line-strong: #CFCAC0;
  --fill: #E7E3DB;
  --dashed: #A8A298;
  --blue-bg: #E3ECF8; --blue: #1D4E89;
  --orange-bg: #FCE7D6; --orange: #9A3412;
  --green-bg: #DCEFE2; --green: #1E6B3A;
  --red: #B42318;
  --card: #FFFFFF;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font: 16px/1.4 var(--font);
  min-height: 100vh; min-height: 100dvh;
}
body.modal-open { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--ink); }
hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; width: 100%; }
[hidden] { display: none !important; }
.ic { flex-shrink: 0; }
:focus-visible { outline: 3px solid rgba(194, 65, 12, 0.45); outline-offset: 2px; }

/* ---------- layout ---------- */
#app { max-width: 560px; margin: 0 auto; }
.screen {
  display: flex; flex-direction: column; gap: 16px;
  padding: calc(16px + var(--safe-t)) 20px calc(100px + var(--safe-b));
}
.topbar + .screen { padding-top: 8px; }
.screen.has-bottom { padding-bottom: calc(120px + var(--safe-b)); }
.center-screen { min-height: 80vh; align-items: center; justify-content: center; text-align: center; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.stack-xs { display: flex; flex-direction: column; gap: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grow { flex: 1 1 auto; }
.push-bottom { margin-top: auto; }

.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding-top: 8px; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: calc(6px + var(--safe-t)) 12px 6px; background: rgba(244, 242, 238, 0.94);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.back { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; color: var(--brand); font-weight: 600; justify-self: start; }
.topbar-title { font-weight: 600; font-family: var(--mono); font-size: 15px; }
.topbar-right { justify-self: end; }

/* ---------- type ---------- */
.h1 { margin: 0; font-size: 32px; line-height: 1.1; font-weight: 800; letter-spacing: -0.02em; }
.h1-md { font-size: 28px; }
.h1-sm { font-size: 24px; }
.h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.lbl { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.lbl-row { display: flex; align-items: center; justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 14px; }
.center { text-align: center; align-self: center; }
.pre { white-space: pre-line; margin: 0; }
.ok-text { color: var(--green); margin: 0; text-align: center; }
.warn-text { display: flex; gap: 8px; align-items: flex-start; color: var(--orange); font-size: 14px; margin: 0; }
.hint { font-size: 13px; color: var(--muted); text-align: center; }
.foot { text-align: center; font-size: 13px; }
.sub { font-size: 14px; font-weight: 600; }

/* ---------- cards & chips ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: block; }
.card.hl { border: 2px solid var(--brand); padding: 15px; }
.card.rows { padding: 0; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; font-size: 15px; border-top: 1px solid #EEEAE3; min-height: 48px; }
.row:first-child { border-top: 0; }
.row .muted { flex-shrink: 0; }
.row .val { margin-left: auto; font-weight: 600; text-align: right; }
.row-btn { display: flex; width: 100%; align-items: center; justify-content: center; gap: 8px; min-height: 52px; border-top: 1px solid #EEEAE3; color: var(--brand); font-weight: 600; font-size: 15px; }
.rows > .row-btn:first-child { border-top: 0; }
.pad { padding: 16px; margin: 0; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--fill); color: var(--ink); white-space: nowrap; }
.chip.dark { background: var(--ink); color: #fff; }
.chip.orange { background: var(--orange-bg); color: var(--orange); }
.chip.blue { background: var(--blue-bg); color: var(--blue); }
.chip.green { background: var(--green-bg); color: var(--green); }

.jobcard { display: flex; flex-direction: column; gap: 8px; }
.jobcard:active { background: #FBFAF7; }
.jc-top { display: flex; align-items: center; gap: 8px; }
.jc-title { font-size: 18px; font-weight: 600; line-height: 1.3; }
.jc-desc { font-size: 14px; color: var(--muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.jc-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; min-width: 0; }
.jc-meta span:first-child { white-space: nowrap; }
.jc-meta span { display: inline-flex; align-items: center; gap: 6px; }
.ell { min-width: 0; overflow: hidden; }
.jc-assignee, .assignee { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.assignee { font-size: 15px; color: var(--ink); }
.jc-assignee.warn, .assignee.warn { color: var(--orange); }

.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--ink); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 15px; flex-shrink: 0; }
.avatar.sm { width: 36px; height: 36px; font-size: 13px; }
.avatar.lg { width: 56px; height: 56px; font-size: 18px; }
.avatar.light { background: var(--fill); color: var(--ink); }

/* ---------- buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 54px; padding: 0 18px; border-radius: var(--radius);
  font-weight: 600; font-size: 17px; text-align: center; width: 100%;
}
.btn.sm { min-height: 48px; font-size: 15px; }
.btn.auto { width: auto; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:active { background: var(--brand-press); }
.btn.dark { background: var(--ink); color: #fff; }
.btn.secondary { background: #fff; border: 1px solid var(--line-strong); }
.btn.secondary:active { background: var(--fill); }
.btn.danger { background: var(--red); color: #fff; }
.btn.danger-outline { background: #fff; border: 1px solid #F1C4BE; color: var(--red); }
.btn:disabled { opacity: 0.45; cursor: default; }
.link { color: var(--brand); font-weight: 600; font-size: 15px; min-height: 40px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; border-radius: 22px; }
.icon-btn.muted { color: var(--muted); min-width: 36px; }

.seg { display: flex; gap: 4px; padding: 4px; background: var(--fill); border-radius: 12px; }
.seg button { flex: 1 1 0; min-height: 44px; border-radius: 9px; font-size: 14px; font-weight: 600; padding: 0 6px; }
.seg button.on { background: var(--ink); color: #fff; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: #fff; font-size: 14px; font-weight: 600; }
.pill.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.pick { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 8px 14px; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); text-align: left; }
.pick.on { border: 2px solid var(--brand); padding: 7px 13px; color: var(--ink); }
.pick.on .ic { color: var(--brand); }
.pick .grow { display: flex; flex-direction: column; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.field input, .field textarea, .field select {
  width: 100%; min-height: 52px; padding: 12px 16px; border-radius: var(--radius);
  border: 1px solid var(--line); background: #fff; font-size: 16px; appearance: none; -webkit-appearance: none;
}
.field select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.field textarea { resize: vertical; line-height: 1.45; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(194, 65, 12, 0.15); }
.toggle { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 15px; }
.toggle input { width: 22px; height: 22px; accent-color: var(--brand); }

/* ---------- login ---------- */
.login { padding-top: calc(56px + var(--safe-t)); }
.brand { font-size: 12px; font-weight: 800; letter-spacing: 0.14em; color: var(--brand); }

/* ---------- details ---------- */
.site { display: flex; flex-direction: column; gap: 12px; }
.site-name { font-size: 17px; font-weight: 600; }
.scope { display: flex; flex-direction: column; gap: 10px; }
.scope-item { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.scope-item .ic { color: var(--dashed); margin-top: 2px; }
.scope-item.done .ic { color: var(--green); }
.sigimg img { max-width: 100%; max-height: 120px; display: block; margin: 0 auto; }

/* ---------- work ---------- */
.timer { display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: 16px; background: var(--ink); color: #fff; }
.timer-l { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.timer-lbl { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; color: #C9C4BA; }
.timer-val { font-size: 32px; font-weight: 600; font-variant-numeric: tabular-nums; }
.timer-sub { font-size: 13px; color: #C9C4BA; }
.timer-btn { width: 56px; height: 56px; border-radius: 50%; background: #fff; color: var(--ink); display: flex; align-items: center; justify-content: center; }
.check { display: flex; width: 100%; align-items: center; gap: 12px; padding: 13px 16px; border-top: 1px solid #EEEAE3; text-align: left; font-size: 15px; min-height: 52px; }
.rows > .check:first-child { border-top: 0; }
.check .box { width: 26px; height: 26px; border-radius: 7px; border: 2px solid var(--dashed); display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: #fff; color: #fff; }
.check.done .box { background: var(--green); border-color: var(--green); }
.check.done .check-text { color: var(--muted); text-decoration: line-through; }
.photos { display: flex; gap: 8px; flex-wrap: wrap; }
.thumb { position: relative; width: 76px; height: 76px; }
.thumb-img { width: 76px; height: 76px; border-radius: 10px; overflow: hidden; background: var(--fill); display: block; }
.thumb-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-del { position: absolute; top: -6px; right: -6px; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; }
.addphoto { display: flex; gap: 8px; }
.add-tile { width: 76px; height: 76px; border-radius: 10px; border: 1.5px dashed var(--dashed); color: var(--brand); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 600; }
.add-tile.busy { width: 160px; color: var(--muted); border-style: solid; }

/* ---------- sign-off ---------- */
.sigpad { position: relative; height: 180px; border-radius: var(--radius); background: #fff; border: 1.5px dashed var(--dashed); overflow: hidden; }
.sigpad canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; z-index: 2; }
.sig-hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); pointer-events: none; }
.sig-line { position: absolute; left: 20px; right: 20px; bottom: 34px; height: 1px; background: var(--line); pointer-events: none; }

/* ---------- done ---------- */
.done-screen { min-height: 100vh; min-height: 100dvh; padding-top: calc(56px + var(--safe-t)); padding-bottom: calc(28px + var(--safe-b)); }
.done-top { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.done-check { width: 88px; height: 88px; border-radius: 50%; background: var(--green); color: #fff; display: flex; align-items: center; justify-content: center; }
.done-screen p { margin: 0; max-width: 320px; }

/* ---------- dispatch ---------- */
.stat { display: flex; flex-direction: column; gap: 2px; padding: 14px; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); font-size: 13px; }
.stat.hl { border: 2px solid var(--brand); padding: 13px; }
.stat-v { font-size: 26px; font-weight: 600; }
.orange-t { color: var(--orange); } .green-t { color: var(--green); }
.tech { gap: 12px; }
.tech-info { display: flex; flex-direction: column; flex: 1; min-width: 0; font-size: 15px; }
.tech-info .muted { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- profile ---------- */
.me { display: flex; align-items: center; gap: 14px; }
.role { color: var(--brand); font-size: 13px; font-weight: 600; }
.card p { margin: 0; }

/* ---------- bars ---------- */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 14px 20px calc(14px + var(--safe-b)); background: #fff; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px; align-items: stretch;
}
.bottombar > * { max-width: 520px; margin: 0 auto; width: 100%; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  padding: 8px 8px calc(8px + var(--safe-b)); background: #fff; border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 84px; min-height: 48px; font-size: 11px; font-weight: 600; color: var(--muted); justify-content: center; }
.tabbar a.on { color: var(--brand); }

.banner { display: flex; align-items: center; gap: 10px; padding: 10px 6px 10px 14px; border-radius: var(--radius); background: var(--blue-bg); color: var(--blue); font-size: 14px; }
.banner span { flex: 1; }
.donebar { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: var(--radius); background: var(--green-bg); color: var(--green); font-weight: 600; font-size: 15px; width: 100%; text-align: left; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 48px 20px; text-align: center; color: var(--muted); }
.empty strong { color: var(--ink); }
.empty.small { padding: 24px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(22, 24, 27, 0.45); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out; }
.sheet { position: relative; width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; background: var(--ground); border-radius: 20px 20px 0 0; padding: 24px 20px calc(24px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; animation: up .2s ease-out; }
.sheet-close { position: absolute; top: 12px; right: 12px; background: var(--fill); }
.photo-modal { background: rgba(0, 0, 0, 0.92); align-items: center; }
.photo-modal img { max-width: 100%; max-height: 90vh; object-fit: contain; }
.photo-loading { position: absolute; bottom: calc(24px + var(--safe-b)); left: 0; right: 0; text-align: center; color: #fff; font-size: 14px; }
.toast.info { background: var(--blue); }
.close-photo { position: absolute; top: calc(12px + var(--safe-t)); right: 12px; color: #fff; background: rgba(255,255,255,0.15); }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--safe-b)); z-index: 60; max-width: calc(100% - 40px); padding: 12px 16px; border-radius: 12px; background: var(--ink); color: #fff; font-size: 15px; box-shadow: 0 8px 24px rgba(0,0,0,0.18); animation: fade .15s ease-out; }
.toast.error { background: var(--red); }

.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--fill); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
@media (min-width: 600px) { .modal { align-items: center; } .sheet { border-radius: 20px; } }
