@page {
    size: A4 portrait;
    margin: 4mm 6mm;
  }
  * {
    box-sizing: border-box;
  }
  body {
    margin: 0;
    background: #e5e5e5;
    font-family: 'Barlow', Arial, sans-serif;
    color: #111;
    font-weight: 500;
    font-size: 12px;
    line-height: 1.15;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .page {
    width: 210mm;
    height: 297mm;
    margin: 0 auto;
    background: #fff;
    padding: 3.5mm 5.5mm 2mm 15mm;
    box-shadow: 0 0 10px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
  }

  .content-body {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 1;
    justify-content: space-between;
    min-height: 0;
  }
  .content-body textarea {
    overflow-wrap: anywhere;
    white-space: pre-wrap;
  }

  /* SVG Icons */
  .icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    width: 14px;
    height: 14px;
    fill: currentColor;
    flex-shrink: 0;
    margin-right: 4px;
  }
  .box h3 .icon, .section-title .icon {
    fill: #fff;
  }

  /* Header */
  .header {
    display: grid;
    grid-template-columns: 1.35fr 0.95fr 1.25fr;
    gap: 6px;
    align-items: center;
  }
  .logo {
    font-family: "Barlow Condensed", sans-serif !important;
    font-size: 42px !important;
    font-weight: 800 !important;
    color: #047A3D !important;
    line-height: 0.95;
    letter-spacing: -0.5px;
  }
  .logo .dot { color: #6FB426; }
  .tagline {
    font-family: "Poppins", sans-serif;
    font-size: 8.5px;
    margin-top: 2px;
    font-weight: 600;
    color: #444;
  }
  .tech {
    font-size: 8px;
    line-height: 1.15;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: #333;
  }
  .contact {
    text-align: right;
    font-size: 11px;
    line-height: 1.2;
  }
  .contact-line {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
  }
  .contact-line .icon {
    color: #047A3D;
  }
  .contact input {
    text-align: right;
    width: 130px;
    font-size: 11px;
  }

  /* Banner & Meta */
  .banner {
    background: #047A3D;
    color: #fff;
    text-align: center;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 2px;
    padding: 1px 0;
    margin: 0;
  }
  .meta {
    display: grid;
    grid-template-columns: 1.2fr 1fr 0.8fr;
    border: 1px solid #bbb;
    border-top: 0;
    font-size: 11px;
    margin: 0;
  }
  .meta div {
    padding: 1px 4px;
    border-right: 1px solid #bbb;
    display: flex;
    align-items: center;
    gap: 4px;
  }
  .meta div:last-child { border-right: 0; }
  .meta input {
    font-size: 11px;
  }
  .date-field {
    position: relative;
    flex: 1;
    min-width: 0;
  }
  .date-field .date-display {
    width: 100%;
  }
  .date-field .date-picker-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
  }
  .calendar-button {
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    height: 16px;
    padding: 0;
    border: 1px solid #aaa;
    background: #fff;
    color: #047A3D;
    font-size: 10px;
    line-height: 14px;
    cursor: pointer;
  }
  .calendar-button svg {
    width: 12px;
    height: 12px;
    fill: currentColor;
    vertical-align: middle;
  }

  /* Service Type Checkbox Bar */
  .service-type-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #bbb;
    border-top: 0;
    padding: 2px 5px;
    background: #fcfcfc;
    font-size: 11px;
    margin: 0;
  }
  .service-type-bar .type-title {
    font-weight: 700;
    color: #047A3D;
    text-transform: uppercase;
    font-size: 11px;
  }
  .service-type-bar label {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 600;
    color: #222;
    cursor: pointer;
    margin: 0;
  }
  .service-type-bar input[type="checkbox"] {
    width: 13px;
    height: 13px;
    accent-color: #047A3D;
    cursor: pointer;
    margin: 0;
  }

  /* Forms & Zero-Gap Headings */
  .grid2 {
    display: grid;
    grid-template-columns: 1.08fr 0.92fr;
    gap: 3px;
    margin: 0;
  }
  .details-grid {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.4fr);
    align-items: stretch;
    min-height: 200px;
  }
  .details-grid > .box,
  .details-grid .instrument-container,
  .details-grid .inst-compact-fields {
    min-width: 0;
  }
  .details-grid .detail-field {
    flex: 1;
    min-width: 0;
    height: 24px;
    min-height: 24px;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    resize: none;
  }
  .details-grid .detail-field.multiline-field {
    height: 40px;
    min-height: 40px;
  }
  
  .next-calibration {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
  }
  .next-calibration .date-field {
    flex: 0 0 145px;
  }
  .box {
    border: 1px solid #bbb;
    padding: 0 4px 2px 4px;
    margin: 0;
  }
  .box h3, .section-title {
    font-size: 14px;
    margin: 0 -4px 0 -4px;
    background: #047A3D;
    color: #fff;
    padding: 1px 5px;
    font-weight: 700;
    text-transform: uppercase;
    border-radius: 0;
    display: flex;
    align-items: center;
    margin-bottom: 5px;
  }
  .box h3.inner-heading {
    margin: 0 -4px 0 -4px;
    border-top: 1px solid #bbb;
  }

  /* Text inside headings & Clear Button */
  .heading-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .clear-btn {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    margin-left: 6px;
    flex-shrink: 0;
    transition: fill 0.2s;
  }
  .clear-btn:hover {
    fill: #ffffff;
  }

  label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    margin-top: 0;
    color: #333;
  }
  input, textarea, select {
    font-family: 'Barlow', Arial, sans-serif;
    font-size: 12px;
    font-weight: 500;
    width: 100%;
    border: 0;
    border-bottom: 1px dotted #aaa;
    padding: 0;
    outline: none;
    background: transparent;
    color: #111;
  }
  textarea {
    resize: none;
    min-height: 14px;
    border: 1px solid #ddd;
    padding: 1px 2px;
    line-height: 1.15;
    margin: 0;
  }
  select {
    border: 1px solid #ccc;
    padding: 0 1px;
    background: #fff;
    font-weight: 700;
    font-size: 11px;
    border-radius: 2px;
    cursor: pointer;
    width: 100%;
  }

  /* Customer Details Compact Structure */
  .cust-fields {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 0;
    padding-top: 1px;
  }
  .field-row {
    display: flex;
    align-items: center;
    gap: 3px;
    margin: 0;
  }
  .field-row label {
    white-space: nowrap;
    font-size: 11px;
    flex-shrink: 0;
  }
  .field-row input {
    flex: 1;
    min-width: 0;
    font-size: 11.5px;
  }

  /* Highlighted Reported Issue in Red */
  .reported-issue-text {
    color: #d32f2f !important;
    font-weight: 600 !important;
  }

  /* Instrument Section */
  .instrument-container {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px;
    align-items: center;
    height: 100%;
    margin: 0;
  }
  .inst-compact-fields {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    padding-right: 2px;
    gap: 0;
  }

  /* 1:1 Square Images */
  .photo {
    aspect-ratio: 1 / 1 !important;
    border: 1px solid #aaa;
    position: relative;
    text-align: center;
    overflow: hidden;
    background: #fafafa;
    margin: 0;
  }
  
  .photo.inst-photo {
    width: 175px;
    height: 175px;
    flex-shrink: 0;
    border-radius: 2px;
  }
  .parts-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
  }
  .photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
  }
  .photoCaption {
    display: block !important;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 16px;
    background: rgba(255,255,255,0.92);
    border: 0;
    border-top: 1px solid #bbb;
    padding: 0 2px;
    font-family: 'Barlow', Arial, sans-serif;
    font-size: 10px;
    font-weight: 600;
    text-align: center;
    z-index: 3;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .uploadBtn {
    position: absolute;
    top: calc(50% - 9px);
    left: 50%;
    transform: translate(-50%, -50%);
    background: #111;
    color: #fff;
    border: 0;
    padding: 2px 4px;
    font-size: 8px;
    cursor: pointer;
    border-radius: 2px;
    white-space: nowrap;
  }
  input[type=file] { display: none; }

  /* 4 Images Row: Seamless Zero Gap 1:1 Squares */
  .photos {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 1fr;
    gap: 0;
    width: 100%;
    border: 1px solid #aaa;
    margin: 0;
  }
  .photos .photo {
    width: 100%;
    height: auto;
    border: 0;
    border-right: 1px solid #aaa;
    border-radius: 0;
  }
  .photos .photo:last-child {
    border-right: 0;
  }

  /* Dual 6-Row Data Tables */
  .dual-tables {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 3px;
    margin: 0;
    min-width: 0;
    width: 100%;
  }
  .dual-tables > .box:nth-child(n + 3) {
    grid-column: 1 / -1;
  }
  .dual-tables > .box,
  table.data-table {
    min-width: 0;
    max-width: 100%;
  }
  table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    font-weight: 500;
    margin: 0;
    table-layout: fixed;
  }
  table.data-table th, table.data-table td {
    border: 1px solid #aaa;
    padding: 0.5px 2px;
    text-align: left;
    height: 15px;
    overflow: hidden;
  }
  table.data-table th {
    font-size: 11px;
    font-weight: 700;
    background: #f4f4f4;
    white-space: nowrap;
  }
  table.data-table td input {
    font-size: 11.5px;
    padding: 0;
    min-width: 0;
    max-width: 100%;
  }
  table.data-table td select {
    min-width: 0;
    max-width: 100%;
  }

  /* Signatures */
  .bottom {
    display: grid;
    grid-template-columns: 1.15fr 1fr 1fr;
    gap: 3px;
    margin: 0;
  }
  .sig {
    height: 80px;
    border: 1px solid #aaa;
    padding: 1px 4px;
    position: relative;
    background: #fff;
    font-size: 11px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    margin: 0;
  }
  .sigTitle {
    font-size: 11px;
    font-weight: 700;
    color: #222;
  }
  .sig-sign-space {
    height: 22px;
    cursor: crosshair;
    display: flex;
    align-items: center;
  }
  .sig-line {
    border-top: 1px dotted #888;
    margin: 1px 0;
  }
  .sig-name-input {
    font-size: 11.5px;
    font-weight: 600;
    padding: 0;
    border: 0;
  }

  /* Status Dropdown */
  .status-select {
    font-size: 10.5px;
    font-weight: 700;
    padding: 1px;
    border: 1px solid #ccc;
    background: #fff;
    cursor: pointer;
  }
  .status-pass {
    color: #047A3D !important;
  }
  .status-fail {
    color: #d32f2f !important;
  }

  /* Footer - Two Line Layout */
  .footer {
    margin: 0 auto;
    width: 100%;
    max-width: 198mm;
    border-top: 1px solid #222;
    padding-top: 5px;
    font-size: 9px;
    line-height: 1.3;
  }
  .footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
  }
  .footer-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    width: 100%;
  }
  .footer .flogo {
    font-family: "Barlow Condensed", sans-serif !important;
    font-weight: 800 !important;
    font-size: 13px;
    color: #047A3D !important;
    letter-spacing: 0.5px;
  }
  .footer .flogo .dot { color: #6FB426; }
  .footer input {
    font-size: 9px;
    padding: 0;
    border: 0;
    border-bottom: 1px dotted #aaa;
    background: transparent;
    text-align: center;
  }
  .footer-address {
    width: 320px !important;
  }

  /* Toolbar */
  .tools {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 10;
  }
  .tools button {
    padding: 6px 12px;
    border: 0;
    background: #047A3D;
    color: #fff;
    border-radius: 4px;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  }

  @media print {
    html, body {
      width: 210mm;
      height: 297mm;
      background: #fff;
      margin: 0 !important;
      padding: 0 !important;
    }
    .page {
      width: 210mm;
      height: 297mm;
      margin: 0;
      padding: 2mm 4mm 1mm 15mm;
      box-shadow: none;
      page-break-inside: avoid;
      page-break-after: avoid;
    }
    .tools, .uploadBtn, .photoCaption, .clear-btn { display: none !important; }
    input, textarea { border-color: transparent !important; }
    select {
      border-color: transparent !important;
      -webkit-appearance: none !important;
      appearance: none !important;
      background-image: none !important;
    }
    input[type=number]::-webkit-inner-spin-button,
    input[type=number]::-webkit-outer-spin-button {
      -webkit-appearance: none;
      margin: 0;
    }
  }