/* RSO-DX 特定技能支援管理システム - モバイルファーストスタイル */

/* ========== CSS変数 ========== */
:root {
  --primary: #1e40af;
  --primary-light: #3b82f6;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #16a34a;
  --gray-dark: #1f2937;
  --sidebar-width: 260px;
  --topbar-height: 56px;
  --tap-min: 48px; /* タップ最小サイズ */
}

/* ========== ベース ========== */
*, *::before, *::after { box-sizing: border-box; }
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  /* iOSバウンス（上下ゴム引き）をhtmlレベルで抖る舞い */
  overscroll-behavior: none;
}
body {
  font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Segoe UI', sans-serif;
  background: #f1f5f9;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  /* iOSでもスクロールを止められるように事前設定 */
  overflow-y: scroll; /* body自体は常にスクロール対象 */
  overscroll-behavior-y: none;
}

/* ========== レイアウト ========== */
/* 100vhはiOS Safariでアドレスバー分含むためdvhを使用，非対応ブラウザは100vhにフォールバック */
#app { display: flex; min-height: 100vh; min-height: 100dvh; }

/* ========== モバイルオーバーレイ ========== */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 299;
  backdrop-filter: blur(2px);
  /* タッチスクロールを防止（背景スクロール無効） */
  touch-action: none;
  overscroll-behavior: contain;
}
#sidebar-overlay.show { display: block; }

/* ========== サイドバー ========== */
#sidebar {
  width: var(--sidebar-width);
  /* 100vhフォールバック + dvh対応 */
  height: 100vh;
  height: 100dvh;
  background: linear-gradient(180deg, #0f172a 0%, #1e3a5f 100%);
  position: fixed;
  left: 0; top: 0;
  z-index: 300;
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain; /* サイドバー内バウンスは内部に封じ込める */
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
#sidebar .logo-area {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}
#sidebar nav {
  flex: 1;
  padding: 8px 0 80px;   /* 下余白を大きくしてログアウトが確実に見える */
  overflow-y: visible;   /* navはスクロールせずsidebar全体でスクロール */
}
#sidebar nav a {
  display: flex;
  align-items: center;
  min-height: var(--tap-min);
  padding: 10px 16px;
  color: rgba(255,255,255,0.72);
  text-decoration: none;
  font-size: 0.88rem;
  border-left: 3px solid transparent;
  transition: all 0.18s;
  gap: 10px;
  -webkit-tap-highlight-color: transparent;
}
#sidebar nav a:hover,
#sidebar nav a.active {
  background: rgba(59,130,246,0.22);
  color: #fff;
  border-left-color: #3b82f6;
}
#sidebar nav a .icon { width: 20px; text-align: center; font-size: 0.95rem; flex-shrink: 0; }
#sidebar nav .section-label {
  padding: 14px 16px 4px;
  font-size: 0.68rem;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ========== メインコンテンツ ========== */
#main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ========== トップバー ========== */
#topbar {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 0 16px;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
#topbar .topbar-left { display: flex; align-items: center; gap: 10px; }
#topbar .topbar-right { display: flex; align-items: center; gap: 8px; }

/* ========== コンテンツエリア ========== */
#content { padding: 16px; flex: 1; }

/* ========== ハンバーガーボタン ========== */
#mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 10px;
  background: #f1f5f9;
  border: 1.5px solid #e2e8f0;
  cursor: pointer;
  color: #374151;
  font-size: 16px;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

/* ========== 信号機バッジ ========== */
.badge-red {
  background: #fee2e2; color: #991b1b;
  padding: 3px 10px; border-radius: 20px;
  font-size: 0.75rem; font-weight: 700;
  border: 1px solid #fca5a5;
  white-space: nowrap;
}
.badge-yellow {
  background: #fef3c7; color: #92400e;
  padding: 3px 10px; border-radius: 20px;
  font-size: 0.75rem; font-weight: 700;
  border: 1px solid #fcd34d;
  white-space: nowrap;
}
.badge-green {
  background: #dcfce7; color: #166534;
  padding: 3px 10px; border-radius: 20px;
  font-size: 0.75rem; font-weight: 700;
  border: 1px solid #86efac;
  white-space: nowrap;
}

