/* ==========================================================================
   Material Price Comparison Sheet (FM-PC-00)
   Extends Doc-forms-suite styles.css & toolbar.css
   ========================================================================== */

:root {
  --pc-sheet-width: 420mm;
  --pc-sheet-min-height: 297mm;
  --pc-win-bg: #edf4ea;
  --pc-win-border: #8aa57f;
  --pc-win-ink: #1f3b1b;
  --pc-sel-bg: #eef2ff;
  --pc-sel-border: #6366f1;
  --pc-sel-ink: #312e81;
  --pc-over-ink: #b91c1c;
  --pc-under-ink: #15803d;
}

body[data-orientation="a3-landscape"] {
  --pc-sheet-width: 420mm;
  --pc-sheet-min-height: 297mm;
}

body[data-orientation="a3-portrait"] {
  --pc-sheet-width: 297mm;
  --pc-sheet-min-height: 420mm;
}

body[data-orientation="16x9"] {
  --pc-sheet-width: 338.67mm;
  --pc-sheet-min-height: 190.5mm;
}

body[data-orientation="landscape"] {
  --pc-sheet-width: 297mm;
  --pc-sheet-min-height: 210mm;
}

body[data-orientation="portrait"] {
  --pc-sheet-width: 210mm;
  --pc-sheet-min-height: 297mm;
}

/* Override workspace & sheet layout so pages + bottom action buttons stack vertically */
.workspace {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  overflow-x: auto;
}

.pc-sheet {
  width: var(--pc-sheet-width);
  min-height: var(--pc-sheet-min-height);
  padding: 5mm 6mm;
  gap: 5px;
}

/* Toolbar refinements for Price Compare */
.toolbar #docSelector {
  max-width: 195px;
}

.toolbar-link-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #365314;
  background: #ecfccb;
  border: 1px solid #bef264;
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: #3f3f46;
  background: #ffffff;
  border: 1px solid #d4d4d8;
  border-radius: 5px;
  padding: 3px 8px;
  min-height: 28px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.toggle-chip:hover {
  background: #f4f4f5;
}

.toggle-chip input[type="checkbox"] {
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: #18181b;
  cursor: pointer;
}

/* Ultra-Slim Content-First Header (~34-38px total height) */
.pc-sheet .doc-header {
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 0 0 2px;
  gap: 12px;
  border-bottom: none;
}

.pc-sheet .header-org {
  gap: 10px;
  align-items: center;
}

.pc-sheet .logo-box {
  width: 88px;
  height: 34px;
  flex: 0 0 88px;
  padding: 1px 2px;
}

.pc-sheet .logo-box img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: left center;
}

.pc-sheet .logo-icon {
  font-size: 9.5px;
  letter-spacing: 0.5px;
}

.pc-sheet .logo-sub {
  display: none;
}

