html{font-size:62.5%;}
body{
  margin:0;
  background:#fff;
  color:#111827;
  font-family:system-ui,-apple-system,"Segoe UI",Roboto,"Noto Sans JP","Yu Gothic",Meiryo,sans-serif;
  font-size:16px;
}
.ci-wrap{
  width:clamp(320px, 96vw, 1500px);
  margin:20px auto 50px;
  padding:18px 20px 30px;
  box-sizing:border-box;
}
.ci-nav{margin:0 0 18px;font-size:14px;}
.ci-nav a{color:#005bac;text-decoration:none;}
.ci-nav a:hover{text-decoration:underline;}
.ci-wrap h1{margin:0 0 18px;font-size:26px;line-height:1.4;font-weight:700;}
.ci-table-meta{
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  gap:4px;
  margin:0 0 10px;
}
.ci-table-year-form,
.ci-chart-target-form{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:8px;
  margin:0;
}
.ci-table-unit{
  font-size:13px;
  line-height:1.4;
  white-space:nowrap;
  color:#333;
}
.ci-chart-target-form{justify-content:center;margin:22px 0 14px;}
.ci-table-year-form label,
.ci-chart-target-form label{font-weight:700;}
.ci-table-year-form select,
.ci-chart-target-form select{
  min-width:100px;
  padding:5px 8px;
  border:1px solid #9ca3af;
  background:#fff;
  font-size:15px;
}
.ci-matrix-scroll{
  width:100%;
  border:0;
  overflow-x:scroll;
  overflow-y:hidden;
  -webkit-overflow-scrolling:touch;
  scrollbar-gutter:stable;
}
.ci-matrix-table{
  min-width:2150px;
  width:max-content;
  border:1px solid #b7c2c9;
  border-collapse:collapse;
  table-layout:auto;
  background:#fff;
}
.ci-matrix-table th,
.ci-matrix-table td{
  border:1px solid #b7c2c9;
  padding:7px 8px;
  min-width:86px;
  text-align:right;
  white-space:nowrap;
  font-size:13px;
}
.ci-matrix-table thead th{
  background:#2f879e;
  color:#fff;
  text-align:center;
  font-weight:700;
}
.ci-matrix-table thead tr:first-child th:not(.ci-country-head){
  min-width:172px;
  white-space:normal;
  line-height:1.35;
}
.ci-matrix-table thead th small{display:block;font-size:11px;font-weight:400;margin-top:2px;}

.ci-matrix-table thead th .ci-hs-code{
  margin-top:3px;
  line-height:1.25;
  white-space:normal;
}
.ci-matrix-table tbody th{
  position:sticky;
  left:0;
  z-index:2;
  background:#d8edf2;
  color:#1f2937;
  text-align:center;
  font-weight:700;
}
.ci-matrix-table tbody tr:nth-child(even) td{background:#f8fbfc;}
.ci-matrix-table .ci-country-head{
  position:sticky;
  left:0;
  z-index:4;
  width:100px;
  min-width:100px;
}
.ci-matrix-table .ci-other-row th,
.ci-matrix-table .ci-other-row td{background:#f1f5f9;}
.ci-note{margin:8px 0 0;font-size:13px;color:#555;}
.ci-chart-remarks{margin-top:30px;text-align:right;}
.ci-source{margin-top:18px;text-align:right;color:#666;font-size:13px;line-height:1.6;}
@media(max-width:760px){
  .ci-wrap{width:100%;margin:0;padding:14px 10px 30px;}
  .ci-wrap h1{font-size:20px;}
  .ci-table-year-form{justify-content:flex-start;}
  .ci-chart-target-form{justify-content:flex-start;flex-wrap:wrap;}
  .ci-matrix-table th,.ci-matrix-table td{font-size:12px;padding:6px;}
  .ci-matrix-scroll{margin-bottom:8px;}
}

/* 表印刷 */
.ci-table-actions{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:10px;
  width:100%;
}
.ci-print-btn{
  appearance:none;
  border:1px solid #256f82;
  background:#2f879e;
  color:#fff;
  padding:6px 14px;
  border-radius:2px;
  font-size:14px;
  font-weight:700;
  line-height:1.4;
  cursor:pointer;
}
.ci-print-btn:hover{background:#256f82;}
.ci-print-guide{
  display:flex;
  align-items:flex-start;
  justify-content:flex-start;
  gap:14px;
  margin:10px 0 18px;
  text-align:left;
}
.ci-print-guide .ci-print-btn{
  flex:0 0 auto;
  margin:0;
}
.ci-print-guide p{
  margin:0;
  color:#333;
  font-size:13px;
  line-height:1.75;
}
.ci-print-year{display:none;}

@media(max-width:760px){
  .ci-table-actions{justify-content:flex-start;flex-wrap:wrap;}
  .ci-print-guide{display:block;}
  .ci-print-guide p{margin-top:8px;}
}

@media print{
  @page{
    size:A4 landscape;
    margin:8mm;
  }

  html,body{
    width:auto!important;
    margin:0!important;
    padding:0!important;
    background:#fff!important;
  }

  .ci-wrap{
    width:100%!important;
    max-width:none!important;
    margin:0!important;
    padding:0!important;
  }

  .ci-nav,
  .ci-table-year-form,
  .ci-print-btn,
  .ci-print-guide,
  .ci-chart-remarks,
  .ci-chart-target-form,
  .charts-row,
  .ci-note,
  .ci-source{
    display:none!important;
  }

  .ci-wrap h1{
    margin:0 0 3mm!important;
    font-size:14pt!important;
    line-height:1.25!important;
  }

  .ci-table-meta{
    display:block!important;
    margin:0 0 2mm!important;
    text-align:right!important;
  }

  .ci-table-actions{display:none!important;}
  .ci-print-year{
    display:block!important;
    margin:0 0 .8mm!important;
    font-size:8pt!important;
    line-height:1.2!important;
  }
  .ci-table-unit{
    font-size:7.5pt!important;
    line-height:1.2!important;
  }

  .ci-matrix-scroll{
    width:100%!important;
    overflow:visible!important;
    border:0!important;
    margin:0!important;
  }

  .ci-matrix-table{
    width:100%!important;
    min-width:0!important;
    table-layout:fixed!important;
    border-collapse:collapse!important;
    page-break-inside:avoid;
  }

  .ci-matrix-table th,
  .ci-matrix-table td{
    min-width:0!important;
    padding:.9mm .35mm!important;
    font-size:5pt!important;
    line-height:1.15!important;
    white-space:nowrap!important;
  }

  .ci-matrix-table thead th{
    white-space:normal!important;
  }

  .ci-matrix-table thead tr:first-child th:not(.ci-country-head){
    min-width:0!important;
    line-height:1.15!important;
  }

  .ci-matrix-table thead th small,
  .ci-matrix-table thead th .ci-hs-code{
    font-size:4.5pt!important;
    line-height:1.1!important;
    margin-top:.4mm!important;
  }

  .ci-matrix-table .ci-country-head,
  .ci-matrix-table tbody th{
    position:static!important;
    left:auto!important;
  }

  .ci-matrix-table .ci-country-head{
    width:17mm!important;
    min-width:17mm!important;
  }

  *{
    -webkit-print-color-adjust:exact!important;
    print-color-adjust:exact!important;
  }
}

/* print01.php に近い「ブラウザ印刷」レイアウト */
.ci-print-footer{margin-top:18px;}
.ci-print-period{display:none;}

@media print{
  @page{
    size:A4 landscape;
    margin:9mm 6mm 9mm 10mm;
  }

  html,body{
    margin:0!important;
    padding:0!important;
    width:auto!important;
    background:#fff!important;
    color:#000!important;
  }

  body{
    font-family:"Yu Gothic",Meiryo,sans-serif!important;
  }

  .ci-wrap{
    width:100%!important;
    max-width:none!important;
    margin:0!important;
    padding:0!important;
  }

  /* 印刷不要部分 */
  .ci-nav,
  .ci-table-year-form,
  .ci-print-btn,
  .ci-print-guide,
  .ci-chart-remarks,
  .ci-chart-target-form,
  .charts-row{
    display:none!important;
  }

  /* 見本同様、タイトルを左上へ */
  .ci-wrap h1{
    display:block!important;
    margin:0 0 4mm!important;
    padding:0!important;
    color:#000!important;
    font-size:14pt!important;
    font-weight:700!important;
    line-height:1.2!important;
    text-align:left!important;
  }

  /* 表示年と単位は表の外、右上に固定 */
  .ci-table-meta{
    display:block!important;
    width:100%!important;
    margin:0 0 1.5mm!important;
    padding:0!important;
    text-align:right!important;
  }
  .ci-table-actions{display:none!important;}
  .ci-print-year,
  .ci-table-unit{
    display:block!important;
    margin:0!important;
    padding:0!important;
    color:#000!important;
    font-size:7.5pt!important;
    line-height:1.25!important;
    white-space:nowrap!important;
  }

  /* 横スクロール枠は印刷時だけ解除 */
  .ci-matrix-scroll,
  .table-scroll-wrap{
    display:block!important;
    width:100%!important;
    max-width:none!important;
    height:auto!important;
    max-height:none!important;
    margin:0!important;
    padding:0!important;
    overflow:visible!important;
    border:0!important;
    scrollbar-width:none!important;
  }
  .ci-matrix-scroll::-webkit-scrollbar,
  .table-scroll-wrap::-webkit-scrollbar{
    display:none!important;
    width:0!important;
    height:0!important;
  }

  /* A4横の印字可能領域へ表全体を収める */
  .ci-matrix-table{
    width:100%!important;
    min-width:0!important;
    max-width:none!important;
    margin:0!important;
    border:1px solid #555!important;
    border-collapse:collapse!important;
    border-spacing:0!important;
    table-layout:fixed!important;
    page-break-inside:avoid!important;
    break-inside:avoid!important;
    background:#fff!important;
  }

  .ci-matrix-table th,
  .ci-matrix-table td{
    min-width:0!important;
    height:auto!important;
    padding:.65mm .25mm!important;
    border:1px solid #777!important;
    background:#fff!important;
    color:#000!important;
    font-size:4.8pt!important;
    font-weight:400!important;
    line-height:1.08!important;
    text-align:right!important;
    white-space:nowrap!important;
    overflow:hidden!important;
  }

  .ci-matrix-table thead th{
    background:#fff!important;
    color:#000!important;
    font-weight:700!important;
    text-align:center!important;
    white-space:normal!important;
    overflow:visible!important;
  }

  .ci-matrix-table thead tr:first-child th:not(.ci-country-head){
    min-width:0!important;
    line-height:1.05!important;
  }

  .ci-matrix-table thead th small,
  .ci-matrix-table thead th .ci-hs-code{
    display:block!important;
    margin-top:.25mm!important;
    color:#000!important;
    font-size:4.1pt!important;
    font-weight:400!important;
    line-height:1.05!important;
    white-space:normal!important;
  }

  .ci-matrix-table .ci-country-head,
  .ci-matrix-table tbody th{
    position:static!important;
    left:auto!important;
    z-index:auto!important;
    background:#fff!important;
    color:#000!important;
    text-align:center!important;
    font-weight:700!important;
  }

  .ci-matrix-table .ci-country-head{
    width:14mm!important;
    min-width:14mm!important;
  }

  .ci-matrix-table tbody tr:nth-child(even) td,
  .ci-matrix-table .ci-other-row th,
  .ci-matrix-table .ci-other-row td{
    background:#fff!important;
  }

  /* 表の下：集計期間を左、出所を右へ */
  .ci-note{display:none!important;}
  .ci-print-footer{
    display:flex!important;
    justify-content:space-between!important;
    align-items:flex-start!important;
    gap:8mm!important;
    width:100%!important;
    margin:2.5mm 0 0!important;
    padding:0!important;
    color:#000!important;
    page-break-inside:avoid!important;
  }
  .ci-print-period{
    display:block!important;
    flex:1 1 auto!important;
    margin:0!important;
    padding:0!important;
    color:#000!important;
    font-size:7pt!important;
    line-height:1.3!important;
    text-align:left!important;
  }
  .ci-source{
    display:block!important;
    flex:0 0 auto!important;
    margin:0!important;
    padding:0!important;
    color:#000!important;
    font-size:8pt!important;
    line-height:1.4!important;
    text-align:right!important;
    white-space:nowrap!important;
  }

  *{
    -webkit-print-color-adjust:exact!important;
    print-color-adjust:exact!important;
  }
}

/* 印刷時：表の右端がプリンタ／ブラウザの丸めで破線状に見えるのを防止 */
@media print{
  .ci-matrix-table tr > th:last-child,
  .ci-matrix-table tr > td:last-child{
    border-right:0.35mm solid #555!important;
  }
}

/* 印刷時の右外枠対策：border-collapse の外周線が印刷領域端で半分クリップされるのを避ける。
   border ではなく、表の内側に塗りつぶし線を重ねて安定して描画する。 */
@media print{
  .ci-matrix-scroll{
    position:relative!important;
    box-sizing:border-box!important;
  }
  .ci-matrix-scroll::after{
    content:"";
    position:absolute;
    top:0;
    right:.20mm;
    bottom:0;
    width:.35mm;
    background:#555!important;
    z-index:20;
    pointer-events:none;
    -webkit-print-color-adjust:exact!important;
    print-color-adjust:exact!important;
  }
}
