/* =========================================================
  table.css
  - Grid表：入院基本料（看護配置） .tch-nursing-table
  - Grid表：施設基準・届出一覧     section.tch-facility-grid
  - Grid表：料金表（居住区分列なし） .tch-room-grid2
  - Grid表：お問い合わせ・ご相談窓口（PC表 + SPカード）
    section.tch-consultation-grid
========================================================= */

/* =========================================================
  病院概要・地域医療支援病院 表用
  - 横幅100%
  - 左列を見出し幅で固定
========================================================= */

.tch-table-full table{
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

/* 左列（項目名） */
.tch-table-full table td:first-child,
.tch-table-full table th:first-child{
  width: 28%;
  min-width: 10em;
  font-weight: 600;
  white-space: nowrap;
}

/* 右列（内容） */
.tch-table-full table td:last-child,
.tch-table-full table th:last-child{
  width: auto;
}



/* =========================================================
  0) 共通トークン（必要最小限）
========================================================= */
:root{
  --tch-border: rgba(0,0,0,.12);
  --tch-border-soft: rgba(0,0,0,.08);
  --tch-bg: #fff;
  --tch-muted: rgba(0,0,0,.65);
  --tch-link: #1f5aa6;
}


/* =========================================================
  1) 入院基本料：看護配置専用 Gridテーブル
  対象：.tch-nursing-table のみ
  - PC：全セル 縦横中央
  - SP：カード（左寄せ）
========================================================= */
.tch-nursing-table{
  margin: 20px 0 32px;
  border: 1px solid var(--tch-border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--tch-bg);
  font-size: 15px;
}

/* ヘッダー */
.tch-nursing-table__head{
  display: grid;
  grid-template-columns: 1.2fr 2.2fr 1fr 1fr 1fr 1fr;
  background: rgba(0,0,0,.04);
  font-weight: 700;
}
.tch-nursing-table__th{
  padding: 10px 12px;
  border-left: 1px solid var(--tch-border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.tch-nursing-table__th:first-child{ border-left: none; }

/* グループ（3行想定） */
.tch-nursing-table__group{
  display: grid;
  grid-template-columns: 1.2fr 2.2fr 1fr 1fr 1fr 1fr;
  grid-auto-rows: minmax(44px, auto);
  border-top: 1px solid var(--tch-border);
}

.tch-nursing-table__cell{
  padding: 10px 12px;
  border-left: 1px solid var(--tch-border-soft);
  border-top: 1px solid var(--tch-border-soft);
  line-height: 1.6;

  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* 病棟（1列目）だけ左罫線を消す */
.tch-nursing-table__group > .tch-nursing-table__cell[data-label="病棟"]{
  border-left: none;
}

/* 疑似セル結合（3行分） */
.tch-nursing-table__cell--span{
  grid-row: span 3;
  font-weight: 600;
  background: rgba(0,0,0,.015);
}

/* SP：カード */
@media (max-width: 780px){
  .tch-nursing-table__head{ display: none; }

  .tch-nursing-table__group{
    grid-template-columns: 1fr;
    padding: 10px 12px;
  }

  .tch-nursing-table__cell{
    border: none;
    padding: 6px 0;

    display: grid;
    grid-template-columns: 9.5em 1fr;
    gap: 10px;
    align-items: start;
    text-align: left;
    justify-content: start;
  }

  .tch-nursing-table__cell::before{
    content: attr(data-label);
    font-weight: 700;
    opacity: .85;
  }

  .tch-nursing-table__cell--span{
    grid-row: auto;
    background: transparent;
  }
}


/* =========================================================
  2) 施設基準・届出一覧（グリッド表）
  対象：section.tch-facility-grid のみ
========================================================= */
section.tch-facility-grid{
  margin: 24px 0;
  --fg-border: var(--tch-border);
  --fg-bg: var(--tch-bg);
  --fg-muted: var(--tch-muted);
}

/* バー */
section.tch-facility-grid .tch-facility-grid__bar{
  display: flex;
  gap: 12px;
  align-items: flex-end;
  justify-content: space-between;
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--fg-border);
  background: var(--fg-bg);
}
section.tch-facility-grid .tch-facility-grid__title{
  margin: 0;
  font-size: 18px;
  line-height: 1.4;
}
section.tch-facility-grid .tch-facility-grid__note{
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--fg-muted);
  max-width: 56ch;
  text-align: right;
}
section.tch-facility-grid .tch-facility-grid__noteTitle{
  font-weight: 700;
  color: rgba(0,0,0,.78);
  margin-right: 6px;
}

/* 表 */
section.tch-facility-grid .tch-facility-grid__table{
  border: 1px solid var(--fg-border);
  background: var(--fg-bg);
}

/* ヘッダー */
section.tch-facility-grid .tch-facility-grid__head{
  display: grid;
  grid-template-columns: 280px 1fr;
  border-bottom: 1px solid var(--fg-border);
  background: rgba(0,0,0,.03);
}
section.tch-facility-grid .tch-facility-grid__th{
  padding: 12px;
  border-right: 1px solid var(--fg-border);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
section.tch-facility-grid .tch-facility-grid__head .tch-facility-grid__th:last-child{
  border-right: 0;
}

/* 行 */
section.tch-facility-grid .tch-facility-grid__row{
  display: grid;
  grid-template-columns: 280px 1fr;
  border-top: 1px solid var(--fg-border);
}
section.tch-facility-grid .tch-facility-grid__row:first-of-type{
  border-top: 0;
}

section.tch-facility-grid .tch-facility-grid__cat{
  padding: 12px;
  border-right: 1px solid var(--fg-border);
  background: rgba(30,90,170,.03);
}
section.tch-facility-grid .tch-facility-grid__items{
  padding: 12px;
}

section.tch-facility-grid .tch-facility-grid__catTitle{
  font-weight: 700;
  margin: 0 0 6px;
}
section.tch-facility-grid .tch-facility-grid__catDesc{
  font-size: 13px;
  line-height: 1.7;
  color: var(--fg-muted);
}

/* リスト（common.css 影響回避） */
section.tch-facility-grid .tch-facility-grid__items ul{
  margin: 0;
  padding-left: 1.2em;
}
section.tch-facility-grid .tch-facility-grid__items li{
  margin: 0 0 6px;
  line-height: 1.7;
}
section.tch-facility-grid .tch-facility-grid__items li:last-child{
  margin-bottom: 0;
}

/* SP */
@media (max-width: 640px){
  section.tch-facility-grid .tch-facility-grid__bar{
    flex-direction: column;
    align-items: flex-start;
  }
  section.tch-facility-grid .tch-facility-grid__note{
    text-align: left;
    max-width: none;
  }
  section.tch-facility-grid .tch-facility-grid__head{
    grid-template-columns: 1fr;
  }
  section.tch-facility-grid .tch-facility-grid__th{
    border-right: 0;
    justify-content: flex-start;
    text-align: left;
  }
  section.tch-facility-grid .tch-facility-grid__row{
    grid-template-columns: 1fr;
  }
  section.tch-facility-grid .tch-facility-grid__cat{
    border-right: 0;
    border-bottom: 1px solid var(--fg-border);
  }
}


/* =========================================================
  3) 料金表 Grid（居住区分列なし）
  対象：.tch-room-grid2
========================================================= */
.tch-room-grid2{
  margin: 24px 0;
  border: 1px solid var(--tch-border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--tch-bg);
  font-size: 15px;
}

/* ヘッダー */
.tch-room-grid2__head{
  display: grid;
  grid-template-columns: 1.2fr 1.4fr 1.5fr 2fr;
  background: #14a3ad;
  color: #fff;
  font-weight: 600;
  text-align: center;
}
.tch-room-grid2__head > div{
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid rgba(255,255,255,.35);
}
.tch-room-grid2__head > div:last-child{ border-right: none; }

/* 行 */
.tch-room-grid2__row{
  display: grid;
  grid-template-columns: 1.2fr 1.4fr 1.5fr 2fr;
}
.tch-room-grid2__row > div{
  padding: 12px;
  border-top: 1px solid rgba(0,0,0,.1);
  border-right: 1px solid var(--tch-border-soft);
  line-height: 1.7;
}
.tch-room-grid2__row > div:last-child{ border-right: none; }

/* 中央セル */
.col-type,
.col-price,
.col-ward{
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.col-type{ font-weight: 600; }

/* 料金セル内 */
.tch-price-list{
  display: grid;
  gap: 6px;
}
.tch-price-item{
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  column-gap: 10px;
  padding: 2px 0;
}
.tch-price-label,
.tch-price-amount{
  white-space: nowrap;
}
.tch-price-amount{
  font-weight: 600;
}

/* 部屋番号：PCは縦中央＋左寄せ */
.col-room{
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
}

/* SP：カード */
@media (max-width: 768px){
  .tch-room-grid2__head{ display: none; }

  .tch-room-grid2__row{
    grid-template-columns: 1fr;
    padding: 12px 14px;
    border-top: 1px solid var(--tch-border);
  }
  .tch-room-grid2__row > div{
    border: none;
    padding: 6px 0;
    text-align: left;
  }
  .col-type{
    font-size: 16px;
    margin-bottom: 6px;
  }
  .col-room{
    justify-content: center;
    text-align: center;
  }
}


/* =========================================================
  4) お問い合わせ・ご相談窓口（PC表 + SPカード）
  対象：section.tch-consultation-grid のみ

  ★改善点
  - PC：テーブル全体を1つの grid にして、
        区分セルを grid-row: span で“真の結合”にする
  - SP：従来通り 1件=カード
========================================================= */
section.tch-consultation-grid{
  margin: 24px 0;
  font-size: 15px;
}

/* バー */
section.tch-consultation-grid .tch-consultation-grid__bar{
  display: flex;
  gap: 12px;
  align-items: flex-end;
  justify-content: space-between;
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--tch-border);
  background: var(--tch-bg);
}
section.tch-consultation-grid .tch-consultation-grid__title{
  margin: 0;
  font-size: 18px;
  line-height: 1.4;
}
section.tch-consultation-grid .tch-consultation-grid__note{
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--tch-muted);
  max-width: 56ch;
  text-align: right;
}

/* 表枠 */
section.tch-consultation-grid .tch-consultation-grid__table{
  border: 1px solid var(--tch-border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--tch-bg);
}

/* リンク */
section.tch-consultation-grid a{
  color: var(--tch-link);
  text-decoration: none;
  font-weight: 600;
}
section.tch-consultation-grid a:hover,
section.tch-consultation-grid a:focus{
  text-decoration: underline;
}

/* サブ文 */
section.tch-consultation-grid .tch-consultation-grid__desk-sub,
section.tch-consultation-grid .tch-consultation-grid__tel-sub{
  color: var(--tch-muted);
  font-size: 13px;
}

/* =========================
  PC：1つのGridで表を組む（真のセル結合）
========================= */
@media (min-width: 681px){

  /* 1つのグリッドに統合 */
  section.tch-consultation-grid .tch-consultation-grid__table{
    display: grid;
    grid-template-columns: 1.2fr 1.3fr 2.4fr 1.2fr 1.4fr;
  }

  /* head / row は“枠”扱い → 中身を grid に流す */
  section.tch-consultation-grid .tch-consultation-grid__head,
  section.tch-consultation-grid .tch-consultation-grid__row{
    display: contents;
  }

  /* ヘッダーセル */
  section.tch-consultation-grid .tch-consultation-grid__th{
    padding: 12px;
    background: rgba(0,0,0,.03);
    border-right: 1px solid var(--tch-border);
    font-weight: 700;

    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }
  section.tch-consultation-grid .tch-consultation-grid__th:last-child{
    border-right: 0;
  }

  /* 本文セル */
  section.tch-consultation-grid .tch-consultation-grid__cell{
    padding: 12px;
    border-right: 1px solid var(--tch-border-soft);
    border-top: 1px solid var(--tch-border);
    line-height: 1.7;
  }
  section.tch-consultation-grid .tch-consultation-grid__cell:last-child{
    border-right: 0;
  }

  /* 指定：中央セル */
  section.tch-consultation-grid .tch-consultation-grid__cell.cell--center{
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  /* 主な内容は左寄せ */
  section.tch-consultation-grid .tch-consultation-grid__cell.cell--main{
    text-align: left;
  }

  /* 上下表示 */
  section.tch-consultation-grid .tch-consultation-grid__cell.cell--stack{
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  /* ★真の縦結合：区分セル（先頭） */
  section.tch-consultation-grid .tch-consultation-grid__cell.cell--cat-span{
    grid-row: span var(--rowspan, 1);
    /* ここが“縦中央”の本体 */
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  /* 2行目以降の“疑似結合セル”は PC では消す */
  section.tch-consultation-grid .tch-consultation-grid__cell.cell--cat-merge{
    display: none;
  }

  /* 電話/内線 折返し防止 */
  section.tch-consultation-grid .tch-consultation-grid__tel-sub{
    display: block;
    white-space: nowrap;
    margin-top: 4px;
    font-weight: 400;
  }
}


/* =========================
  SP：1窓口＝1カード（HTMLそのまま）
========================= */
@media (max-width: 680px){

  /* 表ヘッダーは非表示 */
  section.tch-consultation-grid .tch-consultation-grid__head{
    display: none;
  }

  /* 1件＝カード */
  section.tch-consultation-grid .tch-consultation-grid__row{
    display: grid;
    grid-template-areas:
      "cat desk"
      "main main"
      "tel fax";
    grid-template-columns: 1fr 1fr;

    border: 1px solid var(--tch-border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--tch-bg);
    margin: 0 0 12px;
    padding: 0;
  }

  section.tch-consultation-grid .tch-consultation-grid__cell{
    border: none;
    padding: 10px 12px;
    display: block;
    text-align: left;
    line-height: 1.7;
  }

  /* 1) 区分 */
  section.tch-consultation-grid .tch-consultation-grid__cell:nth-child(1){
    grid-area: cat;
    background: rgba(30,90,170,.03);
    font-weight: 700;

    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;

    border-right: 1px solid var(--tch-border);
  }

  /* 2) 窓口 */
  section.tch-consultation-grid .tch-consultation-grid__cell:nth-child(2){
    grid-area: desk;
    font-weight: 700;

    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  /* 3) 主な内容 */
  section.tch-consultation-grid .tch-consultation-grid__cell:nth-child(3){
    grid-area: main;
    border-top: 1px solid var(--tch-border);
  }

  /* 4) 電話 */
  section.tch-consultation-grid .tch-consultation-grid__cell:nth-child(4){
    grid-area: tel;
    border-top: 1px solid var(--tch-border);
    border-right: 1px solid var(--tch-border);
  }

  /* 5) FAX/備考 */
  section.tch-consultation-grid .tch-consultation-grid__cell:nth-child(5){
    grid-area: fax;
    border-top: 1px solid var(--tch-border);
  }

  /* ラベル */
  section.tch-consultation-grid .tch-consultation-grid__cell:nth-child(n+3)::before{
    content: attr(data-label);
    display: block;
    font-size: 12px;
    color: var(--tch-muted);
    font-weight: 700;
    margin-bottom: 4px;
    opacity: .9;
  }
  section.tch-consultation-grid .tch-consultation-grid__cell:nth-child(1)::before,
  section.tch-consultation-grid .tch-consultation-grid__cell:nth-child(2)::before{
    content: none;
  }

  section.tch-consultation-grid a{
    word-break: keep-all;
    white-space: nowrap;
  }

  /* PC用の span 設定は SP では影響させない */
  section.tch-consultation-grid .tch-consultation-grid__cell.cell--cat-span{
    grid-row: auto;
  }
}
