/* public/css/jobs/jobs.css
 * Phase 1 — Jobs become locally owned with a real UI.
 *
 * Two surfaces inside the #jobs-tab shell (both built by public/js/jobs/index.js):
 *   1. DIRECTORY  (#jobsDirectoryView)  — browse + search all jobs, newest first.
 *   2. JOB DETAIL (#jobsDetailView)     — a job-detail page that mirrors the
 *      Purchasing sub-tab pattern: desktop horizontal sub-nav (#jobsSubNav,
 *      modeled on #purchasingSubNav) + mobile settings-style directory with a
 *      sticky back-header (#jobsDetailBackHeader / .j-dir-*, modeled on
 *      #purchasingDirectory / #purchasingBackHeader).
 *
 * 100% JMD theme tokens (no hardcoded colors) so it tracks both themes.
 * Mobile-first; tap targets >= 44px.
 */

/* Scope the flex layout to the ACTIVE state. A bare `#jobs-tab { display:flex }`
   (ID specificity) overrides the framework's `.tab-content { display:none }`, so
   the tab stays in the layout flow even when inactive and stacks a full-height
   empty block above other tabs (e.g. Shipping). Scoping to `.active` keeps an
   inactive #jobs-tab at display:none per the tab-content contract. */
#jobs-tab { background: var(--bg-primary); color: var(--text-primary); min-height: 0; }
#jobs-tab.active { display: flex; flex-direction: column; overflow: hidden; }

/* ─── Shared section chrome ──────────────────────────────────────────── */
.j-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 24px 0; flex-wrap: wrap;
}
.j-head h1 { font-size: var(--fs-h2, 28px); font-weight: 700; margin: 0; letter-spacing: .2px; }
.j-head-sub { color: var(--text-muted); font-size: var(--fs-sm, 13px); margin-top: 2px; }

