/* =========================================================
   山岡運輸 業務管理 モックアップ 共通スタイル
   基準: デジタル庁デザインシステム（DADS）
   - フォント Noto Sans JP、本文16px、業務画面は行高130%
   - フォーカスは Yellow-300 と黒の二重表示（変更しない）
   - 状態は色だけで区別しない（記号と文字を併記）
   ========================================================= */

:root {
  /* キーカラー（山岡運輸のロゴから採色） */
  --green-900: #014A0F;  /* ロゴの文字色に近い深緑：見出し・ホバー */
  --green-800: #0B5A20;  /* プライマリー：白に対して約8.4:1 */
  --green-700: #1F7A36;  /* 枠線・補助：白に対して約5.3:1 */
  --green-100: #DDEEDF;
  --green-50:  #EEF6EF;
  --red-700:   #CC0000;  /* ロゴとサイトの赤。強調・エラー・未配車に限る：白に対して約5.9:1 */
  --red-50:    #FDEEEE;
  --blue-700:  #1F5FA8;  /* 運行中：白に対して約6.1:1 */
  --blue-600:  #2B6CB5;
  --blue-100:  #DCE8F5;
  --blue-50:   #EEF4FB;

  /* ニュートラル（DADS Solid Gray 相当） */
  --white: #FFFFFF;
  --gray-50:  #F2F2F2;
  --gray-100: #E6E6E6;
  --gray-200: #CCCCCC;
  --gray-420: #949494;   /* 非テキスト 3:1 の境界 */
  --gray-536: #767676;   /* テキスト 4.5:1 の境界 */
  --gray-600: #666666;
  --gray-700: #4D4D4D;
  --gray-900: #1A1A1A;
  --black: #000000;

  /* 画面の地 */
  --bg: #F0F2EF;
  --surface: #FFFFFF;
  --line: #D6DCD5;       /* 区切り線（装飾） */
  --line-strong: #87918A;/* 入力欄などUIの枠：3:1以上 */

  /* セマンティック */
  --error-700: var(--red-700);
  --error-50:  var(--red-50);
  --warn-700:  #B54A00;  /* 橙系の警告（文字用） */
  --warn-50:   #FFF3E6;
  --success-700: #197A4B;
  --success-50:  #E8F5EE;

  /* 事業用ナンバー（緑地に白文字） */
  --plate-green: #1D6B3E;
  --plate-black: #1A1A1A;
  --plate-yellow: #F2C200;

  /* フォーカス（DADS規定） */
  --focus-yellow: #FFD43D;

  --radius-s: 4px;
  --radius-m: 8px;
  --radius-l: 12px;
  --shadow-1: 0 1px 2px rgba(1, 40, 10, .08), 0 0 0 1px var(--line);
  --shadow-3: 0 8px 24px rgba(1, 40, 10, .18), 0 0 0 1px var(--line-strong);

  --sidebar-w: 248px;
  --font: 'Noto Sans JP', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--gray-900);
  background: var(--bg);
  font-feature-settings: "palt" 0;
}
img { max-width: 100%; display: block; }
a { color: #0031D8; }
a:visited { color: #0031D8; }
button, input, select { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }

/* フォーカス表示（DADS：黄＋黒の二重） */
:focus-visible {
  outline: 4px solid var(--black);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--focus-yellow);
  border-radius: 2px;
}

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--focus-yellow); color: var(--black); padding: 8px 16px; font-weight: 700;
}
.skip-link:focus { top: 8px; }

