/* ===== カスタムカラー =====
   ※ access-pro.co.jp のコーポレートカラーを確認後、
      下記の --color-primary 系を実際の値に更新してください
   ============================= */
:root {
  --color-primary:      #1a3a6b;
  --color-primary-dark: #0f2449;
  --color-primary-light:#2a5298;
}

/* ===== 基本スタイル ===== */
body { font-size: 15px; }

/* ===== R20: 左サイドバー =====
   開閉は #navToggle(checkbox) + 兄弟セレクタだけで成立させる。JSは補助のみ。
   Alpine/JSが読めない環境でもドロワーが開く＝ナビゲーション不能にならない。
   マークアップ順は  input#navToggle → label.nav-scrim → aside.app-sidebar → div.app-shell
   （兄弟セレクタが効く順序なので入れ替えないこと）。 */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.app-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
  width: 240px;
  display: flex; flex-direction: column;
  background: var(--color-primary);
  color: #fff;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateX(-100%);
  transition: transform 0.2s ease;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-toggle:checked ~ .app-sidebar { transform: none; }

.nav-scrim {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
.nav-toggle:checked ~ .nav-scrim { opacity: 1; pointer-events: auto; }

/* フォーカスが当たっていることをバーガー側に見せる（checkboxは視覚的に隠れているため） */
.nav-toggle:focus-visible ~ .app-shell .app-burger { outline: 2px solid #fcd34d; outline-offset: 2px; }

.app-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 12px;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}
.app-brand-text { font-weight: 700; font-size: 15px; line-height: 1.25; }
.app-brand-text small { display: block; font-weight: 400; font-size: 11px; color: #fcd34d; }

.app-nav { flex: 1 1 auto; padding: 8px; }
.app-nav-group {
  padding: 12px 8px 4px;
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  color: rgba(255, 255, 255, 0.5);
}
.app-nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  min-height: 44px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.app-nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.app-nav-link span { line-height: 1.25; }
.app-nav-link:hover { background: var(--color-primary-light); color: #fff; }
.app-nav-link.is-active {
  background: var(--color-primary-dark);
  color: #fcd34d;
  font-weight: 700;
}

.app-sidebar-foot {
  flex-shrink: 0;
  padding: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}
.app-nav-cta {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px;
  border-radius: 8px;
  background: #f59e0b; color: #fff;
  font-weight: 700; font-size: 14px;
  transition: background 0.15s;
}
.app-nav-cta svg { width: 18px; height: 18px; }
.app-nav-cta:hover { background: #d97706; }

.app-user { position: relative; margin-top: 8px; }
.app-user-btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  min-height: 44px; padding: 6px 8px;
  border-radius: 8px; color: #fff; font-size: 13px; text-align: left;
}
.app-user-btn:hover { background: var(--color-primary-light); }
.app-user-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-user-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 9999px;
  background: var(--color-primary-light); color: #fff;
  font-size: 12px; font-weight: 700;
}
.app-user-menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px);
  background: #fff; color: #374151;
  border: 1px solid #e5e7eb; border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  overflow: hidden; z-index: 70;
}
.app-user-meta { padding: 8px 12px; font-size: 11px; color: #6b7280; border-bottom: 1px solid #f3f4f6; }
.app-user-logout {
  display: flex; align-items: center; gap: 8px;
  width: 100%; min-height: 44px; padding: 8px 12px;
  font-size: 13px; color: #374151; text-align: left;
}
.app-user-logout:hover { background: #f9fafb; }

/* モバイル/タブレットの上部バー（デスクトップでは消える） */
.app-topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 8px;
  height: 52px; padding: 0 8px;
  background: var(--color-primary); color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}
.app-burger {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; flex-shrink: 0;
  border-radius: 8px; cursor: pointer;
}
.app-burger:hover { background: var(--color-primary-light); }
.app-topbar-title {
  flex: 1 1 auto; color: #fff; font-weight: 700; font-size: 15px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.app-topbar-title span { color: #fcd34d; font-weight: 400; font-size: 12px; }

.app-shell { min-height: 100vh; }

@media (min-width: 1024px) {
  .app-sidebar { transform: none; }
  .nav-scrim, .app-topbar { display: none; }
  .app-shell { padding-left: 240px; }
}

@media print {
  .app-sidebar, .app-topbar, .nav-scrim { display: none !important; }
  .app-shell { padding-left: 0 !important; min-height: 0; }
}

.btn-nav-primary {
  display: inline-flex;
  align-items: center;
  background: #f59e0b;
  color: #fff;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 14px;
  transition: background 0.15s;
}
.btn-nav-primary:hover { background: #d97706; }

/* ===== ボタン ===== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
  border: none;
}
.btn-primary:hover { background: var(--color-primary-dark); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  color: #374151;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid #d1d5db;
}
.btn-secondary:hover { background: #f9fafb; }

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #ef4444;
  color: #fff;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
  border: none;
}
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ===== バッジ ===== */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-gray   { background: #f3f4f6; color: #374151; }
.badge-red    { background: #fee2e2; color: #991b1b; }

/* ===== カード ===== */
.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* ===== フォーム ===== */
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 4px;
}
.form-input {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #fff;
  color: #111827;
}
.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26,58,107,0.12);
}
select.form-input { cursor: pointer; }
textarea.form-input { resize: vertical; min-height: 80px; }

/* ===== テーブル ===== */
.table-base {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table-base thead { background: #f8fafc; }
.table-base th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  color: #6b7280;
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
}
.table-base td {
  padding: 10px 12px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}
.table-base tbody tr:hover { background: #f9fafb; }
.table-base tbody tr:last-child td { border-bottom: none; }

/* ===== フラッシュメッセージ ===== */
.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* B-13: 保存結果はトーストで通知する。
   従来はページ最上部のバナーだったが、インライン保存後は #unit-123 へアンカー移動するため
   バナーが視界に入らず「保存された？」が毎回分からなかった。位置に依存しない固定表示にする。 */
.app-toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 24px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18);
  font-size: 14px;
  /* 内容に応じた幅にする（既定の縮小挙動だと狭幅端末で不要に3行折返しして読みにくい） */
  width: max-content;
  max-width: calc(100vw - 32px);
  opacity: 1;
  transition: opacity 0.3s;
}
.app-toast.is-hiding { opacity: 0; }
.app-toast-x {
  margin-left: 4px; padding: 0 4px;
  font-size: 18px; line-height: 1; opacity: 0.6; cursor: pointer;
  background: none; border: none; color: inherit;
}
.app-toast-x:hover { opacity: 1; }
@media (max-width: 768px) {
  /* FAB(右下60px)と重ならない高さに逃がす */
  .app-toast { bottom: 96px; }
}

/* ===== 統計カード ===== */
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  border: 1px solid #e5e7eb;
}
.stat-value { font-size: 32px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12px; color: #6b7280; margin-top: 4px; }

/* ===== 印刷スタイル ===== */
@media print {
  body { font-size: 11pt; background: #fff; }
  .print-hidden { display: none !important; }
  .print-page-break { page-break-after: always; }

  .doc-page {
    max-width: 100%;
    margin: 0;
    padding: 15mm 20mm;
    box-shadow: none;
    border: none;
  }
  .doc-title {
    font-size: 18pt;
    font-weight: bold;
    text-align: center;
    margin-bottom: 20pt;
  }
  .doc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10pt;
  }
  .doc-table th, .doc-table td {
    border: 1px solid #333;
    padding: 4pt 6pt;
  }
  .doc-table th { background: #f0f0f0; }
}

/* ===== レスポンシブ表 ===== */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ===== 写真グリッド ===== */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.photo-item {
  aspect-ratio: 4/3;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #e5e7eb;
  position: relative;
  background: #f3f4f6;
}
.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo-item .photo-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.photo-item:hover .photo-overlay { opacity: 1; }

/* ===== 機器テーブル入力 ===== */
.eq-input {
  width: 100%;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  background: #fff;
}
.eq-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* ===== 書類カードグリッド（改善#1） ===== */
.doc-section { margin-bottom: 20px; }
.doc-section:last-child { margin-bottom: 0; }
.doc-section-head {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 700; color: #374151;
  margin-bottom: 10px;
  padding-bottom: 6px; border-bottom: 1px solid #e5e7eb;
}
.doc-section-head .doc-step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--color-primary); color: #fff;
  font-size: 11px; font-weight: 700;
}
.doc-section-head .doc-section-meta {
  margin-left: auto; font-size: 11px; font-weight: 500; color: #6b7280;
}
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.doc-card {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 14px 10px 12px; text-align: center;
  transition: all 0.15s; cursor: pointer; text-decoration: none;
  min-height: 96px;
}
.doc-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 4px 10px rgba(26,58,107,0.10);
  transform: translateY(-2px);
}
.doc-card svg, .doc-card .doc-icon {
  width: 28px; height: 28px; color: var(--color-primary);
  margin-bottom: 6px; flex-shrink: 0;
}
.doc-card .doc-label { font-weight: 700; font-size: 13px; color: #1f2937; line-height: 1.25; }
.doc-card .doc-meta  { font-size: 11px; color: #6b7280; margin-top: 4px; line-height: 1.2; }
.doc-card.is-disabled {
  background: #f9fafb; opacity: 0.55; pointer-events: none;
  border-color: #e5e7eb;
}
.doc-card.is-disabled svg, .doc-card.is-disabled .doc-icon { color: #9ca3af; }
.doc-card.is-alert {
  border-color: #f59e0b; background: #fffbeb;
}
.doc-card.is-alert svg { color: #d97706; }
.doc-card.is-alert .doc-meta { color: #b45309; font-weight: 600; }

/* ===== 進捗ステッパー（改善#2） ===== */
.phase-stepper {
  display: flex; align-items: stretch;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 16px 20px; box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  overflow-x: auto;
}
.phase-step {
  flex: 1; min-width: 88px;
  display: flex; flex-direction: column; align-items: center;
  position: relative;
  text-align: center;
}
.phase-step + .phase-step::before {
  content: ''; position: absolute;
  top: 14px; left: -50%; width: 100%; height: 2px;
  background: #e5e7eb; z-index: 0;
}
.phase-step.is-done + .phase-step::before { background: var(--color-primary); }
.phase-step .phase-dot {
  width: 28px; height: 28px; border-radius: 50%;
  background: #f3f4f6; border: 2px solid #d1d5db;
  display: flex; align-items: center; justify-content: center;
  z-index: 1; position: relative;
  font-size: 12px; color: #9ca3af; font-weight: 700;
}
.phase-step.is-done .phase-dot {
  background: var(--color-primary); border-color: var(--color-primary); color: #fff;
}
.phase-step.is-current .phase-dot {
  background: #fff; border-color: var(--color-primary);
  color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(26,58,107,0.15);
}
.phase-step .phase-label {
  margin-top: 8px; font-size: 12px; font-weight: 700; color: #374151;
  white-space: nowrap;
}
.phase-step.is-current .phase-label { color: var(--color-primary); }
.phase-step .phase-meta {
  margin-top: 2px; font-size: 10px; color: #9ca3af;
  line-height: 1.2;
}
.phase-step.is-done .phase-meta { color: #6b7280; }
.phase-summary {
  margin-top: 8px; font-size: 12px; color: #6b7280; text-align: center;
}
.phase-summary strong { color: var(--color-primary); }

/* ===== 積み上げプログレスバー（改善#3） ===== */
.unit-funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row {
  display: grid; grid-template-columns: 84px 1fr 64px;
  align-items: center; gap: 10px;
  font-size: 12px;
}
.funnel-label { color: #374151; font-weight: 600; }
.funnel-bar {
  position: relative; height: 22px; border-radius: 6px;
  background: #f3f4f6; overflow: hidden;
}
.funnel-fill {
  position: absolute; inset: 0 auto 0 0;
  display: flex; align-items: center; padding: 0 8px;
  color: #fff; font-weight: 700; font-size: 11px;
  transition: width 0.3s;
}
.funnel-fill.is-survey    { background: #10b981; }
.funnel-fill.is-scheduled { background: #3b82f6; }
.funnel-fill.is-completed { background: #6366f1; }
.funnel-fill.is-stamped   { background: #f59e0b; }
.funnel-pct {
  font-weight: 700; color: #6b7280; text-align: right; font-variant-numeric: tabular-nums;
}

.unit-stat-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
  margin-top: 14px;
}
.unit-stat {
  display: block;
  padding: 10px 4px; border-radius: 8px;
  background: #f9fafb; border: 1px solid #e5e7eb;
  text-align: center; transition: all 0.15s;
  text-decoration: none; color: inherit;
}
.unit-stat:hover { border-color: var(--color-primary); background: #f3f4f6; }
.unit-stat .us-num { font-size: 20px; font-weight: 800; line-height: 1; }
.unit-stat .us-label { font-size: 11px; color: #6b7280; margin-top: 4px; }
.unit-stat .us-pct   { font-size: 10px; color: #9ca3af; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ===== ダッシュボード KPIカード強化（改善#4） ===== */
.kpi-card {
  display: flex; flex-direction: column; gap: 6px;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  transition: all 0.15s;
  text-decoration: none; color: inherit;
}
.kpi-card:hover { border-color: var(--color-primary); transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.08); }
.kpi-card.is-alert { background: #fef2f2; border-color: #fca5a5; }
.kpi-card.is-alert:hover { border-color: #ef4444; }
.kpi-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: #6b7280; font-weight: 600;
}
.kpi-head .kpi-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: rgba(26,58,107,0.10); color: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.kpi-head .kpi-icon svg { width: 18px; height: 18px; }
.kpi-card.is-alert .kpi-icon { background: #fee2e2; color: #b91c1c; }
.kpi-value {
  font-size: 30px; font-weight: 800; line-height: 1;
  color: #111827; font-variant-numeric: tabular-nums;
}
.kpi-card.is-alert .kpi-value { color: #b91c1c; }
.kpi-trend {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; color: #6b7280;
}
.kpi-trend.is-up   { color: #059669; }
.kpi-trend.is-down { color: #dc2626; }
.kpi-trend.is-flat { color: #6b7280; }
.kpi-spark { height: 24px; width: 100%; }

/* ===== 案件カード（モバイル, 改善#5） ===== */
.proj-card {
  display: block; background: #fff;
  border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 14px 16px; box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  text-decoration: none; color: inherit;
  transition: all 0.15s;
  min-height: 88px;
}
.proj-card:hover, .proj-card:active { border-color: var(--color-primary); box-shadow: 0 4px 10px rgba(0,0,0,0.08); }
.proj-card.is-alert { border-left: 4px solid #ef4444; }
.proj-card-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  margin-bottom: 6px;
}
.proj-card-title { font-size: 15px; font-weight: 700; color: #111827; line-height: 1.3; }
.proj-card-client { font-size: 12px; color: #6b7280; margin-bottom: 6px; }
.proj-card-meta {
  font-size: 12px; color: #4b5563;
  display: flex; flex-wrap: wrap; gap: 6px 12px;
}
.proj-card-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; padding-top: 8px; border-top: 1px dashed #e5e7eb;
}

/* ===== フィルタチップ（改善#6） ===== */
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 9999px;
  background: var(--color-primary); color: #fff;
  font-size: 12px; font-weight: 600;
  text-decoration: none;
}
.filter-chip:hover { background: var(--color-primary-dark); }
.filter-chip .chip-x {
  font-size: 14px; line-height: 1; opacity: 0.8;
}
.filter-chip:hover .chip-x { opacity: 1; }
.filter-chips-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 8px 0 0; border-top: 1px dashed #e5e7eb; margin-top: 12px;
}
.filter-chips-bar .chip-label {
  font-size: 11px; color: #9ca3af; font-weight: 600; margin-right: 4px;
}
.filter-chip-clear {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 9999px;
  background: #fff; color: #6b7280;
  border: 1px solid #d1d5db;
  font-size: 12px; font-weight: 600; text-decoration: none;
  margin-left: 4px;
}
.filter-chip-clear:hover { color: #ef4444; border-color: #ef4444; }

/* ===== FAB (Floating Action Button, 改善#7) ===== */
.fab {
  position: fixed; bottom: 24px; right: 24px;
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--color-primary); color: #fff;
  box-shadow: 0 6px 16px rgba(0,0,0,0.30);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; transition: transform 0.15s, background 0.15s;
  border: none; cursor: pointer; text-decoration: none;
}
.fab:hover  { transform: scale(1.05); background: var(--color-primary-dark); }
.fab:active { transform: scale(0.95); }
.fab svg { width: 28px; height: 28px; }
.fab-label {
  position: absolute; right: 70px; top: 50%; transform: translateY(-50%);
  background: #1f2937; color: #fff; padding: 6px 10px;
  border-radius: 6px; font-size: 12px; font-weight: 600;
  white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity 0.15s;
}
.fab:hover .fab-label { opacity: 1; }

/* =====================================================================
   v2 改善（lazyweb分析版）追加スタイル
   ===================================================================== */

/* ----- 共通: ビュー切替タブ ----- */
.view-toggle {
  display: inline-flex; gap: 0; border: 1px solid #d1d5db; border-radius: 8px;
  overflow: hidden; background: #fff;
}
.view-toggle button, .view-toggle a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; font-size: 13px; font-weight: 600;
  color: #6b7280; background: #fff; border: none; cursor: pointer;
  text-decoration: none; transition: background 0.15s, color 0.15s;
}
.view-toggle button + button, .view-toggle a + a { border-left: 1px solid #e5e7eb; }
.view-toggle button:hover, .view-toggle a:hover { background: #f9fafb; color: #111827; }
.view-toggle button.is-active, .view-toggle a.is-active {
  background: var(--color-primary); color: #fff;
}
.view-toggle svg { width: 14px; height: 14px; }

/* ===== 改善v2-A: 住戸グリッドヒートマップ ===== */
.unit-heatmap {
  display: flex; flex-direction: column; gap: 8px;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.unit-heatmap-head {
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 8px;
  margin-bottom: 4px;
}
.unit-heatmap-legend {
  display: flex; flex-wrap: wrap; gap: 10px;
  font-size: 11px; color: #6b7280;
}
.unit-heatmap-legend span {
  display: inline-flex; align-items: center; gap: 4px;
}
.unit-heatmap-legend i {
  width: 12px; height: 12px; border-radius: 3px; display: inline-block;
}
.unit-floor-row {
  display: flex; align-items: stretch; gap: 6px;
}
.unit-floor-label {
  width: 36px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #6b7280; font-size: 13px;
  background: #f9fafb; border-radius: 8px;
}
.unit-floor-cells {
  display: flex; flex-wrap: wrap; gap: 6px; flex: 1;
}
.unit-cell {
  min-width: 60px; min-height: 64px;
  padding: 6px 4px; border-radius: 8px;
  text-align: center; cursor: pointer;
  border: 1px solid transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: transform .1s, box-shadow .1s;
  text-decoration: none;
}
.unit-cell:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
  border-color: var(--color-primary);
}
.unit-cell .unit-no    { font-weight: 800; font-size: 13px; line-height: 1.1; }
.unit-cell .unit-icon  { font-size: 10px; margin-top: 4px; line-height: 1; opacity: 0.85; }
.unit-cell.is-pending   { background: #f3f4f6; color: #4b5563; }
.unit-cell.is-scheduled { background: #dbeafe; color: #1e40af; }
.unit-cell.is-changed   { background: #fecaca; color: #991b1b; font-weight: 800; }
.unit-cell.is-completed { background: #c7d2fe; color: #3730a3; }
.unit-cell.is-stamped   { background: #fef3c7; color: #92400e; }
.unit-cell.is-alert     { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.unit-cell.is-vacant    { background: #f9fafb; color: #9ca3af; border: 1px dashed #d1d5db; }

/* ===== 改善v2-B: 案件ボードビュー ===== */
.proj-board {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.proj-board-col {
  background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 12px; min-height: 200px;
}
.proj-board-col.is-alert { background: #fef2f2; border-color: #fca5a5; }
.proj-board-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; padding: 0 4px 8px;
  border-bottom: 1px solid #e5e7eb; font-weight: 700; color: #374151; font-size: 13px;
}
.proj-board-head .proj-board-count {
  background: #e5e7eb; color: #374151;
  padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 700;
}
.proj-board-col.is-alert .proj-board-count { background: #fecaca; color: #991b1b; }
.proj-board-list { display: flex; flex-direction: column; gap: 8px; }
.proj-board-card {
  display: block; background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 10px 12px; text-decoration: none; color: inherit;
  transition: all 0.15s;
}
.proj-board-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08); transform: translateY(-1px);
}
.proj-board-card-title { font-weight: 700; color: #111827; font-size: 13px; line-height: 1.3; }
.proj-board-card-client { font-size: 11px; color: #6b7280; margin-top: 2px; }
.proj-board-card-meta {
  display: flex; flex-wrap: wrap; gap: 4px 8px;
  margin-top: 6px; font-size: 11px; color: #6b7280;
}
.proj-board-card .mini-bar {
  position: relative; height: 6px; background: #f3f4f6; border-radius: 3px;
  margin-top: 6px; overflow: hidden;
}
.proj-board-card .mini-bar-fill {
  position: absolute; inset: 0 auto 0 0;
  background: var(--color-primary); border-radius: 3px;
}
.proj-board-empty { padding: 20px 8px; text-align: center; font-size: 12px; color: #9ca3af; }

/* ===== 改善v2-C: KPI警告ストライプ強化 ===== */
@keyframes kpi-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.55); }
  50%      { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}
.kpi-card.is-alert {
  border-left: 6px solid #dc2626;
  padding-left: 14px;
  position: relative;
}
.kpi-card.is-alert::before {
  content: ''; position: absolute; top: 16px; right: 16px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #dc2626;
  animation: kpi-pulse 1.6s ease-out infinite;
}

/* ===== 改善v2-E: 案件詳細 二分割スティッキー (lg+でgrid再配置) ===== */
@media (min-width: 1024px) {
  .view-split {
    display: grid;
    grid-template-columns: minmax(0,1fr) 380px;
    grid-template-areas:
      "vs-info  vs-docs"
      "vs-units vs-docs"
      "vs-equip vs-docs";
    gap: 20px;
    align-items: start;
  }
  .view-split > .vs-docs   { grid-area: vs-docs;  position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; margin: 0; }
  .view-split > .vs-info   { grid-area: vs-info;  margin: 0; }
  .view-split > .vs-units  { grid-area: vs-units; margin: 0; }
  .view-split > .vs-equip  { grid-area: vs-equip; margin: 0; }
  .view-split > .vs-docs::-webkit-scrollbar { width: 6px; }
  .view-split > .vs-docs::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
  .view-split > .vs-docs .doc-grid { grid-template-columns: repeat(2, 1fr); }
  .view-split > .vs-info  .grid.lg\:grid-cols-2 { grid-template-columns: 1fr; } /* 内部grid解除 */
}

/* ===== 改善v2-F: モバイル ボトムシート ===== */
.bottom-sheet {
  width: 100%; max-width: 100%;
  margin: auto 0 0; padding: 0;
  border: none; border-radius: 16px 16px 0 0;
  background: #fff;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.20);
  animation: bs-slide-up 0.22s ease-out;
  position: fixed; inset: auto 0 0 0; top: auto;
}
.bottom-sheet::backdrop { background: rgba(0,0,0,0.45); }
@keyframes bs-slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.bottom-sheet-handle {
  width: 40px; height: 4px; border-radius: 2px;
  background: #d1d5db; margin: 10px auto 0;
}
.bottom-sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px 8px;
}
.bottom-sheet-title { font-weight: 700; color: #111827; font-size: 15px; }
.bottom-sheet-body { padding: 8px 20px 20px; }
.bs-status-btn {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 56px;
  padding: 14px 16px; margin-bottom: 8px;
  border: 2px solid transparent; border-radius: 12px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  background: #f9fafb; color: #111827; text-align: left;
  transition: all 0.15s;
}
.bs-status-btn:hover { border-color: var(--color-primary); }
.bs-status-btn.is-pending   { background: #f3f4f6; color: #4b5563; }
.bs-status-btn.is-scheduled { background: #dbeafe; color: #1e40af; }
.bs-status-btn.is-changed   { background: #fecaca; color: #991b1b; }
.bs-status-btn.is-completed { background: #c7d2fe; color: #3730a3; }
.bs-status-btn.is-stamped   { background: #fef3c7; color: #92400e; }
.bs-status-btn .bs-dot {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
}
.bs-cancel {
  width: 100%; padding: 12px; margin-top: 8px;
  background: #fff; color: #6b7280;
  border: 1px solid #d1d5db; border-radius: 12px;
  font-weight: 600; cursor: pointer;
}

/* ===== 改善v2-H: 今週のアクションセクション ===== */
.weekly-actions { display: flex; flex-direction: column; gap: 6px; }
.weekly-action {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 10px;
  background: #fff; border: 1px solid #e5e7eb;
  text-decoration: none; color: inherit; transition: all 0.15s;
}
.weekly-action:hover { border-color: var(--color-primary); background: #f9fafb; transform: translateX(2px); }
.weekly-action .wa-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.weekly-action .wa-dot.is-critical { background: #dc2626; }
.weekly-action .wa-dot.is-warn     { background: #f59e0b; }
.weekly-action .wa-dot.is-info     { background: #10b981; }
.weekly-action .wa-text { flex: 1; font-size: 13px; min-width: 0; }
.weekly-action .wa-project { font-weight: 700; color: #111827; }
.weekly-action .wa-detail  { color: #6b7280; font-size: 12px; }
.weekly-action .wa-action  {
  font-size: 12px; font-weight: 700; color: var(--color-primary);
  white-space: nowrap;
}
.weekly-empty { padding: 20px; text-align: center; color: #9ca3af; font-size: 13px; }

/* ===== 改善v2-D: Before/After スライダー ===== */
.ba-slider {
  position: relative; max-width: 720px; margin: 0 auto;
  aspect-ratio: 4/3; border-radius: 12px; overflow: hidden;
  background: #111;
  user-select: none; cursor: ew-resize;
}
.ba-slider img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: contain;
  display: block;
  pointer-events: none;
}
.ba-slider .ba-after  { z-index: 1; }
.ba-slider .ba-before { z-index: 2; clip-path: inset(0 50% 0 0); }
.ba-slider .ba-handle {
  position: absolute; top: 0; bottom: 0; left: 50%;
  width: 2px; background: #fff;
  z-index: 3; pointer-events: none;
  box-shadow: 0 0 6px rgba(0,0,0,0.5);
}
.ba-slider .ba-handle::before {
  content: '⇆'; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 32px; height: 32px; border-radius: 50%;
  background: #fff; color: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.ba-slider .ba-label {
  position: absolute; top: 10px;
  padding: 4px 10px; border-radius: 6px;
  background: rgba(0,0,0,0.6); color: #fff;
  font-size: 11px; font-weight: 700; z-index: 4;
  pointer-events: none;
}
.ba-slider .ba-label-before { left: 10px; }
.ba-slider .ba-label-after  { right: 10px; }

/* ===== 改善v2-G: フルスクリーン撮影モード ===== */
.capture-modal {
  width: 100vw; max-width: 100vw;
  height: 100vh; max-height: 100vh;
  margin: 0; padding: 0; border: none;
  background: #111; color: #fff;
}
.capture-modal::backdrop { background: rgba(0,0,0,0.95); }
.capture-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: rgba(0,0,0,0.7);
  position: sticky; top: 0; z-index: 2;
}
.capture-head .capture-close {
  background: none; border: none; color: #fff;
  font-size: 24px; cursor: pointer; padding: 4px 8px;
}
.capture-cat-toggle {
  display: inline-flex; background: rgba(255,255,255,0.1); border-radius: 9999px;
  padding: 3px;
}
.capture-cat-toggle button {
  background: none; border: none; color: #ccc;
  padding: 6px 16px; border-radius: 9999px;
  font-weight: 700; font-size: 13px; cursor: pointer;
}
.capture-cat-toggle button.is-active {
  background: #fff; color: #111;
}
.capture-body {
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 16px; gap: 16px;
}
.capture-thumbs {
  display: flex; flex-wrap: wrap; gap: 8px;
  width: 100%; max-width: 600px;
  min-height: 80px; padding: 8px;
  background: rgba(255,255,255,0.05); border-radius: 12px;
}
.capture-thumbs:empty::before {
  content: 'まだ写真がありません。カメラまたはファイルから追加してください。';
  color: #888; font-size: 12px; text-align: center;
  width: 100%; padding: 24px 0;
}
.capture-thumb {
  position: relative;
  width: 72px; height: 72px; border-radius: 8px;
  background-size: cover; background-position: center;
  border: 2px solid rgba(255,255,255,0.2);
}
.capture-thumb .capture-thumb-x {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #ef4444; color: #fff;
  font-size: 12px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: none;
}
.capture-counter {
  font-size: 13px; color: #ccc; font-weight: 600;
}
.capture-actions {
  display: flex; gap: 16px; align-items: center; justify-content: center;
  width: 100%; padding: 16px;
}
.capture-shutter {
  width: 72px; height: 72px; border-radius: 50%;
  background: #fff; border: 4px solid rgba(255,255,255,0.3);
  cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  transition: transform 0.1s;
  display: flex; align-items: center; justify-content: center;
}
.capture-shutter:active { transform: scale(0.92); }
.capture-shutter::after {
  content: ''; width: 56px; height: 56px; border-radius: 50%;
  background: #fff; border: 2px solid #111;
}
.capture-side-btn {
  padding: 12px 16px; border-radius: 10px;
  background: rgba(255,255,255,0.1); color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  font-size: 13px; font-weight: 700; cursor: pointer;
}
.capture-side-btn.is-primary { background: #10b981; border-color: #10b981; }
.capture-side-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Floating shortcut button to launch capture mode */
.btn-capture-floating {
  display: inline-flex; align-items: center; gap: 6px;
  background: #10b981; color: #fff; font-weight: 700;
  padding: 8px 14px; border-radius: 9999px;
  font-size: 13px; cursor: pointer; border: none;
  transition: background 0.15s;
}
.btn-capture-floating:hover { background: #059669; }
.btn-capture-floating svg { width: 16px; height: 16px; }

/* =====================================================================
   改善適用: lazyweb 5改善
   ===================================================================== */

/* ----- #1 アコーディオンフォーム ----- */
.acc-section {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
  margin-bottom: 10px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.acc-head {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; cursor: pointer; background: none; border: none;
  text-align: left; transition: background 0.15s;
}
.acc-head:hover { background: #f9fafb; }
.acc-section.is-open > .acc-head { background: #f8fafc; border-bottom: 1px solid #e5e7eb; }
.acc-num {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: var(--color-primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
}
.acc-section:not(.is-open) .acc-num { background: #d1d5db; }
/* R16: 見出しは絶対に折らない。
   従来 .acc-title は flex:1（＝基準幅0）だったため、隣の .acc-meta に押されて
   モバイルで「オプ/ショ/ン・/機器」のように1文字ずつ縦に割れていた
   （モバイルでは .acc-meta を12pxに拡大しているぶん、さらに悪化していた）。
   見出しを自然幅で固定し、副次情報の .acc-meta 側を縮めて省略表示にする。 */
.acc-title { font-weight: 700; font-size: 14px; color: #111827; flex: 0 0 auto; white-space: nowrap; }
.acc-meta {
  font-size: 11px; color: #9ca3af; margin-left: 6px;
  flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.acc-status {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 9999px;
  background: #d1fae5; color: #065f46; margin-right: 4px;
}
.acc-chevron {
  width: 18px; height: 18px; color: #9ca3af; flex-shrink: 0;
  transition: transform 0.2s;
}
.acc-section.is-open .acc-chevron { transform: rotate(180deg); }
.acc-body { padding: 20px 24px 24px; }

/* ----- #2 テーブル行ホバーアクション ----- */
.table-base tbody tr { cursor: pointer; }
.row-actions {
  display: flex; justify-content: flex-end; align-items: center; gap: 4px;
}
.btn-row-action {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 4px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 600;
  background: #fff; color: #374151; border: 1px solid #d1d5db;
  text-decoration: none; cursor: pointer;
  transition: all 0.12s; white-space: nowrap;
}
.btn-row-action:hover { background: #f3f4f6; border-color: #9ca3af; }
.btn-row-action.is-primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-row-action.is-primary:hover { background: var(--color-primary-dark); }
.btn-row-action svg { width: 12px; height: 12px; }
.btn-row-action-extra {
  opacity: 0; pointer-events: none;
  transition: opacity 0.12s;
}
.table-base tbody tr:hover .btn-row-action-extra {
  opacity: 1; pointer-events: auto;
}

/* ----- #3 案件詳細タブナビゲーション ----- */
.proj-tabs {
  display: flex; gap: 0; border-bottom: 2px solid #e5e7eb;
  margin-bottom: 20px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
}
.proj-tab {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 10px 18px; font-size: 14px; font-weight: 600;
  color: #6b7280; border-bottom: 2px solid transparent; margin-bottom: -2px;
  cursor: pointer; white-space: nowrap;
  background: none; border-top: none; border-left: none; border-right: none;
  transition: color 0.15s;
}
.proj-tab:hover { color: #374151; }
.proj-tab.is-active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.proj-tab .tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9999px;
  background: #e5e7eb; color: #374151; font-size: 10px; font-weight: 700;
}
.proj-tab.is-active .tab-badge { background: var(--color-primary); color: #fff; }

/* view-split with single-col override for tabs */
.view-split.is-single-col {
  display: block !important;
}
.view-split.is-single-col > * {
  grid-area: unset !important;
  position: static !important;
  max-height: none !important;
  overflow-y: visible !important;
  margin-bottom: 20px;
}

/* ----- #4 期限スケジュール ----- */
.deadline-list { display: flex; flex-direction: column; gap: 6px; }
.deadline-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px; border-radius: 10px;
  background: #fff; border: 1px solid #e5e7eb;
  text-decoration: none; color: inherit; font-size: 13px;
  transition: all 0.12s;
}
.deadline-item:hover { border-color: var(--color-primary); background: #f9fafb; transform: translateX(2px); }
.deadline-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.deadline-dot.is-warranty     { background: #dc2626; }
.deadline-dot.is-questionnaire { background: #f59e0b; }
.deadline-dot.is-notice        { background: #3b82f6; }
.deadline-date { font-weight: 700; color: #374151; white-space: nowrap; min-width: 70px; }
.deadline-label { flex: 1; color: #6b7280; }
.deadline-label strong { color: #111827; }
.deadline-days {
  font-size: 11px; font-weight: 700; white-space: nowrap;
  padding: 2px 7px; border-radius: 9999px;
}
.deadline-days.is-near { background: #fee2e2; color: #991b1b; }
.deadline-days.is-soon { background: #fef3c7; color: #92400e; }
.deadline-days.is-ok   { background: #f3f4f6; color: #6b7280; }

/* ----- #5 フィルター検索バー ----- */
.search-icon-wrap {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  pointer-events: none; color: #9ca3af;
}
.form-input.has-search-icon { padding-left: 34px; }

/* =====================================================================
   Phase A モバイル最適化
   ===================================================================== */

/* A-4: iOS Safari は 16px 未満の入力欄にフォーカスすると自動でズームインする。
   現場のスマホで号室・居住者名・確定日時などを入力する度に画面が拡大され、
   毎回ピンチで戻す必要が出るのを防ぐため、狭幅端末では全入力欄を16pxに引き上げる。
   （text-xs 等のユーティリティに勝てるよう !important を付与。checkbox/radio/file は除外） */
@media (max-width: 768px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
  select,
  textarea,
  .form-input,
  .eq-input {
    font-size: 16px !important;
  }
}

/* A-5: hover を持たないタッチ端末では、写真の操作オーバーレイ（前後移動・拡大・
   キャプション編集・削除）が opacity:0 のままで指では出せない。タッチ端末では
   オーバーレイを常時表示にし、写真を隠さないよう背景は透明・ボタンを右上に寄せる。
   各ボタンは自前の暗い円形背景を持つため写真の上でも視認できる。 */
@media (hover: none) {
  .photo-item .photo-overlay {
    opacity: 1;
    background: transparent;
    align-items: flex-start;
    justify-content: flex-end;
    align-content: flex-start;
    flex-wrap: wrap;
    padding: 4px;
    gap: 4px;
  }

  /* B-10: 案件一覧の行内アクション（編集・複製）は hover 表示のため、
     hoverの無いタッチ端末（タブレット横向き=md以上でテーブル表示になる）では
     永久に出せず操作に辿り着けなかった。タッチ端末では常時表示にする。 */
  .btn-row-action-extra {
    opacity: 1;
    pointer-events: auto;
  }
}

/* C-1: 二次情報が10〜11pxで、屋外や高齢の担当者には読みにくい。
   モバイルでは「読ませたい説明テキスト」の下限を12pxにする。
   ※ バッジ・丸数字・ヒートマップのセル（.acc-num/.acc-status/.deadline-days/.unit-icon 等）は
      固定サイズの中に収まっているため、拡大するとレイアウトが崩れる。あえて対象外にする。 */
@media (max-width: 768px) {
  .unit-stat .us-label,
  .unit-stat .us-pct,
  .phase-step .phase-meta,
  .doc-card .doc-meta,
  .doc-section-head .doc-section-meta,
  .proj-board-card-client,
  .unit-heatmap-legend,
  .acc-meta {
    font-size: 12px;
  }
}

/* B-8: 行内アクションのタッチターゲット確保。
   btn-sm は実高さ約28pxで、住戸一覧では「編集」と「削除」（破壊的）が隣接しており
   指の太い担当者が誤タップしやすかった。モバイルでは最低44pxを確保する。 */
@media (max-width: 768px) {
  .btn-sm,
  .btn-row-action {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 14px;
  }
  /* 破壊的操作は隣接ボタンから離す（誤タップ防止） */
  .btn-danger.btn-sm { margin-left: 6px; }

  /* B-15: 右下固定のFAB(60px)が最終行の削除ボタンやページ末の操作に重なるため、
     コンテンツ末尾にFAB分の余白を確保して被りをなくす。 */
  body { padding-bottom: 96px; }
}

/* ===== R20: 担当者の色ドット（カレンダー・マスタ共通） ===== */
.staff-dot {
  display: inline-block; width: 10px; height: 10px; flex-shrink: 0;
  border-radius: 9999px; background: var(--color-primary-light);
}

/* ===== R20: カレンダー ===== */
.cal-filter > summary.cal-filter-summary {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; list-style: none;
  font-weight: 700; color: #374151; font-size: 14px;
  min-height: 32px;
}
.cal-filter > summary.cal-filter-summary::-webkit-details-marker { display: none; }
.cal-filter > summary.cal-filter-summary::before {
  content: '\25B8'; color: #9ca3af; transition: transform 0.15s;
}
.cal-filter[open] > summary.cal-filter-summary::before { transform: rotate(90deg); }

.cal-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
}
.cal-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cal-nav-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; padding: 0 10px;
  border: 1px solid #d1d5db; border-radius: 8px;
  background: #fff; color: #374151; font-size: 15px; font-weight: 600;
}
.cal-nav-btn:hover { background: #f9fafb; border-color: var(--color-primary); }
.cal-nav-today { font-size: 13px; }
.cal-heading { font-size: 17px; font-weight: 700; color: #111827; margin-left: 6px; }

.cal-viewswitch { display: inline-flex; border: 1px solid #d1d5db; border-radius: 8px; overflow: hidden; }
.cal-view-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 48px; min-height: 44px;
  background: #fff; color: #374151; font-size: 14px; font-weight: 600;
  border-right: 1px solid #e5e7eb;
}
.cal-view-btn:last-child { border-right: none; }
.cal-view-btn:hover { background: #f9fafb; }
.cal-view-btn.is-active { background: var(--color-primary); color: #fff; }

/* 工期の帯 */
.cal-spans { display: flex; flex-wrap: wrap; gap: 6px; }
.cal-span {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 9999px;
  border: 1px solid #cbd5e1; font-size: 12px; color: #111827;
}

/* 月ビュー */
.cal-month { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-dow {
  padding: 6px 4px; text-align: center;
  font-size: 12px; font-weight: 700; color: #6b7280;
  background: #f8fafc; border-bottom: 1px solid #e5e7eb;
}
.cal-dow.is-sun { color: #dc2626; }
.cal-dow.is-sat { color: #2563eb; }

.cal-day {
  min-height: 96px; padding: 4px;
  border-right: 1px solid #f1f5f9; border-bottom: 1px solid #f1f5f9;
  background: #fff;
  min-width: 0;
}
.cal-day.is-out { background: #fafafa; }
.cal-day.is-out .cal-day-num { color: #cbd5e1; }
.cal-day.is-today { background: #eff6ff; }
.cal-day.is-today .cal-day-num { background: var(--color-primary); color: #fff; }
.cal-day.is-idle {
  background-image: repeating-linear-gradient(45deg, #f8fafc 0 6px, #eef2f7 6px 12px);
}
.cal-day-num {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 24px; padding: 0 4px;
  border-radius: 9999px;
  font-size: 12px; font-weight: 700; color: #374151;
}
.cal-day.is-sun .cal-day-num { color: #dc2626; }
.cal-day.is-sat .cal-day-num { color: #2563eb; }
.cal-day.is-today .cal-day-num { color: #fff; }
.cal-day-list { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.cal-chip {
  display: block; padding: 2px 5px; border-radius: 4px;
  font-size: 11px; line-height: 1.4; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-chip:hover { filter: brightness(1.12); }
.cal-more { display: block; font-size: 10px; color: #6b7280; padding-left: 4px; }
.cal-more:hover { color: var(--color-primary); text-decoration: underline; }
.cal-idle-tag { font-size: 10px; color: #94a3b8; padding-left: 4px; }
.cal-day-dots { display: none; }

/* 週ビュー */
table.cal-week { width: 100%; border-collapse: collapse; }
table.cal-week th, table.cal-week td {
  border: 1px solid #e5e7eb; vertical-align: top; padding: 4px;
}
table.cal-week thead th {
  background: #f8fafc; font-size: 12px; font-weight: 700; color: #374151;
  text-align: center; white-space: nowrap; padding: 8px 4px;
}
table.cal-week thead th.is-sun a { color: #dc2626; }
table.cal-week thead th.is-sat a { color: #2563eb; }
table.cal-week thead th.is-today { background: #dbeafe; }
table.cal-week td.is-today { background: #eff6ff; }
table.cal-week td { min-width: 132px; }
.cal-week-slotcol {
  position: sticky; left: 0; z-index: 2;
  background: #f8fafc !important;
  width: 110px; min-width: 110px;
  font-size: 11px; font-weight: 700; color: #4b5563;
  text-align: left; vertical-align: middle !important;
}

/* イベント1件（週・日・アジェンダ共通） */
.cal-ev {
  display: block; padding: 6px 8px; margin-bottom: 4px;
  background: #fff; border: 1px solid #e5e7eb; border-left: 3px solid var(--color-primary-light);
  border-radius: 6px; min-height: 44px;
}
.cal-ev:hover { background: #f9fafb; border-color: #cbd5e1; }
.cal-ev-title { display: block; font-size: 13px; font-weight: 600; color: #111827; line-height: 1.35; }
.cal-ev-sub   { display: block; font-size: 11px; color: #6b7280; line-height: 1.35; margin-top: 2px; }
.cal-ev-milestone { background: #fafafa; }

/* 日ビュー */
.cal-day-slot { margin-bottom: 16px; }
.cal-day-slot:last-child { margin-bottom: 0; }
.cal-day-slot-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 700; color: #374151;
  padding-bottom: 4px; margin-bottom: 8px; border-bottom: 1px solid #e5e7eb;
}
.cal-day-slot-label span { font-size: 11px; font-weight: 400; color: #9ca3af; }

/* スマホ用アジェンダ（PCでは隠す） */
.cal-agenda { display: none; }
.cal-agenda-day { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid #f1f5f9; }
.cal-agenda-date {
  flex: 0 0 76px; font-size: 12px; font-weight: 700; color: #374151; padding-top: 6px;
}
.cal-agenda-date.is-today { color: var(--color-primary); }
.cal-agenda-items { flex: 1 1 auto; min-width: 0; }

/* 凡例 */
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.cal-legend-item { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: #4b5563; }
.cal-legend-sep { width: 100%; height: 0; border-top: 1px dashed #e5e7eb; margin: 2px 0; }

/* 日程未設定パネル */
.cal-missing-list { display: flex; flex-direction: column; gap: 8px; }
.cal-missing-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 8px; border: 1px solid #f1f5f9; border-radius: 8px; background: #fcfcfd;
}
.cal-missing-proj {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--color-primary);
}
.cal-missing-proj:hover { text-decoration: underline; }
.cal-missing-units { display: flex; flex-wrap: wrap; gap: 4px; }
.cal-missing-unit {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 36px; padding: 4px 8px;
  border: 1px solid #d1d5db; border-radius: 6px;
  font-size: 12px; color: #374151; background: #fff;
}
.cal-missing-unit:hover { border-color: var(--color-primary); color: var(--color-primary); }
.cal-missing-unit.is-more { border-style: dashed; color: #6b7280; }
.cal-missing-blank {
  display: inline-block; padding: 3px 8px; border-radius: 9999px;
  background: #fef3c7; color: #92400e; font-size: 11px; font-weight: 600;
}

/* ===== R20: モバイル最適化 ===== */
@media (max-width: 767px) {
  /* iOS Safari は 16px 未満の入力欄でフォーカス時に自動ズームする。
     住戸の入力を現場のスマホで行うため、ズームで画面がずれるのを止める。 */
  .form-input { font-size: 16px; }

  /* 月ビューは7列に文字を詰めると読めないので、色ドットだけにして
     詳細は下のアジェンダで見せる（タップで別ページに飛ばさない）。 */
  .cal-day { min-height: 58px; padding: 2px; }
  .cal-day-list { display: none; }
  .cal-day-dots {
    display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; margin-top: 2px;
  }
  .cal-dot { width: 6px; height: 6px; border-radius: 9999px; }
  .cal-dot-more { font-size: 9px; color: #6b7280; line-height: 1; }
  .cal-agenda { display: block; }

  .cal-heading { width: 100%; margin-left: 0; margin-top: 4px; }

  /* マスタ系のテーブルはカード表示に切り替える（横スクロールを避ける） */
  .master-table thead { display: none; }
  .master-table, .master-table tbody, .master-table tr, .master-table td { display: block; width: 100%; }
  .master-table tr {
    border: 1px solid #e5e7eb; border-radius: 12px;
    padding: 8px; margin-bottom: 10px; background: #fff;
  }
  .master-table td {
    border: none !important; padding: 6px 4px !important;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    text-align: right !important;
  }
  .master-table td::before {
    content: attr(data-label);
    font-size: 11px; font-weight: 700; color: #6b7280; flex-shrink: 0;
  }
  .master-table td[data-label="氏名"],
  .master-table td[data-label="保証タイトル"] { text-align: left !important; }
}

@media print {
  .cal-filter, .cal-toolbar, .filter-chips-bar, .cal-agenda { display: none !important; }
  .cal-day { min-height: 72px; }
}