.j-btn {
  min-height: 40px; padding: 9px 16px; border-radius: var(--r-md, 8px);
  border: 1px solid var(--border-color); background: var(--bg-tertiary);
  color: var(--text-primary); font-weight: 600; font-size: var(--fs-sm, 13px);
  font-family: inherit; cursor: pointer; transition: filter .12s, transform .04s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.j-btn:hover { filter: brightness(1.06); }
.j-btn:active { transform: translateY(1px); }
.j-btn[disabled] { opacity: .45; cursor: not-allowed; }
.j-btn-primary { background: var(--accent-green); border-color: var(--accent-green); color: #fff; }
.j-btn-danger  { background: var(--danger); border-color: var(--danger); color: #fff; }
.j-btn-ghost   { background: transparent; }
.j-btn svg { width: 15px; height: 15px; flex: 0 0 auto; }

/* ─── DIRECTORY view ─────────────────────────────────────────────────── */
#jobsDirectoryView { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.j-dir-toolbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; flex-wrap: wrap; }
.j-search-wrap { flex: 1; position: relative; min-width: 200px; }
.j-search-wrap svg {
  width: 16px; height: 16px; position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%); color: var(--text-muted); pointer-events: none;
}
.j-search {
  width: 100%; padding: 10px 12px 10px 36px; border-radius: var(--r-md, 8px);
  border: 1px solid var(--border-color); background: var(--bg-card);
  color: var(--text-primary); font-size: var(--fs-sm, 13px); font-family: inherit;
  box-sizing: border-box; min-height: 42px;
}
.j-filter {
  padding: 10px 12px; border-radius: var(--r-md, 8px); border: 1px solid var(--border-color);
  background: var(--bg-card); color: var(--text-primary); font-size: var(--fs-sm, 13px);
  font-family: inherit; min-height: 42px; cursor: pointer;
}
.j-dir-count { font-size: var(--fs-sm, 13px); color: var(--text-muted); white-space: nowrap; }

.j-dir-scroll { flex: 1; overflow-y: auto; padding: 4px 24px 32px; min-height: 0; }
.j-dir-empty { color: var(--text-muted); padding: 40px 8px; text-align: center; font-style: italic; }

/* Project number — muted code, used in the detail header + mobile sub-directory meta. */
.j-card-num { font-size: var(--fs-sm, 13px); color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Job directory table (newest first). Columnar: Job # / Job Name / Status / Assigned.
   Job Name is dominant; Job # muted. Each row is a button that opens the job. */
.j-table { display: flex; flex-direction: column; }
.j-table-head,
.j-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 2.4fr) 120px minmax(0, 1fr);
  align-items: center; gap: 14px;
}
.j-table-head {
  padding: 8px 16px; border-bottom: 1px solid var(--border-color);
  position: sticky; top: 0; background: var(--bg-primary); z-index: 1;
}
.j-table-head .j-col {
  font-size: var(--fs-caption, 12px); font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: var(--tr-overline, .08em);
}
.j-table-body { display: flex; flex-direction: column; }
.j-row {
  width: 100%; text-align: left; background: var(--bg-card);
  border: 1px solid var(--border-color); border-radius: var(--r-md, 8px);
  padding: 12px 16px; margin-bottom: 8px; cursor: pointer; font-family: inherit;
  color: var(--text-primary); box-shadow: var(--shadow-sm);
  transition: filter .12s, transform .04s, border-color .12s; min-height: 48px;
}
.j-row:hover { filter: brightness(1.02); border-color: var(--border-strong); }
.j-row:active { transform: translateY(1px); }
.j-col { min-width: 0; }
.j-col-num { font-size: var(--fs-sm, 13px); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.j-col-name { font-size: var(--fs-h4, 18px); font-weight: 700; color: var(--text-primary); line-height: 1.25; word-break: break-word; }
.j-col-status { display: flex; }
.j-col-person { font-size: var(--fs-sm, 13px); color: var(--text-secondary); word-break: break-word; }

/* Status + ownership pills (shared by cards + detail header). */
.j-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border-radius: var(--r-full, 999px); font-weight: 700; font-size: var(--fs-caption, 12px);
  border: 1px solid var(--border-color); white-space: nowrap;
}
.j-pill-open    { color: var(--success-fg, #1B5740); background: var(--success-bg, #E7F2EC); border-color: var(--success); }
.j-pill-closed  { color: var(--text-muted); background: var(--bg-tertiary); }

/* ─── JOB-DETAIL view ────────────────────────────────────────────────── */
#jobsDetailView { flex: 1; display: none; flex-direction: column; min-height: 0; overflow: hidden; }
#jobsDetailView.active { display: flex; }

/* Desktop detail toolbar: back-to-directory + job title + actions.
   Extra right padding clears the global fixed help/chat bubble (top-right) so it
   never overlaps the "Close Job" action in .j-detail-actions. */
.j-detail-top {
  display: flex; align-items: center; gap: 12px; padding: 14px 72px 0 24px; flex-wrap: wrap;
}
.j-back-link {
  display: inline-flex; align-items: center; gap: 4px; background: transparent; border: none;
  color: var(--accent-cyan); font-family: inherit; font-size: var(--fs-sm, 13px); font-weight: 600;
  cursor: pointer; padding: 6px 8px 6px 0; min-height: 40px;
}
.j-back-link svg { width: 18px; height: 18px; }
.j-detail-titlewrap { flex: 1; min-width: 0; }
.j-detail-title { font-size: var(--fs-h3, 22px); font-weight: 700; line-height: 1.2; }
.j-detail-titlemeta { display: flex; align-items: center; gap: 8px; margin-top: 3px; flex-wrap: wrap; }
.j-detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Sub-nav — modeled 1:1 on #purchasingSubNav */
#jobsSubNav.sub-nav {
  display: flex; gap: 4px; padding: 8px 16px 0; border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary); flex-shrink: 0;
}
#jobsSubNav .sub-tab {
  background: transparent; border: 1px solid transparent; border-bottom: none;
  color: var(--text-muted); padding: 8px 16px; border-radius: 8px 8px 0 0;
  cursor: pointer; font-family: inherit; font-size:var(--fs-sm); font-weight: 600;
  display: flex; align-items: center; gap: 6px; margin-bottom: -1px;
}
#jobsSubNav .sub-tab:hover { color: var(--text-primary); background: var(--bg-secondary); }
#jobsSubNav .sub-tab.active {
  color: var(--accent-cyan); border-color: var(--border-color);
  background: var(--bg-primary); border-bottom-color: var(--bg-primary); z-index: 2;
}
#jobsSubContent { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
#jobsSubContent .sub-pane { display: none; flex: 1; overflow-y: auto; padding: 18px 24px; min-height: 0; }
#jobsSubContent .sub-pane.active { display: block; }

