body { min-height: 100vh; }
.risk-dot { width: .9rem; height: .9rem; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 2px rgba(0,0,0,.08); }
.risk-red { background: #dc3545; }
.risk-amber { background: #ffc107; }
.risk-green { background: #198754; }
.risk-gray { background: #6c757d; }
.progress { min-width: 8rem; height: 1.25rem; }
@media (max-width: 767px) { .table { font-size: .88rem; } }

/* Active job tile board */
.job-board { overflow: hidden; }
.job-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 21rem), 1fr));
  gap: 1rem;
  padding: 1rem;
  background: #f4f6f9;
  align-items: start;
}
.job-grid-empty {
  grid-column: 1 / -1;
  padding: 2.5rem 1rem;
  border: 1px dashed #adb5bd;
  border-radius: .75rem;
  background: #fff;
  color: var(--bs-secondary-color);
  text-align: center;
}
.job-tile {
  --job-color: #64748b;
  --job-surface: #f8fafc;
  position: relative;
  overflow: hidden;
  border: 1px solid #d9dee6;
  border-radius: .85rem;
  background: linear-gradient(145deg, var(--job-surface) 0%, #fff 62%);
  box-shadow: 0 .2rem .7rem rgba(15, 23, 42, .09);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.job-tile[data-job-url] { cursor: pointer; }
.job-tile:hover {
  transform: translateY(-2px);
  border-color: var(--job-color);
  box-shadow: 0 .55rem 1.2rem rgba(15, 23, 42, .13);
}
.job-tile:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--job-color) 38%, transparent);
  outline-offset: 3px;
}
.job-tile :is(a, button, input, textarea, select, label) { cursor: auto; }
.job-tile :is(a, button, label, input[type="checkbox"]) { cursor: pointer; }
.job-tile.is-selected {
  border-color: var(--job-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--job-color) 24%, transparent), 0 .55rem 1.2rem rgba(15, 23, 42, .13);
}
.job-tile-accent { height: .45rem; background: var(--job-color); }
.job-tile-body { display: flex; flex-direction: column; gap: .85rem; min-height: 100%; padding: 1rem; }
.job-tile-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; }
/* Carries the reason from Order.risk(), so it is a sentence rather than a
   one-word label and has to wrap. The dot stays aligned to the first line. */
