/* Jobs: list, detail, quote requests, and the subcontractor page.
   base.html loads this on every team page, and the public job pages link it themselves,
   so every class is prefixed (job-, jobs-, pub-quote-, sub-). */

.job-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;
}

/* ---------- Status chips ---------- */
.job-status { background: #eef1f5; color: #3a4552; text-decoration: none; }
.job-status-requested { background: #fdf0dc; color: #8a5300; }
.job-status-quoted { background: #e3edf8; color: #2c5a8f; }
.job-status-approved { background: #e6f0fb; color: #1f4e79; }
.job-status-scheduled { background: #ece8fb; color: #5b3fb3; }
.job-status-in_progress { background: #fff4d6; color: #7a5b00; }
.job-status-completed { background: #dff3ea; color: #23734a; }
.job-status-invoiced { background: #dcefff; color: #0f5a8f; }
.job-status-paid { background: #2e7d4f; color: #fff; }
.job-status-lost { background: #eceff3; color: #6b7785; text-decoration: line-through; }
a.job-status:hover { filter: brightness(0.97); }

.job-num { color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; margin-right: 2px; }

/* ---------- Wider layout on desktop (list + detail) ---------- */
@media (min-width: 900px) {
  body.jobs-wide .page, body.jobs-wide .topbar-inner { max-width: 1120px; }
}

/* ---------- List ---------- */
.jobs-search { margin-bottom: 0; }
.jobs-chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px; margin: 0 -16px 4px;
  padding-left: 16px; padding-right: 16px; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.jobs-chips::-webkit-scrollbar { display: none; }
.jobs-chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 14px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 0.92rem; text-decoration: none; white-space: nowrap;
}
.jobs-chip.is-empty { color: var(--muted); }
.jobs-chip.is-active { background: var(--brand); border-color: var(--brand); color: var(--brand-contrast); }
.jobs-chip-n {
  min-width: 22px; padding: 0 6px; border-radius: 999px; background: rgba(0, 0, 0, 0.06);
  font-size: 0.8rem; text-align: center; font-variant-numeric: tabular-nums;
}
.jobs-chip.is-active .jobs-chip-n { background: rgba(255, 255, 255, 0.22); }

.job-row-head, .job-row-cell { display: none; }
.job-row .row-title {
  white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.job-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.job-row-amount-sm { font-size: 0.85rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.jobs-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }

@media (min-width: 900px) {
  .jobs-list .job-row {
    display: grid; grid-template-columns: minmax(0, 2.4fr) minmax(0, 1.4fr) minmax(0, 1.1fr) 130px 120px;
    align-items: center; gap: 16px;
  }
  .jobs-list .job-row::after { content: none; }
  .job-row-head {
    display: grid; padding: 10px 16px; border-bottom: 1px solid var(--border); background: #f9fafb;
    font-size: 0.75rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted);
  }
  .job-row-cell { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .job-row-main .row-sub { display: block; }
  .job-row-amount { font-weight: 700; font-variant-numeric: tabular-nums; }
  .job-row-amount .muted { display: block; font-weight: 400; }
  .job-row-sub-customer, .job-row-sub-city { display: none; }
  .jobs-list .job-row .row-title { -webkit-line-clamp: 1; }
  .job-row-side { align-items: flex-start; }
  .job-row-amount-sm { display: none; }
  .jobs-list .job-row:hover { background: #f6f8fb; }
}

/* ---------- Detail: header ---------- */
.job-head { margin-bottom: 16px; }
.job-head-top { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.job-num-lg { font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.job-title { margin: 0 0 4px; font-size: 1.4rem; overflow-wrap: anywhere; }
.job-head-meta { margin: 0; }

/* Mobile: one column, cards interleaved by importance. Desktop: main column + side column. */
.job-layout { display: flex; flex-direction: column; }
.job-col { display: contents; }
.job-o-1 { order: 1; } .job-o-2 { order: 2; } .job-o-3 { order: 3; } .job-o-4 { order: 4; } .job-o-5 { order: 5; }
.job-o-6 { order: 6; } .job-o-7 { order: 7; } .job-o-8 { order: 8; } .job-o-9 { order: 9; } .job-o-10 { order: 10; }
@media (min-width: 900px) {
  .job-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 0 20px; align-items: start; }
  .job-col { display: block; }
  .job-col-main { grid-column: 1; grid-row: 1; }
  .job-col-side { grid-column: 2; grid-row: 1; }
}

.job-card-title {
  margin: 0 0 10px; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted);
}
.job-card-title-gap { margin-top: 18px; }
.job-card p:last-child { margin-bottom: 0; }

/* ---------- Detail: actions ---------- */
.job-moves { display: grid; gap: 8px; }
.job-moves form { margin: 0; }
.job-step > summary { list-style: none; cursor: pointer; }
.job-step > summary::-webkit-details-marker { display: none; }
.job-step[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.job-step-form {
  display: grid; gap: 8px; padding: 12px; border: 1px solid var(--border); border-top: 0;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm); background: #fafbfc;
}
.job-step-form .label { margin: 0; }
.job-step-inline { border-top: 1px solid var(--border); border-radius: var(--radius-sm); }
.job-lost-btn { color: var(--danger); }
.job-step-lost[open] > summary { border-color: var(--border); }
.job-lost { padding: 10px 12px; border-radius: var(--radius-sm); background: #eceff3; color: var(--text); }
.job-paid { padding: 10px 12px; border-radius: var(--radius-sm); background: #dff3ea; color: #1d5e3c; font-weight: 600; }
.job-hint { margin: 10px 0 0; }
.job-danger-text { color: var(--danger); }

.job-money { position: relative; }
.job-money > span {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600;
  pointer-events: none;
}
.job-money input { padding-left: 26px; font-variant-numeric: tabular-nums; }

/* ---------- Detail: people, scope ---------- */
.job-person { margin: 0 0 8px; }
.job-person a { color: var(--text); }
.job-contact { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 6px; }
.job-contact .btn { flex: 1 1 0; min-width: 72px; }
.job-contact-line { margin: 0 0 8px; overflow-wrap: anywhere; }
.job-requested { margin: 8px 0; overflow-wrap: anywhere; }
.job-quote-note {
  margin: 8px 0 0; padding: 8px 12px; border-left: 3px solid var(--brand); background: #f6f8fb;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; overflow-wrap: anywhere;
}
.job-address { margin: 0 0 10px; }
.job-address a { color: var(--text); font-weight: 600; }
.job-service { font-weight: 700; margin: 0 0 6px; }
.job-desc { margin: 0 0 12px; overflow-wrap: anywhere; }
.job-findings { list-style: none; margin: 0; padding: 0; }
.job-finding { padding: 10px 0; border-top: 1px solid var(--border); }
.job-finding-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.job-finding-text { margin: 0 0 6px; overflow-wrap: anywhere; }
.job-thumbs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.job-thumbs a { display: block; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: #e7ebf0; }
.job-thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.job-source { margin: 10px 0 0; }

/* ---------- Detail: partner, amounts, docs, sub link ---------- */
.job-issues { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.job-issue { background: #fbe4e1; color: var(--danger); }
.job-inline-form { display: flex; gap: 8px; margin: 4px 0 8px; }
.job-inline-form select { flex: 1; min-width: 0; }
.job-amounts { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.job-amounts .field { margin-bottom: 12px; }
.job-margin { margin: 0 0 12px; font-weight: 700; color: var(--ok); font-variant-numeric: tabular-nums; }
.job-margin.is-negative { color: var(--danger); }
.job-docs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.job-docs svg, .job-camera svg, .job-quote-btn svg, .sub-work svg, .sub-maps svg, .sub-done svg, .sub-complete-btn svg,
.pub-quote-open svg, .pub-quote-thanks svg {
  width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.job-docs-hint { margin: 8px 0 0; }
.job-sub-status { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.job-sub-status form { margin: 0; }
.job-manage { display: grid; gap: 4px; margin-bottom: 16px; }
.job-manage form { margin: 0; }

/* ---------- Photos (team page + sub page) ---------- */
.job-photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 0 0 12px; }
.job-photo-grid:empty { display: none; }
@media (min-width: 900px) { .job-col-main .job-photo-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.job-tile { position: relative; margin: 0; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: #e7ebf0; }
.job-tile > a { display: block; width: 100%; height: 100%; }
.job-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.job-tile-meta {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  padding: 14px 6px 5px; background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
  color: #fff; font-size: 0.7rem; font-weight: 600; pointer-events: none;
}
.job-tile-meta:empty { display: none; }
.job-tile-badge { padding: 0 6px; border-radius: 999px; background: var(--brand); color: var(--brand-contrast); }
.job-tile-delete {
  position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 20px; line-height: 1; cursor: pointer;
}
.job-tile.is-pending img, .job-tile.is-uploading img { opacity: 0.55; }
.job-tile-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px;
  padding: 8px; color: #fff; font-size: 0.75rem; font-weight: 700;
  background: linear-gradient(transparent 30%, rgba(0, 0, 0, 0.55));
}
.job-tile-bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.35); overflow: hidden; }
.job-tile-bar i { display: block; width: 0; height: 100%; background: #fff; transition: width 0.2s; }
.job-tile.is-failed .job-tile-overlay {
  justify-content: center; align-items: center; text-align: center; background: rgba(160, 40, 28, 0.88);
}
.job-tile-actions { display: flex; gap: 6px; }
.job-tile-btn {
  min-height: 36px; padding: 4px 12px; border: 0; border-radius: 999px; font: inherit; font-weight: 700;
  cursor: pointer;
}
.job-tile-retry { background: #fff; color: var(--danger); }
.job-tile-remove { background: rgba(255, 255, 255, 0.25); color: #fff; }
.job-upload-status { margin: 0 0 10px; padding: 8px 12px; border-radius: var(--radius-sm); background: #e3edf8; font-weight: 600; font-size: 0.9rem; }
.job-upload-status.is-warn { background: #fbe4e1; color: var(--danger); }
.job-upload-status.is-ok { background: #dcf1e5; color: var(--ok); }
.job-photos-empty { margin: 0 0 12px; }
.job-camera label.btn { position: relative; display: flex; width: 100%; overflow: hidden; }
.job-file { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 0; }
.job-camera label.btn:focus-within, .sub-photo-btn:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- Timeline ---------- */
.job-note-form { display: grid; gap: 8px; margin-bottom: 14px; }
.job-note-form textarea { min-height: 64px; }
.job-note-form .btn { justify-self: end; }
.job-timeline { list-style: none; margin: 0; padding: 0; }
.job-event { position: relative; display: flex; gap: 12px; padding: 0 0 14px 2px; }
.job-event:not(:last-child)::before {
  content: ""; position: absolute; left: 7px; top: 16px; bottom: 0; width: 2px; background: var(--border);
}
.job-event-dot { flex: none; width: 12px; height: 12px; margin-top: 4px; border-radius: 50%; background: #c3ccd6; }
.job-event-status .job-event-dot { background: var(--brand); }
.job-event-photo .job-event-dot { background: var(--ok); }
.job-event-assignment .job-event-dot { background: #8b6fd6; }
.job-event-body { min-width: 0; }
.job-event-note { overflow-wrap: anywhere; }
.job-event-meta { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }

/* ---------- Finding card: tech "Request quote" ---------- */
.job-quote { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.job-quote form { margin: 0; }
.job-quote-msg { flex-basis: 100%; margin: 0; font-weight: 600; color: var(--ok); }

/* ---------- Public: quote request ---------- */
.pub-quote { margin-top: 12px; }
.pub-quote > summary { list-style: none; cursor: pointer; }
.pub-quote > summary::-webkit-details-marker { display: none; }
.pub-quote-open { border-color: var(--brand); color: var(--brand); }
.pub-quote[open] > .pub-quote-open { background: var(--brand); color: var(--brand-contrast); }
.pub-quote-form { position: relative; margin-top: 12px; }
.pub-quote-page { padding-top: 16px; }
.pub-quote-grid { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 560px) { .pub-quote-grid { grid-template-columns: 1fr 1fr; } }
.pub-quote-hint { margin: -6px 0 12px; }
.pub-quote-fix { margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: #fbe4e1; color: var(--danger); font-weight: 600; }
.pub-quote-form .errorlist.nonfield {
  margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: #fbe4e1; font-weight: 600;
}
.pub-quote-thanks { text-align: center; padding: 28px 20px; }
.pub-quote-thanks svg {
  width: 56px; height: 56px; padding: 10px; margin-bottom: 8px; border-radius: 50%;
  background: #dcf1e5; stroke: var(--ok); stroke-width: 3;
}
.pub-quote-thanks h1 { font-size: 1.5rem; }
.pub-quote-stop { border-left: 4px solid var(--warn); }

/* ---------- Public: subcontractor page ---------- */
.sub-hero .pub-city { margin-bottom: 12px; }
.sub-maps { margin-top: 4px; }
.sub-banner { margin: 0 0 16px; padding: 14px 16px; border-radius: var(--radius); font-weight: 700; }
.sub-banner-ok { background: #dcf1e5; color: #1d5e3c; }
.sub-banner-warn { background: #fdf0dc; color: #7a4a00; }
.sub-work { margin-bottom: 16px; }
.sub-photo-btn {
  position: relative; display: flex; width: 100%; min-height: 72px; overflow: hidden;
  font-size: 1.2rem; border-radius: var(--radius); box-shadow: var(--shadow);
}
.sub-photo-btn svg { width: 28px; height: 28px; }
.sub-library {
  position: relative; display: flex; justify-content: center; align-items: center; min-height: 48px; margin: 4px 0 12px;
  color: var(--brand); font-weight: 600; text-decoration: underline; cursor: pointer; overflow: hidden;
}
.sub-library:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: var(--radius-sm); }
.sub-count { margin: -4px 0 0; }
.sub-complete { margin: 0 0 20px; }
.sub-complete-btn {
  min-height: 64px; font-size: 1.15rem; border: 2px solid var(--ok); color: var(--ok); background: var(--surface);
  border-radius: var(--radius);
}
.sub-complete-btn svg { stroke-width: 3; }
.sub-done {
  display: flex; align-items: center; gap: 12px; margin: 0 0 20px; padding: 14px 16px;
  border-radius: var(--radius); background: #dcf1e5; color: #1d5e3c;
}
.sub-done svg { width: 32px; height: 32px; padding: 5px; border-radius: 50%; background: var(--ok); stroke: #fff; stroke-width: 3; }
.sub-wait { margin: 0 0 20px; }
.sub-closed { border-left: 4px solid var(--muted); }
.sub-scope-title { font-size: 1.15rem; margin-bottom: 10px; overflow-wrap: anywhere; }
.sub-kv { margin-bottom: 12px; }
.sub-scope-sub { margin: 14px 0 6px; font-size: 0.8rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.sub-findings { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.sub-findings li { overflow-wrap: anywhere; }
