* { box-sizing: border-box; }
body { font-family: -apple-system, "Segoe UI", Meiryo, sans-serif; margin: 0; background: #f6f7f9; color: #1c1f24; }
nav { background: #1c1f24; padding: 12px 24px; display: flex; gap: 20px; align-items: center; }
nav a { color: #fff; text-decoration: none; font-size: 14px; }
nav a.brand { font-weight: 700; font-size: 16px; margin-right: 12px; }
main { max-width: 960px; margin: 24px auto; padding: 0 16px; }
h1 { font-size: 20px; }
h2 { font-size: 16px; margin-top: 28px; }
table { width: 100%; border-collapse: collapse; background: #fff; margin-top: 8px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #e5e7eb; font-size: 13px; vertical-align: top; }
th { background: #eef0f3; }
.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 16px; margin-bottom: 12px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; background: #eef; }
.badge.warn { background: #fff3cd; }
.badge.ok { background: #d1f5d3; }
form.inline { display: inline; }
button { cursor: pointer; padding: 4px 10px; border-radius: 4px; border: 1px solid #ccc; background: #fff; font-size: 12px; }
button.primary { background: #2563eb; color: #fff; border-color: #2563eb; }
button.danger { background: #dc2626; color: #fff; border-color: #dc2626; }
label { display: block; margin-top: 10px; font-size: 13px; }
input[type=text], input[type=date], select, textarea { width: 100%; padding: 6px; margin-top: 4px; border: 1px solid #ccc; border-radius: 4px; }
.flags { font-size: 12px; color: #555; }

/* 折りたたみセクション(TO DO候補等)。detailsのopen属性だけでラベルを出し分ける(JS不要)。 */
.collapsible-section { margin-top: 28px; }
.collapsible-section > summary { font-size: 16px; font-weight: 700; cursor: pointer; list-style: none; }
.collapsible-section > summary::-webkit-details-marker { display: none; }
.collapsible-section:not([open]) .toggle-label-close { display: none; }
.collapsible-section[open] .toggle-label-open { display: none; }
.toggle-label-open, .toggle-label-close { font-weight: 400; font-size: 13px; color: #2563eb; }

/* 候補1件ごとの「詳細」(reason)はクリックするまで非表示。 */
.candidate-detail { font-size: 12px; }
.candidate-detail > summary { cursor: pointer; color: #2563eb; font-size: 12px; list-style: none; }
.candidate-detail > summary::-webkit-details-marker { display: none; }
.candidate-row-extra { display: none; }

/* ==== レスポンシブ対応(2026-09-20): PC版と同じHTMLを、スマホ(iPhone/Android)のブラウザでも使えるようにする ==== */
/* 方針: PC版とスマホ版を分けない。スマホでは縦一列・表はカード表示・入力は横幅100%・ボタンは押しやすい大きさ・
   ページ全体が横スクロールしない(320px幅まで)。機能・権限・ロジックは変えない(表示だけ)。 */
html { -webkit-text-size-adjust: 100%; }
img, video { max-width: 100%; height: auto; }
main { overflow-wrap: anywhere; }  /* 長いURL・ID・件名でページが横にはみ出さない */
pre { white-space: pre-wrap; max-width: 100%; overflow-x: auto; }
code { overflow-wrap: anywhere; }

/* 上部メニュー: PC幅では従来どおり横並び(.nav-linksは箱を作らず、中のリンクがnavの直接の子として並ぶ) */
.nav-toggle-input, .nav-toggle-label { display: none; }
.nav-links { display: contents; }
.nav-logout { display: inline; margin: 0; }
.nav-logout button { background: none; border: none; color: #fff; cursor: pointer; text-decoration: underline; padding: 0; font-size: 14px; }

/* PCナビは各項目を1行固定にする。項目が増えても日本語の途中で折り返さず、
   横幅が足りない場合だけナビ領域内で横スクロールできるようにする。 */
@media (min-width: 1024px) {
  nav { gap: 0; }
  nav a.brand { flex: 0 0 auto; white-space: nowrap; margin-right: 24px; }
  .nav-links {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    align-items: center;
    gap: 20px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links a,
  .nav-logout,
  .nav-logout button {
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

@media (max-width: 1023px) {
  /* 上部メニュー: 折りたたみ(「☰ メニュー」を押すと縦に開く。JS不要) */
  nav { flex-wrap: wrap; gap: 0; padding: 6px 12px; }
  nav a.brand { flex: 1 1 auto; display: flex; align-items: center; min-height: 44px; margin-right: 0; padding: 0; font-size: 15px; }
  .nav-toggle-input { display: block; position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
  .nav-toggle-label {
    display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px;
    border: 1px solid #6b7280; border-radius: 6px; color: #fff; font-size: 14px; cursor: pointer; user-select: none;
  }
  .nav-toggle-input:focus-visible + .nav-toggle-label { outline: 2px solid #93c5fd; outline-offset: 2px; }
  .nav-links { display: none; flex: 0 0 100%; width: 100%; flex-direction: column; margin-top: 6px; border-top: 1px solid #3b4048; }
  .nav-toggle-input:checked ~ .nav-links { display: flex; }
  .nav-links a { display: flex; align-items: center; min-height: 44px; padding: 0 4px; font-size: 15px; border-bottom: 1px solid #2c3036; }
  .nav-logout { display: block; }
  .nav-logout button { display: block; width: 100%; min-height: 44px; padding: 0 4px; text-align: left; font-size: 15px; }
}

@media (max-width: 720px) {
  body { font-size: 15px; }
  main { margin: 16px auto; padding: 0 12px; }
  h1 { font-size: 19px; }
  h2 { margin-top: 24px; }
  .card { padding: 12px; }
  .flags { font-size: 13px; }

  /* 入力: 横幅100%・16px(iOSの自動ズームを防ぐ)・押しやすい高さ */
  input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=hidden]):not([type=file]),
  select, textarea { width: 100%; max-width: 100%; font-size: 16px; padding: 10px; min-height: 44px; }
  textarea { min-height: 88px; }
  label { font-size: 14px; }
  input[type=checkbox], input[type=radio] { width: 22px; height: 22px; }

  /* ボタン: タップしやすい大きさ(44px以上) */
  button, input[type=submit], input[type=button] { min-height: 44px; padding: 10px 16px; font-size: 15px; }
  form.inline { display: inline-block; margin: 2px 6px 2px 0; }
  .card form button, details form button { margin: 4px 6px 4px 0; }
  summary { min-height: 44px; padding: 13px 0; cursor: pointer; }
  /* リンクだけのカード(ツール一覧など)・カード内の操作リンクは、指で押しやすい高さにする */
  .card > a:only-child { display: block; padding: 10px 0; }
  .rt td.rt-actions a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px 0 0; }

  /* 表: 既定は「表の中だけ」横スクロール(ページ全体は横スクロールしない) */
  table:not(.rt):not(.kv) { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* 表(class="rt"): 1行を1枚のカードにする。各セルの見出しはdata-labelから表示する。 */
  table.rt, table.rt tbody, table.rt tr, table.rt td { display: block; width: 100%; }
  table.rt { background: transparent; margin-top: 8px; }
  .rt thead, .rt tr.rt-head { display: none; }
  .rt tr { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; margin: 0 0 12px; padding: 6px 12px; }
  .rt td { border: 0; padding: 6px 0; font-size: 14px; }
  .rt td[data-label]::before {
    content: attr(data-label); display: block; margin-bottom: 2px; font-size: 12px; font-weight: 600; color: #555;
  }
  .rt td.rt-actions { padding-top: 10px; }
  .rt tr.candidate-row-extra { display: none; }  /* 「さらに表示」前の行は、カード表示でも隠したまま */

  /* 見出し・値の表(class="kv"): 見出しの下に値を縦に並べる */
  table.kv, table.kv tbody, table.kv tr, table.kv th, table.kv td { display: block; width: 100%; }
  table.kv { background: transparent; }
  .kv tr { background: #fff; border-bottom: 1px solid #e5e7eb; padding: 6px 12px; }
  .kv th { background: none; border: 0; padding: 4px 0 0; font-size: 12px; color: #555; }
  .kv td { border: 0; padding: 0 0 6px; font-size: 14px; }
}
