:root {
  --navy: #14213d;
  --navy-2: #22335a;
  --amber: #f5a524;
  --amber-ink: #3a2500;
  --bg: #f3f4f6;
  --card: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --danger: #c0262d;
  --ok: #15803d;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { min-height: 100vh; padding-bottom: calc(72px + var(--safe-bot)); }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
button { font: inherit; color: inherit; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: var(--navy); color: #fff;
}
.topbar h1 { flex: 1; margin: 0; font-size: 19px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: none; border: 0; color: inherit; padding: 6px; margin-left: -6px; display: grid; place-items: center; }
.sync-pill {
  border: 0; border-radius: 999px; padding: 6px 11px; font-size: 13px; font-weight: 600;
  background: var(--navy-2); color: #dbe3f5; white-space: nowrap;
}
.sync-pill.warn { background: var(--amber); color: var(--amber-ink); }
.sync-pill.ok::before { content: "● "; color: #4ade80; }

.banner {
  margin: 10px 14px 0; padding: 12px 14px; border-radius: var(--radius);
  background: #fff7e6; border: 1px solid #f5d38f; color: #5c3b00; font-size: 15px;
  display: flex; align-items: center; gap: 10px;
}
.banner button { margin-left: auto; }

main { padding: 14px; max-width: 760px; margin: 0 auto; }

/* ---------- bottom tabs ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bot);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 0 8px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600;
}
.tabbar a.active { color: var(--navy); }
.tabbar a.active svg { stroke: var(--navy); }

/* ---------- common bits ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 0;
  background: var(--navy); color: #fff; font-size: 16px; font-weight: 650; cursor: pointer;
}
.btn.secondary { background: #fff; color: var(--navy); border: 1.5px solid var(--navy); }
.btn.ghost { background: transparent; color: var(--navy); }
.btn.danger { background: #fff; color: var(--danger); border: 1.5px solid #f1b5b8; }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }

.camera-btn {
  width: 100%; min-height: 72px; border: 0; border-radius: 18px;
  background: var(--amber); color: var(--amber-ink);
  font-size: 20px; font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 12px;
  box-shadow: 0 2px 0 #c9861a;
}
.camera-btn svg { width: 30px; height: 30px; stroke-width: 2.2; }

.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); }
.list { list-style: none; margin: 0; padding: 0; }
.list li + li { border-top: 1px solid var(--line); }
.row {
  display: flex; align-items: center; gap: 12px; padding: 14px; text-decoration: none; color: inherit; width: 100%;
  background: none; border: 0; text-align: left;
}
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 650; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { color: var(--muted); font-size: 14px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .chev { color: #c0c4cc; }
.thumb-mini { width: 54px; height: 54px; border-radius: 10px; background: #e7e9ee center/cover no-repeat; flex: none; }

.toolbar { display: flex; gap: 10px; margin-bottom: 12px; }
.search {
  flex: 1; min-height: 46px; border-radius: 12px; border: 1px solid var(--line); background: #fff;
  padding: 0 14px; font-size: 16px;
}
.seg { display: flex; background: #e5e7eb; border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.section-h { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 20px 4px 8px; }
.empty { text-align: center; color: var(--muted); padding: 34px 16px; }
.empty b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 6px; }

.badge { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: #e0f2e9; color: var(--ok); white-space: nowrap; }
.badge.closed { background: #eceef2; color: var(--muted); }
.badge.wait { background: #fff1d6; color: #8a5300; }

/* ---------- project header ---------- */
.proj-head { padding: 16px; margin-bottom: 14px; }
.proj-head .cust { color: var(--muted); font-weight: 600; font-size: 14px; }
.proj-head h2 { margin: 2px 0 8px; font-size: 22px; }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 12px;
  border-radius: 10px; background: #eef1f7; color: var(--navy); text-decoration: none; font-size: 14px; font-weight: 600; border: 0;
}
.chip svg { width: 18px; height: 18px; }
.notes { white-space: pre-wrap; color: #374151; font-size: 15px; margin-top: 10px; }

/* ---------- photo grid ---------- */
.day-h { font-size: 14px; font-weight: 700; margin: 18px 2px 8px; color: #374151; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.tile {
  position: relative; aspect-ratio: 1; border: 0; padding: 0; border-radius: 8px; overflow: hidden;
  background: #dde1e8 center/cover no-repeat;
}
.tile .time { position: absolute; left: 4px; bottom: 4px; font-size: 11px; font-weight: 700; color: #fff; background: rgba(0,0,0,.55); padding: 2px 5px; border-radius: 5px; }
.tile .flag { position: absolute; right: 4px; top: 4px; width: 20px; height: 20px; border-radius: 50%; background: var(--amber); display: grid; place-items: center; }
.tile .flag svg { width: 13px; height: 13px; stroke: var(--amber-ink); stroke-width: 3; }
.tile .note-dot { position: absolute; right: 4px; bottom: 4px; width: 18px; height: 18px; border-radius: 50%; background: rgba(0,0,0,.55); display: grid; place-items: center; }
.tile .note-dot svg { width: 11px; height: 11px; stroke: #fff; stroke-width: 3; }

/* ---------- photo viewer ---------- */
.viewer { background: #000; margin: -14px -14px 0; min-height: 50vh; display: grid; place-items: center; position: relative; }
.viewer img { max-width: 100%; max-height: 70vh; display: block; }
.viewer .nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,.45); border: 0; color: #fff; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; }
.viewer .nav.l { left: 8px; } .viewer .nav.r { right: 8px; }
.viewer .loading { color: #9ca3af; padding: 60px; }
.meta { padding: 14px 2px; }
.meta .when { font-size: 18px; font-weight: 700; }
.meta .who { color: var(--muted); font-size: 14px; margin-top: 2px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- forms / sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(15,23,42,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 620px; max-height: 92vh; overflow: auto;
  background: #fff; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + var(--safe-bot));
  animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: .6; } }
.sheet h3 { margin: 0 0 14px; font-size: 20px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 700; color: #374151; margin-bottom: 5px; }
.field input, .field textarea, .field select {
  width: 100%; min-height: 48px; border: 1px solid #d1d5db; border-radius: 12px; padding: 10px 12px; font-size: 16px; background: #fff; font-family: inherit;
}
.field textarea { min-height: 88px; resize: vertical; }
.field .hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
.sheet .btns { display: flex; gap: 10px; margin-top: 16px; }
.sheet .btns .btn { flex: 1; }

/* ---------- sign-in ---------- */
.gate { text-align: center; padding: 40px 18px; }
.gate .logo { width: 84px; height: 84px; border-radius: 20px; margin: 0 auto 18px; display: block; }
.gate h2 { margin: 0 0 8px; }
.gate p { color: var(--muted); margin: 0 0 24px; }
.gate .err { color: var(--danger); font-weight: 600; margin-top: 18px; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 14px; }
.kv + .kv { border-top: 1px solid var(--line); }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 650; text-align: right; word-break: break-word; }

.toast {
  position: fixed; left: 50%; bottom: calc(88px + var(--safe-bot)); transform: translateX(-50%); z-index: 60;
  background: #111827; color: #fff; padding: 11px 16px; border-radius: 12px; font-weight: 600; font-size: 15px;
  max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.processing { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.55); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 18px; }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; }

/* ---------- job tracking ---------- */
.stage { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, white); white-space: nowrap; }
.stage::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.amt { color: var(--ink); font-size: 13px; }
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.summary > div { background: var(--navy); color: #fff; border-radius: var(--radius); padding: 12px 14px; }
.summary b { display: block; font-size: 20px; }
.summary span { font-size: 12px; color: #c7d2ea; }
.chips-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
.chips-row::-webkit-scrollbar { display: none; }
.fchip { flex: none; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 7px 12px; font-size: 14px; font-weight: 600; color: #374151; }
.fchip small { color: var(--muted); font-weight: 600; }
.fchip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.fchip.on small { color: #c7d2ea; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

.stage-card { padding: 14px; margin-bottom: 14px; }
.stage-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.stepper { display: flex; gap: 3px; margin-top: 12px; }
.step { flex: 1; position: relative; }
.step i { display: block; height: 6px; border-radius: 3px; background: #e5e7eb; }
.step.done i { background: color-mix(in srgb, var(--c) 55%, white); }
.step.cur i { background: var(--c); height: 8px; margin-top: -1px; }
.step em { display: none; }
.step.cur em { display: block; font-style: normal; font-size: 11px; font-weight: 700; color: var(--c); margin-top: 4px; white-space: nowrap; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px 14px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.facts span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.facts > div > div { font-size: 15px; margin-top: 1px; }
.co-sum { padding: 14px; margin-top: 14px; border-top: 0; }
.linkish { border: 0; background: none; color: var(--navy); font-weight: 700; padding: 0; text-decoration: underline; }
.tabs { margin-top: 14px; }
.tabs button { font-size: 13px; padding: 8px 2px; }

.stage-list { display: grid; gap: 6px; }
.stage-opt { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 13px 14px; font-size: 16px; font-weight: 600; text-align: left; }
.stage-opt.on { border-color: var(--navy); background: #eef1f7; }
.stage-opt small { color: var(--muted); font-weight: 500; }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pad { padding: 14px; }
.pad-s { padding: 8px 14px; }
.mt-s { margin-top: 6px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.walk-item { margin-bottom: 10px; }
.walk-photos { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tile.sm { width: 64px; height: 64px; aspect-ratio: auto; }
.tile.add { background: #eef1f7; color: var(--navy); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.tile.add svg { width: 22px; height: 22px; }
.report-box { border: 1.5px dashed #b9c3d8; background: #f8faff; }
.rep-links { display: flex; flex-wrap: wrap; gap: 8px; }

.doc-cat { margin-bottom: 8px; overflow: hidden; }
.doc-head { width: 100%; display: flex; align-items: center; gap: 10px; padding: 13px 14px; border: 0; background: #fff; text-align: left; font-size: 16px; }
.doc-head b { flex: 1; }
.doc-head small { color: var(--muted); font-weight: 700; background: #eef1f7; border-radius: 999px; padding: 2px 8px; }
.doc-head svg:first-child { color: #d29a1e; }
.doc-cat.open .doc-head .chev { transform: rotate(90deg); }
.doc-body { border-top: 1px solid var(--line); }
.doc-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; text-decoration: none; color: inherit; border-bottom: 1px solid var(--line); }
.doc-row .grow { display: flex; flex-direction: column; min-width: 0; }
.doc-row .t { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-row .s { font-size: 12px; }
.ftype { flex: none; width: 38px; height: 38px; border-radius: 8px; background: #eef1f7; color: var(--navy); font-size: 10px; font-weight: 800; display: grid; place-items: center; }

.co-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.timeline { position: relative; padding-left: 4px; }
.tl { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tl i { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; }
.tl .s { font-size: 12px; }
.btn.small svg { width: 18px; height: 18px; }

/* ---------- schedule ---------- */
.ev-row { align-items: stretch; }
.ev-bar { width: 4px; border-radius: 3px; flex: none; }
.ev-time { font-weight: 700; color: #374151; margin: 0 0 1px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 15px; padding: 6px 0; }
.check input { width: 20px; height: 20px; min-height: 0; }
.check small { color: var(--muted); }
.crew { border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px; max-height: 190px; overflow: auto; }
.grow-seg { flex: 1; margin: 0; }
.cal-name { margin: -4px 2px 4px; font-size: 12px; }
.tabs button { font-size: 12px; padding: 8px 0; }
.field input[type=time], .field input[type=date] { -webkit-appearance: none; appearance: none; }
