:root {
  --navy: #1f3864;
  --navy-dark: #16294a;
  --office-bg: #fff2cc;
  --grey-bg: #f2f2f2;
  --border: #cfd4da;
  --red: #c00000;
  --green: #1e7e34;
  --data-blue: #0033a0;
  --doc-border: #000;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, Helvetica, sans-serif; background: #eef1f5; color: #1a1a1a; }

/* ---------- auth screens ---------- */
.auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1f3864, #2f5597); }
.auth-screen[hidden] { display: none; }
.auth-card { background: #fff; padding: 36px 40px; border-radius: 10px; width: 340px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.auth-card h1 { font-size: 20px; margin: 0 0 4px; color: var(--navy); }
.auth-card .sub { margin: 0 0 20px; font-size: 13px; color: #666; }
.auth-card label { display: block; font-size: 12px; margin: 12px 0 4px; color: #444; }
.auth-card input { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 5px; font-size: 14px; }
.auth-card button { width: 100%; margin-top: 20px; padding: 10px; background: var(--navy); color: #fff; border: none; border-radius: 5px; font-size: 14px; cursor: pointer; }
.auth-card button:hover { background: var(--navy-dark); }
.error { color: var(--red); font-size: 12px; min-height: 16px; margin-top: 8px; }

/* ---------- app shell ---------- */
.topbar { background: var(--navy); color: #fff; display: flex; align-items: center; padding: 0 20px; height: 56px; position: sticky; top: 0; z-index: 10; }
.topbar .brand { font-weight: bold; font-size: 16px; margin-right: 30px; }
.topbar nav { flex: 1; display: flex; gap: 6px; }
.navbtn { background: transparent; border: none; color: #cfd8e8; padding: 8px 14px; border-radius: 5px; cursor: pointer; font-size: 14px; }
.navbtn:hover { background: rgba(255,255,255,.08); color: #fff; }
.navbtn.active { background: rgba(255,255,255,.18); color: #fff; }
.who { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.linklike { background: none; border: none; color: #cfd8e8; text-decoration: underline; cursor: pointer; font-size: 13px; }

main.view { max-width: 1100px; margin: 20px auto; padding: 0 16px 60px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.toolbar button, .toolbar input { padding: 8px 14px; border-radius: 5px; border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 13px; }
.toolbar button.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.toolbar input { flex: 1; cursor: text; }
.save-status { font-size: 12px; color: var(--green); }

.card { background: #fff; border-radius: 8px; padding: 24px 28px; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
#printArea { border: 2px solid var(--doc-border); border-radius: 0; }
.card h3 { color: #1a1a1a; border-bottom: none; padding-bottom: 0; margin: 20px 0 8px; font-size: 14px; }

/* boxed section label, like a small tab sitting above its detail box - matches the house letterhead style */
.section-chip { display: inline-block; border: 1px solid var(--doc-border); border-radius: 2px; padding: 3px 12px; background: #fff; font-weight: bold; }

/* bordered box wrapping a group of fields, matching the printed form's boxed sections */
.detail-box { border: 1px solid var(--doc-border); border-radius: 2px; padding: 10px 14px; margin-top: -1px; }

.doc-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid var(--navy); padding-bottom: 10px; gap: 20px; }
.doc-header h2 { margin: 0 0 4px; color: var(--navy); text-decoration: underline; text-align: right; font-size: 18pt; }
.letterhead-left { flex: 1; min-width: 0; }
.letterhead-logo-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.logo-img-inline { height: 46px; width: auto; display: block; }
.letterhead-img { width: 440px; max-width: 100%; height: auto; display: block; }
.company-legal-name { font-weight: bold; font-size: 16px; color: #1a1a1a; white-space: nowrap; }
.doc-meta { text-align: right; font-size: 13px; flex: 0 0 auto; }
.meta-table { border-collapse: collapse; margin-left: auto; }
.meta-table td { border: none; padding: 1px 0 1px 12px; font-size: 11px; text-align: left; }
.meta-table td:first-child { font-weight: bold; background: none; }
.meta-table td:first-child::after { content: " :"; }
.small { font-size: 12px; color: #555; }
.logo-img { max-width: 220px; max-height: 70px; display: block; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px 24px; align-items: end; }
.field label { display: block; font-size: 11px; color: #555; margin-bottom: 3px; text-transform: uppercase; letter-spacing: .03em; }
.field input, .field select { width: 100%; padding: 7px 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 13px; color: var(--data-blue); font-weight: 600; }
.field.readonly div { padding: 7px 8px; background: var(--grey-bg); border: 1px solid var(--border); border-radius: 4px; font-size: 13px; min-height: 30px; color: var(--data-blue); font-weight: 600; }

.table-scroll { overflow-x: auto; margin-top: 10px; }
.pricing-table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 13px; }
.pricing-table th, .pricing-table td { border: 1px solid var(--doc-border); padding: 6px 8px; text-align: left; }
.pricing-table th { background: var(--navy); color: #fff; }
.pricing-table .cost-col { background: var(--office-bg); }
.pricing-table th.cost-col { background: #b08d00; color: #fff; }
.pricing-table .colno { width: 34px; text-align: center; }
.pricing-table .col-rm { width: 26px; text-align: left; font-weight: bold; color: var(--data-blue); }
.pricing-table .colmoney { width: 150px; }
.pricing-table .bold td { font-weight: bold; }
.pricing-table .otr-row td { background: var(--navy); color: #fff; font-weight: bold; font-size: 15px; }
.pricing-table .otr-row td.col-rm { color: #fff; }
.pricing-table .discount-label { color: var(--red); font-weight: bold; }
.pricing-table input.cellnum { width: 100%; border: none; background: transparent; font-size: 13px; text-align: right; color: var(--data-blue); font-weight: 600; }
.pricing-table input.discount-input { color: var(--red); }
.pricing-table input.small-input { width: 90px; border: 1px solid var(--border); text-align: right; margin-left: 6px; }
.pricing-table .feature-row td:nth-child(2) { font-style: italic; color: #555; }
.pricing-table tr.cost-col-only td:not(.cost-col) { border: none; background: transparent; }
.pricing-table .col-sub { width: 40px; text-align: center; }
.pricing-table .col-del { width: 30px; }
.pricing-table input.cellname { width: 100%; border: none; background: transparent; font-size: 13px; }
.pricing-table input.cellname.is-sub { font-style: normal; color: inherit; }
.pricing-table .rowDelBtn { border: none; background: none; color: var(--red); cursor: pointer; font-size: 15px; line-height: 1; }
.pricing-table .subCheckbox { transform: scale(1.1); cursor: pointer; }
.pricing-table input.amount-input { width: 100%; border: none; background: transparent; font-size: 13px; text-align: right; color: var(--data-blue); font-weight: 600; }
.profit-table input.cellname { width: 100%; border: none; background: transparent; font-size: 13px; }
.profit-table td:first-child { font-weight: normal; }
.profit-table tr.locked td:first-child { font-weight: bold; }

.inline-add-btn { float: right; font-size: 12px; padding: 4px 10px; border: 1px solid var(--border); background: #fff; border-radius: 4px; cursor: pointer; font-weight: normal; }
.office-box { border: 1px dashed #b08d00; border-radius: 6px; padding: 14px 18px; margin-top: 18px; }
.office-box h3 { border-bottom: none; margin-top: 0; display: inline-flex; align-items: center; gap: 10px; }
.office-tag { font-size: 10px; font-weight: normal; background: #b08d00; color: #fff; padding: 2px 8px; border-radius: 10px; text-transform: none; letter-spacing: 0; }
.hint { font-size: 11px; color: #7a6000; margin: 6px 0 0; }
.crm-lead-content { font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 20px; }
.crm-lead-content .crm-field { min-width: 140px; }
.crm-lead-content .crm-field label { display: block; font-size: 10px; text-transform: uppercase; color: #7a6000; }
.crm-lead-content .crm-stage { font-weight: bold; padding: 2px 8px; border-radius: 10px; color: #fff; background: var(--navy); display: inline-block; }
.crm-lead-content .crm-muted { color: #888; font-style: italic; }
.invoice-content { font-size: 13px; }
.inv-card { border: 1px solid #e2d9a8; border-radius: 6px; padding: 8px 10px; margin-bottom: 6px; background: #fffdf2; }
.inv-card.inv-suggested { border-style: dashed; background: #fff; }
.inv-card .inv-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inv-card .inv-no { font-weight: bold; color: var(--navy); }
.inv-card .inv-tag { font-size: 11px; padding: 1px 8px; border-radius: 10px; background: var(--navy); color: #fff; }
.inv-card .inv-tag.inv-weak { background: #a05a00; }
.inv-card .inv-meta { color: #555; margin-top: 3px; line-height: 1.5; }
.history-table .inv-no-cell { white-space: nowrap; font-size: 12px; }
.branch-row { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.branch-row select { flex: 1 1 180px; min-width: 150px; }
.branch-row button { font-size: 12px; padding: 4px 8px; }
.crm-picker { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.crm-picker input { flex: 1 1 280px; min-width: 200px; }
.crm-results { margin-top: 8px; font-size: 13px; }
.crm-results .crm-muted { color: #888; font-style: italic; }
.crm-result { display: flex; align-items: center; gap: 12px; padding: 6px 8px; border: 1px solid #e2d9a8; border-radius: 6px; margin-bottom: 5px; background: #fffdf2; }
.crm-result > div { flex: 1; min-width: 0; }
.crm-result .crm-stage { font-size: 11px; padding: 2px 8px; border-radius: 10px; color: #fff; background: var(--navy); white-space: nowrap; }
.terms-textarea { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 4px; font-size: 13px; font-family: inherit; resize: vertical; }
.print-text-mirror { display: none; }

.remark { font-size: 11px; color: #666; font-style: italic; }
.closing-line { margin-top: 16px; }
.sig-block { display: flex; justify-content: space-between; margin-top: 30px; font-size: 13px; }
.sig-space { height: 70px; }

.badge-row { display: flex; gap: 6px; margin-top: 16px; align-items: center; justify-content: space-around; }
.badge-row[hidden] { display: none; }
/* each badge gets flex-grow = its aspect ratio (set inline), so every badge ends up the same height and the row spans the full width */
.badge-row img { width: 0; min-width: 0; height: auto; max-height: 84px; object-fit: contain; display: block; }

/* ---------- modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-overlay[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 8px; padding: 20px 24px; width: 90%; max-width: 700px; max-height: 80vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-header h3 { margin: 0; color: var(--navy); }

.history-table, .history-table * { font-size: 13px; }
.history-table { width: 100%; min-width: 720px; border-collapse: collapse; background: #fff; }
.history-table th, .history-table td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.history-table th { background: var(--navy); color: #fff; }
.history-table tr:nth-child(even) { background: var(--grey-bg); }
.history-table button { padding: 4px 10px; font-size: 12px; margin-right: 4px; cursor: pointer; }
.status-badge { padding: 2px 8px; border-radius: 10px; font-size: 11px; color: #fff; }
.status-draft { background: #888; }
.status-sent { background: #2f5597; }
.status-won { background: var(--green); }
.status-lost { background: var(--red); }

#createUserForm { margin-bottom: 20px; }
#createUserResult { margin-top: 10px; font-size: 13px; }
#createUserResult .temp-pw { font-family: monospace; background: #fff2cc; padding: 4px 8px; border-radius: 4px; }

@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
  .doc-header { flex-direction: column; gap: 10px; }
  .doc-meta { text-align: left; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px; }
  .topbar nav { order: 3; width: 100%; margin-top: 8px; }
}

/* ---------- print: everything fits one A4 page ---------- */
/* ---- pricing-line prefixes ("Body :", "- ", ":", "Add On :") and body add-on picker ---- */
.pricing-table:not(.profit-table) th:nth-child(3), .pricing-table:not(.profit-table) tbody td:nth-child(3) { min-width: 340px; }
.pricing-table:not(.profit-table) th.cost-col:nth-child(7), .pricing-table:not(.profit-table) td.cost-col:nth-child(7) { min-width: 100px; }
.pricing-table:not(.profit-table) th.cost-col:nth-child(8), .pricing-table:not(.profit-table) td.cost-col:nth-child(8) { min-width: 170px; }
.label-wrap { display: flex; align-items: baseline; gap: 6px; }
.label-wrap .line-prefix { white-space: nowrap; color: #1a1a1a; font-size: 13px; }
.label-wrap .cellname { flex: 1; min-width: 0; }
.cell-print, .field-print, .num-print { display: none; }
.pricing-table td.colmoney { text-align: right; }
.pricing-table th.col-rm { color: #fff; }
tr.sub-row .label-wrap { padding-left: 26px; }
tr.internal-row td { background: #fff8e1; }
tr.internal-row .line-prefix { color: #7a6000; font-size: 11px; font-style: italic; }
.addon-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.addon-chips:empty { display: none; }
.addon-chip { font-size: 12px; padding: 3px 10px; border-radius: 14px; border: 1px solid #b08d00; background: #fffbe6; color: #5c4700; cursor: pointer; }
.addon-chip:hover { background: #ffefb0; }
.addon-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.addon-toolbar select { flex: 1 1 320px; min-width: 240px; }
.admin-h { margin: 0 0 6px; font-size: 15px; }
.addon-admin-table input, .addon-admin-table select { width: 100%; font-size: 12px; box-sizing: border-box; }
.addon-admin-table input.num { width: 84px; text-align: right; }
.addon-admin-table input[type=checkbox] { width: auto; }
#addonAdminCard { margin-top: 22px; }

.field[hidden] { display: none !important; }

/* ---- chassis price hint (office only, never printed) ---- */
.chassis-hint { margin: 6px 0 0; padding: 6px 10px; background: #eef6ee; border: 1px solid #9bc59b; border-radius: 4px; color: #1f4d1f; font-size: 12px; }
.chassis-hint.warn { background: #fff8e1; border-color: #b08d00; color: #5c4700; }
.chassis-hint[hidden] { display: none; }
#priceAdminCard { margin-top: 22px; }
.price-calc { font-weight: bold; white-space: nowrap; }

/* ---- leaf spring alert (office only, never printed) ---- */
.leaf-alert { background: #fdecea; border: 2px solid #c00000; border-radius: 6px; padding: 10px 14px; margin: 16px 0 8px; font-size: 13px; color: #5a0000; }
.leaf-alert[hidden] { display: none; }
.leaf-alert-title { font-weight: bold; font-size: 14px; color: #c00000; margin-bottom: 3px; }
.leaf-alert-actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 8px; }
.leaf-waive { display: flex; align-items: center; gap: 6px; cursor: pointer; font-weight: bold; }
tr.waiver-row td { background: #eef6ee; }
tr.waiver-row .line-prefix { color: #2d6a2d; font-style: normal; font-weight: bold; }

/* ---- history: clickable quotation numbers / rows ---- */
.qno-link { color: var(--navy); font-weight: bold; text-decoration: underline; }
.history-row { cursor: pointer; }
.history-row:hover td { background: #eef3fb; }

/* ---- import from Excel ---- */
.import-notice { background: #fff8e1; border: 1px solid #b08d00; border-radius: 6px; padding: 10px 14px; margin: 0 0 14px; font-size: 13px; color: #5c4700; }
.import-notice[hidden] { display: none; }
.import-notice ul { margin: 6px 0 0 18px; padding: 0; }
.import-notice .linklike { margin-left: 10px; }
.import-sheet-btn { display: block; width: 100%; text-align: left; background: #fff; border: 1px solid #c9d1e0; border-radius: 6px; padding: 10px 12px; margin: 0 0 8px; cursor: pointer; font-size: 13px; }
.import-sheet-btn:hover { border-color: var(--navy); background: #f3f6fc; }
.import-sheet-btn b { color: var(--navy); }
.import-sheet-btn .sub { color: #666; font-size: 12px; display: block; margin-top: 2px; }
.import-sheet-btn .warn { color: #a05a00; font-size: 12px; display: block; margin-top: 2px; }

@page { size: A4; margin: 8mm 10mm; }
@media print {
  .branch-row, .chassis-hint, .leaf-alert, .import-notice, .topbar, .toolbar, #historyView, #adminView, .modal-overlay, .inline-add-btn, .rowDelBtn, .subCheckbox { display: none !important; }
  /* keep the Sub / delete columns in the table grid (collapsed to zero width) so the footer colspans still line up with the Amount column */
  .pricing-table .col-sub, .pricing-table .col-del { width: 0 !important; min-width: 0 !important; max-width: 0 !important; padding: 0 !important; border: 0 !important; overflow: hidden; font-size: 0 !important; }
  .pricing-table .col-sub *, .pricing-table .col-del * { display: none !important; }
  .cost-col, th.cost-col, tr.cost-col-only, .office-box { display: none !important; }

  html, body { background: #fff; font-size: 9.5px; }
  main.view { margin: 0; max-width: 100%; padding: 0; }
  .card { box-shadow: none; padding: 0; border-radius: 0; }
  /* frame fills the page so the badge row sits at the very bottom */
  #printArea { border-width: 1.5px; padding: 10px; min-height: 274mm; box-sizing: border-box; display: flex; flex-direction: column; }
  #printArea > * { flex-shrink: 0; }
  #printArea > .section-chip { align-self: flex-start; }
  .card h3 { font-size: 10px; margin: 3px 0 2px; }
  .section-chip { padding: 1.5px 8px; border-width: 1px; }
  .detail-box { padding: 4px 8px; }

  .doc-header { padding-bottom: 3px; border-bottom-width: 2px; }
  .logo-img-inline { height: 26px; }
  .letterhead-img { width: 67mm; }
  .company-legal-name { font-size: 11px; }
  .doc-header h2 { font-size: 18pt; margin: 0 0 1px; line-height: 1.1; }
  .doc-meta { font-size: 8.5px; }
  .meta-table td { padding: 0 0 0 8px; font-size: 8.5px; }
  .small { font-size: 7.5px; line-height: 1.3; }

  .grid-2 { gap: 0 16px; row-gap: 0; }
  .field { display: flex; align-items: baseline; gap: 5px; margin-bottom: 0; line-height: 1.35; }
  .field label { font-size: 7px; margin-bottom: 0; width: 82px; flex: 0 0 auto; color: #333; }
  .field input, .field select { font-size: 9px; padding: 0; border: none; background: transparent; flex: 1; min-width: 0; }
  .field.readonly { display: flex; align-items: baseline; gap: 5px; }
  .field.readonly div { padding: 0; min-height: auto; background: transparent; border: none; font-size: 9px; flex: 1; }

  .table-scroll { margin-top: 3px; overflow: visible; }
  .pricing-table { font-size: 9px; min-width: 0; }
  .pricing-table th, .pricing-table td { padding: 1px 4px; }
  .pricing-table .col-rm { padding: 1.5px 2px; }
  .pricing-table .otr-row td { font-size: 10.5px; padding: 3px 4px; }
  .pricing-table input.cellname, .pricing-table input.amount-input { font-size: 9px; }
  tr.internal-row { display: none !important; }
  input::placeholder, textarea::placeholder { color: transparent !important; }
  .field select { -webkit-appearance: none; appearance: none; background-image: none; }
  .detail-box .field > input:not([type=checkbox]) { display: none !important; }
  .field-print { display: block; flex: 1; min-width: 0; font-size: 9px; font-weight: 700; color: var(--data-blue); line-height: 1.3; word-break: break-word; }
  .pricing-table .amount-input, .pricing-table tfoot input.cellnum { display: none !important; }
  .num-print { display: block; text-align: right; font-size: 9px; font-weight: 700; color: var(--data-blue); }
  .pricing-table tfoot td.colmoney { font-size: 9px; }
  .pricing-table .discount-label, .pricing-table td.colmoney .num-print.discount { color: #c00000; }
  .label-wrap { gap: 4px; align-items: flex-start; }
  .label-wrap .line-prefix { font-size: 9px; }
  .pricing-table .cellname { display: none !important; }
  .cell-print { display: block; font-size: 9px; line-height: 1.25; flex: 1; min-width: 0; color: #000; }
  tr.sub-row .label-wrap { padding-left: 16px; }

  .remark { font-size: 7px; margin: 1px 0; }
  .print-text-mirror { display: block; white-space: pre-wrap; font-size: 8.5px; line-height: 1.25; }
  .closing-line { margin: 4px 0 0; font-size: 8.5px; }
  .sig-block { margin-top: 8px; font-size: 8.5px; }
  /* signing gap absorbs whatever page space is left (badges stay pinned to the bottom); shrinks to 3mm on very busy quotes */
  .sig-block { flex: 1 1 auto; align-items: stretch; }
  .sig-block > div { display: flex; flex-direction: column; }
  .sig-space { flex: 1 1 auto; height: auto; min-height: 3mm; }

  .terms-textarea { display: none !important; }

  .badge-row { margin-top: auto; margin-bottom: 3mm; padding-top: 8px; gap: 4px; }
  .badge-row img { max-height: 64px; }
}

/* ================= Vehicle Quotation layout (company classic sample) ================= */
.vq-overlay { position: fixed; inset: 0; z-index: 3000; background: #5b6470; display: flex; flex-direction: column; }
.vq-overlay[hidden] { display: none; }
.vq-bar { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: #1f3864; color: #fff; font-size: 14px; }
.vq-bar span { flex: 1; font-weight: bold; }
.vq-scroll { flex: 1; overflow: auto; padding: 18px 0 40px; }
.vq-sheet { background: #fff; width: 210mm; min-height: 297mm; margin: 0 auto; padding: 11mm 25mm 12mm; box-sizing: border-box;
  font-family: Calibri, Carlito, "Segoe UI", Arial, sans-serif; font-size: 8.4pt; line-height: 1.26; color: #000; box-shadow: 0 2px 14px rgba(0,0,0,.35); }
.vq-sheet .vq-b, .vq-sheet b { font-weight: bold; }
.vq-head { display: flex; justify-content: space-between; align-items: flex-start; }
.vq-letterhead { width: 78mm; height: auto; display: block; }
.vq-brandlogo { height: 17mm; width: auto; display: block; margin-top: 1mm; }
.vq-title { font-family: Cambria, "Times New Roman", serif; font-weight: bold; font-size: 13.5pt; letter-spacing: .4pt; margin: 3mm 0 2mm; }
.vq-info-row { display: grid; grid-template-columns: 33mm 54mm 36mm 4mm 33mm; align-items: baseline; min-height: 3.7mm; }
.vq-info-row.vq-gap { margin-top: 1.4mm; }
.vq-refl { text-align: right; padding-right: 2mm; }
.vq-info-row .vq-ref { font-weight: bold !important; }
.vq-c2.vq-span { grid-column: 2 / -1; }
.vq-c5 { text-align: right; }
.vq-c5.vq-left { text-align: left; }
.vq-c3, .vq-c4 { font-weight: normal; }
.vq-info-row.vq-b .vq-c3, .vq-info-row.vq-b .vq-c4, .vq-info-row.vq-b .vq-c5 { font-weight: normal; }
.vq-info-row .vq-n { font-weight: normal; }
.vq-mail { color: #0563c1; text-decoration: underline; }
.vq-request { margin: 2.6mm 0 2mm; }
.vq-nett { display: flex; justify-content: space-between; font-weight: bold; border-bottom: 1.6px solid #000; padding: 1mm 0 .6mm; margin-top: 2mm; }
.vq-nett span:last-child { font-weight: normal; }
.vq-prows { margin-top: 1.6mm; }
.vq-prow { display: grid; grid-template-columns: 51mm 1fr 22mm; align-items: baseline; }
.vq-prow.vq-gap { margin-top: 1.2mm; }
.vq-pa { text-align: right; }
.vq-pd { padding-right: 4mm; }
.vq-totals { margin-top: 3mm; }
.vq-trow { display: grid; grid-template-columns: 1fr 22mm; align-items: baseline; }
.vq-trow .vq-tl { text-align: right; padding-right: 8mm; }
.vq-trow .vq-ta { text-align: right; }
.vq-trow.vq-left .vq-tl { text-align: left; padding-right: 0; }
.vq-topline { border-top: 1.6px solid #000; }
.vq-sep { border-top: 1.6px solid #000; margin-top: .5mm; }
.vq-ins .vq-tl { display: grid; grid-template-columns: 51mm 44mm 1fr; }
.vq-ins .vq-si { display: flex; gap: 6mm; grid-column: 2; }
.vq-ins .vq-est { text-align: right; padding-right: 7mm; grid-column: 3; }
.vq-otr { border-top: 1.6px solid #000; border-bottom: 1.6px solid #000; margin-top: .8mm; }
.vq-remark { font-weight: bold; margin-top: 1.6mm; }
.vq-badges { display: flex; gap: 2.2mm; align-items: center; justify-content: space-between; margin-top: 2mm; }
.vq-badges img { width: 0; min-width: 0; height: auto; max-height: 10.5mm; object-fit: contain; display: block; }
.vq-terms-h { margin-top: 2.4mm; }
.vq-term { display: grid; grid-template-columns: 22mm 1fr; margin-top: .5mm; }
.vq-tk { text-align: right; padding-right: 20mm; }
.vq-bank { margin-top: 1.6mm; }
.vq-closing { margin-top: 2.6mm; max-width: 150mm; }
.vq-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 20mm; margin-top: 4mm; }
.vq-sign .vq-say { margin-bottom: 9mm; }
.vq-sign .vq-line { border-top: 1.2px solid #000; margin-bottom: .8mm; }

/* ---- Hino quotation: exact company "Final Hino" format (scoped to .vq-sheet.hq) ---- */
.vq-sheet.hq .vq-info-row { grid-template-columns: 50mm 51mm 33mm 4mm 1fr; }
.vq-sheet.hq .vq-c2:not(.vq-span) { white-space: nowrap; }
.vq-sheet.hq .vq-c5 { display: flex; justify-content: flex-end; white-space: nowrap; }
.vq-sheet.hq .vq-c5.vq-left { justify-content: flex-start; }
.vq-sheet.hq .vq-c1.vq-b { font-weight: bold; }
.hq-request { display: grid; grid-template-columns: 25.4mm 1fr; margin: 2.6mm 0 2mm; }
.hq-request u { text-decoration: underline; }
.hq-acc { display: grid; grid-template-columns: 25.4mm 1fr; margin-top: 2mm; align-items: start; }
.hq-hang { display: block; padding-left: 2.2mm; text-indent: -2.2mm; }
.vq-sheet.hq .vq-trow .vq-tl { padding-right: 4.5mm; }
.vq-sheet.hq .vq-trow.vq-left .vq-tl { padding-right: 0; }
.vq-sheet.hq .vq-ins .vq-tl { grid-template-columns: 52mm 48.5mm 1fr; }
.vq-sheet.hq .vq-ins .vq-si { justify-content: space-between; gap: 0; }
.vq-sheet.hq .vq-ins .vq-est { padding-right: 4.5mm; }
.hq-term { display: grid; grid-template-columns: 24mm 27mm 1fr; margin-top: .5mm; }
.hq-tk, .hq-tl { text-align: right; }
.hq-tl { padding-right: 0; }
.hq-tv { padding-left: 1.2mm; }
.hq-sign { display: grid; grid-template-columns: 51.7mm 1fr 37.4mm; margin-top: 4mm; }
.hq-sign .vq-say { margin-bottom: 9mm; }
.hq-sign .vq-line { border-top: 1.2px solid #000; margin-bottom: .8mm; }
.linklike-dark { background: none; border: none; color: #1f3864; text-decoration: underline; cursor: pointer; font-size: 13px; }


/* ---- Hino sheet built from the company's Excel template geometry (.hx-*) ---- */
.vq-sheet.hq { width: 772px; min-height: 0; padding: 14px 0 12px; font-family: Calibri, Carlito, "Segoe UI", Arial, sans-serif; font-size: 10pt; line-height: 17px; }
.hx-row { display: grid; grid-template-columns: 119px 128px 78px 41px 117px 101px 8px 47px 9px 124px; align-items: end; box-sizing: border-box; position: relative; }
.hx-c { white-space: nowrap; overflow: visible; line-height: 1.15; padding: 0 2px 1px 3px; min-width: 0; }
.hx-row.hx-g { align-items: start; padding-top: var(--pt, 0); }
.hx-row.hx-g .hx-c { padding-bottom: 0; line-height: 17px; }
.hx-c.hx-wrap { white-space: normal; line-height: 17px; padding-bottom: 0; align-self: start; }
.hx-c.hx-nw { white-space: nowrap; }
.hx-b, .hx-c b { font-weight: bold; }
.hx-r { text-align: right; }
.hx-center { text-align: center; }
.hx-u { text-decoration: underline; }
.hx-mail { color: #0563c1; }
.hx-s9 { font-size: 9pt; }
.hx-over { position: relative; }
.hx-title { font-family: "Bell MT", Cambria, "Times New Roman", serif; font-weight: bold; font-size: 16pt; line-height: 1; padding-bottom: 2px; }
.hx-head { position: relative; }
.hx-letterhead { position: absolute; left: 0; top: 0; height: 128px; width: auto; }
.hx-logo { position: absolute; right: 14px; top: 0; height: 104px; width: auto; }
.hx-hang { display: block; padding-left: 7px; text-indent: -7px; white-space: normal; max-width: 396px; }
.hx-acc { display: block; max-width: 600px; }
.hx-bm { border-bottom: 2px solid #000; }
.hx-tm { border-top: 2px solid #000; }
.hx-bt { border-bottom: 1px solid #000; }
.hx-bmc { border-bottom: 2px solid #000; }
.hx-badges { display: flex; gap: 6px; align-items: center; justify-content: space-between; box-sizing: border-box; padding: 2px 0; }
.hx-badges img { width: 0; min-width: 0; height: auto; max-height: 100%; object-fit: contain; display: block; }
.hx-closing { width: 740px; white-space: normal; line-height: 17px; }
@media print {
  body.vq-open .vq-sheet.hq { width: 772px; margin: 0 auto; padding: 0; font-size: 10pt; zoom: var(--vq-fit, 1); }
}
.hx-c.hx-bmc, .hx-c.hx-bt { align-self: stretch; }
.hx-c.hx-bmc { display: flex; align-items: flex-end; }
.hx-c.hx-bmc.hx-r { justify-content: flex-end; }
.hx-c.hx-bmc.hx-center { justify-content: center; }

/* ---- Fuso / Isuzu: company 2026 QUOTATION template (.qx-*) ---- */
.vq-sheet.qx { width: var(--qxw, 855px); min-height: 0; padding: 14px 0 12px; font-family: Arial, "Liberation Sans", Helvetica, sans-serif; font-size: 11pt; line-height: 1.15; }
.qx-wrap { position: relative; }
.qx-head { position: relative; }
.qx-abs { position: absolute; display: block; }
.qx-co { font-weight: bold; text-decoration: underline; font-size: 17pt; display: flex; align-items: flex-end; white-space: nowrap; line-height: 1; }
.qx-c.qx-addrtxt { white-space: normal; align-self: start; line-height: 20px; max-width: 330px; padding-top: 1px; }
.qx-addr { font-size: 10pt; white-space: nowrap; line-height: 1.2; }
.qx-hr { position: absolute; top: 0; }
.qx-title { display: flex; align-items: center; justify-content: center; font-weight: bold; text-decoration: underline; font-size: 14pt; line-height: 1; }
.qx-termsblock { overflow: visible; }
.qx-hbox { box-sizing: border-box; border: 1px solid #000; text-align: center; font-size: 10pt; display: flex; align-items: center; justify-content: center; }
.qx-hbox + .qx-hbox { margin-top: -1px; }
.qx-hl { position: absolute; text-align: right; font-size: 10pt; }
.qx-hl > div { display: flex; align-items: center; justify-content: flex-end; }
.qx-box { border: 1px solid #000; margin-left: 12px; position: relative; box-sizing: border-box; }
.qx-tab { position: absolute; left: -1px; top: -13px; width: 156px; height: 25px; background: #fff; border: 1px solid #000; font-weight: bold; font-size: 11pt; display: flex; align-items: center; padding-left: 8px; box-sizing: border-box; z-index: 2; }
.qx-row { display: grid; align-items: end; box-sizing: border-box; }
.qx-row.qx-gs { align-items: start; padding-top: 2px; }
.qx-c { white-space: nowrap; min-width: 0; padding: 0 2px 1px; line-height: 1.12; }
.qx-ctr { text-align: center; }
.qx-r { text-align: right; padding-right: 4px; }
.qx-b, .qx-c b { font-weight: bold; }
.qx-nw { white-space: nowrap; }
.qx-s9 { font-size: 9pt; }
.qx-s12 { font-size: 12pt; }
.qx-wrapd { white-space: normal; align-self: start; padding-left: 3px; }
.qx-mail { color: #0563c1; text-decoration: underline; font-family: Calibri, Carlito, Arial, sans-serif; }
.qx-wrapmail { white-space: normal; overflow-wrap: anywhere; align-self: start; }
.qx-row.qx-tr { border-bottom: 0.5px solid #b5b5b5; align-items: start; padding-top: 2px; background-image: linear-gradient(#000, #000), linear-gradient(#000, #000), linear-gradient(#000, #000), linear-gradient(#000, #000); background-size: 1px 100%; background-repeat: no-repeat; background-position: 0 0, var(--vx1) 0, var(--vx2) 0, calc(100% - 1px) 0; }
.qx-row.qx-tr .qx-c { align-self: start; }
.qx-row.qx-th { border-top: 1px solid #000; border-bottom: 1px solid #000; align-items: center; background-image: linear-gradient(#000, #000), linear-gradient(#000, #000), linear-gradient(#000, #000), linear-gradient(#000, #000); background-size: 1px 100%; background-repeat: no-repeat; background-position: 0 0, var(--vx1) 0, var(--vx2) 0, calc(100% - 1px) 0; }
.qx-table { margin-left: 12px; border-bottom: 1px solid #000; }
.qx-m { border-top: 2px solid #000; }
.qx-mb { border-bottom: 2px solid #000; }
.qx-redrow .qx-c, .qx-red { color: #ff0000; }
.qx-amtc { padding: 0 3px 0 4px; }
.qx-amt { display: flex; justify-content: space-between; width: 100%; }
.qx-txtamt { display: block; text-align: right; }
.qx-est { font-size: 12pt; }
.qx-otrrow { position: relative; margin-left: 12px; box-sizing: border-box; border-top: 1px solid #000; }
.qx-remark { position: absolute; left: 2px; bottom: 1px; font-size: 9pt; font-weight: bold; white-space: nowrap; }
.qx-otrlbl { position: absolute; top: 0; height: 100%; box-sizing: border-box; border: 2px solid #000; font-weight: bold; display: flex; align-items: center; justify-content: center; }
.qx-otramt { position: absolute; top: 0; height: 100%; box-sizing: border-box; border: 2px solid #000; border-left: 0; font-weight: bold; font-size: 12pt; display: flex; align-items: center; padding: 0 3px; }
.qx-otramt .qx-amt { font-weight: bold; }
.qx-th2 { font-size: 12pt; text-decoration: underline; margin-top: 3px; height: 21px; display: flex; align-items: flex-end; }
.qx-terms { list-style: none; counter-reset: t; margin: 0 0 0 12px; padding: 4px 0 0; }
.qx-terms li { counter-increment: t; position: relative; padding-left: 48px; line-height: var(--lh, 1.15); margin: 0; }
.qx-terms li::before { content: counter(t) "."; position: absolute; left: 0; }
.qx-bank2 { padding-left: 92px; }
.qx-t-FUSO i { font-size: 11pt; }
.qx-line { border-bottom: 1px solid #000; }
.qx-foot { position: relative; overflow: hidden; }
.qx-foot img { position: absolute; left: 0; display: block; }
@page vq { size: A4; margin: 7mm 7mm; }
@media print {
  body.vq-open .vq-sheet.hq, body.vq-open .vq-sheet.qx { page: vq; }
  body.vq-open .vq-sheet.qx { width: var(--qxw, 855px); margin: 0 auto; padding: 0; font-size: 11pt; zoom: var(--vq-fit, 1); }
}

@media print {
  body.vq-open #appView, body.vq-open #loginView, body.vq-open #changePwView, body.vq-open .modal-overlay { display: none !important; }
  body.vq-open { background: #fff !important; }
  body.vq-open .vq-overlay { position: static; background: #fff; display: block; }
  body.vq-open .vq-bar { display: none !important; }
  body.vq-open .vq-scroll { overflow: visible; padding: 0; }
  body.vq-open .vq-sheet { width: 100%; min-height: 0; margin: 0; padding: 2mm 15mm 0; box-shadow: none; font-size: 8.4pt; zoom: var(--vq-fit, 1); }
  body.vq-open .vq-prow, body.vq-open .vq-trow, body.vq-open .vq-term { break-inside: avoid; }
}

/* ---------- costing window (office only) ---------- */
.cost-modal { max-width: 900px; }
.cost-modal .modal-header h3 { font-size: 17px; }
.cw-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 4px; table-layout: fixed; }
.cost-modal { overflow-x: hidden; }
.cw-table th { background: #b08d00; color: #fff; text-align: left; padding: 5px 7px; font-weight: 600; }
.cw-table td { border: 1px solid var(--border); padding: 3px 6px; vertical-align: middle; }
.cw-table td.num, .cw-table th.num { text-align: right; white-space: nowrap; }
.cw-table input { width: 100%; box-sizing: border-box; border: 1px solid #d6c98a; border-radius: 3px; padding: 3px 5px; font-size: 13px; background: #fffdf3; }
.cw-table input.cw-cost { text-align: right; }
.cw-table tr.cw-sub td:nth-child(2) { padding-left: 22px; color: #555; }
.cw-table tr.cw-internal td { background: #fff8e1; }
.cw-h { margin: 14px 0 4px; font-size: 13px; font-weight: 700; color: var(--navy); display: flex; align-items: center; gap: 10px; }
.cw-h button { font-size: 12px; padding: 2px 9px; cursor: pointer; }
.cw-total td { font-weight: 700; background: #f3f3f3; }
.cw-total.cw-big td { font-size: 14px; background: #fff3c4; border-top: 2px solid #000; }
.cw-nett td { font-weight: 700; font-size: 15px; background: #ffe8d6; border-top: 2px solid #000; color: #c00000; }
.cw-ins { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; align-items: end; }
.cw-ins label { font-size: 12px; display: block; color: #555; }
.cw-ins input { width: 100%; box-sizing: border-box; padding: 4px 6px; }
.cw-ins .cw-out { font-weight: 700; padding: 4px 0; }
.cw-del { border: none; background: none; color: #b00020; font-size: 16px; cursor: pointer; }
.cw-note { font-size: 12px; color: #666; margin: 4px 0; }

.history-table .num-cell { white-space: nowrap; text-align: right; }
.history-table .num-cell.neg { color: #c0392b; font-weight: 600; }
