/* HaulBase — Job Detail page (.jd-* prefix)
 *
 * Source: Haulbase_Claude_Design/assets/design/Job Detail.html
 *
 * Tokens (--bg-card, --fg-1, etc.) come from tokens.css; sidebar +
 * top-strip + status pills (.pill / .pill-onsite / .pill-complete /
 * etc.) are owned by the global shell. This file only carries the
 * page-local hero + cards + timeline + audit CSS.
 */

/* ========= JOB DETAIL ========= */
/* No max-width: let the page fill the area right of the sidebar so wide
 * monitors aren't left with 500px of empty space on the right. The body
 * grid below (.jd-grid: 1fr / 360px) keeps the right rail fixed while
 * the left column expands. */
.jd-page { padding: 24px 28px 56px; }

/* --- Hero strip --- */
.jd-hero {
  background: var(--bg-card);
  border: 1px solid var(--border-1);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.jd-hero-row1 {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 24px; margin-bottom: 14px;
}
.jd-id-stack { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.jd-jobid {
  font: 500 11px/1 var(--font-mono); color: var(--fg-4);
  letter-spacing: .04em;
  display: flex; align-items: center; gap: 8px;
}
.jd-jobid .copy { color: var(--fg-4); cursor: pointer; }
.jd-jobid .copy:hover { color: var(--fg-2); }
.jd-jobid .copy svg { width: 11px; height: 11px; }
.jd-customer {
  font: 700 26px/1.1 var(--font-display); letter-spacing: -0.018em;
  color: var(--fg-1);
  display: inline-flex; align-items: center; gap: 8px;
}
.jd-customer a {
  color: inherit; text-decoration: none;
  border-bottom: 1.5px dashed var(--border-2);
}
.jd-customer a:hover { color: var(--accent-300); border-color: var(--accent-400); }
.jd-customer .ext {
  width: 14px; height: 14px; color: var(--fg-4); flex-shrink: 0;
}
.jd-pills {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px;
}
.jd-window {
  font: 600 10.5px/1 var(--font-body); text-transform: uppercase;
  letter-spacing: .1em;
  padding: 4px 9px; border-radius: var(--r-md);
  background: var(--bg-input); color: var(--fg-2); border: 1px solid var(--border-2);
  display: inline-flex; align-items: center; gap: 6px;
}
.jd-window svg { width: 11px; height: 11px; color: var(--fg-3); }

.jd-actions {
  display: flex; gap: 6px; align-items: center;
  flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end;
}
.jd-btn {
  height: 32px; padding: 0 12px; border-radius: var(--r-md);
  background: var(--bg-card); border: 1px solid var(--border-2);
  color: var(--fg-2);
  font: 600 12px/1 var(--font-display); letter-spacing: .01em;
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  text-decoration: none;
}
.jd-btn:hover { color: var(--fg-1); border-color: var(--border-3); }
.jd-btn svg { width: 13px; height: 13px; }
.jd-btn.danger:hover {
  color: var(--status-issue-fg); border-color: var(--status-issue-bd);
  background: var(--status-issue-bg);
}
.jd-btn.primary {
  background: var(--brand-cta); color: var(--brand-cta-fg);
  border-color: var(--brand-cta);
}
.jd-btn.primary:hover {
  background: var(--brand-cta-hover); border-color: var(--brand-cta-hover);
}
.jd-btn[disabled] { opacity: .45; cursor: not-allowed; }
.jd-btn[disabled]:hover {
  color: var(--fg-2); border-color: var(--border-2); background: var(--bg-card);
}

/* --- Hero meta row (date / driver / truck) --- */
.jd-meta-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-1);
}
.jd-meta { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.jd-meta .lbl {
  font: 600 9.5px/1 var(--font-body); text-transform: uppercase;
  letter-spacing: .14em; color: var(--fg-4);
}
.jd-meta .val {
  font: 600 14px/1.25 var(--font-display); color: var(--fg-1);
  display: inline-flex; align-items: center; gap: 8px;
}
.jd-meta .val .sub {
  font: 400 12px/1 var(--font-body); color: var(--fg-3); margin-left: 2px;
}
.jd-meta .val a {
  color: inherit; text-decoration: none;
  border-bottom: 1.5px dashed var(--border-2);
}
.jd-meta .val a:hover { color: var(--accent-300); border-color: var(--accent-400); }
.jd-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #0f172a; font: 700 11px/24px var(--font-display); text-align: center;
  flex-shrink: 0;
}
.jd-truck-mono {
  width: 28px; height: 22px; border-radius: 3px;
  background: var(--bg-input); border: 1px solid var(--border-2);
  display: inline-grid; place-items: center;
  font: 600 9.5px/1 var(--font-mono); color: var(--fg-2);
  letter-spacing: .04em;
  flex-shrink: 0;
}