/* Overview tab layout */
.j-ov-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 1000px; }
.j-ov-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--r-lg, 12px); padding: 18px; box-shadow: var(--shadow-sm);
}
.j-ov-card.full { grid-column: 1 / -1; }
.j-ov-card h2 {
  font-size: var(--fs-overline, 11px); font-weight: 600; letter-spacing: var(--tr-overline, .14em);
  text-transform: uppercase; color: var(--text-muted); margin: 0 0 12px;
}
.j-ov-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 7px 0; border-bottom: 1px solid var(--border-color); }
.j-ov-row:last-child { border-bottom: none; }
.j-ov-label { font-size: var(--fs-sm, 13px); color: var(--text-muted); flex: 0 0 auto; }
.j-ov-value { font-size: var(--fs-body, 15px); color: var(--text-primary); font-weight: 600; text-align: right; min-width: 0; word-break: break-word; }
.j-ov-value.num { font-variant-numeric: tabular-nums; }
.j-ov-value.money { font-size: var(--fs-h4, 18px); font-weight: 700; }
.j-ov-value.muted { color: var(--text-muted); font-weight: 400; }

/* Activity rollup tiles (Work Orders / Tasks / Open MRs / POs / Shipments). */
.j-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }
.j-stat-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 12px 14px; border: 1px solid var(--border-color);
  border-radius: var(--r-md, 8px); background: var(--bg-primary);
}
.j-stat-num { font-size: var(--fs-h3, 22px); font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; line-height: 1; }
.j-stat-label { font-size: var(--fs-caption, 12px); color: var(--text-muted); font-weight: 600; }

/* Placeholder panes (Work Orders / POs / Shipping — later phases) */
.j-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: var(--text-muted); padding: 60px 20px; gap: 10px;
}
.j-placeholder svg { width: 40px; height: 40px; opacity: .5; }
.j-placeholder .j-ph-title { font-size: var(--fs-body-lg, 17px); font-weight: 600; color: var(--text-secondary); }
.j-placeholder .j-ph-sub { font-size: var(--fs-sm, 13px); max-width: 360px; }

/* ─── POs + Shipping sub-tab tables (js/jobs/index.js) ────────────────────
   Columnar read-only lists: the description/name (Vendor, Manifest title) is the
   dominant text; codes/numbers are muted. Tables wrap in a horizontal scroller
   so a wide row never forces the whole page to scroll on mobile. */
.j-tab-head { margin: 0 0 14px; }
.j-tab-h2 { margin: 0; font-size: var(--fs-h4, 18px); font-weight: 700; color: var(--text-primary); }
.j-tab-sub { font-size: var(--fs-sm, 13px); color: var(--text-muted); margin-top: 2px; }
.j-tab-loading { color: var(--text-muted); padding: 28px 8px; font-style: italic; }
.j-tab-empty {
  color: var(--text-muted); padding: 32px 16px; text-align: center; font-style: italic;
  background: var(--bg-card); border: 1px dashed var(--border-color); border-radius: var(--r-md, 8px);
}
.j-tab-tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.j-ptable { display: flex; flex-direction: column; min-width: 0; }
.j-ptable-head,
.j-prow { display: grid; align-items: center; gap: 14px; }
.j-ptable-po .j-ptable-head,
.j-ptable-po .j-prow {
  grid-template-columns: 120px minmax(0, 2.2fr) 120px 110px 70px 130px 110px;
}
.j-ptable-ship .j-ptable-head,
.j-ptable-ship .j-prow {
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.4fr) 130px 80px 110px;
}
.j-ptable-head {
  padding: 8px 16px; border-bottom: 1px solid var(--border-color);
  position: sticky; top: 0; background: var(--bg-primary); z-index: 1;
}
.j-ptable-head .j-pcol {
  font-size: var(--fs-caption, 12px); font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: var(--tr-overline, .08em); white-space: nowrap;
}
.j-ptable-body { display: flex; flex-direction: column; }
.j-prow {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--r-md, 8px); padding: 12px 16px; margin-bottom: 8px;
  color: var(--text-primary); box-shadow: var(--shadow-sm); min-height: 44px;
}
.j-pcol { min-width: 0; }
.j-pcol.num { font-variant-numeric: tabular-nums; }
/* Dominant name columns (Vendor, Manifest title). */
.j-pc-name, .j-mc-name { font-size: var(--fs-h4, 18px); font-weight: 700; color: var(--text-primary); line-height: 1.25; word-break: break-word; }
/* Muted codes / secondary text. */
.j-pc-num { font-size: var(--fs-sm, 13px); color: var(--text-muted); font-variant-numeric: tabular-nums; word-break: break-word; }
.j-pc-date, .j-pc-num2, .j-pc-recv, .j-mc-date, .j-mc-items { font-size: var(--fs-sm, 13px); color: var(--text-secondary); }
.j-pc-money { font-size: var(--fs-body, 15px); font-weight: 700; color: var(--text-primary); }
.j-pc-dest, .j-mc-dest { font-size: var(--fs-sm, 13px); color: var(--text-secondary); word-break: break-word; }
.j-pc-status, .j-mc-status { display: flex; }

