/* v16 layout refinements: grouped NCR row on desktop + A4 landscape executive print layout. */

/* SCREEN / DESKTOP
   Row 1 = the six operational KPIs.
   Row 2 = all five NCR KPIs together on one line. */
@media screen and (min-width:1100px){
  .stats-grid{
    display:grid!important;
    grid-template-columns:repeat(30,minmax(0,1fr))!important;
    grid-auto-flow:row!important;
    gap:9px!important;
  }
  .stats-grid>.stat-card{min-width:0!important;}
  .stats-grid>.stat-card:nth-child(-n+6){grid-column:span 5!important;}
  .stats-grid>.stat-card:nth-child(n+7){grid-column:span 6!important;}
}

/* PRINT / PDF
   A4 landscape.
   Header + all KPI cards at the top.
   Lower area is three side-by-side columns:
   Projects | Contractor scoring | Areas of Concern and Improvement. */
@page{size:A4 landscape;margin:4mm}
@media print{
  *{-webkit-print-color-adjust:exact!important;print-color-adjust:exact!important;animation:none!important;transition:none!important;box-shadow:none!important}
  html,body{width:100%!important;height:100%!important;margin:0!important;padding:0!important;background:#fff!important;color:#102f53!important;overflow:hidden!important}
  body{font-size:7pt!important}
  .project-modal,.tabs,footer,.topbar-actions{display:none!important}

  .app-shell{
    width:289mm!important;
    height:202mm!important;
    max-width:none!important;
    min-height:0!important;
    margin:0!important;
    padding:0!important;
    display:grid!important;
    grid-template-rows:11mm 40mm 147mm!important;
    gap:2mm!important;
    overflow:hidden!important;
  }

  /* Report header */
  .hero-panel{
    width:289mm!important;
    height:11mm!important;
    min-height:11mm!important;
    margin:0!important;
    padding:1.8mm 3mm!important;
    display:flex!important;
    align-items:center!important;
    border-radius:1.4mm!important;
    border-left-width:3px!important;
  }
  .hero-copy{width:100%!important;max-width:none!important}
  .hero-panel h1{font-size:16pt!important;line-height:1!important;margin:0!important;letter-spacing:-.025em!important}
  .hero-panel .eyebrow,.hero-panel .subtitle{display:none!important}

  /* KPI zone: 6 operational cards on row one, 5 NCR cards on row two. */
  .stats-grid{
    width:289mm!important;
    height:40mm!important;
    min-height:40mm!important;
    margin:0!important;
    display:grid!important;
    grid-template-columns:repeat(30,minmax(0,1fr))!important;
    grid-template-rows:repeat(2,minmax(0,1fr))!important;
    grid-auto-flow:row!important;
    gap:1mm!important;
    align-items:stretch!important;
    overflow:hidden!important;
  }
  .stats-grid>.stat-card{
    min-width:0!important;
    min-height:0!important;
    height:auto!important;
    margin:0!important;
    padding:1.25mm 1.4mm!important;
    border-radius:1.2mm!important;
    border-top-width:2px!important;
    display:flex!important;
    flex-direction:column!important;
    justify-content:flex-start!important;
    overflow:hidden!important;
  }
  .stats-grid>.stat-card:nth-child(-n+6){grid-column:span 5!important;}
  .stats-grid>.stat-card:nth-child(n+7){grid-column:span 6!important;}
  .stat-top{gap:.7mm!important;min-height:3.3mm!important;align-items:flex-start!important}
  .stat-label{font-size:6.5pt!important;line-height:1.05!important;font-weight:850!important;white-space:normal!important;overflow:visible!important;text-overflow:clip!important}
  .stat-marker{width:1.25mm!important;height:1.25mm!important;flex:0 0 auto!important;margin-top:.2mm!important}
  .stat-main{margin:.4mm 0 .45mm!important;gap:.6mm!important;align-items:flex-end!important;min-height:4mm!important}
  .stat-main .stat-value,.stat-value{font-size:12.8pt!important;line-height:.95!important;font-weight:900!important;margin:0!important;letter-spacing:-.03em!important}
  .stat-main .stat-foot,.stat-foot{font-size:4.8pt!important;line-height:1.08!important;max-width:48%!important;text-align:right!important}
  .stat-breakdown{grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:.4mm!important;margin-top:auto!important;padding-top:.45mm!important}
  .stat-project{padding:.42mm .5mm!important;border-radius:.6mm!important;min-width:0!important}
  .stat-project span{font-size:4pt!important;line-height:1.05!important;margin-bottom:.08mm!important}
  .stat-project strong{font-size:5.6pt!important;line-height:1!important}

  /* Flatten the two screen tabs into one three-column report row. */
  main{
    width:289mm!important;
    height:147mm!important;
    min-height:147mm!important;
    margin:0!important;
    padding:0!important;
    display:grid!important;
    grid-template-columns:minmax(0,1.28fr) minmax(0,.78fr) minmax(0,.94fr)!important;
    grid-template-rows:147mm!important;
    gap:1.5mm!important;
    align-items:stretch!important;
    overflow:hidden!important;
  }
  #tab-overview,#tab-contractors{display:contents!important;}
  .report-page-overview>.section-heading,.report-page-contractors>.section-heading,.print-page-heading{display:none!important}
  .contractor-layout{display:contents!important;}

  /* Column 1: Projects */
  .project-pulse-shell{
    grid-column:1!important;
    grid-row:1!important;
    width:auto!important;
    height:147mm!important;
    min-height:147mm!important;
    margin:0!important;
    padding:1.6mm!important;
    display:flex!important;
    flex-direction:column!important;
    border-radius:1.3mm!important;
    overflow:hidden!important;
  }
  .pulse-heading{margin-bottom:.8mm!important;flex:0 0 auto!important}
  .pulse-heading h3{font-size:9.4pt!important;line-height:1!important;margin:0!important}
  .pulse-heading p{font-size:5.2pt!important;line-height:1.12!important;margin:.3mm 0 0!important}
  .project-pulse{
    display:grid!important;
    grid-template-columns:1fr!important;
    grid-template-rows:repeat(3,minmax(0,1fr))!important;
    gap:.85mm!important;
    flex:1!important;
    min-height:0!important;
    align-items:stretch!important;
  }
  .pulse-card{
    height:100%!important;
    min-height:0!important;
    margin:0!important;
    padding:1.15mm!important;
    border-radius:1.05mm!important;
    border-top-width:2px!important;
    display:flex!important;
    flex-direction:column!important;
    transform:none!important;
    overflow:hidden!important;
  }
  .pulse-title{margin-bottom:.45mm!important;gap:.6mm!important}
  .pulse-project-name{font-size:8.2pt!important;line-height:1!important;font-weight:900!important}
  .score-pill{font-size:5pt!important;padding:.4mm .65mm!important;border-radius:.7mm!important}
  .pulse-section-label{font-size:4.7pt!important;margin:.5mm 0 .3mm!important;letter-spacing:.05em!important}
  .pulse-section-label::before{width:.8mm!important;height:.8mm!important}
  .delivery-list{gap:.35mm!important}
  .delivery-row{padding:.48mm .6mm!important;border-radius:.65mm!important}
  .delivery-head{gap:.35mm!important;margin-bottom:.22mm!important}
  .delivery-label{font-size:5.35pt!important;font-weight:850!important}
  .delivery-count{font-size:4.55pt!important}
  .delivery-rate{font-size:5.3pt!important;font-weight:900!important}
  .metric-track{height:.65mm!important}
  .pulse-count-grid{grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:.35mm!important}
  .pulse-metric{padding:.42mm .45mm!important;border-radius:.6mm!important;min-width:0!important}
  .pulse-metric span{font-size:4pt!important;line-height:1.02!important;margin-bottom:.1mm!important}
  .pulse-metric strong{font-size:5.7pt!important;line-height:1!important}
  .quality-summary{padding:.55mm!important;border-radius:.65mm!important;margin-top:auto!important}
  .ncr-title{font-size:5.2pt!important}.ncr-detail{font-size:4.35pt!important}.ncr-rate,.sla-rate{font-size:6.3pt!important;font-weight:900!important}.sla-label{font-size:4.7pt!important}.ncr-stack,.sla-track{height:.7mm!important}.ncr-stack{margin:.28mm 0 .35mm!important}

  /* Column 2: Contractor scoring */
  .contractor-card{
    grid-column:2!important;
    grid-row:1!important;
    width:auto!important;
    height:147mm!important;
    min-height:147mm!important;
    margin:0!important;
    padding:1.5mm!important;
    border-radius:1.3mm!important;
    display:flex!important;
    flex-direction:column!important;
    overflow:hidden!important;
  }
  .contractor-card .card-heading{margin-bottom:.8mm!important;flex:0 0 auto!important}
  .contractor-card .card-heading h3{font-size:9pt!important;line-height:1.05!important;margin:0!important}
  .contractor-card .card-heading p{font-size:5.2pt!important;line-height:1.1!important;margin-top:.25mm!important}
  .contractor-card .mini-tag{display:none!important}
  .accordion-list{
    flex:1!important;
    min-height:0!important;
    display:grid!important;
    grid-auto-rows:1fr!important;
    gap:.7mm!important;
    overflow:hidden!important;
  }
  .contractor-flat-row{
    height:100%!important;
    min-height:0!important;
    grid-template-columns:minmax(20mm,.85fr) minmax(0,1.5fr) 10mm!important;
    gap:.75mm!important;
    padding:.75mm .9mm!important;
    border-left-width:2px!important;
    border-radius:.8mm!important;
    align-items:center!important;
    break-inside:avoid!important;
  }
  .contractor-flat-name{font-size:6.7pt!important;font-weight:900!important}
  .contractor-flat-rate{font-size:6.4pt!important;font-weight:900!important}
  .contractor-flat-bar{height:1mm!important}

  /* Column 3: Areas of Concern and Improvement */
  .quality-card{
    grid-column:3!important;
    grid-row:1!important;
    width:auto!important;
    height:147mm!important;
    min-height:147mm!important;
    margin:0!important;
    padding:1.5mm!important;
    border-radius:1.3mm!important;
    display:flex!important;
    flex-direction:column!important;
    overflow:hidden!important;
  }
  .quality-card .card-heading{margin-bottom:.8mm!important;flex:0 0 auto!important}
  .quality-card .card-heading h3{font-size:8.8pt!important;line-height:1.05!important;margin:0!important}
  .quality-card .card-heading p{font-size:5.1pt!important;line-height:1.1!important;margin-top:.25mm!important}
  .quality-card .mini-tag{display:none!important}
  .quality-groups{
    flex:1!important;
    min-height:0!important;
    display:grid!important;
    grid-auto-rows:1fr!important;
    gap:.75mm!important;
    overflow:hidden!important;
  }
  .quality-group{
    height:100%!important;
    min-height:0!important;
    padding:.85mm 1mm!important;
    border-radius:.8mm!important;
    border-left-width:2px!important;
    display:flex!important;
    flex-direction:column!important;
    overflow:hidden!important;
    break-inside:avoid!important;
  }
  .quality-group-head{margin-bottom:.35mm!important;flex:0 0 auto!important}
  .quality-group-head strong{font-size:6.7pt!important;line-height:1!important}
  .count-badge{font-size:4.8pt!important;padding:.35mm .55mm!important}
  .quality-item{
    flex:1 1 auto!important;
    display:flex!important;
    align-items:center!important;
    padding:.35mm 0!important;
    font-size:5.7pt!important;
    line-height:1.08!important;
    min-height:0!important;
  }
}