/* --- Body grid --- */
.jd-grid { display: grid; grid-template-columns: 1fr 360px; gap: 18px; }

.jd-card {
  background: var(--bg-card); border: 1px solid var(--border-1);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.jd-card + .jd-card { margin-top: 18px; }
.jd-card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-1);
  background: var(--bg-card-2);
}
.jd-card-head h3 {
  margin: 0;
  font: 600 10.5px/1 var(--font-body); text-transform: uppercase;
  letter-spacing: .14em; color: var(--fg-3);
}
.jd-card-head .spacer { flex: 1; }
.jd-card-head .meta {
  font: 500 11px/1 var(--font-mono); color: var(--fg-4);
}
.jd-card-body { padding: 18px; }

/* Side-by-side row for paired narrow cards (Service Address +
 * Equipment & Service). Wraps below 900px so a small viewport stacks
 * them again. */
.jd-row-half {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px; align-items: stretch;
}
.jd-row-half > .jd-card { margin-top: 0; }
.jd-row-half + .jd-card { margin-top: 18px; }
@media (max-width: 900px) {
  .jd-row-half { grid-template-columns: 1fr; }
}

/* Three-card row: Service Address (wide) + Equipment & Service (narrow)
 * + Site Info (medium). Each card stretches to the same height so the
 * 200px-tall Service Address mini-map sets the row's vertical rhythm
 * and the other two cards spread their content to match.
 *
 * Breakpoints:
 *   ≥ 1200px : 3 cards across
 *   900–1200 : Service Address full-width on top, Equipment + Site Info
 *              share a row underneath
 *   < 900px  : everything stacks
 */
.jd-row-trio {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 0.7fr) minmax(0, 1.1fr);
  gap: 18px; align-items: stretch;
}
.jd-row-trio > .jd-card { margin-top: 0; }
.jd-row-trio + .jd-card { margin-top: 18px; }
@media (max-width: 1200px) {
  .jd-row-trio {
    grid-template-columns: 1fr 1fr;
  }
  .jd-row-trio > .jd-card:first-child {
    grid-column: 1 / -1;
  }
}
@media (max-width: 900px) {
  .jd-row-trio { grid-template-columns: 1fr; }
  .jd-row-trio > .jd-card:first-child { grid-column: auto; }
}

/* --- Address + mini-map --- */
.jd-addr-grid {
  display: grid; grid-template-columns: 1fr 200px; gap: 16px;
  align-items: stretch;
}
/* Spread the address pieces across the available height so the card
 * matches the mini-map's 200px instead of bunching at the top — Line 1
 * and Line 2 stay at the top, the coords sit in the middle, and the
 * "Open in Maps" button drops to the bottom. */
.jd-addr-block {
  display: flex; flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  min-height: 200px;
}
.jd-addr-block .jd-addr-text { display: flex; flex-direction: column; gap: 4px; }
.jd-addr-line1 {
  font: 700 17px/1.25 var(--font-display); color: var(--fg-1);
  letter-spacing: -0.01em;
}
.jd-addr-line2 {
  font: 400 13.5px/1.25 var(--font-body); color: var(--fg-3);
}
.jd-addr-coords {
  font: 500 11.5px/1 var(--font-mono); color: var(--fg-4);
  letter-spacing: .02em;
  display: inline-flex; align-items: center; gap: 6px;
}
.jd-addr-coords svg { width: 11px; height: 11px; }
.jd-addr-actions { display: flex; gap: 6px; margin-top: 0; }

