/* ===== フォント ===== */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;500;700;900&display=swap');

/* ===== CSS変数 ===== */
:root {
  --bg: #FDF3E8;
  --surface: #FFFFFF;
  --surface2: #FBF0E4;
  --border: #E8C89A;
  --primary: #C8721A;
  --primary-light: #E08828;
  --accent: #e85d26;
  --gold: #d4a017;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --text: #1a202c;
  --text2: #4a5568;
  --text3: #8a9bb0;
  --nav-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ===== リセット ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}

/* ===== トップバー ===== */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: calc(56px + var(--safe-top));
  padding-top: var(--safe-top);
  background: var(--primary);
  display: flex;
  align-items: center;
  padding-left: 16px;
  padding-right: 16px;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,.2);
}

.topbar-title {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .04em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.topbar-sub {
  font-size: .65rem;
  color: rgba(255,255,255,.6);
  margin-top: 1px;
}

.topbar-btn {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: .75rem;
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 700;
  cursor: pointer;
  margin-left: 6px;
}

/* ===== 同期ステータス ===== */
.sync-status {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-right: 8px;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.sync-dot.online {
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74, 222, 128, .6);
}

.sync-dot.offline {
  background: #f87171;
  box-shadow: 0 0 6px rgba(248, 113, 113, .6);
}

.sync-label {
  font-size: .6rem;
  color: rgba(255,255,255,.7);
  font-weight: 500;
}

/* ===== メインコンテンツ ===== */
.main-content {
  position: fixed;
  top: calc(56px + var(--safe-top));
  left: 0; right: 0;
  bottom: calc(var(--nav-h) + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

/* ===== フッターナビ ===== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  background: var(--primary);
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 16px rgba(0,0,0,.2);
  padding-bottom: var(--safe-bottom);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  color: rgba(255,255,255,.5);
  font-size: .62rem;
  font-weight: 500;
  letter-spacing: .04em;
  transition: color .2s, background .2s;
  padding: 6px 0;
  border: none;
  background: transparent;
  font-family: 'Noto Sans JP', sans-serif;
}

.nav-item.active {
  color: #fff;
  background: rgba(255,255,255,.12);
  border-top: 2px solid var(--accent);
}

.nav-item .nav-icon {
  font-size: 1.35rem;
  line-height: 1;
}

.nav-item:active {
  transform: scale(.96);
  opacity: .85;
}

/* ===== カード ===== */
.card {
  background: var(--surface);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 6px rgba(0,0,0,.07);
}

.card-head {
  font-size: .72rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: .1em;
  text-transform: uppercase;
  padding-bottom: 10px;
  margin-bottom: 14px;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ===== ボタン ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: .88rem;
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: opacity .15s, transform .1s;
  letter-spacing: .02em;
  -webkit-appearance: none;
}

.btn:active {
  transform: translateY(2px);
  box-shadow: inset 0 2px 4px rgba(0,0,0,.3);
  opacity: .9;
}

.btn-full { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-outline { background: transparent; color: var(--text2); border: 1.5px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-gold { background: var(--gold); color: #fff; }
.btn-sm { padding: 7px 13px; font-size: .76rem; border-radius: 8px; }
.btn-lg { padding: 16px 24px; font-size: 1rem; border-radius: 12px; min-height: 48px; }

/* ===== 入力欄 ===== */
.field {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: .88rem;
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .2s;
}

.field:focus {
  border-color: var(--primary-light);
}

.field-label {
  font-size: .7rem;
  font-weight: 700;
  color: var(--text3);
  margin-bottom: 6px;
  display: block;
}

/* ===== タグチップ ===== */
.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all .15s;
}

.tag-chip.active {
  border-color: var(--primary);
}

.tag-chip:active {
  transform: scale(.96);
  opacity: .85;
}

/* ===== ステータスバッジ ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: .68rem;
  font-weight: 700;
}

.badge-pending { background: #e2e8f0; color: #64748b; }
.badge-travel { background: #dbeafe; color: #2563eb; }
.badge-working { background: #dcfce7; color: #16a34a; }
.badge-done { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.badge-hold { background: #fef3c7; color: #d97706; }
.badge-urgent { background: #fef2f2; color: #dc2626; }

/* ===== サマリーカード ===== */
.summary-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.summary-item {
  flex: 1;
  background: var(--surface);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}

.summary-value {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--primary);
  line-height: 1.2;
}

.summary-label {
  font-size: .6rem;
  font-weight: 700;
  color: var(--text3);
  margin-top: 2px;
}

/* ===== 案件カード ===== */
.job-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: 0 1px 6px rgba(0,0,0,.07);
  cursor: pointer;
  transition: transform .1s;
  animation: fadeUp .25s ease;
}

.job-card:active {
  transform: scale(.98);
}

.job-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.job-card-time {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text);
}

.job-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.job-card-customer {
  font-size: .92rem;
  font-weight: 700;
  color: var(--text);
}

.job-card-address {
  font-size: .72rem;
  color: var(--text2);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.job-card-type {
  font-size: .7rem;
  color: var(--text3);
  font-weight: 500;
}

.job-card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.job-card-meta {
  font-size: .65rem;
  color: var(--text3);
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ===== 空状態 ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text3);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-state-text {
  font-size: .88rem;
  font-weight: 500;
}

.empty-state-sub {
  font-size: .75rem;
  margin-top: 6px;
}

/* ===== セクションタイトル ===== */
.section-title {
  font-size: .7rem;
  font-weight: 700;
  color: var(--text3);
  letter-spacing: .08em;
  margin-bottom: 10px;
  margin-top: 8px;
}

/* ===== モーダル ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 24px 16px;
  padding-bottom: calc(24px + var(--safe-bottom));
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp .3s ease;
}

.modal-title {
  font-size: .92rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  text-align: center;
}

/* ===== 確認ダイアログ ===== */
.confirm-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.confirm-box {
  background: var(--surface);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 320px;
  text-align: center;
  animation: fadeUp .2s ease;
}

.confirm-msg {
  font-size: .88rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 20px;
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  gap: 10px;
}

.confirm-actions .btn {
  flex: 1;
}

/* ===== PWAインストールバナー ===== */
.install-banner {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 8px);
  left: 12px; right: 12px;
  background: var(--surface);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  z-index: 50;
  font-size: .78rem;
  font-weight: 500;
  color: var(--text2);
  animation: slideUp .3s ease;
}

.install-banner span:first-child {
  flex: 1;
}

/* ===== ページ遷移中の案件未選択メッセージ ===== */
.no-job-selected {
  text-align: center;
  padding: 48px 24px;
  color: var(--text3);
}

.no-job-selected-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.no-job-selected-text {
  font-size: .85rem;
  font-weight: 500;
  margin-bottom: 16px;
}

/* ===== フィルタ行 ===== */
.filter-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

/* ===== 写真グリッド ===== */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.photo-card {
  background: var(--surface);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  cursor: pointer;
  transition: transform .1s;
  animation: fadeUp .25s ease;
}

.photo-card:active {
  transform: scale(.96);
}

.photo-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
}

.photo-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-tag-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  color: #fff;
  font-size: .55rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
}

