/* PET配送 配車進捗管理 - 共通スタイル（最小版） */

:root {
  --color-bg: #f5f7fa;
  --color-surface: #ffffff;
  --color-text: #1f2937;
  --color-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-primary: #1e88e5;
  --color-primary-dark: #1565c0;
  --color-secondary: #43a047;
  --color-danger: #e53935;
  --color-warning: #fdd835;

  /* ステータスカラー（設計書 04 §5） */
  --status-contract: #e0e0e0;
  --status-home: #1e88e5;
  --status-lab: #4dd0e1;
  --status-arrived: #fdd835;
  --status-entered: #43a047;

  --radius: 8px;
  --space: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI",
               "Meiryo", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space);
}

h1 { font-size: 24px; margin: 0 0 12px; }
h2 { font-size: 20px; margin: 24px 0 12px; }

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== トップ画面 ===== */
.hero {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
}
.hero .lead { color: var(--color-muted); margin-bottom: 24px; }
.role-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 360px;
  margin: 0 auto;
}
.env-note {
  margin-top: 24px;
  font-size: 12px;
  color: var(--color-muted);
}

/* ===== ボタン ===== */
.btn {
  display: inline-block;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-align: center;
  min-height: 44px;
  text-decoration: none;
}
.btn-lg { font-size: 18px; padding: 16px 24px; min-height: 56px; }
.btn-primary   { background: var(--color-primary);   color: #fff; }
.btn-primary:hover   { background: var(--color-primary-dark); text-decoration: none; }
.btn-secondary { background: var(--color-secondary); color: #fff; }
.btn-secondary:hover { opacity: 0.92; text-decoration: none; }
.btn-danger    { background: var(--color-danger);    color: #fff; }
.btn-muted     { background: #cfd8dc; color: #1f2937; }
.w-full        { width: 100%; }
.btn-row       { display: flex; gap: 6px; flex-wrap: wrap; }

/* 配車表掲示（ドライバーホーム下部） */
.board-link { display: block; }
.board-image {
  width: 100%;
  height: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.board-admin { margin: 8px 0 12px; }
.board-image-admin { max-width: 480px; }

/* ===== ログインフォーム ===== */
.form-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 28px 24px;
  max-width: 420px;
  margin: 32px auto;
}
.form-card h1 { text-align: center; margin-bottom: 20px; }
.form-field { margin-bottom: 16px; }
.form-field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 14px;
}
.form-field input[type="text"],
.form-field input[type="password"],
.form-field input[type="number"],
.form-field input[type="email"],
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: #fff;
  min-height: 44px;
}
.form-field input:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}
.form-error {
  background: #fdecea;
  color: #b71c1c;
  border: 1px solid #f5c2c0;
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-weight: 600;
}
.form-foot {
  margin-top: 20px;
  text-align: center;
  font-size: 14px;
}

/* ===== ページヘッダ（ダッシュボード共通） ===== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}
.page-header h1 { margin: 0 0 4px; }
.muted { color: var(--color-muted); margin: 0; font-size: 14px; }
.inline-form { display: inline; margin: 0; }

/* ===== カード（ダッシュボード等） ===== */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px 20px 16px;
  margin-bottom: 16px;
}
.card h2 { margin-top: 0; }
.menu-list {
  list-style: disc inside;
  margin: 0;
  padding-left: 0;
  color: var(--color-muted);
}
.menu-list li { padding: 2px 0; }
.kv {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 4px 16px;
  margin: 0;
}
.kv dt { color: var(--color-muted); }
.kv dd { margin: 0; }