/* Soft neutral pill for PO statuses (varied CrowsNest status names). */
.j-pill-soft { color: var(--text-secondary); background: var(--bg-tertiary); }

/* Shipping pane: CrowsNest section sits above the Phase 6 builder module. */
.j-ship-cn { margin-bottom: 28px; }
.j-ship-module { margin-top: 4px; }

@media (max-width: 768px) {
  /* Stack each table row into a labeled card so nothing scrolls horizontally. */
  .j-tab-tablewrap { overflow-x: visible; }
  .j-ptable-head { display: none; }
  .j-ptable-po .j-prow,
  .j-ptable-ship .j-prow {
    display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
    grid-template-columns: none; padding: 14px 16px;
  }
  /* Name first, then labeled secondary fields. */
  .j-pc-name, .j-mc-name { order: 0; }
  .j-prow .j-pcol:not(.j-pc-name):not(.j-mc-name):not(.j-pc-status):not(.j-mc-status)::before {
    content: attr(data-label) ": "; color: var(--text-muted); font-weight: 600; font-size: var(--fs-caption, 12px);
  }
  .j-pc-status, .j-mc-status { margin-top: 2px; }
}

/* ─── Mobile drill pattern (<=768px) — settings-style detail directory ───
   Mirrors the Purchasing #poViewContainer / .p-drilled pattern:
   - Detail opens to a directory of sub-tab rows (.j-subdir).
   - Tapping a row adds .j-drilled to #jobsDetailView → pane + back header show,
     sub-directory hides. js/jobs/index.js pushes one history entry so the
     hardware Back returns to the sub-directory (then the job directory).
   - Desktop is unaffected: .j-subdir + #jobsDetailBackHeader are hidden above
     768px, and the desktop sub-nav stays visible. */
#jobsDetailSubDir { display: none; }
#jobsDetailBackHeader { display: none; }

