/* JobPass HK / 工單通 — mobile-first staff console + customer page */

:root {
  --brand: #0c3b3a;
  --brand-mid: #155e57;
  --brand-deep: #082726;
  --mint: #7ec8c3;
  --brass: #c4a35a;
  --brass-deep: #8d6d2e;
  --bg: #f3efe6;
  --bg-2: #e8e2d4;
  --surface: #fffdf8;
  --ink: #1c1915;
  --muted: #5e584e;
  --line: #ddd6c8;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(12, 59, 58, 0.08);
  --st-received: #1d6ba3;
  --st-scheduled: #5b4b8a;
  --st-en_route: #c4841d;
  --st-on_site: #0e7c6b;
  --st-parts: #c2410c;
  --st-done: #157a4b;
  --st-cancelled: #6b7280;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --tap: 48px;
  --radius: 16px;
  --font: "Noto Sans TC", "PingFang TC", "Hiragino Sans CNS", "Microsoft JhengHei",
    "Noto Sans", "Helvetica Neue", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--brand-deep);
  line-height: 1.45;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand-mid); }

#app {
  min-height: 100dvh;
  min-height: 100vh;
}

.shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
}

@media (min-width: 820px) {
  body {
    background:
      radial-gradient(1200px 600px at 10% -10%, rgba(196, 163, 90, 0.18), transparent 50%),
      radial-gradient(900px 500px at 110% 10%, rgba(126, 200, 195, 0.12), transparent 46%),
      var(--brand-deep);
  }
  .shell {
    margin: 24px auto;
    height: min(100dvh - 48px, 920px);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(196, 163, 90, 0.25);
  }
}

.demo-banner {
  flex: none;
  background: #c4a35a;
  color: #2a220f;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 6px 12px;
  padding-top: max(6px, calc(var(--safe-t) * 0.35));
}
.demo-banner span { display: inline-block; }

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  padding-left: max(16px, var(--safe-l));
  padding-right: max(16px, var(--safe-r));
  background: var(--brand);
  color: #f6f1e4;
  min-height: 60px;
}
.topbar.customer {
  background:
    linear-gradient(160deg, #0c3b3a 0%, #155e57 70%, #0c3b3a 100%);
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex: none;
}
.brand-text { flex: 1; min-width: 0; }
.brand-text .shop {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-text .sub {
  font-size: 11px;
  opacity: 0.75;
  letter-spacing: 0.04em;
}
.icon-btn, .text-btn {
  min-height: var(--tap);
  min-width: var(--tap);
  border: 0;
  background: transparent;
  color: inherit;
  border-radius: 12px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.icon-btn:active, .text-btn:active { background: rgba(255,255,255,0.08); }
.lang-btn {
  border: 1px solid rgba(196, 163, 90, 0.55);
  color: var(--brass);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
}

.main {
  flex: 1;
  height: 0;
  min-height: 0;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-left: max(16px, var(--safe-l));
  padding-right: max(16px, var(--safe-r));
}
.main.with-nav { padding-bottom: calc(88px + var(--safe-b)); }

.hint {
  background: rgba(12, 59, 58, 0.06);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 14px;
}

.search {
  width: 100%;
  min-height: var(--tap);
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 14px;
  padding: 0 14px;
  margin-bottom: 12px;
}
.search:focus { outline: 2px solid var(--brand-mid); outline-offset: 1px; }

.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  margin-bottom: 14px;
}
.chip {
  flex: none;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
}
.chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.list-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.job-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.job-card:active { transform: scale(0.992); }
.job-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.job-id { font-size: 12px; color: var(--muted); letter-spacing: 0.02em; }
.job-card h3 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 700;
}
.job-title {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--ink);
}
.job-addr, .job-meta {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.job-addr { margin-bottom: 4px; }

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--muted);
}
.pill.received { background: var(--st-received); }
.pill.scheduled { background: var(--st-scheduled); }
.pill.en_route { background: var(--st-en_route); }
.pill.on_site { background: var(--st-on_site); }
.pill.waiting_parts { background: var(--st-parts); }
.pill.completed { background: var(--st-done); }
.pill.cancelled { background: var(--st-cancelled); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 16px;
}
.empty p { margin: 0 0 14px; }