.pc-sheet .proj-header-details {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  min-height: 26px;
  padding-left: 10px;
  border-left: 1px solid var(--line-dark, #d4d4d8);
}

.pc-sheet .proj-header-eyebrow {
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--ink, #18181b);
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
  flex: 0 0 auto;
  user-select: none;
}

.pc-sheet .proj-header-line {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  min-width: 0;
}

.pc-sheet .proj-header-code-input {
  width: 6ch;
  min-width: 3ch;
  max-width: 18ch;
  flex: 0 0 auto;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink, #18181b);
  line-height: 1.2;
  padding: 0 2px;
  border-radius: 3px;
  outline: none;
}

.pc-sheet .proj-header-sep {
  font-family: inherit;
  color: var(--ink, #18181b);
  opacity: 0.45;
  font-size: 11.5px;
  font-weight: 400;
  line-height: 1.2;
  flex: 0 0 auto;
  margin: 0 1px;
  user-select: none;
}

.pc-sheet .proj-header-name-input {
  flex: 1;
  min-width: 100px;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink, #18181b);
  line-height: 1.2;
  padding: 0 3px;
  border-radius: 3px;
  outline: none;
}

.pc-sheet .proj-header-code-input:hover,
.pc-sheet .proj-header-code-input:focus,
.pc-sheet .proj-header-name-input:hover,
.pc-sheet .proj-header-name-input:focus {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.pc-sheet .header-docbox {
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.pc-sheet .doc-title-th {
  font-size: 12px;
  line-height: 1.1;
  text-align: right;
  white-space: nowrap;
}

.pc-sheet .doc-title-en {
  font-size: 7.8px;
  line-height: 1.1;
  text-align: right;
  white-space: nowrap;
}

.pc-sheet .doc-meta-mini {
  width: auto;
  min-width: 0;
  font-size: 9px;
  border-collapse: collapse;
  border: 1.75px solid #000000;
  white-space: nowrap;
}

.pc-sheet .doc-meta-mini th,
.pc-sheet .doc-meta-mini td {
  border: 1.25px solid #000000;
  padding: 3px 7px;
  line-height: 1.2;
}

.pc-sheet .doc-meta-mini th {
  background: #f4f4f5;
  color: var(--ink, #18181b);
  font-weight: 700;
  white-space: nowrap;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.pc-sheet .doc-meta-mini .inline-input {
  font-family: inherit;
  font-size: 9.2px;
  padding: 0 2px;
  width: 78px;
  text-align: center;
  color: var(--ink, #18181b);
}

.pc-sheet .doc-meta-mini .inline-input[data-meta="docDate"] {
  width: 64px;
}

.pc-sheet .doc-meta-mini .inline-input[data-meta="docPage"] {
  width: 74px;
}

.pc-sheet .section-header {
  padding: 3px 7px;
  font-size: 10px;
}

.pc-sheet .doc-footer {
  font-size: 8.5px;
  color: #71717a;
  border-top: none;
  margin-top: 6px;
  padding-top: 2px;
}

body[data-orientation="portrait"] .pc-sheet .header-docbox {
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

/* Compact Info Grid (3 pairs per row) */
.pc-info-grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-top: 1.5px solid #000000;
  border-left: 1.5px solid #000000;
  font-size: 9.5px;
}

.pc-info-grid th,
.pc-info-grid td {
  border-top: none;
  border-left: none;
  border-right: 1.25px solid #000000;
  border-bottom: 1.25px solid #000000;
  padding: 2px 5px;
  vertical-align: middle;
  background-clip: padding-box;
}

.pc-info-grid th {
  background: var(--surface-tint);
  color: var(--ink);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  width: 11%;
}

.pc-info-grid td {
  width: 22.33%;
}

.pc-info-grid .budget-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pc-info-grid .budget-input-wrap input {
  text-align: right;
  font-weight: 700;
}

.pc-info-grid .unit-tag {
  font-size: 9.5px;
  color: var(--ink-muted);
  white-space: nowrap;
}

/* KPI Strip (Slim) */
.pc-kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.pc-kpi-card {
  border: 1px solid var(--line-dark);
  background: var(--surface-tint);
  padding: 3px 7px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.pc-kpi-card.is-highlight {
  background: var(--pc-win-bg);
  border-color: var(--pc-win-border);
}

.pc-kpi-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--ink-muted);
}

.pc-kpi-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.15;
}

.pc-kpi-card.is-highlight .pc-kpi-value {
  color: var(--pc-win-ink);
}

.pc-kpi-sub {
  font-size: 9px;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pc-kpi-value.is-over {
  color: var(--pc-over-ink);
}

.pc-kpi-value.is-under {
  color: var(--pc-under-ink);
}

/* Main Price Comparison Table */
.pc-table-wrap {
  width: 100%;
  overflow-x: auto;
  padding: 1px;
}

.pc-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-top: 2px solid #000000;
  border-left: 2px solid #000000;
  font-size: 9.8px;
  table-layout: fixed;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.pc-table thead th {
  background: var(--surface-tint);
  color: #000000;
  font-weight: 700;
  border-top: none;
  border-left: none;
  border-right: 1.75px solid #000000;
  border-bottom: 2px solid #000000;
  padding: 4px 4px;
  text-align: center;
  vertical-align: middle;
  background-clip: padding-box;
}

.pc-table tbody td,
.pc-table tfoot td {
  border-top: none;
  border-left: none;
  border-right: 1.75px solid #000000;
  border-bottom: 1.75px solid #000000;
  padding: 3px 4px;
  vertical-align: middle;
  background-clip: padding-box;
  color: #000000;
}

.pc-table th:last-child,
.pc-table td:last-child {
  border-right: 2px solid #000000;
}

.pc-table tfoot tr:last-child td {
  border-bottom: 2px solid #000000;
}

.pc-table tbody tr:nth-child(even) {
  background: #fcfcfc;
}

/* Theme header harmonization */
body[data-theme="navy"] .pc-table thead th {
  background: #dce5e8;
  color: #1b2428;
}
body[data-theme="emerald"] .pc-table thead th {
  background: #e2e7d8;
  color: #1d2317;
}
body[data-theme="sage-smoke"] .pc-table thead th {
  background: #e4ebe6;
  color: #364147;
}
body[data-theme="earth-ivory"] .pc-table thead th {
  background: #efe5d8;
  color: #4d3b32;
}

/* Column Sizing */
.pc-col-no {
  width: 24px;
  text-align: center;
}

.pc-col-photo {
  width: 54px;
  text-align: center;
}

.pc-col-desc {
  width: 22%;
}

.pc-col-qty {
  width: 44px;
  text-align: right;
}

.pc-col-unit {
  width: 42px;
  text-align: center;
}

.pc-col-boq {
  width: 68px;
  text-align: right;
}

.pc-col-act {
  width: 24px;
  text-align: center;
}

.pc-vendor-sub-th {
  font-size: 9px;
  font-weight: 600;
  padding: 2px 3px !important;
}

/* Vendor Header Cell */
.vendor-head-cell {
  vertical-align: top !important;
  padding: 4px 5px !important;
  position: relative;
}

.vendor-head-cell.is-lowest {
  background: var(--pc-win-bg) !important;
  border-bottom: 2px solid var(--pc-win-border) !important;
}

.vendor-head-cell.is-selected {
  box-shadow: inset 0 2.5px 0 0 var(--accent);
}

.vendor-head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 2px;
}

.vendor-badges {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
}

.v-badge {
  display: inline-block;
  font-size: 8.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  line-height: 1.25;
  white-space: nowrap;
}

.v-badge-lowest {
  background: #2f6b29;
  color: #ffffff;
}

.v-badge-selected {
  background: var(--accent);
  color: #ffffff;
}

.vendor-pick-radio {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 9px;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
  white-space: nowrap;
}

.vendor-pick-radio input {
  width: 11px;
  height: 11px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.vendor-name-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  padding: 1px 2px;
  border-radius: 2px;
}

.vendor-meta-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 8.8px;
  font-weight: 500;
  color: var(--ink-muted);
  text-align: center;
  padding: 1px 2px;
  border-radius: 2px;
}

.vendor-name-input:hover,
.vendor-meta-input:hover {
  border-color: #cbd5e1;
  background: rgba(255, 255, 255, 0.8);
}

.vendor-name-input:focus,
.vendor-meta-input:focus {
  outline: none;
  border-color: #2563eb;
  background: #ffffff;
}

/* Numeric cells */
.num-input {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.num-display {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  white-space: nowrap;
}

.cell-lowest {
  background: var(--pc-win-bg) !important;
  color: var(--pc-win-ink) !important;
  font-weight: 700;
}

.cell-lowest .cell-input {
  color: var(--pc-win-ink);
  font-weight: 700;
}

/* Material Photo Slot */
.mat-photo-slot {
  position: relative;
  width: 44px;
  height: 36px;
  margin: 0 auto;
  border: 1px dashed var(--line-dark);
  border-radius: 3px;
  background: var(--surface-tint);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
}

.mat-photo-slot.has-img {
  border-style: solid;
  border-color: var(--line);
  background: #ffffff;
}

.mat-photo-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mat-photo-ph {
  font-size: 8.5px;
  color: var(--ink-muted);
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
}

.mat-photo-clr {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 13px;
  height: 13px;
  border: none;
  border-radius: 50%;
  background: rgba(24, 24, 27, 0.78);
  color: #ffffff;
  font-size: 9px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: none;
}

.mat-photo-slot.has-img:hover .mat-photo-clr {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Summary Footer Rows in Price Table */
.pc-table tfoot tr.sum-row td {
  background: var(--surface-tint);
  font-size: 9.8px;
  padding: 3.5px 5px;
}

.pc-table tfoot tr.sum-row td.sum-label {
  text-align: right;
  font-weight: 600;
  color: var(--ink);
  padding-right: 8px;
}

.pc-table tfoot tr.sum-row-edit td {
  background: #ffffff;
}

.pc-table tfoot tr.sum-row-grand td {
  background: var(--section-bg);
  color: var(--section-ink);
  border-top: 1.5px solid var(--line-dark);
  border-bottom: 1.5px solid var(--line-dark);
  font-size: 10.5px;
  font-weight: 700;
  padding: 5px 5px;
}

.pc-table tfoot tr.sum-row-grand td.sum-label {
  color: var(--section-ink);
}

.pc-table tfoot tr.sum-row-grand td.is-lowest-total {
  background: #2f6b29;
  color: #ffffff;
}

.pc-table tfoot tr.sum-row-diff td {
  background: #ffffff;
  font-size: 9.2px;
  color: var(--ink-muted);
  padding: 3px 5px;
}

.diff-pill-low {
  display: inline-block;
  background: var(--pc-win-bg);
  color: var(--pc-win-ink);
  border: 1px solid var(--pc-win-border);
  border-radius: 3px;
  padding: 0 5px;
  font-weight: 700;
  font-size: 8.8px;
}

.diff-pill-higher {
  color: #b45309;
  font-weight: 600;
}

.diff-pill-under {
  color: var(--pc-under-ink);
  font-weight: 700;
}

.diff-pill-over {
  color: var(--pc-over-ink);
  font-weight: 700;
}

.vat-inline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.vat-inline-toggle input {
  width: 12px;
  height: 12px;
  margin: 0;
  accent-color: var(--accent);
}

/* Terms & Commercial Comparison Table */
.terms-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-top: 2px solid #000000;
  border-left: 2px solid #000000;
  font-size: 9.8px;
  table-layout: fixed;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.terms-table thead th {
  background: var(--surface-tint);
  color: var(--ink);
  font-weight: 700;
  border-top: none;
  border-left: none;
  border-right: 1.5px solid #000000;
  border-bottom: 1.75px solid #000000;
  padding: 4px 6px;
  text-align: center;
  background-clip: padding-box;
}

.terms-table tbody td {
  border-top: none;
  border-left: none;
  border-right: 1.5px solid #000000;
  border-bottom: 1.5px solid #000000;
  padding: 3px 5px;
  vertical-align: middle;
  background-clip: padding-box;
}

.terms-table th:last-child,
.terms-table td:last-child {
  border-right: 2px solid #000000;
}

.terms-table tbody tr:last-child td {
  border-bottom: 2px solid #000000;
}

.terms-table tbody tr:nth-child(even) {
  background: #fcfcfc;
}

.terms-col-topic {
  width: 22%;
  background: var(--surface-tint);
  font-weight: 600;
}

.terms-col-act {
  width: 24px;
  text-align: center;
}

.terms-table td.is-selected-col {
  background: rgba(47, 107, 41, 0.04);
}

/* Recommendation & Decision Box */
.decision-grid {
  display: grid;
  grid-template-columns: 1.05fr 1.65fr;
  border-top: none;
}

.decision-pane {
  padding: 6px 9px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.decision-pane + .decision-pane {
  border-left: 1px solid var(--line);
}

.decision-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
}

.decision-row label {
  font-weight: 700;
  color: var(--ink-muted);
  white-space: nowrap;
  min-width: 105px;
}

.decision-amount-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--pc-win-ink);
  background: var(--pc-win-bg);
  border: 1px solid var(--pc-win-border);
  padding: 2px 8px;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}

/* Signature compactness & crisp borders matching A3 table */
.pc-sheet .signature-grid {
  margin-top: 4px;
  border: 1.75px solid #000000;
}

.pc-sheet .sig-box {
  min-height: 76px;
  padding: 5px 8px;
  border-color: #000000;
  border-left-width: 1.5px;
}

.pc-sheet .sig-role {
  margin: -5px -8px 6px;
  padding: 4px 6px;
  background: #e5e7eb;
  color: #000000;
  border-bottom: 1.5px solid #000000;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.pc-sheet .sig-line {
  height: 24px;
  margin: 2px 10px 4px;
  border-bottom: 1.25px dotted #27272a;
}

.pc-sheet .sig-meta .inline-input {
  text-align: center;
  font-size: 9.5px;
  color: #000000;
  border: 1px solid transparent;
  background: transparent;
}

.pc-sheet .sig-meta .inline-input:hover,
.pc-sheet .sig-meta .inline-input:focus {
  border-color: #cbd5e1;
  background: #f8fafc;
}

/* Hide optional columns cleanly */
.hide-photo .col-photo-cell {
  display: none !important;
}

.hide-boq .col-boq-cell {
  display: none !important;
}

/* Portrait adjustments */
body[data-orientation="portrait"] .pc-info-grid th {
  width: 14%;
}

body[data-orientation="portrait"] .pc-kpi-strip {
  grid-template-columns: repeat(2, 1fr);
}

body[data-orientation="portrait"] .decision-grid {
  grid-template-columns: 1fr;
}

body[data-orientation="portrait"] .decision-pane + .decision-pane {
  border-left: none;
  border-top: 1px solid var(--line);
}

/* ==========================================================================
   Matrix Product Comparison Table (Vendor-Grouped Columns Layout)
   ========================================================================== */
.matrix-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.matrix-body[hidden],
.form-body[hidden],
.mx-signoff-wrap[hidden] {
  display: none !important;
}

.mx-title-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 2px;
}

.mx-sheet-title-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  color: #111827;
  text-align: center;
  padding: 1px 6px;
  border-radius: 4px;
  outline: none;
}

.mx-sheet-title-input:hover,
.mx-sheet-title-input:focus {
  border-color: #d4d4d8;
  background: #fafafa;
}

.mx-table-wrap {
  width: 100%;
  overflow-x: auto;
  padding: 1px;
}

.mx-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font-size: 10.4px;
  color: #000000;
  background: #ffffff;
  border-top: 2.25px solid #000000;
  border-left: 2.25px solid #000000;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.mx-table th,
.mx-table td {
  border-top: none;
  border-left: none;
  border-right: 1.75px solid #000000;
  border-bottom: 1.75px solid #000000;
  padding: 5px 6px;
  vertical-align: middle;
  text-align: center;
  word-wrap: break-word;
  overflow-wrap: break-word;
  background-clip: padding-box;
  color: #000000;
}

.mx-table thead th {
  border-bottom: 2.25px solid #000000;
}

.mx-table th:last-child,
.mx-table td:last-child {
  border-right: 2.25px solid #000000;
}

.mx-table tbody tr:last-child th,
.mx-table tbody tr:last-child td {
  border-bottom: 2.25px solid #000000;
}

body[data-orientation="landscape"] .mx-table th,
body[data-orientation="landscape"] .mx-table td,
body[data-orientation="portrait"] .mx-table th,
body[data-orientation="portrait"] .mx-table td,
body[data-orientation="16x9"] .mx-table th,
body[data-orientation="16x9"] .mx-table td {
  padding: 4px 5px;
}

/* Sticky / Fixed Left Label Column */
.mx-col-label {
  width: 162px;
}

body[data-orientation="landscape"] .mx-col-label {
  width: 138px;
}

body[data-orientation="portrait"] .mx-col-label {
  width: 112px;
}

.mx-table thead th.mx-corner-th {
  background: #d9d9d9;
  color: #111827;
  font-weight: 700;
  font-size: 10.2px;
  text-align: center;
  padding: 4px 6px;
}

.mx-table thead th.mx-vendor-th {
  background: var(--mx-vendor-bg, #ddd7bf);
  color: #111827;
  font-weight: 700;
  padding: 3px 5px;
  position: relative;
}

.mx-vendor-th-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.mx-vendor-name-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 10.8px;
  font-weight: 700;
  color: #111827;
  text-align: center;
  padding: 1px 4px;
  border-radius: 3px;
  outline: none;
}

.mx-vendor-name-input:hover,
.mx-vendor-name-input:focus {
  background: rgba(255, 255, 255, 0.72);
  border-color: rgba(24, 24, 27, 0.22);
}

.mx-vendor-tools {
  position: absolute;
  top: calc(100% - 1px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: nowrap;
  padding: 3px 5px;
  background: #ffffff;
  border: 1px solid #d4d4d8;
  border-radius: 5px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.14);
}

.mx-vendor-th:hover .mx-vendor-tools,
.mx-vendor-th:focus-within .mx-vendor-tools {
  display: inline-flex;
}

.mx-color-dot {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid rgba(24, 24, 27, 0.25);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.mx-mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  padding: 0 5px;
  border-radius: 3px;
  border: 1px solid rgba(24, 24, 27, 0.2);
  background: rgba(255, 255, 255, 0.8);
  color: #27272a;
  font-family: inherit;
  font-size: 9.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.mx-mini-btn:hover {
  background: #ffffff;
  border-color: #18181b;
}

.mx-mini-btn.is-baseline {
  background: #18181b;
  color: #ffffff;
  border-color: #18181b;
}

.mx-mini-btn.is-del:hover {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

/* Row Label Cell (Column 1) */
.mx-table tbody th.mx-row-lbl {
  background: #d9d9d9;
  color: #111827;
  font-weight: 700;
  text-align: left;
  padding: 4px 6px;
  position: relative;
}

.mx-row-lbl-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.mx-row-lbl-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  color: #111827;
  padding: 1px 2px;
  border-radius: 3px;
  outline: none;
}

.mx-row-lbl-input:hover,
.mx-row-lbl-input:focus {
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(24, 24, 27, 0.25);
}

.mx-row-tools {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.14s ease;
}

.mx-table tbody tr:hover .mx-row-tools,
.mx-table tbody tr:focus-within .mx-row-tools {
  opacity: 1;
}

.mx-row-icon-btn {
  height: 17px;
  padding: 0 4px;
  border-radius: 3px;
  border: 1px solid rgba(24, 24, 27, 0.2);
  background: rgba(255, 255, 255, 0.85);
  color: #3f3f46;
  font-family: inherit;
  font-size: 9px;
  font-weight: 600;
  cursor: pointer;
}

.mx-row-icon-btn:hover {
  background: #ffffff;
  color: #18181b;
  border-color: #18181b;
}

.mx-row-icon-btn.is-del:hover {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

/* Model / Product Name Cell */
.mx-model-cell {
  position: relative;
  background: #ffffff;
  padding: 5px 5px !important;
}

.mx-model-del-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 15px;
  height: 15px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: #a1a1aa;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mx-model-cell:hover .mx-model-del-btn {
  opacity: 1;
}

.mx-model-del-btn:hover {
  background: #fee2e2;
  color: #b91c1c;
}

/* Editable Inputs inside Matrix Cells */
.mx-cell-input,
.mx-cell-area {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 10px;
  line-height: 1.35;
  color: #000000;
  text-align: center;
  padding: 2px 3px;
  border-radius: 3px;
  outline: none;
  resize: none;
  overflow: hidden;
  display: block;
}

.mx-cell-input:hover,
.mx-cell-input:focus,
.mx-cell-area:hover,
.mx-cell-area:focus {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.mx-cell-input.is-price-blue {
  color: #1d4ed8;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.mx-cell-input.is-bold-num {
  color: #111827;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Photo Row */
.mx-photo-td {
  padding: 6px !important;
  background: #ffffff;
  height: 148px;
}

.mx-photo-box {
  position: relative;
  width: 100%;
  height: 136px;
  border: 1px dashed #d4d4d8;
  border-radius: 4px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  outline: none;
  overflow: hidden;
  transition: border-color 0.14s ease, background-color 0.14s ease;
}

body[data-orientation="landscape"] .mx-photo-td,
body[data-orientation="16x9"] .mx-photo-td {
  height: 118px;
}

body[data-orientation="landscape"] .mx-photo-box,
body[data-orientation="16x9"] .mx-photo-box {
  height: 106px;
}

.mx-photo-box:hover,
.mx-photo-box:focus {
  border-color: #3f3f46;
  background: #fafafa;
}

.mx-photo-box.is-dragover {
  border-color: #2563eb;
  background: #eff6ff;
}

.mx-photo-box.has-photo {
  border-color: transparent;
  border-style: solid;
}

.mx-photo-box.has-photo:hover,
.mx-photo-box.has-photo:focus {
  border-color: #a1a1aa;
}

.mx-photo-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.mx-photo-ph {
  font-size: 9.5px;
  color: #a1a1aa;
  line-height: 1.3;
  text-align: center;
  padding: 0 4px;
  pointer-events: none;
}

.mx-photo-clr {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 999px;
  background: rgba(24, 24, 27, 0.72);
  color: #ffffff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

.mx-photo-box.has-photo:hover .mx-photo-clr {
  display: inline-flex;
}

/* Section Banner ("สรุปค่าใช้จ่าย (บาท)") */
.mx-table tbody tr:has(+ .mx-section-banner-row) th,
.mx-table tbody tr:has(+ .mx-section-banner-row) td {
  border-bottom: 2px solid #000000 !important;
}

.mx-section-banner-row td {
  background: #a6a6a6 !important;
  border-right: 2px solid #000000 !important;
  border-bottom: 2px solid #000000 !important;
  color: #111827;
  font-weight: 700;
  font-size: 10.5px;
  padding: 4px 8px;
  text-align: center;
}

.mx-banner-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 700;
  color: #111827;
  text-align: center;
  outline: none;
}

.mx-banner-input:focus {
  background: rgba(255, 255, 255, 0.45);
  border-radius: 3px;
}

/* Unit Price + Optional Qty */
.mx-price-flex {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.mx-qty-wrap {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 9px;
  color: #71717a;
  flex-shrink: 0;
}

.mx-qty-input {
  width: 34px;
  border: 1px solid #d4d4d8;
  border-radius: 3px;
  background: #fafafa;
  font-family: inherit;
  font-size: 9.5px;
  font-weight: 600;
  color: #27272a;
  text-align: center;
  padding: 1px 2px;
}

.mx-calc-val {
  font-variant-numeric: tabular-nums;
  font-size: 10.2px;
  color: #18181b;
}

.mx-calc-val.is-bold {
  font-weight: 700;
  color: #111827;
}

.mx-calc-val.is-saving {
  color: #15803d;
  font-weight: 600;
}

.mx-calc-val.is-higher {
  color: #b91c1c;
  font-weight: 600;
}

/* VAT cell with mode switch */
.mx-vat-cell-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-wrap: wrap;
}

.mx-vat-mode-select {
  height: 19px;
  padding: 0 4px;
  border: 1px solid #d4d4d8;
  border-radius: 3px;
  background: #f8fafc;
  color: #52525b;
  font-family: inherit;
  font-size: 9px;
  font-weight: 600;
  cursor: pointer;
}

/* Highlighted Grand Total Row (Yellow Cream like reference) */
.mx-table tbody tr:has(+ .mx-grand-total-row) th,
.mx-table tbody tr:has(+ .mx-grand-total-row) td {
  border-bottom: 2px solid #000000 !important;
}

.mx-grand-total-row th,
.mx-grand-total-row td {
  background: #fff2cc !important;
  border-right: 1.75px solid #000000 !important;
  border-bottom: 2.25px solid #000000 !important;
  color: #000000;
  font-weight: 700;
  font-size: 10.8px;
  padding: 5px 5px;
}

.mx-grand-total-row td:last-child {
  border-right: 2.25px solid #000000 !important;
}

.mx-lowest-tag {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 5px;
  border-radius: 999px;
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
  font-size: 8.5px;
  font-weight: 700;
  vertical-align: middle;
}

.mx-footer-bar {
  border: 1px solid #d4d4d8;
  border-radius: 4px;
  margin-top: 4px;
}

/* Editable Bottom Lines below Compare Table */
.mc-bottom-lines {
  margin-top: 6px;
  border: 1.75px solid #000000;
  background: #ffffff;
}

.mc-bottom-lines-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 8px;
  background: #f4f4f5;
  border-bottom: 1.5px solid #000000;
  font-size: 9.5px;
  font-weight: 700;
  color: #000000;
}

.mc-bottom-lines-title-input {
  flex: 1;
  min-width: 0;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 9.5px;
  font-weight: 700;
  color: #18181b;
  padding: 1px 2px;
  outline: none;
}

.mc-bottom-lines-title-input:hover,
.mc-bottom-lines-title-input:focus {
  background: #ffffff;
  border-color: #cbd5e1;
  border-radius: 3px;
}

.mc-bottom-line-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 3px 8px;
  border-bottom: 1.25px solid #27272a;
}

.mc-bottom-line-row:last-child {
  border-bottom: none;
}

.mc-bottom-line-num {
  font-size: 9.5px;
  font-weight: 700;
  color: #3f3f46;
  min-width: 18px;
  padding-top: 2px;
}

.mc-bottom-line-input {
  flex: 1;
  min-width: 0;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 10px;
  line-height: 1.35;
  color: #18181b;
  padding: 1px 4px;
  border-radius: 3px;
  resize: none;
  overflow: hidden;
  outline: none;
  display: block;
}

.mc-bottom-line-input:hover,
.mc-bottom-line-input:focus {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.mc-bottom-line-del {
  border: none;
  background: transparent;
  color: #a1a1aa;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
}

.mc-bottom-line-del:hover {
  background: #fee2e2;
  color: #b91c1c;
}

.stage-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
  margin-bottom: 12px;
}

.mx-extra-sheet-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  background: #f4f4f5;
  border: 1px solid #d4d4d8;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 600;
  color: #3f3f46;
}

.mx-extra-sheet-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mx-signoff-wrap {
  margin-top: 4px;
}

/* Compact Mode when Matrix hides Doc Header */
.pc-sheet.is-matrix-clean {
  padding: 6mm 7mm;
  gap: 4px;
}

/* Exact-Size Multi-Page Pagination & Continuation Styles */
.pages-container.is-measuring .pc-sheet {
  height: auto !important;
  min-height: 0 !important;
}

.pages-container.is-measuring .matrix-body,
.pages-container.is-measuring .form-body {
  flex: 0 0 auto !important;
}

.mx-cont-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #111827;
  text-align: center;
  padding: 2px 0 3px;
}

.mx-cont-vendor-lbl {
  font-size: 11px;
  font-weight: 700;
  color: #111827;
  padding: 2px 4px;
}

.mx-cont-model-hdr th,
.mx-cont-model-hdr td {
  background: #f4f4f5 !important;
  color: #27272a;
  font-size: 9.5px;
  font-weight: 600;
  padding: 3px 4px;
}

.mx-cont-model-hdr th {
  background: #d9d9d9 !important;
  text-align: left;
  padding-left: 6px;
}

.pc-cont-vendor-static {
  font-size: 10px;
  font-weight: 700;
  color: #18181b;
  line-height: 1.25;
}

.pc-cont-quote-static {
  font-size: 8.8px;
  color: #52525b;
  font-weight: 500;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
  .pc-sheet {
    width: 100% !important;
    min-height: 0 !important;
    height: auto !important;
    padding: 0 !important;
    box-shadow: none !important;
  }

  .pc-sheet + .pc-sheet {
    break-before: page;
    page-break-before: always;
  }

  .pc-table-wrap,
  .mx-table-wrap {
    overflow: visible !important;
  }

  .vendor-name-input,
  .vendor-meta-input,
  .mx-sheet-title-input,
  .mx-vendor-name-input,
  .mx-row-lbl-input,
  .mx-cell-input,
  .mx-cell-area,
  .mx-banner-input,
  .proj-header-code-input,
  .proj-header-name-input {
    border-color: transparent !important;
    background: transparent !important;
    border-radius: 0 !important;
    overflow: visible !important;
  }

  .mat-photo-clr,
  .vendor-pick-radio,
  .mx-vendor-tools,
  .mx-row-tools,
  .mx-model-del-btn,
  .mx-photo-clr,
  .mx-vat-mode-select {
    display: none !important;
  }

  .pc-sheet .logo-box:not(.has-logo),
  .pc-sheet .logo-box:not(.has-logo) .logo-placeholder,
  .mat-photo-box:not(.has-photo) .mat-photo-ph,
  .mx-photo-box:not(.has-photo) .mx-photo-ph {
    visibility: hidden !important;
    border-color: transparent !important;
  }

  .mx-photo-box {
    border-color: transparent !important;
  }

  .mx-table,
  .mx-table th,
  .mx-table td,
  .pc-table,
  .pc-table th,
  .pc-table td,
  .terms-table,
  .terms-table th,
  .terms-table td,
  .pc-info-grid,
  .pc-info-grid th,
  .pc-info-grid td,
  .doc-meta-mini,
  .doc-meta-mini th,
  .doc-meta-mini td,
  .signature-grid,
  .sig-box,
  .sig-role,
  .mx-grand-total-row th,
  .mx-grand-total-row td,
  .mx-section-banner-row td {
    border-color: #000000 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .mc-bottom-lines,
  .mc-bottom-lines-head,
  .mc-bottom-line-row {
    border-color: #000000 !important;
  }

  .mc-bottom-line-input {
    border-color: transparent !important;
    background: transparent !important;
  }

  .pc-kpi-strip,
  .decision-grid,
  .signature-grid {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

.mx-model-pick {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 2px;
  font-size: 9.5px;
  color: #52525b;
  cursor: pointer;
  user-select: none;
}

.mx-model-pick input[type="checkbox"] {
  accent-color: #18181b;
  cursor: pointer;
}

.mx-vat-warn-row td {
  background: #fffbeb !important;
  color: #b45309;
  font-size: 10.5px;
  font-weight: 600;
  text-align: left !important;
  padding: 4px 8px !important;
}