@media (max-width: 768px) {
  .j-head { padding: 14px 14px 0; }
  .j-head h1 { font-size: var(--fs-h3, 22px); }
  .j-dir-toolbar { padding: 10px 12px; }
  .j-dir-scroll { padding: 4px 12px 28px; }
  .j-search { font-size: 16px; }

  /* Job directory table → stacked cards on narrow screens (no horizontal scroll).
     Hide the header row; each row stacks its columns and labels them. */
  .j-table-head { display: none; }
  .j-row {
    display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
    padding: 14px 16px;
  }
  .j-col-name { order: 1; }
  .j-col-num { order: 2; }
  .j-col-status { order: 3; margin-top: 2px; }
  .j-col-person { order: 4; }
  .j-col-person::before { content: attr(data-label) ": "; color: var(--text-muted); }
  .j-col-person[data-label]:empty { display: none; }

  /* Detail: hide the desktop top bar + sub-nav; drive everything from the
     sub-directory + back header instead. */
  .j-detail-top { display: none; }
  #jobsDetailView:not(.j-drilled) #jobsSubNav { display: none; }
  #jobsDetailView:not(.j-drilled) #jobsSubContent { display: none; }
  #jobsDetailView.j-drilled #jobsSubNav { display: none; }

  #jobsDetailSubDir { display: block; flex: 1; overflow-y: auto; padding: 14px 12px; }
  #jobsDetailView.j-drilled #jobsDetailSubDir { display: none; }

  .j-subdir-hd { padding: 4px 6px 12px; }
  .j-subdir-hd .j-subdir-name { font-size: var(--fs-h4, 18px); font-weight: 700; }
  .j-subdir-hd .j-subdir-meta { display: flex; align-items: center; gap: 8px; margin-top: 5px; flex-wrap: wrap; }

  .j-subdir-group { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px; overflow: hidden; }
  .j-subdir-row {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px;
    padding: 8px 14px; background: transparent; border: none; cursor: pointer;
    font-family: inherit; text-align: left; color: var(--text-primary);
  }
  .j-subdir-row + .j-subdir-row { border-top: 1px solid var(--border-color); }
  .j-subdir-row:active { background: var(--bg-secondary); }
  .j-subdir-icon {
    flex: 0 0 auto; width: 30px; height: 30px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center; background: var(--bg-tertiary);
  }
  .j-subdir-icon svg { width: 17px; height: 17px; }
  .j-subdir-label { flex: 1; font-size: 16px; font-weight: 600; min-width: 0; }
  .j-subdir-chevron { width: 16px; height: 16px; color: var(--text-muted); flex: 0 0 auto; }

  /* Back header — visible only when drilled into a sub-pane on mobile */
  #jobsDetailView.j-drilled #jobsDetailBackHeader {
    position: relative; display: flex; align-items: center; min-height: 44px;
    padding: 0 8px; border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary); flex-shrink: 0;
  }
  #jobsDetailBackBtn {
    display: inline-flex; align-items: center; gap: 2px; background: transparent; border: none;
    color: var(--accent-cyan); font-family: inherit; font-size:var(--fs-body); font-weight: 600;
    cursor: pointer; padding: 10px 12px 10px 4px; min-height: 44px;
  }
  #jobsDetailBackBtn svg { width: 20px; height: 20px; flex: 0 0 auto; }
  #jobsDetailBackTitle {
    position: absolute; left: 50%; transform: translateX(-50%);
    font-size: 16px; font-weight: 700; color: var(--text-primary);
    pointer-events: none; white-space: nowrap;
  }
  #jobsDetailView.j-drilled #jobsSubContent,
  #jobsDetailView.j-drilled #jobsDetailBackHeader { animation: jDirSlideInR .25s ease-out; }
  #jobsDetailView:not(.j-drilled) #jobsDetailSubDir { animation: jDirSlideInL .25s ease-out; }
  @media (prefers-reduced-motion: reduce) {
    #jobsDetailView.j-drilled #jobsSubContent,
    #jobsDetailView.j-drilled #jobsDetailBackHeader,
    #jobsDetailView:not(.j-drilled) #jobsDetailSubDir { animation: none; }
  }

  .j-ov-grid { grid-template-columns: 1fr; gap: 12px; }
}

@keyframes jDirSlideInR { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
@keyframes jDirSlideInL { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: translateX(0); } }

/* ─── Edit modal (create / edit job) ─────────────────────────────────── */
.j-modal-overlay {
  position: fixed; inset: 0; z-index: 9000; background: rgba(8,27,22,.55);
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.j-modal-overlay.show { display: flex; }
.j-modal {
  width: 480px; max-width: 100%; max-height: 90vh; overflow-y: auto;
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--r-lg, 12px); box-shadow: var(--shadow-xl); display: flex; flex-direction: column;
}
.j-modal-head { padding: 18px 20px 8px; }
.j-modal-head h3 { margin: 0; font-size: var(--fs-h4, 18px); font-weight: 700; color: var(--text-primary); }
.j-modal-body { padding: 8px 20px 16px; display: flex; flex-direction: column; gap: 12px; }
.j-field { display: flex; flex-direction: column; gap: 5px; }
.j-field.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.j-field label { font-size: var(--fs-caption, 12px); color: var(--text-muted); font-weight: 600; }
.j-field input, .j-field select, .j-field textarea {
  padding: 10px 12px; border-radius: var(--r-sm, 6px); border: 1px solid var(--border-color);
  background: var(--bg-primary); color: var(--text-primary); font-size: var(--fs-sm, 13px);
  font-family: inherit; min-height: 42px; box-sizing: border-box;
}
.j-field textarea { min-height: 64px; resize: vertical; }
.j-modal-err { color: var(--danger); font-size: var(--fs-sm, 13px); min-height: 18px; padding: 0 2px; }
.j-modal-foot { padding: 8px 20px 18px; display: flex; justify-content: flex-end; gap: 10px; }