.jd-minimap {
  position: relative;
  border-radius: var(--r-md); overflow: hidden;
  border: 1px solid var(--border-2);
  background: var(--bg-card-2);
  /* Bumped from 160px to 200px so the address column has more room
   * to spread Line 1 / coords / Open-in-Maps button. */
  min-height: 200px;
  height: 200px;
}
/* Leaflet target — fills the .jd-minimap parent. The OSM tile layer
 * paints in real road colors against a near-white background; force
 * the parent to white so the brief pre-tile flash isn't dark. */
.jd-leaflet-mini {
  position: absolute; inset: 0;
  background: #f8fafc;
}
[data-theme="light"] .jd-leaflet-mini { background: #f8fafc; }
.jd-minimap svg.bg {
  display: block; width: 100%; height: 100%; position: absolute; inset: 0;
}
.jd-minimap .pin {
  position: absolute; left: 50%; top: 48%;
  transform: translate(-50%, -100%);
  width: 0; height: 0;
}
.jd-minimap .pin .dot {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--pin-customer); border: 3px solid var(--pin-customer-bd);
  box-shadow: var(--shadow-pin);
  transform: translate(-50%, -50%);
  position: absolute;
}
.jd-minimap .pin .needle {
  position: absolute; left: 50%; top: 0; transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 6px solid transparent; border-right: 6px solid transparent;
  border-top: 10px solid var(--pin-customer);
  margin-top: -2px;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.4));
}
.jd-minimap-cap {
  position: absolute; left: 8px; bottom: 8px;
  background: rgba(15, 23, 42, 0.78); border: 1px solid var(--border-2);
  padding: 4px 8px; border-radius: var(--r-sm);
  font: 500 11px/1 var(--font-mono); color: var(--fg-2);
  backdrop-filter: blur(4px);
}
[data-theme="light"] .jd-minimap-cap { background: rgba(255,255,255,.92); }
.jd-minimap-empty {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font: 500 11.5px/1.4 var(--font-body); color: var(--fg-4);
  text-align: center; padding: 0 14px;
}

/* --- Site info card ---
 * Default: 2-column grid (gate code | contact, instructions full-width).
 * Narrow variant for the trio-row layout: stacks every cell into a
 * single column so it fits in the third slot of the row. */
.jd-site-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px 32px;
}
.jd-site-cell-full { grid-column: 1 / -1; }
.jd-site-grid.narrow {
  grid-template-columns: 1fr;
  gap: 18px;
}
.jd-site-grid.narrow .jd-site-cell-full { grid-column: auto; }
.jd-site-cell .lbl {
  font: 600 9.5px/1 var(--font-body); text-transform: uppercase;
  letter-spacing: .14em; color: var(--fg-4); margin-bottom: 8px;
}
.jd-site-cell .val {
  font: 500 13.5px/1.45 var(--font-body); color: var(--fg-1);
}
.jd-site-cell .val.body { color: var(--fg-2); font-weight: 400; }
.jd-site-cell .inh {
  margin-left: 6px;
  font: 500 9px/1 var(--font-body); text-transform: uppercase;
  letter-spacing: .14em; color: var(--fg-4);
  padding: 2px 5px; border-radius: 3px;
  background: var(--bg-input); border: 1px solid var(--border-2);
  vertical-align: middle;
}
.jd-gate {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: var(--r-md);
  background: var(--bg-input);
  border: 1.5px solid var(--accent-500);
  font: 700 18px/1 var(--font-mono); color: var(--accent-300);
  letter-spacing: .12em;
  box-shadow: var(--shadow-glow-amber);
}
.jd-gate .key { width: 14px; height: 14px; color: var(--accent-400); }
.jd-gate-hint {
  font: 500 11px/1.4 var(--font-body); color: var(--fg-4); margin-top: 6px;
}

