/* ---------------------------------------------------------------------------
   Work order (LSM allotment), printable letter, and depot volume variation.
   Phone first: every rate line is a stacked card; from 720px up the same
   markup lays out as one table-like row. Nothing here may scroll the page
   sideways at 320px.
--------------------------------------------------------------------------- */

.wo-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.wo-tabs button {
  flex: 1; min-height: 44px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--ink-700); border-radius: var(--radius); font: inherit; font-weight: 650; cursor: pointer;
}
.wo-tabs button.active { background: var(--green-700); border-color: var(--green-700); color: #fff; }

.wo-lot-info {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px 14px;
  background: var(--green-050); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 16px;
}
.wo-lot-info div { min-width: 0; overflow-wrap: anywhere; }
.wo-lot-info span { display: block; font-size: 0.74rem; font-weight: 650; color: var(--ink-500); }
.wo-lot-info strong { font-size: 1rem; }

.wo-form textarea { min-height: 64px; }
.wo-form input, .wo-form select, .wo-form textarea { max-width: 100%; }

/* Rate schedule */
.wo-group { margin: 18px 0 0; }
.wo-group-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 8px 12px; background: var(--surface-alt); border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--border); font-weight: 700;
}
.wo-group-sub { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--green-800); white-space: nowrap; }
.wo-line {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px;
  padding: 12px; border: 1px solid var(--border); border-top: none; background: var(--surface);
}
.wo-line:last-of-type { border-radius: 0 0 var(--radius) var(--radius); }
.wo-line-name { grid-column: 1 / -1; font-weight: 600; overflow-wrap: anywhere; }
.wo-cell { min-width: 0; }
.wo-cell-label { display: block; font-size: 0.72rem; font-weight: 650; color: var(--ink-500); margin-bottom: 3px; }
.wo-cell input { width: 100%; min-width: 0; min-height: 46px; font-size: 1rem; text-align: right; }
.wo-amt {
  min-height: 46px; display: flex; align-items: center; justify-content: flex-end;
  font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.wo-head-row { display: none; }

.wo-totals { margin-top: 16px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.wo-totals div { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.wo-totals div:last-child { border-bottom: none; background: var(--green-100); color: var(--green-800); font-size: 1.15rem; font-weight: 760; }

@media (min-width: 720px) {
  .wo-head-row, .wo-line { grid-template-columns: minmax(0, 1fr) 140px 140px 150px; align-items: center; }
  .wo-head-row {
    display: grid; gap: 10px; padding: 8px 12px; font-size: 0.78rem; font-weight: 700; color: var(--ink-500);
    margin-top: 16px; text-align: right;
  }
  .wo-head-row span:first-child { text-align: left; }
  .wo-line-name { grid-column: auto; }
  .wo-cell-label { display: none; }
  .wo-cell input { min-height: 40px; }
  .wo-amt { min-height: 40px; }
}

/* Work order list + detail */
.wo-list-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.wo-detail dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 16px; margin: 0 0 16px; }
.wo-detail dt { font-size: 0.74rem; font-weight: 650; color: var(--ink-500); }
.wo-detail dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.wo-detail .table-wrap td, .wo-detail .table-wrap th { padding-left: 8px; padding-right: 8px; }
.wo-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }

/* Depot receiving: a stacked card per truck line, volume beside pieces */
.dv-line { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; background: var(--surface); }
.dv-line-name { font-weight: 700; overflow-wrap: anywhere; }
.dv-line-sub { font-size: 0.8rem; color: var(--ink-500); margin-bottom: 8px; }
.dv-cells { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px 10px; }
.dv-cells .field { margin-bottom: 0; min-width: 0; }
.dv-cells input { width: 100%; min-width: 0; min-height: 44px; }
.dv-var { margin-top: 8px; font-size: 0.86rem; display: flex; flex-wrap: wrap; gap: 4px 16px; font-variant-numeric: tabular-nums; }
.dv-pos { color: var(--green-800); font-weight: 700; }
.dv-neg { color: var(--red-600); font-weight: 700; }
.dv-zero { color: var(--ink-500); font-weight: 700; }
.dv-total { padding: 10px 12px; border-radius: var(--radius); background: var(--surface-alt); display: flex; flex-wrap: wrap; gap: 4px 18px; font-weight: 650; }
.dv-fig { font-size: 0.78rem; color: var(--ink-500); margin-top: 8px; font-variant-numeric: tabular-nums; }
.dv-fig strong { font-size: 0.95rem; }
.dv-scroll { max-width: 100%; overflow-x: auto; }
.dv-scroll table { min-width: 560px; }

/* Printable letter: only exists in the DOM while printing */
.wo-sheet { display: none; }
@media print {
  @page { size: A4; margin: 14mm 14mm 12mm; }
  body.wo-printing > *:not(.wo-sheet) { display: none !important; }
  body.wo-printing { background: #fff !important; padding: 0 !important; }
  body.wo-printing .wo-sheet {
    display: block; color: #000; background: #fff; font-family: "Times New Roman", "Noto Serif Devanagari", serif;
    font-size: 11pt; line-height: 1.35; width: 100%;
  }
  .wo-sheet h1, .wo-sheet h2 { text-align: center; margin: 0; font-size: 12.5pt; }
  .wo-sheet .wo-l-row { display: flex; justify-content: space-between; margin-top: 8pt; }
  .wo-sheet p { margin: 6pt 0; text-align: justify; }
  .wo-sheet table { width: 100%; border-collapse: collapse; margin: 8pt 0; }
  .wo-sheet th, .wo-sheet td { border: 1px solid #000; padding: 2pt 4pt; vertical-align: top; }
  .wo-sheet td.r, .wo-sheet th.r { text-align: right; white-space: nowrap; }
  .wo-sheet tr { page-break-inside: avoid; }
  .wo-sheet .wo-l-sign { margin-top: 26pt; font-weight: 700; }
  .wo-sheet .wo-l-cc { margin-left: 40pt; }
}