/* ========== カード ========== */
.card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  padding: 18px;
  margin-bottom: 0;
  box-sizing: border-box;
  overflow: hidden;
  width: 100%;
}
.card-header {
  font-size: 0.88rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ========== KPIカード ========== */
.stat-card {
  background: linear-gradient(135deg, var(--bg1,#f0f9ff), var(--bg2,#e0f2fe));
  border: 1px solid var(--border,#bae6fd);
  border-radius: 14px;
  padding: 16px;
}
.stat-card .stat-number {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}
.stat-card .stat-label {
  font-size: 0.78rem;
  margin-top: 6px;
  display: flex;
  align-items: center;
}
@media (max-width: 768px) {
  .stat-card .stat-number { font-size: 1.6rem; }
  .stat-card .stat-label { font-size: 0.7rem; }
  .stat-card { padding: 12px 14px; border-radius: 12px; }
}

/* ========== テーブル ========== */
.table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; min-width: 500px; }
.data-table th {
  background: #f8fafc;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: #64748b;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
  font-size: 0.78rem;
}
.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fafc; }
.data-table tr.anomaly td { background: #fff7ed; }

/* ========== ボタン ========== */
.btn {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn-primary { background: #1e40af; color: #fff; }
.btn-primary:active { background: #1d4ed8; transform: scale(0.97); }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:active { background: #15803d; }
.btn-warning { background: #d97706; color: #fff; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid #d1d5db; color: #374151; }
.btn-outline:active { background: #f9fafb; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 0.78rem; border-radius: 8px; }
.btn-xs { min-height: 28px; padding: 0 8px; font-size: 0.72rem; border-radius: 6px; }

/* ========== フォーム ========== */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 0.82rem; font-weight: 600; color: #374151; margin-bottom: 5px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1.5px solid #d1d5db;
  border-radius: 10px;
  font-size: 0.9rem; /* PCは0.9rem */
  color: #1f2937;
  background: #fff;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.form-textarea { resize: vertical; min-height: 88px; }
.required { color: #dc2626; margin-left: 2px; }

/* ========== モーダル ========== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 400;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal-box {
  background: #fff;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.2);
  animation: slideUp 0.28s cubic-bezier(0.4,0,0.2,1);
}
@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0.5; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-header {
  padding: 16px 20px 14px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
  border-radius: 20px 20px 0 0;
}
.modal-body { padding: 16px 20px 24px; }

/* モーダルハンドルバー */
.modal-handle {
  width: 36px; height: 4px;
  background: #d1d5db;
  border-radius: 2px;
  margin: 10px auto 0;
}

/* ========== タブ ========== */
.tab-list {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tab-list::-webkit-scrollbar { display: none; }
.tab-btn {
  min-height: 44px;
  padding: 0 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.tab-btn.active { color: #1e40af; border-bottom-color: #1e40af; }
.tab-btn:hover:not(.active) { color: #1e293b; }

/* ========== 信号機ドット ========== */
.signal-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.signal-red { background: #dc2626; box-shadow: 0 0 6px #dc262660; }
.signal-yellow { background: #f59e0b; box-shadow: 0 0 6px #f59e0b60; }
.signal-green { background: #16a34a; box-shadow: 0 0 6px #16a34a60; }

/* ========== ローディング ========== */
.loading-spinner {
  display: inline-block;
  width: 24px; height: 24px;
  border: 3px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== ページアニメーション ========== */
.page-enter { animation: fadeSlide 0.22s ease; }
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== 国籍タグ ========== */
.nationality-tag {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 6px;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
  display: inline-block;
}

/* ========== トースト通知 ========== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 600;
  z-index: 9999;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  animation: toastIn 0.25s ease;
  max-width: 90vw;
  text-align: center;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ========== リストアイテム（スマホ向け） ========== */
.list-item {
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s;
  text-decoration: none;
  color: inherit;
}
.list-item:active { background: #f8fafc; }

/* ========== 外国人材カード（スマホ向け） ========== */
.foreigner-card {
  background: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow 0.15s, transform 0.1s;
  border: 1.5px solid #f1f5f9;
}
.foreigner-card:active { transform: scale(0.99); box-shadow: 0 2px 8px rgba(0,0,0,0.1); }

/* ========== アラートサマリーカード ========== */
.alert-summary-card {
  border-radius: 14px;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  border: 2px solid;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.alert-summary-card:active { transform: scale(0.97); }
.alert-summary-red { background:#fff5f5; border-color:#fca5a5; }
.alert-summary-yellow { background:#fffbeb; border-color:#fcd34d; }
.alert-summary-green { background:#f0fdf4; border-color:#86efac; }
.alert-summary-num {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}
.alert-summary-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
  margin-top: 4px;
  line-height: 1.3;
}
@media (max-width: 768px) {
  .alert-summary-num { font-size: 1.6rem; }
  .alert-summary-label { font-size: 0.7rem; }
}

/* ========== アラートアイテム ========== */
.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff;
  border-left: 4px solid;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.alert-item.alert-red { border-left-color: #dc2626; background: #fff5f5; }
.alert-item.alert-yellow { border-left-color: #f59e0b; background: #fffbeb; }
.alert-item.alert-green { border-left-color: #16a34a; background: #f0fdf4; }

/* ========== ボトムナビゲーション（スマホ専用） ========== */
#bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  z-index: 200;
  /* iOSホームインジケーター分の余白を両形式で対応 */
  padding-bottom: env(safe-area-inset-bottom, 0);
  padding-bottom: constant(safe-area-inset-bottom, 0); /* iOS 11旧形式フォールバック */
  box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
}
#bottom-nav .nav-items {
  display: flex;
  justify-content: space-around;
  align-items: stretch;
}
#bottom-nav .nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  min-height: 56px;
  cursor: pointer;
  color: #94a3b8;
  font-size: 0.62rem;
  font-weight: 600;
  gap: 3px;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
  border: none;
  background: none;
}
#bottom-nav .nav-item i { font-size: 1.1rem; }
#bottom-nav .nav-item.active { color: #1e40af; }
#bottom-nav .nav-item .nav-badge {
  position: absolute;
  top: 6px;
  background: #dc2626;
  color: #fff;
  border-radius: 10px;
  font-size: 0.6rem;
  padding: 1px 5px;
  font-weight: 700;
  min-width: 16px;
  text-align: center;
}

/* ========== ページヘッダー ========== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 10px;
  flex-wrap: wrap;
}
/* ページヘッダー内のボタン群は常にwrap対応 */
.page-header > div {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.page-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0;
}
.page-subtitle {
  font-size: 0.8rem;
  color: #64748b;
  margin: 2px 0 0;
}

/* ========== ダッシュボードグリッド ========== */
.dash-grid-main,
.dash-grid-sub {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (min-width: 769px) {
  .dash-grid-main {
    grid-template-columns: 2fr 1fr;
    margin-bottom: 24px;
  }
  .dash-grid-sub {
    grid-template-columns: 1fr 1fr;
    margin-bottom: 24px;
  }
  .page-header { margin-bottom: 24px; }
  .page-title { font-size: 1.6rem; }
}

/* ========== KPIグリッド ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
@media (min-width: 769px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
  }
}

/* ========== フィルター行 ========== */
.filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.filter-row .form-select,
.filter-row .form-input {
  flex: 1;
  min-width: 140px;
}

/* ========== プリント用 ========== */
@media print {
  #sidebar, #topbar, #bottom-nav, .btn, .modal-overlay { display: none !important; }
  #main { margin-left: 0; }
  .card { box-shadow: none; border: 1px solid #e2e8f0; }
}

/* ========================================================
   レスポンシブ（デスクトップ: 769px以上）
   ======================================================== */
@media (min-width: 769px) {
  #mobile-menu-btn { display: none !important; }
  #bottom-nav { display: none !important; }
  #content { padding: 24px; }
  .modal-overlay { align-items: center; padding: 20px; }
  .modal-box {
    border-radius: 16px;
    max-width: 700px;
    max-height: 88vh;
    animation: fadeIn 0.22s ease;
  }
  @keyframes fadeIn {
    from { opacity: 0; transform: scale(0.97); }
    to { opacity: 1; transform: scale(1); }
  }
  .modal-handle { display: none; }
  /* PC ではテーブル表示・カード非表示 */
  .mobile-cards { display: none !important; }
  .desktop-table { display: block !important; }
}

/* ========================================================
   スマホ（768px以下）
   ======================================================== */
@media (max-width: 768px) {
  /* サイドバーを隠す */
  #sidebar {
    transform: translateX(-100%);
  }
  #sidebar.open {
    transform: translateX(0);
  }

  /* メインを全幅に */
  #main {
    margin-left: 0;
    padding-bottom: 64px; /* ボトムナビ分 */
  }

  /* ハンバーガーボタン表示 */
  #mobile-menu-btn { display: inline-flex !important; }

  /* ボトムナビ表示 */
  #bottom-nav { display: block; }

  /* トップバーをコンパクトに */
  #topbar { height: 52px; padding: 0 12px; }
  #topbar .ai-btn-text { display: none; } /* AI相談テキスト隠す */
  #topbar .topbar-right .btn { display: none; } /* スマホはトップバーのAI相談ボタン非表示（ボトムナビ使用） */

  /* ページヘッダー */
  .page-header { margin-bottom: 12px; }
  .page-title { font-size: 1.1rem !important; }
  .page-subtitle { font-size: 0.75rem !important; }

  /* KPIカードを2列 */
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
  .stat-card { padding: 12px; }
  .stat-card .stat-number { font-size: 1.7rem; }
  .stat-card .stat-label { font-size: 0.72rem; }

  /* コンテンツのpaddingを狭く */
  #content { padding: 12px; }

  /* カードのpadding調整 */
  .card { padding: 14px; border-radius: 12px; }
  .card-header { font-size: 0.85rem; margin-bottom: 12px; }

  /* テーブルをカードリストに切り替え */
  .mobile-cards { display: block !important; }
  .desktop-table { display: none !important; }

  /* フィルター行 */
  .filter-row { gap: 8px; }
  .filter-row .form-select,
  .filter-row .form-input { min-width: 100%; }

  /* グリッドを1列に */
  .lg\:grid-cols-3 { grid-template-columns: 1fr !important; }
  .lg\:col-span-2 { grid-column: span 1 !important; }

  /* ボタンのフルワイド */
  .btn-fullmobile { width: 100%; justify-content: center; }

  /* フォントサイズ調整 */
  .data-table { font-size: 0.8rem; }
  .data-table th, .data-table td { padding: 8px 10px; }

  /* モーダルタイトルサイズ */
  .modal-header h3 { font-size: 1rem; }
  .modal-body { padding: 14px 16px 20px; }

  /* ダッシュボード: ヘッダー内ボタン */
  .dashboard-header-btn { display: none; }

  /* =====================================================
     iOS/Android 差異吸収
     ===================================================== */

  /* iOSでinput/select/textareaは16px未満だとフォーカス時に自動ズームが発生する
     → スマホでは必ず16px以上に上書き */
  .form-input, .form-select, .form-textarea,
  input, select, textarea {
    font-size: 16px !important;
  }

  /* #mainの高さをdvhで正確に（iOSアドレスバー分を自動除外） */
  #main {
    min-height: 100svh; /* svh: small viewport height = アドレスバー表示時の最小高さ */
  }

  /* ボトムナビの実高さにsafe-area-inset-bottomを加算
     → iOSホームインジケーター分をpaddingで確保
     ただしbody padding-bottomも合わせて調整 */
  #main {
    /* ボトムナビ(60px) + iOS safe-area 分の余白 */
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    padding-bottom: calc(60px + constant(safe-area-inset-bottom, 0px));
  }

  /* iOSでposition:fixed要素がキーボード表示時にずれる問題
     → topbar/bottom-navを明示的にz-indexで最前面に固定 */
  #topbar  { z-index: 100; }
  #bottom-nav { z-index: 200; }

  /* iOSのモーダル内スクロールが止まる問題 → -webkit-overflow-scrolling統一 */
  .modal-box, .modal-body {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }

  /* サイドバー内スクロール: iOSで慣性スクロールを確保 */
  #sidebar {
    -webkit-overflow-scrolling: touch;
  }

  /* Androidのselect要素の矢印アイコンを統一（-webkit-appearance: noneで除去済みだが念のため） */
  select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
  }

  /* タップ時のハイライト完全無効化（iOS/Android両方） */
  * { -webkit-tap-highlight-color: rgba(0,0,0,0) !important; }
}
