/* ============================================================================
 * 補助金の一覧ページ（/ai/subsidy/）だけで使う CSS（MK 2026-11-12・TODO 965）
 * 使い方: style.css → sub.css の後に読み込む。新しい見た目は作らず、
 *         会社概要の表（.company-table）・料金のカード（.plan）・お知らせのチップ（.news-chip）の形を借りる
 * 決まり: 明るい色の上に白文字を置かない／12px 未満なし／押せる場所 44px 以上／明暗の差 4.5:1 以上
 * ========================================================================== */

.sb-visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ページ上部 */
.sb-crumb { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; font-size: var(--fs-small); color: var(--ink-2); }
.sb-crumb a { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); font-weight: 700; }
.sb-crumb span { display: inline-flex; align-items: center; }
.page-hero .page-title-ja { word-break: keep-all; overflow-wrap: anywhere; }
.sb-updated { margin-top: 12px; font-size: var(--fs-small); color: var(--ink-2); }

/* 区画は下層ページより詰める（1ページに区画が多いため） */
.sb-section { padding: clamp(48px, 6vw, 72px) 0 0; }
.sb-note { max-width: 34em; margin-top: 8px; color: var(--ink-2); }
.sb-empty { margin-top: 12px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--ink-2); }
.sb-back { margin-top: 24px; }
.sb-about { margin-top: 8px; }
.sb-national a { color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 4px; }

