/* 3S Official Unified Forms Theme - Equal A4 Size Fix */
:root{
  --red:#d40000 !important;
  --red-dark:#b30000 !important;
  --brand-red:#d40000 !important;
  --brand-red-dark:#b30000 !important;
  --text:#222222 !important;
  --border:#000000 !important;
  --page-bg:#ffffff !important;
  --outer-bg:#cfcfcf !important;
  --white:#ffffff !important;
  --font-main:Arial,Tahoma,"Segoe UI",sans-serif;
  --a4w:210mm;
  --a4h:297mm;
  --frame-inset:3mm;
}
html,body{
  font-family:var(--font-main)!important;
  background:var(--outer-bg)!important;
  color:var(--text)!important;
}
*{-webkit-print-color-adjust:exact!important;print-color-adjust:exact!important;}
.page,.page-sheet,.form-sheet{
  width:var(--a4w)!important;
  height:var(--a4h)!important;
  min-height:var(--a4h)!important;
  max-height:var(--a4h)!important;
  margin:10px auto!important;
  background:#fff!important;
  position:relative!important;
  isolation:isolate!important;
  overflow:hidden!important;
  box-shadow:0 0 10px rgba(0,0,0,.18)!important;
  font-family:var(--font-main)!important;
  color:var(--text)!important;
}
.page::before,.page-sheet::before,.form-sheet::before{
  content:"";
  position:absolute;
  inset:var(--frame-inset);
  border:1px solid #b9b9b9;
  pointer-events:none;
  z-index:0;
}
.page > *,.page-sheet > *,.form-sheet > *{position:relative;z-index:1;}

/* unified header/footer sizes inside the page frame */
.brand-header,.official-header{
  width:100%!important;
  height:30mm!important;
  min-height:30mm!important;
  max-height:30mm!important;
  margin:0 0 2mm 0!important;
  display:flex!important;
  align-items:center!important;
  justify-content:center!important;
  text-align:center!important;
}
.brand-header img,.official-header img,.header-logo{
  display:block!important;
  width:100%!important;
  max-width:100%!important;
  height:30mm!important;
  max-height:30mm!important;
  object-fit:contain!important;
  margin:0 auto!important;
}
.brand-footer,.official-footer,.page .footer{
  width:auto!important;
  min-height:18mm!important;
  max-height:18mm!important;
  height:18mm!important;
  margin:0!important;
}
.brand-footer img,.official-footer img{
  display:block!important;
  width:100%!important;
  max-width:100%!important;
  height:18mm!important;
  max-height:18mm!important;
  object-fit:contain!important;
  margin:0 auto!important;
}