.photo-card-info {
  padding: 6px 8px;
}

.photo-card-time {
  font-size: .62rem;
  color: var(--text3);
  font-weight: 500;
}

.photo-card-note {
  font-size: .6rem;
  color: var(--text2);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 2px;
}

/* ===== 報告書プレビュー ===== */
.report-preview {
  background: #fff;
  border-radius: 12px;
  padding: 20px 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,.1);
  border: 1px solid var(--border);
}

.report-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--primary);
}

.report-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 8px;
}

.report-title {
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--primary);
}

.report-no {
  font-size: .7rem;
  color: var(--text3);
  font-weight: 500;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: .82rem;
}

.report-table th {
  text-align: left;
  width: 80px;
  padding: 6px 8px;
  color: var(--text3);
  font-weight: 700;
  font-size: .72rem;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.report-table td {
  padding: 6px 8px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.report-section-title {
  font-size: .78rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  padding: 5px 10px;
  border-radius: 6px;
  margin-bottom: 10px;
  margin-top: 16px;
}

.report-photos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.report-photo-item {
  text-align: center;
}

.report-photo-img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.report-photo-label {
  font-size: .6rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 4px;
}

.report-photo-note {
  font-size: .55rem;
  color: var(--text3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.report-text {
  font-size: .82rem;
  color: var(--text);
  line-height: 1.7;
  white-space: pre-wrap;
  padding: 8px 0;
}

.report-checklist {
  padding: 4px 0;
}

.report-check-item {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: .78rem;
  padding: 4px 0;
}

.report-footer {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: .65rem;
  color: var(--text3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ===== テンプレートアイテム ===== */
.template-item {
  background: var(--surface2);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}

/* ===== メモアイテム ===== */
.memo-item {
  background: var(--surface2);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  animation: fadeUp .2s ease;
}

/* ===== 録音インジケーター ===== */
.recording-indicator {
  display: inline-block;
  width: 12px;
  height: 12px;
  background: var(--danger);
  border-radius: 50%;
  margin-bottom: 4px;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .4; transform: scale(1.3); }
}

/* ===== アニメーション ===== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== ユーティリティ ===== */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ===== SuidouWorks Series ===== */
.series-item-desc-col { font-size: .8rem; color: var(--text2); flex: 1; margin: 0 12px; }
@media (max-width: 640px) { .series-item-desc-col { display: none; } }
