/* カゴマッチ 共通スタイル
   配色は画面設計（高速道路の案内標識グリーン）に準拠。
   識別子（会社コード・ユーザーID・車番）は等幅で扱う。 */

:root {
  --bg: #f6f8f7;
  --surface: #ffffff;
  --surface-2: #eef2f0;
  --ink: #131c19;
  --muted: #5a6b64;
  --faint: #86948e;
  --line: #d8ded9;
  --line-strong: #b9c3bd;
  --accent: #0b6e4f;
  --accent-ink: #ffffff;
  --accent-soft: #e4efe9;
  --warn: #8f5407;
  --warn-soft: #fbf0dd;
  --danger: #9c2b23;
  --danger-soft: #fbe7e4;
  --info: #1f5d7a;
  --info-soft: #e5eff4;

  --font-ui: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic Medium", "Yu Gothic",
    "Noto Sans JP", Meiryo, system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

code, .u-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------- 認証画面 ---------------- */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.auth__card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 34px 30px 30px;
  box-shadow: 0 1px 2px rgba(19, 28, 25, .06), 0 10px 30px rgba(19, 28, 25, .06);
}

.auth__brand { text-align: center; margin-bottom: 22px; }
.auth__logo { font-size: 22px; font-weight: 700; letter-spacing: .04em; }
.auth__logo span { color: var(--accent); }
.auth__sub { font-size: 11.5px; color: var(--faint); letter-spacing: .06em; margin-top: 2px; }

.auth__form { display: flex; flex-direction: column; gap: 16px; }
.auth__lead { margin: 0 0 18px; font-size: 13px; line-height: 1.75; color: var(--muted); }