.jd-contact { display: flex; align-items: center; gap: 10px; }
.jd-contact .av {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-input); border: 1px solid var(--border-2);
  display: inline-grid; place-items: center;
  font: 700 12px/1 var(--font-display); color: var(--fg-1);
}
.jd-contact .who {
  display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.jd-contact .who .nm {
  font: 600 13.5px/1 var(--font-display); color: var(--fg-1);
}
.jd-contact .who .ph {
  font: 500 12.5px/1 var(--font-mono); color: var(--accent-300);
  text-decoration: none;
}
.jd-contact .who .ph:hover { color: var(--accent-200); }

/* --- Equipment block ---
 * Narrow card: icon at the top-left, spec to its right (type then size
 * stacked), and the service action pill on its OWN row beneath the spec
 * — gives the user the same info in roughly half the horizontal space
 * the side-pill layout used. */
.jd-equip {
  display: flex; flex-direction: column; gap: 14px;
  align-items: stretch;
  min-height: 200px;
  justify-content: space-between;
}
.jd-equip-spec-row {
  display: flex; align-items: center; gap: 14px;
}
.jd-equip-icon {
  width: 52px; height: 52px; border-radius: var(--r-md);
  background: var(--bg-input); border: 1px solid var(--border-2);
  display: grid; place-items: center;
  color: var(--fg-2);
  flex-shrink: 0;
}
.jd-equip-icon svg { width: 28px; height: 28px; }
.jd-equip-spec { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.jd-equip-type {
  font: 700 16px/1.2 var(--font-display); color: var(--fg-1);
  letter-spacing: -0.01em;
}
.jd-equip-size {
  display: inline-flex; gap: 6px; align-items: baseline;
  font: 500 13px/1 var(--font-mono); color: var(--fg-3);
}
.jd-equip-size .num {
  color: var(--fg-1); font-weight: 600; font-size: 14px;
}
/* Service action — full-width pill row at the bottom of the card. */
.jd-equip-action {
  font: 700 11px/1 var(--font-body); text-transform: uppercase;
  letter-spacing: .12em;
  padding: 9px 12px; border-radius: var(--r-md);
  background: var(--status-onsite-bg); color: var(--status-onsite-fg);
  border: 1px solid var(--status-onsite-bd);
  text-align: center;
  align-self: stretch;
}

/* --- Notes --- */
.jd-notes {
  font: 400 13.5px/1.55 var(--font-body); color: var(--fg-2);
  padding: 14px 16px;
  border-left: 3px solid var(--accent-500);
  background: var(--bg-card-2);
  border-radius: var(--r-sm);
}
.jd-notes .author {
  display: block; margin-top: 8px;
  font: 500 11px/1 var(--font-mono); color: var(--fg-4);
}

/* --- Right rail: timeline --- */
.jd-timeline { padding: 8px 18px 18px; }
.jd-tl-item { position: relative; padding: 10px 0 14px 28px; }
.jd-tl-item::before {
  content: ""; position: absolute;
  left: 7px; top: 0; bottom: 0;
  width: 2px; background: var(--border-1);
}
.jd-tl-item:last-child::before { display: none; }
.jd-tl-item:first-child::before { top: 14px; }
.jd-tl-dot {
  position: absolute; left: 0; top: 11px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--bg-card); border: 2.5px solid var(--border-3);
  z-index: 1;
}
.jd-tl-item.done .jd-tl-dot {
  background: var(--status-complete-fg); border-color: var(--status-complete-bd);
}
.jd-tl-item.active .jd-tl-dot {
  background: var(--accent-400); border-color: var(--accent-500);
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.18);
}
.jd-tl-item.future .jd-tl-dot {
  background: var(--bg-input); border-color: var(--border-2);
}
.jd-tl-item.issue .jd-tl-dot {
  background: var(--status-issue-fg); border-color: var(--status-issue-bd);
}

.jd-tl-step { display: flex; align-items: center; gap: 8px; }
.jd-tl-step .nm {
  font: 600 13px/1 var(--font-display); color: var(--fg-1);
}
.jd-tl-item.future .jd-tl-step .nm {
  color: var(--fg-4); font-weight: 500;
}
.jd-tl-step .at {
  margin-left: auto; font: 500 11px/1 var(--font-mono); color: var(--fg-3);
}
.jd-tl-item.future .jd-tl-step .at { color: var(--fg-5); }
.jd-tl-actor {
  font: 400 12px/1.4 var(--font-body); color: var(--fg-3); margin-top: 4px;
}
.jd-tl-actor a {
  color: var(--fg-2); text-decoration: none;
  border-bottom: 1px dashed var(--border-2);
}
.jd-tl-actor a:hover { color: var(--accent-300); }