/* ─── Phase 2: Work Orders & Tasks pane (js/jobs/workorders.js) ──────────
   Lives inside #jobsPaneWorkorders. Description is dominant; the WO number is
   the muted code (JMD theme rule). 100% theme tokens; mobile-first. */
.jwo-loading { color: var(--text-muted); padding: 40px 8px; text-align: center; font-style: italic; }

.jwo-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.jwo-head-titles { min-width: 0; }
.jwo-h2 { font-size: var(--fs-h4, 18px); font-weight: 700; margin: 0; color: var(--text-primary); }
.jwo-sub { color: var(--text-muted); font-size: var(--fs-sm, 13px); margin-top: 2px; }

.jwo-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: var(--text-muted); padding: 50px 20px; gap: 8px;
}
.jwo-empty svg { width: 38px; height: 38px; opacity: .5; }
.jwo-empty-title { font-size: var(--fs-body-lg, 17px); font-weight: 600; color: var(--text-secondary); }
.jwo-empty-sub { font-size: var(--fs-sm, 13px); max-width: 340px; }

/* ── Compact Work Orders TABLE (cards → condensed rows). No pills — status is a
   plain word in its column. Grid columns shared by header row + each WO row.   */
.jwo-table {
  max-width: 1000px; border: 1px solid var(--border-color);
  border-radius: var(--r-lg, 12px); overflow: hidden; background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  /* exp | WO | Series | Description | Status | % | Ships  (+ actions when editable) */
  --jwo-cols: 26px 76px 64px minmax(0, 1fr) 96px 120px 110px;
}
.jwo-table.has-act { --jwo-cols: 26px 76px 64px minmax(0, 1fr) 96px 120px 110px 92px; }