.job-risk-label {
  display: flex;
  align-items: flex-start;
  gap: .4rem;
  margin-bottom: .3rem;
  color: #5f6b7a;
  font-size: .74rem;
  font-weight: 600;
  line-height: 1.3;
}
.job-risk-label .risk-dot { width: .65rem; height: .65rem; flex: 0 0 auto; margin-top: .2rem; }
.job-customer { margin: 0; font-size: 1.12rem; line-height: 1.25; }
.job-customer a { color: #172033; text-decoration: none; }
.job-customer a:hover { color: var(--job-color); text-decoration: underline; }
.job-description { margin: .3rem 0 0; color: #526071; font-size: .88rem; line-height: 1.35; }
.job-order-number { display: inline-block; margin-top: .2rem; font-size: .86rem; font-weight: 600; }
.job-tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.job-status-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--job-color);
  border-radius: 999px;
  padding: .2rem .55rem;
  background: #fff;
  color: var(--job-color);
  font-size: .76rem;
  font-weight: 750;
}
.job-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .7rem;
  margin: 0;
}
.job-facts > div {
  border: 1px solid rgba(100, 116, 139, .18);
  border-radius: .6rem;
  padding: .55rem .65rem;
  background: rgba(255, 255, 255, .72);
}
.job-facts .job-fact-wide { grid-column: 1 / -1; }
.job-facts dt {
  margin-bottom: .18rem;
  color: #687386;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.job-facts dd { margin: 0; color: #172033; font-size: .88rem; font-weight: 600; }
.job-tile .progress { min-width: 0; height: 1.15rem; background: #e6eaf0; }
.job-tile .progress-bar { background: var(--job-color); }
.job-status-awaiting_deposit { --job-color: #a16207; --job-surface: #fffbeb; }
.job-status-confirmed { --job-color: #2563eb; --job-surface: #eff6ff; }
.job-status-waiting_materials { --job-color: #c2410c; --job-surface: #fff7ed; }
.job-status-ready_production { --job-color: #0f766e; --job-surface: #f0fdfa; }
.job-status-in_production { --job-color: #4f46e5; --job-surface: #eef2ff; }
.job-status-quality_check { --job-color: #7e22ce; --job-surface: #faf5ff; }
.job-status-ready_ship { --job-color: #15803d; --job-surface: #f0fdf4; }
.job-status-on_hold { --job-color: #b91c1c; --job-surface: #fef2f2; }
.job-status-shipped { --job-color: #047857; --job-surface: #ecfdf5; }
@media (max-width: 767px) {
  .job-grid { padding: .75rem; }
}

/* Job due countdown, comments, and attachments */
.job-due {
  display: block;
  margin-top: .18rem;
  font-size: .72rem;
  font-weight: 750;
  line-height: 1.25;
}
.job-due-overdue { color: #b42318; }
.job-due-today { color: #b54708; }
.job-due-upcoming { color: #397152; }
.job-sheets {
  overflow: hidden;
  border: 1px solid rgba(100, 116, 139, .22);
  border-radius: .65rem;
  background: rgba(255, 255, 255, .78);
}
.job-sheets-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .65rem .75rem;
  border-bottom: 1px solid rgba(100, 116, 139, .18);
  color: #344054;
  font-size: .82rem;
  font-weight: 750;
}
.job-sheet-progress {
  border-radius: 999px;
  padding: .18rem .48rem;
  background: #eef2f6;
  color: #475467;
  font-size: .7rem;
  font-weight: 750;
  white-space: nowrap;
}
.job-sheet-list { display: grid; gap: .45rem; padding: .65rem .75rem; }
.job-sheet-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem .75rem;
  border: 1px solid rgba(100, 116, 139, .18);
  border-radius: .5rem;
  padding: .5rem .55rem;
  background: #fff;
}
.job-sheet-row.is-cut { border-color: #75b798; background: #f0fff6; }
.job-sheet-spec { color: #273244; font-size: .8rem; overflow-wrap: anywhere; }
.job-sheet-units { display: flex; flex-wrap: wrap; gap: .35rem; }
.job-sheet-unit { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
.job-sheet-unit-readonly {
  border-radius: .45rem;
  padding: .18rem .25rem;
  background: #f7f8fa;
}
.job-sheet-unit-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  min-height: 1.35rem;
  border: 1px solid #cbd2dc;
  border-radius: .35rem;
  background: #fff;
  color: #475467;
  font-size: .68rem;
  font-weight: 750;
}
.job-sheet-check { display: inline-flex; align-items: center; gap: .18rem; margin: 0; color: #667085; font-size: .68rem; }
.job-sheet-check .form-check-input { width: 1.1rem; height: 1.1rem; margin: 0; }
.job-inventory-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: .14rem .4rem;
  font-size: .65rem;
  font-weight: 750;
  line-height: 1.2;
  white-space: nowrap;
}
.job-inventory-available { border-color: #75b798; background: #eaf8f0; color: #146c43; }
.job-inventory-on_order { border-color: #ffda6a; background: #fff8dd; color: #8a5a00; }
.job-inventory-needs_ordered { border-color: #f1aeb5; background: #fff1f2; color: #b42318; }
.job-inventory-cut { border-color: #9ec5fe; background: #eaf2ff; color: #0a58ca; }
.job-sheets-empty { margin: 0; padding: .7rem .75rem; color: #667085; font-size: .78rem; }
.job-activity {
  overflow: hidden;
  border: 1px solid rgba(100, 116, 139, .22);
  border-radius: .65rem;
  background: rgba(255, 255, 255, .78);
}
.job-activity-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .65rem .75rem;
  border-bottom: 1px solid rgba(100, 116, 139, .18);
  color: #344054;
  font-size: .82rem;
  font-weight: 750;
}
.job-activity-count {
  color: #667085;
  font-size: .7rem;
  font-weight: 600;
  white-space: nowrap;
}
.job-activity-body { display: grid; gap: .8rem; padding: .75rem; }
.job-activity-section h4 {
  margin: 0 0 .4rem;
  color: #667085;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.job-comment-list, .job-attachment-list {
  display: grid;
  gap: .45rem;
  max-height: 13rem;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}
.job-comment-list li, .job-attachment-list li {
  border: 1px solid rgba(100, 116, 139, .17);
  border-radius: .5rem;
  padding: .55rem;
  background: #fff;
}
.job-activity-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .25rem .65rem;
  margin-bottom: .25rem;
  color: #667085;
  font-size: .68rem;
}
.job-comment-body {
  color: #273244;
  font-size: .8rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.job-attachment-list li { display: grid; gap: .15rem; }
.job-attachment-list a { font-size: .8rem; font-weight: 700; overflow-wrap: anywhere; }
.job-attachment-list span { color: #667085; font-size: .68rem; }
.job-activity-empty { margin: 0; color: #667085; font-size: .78rem; }
.job-activity-form {
  display: grid;
  gap: .55rem;
  padding-top: .7rem;
  border-top: 1px solid rgba(100, 116, 139, .18);
}
.job-activity-form .form-label { margin: 0; color: #475467; font-weight: 650; }
.job-activity-form textarea { resize: vertical; min-height: 4.25rem; }
.job-activity-form-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .55rem;
}
.job-activity-form-footer span { color: #667085; font-size: .68rem; }

.inventory-table tr[data-inventory-edit-url] { cursor: pointer; }
.inventory-table tr[data-inventory-edit-url]:focus-visible { outline: 2px solid #0d6efd; outline-offset: -2px; }

/* Full job detail page */
.job-open-link { align-self: flex-start; }
.job-detail-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.job-detail-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.5rem; }
.job-detail-facts div { min-width: 0; }
.job-detail-facts dt { margin-bottom: .2rem; color: #667085; font-size: .72rem; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.job-detail-facts dd { margin: 0; color: #172033; overflow-wrap: anywhere; }
.job-detail-notes { color: #344054; white-space: normal; }
.job-detail-sheets .card-body { padding-top: .8rem; }
.job-sheet-list-detail { padding: 0; }
.job-sheet-row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }
.job-sheet-unit-detail {
  border-left: 1px solid var(--bs-border-color);
  padding-left: .55rem;
}
.job-sheet-inventory-actions { display: inline-flex; flex-wrap: wrap; gap: .3rem; }
.job-sheet-inventory-actions form { margin: 0; }
.job-sheet-add-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(5.5rem, 1fr)) auto;
  align-items: end;
  gap: .75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--bs-border-color);
}
@media (max-width: 991px) {
  .job-sheet-add-form { grid-template-columns: repeat(2, minmax(7rem, 1fr)); }
}
.job-detail-activity { background: #fff; }
.job-detail-activity .job-activity-heading { padding: .85rem 1rem; font-size: 1rem; }
.job-detail-activity .job-activity-body { gap: 1rem; padding: 1rem; }
.job-detail-activity-list { max-height: none; }
.job-detail-activity .job-activity-section h2 { margin: 0 0 .5rem; color: #667085; font-size: .72rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
@media (max-width: 575px) {
  .job-detail-facts { grid-template-columns: 1fr; }
  .job-sheet-add-form { grid-template-columns: 1fr; }
  .job-activity-heading { align-items: flex-start; flex-direction: column; gap: .2rem; }
}

/* Sheet inventory dashboard */
.inventory-dashboard-card { overflow: hidden; }
.inventory-table th {
  color: #667085;
  font-size: .7rem;
  letter-spacing: .035em;
  text-transform: uppercase;
  white-space: nowrap;
}
.inventory-table td { font-size: .84rem; }
.inventory-used-count { color: #0d6efd; font-weight: 800; }
.inventory-available-count { color: #198754; font-weight: 800; }
.inventory-state {
  display: inline-flex;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: .2rem .5rem;
  font-size: .7rem;
  font-weight: 750;
  white-space: nowrap;
}
.inventory-state-available { border-color: #75b798; background: #eaf8f0; color: #146c43; }
.inventory-state-partially-allocated { border-color: #9ec5fe; background: #eaf2ff; color: #0a58ca; }
.inventory-state-fully-allocated { border-color: #6ea8fe; background: #cfe2ff; color: #084298; }
.inventory-state-on-order { border-color: #ffda6a; background: #fff8dd; color: #8a5a00; }
.inventory-state-consumed { border-color: #adb5bd; background: #e9ecef; color: #495057; }
.inventory-assignment {
  display: grid;
  color: #0d6efd;
  font-size: .78rem;
  font-weight: 700;
  text-decoration: none;
}
.inventory-assignment + .inventory-assignment { margin-top: .35rem; }
.inventory-assignment:hover { text-decoration: underline; }
.inventory-assignment span { color: #667085; font-size: .68rem; font-weight: 500; }

/* One grouped inventory row can cover lots carrying different codes. */
.inventory-codes { font-size: .82rem; }
.inventory-codes span { display: block; white-space: nowrap; }

/* Job cost panel: hours and dollars per operation, live material, profit. */
.costing-table { font-size: .92rem; }
.costing-table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); }
.costing-table .tabular { font-variant-numeric: tabular-nums; }
.costing-table em { font-style: italic; color: var(--bs-secondary-color); }
.costing-subtotal td { border-top: 2px solid #dee2e6; font-weight: 600; background: #f8f9fa; }
.costing-totals dl { display: grid; gap: .3rem; margin: 0 0 .6rem; max-width: 22rem; }
.costing-totals dl > div { display: flex; justify-content: space-between; gap: 1.5rem; }
.costing-totals dt { font-weight: 500; color: #526071; margin: 0; }
.costing-totals dd { margin: 0; font-variant-numeric: tabular-nums; }
.costing-totals .costing-rule { border-top: 1px solid #dee2e6; padding-top: .3rem; font-weight: 600; }
.costing-totals .costing-rule dt, .costing-totals .costing-rule dd { color: #172033; }
.costing-totals .costing-profit { border-top: 2px solid #172033; padding-top: .35rem; font-weight: 700; font-size: 1.05rem; }
.costing-totals .costing-profit dt { color: #172033; font-weight: 700; }

/* Inline material pricing on the job cost panel. */
.material-price-form { display: flex; align-items: center; justify-content: flex-end; gap: .35rem; margin: 0; }
.material-price-input { display: inline-flex; align-items: baseline; gap: .1rem; }
.material-price-input span { color: var(--bs-secondary-color); font-size: .88rem; }
.material-price-input input {
  width: 6.2rem;
  padding: .15rem .35rem;
  border: 1px solid #ced4da;
  border-radius: .25rem;
  text-align: right;
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
  background: #fff;
}
.material-price-input input:focus { border-color: #0d6efd; outline: 2px solid rgba(13,110,253,.2); outline-offset: 0; }
.material-price-save { white-space: nowrap; padding: .1rem .5rem; font-size: .8rem; }
.material-pinned {
  display: inline-block;
  margin-left: .4rem;
  padding: 0 .35rem;
  border: 1px solid #adb5bd;
  border-radius: .2rem;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #526071;
  cursor: help;
}
[data-material-subtotal].is-estimated { color: #9a6410; }

/* Time log entry: one row of fields matching the shop's time sheet columns.

   An explicit grid rather than a wrapping flex row. With flex the fields summed
   to within a pixel of the container, so the Add button dropped to a line of its
   own and the description then grew into the space that left behind. Naming the
   columns keeps every control on one row and lets the description absorb
   whatever is spare. */
.time-log-form { display: grid; align-items: end; gap: .5rem; }
.time-log-form-start { grid-template-columns: minmax(7rem, 1fr) 9rem auto; }
.time-log-form-entry { grid-template-columns: minmax(7rem, 1fr) 8.25rem 8rem 7.25rem 7.25rem 4.25rem auto; }
.time-log-field { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.time-log-field .form-label { margin: 0; font-size: .74rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: #526071; }
.time-log-field .form-control, .time-log-field .form-select { width: 100%; min-width: 0; }
.time-log-duration output { font-variant-numeric: tabular-nums; font-weight: 600; padding: .375rem 0; white-space: nowrap; }
.time-log-duration output.is-invalid-duration { color: #a8301b; font-weight: 500; font-size: .8rem; white-space: normal; }
.time-log-submit .btn { width: 100%; white-space: nowrap; }
.time-log-table { font-size: .9rem; }
.time-log-table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); }
.time-log-table .tabular { font-variant-numeric: tabular-nums; }
.time-log-table form { margin: 0; }
.time-log-category {
  display: inline-block; padding: .05rem .5rem; border-radius: 1rem;
  font-size: .8rem; background: #e9ecef; color: #343a40; white-space: nowrap;
}
.time-log-cut { background: #cfe2ff; color: #084298; }
.time-log-bend { background: #ffe5d0; color: #8a3e00; }
.time-log-design { background: #e2d9f3; color: #432874; }
.time-log-assembly { background: #d1e7dd; color: #0f5132; }
.time-log-load { background: #e2e3e5; color: #41464b; }
.time-log-prep { background: #fff3cd; color: #664d03; }

/* Too narrow for one row: description over its own line, the rest in pairs. */
@media (max-width: 991px) {
  .time-log-form-entry { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .time-log-form-entry .time-log-description { grid-column: 1 / -1; }
  .time-log-form-entry .time-log-submit { grid-column: 1 / -1; }
}
@media (max-width: 575px) {
  .time-log-form-start { grid-template-columns: minmax(0, 1fr); }
}

/* A step currently running on the clock. */
.running-timers { border-bottom: 1px solid #dee2e6; }
.running-timer {
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem 1rem; background: #fff8e6; border-left: 4px solid #d9822b;
}
.running-timer + .running-timer { border-top: 1px solid #f0e2c4; }
.running-timer-what { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .5rem; flex: 1 1 auto; min-width: 0; }
.running-timer-what strong { font-size: .98rem; }
.running-timer-what span { color: #6b5a3e; font-size: .86rem; }
.running-timer-since { white-space: nowrap; }
.running-elapsed { font-variant-numeric: tabular-nums; font-size: 1.15rem; font-weight: 700; color: #8a5200; white-space: nowrap; }
.running-timer form { margin: 0; }
.running-dot { width: .6rem; height: .6rem; border-radius: 50%; background: #d9822b; flex: 0 0 auto; animation: running-pulse 1.6s ease-in-out infinite; }
@keyframes running-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .running-dot { animation: none; } }
.start-timer { background: #f8f9fa; }
@media (max-width: 575px) {
  .running-timer { flex-wrap: wrap; }
  .running-timer form { width: 100%; }
  .running-timer form .btn { width: 100%; }
}

/* How a step's time budget reads in the job cost table. */
.variance {
  display: inline-block; padding: .05rem .45rem; border-radius: 1rem;
  font-size: .78rem; font-weight: 600; white-space: nowrap;
}
.variance-left { background: #cfe2ff; color: #084298; }
.variance-saved { background: #d1e7dd; color: #0f5132; }
.variance-over { background: #f8d7da; color: #842029; }
.variance-on { background: #e9ecef; color: #343a40; }

.budget-cell { min-width: 9rem; }
.budget-bar {
  display: block; height: .3rem; margin-top: .3rem; border-radius: .15rem;
  background: #e9ecef; overflow: hidden;
}
.budget-bar > span { display: block; height: 100%; border-radius: .15rem; max-width: 100%; }
.budget-left > span { background: #3d8bfd; }
.budget-saved > span { background: #479f76; }
.budget-over > span { background: #dc3545; }
.budget-on > span { background: #6c757d; }

/* Job costs that are not sheet stock: freight, fasteners, outside work. */
.extra-cost-form { grid-template-columns: minmax(7rem, 1fr) 6rem 7rem auto; }
.extra-cost-entry { background: #f8f9fa; }
.extra-cost-row td:first-child { color: #526071; }
.extra-cost-row form { display: inline; margin-left: .5rem; }
.extra-cost-tag {
  display: inline-block; margin-left: .4rem; padding: 0 .35rem;
  border: 1px solid #ced4da; border-radius: .2rem;
  font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: #6c757d;
}
@media (max-width: 575px) {
  .extra-cost-form { grid-template-columns: minmax(0, 1fr) 1fr; }
  .extra-cost-form .time-log-description, .extra-cost-form .time-log-submit { grid-column: 1 / -1; }
}

/* Auto-refresh stamp on the tile board. A frozen display should look frozen. */
.dashboard-stamp { font-variant-numeric: tabular-nums; }
.dashboard-stamp.is-stale { color: #a8301b; font-weight: 600; }