/* --- Invoice block --- */
.jd-inv {
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 12px;
}
.jd-inv-row1 {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
}
.jd-inv-amt {
  font: 700 28px/1 var(--font-mono); color: var(--fg-1); letter-spacing: -0.01em;
}
.jd-inv-num { font: 500 11px/1 var(--font-mono); color: var(--fg-4); }
.jd-inv-row2 {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.jd-inv-cta {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 4px;
  padding: 8px 12px; border-radius: var(--r-md);
  background: var(--bg-input); color: var(--fg-1); border: 1px solid var(--border-2);
  font: 600 12.5px/1 var(--font-display);
  text-decoration: none;
}
.jd-inv-cta:hover { border-color: var(--accent-500); color: var(--accent-300); }
.jd-inv-cta svg { width: 13px; height: 13px; color: var(--accent-400); }

/* --- Photos / issue --- */
.jd-photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.jd-photo {
  aspect-ratio: 1 / 1; border-radius: var(--r-sm);
  border: 1px solid var(--border-2);
  overflow: hidden;
  position: relative; cursor: pointer;
}
.jd-photo .ph-stamp {
  position: absolute; left: 4px; bottom: 4px;
  font: 500 9px/1 var(--font-mono); color: #f1f5f9;
  background: rgba(15, 23, 42, 0.8); padding: 2px 4px; border-radius: 2px;
  letter-spacing: .04em;
}
.jd-photo svg { width: 100%; height: 100%; display: block; }
.jd-photo .badge {
  position: absolute; right: 4px; top: 4px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--status-issue-bd); color: #fff;
  display: grid; place-items: center;
  font: 700 10px/1 var(--font-display);
}
.jd-photo-more {
  aspect-ratio: 1 / 1; border-radius: var(--r-sm);
  border: 1px dashed var(--border-2);
  background: var(--bg-input);
  display: grid; place-items: center;
  color: var(--fg-3); font: 600 12px/1 var(--font-display);
  cursor: pointer;
}
.jd-photo-more:hover { color: var(--fg-1); border-color: var(--border-3); }

.jd-issue {
  background: var(--status-issue-bg); border: 1px solid var(--status-issue-bd);
  border-radius: var(--r-md); padding: 12px 14px;
  margin: 12px 18px;
  display: flex; gap: 10px; align-items: flex-start;
}
.jd-issue svg {
  width: 16px; height: 16px; flex-shrink: 0;
  color: var(--status-issue-fg); margin-top: 1px;
}
.jd-issue .body {
  color: var(--status-issue-fg); font: 500 13px/1.45 var(--font-body);
}
.jd-issue .body b { font-weight: 700; }
.jd-issue .body .meta {
  display: block; margin-top: 4px;
  font: 500 10.5px/1 var(--font-mono); color: var(--status-issue-fg);
  opacity: .8; letter-spacing: .04em;
}

/* --- Audit table --- */
.jd-audit { padding: 0; }
.jd-audit-empty {
  padding: 18px 20px;
  font: 500 12.5px/1.4 var(--font-body); color: var(--fg-4);
  text-align: center;
}
.jd-audit-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.jd-audit-table th, .jd-audit-table td {
  padding: 10px 18px; text-align: left;
  font: 400 12.5px/1.4 var(--font-body);
}
.jd-audit-table th {
  font: 600 9.5px/1 var(--font-body); text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--fg-4); background: var(--bg-card-2);
  border-bottom: 1px solid var(--border-1);
  white-space: nowrap;
}
.jd-audit-table th.num { text-align: right; }
.jd-audit-table tbody tr + tr td { border-top: 1px solid var(--border-1); }
.jd-audit-table td.when {
  font-family: var(--font-mono); color: var(--fg-3);
  white-space: nowrap; font-size: 12px; width: 130px;
}
.jd-audit-table td.who { color: var(--fg-2); white-space: nowrap; }
.jd-audit-table td.who b { color: var(--fg-1); font-weight: 600; }
.jd-audit-table td.what { color: var(--fg-2); }
.jd-audit-table td.what code {
  font-family: var(--font-mono); font-size: 11.5px;
  background: var(--bg-input); border: 1px solid var(--border-2);
  padding: 1px 5px; border-radius: 3px; color: var(--fg-1);
}