/* ===== ボタン拡張 ===== */
.btn-sm   { padding: 8px 12px; font-size: 14px; min-height: 36px; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== フラッシュメッセージ ===== */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-weight: 600;
}
.flash-ok { background: #e8f5e9; color: #1b5e20; border: 1px solid #a5d6a7; }

/* ===== テーブル ===== */
.table-wrap { overflow-x: auto; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th, .data-table td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--color-border);
}
.data-table th {
  background: #f0f3f7;
  font-weight: 700;
  color: #334155;
  white-space: nowrap;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr.row-inactive td { color: var(--color-muted); background: #fafafa; }
.data-table tr.row-inactive code { opacity: 0.7; }
.data-table .small { font-size: 12px; }
.data-table code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.col-actions { white-space: nowrap; }
.col-actions .btn, .col-actions form { margin-right: 4px; }

/* ===== バッジ ===== */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge-ok  { background: #e8f5e9; color: #1b5e20; }
.badge-off { background: #ffebee; color: #b71c1c; }

/* ===== フォーム拡張 ===== */
.form-card-wide { max-width: 640px; }
.form-check label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.form-check input[type="checkbox"] { width: 20px; height: 20px; }
.req { color: var(--color-danger); margin-left: 4px; }
.field-help { color: var(--color-muted); font-size: 13px; margin: 4px 0 0; }
.field-error { color: #b71c1c; font-size: 13px; margin: 4px 0 0; font-weight: 600; }
.form-note {
  background: #f0f7ff;
  border: 1px solid #bbdefb;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  color: #1565c0;
  margin: 8px 0 16px;
}
.form-warning {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  color: #6b4f00;
  font-size: 14px;
}
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ===== 空状態 ===== */
.empty-state { text-align: center; padding: 32px; }
.empty-state p { color: var(--color-muted); margin-bottom: 16px; }

/* ===== メニュータイル（ダッシュボード） ===== */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.menu-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  background: #f0f7ff;
  border: 1px solid #bbdefb;
  border-radius: var(--radius);
  color: var(--color-text);
  text-decoration: none;
  transition: background 0.15s ease;
}
.menu-tile:hover { background: #e1f0ff; text-decoration: none; }
.menu-tile-title { font-weight: 700; font-size: 16px; }
.menu-tile-desc  { font-size: 13px; color: var(--color-muted); }
.menu-tile-disabled { background: #f5f5f5; border-color: var(--color-border); pointer-events: none; opacity: 0.7; }
.menu-tile-disabled .menu-tile-title { color: var(--color-muted); }

/* ===== CSV プレビュー ===== */
.summary-row {
  display: flex;
  gap: 24px;
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.summary-label { color: var(--color-muted); margin-right: 4px; font-size: 13px; }
.summary-value { font-weight: 700; font-size: 22px; }
.summary-ok { color: #1b5e20; }
.summary-ng { color: #b71c1c; }

.preview-table .row-ng td { background: #fff5f5; }
.preview-table .row-ng .error-list { margin: 0; padding-left: 18px; color: #b71c1c; font-size: 13px; }
.preview-table .row-ng .error-list li { padding: 2px 0; }
.preview-table .row-ok td { background: #ffffff; }
.cell-wrap { max-width: 240px; word-break: break-word; }

.form-actions-bottom {
  margin-top: 16px;
  padding: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

/* =========================================================
   ドライバー側スタイル（スマホ最適化）
   ========================================================= */

.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;
}

.driver-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.driver-header h1 { margin: 4px 0; font-size: 22px; }
.back-link { display: inline-block; margin-bottom: 4px; text-decoration: none; }
.back-link:hover { text-decoration: underline; }

.date-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.date-row h2 { margin: 0; font-size: 18px; }
.date-form { display: flex; gap: 8px; align-items: center; }
.date-form input[type="date"] {
  padding: 8px 10px;
  font-size: 15px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  min-height: 38px;
}

/* 自動更新トグル行 */
.autorefresh-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--color-border);
}
.autorefresh-status { font-size: 14px; font-weight: 600; }
.autorefresh-status.is-on { color: var(--color-secondary); }
.autorefresh-status.is-off { color: var(--color-muted); }

/* ===== 5つの進捗ボタン（ドライバートップ） ===== */
.status-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.status-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-radius: var(--radius);
  font-size: 20px;
  font-weight: 700;
  text-decoration: none;
  /* 進捗メニューのボタンは全て青に統一（ステータス別の色分けはしない） */
  background: var(--color-primary);
  color: #ffffff;
  min-height: 64px;
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  transition: transform 0.06s ease;
}
.status-btn:hover { text-decoration: none; transform: translateY(-1px); }
.status-btn:active { transform: translateY(0); }
.status-btn-arrow { font-size: 26px; font-weight: 400; opacity: 0.7; }

/* ===== ステータスカラー（設計書 04 §5） ===== */
.status-contract { background: var(--status-contract); color: #1f2937; }
.status-home     { background: var(--status-home);     color: #ffffff; }
.status-lab      { background: var(--status-lab);      color: #1f2937; }
.status-arrived  { background: var(--status-arrived);  color: #1f2937; }
.status-entered  { background: var(--status-entered);  color: #ffffff; }

/* ===== ステータスチップ（タイトル横） ===== */
.status-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.status-chip {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 700;
}

/* ===== 配車カード（ドライバートップ / ステータス別一覧） ===== */
.dispatch-list { display: flex; flex-direction: column; gap: 12px; }
.dispatch-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.dispatch-card.is-done { border-left: 4px solid var(--status-entered); background: #f8fbf8; }
.dispatch-card.is-pending { border-left: 4px solid #cfd8dc; }
.dispatch-card-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 4px;
}
.dispatch-time {
  font-size: 22px; font-weight: 700; color: var(--color-primary);
}
.dispatch-time-sep { margin: 0 1px; font-weight: 700; }
/* 便番号（1便/2便…）をはっきり視認できるバッジに */
.dispatch-route {
  display: inline-block;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: var(--color-primary);
  padding: 3px 12px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.dispatch-hospital { font-size: 22px; margin: 4px 0 6px; line-height: 1.3; }
.dispatch-qty {
  display: inline-flex; align-items: baseline; gap: 4px;
  margin: 0 0 8px;
  padding: 4px 12px;
  background: #fff3e0;
  border: 1px solid #ffcc80;
  border-radius: 999px;
  color: #e65100;
  font-size: 15px;
}
.dispatch-qty-label { font-size: 12px; font-weight: 600; }
.dispatch-qty strong { font-size: 20px; font-weight: 700; line-height: 1; }
.dispatch-note {
  font-size: 13px; color: var(--color-muted); margin: 0 0 8px;
  background: #f8f9fa; padding: 6px 10px; border-radius: 6px;
}

.dispatch-action { margin-top: 12px; }
.recorded-label {
  margin: 0 0 8px;
  padding: 10px 12px;
  background: #e8f5e9;
  border-radius: var(--radius);
  font-weight: 600;
  color: #1b5e20;
}
.record-btn { font-size: 18px; min-height: 56px; }

/* ===== 進捗ストリップ（home の各カード下） ===== */
.status-strip {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.status-pill {
  padding: 6px 4px;
  border-radius: 6px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 48px;
  justify-content: center;
}
.status-pill.is-pending { background: #f0f0f0 !important; color: #9e9e9e !important; }
.status-pill-time { font-size: 13px; font-weight: 700; }

/* ===== 再記録確認画面 ===== */
.confirm-card { padding: 24px; }
.confirm-header { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--color-border); }
.confirm-header h2 { margin: 0 0 4px; font-size: 22px; }
.confirm-existing {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}
.confirm-message { margin: 0 0 8px; font-size: 16px; }
.confirm-actions { display: flex; flex-direction: column; gap: 10px; }

/* =========================================================
   管理者進捗一覧（/admin/progress）
   ========================================================= */

/* セル色：未記録 + 5進捗（青→黄→橙→紫→緑のグラデーション）
   ※ 色だけに頼らず、必ず時刻 or 「未」を併記する設計（設計書 04 §5）。
   ※ ドライバー側で使う .status-* とは別系統。
*/
.cell-untouched         { background: #f5f5f5; color: #9e9e9e; }
.cell-contract_confirmed{ background: #bbdefb; color: #0d47a1; }   /* 青系 */
.cell-home_departed     { background: #fff59d; color: #5d4037; }   /* 黄系 */
.cell-lab_departed      { background: #ffcc80; color: #4e2700; }   /* 橙系 */
.cell-hospital_arrived  { background: #ce93d8; color: #4a148c; }   /* 紫系 */
.cell-entered_hospital  { background: #a5d6a7; color: #1b5e20; }   /* 緑系 */

/* 進捗一覧テーブル：セル */
.progress-table th { white-space: nowrap; }
.progress-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.progress-table .status-cell {
  text-align: center;
  font-weight: 700;
  padding: 12px 8px;
  white-space: nowrap;
}
.progress-table .status-cell-time { font-size: 15px; font-variant-numeric: tabular-nums; }
.progress-table .status-cell-empty { font-size: 13px; opacity: 0.7; }

/* 進捗セルの取り消しボタン（管理者のみ表示） */
.progress-table .clear-form {
  display: inline-block;
  margin: 0 0 0 4px;
  vertical-align: middle;
}
.progress-table .clear-btn {
  border: none;
  background: rgba(255,255,255,0.6);
  color: #b71c1c;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  opacity: 0.55;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.progress-table .clear-btn:hover {
  opacity: 1;
  background: #fff;
}

/* 現在状態バッジ */
.state-badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

/* 集計タイル */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.summary-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.summary-tile-label { font-size: 13px; font-weight: 600; opacity: 0.8; }
.summary-tile-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
/* 集計タイルは cell-* と組み合わせて背景色付き */
.summary-tile.cell-untouched,
.summary-tile.cell-contract_confirmed,
.summary-tile.cell-home_departed,
.summary-tile.cell-lab_departed,
.summary-tile.cell-hospital_arrived,
.summary-tile.cell-entered_hospital { border: none; }

/* =========================================================
   操作ログ画面（/admin/logs）
   ========================================================= */

.badge-info { background: #e3f2fd; color: #0d47a1; }

.filter-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
}
.filter-field { display: flex; flex-direction: column; gap: 4px; }
.filter-field label { font-size: 13px; font-weight: 600; color: var(--color-muted); }
.filter-field select,
.filter-field input[type="date"] {
  padding: 8px 10px;
  font-size: 15px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  min-height: 40px;
  background: #fff;
}
.filter-actions { display: flex; gap: 8px; align-items: end; }

.logs-table .logs-time {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  display: inline-block;
}
.cell-detail { max-width: 420px; }
.detail-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
  display: grid;
  gap: 2px;
}
.detail-list li { word-break: break-word; line-height: 1.4; }
.detail-key { color: var(--color-muted); font-weight: 600; margin-right: 4px; }
.detail-val { color: var(--color-text); }
.detail-pre {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  background: #f1f5f9;
  padding: 6px 8px;
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow: auto;
  margin: 0;
}
