/* CFES Photo Submission. Palette matches CFES's Material Request app. */
:root {
  --green: #71a62b;
  --green-hover: #66992a;
  --green-ink: #4c6b16;
  --green-soft: #edf4e3;
  --green-faint: #f5f8ef;
  --ink: #26281f;
  --ink-2: #4a4c45;
  --muted: #74766f;
  --line: #e4e3dc;
  --line-strong: #d3d2ca;
  --surface: #ffffff;
  --canvas: #f2f1ec;
  --red: #b23a31;
  --red-soft: #fbeeec;
  --amber: #b06d0c;
  --amber-soft: #fff4de;
  --blue: #2f6db3;
  --blue-soft: #eaf1fa;
  --radius: 14px;
  --radius-s: 9px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 1px 3px rgba(0, 0, 0, .04);
  --tap: 44px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--canvas); color: var(--ink);
  font: 15px/1.4 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
  min-height: 100vh; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--green-ink); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.red { color: var(--red); }
.amber { color: var(--amber); }
.green { color: var(--green-ink); }

/* ---------- top bar ---------- */
.test-notice { background: var(--amber); color: #fff; font-size: 13px; font-weight: 600; text-align: center; padding: calc(6px + env(safe-area-inset-top)) 12px 6px; }
.test-notice:not([hidden]) + .topbar { padding-top: 8px; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .97); border-bottom: 1px solid var(--line);
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  display: flex; align-items: center; gap: 10px; min-height: 56px;
}
.topbar-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.topbar-title img { width: 30px; height: 30px; border-radius: 7px; }
.topbar-title h1 { font-size: 16px; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: var(--tap); height: var(--tap); flex: 0 0 auto; border: none; background: transparent; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2);
}
.icon-btn:active { background: var(--canvas); }
.icon-btn svg { width: 22px; height: 22px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--green-soft); color: var(--green-ink);
  font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; justify-content: center;
}
.upload-pill {
  border: none; border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 600;
  background: var(--blue-soft); color: var(--blue); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.upload-pill.waiting { background: var(--amber-soft); color: var(--amber); }
.upload-pill.failed { background: var(--red-soft); color: var(--red); }
.spinner { width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { max-width: 860px; margin: 0 auto; padding: 12px 12px 110px; }
.page-head { display: flex; align-items: center; gap: 10px; margin: 6px 0 12px; }
.page-head h2 { font-size: 20px; margin: 0; flex: 1; }

/* ---------- buttons ---------- */
.btn {
  min-height: var(--tap); padding: 0 16px; border-radius: 11px; border: 1px solid var(--line-strong);
  background: var(--surface); font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:not(:disabled):active { background: var(--green-hover); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--green-ink); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn svg { width: 18px; height: 18px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 auto; }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field > label, .field-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  background: var(--surface); font-size: 16px;
}
textarea.input { min-height: 88px; resize: vertical; }
.input:focus { outline: 2px solid var(--green); outline-offset: -1px; border-color: transparent; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.hint.green { color: var(--green-ink); }
.hint.red { color: var(--red); }
.segmented { display: flex; background: var(--canvas); border-radius: 11px; padding: 3px; gap: 3px; }
.segmented button {
  flex: 1; min-height: 38px; border: none; border-radius: 9px; background: transparent; font-weight: 600; font-size: 14px; color: var(--muted); padding: 0 8px;
}
.segmented button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.segmented button .count { font-weight: 500; color: var(--muted); margin-left: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-toggle {
  min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface);
  font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px;
}
.chip-toggle.on { background: var(--green-soft); border-color: var(--green); color: var(--green-ink); }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: var(--radius-s); overflow: hidden; background: var(--surface); }
.stepper button { width: var(--tap); height: var(--tap); border: none; background: transparent; font-size: 20px; }
.stepper span { min-width: 40px; text-align: center; font-weight: 700; }

/* ---------- cards / lists ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 14px; }
.search {
  position: relative; margin-bottom: 10px;
}
.search input { padding-left: 40px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.section-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 18px 4px 8px; }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; }
.empty b { display: block; color: var(--ink-2); font-size: 16px; margin-bottom: 4px; }

.job-card { display: block; width: 100%; text-align: left; padding: 14px; margin-bottom: 10px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.job-card:active { background: var(--green-faint); }
.job-card-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.job-card-name { font-weight: 700; font-size: 16px; }
.job-card-when { font-size: 12px; color: var(--muted); white-space: nowrap; }
.job-card-addr { font-size: 13px; color: var(--muted); margin-top: 2px; }
.job-card-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.side-progress-label { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.bar { height: 6px; background: var(--canvas); border-radius: 999px; overflow: hidden; margin-top: 5px; display: flex; }
.bar i { display: block; height: 100%; }
.bar .done { background: var(--green); }
.bar .waiting { background: #c9ddb0; }
.bar .retake { background: var(--red); }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tag { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--canvas); color: var(--ink-2); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.green { background: var(--green-soft); color: var(--green-ink); }
.tag.blue { background: var(--blue-soft); color: var(--blue); }

/* ---------- job screen ---------- */
.job-summary { padding: 14px; margin-bottom: 12px; }
.job-summary .status-line { font-size: 14px; font-weight: 600; margin: 10px 0 0; }
.big-bar { height: 8px; margin-top: 10px; }
.office-box { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.office-box .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.item-list { overflow: hidden; }
.item { border-top: 1px solid var(--line); }
.item:first-child { border-top: none; }
.item-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 12px; min-height: 64px; }
.item-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; cursor: pointer; text-align: left; padding: 2px 0; border-radius: 10px; }
.item-main:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.item-thumb, .item-state {
  width: 44px; height: 44px; border-radius: 8px; flex: 0 0 auto; position: relative;
  display: flex; align-items: center; justify-content: center;
}
.item-thumb { overflow: hidden; background: var(--canvas); }
.item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.item-thumb .dot { position: absolute; right: 3px; bottom: 3px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; }
.item-state { border-radius: 50%; width: 26px; height: 26px; margin: 0 4px; }
.item-state svg { width: 17px; height: 17px; }
.item-state.is-empty { color: var(--line-strong); }
.item-state.is-waiting { color: var(--amber); background: var(--amber-soft); }
.item-state.is-done { color: #fff; background: var(--green); }
.item-state.is-retake { color: #fff; background: var(--red); }
.item-state.is-na { color: var(--muted); background: var(--canvas); }
.item-state.is-uploading { color: var(--blue); background: var(--blue-soft); }
.dot.done { background: var(--green); }
.dot.waiting { background: #e0a43a; }
.dot.retake { background: var(--red); }
.dot.uploading { background: var(--blue); }
.item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item-label { font-weight: 600; font-size: 15px; }
.item-label .opt { font-weight: 500; color: var(--muted); font-size: 12px; margin-left: 6px; }
.item-status { font-size: 13px; margin-top: 2px; }
.item-status.is-done { color: var(--green-ink); }
.item-status.is-waiting { color: var(--amber); }
.item-status.is-retake { color: var(--red); font-weight: 600; }
.item-status.is-empty { color: var(--muted); }
.item-status.is-na { color: var(--muted); font-style: italic; }
.chev { color: var(--muted); flex: 0 0 auto; display: flex; transition: transform .15s; }
.chev svg { width: 18px; height: 18px; }
.item.open .chev { transform: rotate(90deg); }
.take-btn {
  flex: 0 0 auto; min-height: var(--tap); padding: 0 14px; border-radius: 11px; background: var(--green); color: #fff;
  display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.take-btn svg { width: 20px; height: 20px; }
.take-btn.quiet { background: var(--green-soft); color: var(--green-ink); }
.take-btn.secondary { background: var(--surface); color: var(--ink-2); border: 1px solid var(--line-strong); }
.row-btns { display: flex; gap: 6px; flex: 0 0 auto; }
/* Phones: the button stacks its icon over a short label so item names keep the width. */
@media (max-width: 480px) {
  .item-row { gap: 8px; padding-right: 8px; }
  .item-main { gap: 8px; }
  .item-thumb { width: 40px; height: 40px; }
  .take-btn { flex-direction: column; justify-content: center; gap: 1px; width: 62px; padding: 6px 2px; font-size: 11px; line-height: 1.15; white-space: normal; text-align: center; }
  .row-btns { gap: 4px; }
  .take-btn svg { width: 22px; height: 22px; }
}
.item-detail { padding: 2px 12px 14px; background: var(--green-faint); border-top: 1px solid var(--line); }
.item-detail .hint { margin: 10px 0 0; }
.reject-note { margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-s); background: var(--red-soft); color: var(--red); font-size: 13px; }
.photo-strip { display: flex; gap: 10px; overflow-x: auto; padding: 12px 0 4px; }
.photo-tile { flex: 0 0 auto; width: 112px; }
.photo-tile .img { width: 112px; height: 84px; border-radius: 8px; overflow: hidden; background: var(--canvas); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; position: relative; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.photo-tile .na { font-size: 12px; font-weight: 700; color: var(--muted); }
.photo-tile .cap { font-size: 12px; margin-top: 4px; line-height: 1.3; }
.photo-tile .cap b { font-weight: 600; }
.photo-tile .acts { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.photo-tile .acts button { font-size: 12px; border: none; background: none; color: var(--green-ink); padding: 2px 0; text-decoration: underline; }
.photo-tile .acts button.red { color: var(--red); }
.photo-tile select { font-size: 12px; max-width: 112px; margin-top: 4px; }
.tile-overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, .35); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; gap: 6px; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.group-head { padding: 12px 12px 2px; font-weight: 700; font-size: 15px; border-top: 1px solid var(--line); }
.group-head:first-child { border-top: none; }
.group-head .opt { font-weight: 500; color: var(--muted); font-size: 12px; margin-left: 6px; }
.group-head + .item { border-top: none; }
.group-head + .item .item-row, .item.sub .item-row { padding-left: 20px; }

/* electrical checklist questions */
.q { padding: 14px 12px; border-top: 1px solid var(--line); }
.q:first-child { border-top: none; }
.q-label { font-weight: 600; font-size: 15px; margin-bottom: 8px; }
.q-label .req { color: var(--red); margin-left: 2px; }
.q.missing .q-label { color: var(--red); }
.q.missing .input { border-color: var(--red); }
.item.missing .item-label { color: var(--red); }
.yes-no { display: flex; gap: 8px; }
.yes-no button { flex: 1; min-height: var(--tap); border-radius: 11px; border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; }
.yes-no button.on { background: var(--green); border-color: var(--green); color: #fff; }
.checklist-foot { padding: 14px 12px; border-top: 1px solid var(--line); }

/* ---------- review ---------- */
.queue-job { margin-bottom: 14px; }
.queue-job-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px 6px; }
.queue-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.queue-tile { border: 1px solid var(--line); border-radius: 11px; background: var(--surface); padding: 0; overflow: hidden; text-align: left; }
.queue-tile img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--canvas); }
.queue-tile div { padding: 6px 8px 8px; font-size: 12px; }
.queue-tile b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.reviewer { position: fixed; inset: 0; z-index: 40; background: #111; color: #fff; display: flex; flex-direction: column; }
.reviewer-top { display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 8px 8px; background: rgba(0, 0, 0, .6); }
.reviewer-top .icon-btn { color: #fff; }
.reviewer-top .t { flex: 1; min-width: 0; }
.reviewer-top .t b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reviewer-top .t span { font-size: 12px; color: #c9c9c9; }
.reviewer-img { flex: 1; min-height: 0; position: relative; overflow: hidden; touch-action: none; display: flex; align-items: center; justify-content: center; }
.reviewer-img img { max-width: 100%; max-height: 100%; user-select: none; -webkit-user-drag: none; }
.reviewer-info { padding: 8px 14px; font-size: 13px; color: #ddd; background: rgba(0, 0, 0, .6); }
.reviewer-info .warn { color: #ffc964; }
.reviewer-actions { display: flex; gap: 10px; padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); background: #000; }
.reviewer-actions .btn { flex: 1; min-height: 52px; font-size: 16px; }
.reviewer-actions .btn.reject { background: #3a1d1b; border-color: #6d2c27; color: #ffb4ad; }
.kbd { font-size: 11px; opacity: .6; font-weight: 500; }

/* ---------- reports ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { padding: 12px 14px; }
.tile .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .l { font-size: 12px; color: var(--muted); }
table.plain { width: 100%; border-collapse: collapse; font-size: 14px; }
table.plain th, table.plain td { text-align: left; padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: top; }
table.plain th { font-size: 12px; color: var(--muted); font-weight: 600; border-top: none; }
table.plain td.num, table.plain th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }

/* ---------- bottom nav (office) ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line);
  display: flex; justify-content: center; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.bottom-nav a {
  flex: 1; max-width: 200px; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; position: relative;
}
.bottom-nav a svg { width: 24px; height: 24px; }
.bottom-nav a.on { color: var(--green-ink); }
.bottom-nav .badge { position: absolute; top: 0; left: calc(50% + 6px); background: var(--red); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 6px; }

/* ---------- sheets, toasts, lightbox ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(20, 20, 18, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 18px; }
}
.sheet h3 { margin: 0 0 12px; font-size: 18px; }
.sheet-preview { width: 100%; max-height: 50vh; object-fit: contain; border-radius: 10px; background: var(--canvas); margin-bottom: 12px; }
.menu-item { display: flex; width: 100%; align-items: center; gap: 12px; min-height: 50px; padding: 0 4px; border: none; background: none; border-top: 1px solid var(--line); text-align: left; font-size: 16px; }
.menu-item:first-of-type { border-top: none; }
.menu-item.red { color: var(--red); }
.toast-wrap { position: fixed; left: 0; right: 0; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 70; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.toast { background: #26281f; color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; max-width: 520px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); pointer-events: auto; }
.toast.error { background: var(--red); }
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(8, 8, 8, .94); }
.lightbox .reviewer-img { position: absolute; inset: 0; }
.lightbox .icon-btn { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 10px; z-index: 2; background: rgba(255, 255, 255, .9); color: #000; }
.banner { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 12px; font-size: 14px; }
.banner.red { background: var(--red-soft); color: var(--red); }
.banner.amber { background: var(--amber-soft); color: var(--amber); }
.banner.green { background: var(--green-soft); color: var(--green-ink); }

/* ---------- sign in ---------- */
.signin { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.signin .card { max-width: 360px; width: 100%; text-align: center; padding: 28px 22px; }
.signin img { width: 56px; height: 56px; border-radius: 12px; }
.signin h1 { font-size: 20px; margin: 10px 0 20px; }

.file-inputs { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.loading { opacity: .5; pointer-events: none; }