.jwo-thead, .jwo-row {
  display: grid; grid-template-columns: var(--jwo-cols);
  align-items: center; column-gap: 10px; padding: 0 12px;
}
.jwo-thead {
  min-height: 36px; background: var(--bg-tertiary, #f4f5f6);
  border-bottom: 1px solid var(--border-color);
}
.jwo-th {
  font-size: var(--fs-caption, 12px); font-weight: 700; letter-spacing: .02em;
  text-transform: uppercase; color: var(--text-muted);
}
.jwo-th.jwo-c-pct, .jwo-th.jwo-c-date { text-align: left; }

.jwo-row {
  min-height: 46px; border-bottom: 1px solid var(--border-color);
  cursor: pointer; transition: background .12s ease;
}
.jwo-row:last-of-type { border-bottom: none; }
.jwo-row:hover { background: var(--bg-tertiary, #f7f8f9); }
.jwo-row:focus-visible { outline: 2px solid var(--accent, #1E4E7C); outline-offset: -2px; }
.jwo-row.open { background: var(--bg-tertiary, #f4f6f8); }

.jwo-cell { min-width: 0; display: flex; align-items: center; }
.jwo-c-exp { justify-content: center; }
/* Single right-pointing chevron; rotates 90° when its row is expanded. */
.jwo-chev { display: inline-flex; color: var(--text-muted); transition: transform .22s cubic-bezier(.22,.9,.34,1); }
.jwo-chev svg { width: 15px; height: 15px; display: block; }
.jwo-row.open .jwo-chev { transform: rotate(90deg); }

/* Description dominant; WO number muted (JMD theme rule). */
.jwo-desc {
  font-size: var(--fs-base, 15px); font-weight: 600; color: var(--text-primary);
  line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.jwo-wonum { font-size: var(--fs-sm, 13px); color: var(--text-muted); font-variant-numeric: tabular-nums; }
/* Series is its OWN column (2026-07-02; was stacked under the WO number). */
.jwo-series {
  font-size: var(--fs-sm, 13px); font-weight: 600; color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.jwo-series-none { color: var(--text-muted); }

/* Status = plain word in a cell (NOT a pill). Subtle colour only. */
.jwo-status { font-size: var(--fs-sm, 13px); font-weight: 600; }
.jwo-stat-active   { color: var(--info-fg, #1E4E7C); }
.jwo-stat-hold     { color: var(--warning-fg, #845E08); }
.jwo-stat-complete { color: var(--success-fg, #1B5740); }

.jwo-c-pct { flex-direction: column; align-items: flex-start; gap: 3px; }
.jwo-pctnum { font-size: var(--fs-sm, 13px); font-weight: 600; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.jwo-progress {
  width: 100%; max-width: 80px; height: 5px; border-radius: var(--r-full, 999px);
  background: var(--bg-tertiary); overflow: hidden;
}
.jwo-progress-bar { display: block; height: 100%; background: var(--accent-cyan); border-radius: inherit; transition: width .25s ease; }
.jwo-progress-bar.done { background: var(--accent-green); }

.jwo-c-date { font-size: var(--fs-sm, 13px); color: var(--text-secondary); font-variant-numeric: tabular-nums; }

.jwo-card-actions { display: flex; gap: 4px; justify-content: flex-end; }
.jwo-icon-btn { min-height: 36px; min-width: 36px; padding: 6px; }
.jwo-icon-btn svg { width: 16px; height: 16px; }
/* Delete lives at the bottom of the WO edit dialog (danger, left-aligned). */
.jwo-modal-del { margin-right: auto; }

/* ── Phase 3: nested Task SUB-ROWS under an expanded WO row ───────────────────
   Expand/collapse uses the house grid-rows pattern (see .fsched-detail):
   outer grid animates 0fr→1fr; .jwo-tasks-clip (overflow:hidden; min-height:0)
   clips; the body fades/rises in slightly after the drop-down starts. */
.jwo-tasks {
  grid-column: 1 / -1;
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows .28s cubic-bezier(.22,.9,.34,1);
}
.jwo-tasks.open { grid-template-rows: 1fr; border-bottom: 1px solid var(--border-color); }
.jwo-tasks-clip { overflow: hidden; min-height: 0; }
.jwo-row + .jwo-tasks.open { border-top: 1px dashed var(--border-color); }
.jwo-tasks-body {
  padding: 6px 12px 12px 36px; background: var(--bg-subtle, #fafbfc);
  /* Task sub-columns: Task | Description | Status | % | Assignee/Due (+ act) */
  --jwt-cols: 84px minmax(0, 1.3fr) 96px 110px minmax(0, 1fr);
  /* Subtle fade + rise, slightly delayed behind the drop-down. */
  opacity: 0; transform: translateY(-4px);
  transition: opacity .22s ease .05s, transform .22s ease .05s;
}
.jwo-tasks.open .jwo-tasks-body { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .jwo-tasks, .jwo-tasks-body, .jwo-chev { transition: none; }
}
.jwo-tasks-body.has-act { --jwt-cols: 84px minmax(0, 1.3fr) 96px 110px minmax(0, 1fr) 84px; }

.jwt-loading, .jwt-empty {
  font-size: var(--fs-caption, 12px); color: var(--text-muted); font-style: italic; padding: 8px 2px;
}

.jwt-subhead, .jwt-row {
  display: grid; grid-template-columns: var(--jwt-cols);
  align-items: center; column-gap: 10px; padding: 0 6px;
}
.jwt-subhead { min-height: 30px; border-bottom: 1px solid var(--border-color); }
.jwt-sh {
  font-size:var(--fs-overline); font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
  color: var(--text-muted);
}

.jwt-row {
  min-height: 42px; border-bottom: 1px dashed var(--border-color);
}
.jwt-row:last-of-type { border-bottom: none; }
.jwt-cell { min-width: 0; display: flex; align-items: center; }

/* Description dominant; task number is the muted code (JMD theme rule). */
.jwt-title {
  font-weight: 600; color: var(--text-primary); font-size: var(--fs-sm, 13px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.jwt-tnum { font-size: var(--fs-caption, 12px); color: var(--text-muted); font-variant-numeric: tabular-nums; }

.jwt-c-pct { flex-direction: column; align-items: flex-start; gap: 2px; }
.jwt-pct { font-size: var(--fs-caption, 12px); font-weight: 600; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.jwt-progress {
  width: 100%; max-width: 72px; height: 4px; border-radius: var(--r-full, 999px);
  overflow: hidden; background: var(--border-color, #e5e5e5);
}
.jwt-progress-bar { display: block; height: 100%; background: var(--accent, #1E4E7C); transition: width .25s ease; }
.jwt-progress-bar.done { background: var(--success, #2E7D32); }

.jwt-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.jwt-bit { font-size: var(--fs-caption, 12px); color: var(--text-muted); }
.jwt-bit + .jwt-bit::before { content: "•"; margin-right: 8px; color: var(--border-strong); }
.jwt-assignee { color: var(--text-secondary); font-weight: 600; }

.jwt-actions { display: flex; gap: 4px; justify-content: flex-end; }
.jwt-add { margin-top: 10px; }

@media (max-width: 768px) {
  /* Keep the table from forcing horizontal PAGE scroll: drop lower-priority columns. */
  .jwo-table { --jwo-cols: 24px minmax(0, 1fr) 84px 56px; }
  /* Act column fits two 44px buttons (Drawing + Edit) without overflow. */
  .jwo-table.has-act { --jwo-cols: 24px minmax(0, 1fr) 84px 56px 96px; }
  .jwo-thead .jwo-c-num, .jwo-row .jwo-c-num { display: none; }
  .jwo-thead .jwo-c-series, .jwo-row .jwo-c-series { display: none; }
  .jwo-thead .jwo-c-date, .jwo-row .jwo-c-date { display: none; }
  .jwo-c-pct .jwo-progress { display: none; }   /* keep just the % number on mobile */

  .jwo-head { margin-bottom: 12px; }
  .jwo-head .j-btn { width: 100%; min-height: 44px; }
  .jwo-row { min-height: 48px; }
  /* Edit/delete tap targets >= 44px on mobile (desktop stays compact at 36). */
  .jwo-icon-btn { min-height: 44px; min-width: 44px; }

  /* Task sub-rows: indent less, drop the assignee/due column; keep core info. */
  .jwo-tasks-body { padding-left: 16px; --jwt-cols: 70px minmax(0, 1fr) 78px 52px; }
  .jwo-tasks-body.has-act { --jwt-cols: 70px minmax(0, 1fr) 78px 52px 80px; }
  .jwt-subhead .jwt-c-meta, .jwt-row .jwt-c-meta { display: none; }
  .jwt-c-pct .jwt-progress { display: none; }
  .jwt-row { min-height: 46px; }
  .jwt-add { width: 100%; min-height: 44px; }
}

/* ─── Per-WO Drawing viewer overlay (shared /js/shared/drawing-viewer.js) ─────
   Full-screen fixed host above everything (modals sit at 9000); the shared
   viewer root is height:100% so the overlay's fixed inset gives it its size.
   The compound .dv-host selector is required: the viewer adds `dv-host` to its
   container and drawing-viewer.css (`.dv-host { position: relative }`) loads
   AFTER this sheet (runtime-injected link), so at equal specificity its
   position would win and drop the overlay into normal document flow. */
.jwo-drawing-overlay,
.jwo-drawing-overlay.dv-host {
  position: fixed; inset: 0; z-index: 9500;
  background: var(--bg-app, #fff);
}

/* ─── Reusable staggered list entrance (composited fade + rise) ───────────────
   Opt-in: JS owners add class `jmd-fade-rise` to each list item to animate it in,
   and may set `--jmd-stagger` (e.g. style="--jmd-stagger:40ms") per item for a
   staggered cascade. NOT auto-applied to existing selectors (would fight layout).
   Only runs when the user hasn't requested reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  @keyframes jmdFadeRise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
  .jmd-fade-rise { animation: jmdFadeRise 200ms ease-out both; animation-delay: var(--jmd-stagger, 0ms); }
}