/* ---------- 骨組み ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
.sidebar__brand { padding: 20px 20px 16px; border-bottom: 1px solid var(--line); }
.sidebar__brand img { width: 168px; height: auto; }
.sidebar__office { margin: 10px 0 0; font-size: 14px; color: var(--gray-600); }
.nav { padding: 8px 12px 24px; flex: 1; }
.nav__group { margin-top: 10px; }
.nav__heading { font-size: 14px; color: var(--gray-600); font-weight: 400; margin: 0 0 4px 12px; }
.nav__list { list-style: none; margin: 0; padding: 0; }
.nav__link {
  display: flex; align-items: center; gap: 10px;
  min-height: 40px; padding: 6px 12px; border-radius: var(--radius-m);
  color: var(--gray-900); text-decoration: none; font-weight: 400;
  position: relative;
}
.nav__link:visited { color: var(--gray-900); }
.nav__link:hover { background: var(--green-50); text-decoration: underline; }
.nav__link svg { flex: none; width: 20px; height: 20px; color: var(--green-700); }
.nav__link[aria-current="page"] { background: var(--green-800); color: var(--white); font-weight: 700; }
.nav__link[aria-current="page"] svg { color: var(--white); }
.nav__link[aria-current="page"]:hover { text-decoration: none; }
.nav__link[data-out]::after {
  content: "範囲外"; margin-left: auto; font-size: 12px; color: var(--gray-600);
  border: 1px solid var(--gray-200); border-radius: 999px; padding: 0 6px; line-height: 18px;
}
.nav__badge {
  margin-left: auto; min-width: 24px; padding: 0 7px; border-radius: 999px;
  background: var(--error-700); color: var(--white); font-size: 14px; font-weight: 700; line-height: 22px; text-align: center;
}
.sidebar__foot { padding: 16px 20px; border-top: 1px solid var(--line); font-size: 14px; color: var(--gray-600); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  min-height: 56px; padding: 0 32px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar__menu { display: none; }
.topbar__brand { display: none; }
.topbar__clock { font-variant-numeric: tabular-nums; color: var(--gray-700); }
.topbar__clock strong { color: var(--gray-900); }
.topbar__user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--blue-100); color: var(--blue-700);
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}

.content { padding: 24px 32px 48px; flex: 1; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 28px; line-height: 1.4; letter-spacing: .01em; color: var(--green-900); }
.page-head p { margin: 4px 0 0; color: var(--gray-700); }
.page-head__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.demo-note {
  padding: 12px 32px 24px; font-size: 14px; color: var(--gray-600);
}

/* ---------- ボタン（DADS：塗り＝主、枠＝副、文字＝取消） ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 18px; border-radius: var(--radius-m);
  font-weight: 700; font-size: 16px; line-height: 1; cursor: pointer; text-decoration: none;
  border: 1px solid transparent; white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn--primary { background: var(--green-800); color: var(--white); }
.btn--primary:hover { background: var(--green-900); text-decoration: underline; }
.btn--secondary { background: var(--white); color: var(--green-800); border-color: var(--green-800); }
.btn--secondary:hover { background: var(--green-50); text-decoration: underline; }
.btn--text { background: none; color: var(--green-800); text-decoration: underline; padding-inline: 8px; }
.btn--s { min-height: 36px; padding: 6px 12px; font-size: 14px; }
a.btn--primary:visited { color: var(--white); }
a.btn--secondary:visited { color: var(--green-800); }

/* ---------- 面 ---------- */
.panel {
  background: var(--surface); border-radius: var(--radius-l); box-shadow: var(--shadow-1);
  min-width: 0;
}
.panel__head {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 16px 20px 12px; border-bottom: 1px solid var(--line);
}
.panel__head h2 { margin: 0; font-size: 20px; line-height: 1.4; color: var(--green-900); }
.panel__head .sub { color: var(--gray-700); font-size: 14px; }
.panel__head .more { margin-left: auto; font-size: 14px; }
.panel__body { padding: 16px 20px 20px; }

/* ---------- 状態表示（記号＋文字） ---------- */
.status {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: 14px; font-weight: 700; line-height: 1; padding: 5px 10px 5px 8px; border-radius: 999px;
  border: 1px solid currentColor;
}
.status::before { content: ""; width: 10px; height: 10px; flex: none; }
.status--unassigned { color: var(--error-700); background: var(--error-50); border-style: dashed; }
.status--unassigned::before { border: 2px solid currentColor; border-radius: 50%; width: 8px; height: 8px; }
.status--assigned { color: var(--green-800); background: var(--white); }
.status--assigned::before { background: currentColor; border-radius: 2px; }
.status--tentative { color: var(--green-800); background: var(--white); border: 1.5px dashed var(--green-700); }
.status--tentative::before { border: 2px dashed currentColor; border-radius: 2px; width: 8px; height: 8px; }
.status--running { color: var(--white); background: var(--blue-700); border-color: var(--blue-700); }
.status--running::before { background: var(--white); border-radius: 50%; box-shadow: 0 0 0 3px rgba(255,255,255,.35); }
.status--done { color: var(--success-700); background: var(--success-50); }
.status--done::before { width: 10px; height: 6px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg) translate(1px,-1px); }
.status--billed { color: var(--gray-700); background: var(--gray-50); border-color: var(--gray-420); }
.status--billed::before { background: none; border: 2px solid currentColor; border-radius: 2px; width: 8px; height: 10px; }

.tag {
  display: inline-block; font-size: 14px; line-height: 20px; padding: 0 7px; border-radius: var(--radius-s);
  border: 1px solid var(--gray-420); color: var(--gray-700); background: var(--white); white-space: nowrap;
}
.tag--blue { border-color: var(--blue-600); color: var(--blue-700); background: var(--blue-50); }
.tag--size { font-weight: 700; color: var(--gray-900); border-color: var(--gray-700); min-width: 3em; text-align: center; }
.tag--size-l { color: var(--white); background: var(--green-900); border-color: var(--green-900); }
.tag--warn { border-color: var(--warn-700); color: var(--warn-700); background: var(--warn-50); }