.field { display: flex; flex-direction: column; }
.field__label { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
.field__input {
  font: inherit;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}
.field__input--mono { font-family: var(--font-mono); }
.field__input:focus-visible { border-color: var(--accent); }
.field__help { font-size: 11.5px; color: var(--faint); margin-top: 4px; }
.field--invalid .field__input { border-color: var(--danger); background: var(--danger-soft); }

.alert {
  border-radius: 0 6px 6px 0;
  padding: 10px 13px;
  font-size: 12.5px;
  border-left: 3px solid currentColor;
}
.alert--danger { background: var(--danger-soft); color: var(--danger); }

.btn {
  font: inherit;
  font-weight: 700;
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn--block { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.btn--link {
  background: none;
  color: var(--accent);
  min-height: 0;
  padding: 0;
  font-size: 12.5px;
  font-weight: 400;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.auth__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--faint);
}

/* ---------------- 共通シェル ---------------- */
/* grid-template-rows を指定しないと、min-height の余りがヘッダー行にも配分される */
.shell { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: auto 1fr; min-height: 100vh; }
@media (max-width: 720px) { .shell { grid-template-columns: 1fr; } }

.shell__top {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.shell__logo { font-weight: 700; letter-spacing: .03em; white-space: nowrap; text-decoration: none; color: inherit; }
.shell__logo span { color: var(--accent); }
.shell__org {
  display: flex; flex-direction: column; line-height: 1.3;
  padding-left: 14px; border-left: 1px solid var(--line); min-width: 0;
}
.shell__org b { font-size: 13px; }
.shell__org code { font-size: 11px; color: var(--faint); }
.shell__spacer { flex: 1; }

.icon-btn {
  position: relative; display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 7px;
  border: 0; background: none; padding: 0; font: inherit; cursor: pointer;
  color: var(--muted); text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn__badge {
  position: absolute; top: 2px; right: 1px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
}

.shell__me { display: flex; align-items: center; gap: 9px; padding-left: 12px; border-left: 1px solid var(--line); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.shell__me-txt { display: flex; flex-direction: column; line-height: 1.3; }
.shell__me-txt b { font-size: 12.5px; }
.shell__me-txt span { font-size: 11px; color: var(--faint); }

.shell__nav {
  background: var(--surface-2);
  border-right: 1px solid var(--line);
  padding: 12px 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.nav-group {
  font-size: 10px; letter-spacing: .12em; font-weight: 700;
  color: var(--faint); padding: 14px 8px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 6px;
  font-size: 13px; color: var(--ink); text-decoration: none;
}
.nav-item:hover { background: rgba(11, 110, 79, .08); }
.nav-item--current { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.nav-item--todo { color: var(--faint); cursor: default; }
.nav-item--todo:hover { background: none; }
.nav-item__icon { flex: none; opacity: .55; }
.nav-item--current .nav-item__icon { opacity: 1; }
.nav-item--todo .nav-item__icon { opacity: .35; }

.shell__main { padding: 20px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.banner {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 15px; border-radius: 8px;
  border-left: 3px solid currentColor; font-size: 13px;
}
.banner b { display: block; font-size: 13.5px; margin-bottom: 1px; }
.banner--warn { background: var(--warn-soft); color: var(--warn); }
.banner--danger { background: var(--danger-soft); color: var(--danger); }
.banner--info { background: var(--info-soft); color: var(--info); }

.banner__action {
  font: inherit; font-size: 12.5px; font-weight: 700;
  margin-left: auto; padding: 6px 12px; white-space: nowrap;
  background: transparent; color: inherit; cursor: pointer;
  border: 1px solid currentColor; border-radius: 6px;
}
.banner__action:hover { background: rgba(255, 255, 255, .5); }

/* 操作結果の一時メッセージ */
.flash {
  padding: 11px 15px; border-radius: 8px; font-size: 13px;
  border-left: 3px solid currentColor;
}
.flash--success { background: var(--accent-soft); color: var(--accent); }
.flash--info { background: var(--info-soft); color: var(--info); }
.flash--warning { background: var(--warn-soft); color: var(--warn); }
.flash--error { background: var(--danger-soft); color: var(--danger); }

.page-head { display: flex; flex-direction: column; gap: 2px; }
.page-head__crumb { font-size: 11.5px; color: var(--faint); }
.page-head h1 { margin: 0; font-size: 20px; letter-spacing: -.01em; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 9px; padding: 18px 20px;
}
.card p { margin: 0; color: var(--muted); font-size: 14px; }
.card p + p { margin-top: 8px; }
.card--form { max-width: 460px; }
.card--form .auth__form { gap: 16px; }
.card--form h2 { margin: 0 0 14px; font-size: 13px; font-weight: 700; color: var(--muted); }

/* 積地・卸地に地図を2つ埋め込む案件フォームなど、横幅に余裕が欲しい画面向け。
   カード自体は画面幅いっぱいに広げつつ、個々の入力欄は読みやすい固定幅に留める。 */
.card--form-wide { max-width: 100%; }
.card--form-wide .field__input { max-width: 420px; }

.logout-form { display: inline; }

/* ---------------- 業務画面 ---------------- */
.page-head--row {
  flex-direction: row; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.page-head__actions { display: flex; gap: 8px; align-items: center; }
.page-head__crumb a { color: inherit; }

.btn--secondary {
  background: var(--surface); color: var(--accent);
  border: 1px solid var(--line-strong);
}
.btn--secondary:hover { background: var(--accent-soft); filter: none; }

.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.form-actions .btn { flex: 1; min-width: 150px; }
.field__optional {
  margin-left: 6px; font-weight: 400; font-size: 10.5px;
  color: var(--faint); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px;
}

.table-wrap {
  overflow-x: auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: 9px;
}
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 720px; }
/* 既定は折り返さない。金額や貨物種別が語中・桁中で割れるのを防ぐ。
   長い住所だけ .table__route で折り返しを許し、全体は overflow-x で逃がす。 */
.table th, .table td {
  text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table thead th {
  font-size: 11px; letter-spacing: .06em; color: var(--faint);
  background: var(--surface-2); font-weight: 700; white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table__num { text-align: right; }
/* 唯一の折り返し可能な列。ここが縮むことで他の列（金額・日時）が割れずに済む */
.table__route { color: var(--muted); white-space: normal; }

/* 案件の状態。色は意味に対応させ、アクセント色とは別系統にする */
.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
  background: var(--surface-2); color: var(--muted);
}
.pill--open, .pill--bidding { background: var(--accent-soft); color: var(--accent); }
.pill--contracted, .pill--in_transit { background: var(--info-soft); color: var(--info); }
.pill--cancelled { background: var(--danger-soft); color: var(--danger); }

.detail {
  display: grid; grid-template-columns: 150px 1fr; gap: 10px 20px; margin: 0;
  font-size: 14px;
}
@media (max-width: 560px) { .detail { grid-template-columns: 1fr; gap: 4px 0; } }
.detail dt { font-size: 12px; font-weight: 700; color: var(--muted); padding-top: 2px; }
.detail dd { margin: 0; }

.pager { display: flex; gap: 14px; align-items: center; font-size: 13px; color: var(--muted); }

.card--search { display: flex; flex-direction: column; gap: 14px; }
.search-form { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.search-form .field { flex: 1; min-width: 200px; }
.search-form__actions { display: flex; gap: 8px; padding-top: 22px; }
.search-form__save { border-top: 1px solid var(--line); padding-top: 14px; }

.btn--danger { background: var(--danger); color: #fff; }
.link-danger { color: var(--danger); margin-left: 12px; }
.caption { font-size: 12px; color: var(--faint); margin: 0; }

/* 一覧の行アクション（配車する・編集・削除など）。アイコン付きの小さなピル型ボタンで統一する */
.action-row { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.action-link {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 11px; border-radius: 999px;
  border: 1px solid transparent; background: var(--surface-2); color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 700; white-space: nowrap;
  text-decoration: none; cursor: pointer;
}
.action-link:hover { background: var(--line); color: var(--ink); }
.action-link__icon { flex: none; }
.action-link--accent { background: var(--accent-soft); color: var(--accent); }
.action-link--accent:hover { background: var(--accent); color: var(--accent-ink); }
.action-link--danger { background: var(--danger-soft); color: var(--danger); }
.action-link--danger:hover { background: var(--danger); color: #fff; }
.action-link--warn { background: var(--warn-soft); color: var(--warn); }
.action-link--warn:hover { background: var(--warn); color: #fff; }

.card__title { margin: 0 0 12px; font-size: 15px; font-weight: 700; }

/* 応募の状態。成約＝アクセント、却下・撤回＝控えめ */
.pill--bid-submitted { background: var(--info-soft); color: var(--info); }
.pill--bid-accepted { background: var(--accent-soft); color: var(--accent); }
.pill--bid-rejected, .pill--bid-withdrawn { background: var(--surface-2); color: var(--muted); }

/* 契約の状態。confirmed/cancelled は Job.Status と同じ語を使うため .pill--cancelled を共有する */
.pill--confirmed, .pill--fulfilled { background: var(--accent-soft); color: var(--accent); }

/* 輸送・車両の状態。assigned/in_transit は Job.Status / Vehicle.Status とも語を共有する */
.pill--assigned, .pill--pending_pickup { background: var(--info-soft); color: var(--info); }
.pill--delivered, .pill--settled, .pill--available { background: var(--accent-soft); color: var(--accent); }
.pill--maintenance { background: var(--warn-soft); color: var(--warn); }

/* ドライバーの有効/無効。無効はデフォルトの .pill（グレー）をそのまま使う */
.pill--active { background: var(--accent-soft); color: var(--accent); }

.page-head__sub { margin: 0; font-size: 16px; font-weight: 700; }

/* ---------------- メッセージ ---------------- */
.msg-list { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 72%; padding: 9px 13px; border-radius: 10px; background: var(--surface-2); }
.msg--mine { align-self: flex-end; background: var(--accent-soft); }
.msg__meta { display: flex; gap: 8px; font-size: 11px; color: var(--faint); margin-bottom: 3px; }
.msg__body { font-size: 14px; white-space: pre-wrap; word-break: break-word; }

/* ---------------- 積地・卸地の住所入力（郵便番号検索・地図） ---------------- */
.field-group {
  display: flex; flex-direction: column; gap: 14px;
  padding: 14px 0; border-top: 1px solid var(--line);
}
.field-group__title { margin: 0; font-size: 13px; font-weight: 700; color: var(--muted); }
.field--postal .field__row { display: flex; gap: 8px; }
.field--postal .field__row .field__input { flex: 1; max-width: 160px; }
.field--postal .field__row .btn { min-height: 40px; }

.map-widget { display: flex; flex-direction: column; gap: 6px; }
.map-widget__map {
  height: 520px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface-2);
}
.map-widget__actions { display: flex; align-items: center; gap: 12px; }

.badge {
  display: inline-grid; place-items: center;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
}

/* ---------------- 通知 ---------------- */
.table tbody tr.is-unread { background: var(--accent-soft); }
.pill--new_job_match { background: var(--info-soft); color: var(--info); }
.pill--bid_accepted { background: var(--accent-soft); color: var(--accent); }
.pill--contract_cancelled { background: var(--danger-soft); color: var(--danger); }

/* ヘッダーの通知ベルの吹き出し */
.notif-bell { position: relative; }
.notif-bell__panel {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 20;
  width: 320px; max-width: calc(100vw - 24px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
  padding: 12px;
}
.notif-bell__head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; margin-bottom: 8px; font-size: 13px;
}
.notif-bell__head a { color: var(--accent); font-weight: 700; }
.notif-bell__list {
  list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column;
  gap: 8px; max-height: 320px; overflow-y: auto;
}
.notif-bell__item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px; border-radius: 7px; background: var(--surface-2);
}
.notif-bell__item-body { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.notif-bell__meta { font-size: 11px; color: var(--faint); }
.notif-bell__empty { margin: 0; font-size: 13px; color: var(--muted); }

/* ---------------- ダッシュボード ---------------- */
.dashboard-section { display: flex; flex-direction: column; gap: 14px; margin-top: 22px; }
.dashboard-section:first-child { margin-top: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.section-head__sub { margin: 0 0 0 8px; font-size: 12px; font-weight: 400; color: var(--muted); }

.perf-groups { display: flex; flex-direction: column; gap: 14px; }
.perf-group__title { margin: 0 0 10px; font-size: 13px; font-weight: 700; color: var(--muted); }

/* 値は等幅にしない（表の桁揃えとは別の見せ方）。ラベルは末尾のコロンなしの文とする */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: 9px; overflow: hidden;
}
.stat-tile { background: var(--surface); padding: 14px 16px; }
.stat-tile__label { margin: 0 0 6px; font-size: 12px; color: var(--muted); }
.stat-tile__value { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.stat-tile__unit { margin-left: 2px; font-size: 12px; font-weight: 400; color: var(--muted); }