/* Official red theme */
.red,.sec-title,.section-title,.main-title,.table-title,.red-title,.acc-title,.pm-title,.pm-sub,.red-label,
.section-head td,.signature-original .head,.vehicle-info th.red,.accessories th.red,.remarks th.red,.ack th.red,.sig-table th.red,.pm th.red{
  background:var(--red)!important;
  background-color:var(--red)!important;
  color:#fff!important;
  font-family:var(--font-main)!important;
}
.toolbar{font-family:var(--font-main)!important;background:#fff!important;border-bottom:1px solid #bbb!important;}
.toolbar button,.toolbar a,.btn-primary-3s{background:var(--red)!important;color:#fff!important;border-color:var(--red-dark)!important;font-family:var(--font-main)!important;}
.toolbar button:hover,.toolbar a:hover,.btn-primary-3s:hover{background:var(--red-dark)!important;color:#fff!important;}
.toolbar .dark,.btn-dark-3s{background:#333!important;color:#fff!important;}
th,td,input,textarea,select,button{font-family:var(--font-main)!important;}
th,td{border-color:var(--border)!important;}
input[type="checkbox"]{accent-color:var(--red)!important;}

/* Undertaking Form - balanced on one A4 */
.undertaking-form .page,.undertaking-page{
  padding:5mm 8mm 25mm 8mm!important;
}
.undertaking-page .official-header{
  height:30mm!important;
  margin-bottom:1.8mm!important;
}
.undertaking-page .official-header img{
  width:100%!important;
  height:30mm!important;
  max-height:30mm!important;
}
.undertaking-page .form-code{
  font-size:10px!important;
  line-height:1!important;
  margin:0 8px 1mm!important;
  border-bottom:1px solid #555!important;
}
.undertaking-page .main-title{
  font-size:15px!important;
  line-height:1.05!important;
  padding:3px 8px!important;
  margin:0 8px!important;
}
.undertaking-page .main-title .ar{font-size:15px!important;}
.undertaking-page .details-table td,.undertaking-page .details-table th{
  height:22px!important;
  padding:2px 5px!important;
  font-size:10px!important;
  line-height:1.05!important;
}
.undertaking-page .details-table .label{font-size:10.5px!important;}
.undertaking-page .details-table .ar{font-size:10.5px!important;}
.undertaking-page .section-title{
  font-size:12px!important;
  line-height:1.05!important;
  padding:2px 8px!important;
  margin:4px 8px 0!important;
}
.undertaking-page .asset-table td,.undertaking-page .asset-table th{
  height:22px!important;
  padding:2px 5px!important;
  font-size:10px!important;
  line-height:1.05!important;
}
.undertaking-page .undertaking-lines{
  margin:5px 8px 6px!important;
}
.undertaking-page .undertaking-lines .line{
  gap:14px!important;
  margin-bottom:4px!important;
}
.undertaking-page .undertaking-lines .en,.undertaking-page .undertaking-lines .ar{
  font-size:10.2px!important;
  line-height:1.18!important;
}
.undertaking-page .sign-table{margin-top:7px!important;}
.undertaking-page .sign-table td{height:23px!important;}
.undertaking-page .sign-table .red-label{
  font-size:11px!important;
  line-height:1.05!important;
}
.undertaking-page .notice-row{
  margin:9px 12px 0!important;
  font-size:10.5px!important;
  line-height:1.15!important;
}
.undertaking-page .undertaking-footer,.undertaking-page .brand-footer{
  position:absolute!important;
  left:8mm!important;
  right:8mm!important;
  bottom:7mm!important;
  height:18mm!important;
  max-height:18mm!important;
}
.undertaking-page .undertaking-footer img,.undertaking-page .brand-footer img{
  height:18mm!important;
  max-height:18mm!important;
  object-fit:contain!important;
}
.undertaking-page .footer-date{display:none!important;}

/* Vehicle form - bigger readable content while keeping one page */
.vehicle-form .page,.vehicle-page{
  padding:4mm 5mm 25mm 5mm!important;
}
.vehicle-page .brand-header{
  height:30mm!important;
  margin-bottom:1.5mm!important;
}
.vehicle-page .brand-header img{
  height:30mm!important;
  max-height:30mm!important;
}
.vehicle-page .code{font-size:8px!important;margin-bottom:1px!important;}
.vehicle-page .topline{margin:1px 0 2px!important;}
.vehicle-page .title-en{font-size:12.5px!important;line-height:1!important;margin-bottom:1px!important;}
.vehicle-page .title-ar{font-size:12.5px!important;line-height:1!important;margin-bottom:1px!important;}
.vehicle-page .rev-row{font-size:8px!important;margin-bottom:3px!important;}
.vehicle-page .vehicle-info th{height:21px!important;font-size:8.5px!important;}
.vehicle-page .vehicle-info td{height:16px!important;}
.vehicle-page .acc-title{height:16px!important;font-size:8.5px!important;}
.vehicle-page .accessories td{height:13px!important;}
.vehicle-page .accessories .item{font-size:7.2px!important;line-height:1.05!important;}
.vehicle-page .accessories .item .ar{font-size:7.2px!important;}
.vehicle-page .remarks{margin-top:3px!important;}
.vehicle-page .remarks th{height:17px!important;font-size:8.4px!important;}
.vehicle-page .remarks td{height:112px!important;}
.vehicle-page .body-box{height:108px!important;}
.vehicle-page .vehicle-diagram-wrap{height:96px!important;}
.vehicle-page .ack{margin-top:3px!important;}
.vehicle-page .ack th{height:17px!important;font-size:8.3px!important;}
.vehicle-page .ack td{height:17px!important;}
.vehicle-page .ack .en{font-size:6.45px!important;line-height:1.05!important;}
.vehicle-page .ack .ar{font-size:7.3px!important;line-height:1.05!important;}
.vehicle-page .signatures{gap:5mm!important;margin-top:3px!important;}
.vehicle-page .sig-table th{height:16px!important;font-size:8.5px!important;}
.vehicle-page .sig-table td{height:12.5px!important;}
.vehicle-page .pm{margin-top:3px!important;}
.vehicle-page .pm-title{height:16px!important;font-size:7.8px!important;}
.vehicle-page .pm-sub{height:15px!important;font-size:7.8px!important;}
.vehicle-page .pm td{height:15px!important;}
.vehicle-page .pm .approval-en,.vehicle-page .pm .remarks-en{font-size:6.5px!important;line-height:1.05!important;}
.vehicle-page .pm .approval-ar,.vehicle-page .pm .remarks-ar{font-size:7px!important;line-height:1.05!important;}
.vehicle-page .brand-footer{
  position:absolute!important;
  left:7mm!important;
  right:7mm!important;
  bottom:7mm!important;
  height:18mm!important;
}
.vehicle-page .brand-footer img{height:18mm!important;}

/* Accommodation report - same page size/frame and consistent footer */
.accommodation-form .page,.accommodation-page{
  padding:5mm 8mm 25mm 8mm!important;
  background:#fff!important;
}
.accommodation-page .header-logo{
  height:30mm!important;
  max-height:30mm!important;
  object-fit:contain!important;
  margin-bottom:2mm!important;
}
.accommodation-page .top-line{margin:1mm 0 1mm!important;}
.accommodation-page .title-bar{
  font-size:10px!important;
  padding:4px 10px!important;
  margin:1mm auto 1mm!important;
}
.accommodation-page .title-ar{font-size:10px!important;margin-bottom:2mm!important;}
.accommodation-page table{font-size:9px!important;}
.accommodation-page th,.accommodation-page td{padding:1px 3px!important;}
.accommodation-page .footer{
  position:absolute!important;
  left:8mm!important;
  right:8mm!important;
  bottom:7mm!important;
  height:18mm!important;
  max-height:18mm!important;
  min-height:18mm!important;
  padding-top:2px!important;
  display:grid!important;
  grid-template-columns:1.25fr .8fr 1.1fr!important;
  gap:10px!important;
  align-items:center!important;
  font-size:7px!important;
  line-height:1!important;
  border-top:1px solid #555!important;
}
.accommodation-page .footer .center-col{
  min-height:15mm!important;
  height:15mm!important;
  padding:0 8px!important;
}
.accommodation-page .footer strong{font-size:8px!important;}
.accommodation-page .page-no{
  position:absolute!important;
  left:0!important;
  right:0!important;
  bottom:27mm!important;
  margin:0!important;
  font-size:9px!important;
}

/* Master template */
.master-form .page,.master-page{
  padding:5mm 8mm 25mm 8mm!important;
}
.master-page .brand-footer{
  position:absolute!important;
  left:8mm!important;
  right:8mm!important;
  bottom:7mm!important;
  height:18mm!important;
}

/* Print exact A4 */
@media print{
  html,body{
    width:210mm!important;
    min-height:297mm!important;
    background:#fff!important;
  }
  .toolbar,.modal-backdrop,.no-print,.signature-remove{
    display:none!important;
  }
  .page,.page-sheet,.form-sheet{
    width:210mm!important;
    height:297mm!important;
    min-height:297mm!important;
    max-height:297mm!important;
    margin:0!important;
    box-shadow:none!important;
    background:#fff!important;
    page-break-after:always!important;
  }
  .page:last-of-type{page-break-after:auto!important;}
  @page{size:A4 portrait;margin:0;}
}
