/* SUINOWA LETTER — 共通スタイル
   濃紺 #102847 / 文字 #18314E / 背景 #F4F7FA / 白カード
   スマホ（とくに LINE 内ブラウザ）優先・主要ボタン 48px 以上・横スクロールなし */

:root {
  --navy: #102847;
  --navy-soft: #1d3c63;
  --ink: #18314e;
  --ink-muted: #5b6f86;
  --bg: #f4f7fa;
  --card: #ffffff;
  --line: #dfe7f0;
  --accent: #c9a227;
  --notice: #f7f1de;
  --danger: #b3261e;
  --danger-bg: #fdeceb;
  --ok: #1d6f4b;
  --ok-bg: #e8f4ee;
  --warn-bg: #fff7e0;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 6px 20px rgba(16, 40, 71, 0.07);
  --tap: 48px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

body { overflow-x: hidden; }

img { max-width: 100%; height: auto; }

a { color: var(--navy-soft); }

button, input, select, textarea { font-family: inherit; font-size: 16px; color: var(--ink); }

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: 0.01em; }

.app { max-width: 720px; margin: 0 auto; padding-bottom: calc(84px + var(--safe-bottom)); }

/* ---------- ヘッダー ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--navy);
  color: #fff;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; flex-direction: column; line-height: 1.25; }
.brand-mark { font-family: "Times New Roman", Georgia, serif; letter-spacing: 0.18em; font-size: 12px; opacity: 0.82; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: 0.04em; }
.header-link { color: #fff; background: none; border: 0; font: inherit; font-size: 13px; text-decoration: none; padding: 10px 4px; min-height: var(--tap); display: inline-flex; align-items: center; cursor: pointer; }

/* ---------- マイページ見出し ---------- */
.identity {
  background: linear-gradient(160deg, var(--navy) 0%, #173a5e 100%);
  color: #fff;
  padding: 18px 18px 22px;
  border-radius: 0 0 22px 22px;
}
.identity-company { font-size: 13px; opacity: 0.8; margin-bottom: 2px; }
.identity-name { font-size: 21px; font-weight: 700; line-height: 1.4; }
.identity-note { font-size: 12px; opacity: 0.75; margin-top: 6px; }

/* ---------- カード・セクション ---------- */
main { padding: 16px; }
.section { margin-bottom: 20px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; gap: 8px; }
.section-title { font-size: 15px; font-weight: 700; color: var(--navy); letter-spacing: 0.02em; }
.section-link { font-size: 13px; color: var(--ink-muted); background: none; border: 0; padding: 8px 2px; cursor: pointer; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card + .card { margin-top: 12px; }
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.card-sub { font-size: 13px; color: var(--ink-muted); }

.muted { color: var(--ink-muted); font-size: 13px; }
.small { font-size: 12px; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--navy);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  width: 100%;
  transition: opacity 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-secondary { background: #fff; color: var(--navy); border-color: var(--navy); }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--line); }
.btn-danger { background: var(--danger); }
.btn-small { min-height: 40px; padding: 8px 14px; font-size: 14px; width: auto; border-radius: 999px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ---------- フォーム ---------- */
.field { margin-bottom: 18px; }
.label { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; margin-bottom: 8px; color: var(--navy); }
.label .req { background: var(--navy); color: #fff; font-size: 10px; padding: 2px 7px; border-radius: 999px; letter-spacing: 0.06em; }
.label .opt { background: #eef2f7; color: var(--ink-muted); font-size: 10px; padding: 2px 7px; border-radius: 999px; }
.input, .textarea, .select {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  line-height: 1.5;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.textarea { min-height: 120px; resize: vertical; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--navy-soft); box-shadow: 0 0 0 3px rgba(29, 60, 99, 0.12); }
.help { font-size: 12px; color: var(--ink-muted); margin-top: 6px; }
.field-error { font-size: 12px; color: var(--danger); margin-top: 6px; }
.input.has-error, .textarea.has-error { border-color: var(--danger); }
.counter { font-size: 11px; color: var(--ink-muted); text-align: right; margin-top: 4px; }

.choice-grid { display: grid; gap: 10px; }
.choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  min-height: var(--tap);
  background: #fff;
  cursor: pointer;
}
.choice input { margin-top: 4px; width: 20px; height: 20px; accent-color: var(--navy); flex: 0 0 auto; }
.choice.selected { border-color: var(--navy); background: #f2f6fb; }
.choice-label { font-size: 15px; font-weight: 600; }
.choice-note { font-size: 12px; color: var(--ink-muted); }

.checkbox-row { display: flex; gap: 10px; align-items: flex-start; }
.checkbox-row input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--navy); flex: 0 0 auto; }

/* ---------- タブ（モード切替） ---------- */
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: #e9eff6; padding: 5px; border-radius: 999px; margin-bottom: 14px; }
.segmented button {
  min-height: 42px;
  border: 0;
  background: transparent;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-muted);
  cursor: pointer;
}
.segmented button.active { background: #fff; color: var(--navy); box-shadow: 0 2px 8px rgba(16, 40, 71, 0.12); }

/* ---------- ステップ ---------- */
.steps { display: flex; align-items: center; gap: 6px; margin: 0 0 16px; }
.step-dot { flex: 1; height: 5px; border-radius: 999px; background: #dbe4ee; }
.step-dot.active { background: var(--navy); }
.step-dot.done { background: var(--navy-soft); }
.step-label { font-size: 12px; color: var(--ink-muted); margin-bottom: 8px; letter-spacing: 0.04em; }

/* ---------- リスト ---------- */
.list { display: flex; flex-direction: column; gap: 12px; }
.item {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 15px 16px;
}
.item-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.item-person { font-size: 16px; font-weight: 700; line-height: 1.45; }
.item-company { font-size: 12px; color: var(--ink-muted); margin-top: 2px; }
.item-meta { font-size: 12px; color: var(--ink-muted); margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px 12px; }
.item-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.chip { display: inline-flex; align-items: center; white-space: nowrap; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: #eef2f7; color: var(--ink-muted); letter-spacing: 0.02em; }
.chip-status-received, .chip-status-address_check, .chip-status-drafting { background: #eef2f7; color: var(--navy-soft); }
.chip-status-draft { background: var(--notice); color: #7a5a05; }
.chip-status-approved, .chip-status-processing { background: var(--ok-bg); color: var(--ok); }
.chip-status-sent { background: #e6eefc; color: #1a3f85; }
.chip-status-cancelled { background: #f1f0ef; color: #6b6b6b; }
.chip-warn { background: var(--warn-bg); color: #8a5a00; }

/* ---------- 空状態 ---------- */
.empty { text-align: center; padding: 32px 18px; color: var(--ink-muted); font-size: 14px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.empty-title { font-weight: 700; color: var(--navy); margin-bottom: 6px; font-size: 15px; }

/* ---------- 下部ナビ ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  max-width: 720px;
  margin: 0 auto;
}
.tabbar button {
  border: 0;
  background: none;
  min-height: 58px;
  padding: 8px 4px 10px;
  font-size: 11px;
  color: var(--ink-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}
.tabbar button .tab-icon { font-size: 20px; line-height: 1; }
.tabbar button.active { color: var(--navy); font-weight: 700; }

/* ---------- 固定フッター（フォーム） ---------- */
.footer-fixed {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + var(--safe-bottom));
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
}
.footer-fixed .btn { flex: 1; }

/* ---------- 通知・アラート ---------- */
.alert { border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13px; line-height: 1.6; margin-bottom: 14px; }
.alert-info { background: #eef4fb; color: var(--navy-soft); }
.alert-warn { background: var(--warn-bg); color: #7a5a05; border: 1px solid #f0dfae; }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #f3c6c3; }
.alert-ok { background: var(--ok-bg); color: var(--ok); }

.badge-low { display: inline-flex; align-items: center; gap: 4px; background: var(--warn-bg); color: #8a5a00; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.badge-ok { display: inline-flex; align-items: center; gap: 4px; background: var(--ok-bg); color: var(--ok); font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.confidence-bar { height: 4px; border-radius: 999px; background: #e9eef5; overflow: hidden; margin-top: 6px; }
.confidence-bar span { display: block; height: 100%; background: var(--ok); }
.confidence-bar.low span { background: var(--accent); }

/* ---------- OCR ---------- */
.photo-drop {
  border: 2px dashed #c6d4e4;
  border-radius: var(--radius);
  background: #fbfdff;
  padding: 22px 16px;
  text-align: center;
}
.photo-drop strong { display: block; font-size: 15px; color: var(--navy); margin-bottom: 4px; }
.preview-wrap { position: relative; border-radius: var(--radius); overflow: hidden; background: #0e1c2e; }
.preview-wrap img { display: block; width: 100%; max-height: 320px; object-fit: contain; }
.ocr-status { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-muted); padding: 10px 0; }
.spinner { width: 20px; height: 20px; border: 2px solid #d8e2ee; border-top-color: var(--navy); border-radius: 50%; animation: spin 0.9s linear infinite; flex: 0 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.candidate-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.candidate { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 12px; font-size: 13px; cursor: pointer; min-height: 36px; }
.candidate.active { border-color: var(--navy); background: #f2f6fb; font-weight: 700; }

/* ---------- モーダル ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 25, 43, 0.55);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal {
  background: #fff;
  width: 100%;
  max-width: 720px;
  border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(20px + var(--safe-bottom));
  max-height: 92vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease;
}
@keyframes slideUp { from { transform: translateY(18px); opacity: 0.6; } to { transform: translateY(0); opacity: 1; } }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }

/* ---------- サマリー（確認画面） ---------- */
.summary { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.summary-row { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.summary-row:last-child { border-bottom: 0; }
.summary-key { flex: 0 0 92px; color: var(--ink-muted); font-size: 12px; padding-top: 2px; }
.summary-val { flex: 1; white-space: pre-wrap; word-break: break-word; }

.draft-box { background: #fbfcfe; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; white-space: pre-wrap; font-size: 15px; line-height: 1.9; }

/* ---------- トースト ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%);
  background: rgba(16, 40, 71, 0.94);
  color: #fff;
  font-size: 14px;
  padding: 12px 18px;
  border-radius: 999px;
  z-index: 80;
  max-width: min(90vw, 560px);
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* ---------- 管理画面（PC） ---------- */
.admin-shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; background: var(--bg); }
.admin-side { background: var(--navy); color: #fff; padding: 22px 18px; }
.admin-side .brand-name { font-size: 18px; }
.admin-side nav { margin-top: 24px; display: flex; flex-direction: column; gap: 4px; }
.admin-side nav button { background: none; border: 0; color: rgba(255, 255, 255, 0.78); text-align: left; padding: 12px 10px; border-radius: 10px; font-size: 14px; cursor: pointer; }
.admin-side nav button.active { background: rgba(255, 255, 255, 0.12); color: #fff; font-weight: 700; }
.admin-main { padding: 26px 30px 60px; max-width: 1180px; }
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.admin-title { font-size: 20px; font-weight: 700; color: var(--navy); }
.admin-panel { background: #fff; border-radius: 14px; box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters .input, .filters .select { min-height: 42px; padding: 8px 12px; width: auto; min-width: 160px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; color: var(--ink-muted); font-weight: 600; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 12px; white-space: nowrap; }
.table td { padding: 12px 8px; border-bottom: 1px solid #eef3f8; vertical-align: top; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover { background: #f7fafd; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; font-size: 13px; }
.detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
.kv { display: grid; grid-template-columns: 116px 1fr; gap: 8px; font-size: 13px; padding: 7px 0; border-bottom: 1px dashed #edf2f7; }
.kv dt { color: var(--ink-muted); font-size: 12px; }
.kv dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.card-thumb { width: 100%; border-radius: 10px; border: 1px solid var(--line); background: #f7fafc; display: block; }
.timeline { font-size: 12px; color: var(--ink-muted); display: flex; flex-direction: column; gap: 6px; }
.tag { display: inline-block; background: #eef2f7; color: var(--ink-muted); border-radius: 6px; padding: 1px 7px; font-size: 11px; margin-right: 6px; }

/* ---------- レスポンシブ ---------- */
@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side { display: flex; align-items: center; gap: 12px; padding: 12px 14px; overflow-x: auto; }
  .admin-side nav { margin: 0; flex-direction: row; }
  .admin-main { padding: 16px 14px 80px; }
  .detail-grid { grid-template-columns: 1fr; }
  .table { display: block; overflow-x: auto; }
}

@media (min-width: 721px) {
  .app { box-shadow: 0 0 40px rgba(16, 40, 71, 0.06); min-height: 100vh; background: var(--bg); }
  .tabbar { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