.alert-text { color: var(--error-700); font-weight: 700; }
.warn-text { color: var(--warn-700); font-weight: 700; }
.muted { color: var(--gray-600); }

/* ---------- ナンバープレート ---------- */
.plate {
  display: inline-grid; grid-template-columns: auto auto; grid-template-rows: auto auto;
  column-gap: 4px; align-items: center;
  background: var(--plate-green); color: var(--white);
  border-radius: 4px; padding: 2px 6px 3px; line-height: 1.1;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.45), 0 0 0 1px var(--plate-green);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.plate__top { grid-column: 1 / -1; font-size: 11px; text-align: center; letter-spacing: .08em; }
.plate__kana { font-size: 12px; }
.plate__num { font-size: 17px; font-weight: 700; letter-spacing: .02em; }
.plate--kei { background: var(--plate-black); color: var(--plate-yellow); box-shadow: inset 0 0 0 1px rgba(242,194,0,.5), 0 0 0 1px var(--plate-black); }
.plate--l { padding: 6px 12px 7px; border-radius: 6px; column-gap: 8px; }
.plate--l .plate__top { font-size: 15px; }
.plate--l .plate__kana { font-size: 18px; }
.plate--l .plate__num { font-size: 32px; }

/* ---------- 表（DADS：見出しと本体は濃い線で区切り、見出し太字） ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.3; }
.table th, .table td { padding: 10px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
.table thead th {
  font-weight: 700; color: var(--gray-900); background: var(--green-50);
  border-bottom: 2px solid var(--gray-900); white-space: nowrap; font-size: 14px;
  position: sticky; top: 0; z-index: 1;
}
.table td.r, .table th.r { text-align: right; }
.table tbody tr:hover { background: #F5F8F5; }
.table tbody tr.is-selected { background: var(--blue-50); }
.table tbody tr.is-selected:hover { background: var(--blue-100); }
.sort-btn {
  all: unset; cursor: pointer; text-decoration: underline; display: inline-flex; align-items: center; gap: 4px;
}
.sort-btn:focus-visible { outline: 4px solid var(--black); outline-offset: 2px; box-shadow: 0 0 0 2px var(--focus-yellow); }
.sort-btn svg { width: 12px; height: 12px; }

.check { width: 20px; height: 20px; accent-color: var(--green-800); cursor: pointer; }

/* ---------- 入力 ---------- */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label, .field .label { font-size: 14px; font-weight: 700; color: var(--gray-700); }
.input, .select {
  min-height: 44px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-m);
  background: var(--white); min-width: 0;
}
.select { padding-right: 36px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23333' stroke-width='1.8'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 8px; }
.input:hover, .select:hover { border-color: var(--gray-900); }

/* ---------- トースト ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--green-900); color: var(--white); padding: 12px 20px; border-radius: var(--radius-m);
  box-shadow: var(--shadow-3); z-index: 200; transition: opacity .2s, transform .2s; pointer-events: none;
  max-width: calc(100vw - 32px);
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 説明リスト ---------- */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 0; margin: 0; }
.dl dt, .dl dd { padding: 9px 0; border-bottom: 1px solid var(--line); margin: 0; }
.dl dt { color: var(--gray-700); font-size: 14px; padding-right: 20px; }
.dl dd { font-variant-numeric: tabular-nums; }

/* ---------- レスポンシブ ---------- */
@media (max-width: 1080px) {
  :root { --sidebar-w: 216px; }
  .content { padding: 20px 20px 40px; }
  .topbar { padding: 0 20px; }
  .demo-note { padding: 12px 20px 24px; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 60; transform: translateX(-100%);
    transition: transform .2s; box-shadow: var(--shadow-3);
  }
  .sidebar.is-open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(1,40,10,.45); z-index: 50; }
  .topbar { padding: 0 16px; gap: 12px; }
  .topbar__menu {
    display: inline-grid; place-items: center; width: 44px; height: 44px; margin-left: -8px;
    border: none; background: none; cursor: pointer; border-radius: var(--radius-m);
  }
  .topbar__menu svg { width: 24px; height: 24px; }
  .topbar__brand { display: block; }
  .topbar__brand img { height: 30px; width: auto; }
  .topbar__clock { display: none; }
  .topbar__user span { display: none; }
  .content { padding: 16px 16px 32px; }
  .demo-note { padding: 8px 16px 24px; }
  .page-head h1 { font-size: 24px; }
  .page-head__actions { margin-left: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