/* 表（.company-table と同じ線の引き方） */
.sb-table-wrap { margin-top: 16px; }
.sb-table { width: 100%; border-collapse: collapse; border-top: 1px solid var(--ink); }
.sb-table th, .sb-table td { padding: 16px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; line-height: 1.75; }
.sb-table thead th { font-weight: 700; color: var(--ink-2); font-size: var(--fs-small); white-space: nowrap; }
.sb-table td { font-size: 15px; overflow-wrap: anywhere; }
.sb-table td:not(.sb-name) { width: 9.5em; min-width: 9.5em; }   /* 「2026年11月30日」が1行に収まる幅 */
.sb-title, .sb-op { overflow-wrap: anywhere; }
.sb-table .sb-name { width: auto; }
.sb-title { font-weight: 700; color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }
.sb-op, .sb-checked, .sb-fy, .sb-target { margin-top: 4px; font-size: var(--fs-small); color: var(--ink-2); line-height: 1.7; }
.sb-fy, .sb-target { color: var(--ink); font-weight: 700; }
.sb-uses { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; list-style: none; }
.sb-uses li { padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper-warm); font-size: var(--fs-small); line-height: 1.8; }
.sb-row.is-closed { background: #fafaf8; }

/* 状況の札（.news-chip と同じ形） */
.sb-status { display: inline-block; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); font-size: var(--fs-small); font-weight: 700; line-height: 1.7; white-space: nowrap; color: var(--ink); background: #fff; }
.sb-status--open { background: var(--chip-bg); border-color: var(--chip-line); }
.sb-status--closed { background: #ececea; border-color: #d6d6d2; color: #4a4e4c; }
.sb-status--unknown { color: var(--ink-2); }
.sb-status-sub { display: block; margin-top: 4px; font-size: var(--fs-small); color: var(--ink-2); }

/* 市町村 */
.sb-jump { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 16px; list-style: none; }
.sb-jump a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: var(--accent); font-weight: 700; }
.sb-count { font-size: var(--fs-small); font-weight: 500; color: var(--ink-2); }
.sb-muni { margin-top: 48px; padding-bottom: 8px; border-bottom: 1px solid var(--line); font-family: var(--font-disp); font-weight: 700; font-size: var(--fs-title); scroll-margin-top: calc(var(--hdr-h) + 16px); }

/* 県のカード（料金の .plan と同じ: 白地・枠・角丸18px） */
.sb-pref-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; margin-top: 16px; list-style: none; }
.sb-pref-card { display: flex; flex-direction: column; gap: 6px; height: 100%; padding: clamp(24px, 3vw, 36px); background: #fff; border: 1px solid var(--line); border-radius: 18px; color: var(--ink); text-decoration: none; }
.sb-pref-card:hover { background: var(--paper-warm); }
.sb-pref-name { font-family: var(--font-disp); font-weight: 700; font-size: clamp(20px, 2vw, 24px); letter-spacing: 0.04em; }
.sb-pref-count { padding-top: 12px; border-top: 1px solid var(--line); color: var(--ink-2); }
.sb-pref-more { margin-top: auto; padding-top: 8px; color: var(--accent); font-weight: 700; }
.sb-pref-more::after { content: " →"; }

/* 注意書き */
.subsidy-caution-sec { padding: clamp(48px, 6vw, 72px) 0; }
.subsidy-caution { max-width: 40em; padding: 16px 20px; border: 1px solid var(--chip-line); border-radius: 12px; background: var(--chip-bg); color: var(--ink); font-weight: 700; }

/* スマホとタブレット: 表をカードの並びにする */
@media (max-width: 1099px) { .sb-pref-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 899px) {
  .sb-pref-grid { grid-template-columns: 1fr; gap: 16px; }
  .sb-nat { padding: 18px; }
  .sb-kv { grid-template-columns: 6.5em minmax(0, 1fr); }
  .sb-table, .sb-table tbody, .sb-table tr, .sb-table td { display: block; width: auto !important; min-width: 0 !important; }
  .sb-table { border-top: 0; }
  .sb-table thead { display: none; }
  .sb-table tr { margin-top: 12px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 18px; background: #fff; }
  .sb-row.is-closed { background: #fafaf8; }
  .sb-table td { display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .sb-table td:last-child { border-bottom: 0; }
  .sb-table td::before { content: attr(data-label); font-size: var(--fs-small); font-weight: 700; color: var(--ink-2); }
  .sb-table td.sb-name { display: block; padding-top: 0; padding-right: 6px; }   /* 長い制度名が1行に収まると判定されて2pxはみ出すのを防ぐ（愛媛・実測） */
  .sb-table td.sb-name::before { content: none; }
  .sb-status-sub { display: inline; margin: 0 0 0 8px; }
}
.sb-status-wrap { display: block; }

/* ---------------------------------------------------------------- 国の制度（2026-11-12 追加） */
/* 入口の「いま受付中」で、県と国を見分ける札 */
.sb-area { display: inline-block; margin-bottom: 6px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: var(--fs-small); font-weight: 700; line-height: 1.8; color: var(--ink); }
.sb-area--nat { background: var(--chip-bg); border-color: var(--chip-line); }
.sb-name .sb-title { display: inline; }
.sb-name .sb-area + .sb-title { display: block; width: fit-content; max-width: 100%; }

/* 国の制度のカード（料金の .plan と同じ: 白地・枠・角丸18px） */
.sb-nat-list { display: grid; gap: 20px; margin-top: 16px; }
.sb-nat { padding: clamp(20px, 3vw, 32px); background: #fff; border: 1px solid var(--line); border-radius: 18px; scroll-margin-top: calc(var(--hdr-h) + 16px); }
.sb-nat.is-closed { background: #fafaf8; }
.sb-nat-title { font-family: var(--font-disp); font-weight: 700; font-size: var(--fs-title); line-height: 1.5; }
.sb-kv { display: grid; grid-template-columns: 7em minmax(0, 1fr); gap: 6px 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.sb-kv dt { font-size: var(--fs-small); font-weight: 700; color: var(--ink-2); line-height: 1.9; }
.sb-kv dd { overflow-wrap: anywhere; }
.sb-money { margin-top: 14px; }
.sb-tiers { width: 100%; max-width: 46em; border-collapse: collapse; border-top: 1px solid var(--ink); }
.sb-tiers th, .sb-tiers td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 15px; line-height: 1.7; overflow-wrap: anywhere; }
.sb-tiers th { font-size: var(--fs-small); color: var(--ink-2); font-weight: 700; }
.sb-tiers td:first-child { width: 46%; }
.sb-quote { max-width: 46em; margin-top: 8px; font-size: var(--fs-small); color: var(--ink-2); line-height: 1.8; }
.sb-caution { max-width: 46em; margin-top: 16px; padding: 14px 18px; border: 1px solid var(--chip-line); border-left: 4px solid var(--mikan); border-radius: 12px; background: var(--chip-bg); }
.sb-caution-head { font-weight: 700; color: var(--ink); }
.sb-caution p + p { margin-top: 4px; }
.sb-nat .sb-target { margin-top: 10px; padding: 8px 12px; border-radius: 8px; background: #ececea; color: var(--ink); }

/* 入口の国の表は「状況」「くわしく」の列を細く */
.sb-table--nat td:not(.sb-name) { width: 9.5em; }

/* 誤りのお知らせの1行 */
.sb-report { margin-top: 14px; font-size: var(--fs-small); color: var(--ink-2); }
.sb-report a { color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 4px; }

@media (max-width: 699px) {
  .sb-tiers th, .sb-tiers td { padding: 8px 4px; font-size: var(--fs-small); }
}
.sb-nw { white-space: nowrap; }
.sb-special-cond { display: block; margin-top: 2px; font-size: var(--fs-small); color: var(--ink-2); line-height: 1.6; }
.sb-tiers--4 td:first-child { width: 32%; }
@media (min-width: 700px) {   /* 「上限50万円」を1行に（PCで縦に折れていた）。スマホは幅が足りずはみ出すので当てない */
  .sb-tiers td:nth-child(2), .sb-tiers th { white-space: nowrap; }
  .sb-tiers td:nth-child(2) { width: 1%; }
}

/* ---------------------------------------------------------------- 国の枠の表: 金額を折らない・スマホは枠ごとのカード（2026-11-12 点検の指摘） */
.sb-amt { white-space: nowrap; }                      /* 「上限1,000万円」「50 万円上乗せ」を1つのかたまりにする（長い条件の文は折れてよい） */
@media (max-width: 699px) {
  .sb-tiers, .sb-tiers tbody, .sb-tiers tr, .sb-tiers td { display: block; width: auto !important; }
  .sb-tiers { border-top: 0; }
  .sb-tiers thead { display: none; }
  .sb-tiers tr { margin-top: 8px; padding: 8px 12px 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-warm); }
  .sb-tiers td { display: grid; grid-template-columns: 8.5em minmax(0, 1fr); gap: 8px; padding: 4px 0; border-bottom: 0; font-size: 14px; line-height: 1.65; white-space: normal; }
  .sb-tiers td::before { content: attr(data-label); font-size: var(--fs-small); font-weight: 700; color: var(--ink-2); }
  .sb-tiers td.sb-tier-name { display: block; padding: 0 0 4px; margin-bottom: 2px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 14px; }
  .sb-tiers td.sb-tier-name::before { content: none; }
}
.sb-v { display: block; min-width: 0; }   /* 値を1つのかたまりにして、スマホの2列の並びで文と金額が別の行に分かれないようにする */

/* ---------------------------------------------------------------- 入口の「制度をさがす」（2026-11-13 追加・オーナー指示「国や県や市でさがせるように」） */
.sb-filter { margin-top: 20px; padding: clamp(18px, 2.4vw, 28px); background: var(--paper-warm); border: 1px solid var(--line); border-radius: 18px; }
.no-js .sb-filter { display: none; }   /* 動かないときは出さない（表は受付中だけが見える） */
.sb-filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(0, 1.4fr); gap: 14px 18px; }
.sb-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sb-field-label { font-size: var(--fs-small); font-weight: 700; color: var(--ink-2); }
.sb-field select, .sb-field input { width: 100%; min-height: 48px; padding: 8px 12px; border: 1px solid #b9b6ae; border-radius: 10px; background: #fff; color: var(--ink); font: inherit; font-size: 16px; }
.sb-field select:disabled { background: #f3f2ee; color: var(--ink-2); }
.sb-field select:focus-visible, .sb-field input:focus-visible, .sb-reset:focus-visible, .sb-check input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sb-filter-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 18px; margin-top: 12px; }
.sb-check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 700; cursor: pointer; }
.sb-check input { width: 22px; height: 22px; accent-color: var(--accent); }
.sb-reset { min-height: 44px; padding: 0 18px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; }
.sb-reset:hover { background: var(--chip-bg); }
.sb-result { margin-top: 18px; font-weight: 700; }
.sb-table tr[hidden] { display: none !important; }
@media (max-width: 899px) {
  .sb-filter-grid { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- 受付が終わった制度を束ねて開け閉めする欄（2026-11-13 オーナー指示） */
.sb-closed { border: 1px solid var(--line); border-radius: 18px; background: #fafaf8; }
.sb-closed-sum { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; min-height: 64px; padding: 14px 56px 14px 22px; position: relative; cursor: pointer; list-style: none; }
.sb-closed-sum::-webkit-details-marker { display: none; }
.sb-closed-sum::after { content: ""; position: absolute; right: 24px; top: 50%; width: 10px; height: 10px; border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: translateY(-70%) rotate(45deg); transition: transform 0.2s ease; }
.sb-closed[open] > .sb-closed-sum::after { transform: translateY(-30%) rotate(-135deg); }
.sb-closed-sum:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 18px; }
.sb-closed-title { font-family: var(--font-disp); font-weight: 700; font-size: var(--fs-title); }
.sb-closed-count { font-weight: 700; }
.sb-closed-hint { color: var(--ink-2); }
.sb-closed-body { padding: 0 22px 24px; }
.sb-closed-body .sb-muni { margin-top: 32px; }
.sb-empty a { color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 4px; }
@media (max-width: 699px) {
  .sb-closed-sum { padding: 12px 48px 12px 16px; }
  .sb-closed-sum::after { right: 20px; }
  .sb-closed-body { padding: 0 12px 18px; }
}
@media (prefers-reduced-motion: reduce) { .sb-closed-sum::after { transition: none; } }