.bottom-nav {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  gap: 8px;
  padding: 10px 16px calc(10px + var(--safe-b));
  background: rgba(243, 239, 230, 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.nav-btn {
  flex: 1;
  min-height: var(--tap);
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 700;
}
.nav-btn.active { border-color: var(--brand); color: var(--brand); }
.nav-btn.primary, .btn.primary, .nav-btn.primary.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn {
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn.primary:active { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.danger { color: var(--danger); border-color: #efc2bd; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 140px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card h2, .section-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
}
.kv { display: grid; gap: 10px; }
.kv-row { display: grid; grid-template-columns: 88px 1fr; gap: 8px; font-size: 14px; }
.kv-row dt { color: var(--muted); font-weight: 600; }
.kv-row dd { margin: 0; overflow-wrap: anywhere; }
.kv-row a { color: var(--brand-mid); font-weight: 700; text-decoration: none; }

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.status-grid button {
  min-height: 56px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 10px;
  color: var(--ink);
}
.status-grid button.active.received { background: var(--st-received); color: #fff; border-color: transparent; }
.status-grid button.active.scheduled { background: var(--st-scheduled); color: #fff; border-color: transparent; }
.status-grid button.active.en_route { background: var(--st-en_route); color: #fff; border-color: transparent; }
.status-grid button.active.on_site { background: var(--st-on_site); color: #fff; border-color: transparent; }
.status-grid button.active.waiting_parts { background: var(--st-parts); color: #fff; border-color: transparent; }
.status-grid button.active.completed { background: var(--st-done); color: #fff; border-color: transparent; }
.status-grid button.active.cancelled { background: var(--st-cancelled); color: #fff; border-color: transparent; }
.status-grid button:last-child { grid-column: 1 / -1; }

label.field { display: block; margin-bottom: 12px; }
label.field > span:first-child {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}
label.field .req { color: var(--danger); }
input[type="text"], input[type="tel"], input[type="search"], textarea, select {
  width: 100%;
  min-height: var(--tap);
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
}
textarea { min-height: 96px; resize: vertical; }
.field.error input, .field.error textarea, .field.error .svc-grid {
  box-shadow: 0 0 0 2px rgba(180, 35, 24, 0.25);
}
.err { color: var(--danger); font-size: 12px; margin-top: 4px; display: none; }
.field.error .err { display: block; }
.help { display: block; font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 4px; }

.svc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.svc-grid label {
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
  font-weight: 700;
  font-size: 13px;
  background: #fff;
}
.svc-grid input { position: absolute; opacity: 0; pointer-events: none; }
.svc-grid input:checked + span,
.svc-grid label:has(input:checked) {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative;
  padding: 0 0 18px 22px;
}
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: "";
  position: absolute;
  left: 5px; top: 10px; bottom: -4px;
  width: 2px;
  background: var(--line);
}
.timeline li:last-child::before { display: none; }
.timeline .dot {
  position: absolute;
  left: 0; top: 6px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--brand-mid);
  box-shadow: 0 0 0 4px rgba(21, 94, 87, 0.12);
}
.timeline .dot.received { background: var(--st-received); }
.timeline .dot.scheduled { background: var(--st-scheduled); }
.timeline .dot.en_route { background: var(--st-en_route); }
.timeline .dot.on_site { background: var(--st-on_site); }
.timeline .dot.waiting_parts { background: var(--st-parts); }
.timeline .dot.completed { background: var(--st-done); }
.timeline .dot.cancelled { background: var(--st-cancelled); }
.timeline .dot.photo, .timeline .dot.note { background: var(--brass-deep); }
.tl-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.tl-title { font-weight: 700; font-size: 14px; }
.tl-time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.tl-body { margin: 4px 0 0; font-size: 14px; color: #3a3530; }
.tl-photo {
  margin-top: 8px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.tl-photo img { width: 100%; height: auto; max-height: 220px; object-fit: cover; }

.photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.photo-grid button {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #eee;
  min-height: 110px;
}
.photo-grid img { width: 100%; height: 120px; object-fit: cover; }

.status-hero {
  position: relative;
  border-radius: 20px;
  padding: 20px 18px 18px;
  color: #fff;
  margin-bottom: 12px;
  overflow: hidden;
}
.status-hero.received { background: linear-gradient(160deg, #1d6ba3, #154d76); }
.status-hero.scheduled { background: linear-gradient(160deg, #5b4b8a, #3d3260); }
.status-hero.en_route { background: linear-gradient(160deg, #c4841d, #8a5a10); }
.status-hero.on_site { background: linear-gradient(160deg, #0e7c6b, #0c3b3a); }
.status-hero.waiting_parts { background: linear-gradient(160deg, #c2410c, #7a2a08); }
.status-hero.completed { background: linear-gradient(160deg, #157a4b, #0c3b3a); }
.status-hero.cancelled { background: linear-gradient(160deg, #6b7280, #374151); }
.status-hero .kicker { font-size: 12px; letter-spacing: 0.08em; opacity: 0.85; font-weight: 700; }
.status-hero h1 { margin: 6px 0 8px; font-size: 26px; line-height: 1.2; }
.status-hero p { margin: 0; opacity: 0.92; font-size: 14px; }
.seal {
  position: absolute;
  right: 16px;
  top: 16px;
  width: 76px;
  height: 76px;
  border: 3px solid rgba(255,255,255,0.85);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  transform: rotate(-14deg);
  letter-spacing: 0.04em;
}

.eta-callout {
  background: #fff7e6;
  border: 1px solid #ead8a6;
  color: #5a4714;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.eta-callout strong { display: block; font-size: 12px; letter-spacing: 0.06em; margin-bottom: 4px; }

.visit-line {
  display: flex;
  gap: 8px;
  align-items: baseline;
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 0;
}
.visit-line b { color: var(--ink); font-weight: 600; }

.cust-hello { margin: 0 0 4px; font-size: 22px; }
.cust-jobno { margin: 0; color: var(--muted); font-size: 13px; }

.shop-footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 8px 8px 20px;
}
.shop-footer .name { color: var(--brand); font-weight: 800; font-size: 15px; margin-bottom: 4px; }
.fine { font-size: 11px; opacity: 0.8; }

.footer-tools {
  margin-top: 18px;
  display: grid;
  gap: 8px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 20, 18, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
  padding: 16px;
  padding-bottom: max(16px, var(--safe-b));
}
.modal {
  background: var(--surface);
  width: 100%;
  border-radius: 20px 20px 16px 16px;
  padding: 18px 16px 16px;
  max-height: 86%;
  overflow: auto;
}
.modal h2 { margin: 0 0 8px; font-size: 18px; }
.qr-box {
  display: grid;
  place-items: center;
  padding: 12px;
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--line);
  margin: 12px 0;
}
.qr-box img, .qr-box canvas { width: 200px !important; height: 200px !important; }
.share-url {
  font-size: 12px;
  word-break: break-all;
  background: var(--bg);
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.lightbox {
  position: absolute;
  inset: 0;
  background: rgba(8, 16, 14, 0.92);
  z-index: 30;
  display: flex;
  flex-direction: column;
  padding: 16px;
  padding-top: max(16px, var(--safe-t));
}
.lightbox img {
  flex: 1;
  height: 0;
  min-height: 0;
  width: 100%;
  object-fit: contain;
}
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(96px + var(--safe-b));
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  z-index: 40;
  white-space: nowrap;
  max-width: calc(100% - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-btn { position: relative; overflow: hidden; }
.file-btn input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.topbar .back {
  min-width: var(--tap);
  font-weight: 700;
}

@media (max-width: 360px) {
  .status-grid, .svc-grid, .photo-grid { grid-template-columns: 1fr; }
  .kv-row { grid-template-columns: 1fr; gap: 2px; }
}

a.btn { text-decoration: none; color: inherit; }
a.btn.primary { color: #fff; }

.install-card {
  background: var(--surface);
  border: 1px solid rgba(196, 163, 90, 0.5);
  border-radius: var(--radius);
  padding: 14px;
  margin: 0 0 14px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
}
.install-card > img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}
.install-copy strong {
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
}
.install-copy p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}
.install-steps {
  margin: 8px 0 0;
  padding-left: 1.25em;
  color: var(--ink);
  font-size: 13px;
}
.install-steps li { margin: 0 0 6px; }
.install-card .text-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  min-height: 40px;
}

.field-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  gap: 8px;
  padding: 10px 16px calc(10px + var(--safe-b));
  padding-left: max(16px, var(--safe-l));
  padding-right: max(16px, var(--safe-r));
  background: rgba(243, 239, 230, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  z-index: 5;
}
.field-bar .btn {
  flex: 1;
  font-size: 13px;
  padding: 0 10px;
}
.main.with-fieldbar { padding-bottom: calc(88px + var(--safe-b)); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.job-hero .cust-name {
  margin: 4px 0 6px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
}
.detail-quick { margin-top: 14px; }
.card h2.tight-top { margin-top: 18px; }

.photo-actions { margin-top: 10px; }
.photo-actions .btn { flex: 1 1 140px; }
#note-form .help { margin: 8px 0 10px; }

.preview-shot {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  margin: 8px 0 14px;
  background: #111;
}
.preview-shot img {
  width: 100%;
  max-height: 52vh;
  object-fit: contain;
  margin: 0 auto;
}

