/* ============================================================
 * PCN Design System — Common Styles
 * Bootstrap 4.6.2 のカスタムレイヤー
 * ============================================================ */

/* ============================================================
 * CSS Variables
 * ============================================================ */
:root {
  /* ベース */
  --bg: #faf8f4;
  --card: #ffffff;
  --text: #3d3529;
  --text-soft: #7a7062;
  --text-muted: #a89f93;
  --danger: #e74c3c;
  --border: #e8e2d9;
  --border-focus: #b8ae9f;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 8px rgba(80,60,30,0.06);
  --shadow-hover: 0 4px 16px rgba(80,60,30,0.10);

  /* セクション色 */
  --sec1: #4a90d9;  --sec1-bg: #eef4fb;  --sec1-light: #d6e6f7;
  --sec2: #3da06d;  --sec2-bg: #edf7f0;  --sec2-light: #d0eddb;
  --sec3: #d4883e;  --sec3-bg: #fef3e8;  --sec3-light: #fae0c4;
  --sec4: #8b72b8;  --sec4-bg: #f3effa;  --sec4-light: #dfd6f0;
  --sec5: #c75480;  --sec5-bg: #fceef3;  --sec5-light: #f5d3e0;
  --sec6: #3a9e8c;  --sec6-bg: #eaf6f3;  --sec6-light: #c8ece4;
  --sec7: #8c7e6e;  --sec7-bg: #f3f0ec;  --sec7-light: #ddd7cf;

  /* BOM階層色（セマンティック名） */
  --sec-info: #4a90d9;      --sec-info-bg: #eef4fb;    --sec-info-light: #d6e6f7;
  --sec-main: #d4883e;      --sec-main-bg: #fef3e8;    --sec-main-light: #fae0c4;
  --sec-sub:  #3da06d;      --sec-sub-bg:  #edf7f0;    --sec-sub-light:  #d0eddb;
  --sec-part: #8b72b8;      --sec-part-bg: #f3effa;    --sec-part-light: #dfd6f0;

  /* テーブル系 */
  --tbl-head: #f5f0ea;
  --tbl-accent: #8c7e6e;
  --tbl-accent-bg: #f3f0ec;
  --process-accent: #5a6e8a;
  --process-accent-bg: #eef2f7;

  /* 出荷・不良 */
  --shipping: #e08540;         --shipping-bg: #fef4e8;
  --defect: #c0392b;           --defect-bg: #fdf0ed;
  --defect-purchase: #a0365c;  --defect-purchase-bg: #f8eaf0;

  /* 登録ボタン */
  --register: #e8833a;
  --register-hover: #d5742e;
}

* { box-sizing: border-box; }

body {
  font-family: 'Zen Maru Gothic', 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
 * ナビバー
 * ============================================================ */
.top-bar {
  background: #5c5040;
  color: #fff;
  padding: 0 28px;
  height: 52px;
  display: flex;
  position: sticky;
  top: 0;
  z-index: 100;
  align-items: center;
  gap: 0;
  font-size: 14px;
  font-weight: 500;
}
.top-bar .logo {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.04em;
  margin-right: 24px;
  flex-shrink: 0;
}

/* ナビリンク共通 */
.nav-item {
  position: relative;
  height: 52px;
  display: flex;
  align-items: center;
}
.nav-item > a,
.nav-item > span {
  display: flex;
  align-items: center;
  height: 52px;
  padding: 0 16px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  transition: color 0.2s, background 0.2s;
  white-space: nowrap;
  cursor: pointer;
}
.nav-item > a:hover,
.nav-item > span:hover,
.nav-item:hover > a,
.nav-item:hover > span {
  color: #fff;
  background: rgba(255,255,255,0.08);
}
.nav-item > a.now,
.nav-item > span.now {
  color: #fff;
}

/* ドロップダウン親の ▼ マーク */
.nav-item.has-dropdown > a::after,
.nav-item.has-dropdown > span::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  margin-left: 6px;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.nav-item.has-dropdown:hover > a::after,
.nav-item.has-dropdown:hover > span::after {
  opacity: 1;
}

/* ドロップダウンメニュー */
.dropdown-menu {
  display: none;
  position: absolute;
  top: 52px;
  left: 0;
  min-width: 180px;
  background: #6b6050;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  padding: 6px 0;
  z-index: 200;
}
/* ナビのドロップダウンのみ（PDFボタン等の .dropdown-menu には影響させない）:
   display:none/block の即時切替だと、カーソルが項目→メニューへ移る 2px の隙間や
   わずかな移動で hover が切れ、配下が消えて操作しづらい。
   そこで nav のメニューは常時 block としつつ visibility/opacity で制御し、
   hover が外れても .25s の猶予（transition-delay）を置いてから消す。
   さらに透明ブリッジ(::before)で項目とメニューの隙間を埋め hover を連続させる。 */
.nav-item.has-dropdown .dropdown-menu {
  display: block;
  visibility: hidden;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .15s ease .25s, transform .15s ease .25s, visibility 0s linear .4s;
  top: 100%;
  /* 項目数の多いメニュー（マスター等）や小型ノートでビューポートを超えても
     下部が届くよう高さを制限してスクロール可能にする（メニュー:hover 中は開いたまま） */
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.nav-item.has-dropdown:hover .dropdown-menu,
.nav-item.has-dropdown .dropdown-menu:hover {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  transition: opacity .15s ease, transform .15s ease, visibility 0s;
}
/* 項目とメニューの隙間を埋める透明ブリッジ（hover 継続用・メニュー可視時のみ有効） */
.nav-item.has-dropdown .dropdown-menu::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 0;
  right: 0;
  height: 8px;
}
.dropdown-menu a {
  display: block;
  padding: 10px 20px;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.dropdown-menu a:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

/* ドロップダウン内グループ見出し（非クリックの区切り・上部罫線内包） */
.dropdown-head {
  padding: 8px 20px 4px;
  margin-top: 4px;
  border-top: 1px solid var(--text-muted);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  pointer-events: none;
}
/* 区切り線（見出しを使わない場合用） */
.dropdown-sep {
  height: 0;
  margin: 4px 0;
  border-top: 1px solid var(--text-muted);
}

/* ユーザーエリア（右寄せ） */
.nav-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  flex-shrink: 0;
  padding-left: 16px;
}
.nav-user .search-icon {
  font-size: 15px;
  cursor: pointer;
  transition: color 0.2s;
}
.nav-user .search-icon:hover {
  color: #fff;
}
.nav-user .help-nav-icon {
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 16px;
  padding: 0 4px;
  transition: color 0.2s;
}
.nav-user .help-nav-icon:hover {
  color: #fff;
}
.nav-user .user-name {
  font-weight: 500;
}

/* ============================================================
 * ページ見出し
 * ============================================================ */
.page-title-area {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 20px 32px;
  box-shadow: var(--shadow);
  display: flex;
  position: sticky;
  top: 52px;
  z-index: 90;
  align-items: center;
  justify-content: space-between;
}
.page-title-area .title-left {
  flex: 1;
}
.page-title-area h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-title-area h1 .new-badge {
  display: inline-block;
  background: var(--register);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 20px;
}
.page-title-area .subtitle {
  font-size: 14px;
  color: var(--text-soft);
}

/* ============================================================
 * メイン
 * ============================================================ */
.main {
  max-width: 1800px;
  margin: 0 auto;
  width: 90%;
  padding: 36px 0 180px;
}

/* ============================================================
 * 2カラムグリッド
 * ============================================================ */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
.two-col > .sec {
  margin-bottom: 0;
}
.two-col > .right-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.two-col > .right-stack > .sec {
  margin-bottom: 0;
}
/* two-col 内で単独セクションを全幅に広げる（メモ等） */
.two-col > .sec-full {
  grid-column: 1 / -1;
}

/* ============================================================
 * セクションカード
 * ============================================================ */
.sec {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: box-shadow 0.2s ease;
}
.sec:hover {
  box-shadow: var(--shadow-hover);
}
.sec-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  font-size: 18px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}
.sec-head .sec-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.sec-head .sec-num {
  font-size: 11px;
  font-weight: 700;
  border-radius: 20px;
  padding: 1px 9px;
  margin-left: auto;
  letter-spacing: 0.03em;
}
.sec-body {
  padding: 20px 24px 24px;
}

/* セクション色 */
.sec-1 .sec-head { background: var(--sec1-bg); }
.sec-1 .sec-icon { background: var(--sec1); color: #fff; }
.sec-1 .sec-num  { background: var(--sec1-light); color: var(--sec1); }

.sec-2 .sec-head { background: var(--sec2-bg); }
.sec-2 .sec-icon { background: var(--sec2); color: #fff; }
.sec-2 .sec-num  { background: var(--sec2-light); color: var(--sec2); }

.sec-3 .sec-head { background: var(--sec3-bg); }
.sec-3 .sec-icon { background: var(--sec3); color: #fff; }
.sec-3 .sec-num  { background: var(--sec3-light); color: var(--sec3); }

.sec-4 .sec-head { background: var(--sec4-bg); }
.sec-4 .sec-icon { background: var(--sec4); color: #fff; }
.sec-4 .sec-num  { background: var(--sec4-light); color: var(--sec4); }

.sec-5 .sec-head { background: var(--sec5-bg); }
.sec-5 .sec-icon { background: var(--sec5); color: #fff; }
.sec-5 .sec-num  { background: var(--sec5-light); color: var(--sec5); }

.sec-6 .sec-head { background: var(--sec6-bg); }
.sec-6 .sec-icon { background: var(--sec6); color: #fff; }
.sec-6 .sec-num  { background: var(--sec6-light); color: var(--sec6); }

.sec-7 .sec-head { background: var(--sec7-bg); }
.sec-7 .sec-icon { background: var(--sec7); color: #fff; }
.sec-7 .sec-num  { background: var(--sec7-light); color: var(--sec7); }

/* ============================================================
 * フォーム部品
 * ============================================================ */
.fg {
  margin-bottom: 18px;
}
.fg:last-child { margin-bottom: 0; }
/* 単独フィールド行（row内にfgが1つ）。fgが only-child=last-child となり
   margin-bottom:0 に潰れて次行と詰まるため、行間マージンを復元する。
   セクション最終行では使わないこと（余白過多になる）。 */
.row-solo > .fg:last-child { margin-bottom: 18px; }
.fg-label {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.fg-label .must,
.dt th .must {
  display: inline-block;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 6px;
  margin-left: 6px;
  vertical-align: middle;
}
.fg-label .opt-tag,
.dt th .opt-tag {
  display: inline-block;
  background: var(--border);
  color: var(--text-soft);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 6px;
  margin-left: 6px;
  vertical-align: middle;
}
/* 条件付き必須（例: 箱管理ONのときだけ必須）。必須(赤)と任意(灰)の中間＝アンバー。 */
.fg-label .cond-tag,
.dt th .cond-tag {
  display: inline-block;
  background: #f59e0b;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 6px;
  margin-left: 6px;
  vertical-align: middle;
  white-space: nowrap;
}
.fg-hint {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}
/* 入力欄＋単位サフィックス（例: 抵抗値 [___] Ω） */
.fi-unit-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.fi-unit-row .fi {
  flex: 1 1 auto;
  min-width: 0;
}
.fi-unit {
  flex: 0 0 auto;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-soft);
  white-space: nowrap;
}
.fi {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 18px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.fi:focus {
  outline: none;
  border-color: var(--sec1);
  box-shadow: 0 0 0 4px var(--sec1-bg);
}
.fi::placeholder {
  color: var(--text-muted);
  font-size: 15px;
}
.fi[disabled], .fi[readonly] {
  background: var(--bg);
  color: var(--text-muted);
  cursor: default;
}
.fi-auto {
  background: repeating-linear-gradient(
    -45deg,
    var(--bg),
    var(--bg) 4px,
    #f3efe9 4px,
    #f3efe9 8px
  );
  font-style: italic;
}
select.fi {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath fill='%23a89f93' d='M3 5l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 38px;
}
textarea.fi {
  height: auto;
  min-height: 80px;
  padding: 14px 16px;
  resize: vertical;
  line-height: 1.6;
}

/* 横並び */
/* minmax(0,1fr) で列を「均等かつ縮小可能」にする。
   1fr(=minmax(auto,1fr)) だと Select2 等の最小幅で列が広がり、
   隣のテキスト入力が極端に細くなる（列幅の不均等）ため minmax(0,1fr) に統一。 */
.row-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.row-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.row-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.row-5 {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
}

/* カスタム項目モーダル（spec_modal）のフィールドを適切な幅で多列配置する。
   auto-fill + minmax でモーダル幅に応じ 2〜3 列に自動折り返し（全幅縦積みの是正）。
   .fg の margin-bottom はグリッド gap と二重にならないよう 0 に上書き。 */
.spec-fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px 20px;
}
.spec-fields-grid .fg {
  margin-bottom: 0;
}

/* フィルター付きセレクト */
.filter-row {
  display: flex;
  gap: 8px;
}
.filter-row .filter-sm { width: 100px; flex-shrink: 0; }
.filter-row .filter-lg { flex: 1; }

/* ============================================================
 * Readonly フィールド値（詳細ページ用）
 * ============================================================ */
.field-value {
  font-size: 18px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text);
  min-height: 50px;
  display: flex;
  align-items: center;
}

/* ============================================================
 * 担当者の区切り
 * ============================================================ */
.role-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-soft);
}
.role-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.role-divider .role-icon {
  font-size: 16px;
}

/* ============================================================
 * チェックボックス
 * ============================================================ */
.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.ck {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 16px;
  font-weight: 500;
  user-select: none;
  background: #fff;
  flex: 1;
  min-width: 140px;
}
.ck:hover {
  border-color: var(--sec6);
  background: var(--sec6-bg);
}
.ck input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--sec6);
  cursor: pointer;
  flex-shrink: 0;
}
.ck.on {
  border-color: var(--sec6);
  background: var(--sec6-bg);
}
.ck-important {
  border-color: #ef4444;
  background: #fef2f2;
  color: #b91c1c;
}
.ck-important:hover {
  border-color: #dc2626;
  background: #fee2e2;
}

/* ============================================================
 * ラジオボタングループ（区分選択などの二者択一）
 * ============================================================ */
.radio-group {
  display: inline-flex;
  align-items: center;
  gap: 24px;
  padding: 6px 0;
}
.radio-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  margin: 0;
}
.radio-label input[type="radio"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--sec1);
}
.radio-group.fi-error {
  outline: 2px solid var(--danger);
  outline-offset: 4px;
  border-radius: var(--radius-sm);
}

/* ============================================================
 * テーブルセクション
 * ============================================================ */
.tbl-sec {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
/* テーブル横スクロール用ラッパー（列数が多い一覧で .tbl-sec 内に配置） */
.tbl-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tbl-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 10px;
}
/* テーブル下部の操作行（行数が多い明細で「追加」を上部と両方に置く場合に使う） */
.tbl-foot-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
}
/* 工程実績モーダル: 前工程まで/全工程の不良数サマリー（自社・外注共通・表示専用） */
.proc-defect-info {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
}
.proc-defect-info .pdi-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.proc-defect-info .pdi-label {
  color: var(--text-muted);
}
.proc-defect-info .pdi-val {
  font-weight: 700;
  color: var(--defect);
}
.tbl-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
}
.tbl-title .tbl-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: #fff;
}
.tbl-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
/* 表ヘッダー内の絞り込み（例: 配下Lot一覧の所有フィルタ）。
   ラベルとセレクトを1行に収め、セレクトが伸びすぎないよう幅を抑える */
.lot-owner-filter { align-items: center; }
.lot-owner-filter .fi-xs { width: auto; min-width: 120px; max-width: 220px; }
.lot-owner-filter .lot-filter-count { font-weight: 500; color: var(--text-muted); }
/* 得意先を選ぶと「汎用」は対象外になる（所有者を持たないため）。
   黙って外さず、薄くして理由が分かるようにする */
.lot-owner-filter .checkbox-label.is-disabled { opacity: 0.45; cursor: not-allowed; }

/* サマリ欄（.info-grid）のその場編集。安全在庫・既定の保管場所・取得原価で共通。
   ⚠ flex-wrap は必須。info-grid のセルは minmax(220px,1fr) なので
     入力欄＋ボタンが1行に収まらず、折り返さないと**隣のセルの上に重なる**。 */
.inline-edit-row { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
/* 幅1セル（220px前後）のときは入力欄で1行を使い切り、ボタン2つを次の行に並べる。
   そうしないと「保存」だけが先に折り返して「キャンセル」がさらに次の行に落ちる。
   1行を占有するセル（.info-item-wide）は横に余裕があるので折り返させない。 */
.info-item:not(.info-item-wide) .inline-edit-row > .select2-container,
.info-item:not(.info-item-wide) .inline-edit-row > .fi { flex: 1 1 100%; }
/* 幅は .inline-edit-row 配下に限定して指定する。
   .fi-sm { width:100% } がこの定義より後ろにあるため、単独クラスだと負ける。 */
.inline-edit-row .cost-edit-input { width: 130px; }
.inline-edit-row .cost-reason-input { width: 260px; }
.inline-edit-row .safety-edit-input { width: 120px; }
/* 金額の脇に添える補足（評価額・未設定の理由など）。数字より一段弱く見せる */
.lot-cost-sub { margin-left: 8px; font-size: 12px; color: var(--text-soft); }

/* 在庫評価額（取得原価法・当時価値）。在庫一覧・品目詳細・単価未設定一覧の3画面で使う。
   「取得原価未設定」の注記はリンクにもなるため、リンク色に引きずられないよう色を明示する */
.stock-valuation-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--sec1-bg);
  border-radius: 6px;
  font-size: 13px;
}
.stock-valuation-main { color: var(--text); }
.stock-valuation-main strong { font-size: 15px; color: var(--sec1); }
.stock-valuation-note { color: var(--text-soft); font-size: 12px; }

/* 評価額セル内の取得原価未設定の注記 */
.stock-uncosted-note {
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-soft);
  white-space: nowrap;
}
a.stock-uncosted-note, a.stock-valuation-note { color: var(--text-soft); text-decoration: underline; }
a.stock-uncosted-note:hover, a.stock-valuation-note:hover { color: var(--sec1); }

/* ツールバー内のインラインラベル（例: 枚数） */
.fg-inline-label {
  align-self: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
}
/* ツールバー内のコンパクト数値入力（例: ラベル印刷枚数） */
.fi-copies {
  width: 72px;
  height: 40px;
  padding: 0 10px;
  font-size: 15px;
  text-align: right;
}
/* 一覧上部のアクションツールバー（選択の束ね操作ボタン等） */
.tbl-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 12px;
}
.btn-tbl {
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 2px solid;
}
.btn-tbl-primary {
  background: var(--tbl-accent);
  border-color: var(--tbl-accent);
  color: #fff;
}
.btn-tbl-primary:hover {
  background: #766a5c;
  border-color: #766a5c;
}
.btn-tbl-outline {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}
.btn-tbl-outline:hover {
  background: var(--bg);
  border-color: var(--border-focus);
}
.btn-tbl-success {
  background: var(--sec2);
  border-color: var(--sec2);
  color: #fff;
}
.btn-tbl-success:hover { background: #348f60; border-color: #348f60; }
.btn-tbl-procurement {
  background: var(--sec3);
  border-color: var(--sec3);
  color: #fff;
}
.btn-tbl-procurement:hover { background: #c07a35; border-color: #c07a35; }
.btn-tbl-supplied {
  background: var(--sec4);
  border-color: var(--sec4);
  color: #fff;
}
.btn-tbl-supplied:hover { background: #7a619f; border-color: #7a619f; }
.btn-tbl-process {
  background: var(--process-accent);
  border-color: var(--process-accent);
  color: #fff;
}
.btn-tbl-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-tbl-danger:hover { background: #c0392b; border-color: #c0392b; }
.btn-tbl:disabled,
.btn-tbl[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* テーブル本体 */
.dt {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}
.dt thead {
  border-bottom: 2px solid var(--border);
}
.dt thead th {
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
  text-align: left;
  white-space: nowrap;
}
/* ソート可能な見出し（SortHeader::th）。リンクが見出しセルを満たし、クリックで昇順⇄降順 */
.dt thead th.th-sortable { padding: 0; }
.dt thead th.th-sortable .sort-link {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 14px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.dt thead th.th-sortable .sort-link:hover { color: var(--sec1); }
.dt thead th.th-sortable .sort-arrow { font-size: 11px; opacity: 0.3; }
.dt thead th.th-sortable:hover .sort-arrow { opacity: 0.6; }
.dt thead th.th-sortable.is-sorted { color: var(--sec1); }
.dt thead th.th-sortable.is-sorted .sort-arrow { opacity: 1; }
/* 副ソートリンク（見出し下段）。列を畳んでセル内にサブ行を持たせた列で、
   サブ行側の並べ替えを残すために使う（例: 出荷予定日の下の作成日）。 */
.dt thead th.th-sortable .sort-sublink {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 14px 8px;
  margin-top: -6px;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  text-decoration: none;
}
.dt thead th.th-sortable .sort-sublink:hover { color: var(--sec1); }
.dt thead th.th-sortable .sort-sublink.is-sorted { color: var(--sec1); }
.dt thead th.th-sortable .sort-sublink.is-sorted .sort-arrow { opacity: 1; }
.dt tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}
.dt tbody tr:hover {
  background: #faf8f4;
}
/* 折り返し禁止モディファイア（横スクロール前提の一覧で行を1行に収める） */
.dt-nowrap th,
.dt-nowrap td { white-space: nowrap; }
.ci {
  height: 42px;
  padding: 0 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 16px;
  font-family: inherit;
  width: 100%;
  background: #fff;
  transition: border-color 0.2s;
}
.ci:focus {
  outline: none;
  border-color: var(--sec1);
}
select.ci {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%23a89f93' d='M2 3l3 4 3-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.dt .rn {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  width: 32px;
  white-space: nowrap;
}
/* #列に統合した完成（入庫）マーク: 最終工程のみ表示する緑チェック */
.completion-check {
  color: var(--sec2);
  margin-left: 3px;
  font-size: 12px;
}
.dt .del-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.2s;
}
.dt .del-btn:hover {
  color: #dc2626;
  background: #fef2f2;
}

/* 行操作ボタン（上へ／下へ／この行の下に挿入）
   del-btn と同じ「テーブル行末の小さなアイコンボタン」語彙。
   削除だけが赤系ホバーで、それ以外の行操作は中立色にする */
.dt .row-op-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.2s;
}
.dt .row-op-btn:hover:not(:disabled) {
  color: var(--sec1);
  background: var(--sec1-bg);
}
.dt .row-op-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

/* メモボタン（モーダル方式）
   th-memo に収まる小さなアイコンボタン。has-memo 時に色変化。
   受注/製造/マスタで共通に使うため order.css から移設 */
.memo-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm, 4px);
  transition: background 0.2s;
}
.memo-btn:hover {
  background: var(--bg);
}
.memo-btn.has-memo {
  background: var(--sec3-bg);
}
.memo-btn.has-memo i {
  color: var(--sec3) !important;
}

/* テーブル内グループ見出し行（仕入ロット単位の箱Lotグルーピング等） */
.dt tbody tr.tbl-group-row td {
  background: var(--sec2-bg);
  font-weight: 700;
  color: var(--text-soft);
}
.dt tbody tr.tbl-group-row:hover td {
  background: var(--sec2-bg);
}
.tbl-group-title {
  color: var(--sec2);
  font-weight: 700;
}
.tbl-group-meta {
  margin-left: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-soft);
}
/* グループ配下の字下げ（箱Lot枝番行のLot番号セル） */
.td-lot-indent {
  padding-left: 26px;
}

/* 空状態 */
.empty-state {
  padding: 28px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}
.empty-state i {
  display: block;
  font-size: 28px;
  margin-bottom: 8px;
  opacity: 0.3;
}

/* 利益率 */
.profit-bar {
  display: flex;
  align-items: stretch;
  border-top: 1px solid var(--border);
  background: #faf8f4;
}
.profit-cell {
  flex: 1;
  text-align: center;
  padding: 14px 12px;
  border-right: 1px solid var(--border);
}
.profit-cell:last-child { border-right: none; }
.profit-cell .p-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.profit-cell .p-val {
  font-size: 22px;
  font-weight: 700;
}
.p-val.green { color: var(--sec2); }
.p-val.amber { color: var(--sec3); }
.p-val.red { color: #dc2626; }

/* 図面エリア */
.drawing-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 19px 32px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.drawing-row .attached {
  font-size: 18px;
  color: var(--text-soft);
}

/* 図面モーダル（#drawingModal）内のアップロード行・図面一覧 */
.dwg-upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dwg-upload-row .fi-sm {
  flex: 1 1 auto;
  min-width: 0;
}
.dwg-list {
  border: 1px solid var(--border);
  border-radius: 6px;
}
.dwg-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}
.dwg-item:first-child {
  border-top: none;
}
.dwg-item-name {
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-all;
}
.dwg-item-size {
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--text-muted);
}
.dwg-empty {
  padding: 8px 12px;
  margin-top: 0;
}

/*----------------------------------------------------------
 * 製造計画 sec-7 インライン図面（mfg-plan.js renderInlineDrawings）
 * 既存モーダル(order-actions.js)と同じ .dwg-row / .dwg-size を共用
 *----------------------------------------------------------*/
.drawing-file-list {
  margin-bottom: 12px;
}
.dwg-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.dwg-row > a {
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-all;
}
.dwg-size {
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--text-muted);
}
.drawing-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
}
.drawing-upload-area.is-dragover {
  border-color: var(--border-focus);
  background: var(--bg);
}
.drawing-upload-text {
  color: var(--text);
  margin-bottom: 4px;
}
.drawing-upload-hint {
  font-size: 13px;
  color: var(--text-muted);
}
.drawing-upload-area.is-disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

/* テーブル系ヘッダー色 */
.tbl-purchase .tbl-head { background: var(--tbl-accent-bg); }
.tbl-purchase .tbl-icon { background: var(--tbl-accent); }
.tbl-purchase .dt thead { background: var(--tbl-accent-bg); }
.tbl-stock .tbl-head { background: var(--sec2-bg); }
.tbl-stock .tbl-icon { background: var(--sec2); }
.tbl-process .tbl-head { background: var(--process-accent-bg); }
.tbl-process .tbl-icon { background: var(--process-accent); }
.tbl-process .dt thead { background: var(--process-accent-bg); }

/* ============================================================
 * フッター固定バー
 * ============================================================ */
.foot {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 70px;
  background: var(--card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(80,60,30,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 0 32px;
  z-index: 50;
}
.btn-go {
  height: 50px;
  padding: 0 40px;
  background: var(--register);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  letter-spacing: 0.03em;
  box-shadow: 0 4px 12px rgba(232,131,58,0.3);
}
.btn-go:hover {
  background: var(--register-hover);
  box-shadow: 0 6px 20px rgba(232,131,58,0.4);
  transform: translateY(-1px);
}
.btn-go i { font-size: 20px; }
.btn-back {
  height: 50px;
  padding: 0 28px;
  background: #fff;
  color: var(--text-soft);
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
}
.btn-back:hover {
  background: var(--bg);
  border-color: var(--border-focus);
}
/* フッターの左右ボタンを両端に寄せるスペーサー */
.foot .btn-spacer {
  flex: 1;
}

/* 送り状Noセル（入力＋保存ボタン＋保存できた合図）
   押した手応えが無いと確定したか分からないため、保存ボタンを常に見せる。 */
.dt .tracking-edit {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  /* 横スクロールする一覧では th の width が効かない（列幅は中身の最小幅で決まる）ため、
     入力欄＋保存ボタンが並ぶ幅をここで確保する */
  min-width: 190px;
}
.dt .tracking-edit .ci {
  min-width: 0;
  flex: 1 1 auto;
}
.dt .tracking-saved {
  font-size: 11px;
  color: var(--sec2);
  white-space: nowrap;
}

/* テーブル内の参照専用セル（入力欄をやめてテキストで見せる列）
   入力欄のまま disabled にすると「触れるのに書けない」ように見えるため、
   参照しかしない列はこのクラスでテキスト表示にする。 */
.dt .td-readonly-text {
  padding: 0 10px;
  color: var(--text);
  white-space: nowrap;
}
.dt .td-readonly-text .text-muted {
  color: var(--text-muted);
}


/* ============================================================
 * ページ見出しアイコン色（インラインstyle 排除ユーティリティ）
 * ============================================================ */
.h1-icon-sec1 { color: var(--sec1); }
.h1-icon-sec2 { color: var(--sec2); }
.h1-icon-sec3 { color: var(--sec3); }
.h1-icon-sec4 { color: var(--sec4); }
.h1-icon-sec5 { color: var(--sec5); }
.h1-icon-sec6 { color: var(--sec6); }
.h1-icon-sec7 { color: var(--sec7); }

/* ============================================================
 * 商品選択ボタン
 * ============================================================ */
.item-pick {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--sec1-bg);
  color: var(--sec1);
  border: 2px solid var(--sec1-light);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}
.item-pick:hover {
  background: var(--sec1);
  color: #fff;
  border-color: var(--sec1);
}

/* ============================================================
 * ステップガイド
 * ============================================================ */
.step-guide {
  display: flex;
  gap: 4px;
  margin-bottom: 22px;
  padding: 0 4px;
}
.step-pip {
  height: 9px;
  flex: 1;
  border-radius: 5px;
  background: var(--border);
  transition: background 0.3s;
}
.step-pip.s1 { background: var(--sec1); }
.step-pip.s2 { background: var(--sec2); }
.step-pip.s3 { background: var(--sec3); }

/* ============================================================
 * アニメーション
 * ============================================================ */
@keyframes gentleUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.sec, .tbl-sec {
  animation: gentleUp 0.4s ease-out both;
}

/* 2カラム配置用アニメーションdelay */
.two-col:nth-of-type(1) .sec:nth-child(1)  { animation-delay: 0.03s; }
.two-col:nth-of-type(1) .sec:nth-child(2),
.two-col:nth-of-type(1) .right-stack        { animation-delay: 0.07s; }
.two-col:nth-of-type(1) .right-stack .sec   { animation-delay: 0.07s; }

.two-col:nth-of-type(2) .sec:nth-child(1)  { animation-delay: 0.11s; }
.two-col:nth-of-type(2) .right-stack .sec:nth-child(1) { animation-delay: 0.15s; }
.two-col:nth-of-type(2) .right-stack .sec:nth-child(2) { animation-delay: 0.19s; }
.two-col:nth-of-type(2) .right-stack .sec:nth-child(3) { animation-delay: 0.23s; }

.tbl-sec:nth-of-type(1) { animation-delay: 0.27s; }
.tbl-sec:nth-of-type(2) { animation-delay: 0.31s; }
.tbl-sec:nth-of-type(3) { animation-delay: 0.35s; }

/* ============================================================
 * ページネーション
 * ============================================================ */
.pagination {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin: 24px 0;
  flex-wrap: wrap;
}
.page-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.page-btn:hover {
  background: var(--bg);
  border-color: var(--border-focus);
}
.page-btn.active {
  background: var(--sec1);
  color: #fff;
  border-color: var(--sec1);
}
.page-btn:disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

/* ============================================================
 * 検索パネル
 * ============================================================ */
.search-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.search-panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  background: var(--tbl-head);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}
.search-panel-head:hover {
  background: var(--border);
}
.search-panel-head .toggle-icon {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.search-panel-body {
  padding: 20px 24px;
}
.search-panel-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* ============================================================
 * タブUI
 * ============================================================ */
.tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.tab-btn:hover {
  color: var(--text);
}
.tab-btn.active {
  border-bottom: 3px solid var(--sec1);
  color: var(--sec1);
}

/* ============================================================
 * バッジ
 * ============================================================ */
.badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  display: inline-block;
}
/* アイコンのみのコンパクトバッジ（不良/再製造 等・省スペース。意味は title で補う） */
.badge-icon {
  padding: 3px 6px;
  font-size: 12px;
  line-height: 1;
}
/* 種別バッジを先頭番号/品名の上に重ねる行（列を増やさず省スペース化） */
.cell-kind {
  margin-bottom: 3px;
  line-height: 1;
}
.badge-green { background: var(--sec2-bg); color: var(--sec2); }
.badge-red { background: #fef2f2; color: #dc2626; }
.badge-remake { background: #fdf0d5; color: #9a6b00; }  /* 再製造バッジ（不良=badge-defect赤 と区別する琥珀色） */
.badge-blue { background: var(--sec1-bg); color: var(--sec1); }
.badge-purple { background: var(--sec4-bg); color: var(--sec4); }
.badge-gray { background: #f3f0ec; color: var(--text-muted); }
.badge-orange { background: var(--sec3-bg); color: var(--sec3); }

/* 仕様chip群（テーブルセル内で複数バッジを折返し配置） */
.spec-chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* ============================================================
 * アクションバー（詳細ページ用）
 * ============================================================ */
.action-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ページ見出し右の操作ボタン群（受注タブ共通アクションバー） */
.title-right-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

/* 危険系アウトラインボタン（不良品登録等） */
.btn-tbl-outline.btn-outline-danger {
  color: var(--defect);
  border-color: var(--defect);
}
.btn-tbl-outline.btn-outline-danger:hover {
  background: var(--defect-bg);
}

/* タブ単位の保存アクションバー（製造計画/調達・入荷の段階保存） */
.tab-save-bar {
  display: flex;
  justify-content: flex-end;
  padding: 16px 0 4px;
  margin-top: 8px;
}

/* ============================================================
 * カードグリッド（メニュー・ホーム用）
 * ============================================================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.nav-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
}
.nav-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
  text-decoration: none;
  color: var(--text);
}
.nav-card .card-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #fff;
}
.nav-card .card-title {
  font-size: 16px;
  font-weight: 700;
}
.nav-card .card-desc {
  font-size: 13px;
  color: var(--text-soft);
  margin-top: 4px;
}
/* カードアイコンのセクション色（インラインCSS回避） */
.card-icon-sec1 { background: var(--sec1); }
.card-icon-sec2 { background: var(--sec2); }
.card-icon-sec3 { background: var(--sec3); }
.card-icon-sec4 { background: var(--sec4); }
.card-icon-sec5 { background: var(--sec5); }
.card-icon-sec6 { background: var(--sec6); }
.card-icon-sec7 { background: var(--sec7); }

/* ============================================================
 * ステータス表示
 * ============================================================ */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
}
.status-pending { background: var(--sec3-bg); color: var(--sec3); }
.status-progress { background: var(--sec1-bg); color: var(--sec1); }
/* 中断中: 作業中（進行）と完了の間。手が止まっている状態なので警告寄りの色を当てる */
.status-paused { background: var(--sec4-bg); color: var(--sec4); }
.status-done { background: var(--sec2-bg); color: var(--sec2); }
.status-cancel { background: #f3f0ec; color: var(--text-muted); }

/* ============================================================
 * サマリーグリッド（一覧ページ用）
 * ============================================================ */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

/* ============================================================
 * レスポンシブ
 * ============================================================ */
@media (max-width: 992px) {
  .two-col { grid-template-columns: 1fr; }
  .two-col > .sec { margin-bottom: 0; }

  /* 検索条件などの多列グリッドを段階的に折り返す（640px で 1 列化する前段）。
     4/5 列は狭幅で窮屈になるため 2/3 列へ緩和し、小型ノートでの崩れを防ぐ。 */
  .row-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  /* ナビバー: 横スクロール可能に */
  .top-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0;
  }
  .nav-item > a,
  .nav-item > span {
    padding: 0 12px;
    font-size: 13px;
  }
  .nav-user {
    padding-left: 8px;
  }
}

@media (max-width: 640px) {
  .row-2, .row-3, .row-4, .row-5 { grid-template-columns: 1fr; }
  .check-row { flex-direction: column; }
  .profit-bar { flex-direction: column; }
  .profit-cell { border-right: none; border-bottom: 1px solid var(--border); }
  .btn-go { padding: 0 38px; font-size: 18px; }
  .page-title-area { flex-direction: column; align-items: flex-start; gap: 12px; }

  /* ナビバー: さらにコンパクト */
  .top-bar {
    padding: 0 12px;
    height: 48px;
  }
  .top-bar .logo {
    font-size: 16px;
    margin-right: 12px;
  }
  .nav-item > a,
  .nav-item > span {
    padding: 0 10px;
    font-size: 12px;
  }

  /* ドロップダウン: モバイルでも使えるように */
  .dropdown-menu {
    position: absolute;
    left: 0;
    min-width: 160px;
    border-radius: 0 0 8px 8px;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  /* サマリーグリッド: 2列に変更 */
  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================================
 * 共通確認モーダル
 * ============================================================ */
.confirm-modal-icon { font-size: 48px; margin-bottom: 16px; }
.confirm-modal-icon.type-danger { color: #e74c3c; }
.confirm-modal-icon.type-warning { color: #f39c12; }
.confirm-modal-icon.type-success { color: #27ae60; }
.confirm-modal-body { text-align: center; padding: 24px 24px 16px; }
.confirm-modal-msg { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.confirm-modal-hint { font-size: 13px; color: var(--text-muted); }
.ccm-check-line { display: block; margin-top: 14px; font-size: 13px; font-weight: 600; cursor: pointer; }
.ccm-check-line input { margin-right: 6px; }
/* 確認モーダルの理由入力欄（所有分離Phase B 横持ち理由など） */
.ccm-reason-wrap { margin: 14px 0 4px; text-align: left; }
.ccm-reason-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-soft); }
.ccm-reason-input { width: 100%; box-sizing: border-box; padding: 8px 10px; font-size: 14px; border: 1px solid var(--border); border-radius: 6px; resize: vertical; }
.btn-confirm-danger {
  background: #e74c3c;
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-confirm-danger:hover { background: #c0392b; }
.btn-confirm-warning {
  background: #f39c12;
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-confirm-warning:hover { background: #d68910; }
.btn-confirm-success {
  background: #27ae60;
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-confirm-success:hover { background: #1e8449; }

/* ============================================================
 * order: インラインCSS外部化
 * ============================================================ */

/* ページアイコン */
.icon-page-title { color: var(--sec1); }

/* ナビアクティブリンク */
.nav-link-active { color: #fff; }

/* フォームスペーシング */
.form-group-spacing-lg { margin-top: 16px; }

/* オプション説明文 */
.option-desc { font-size: 18px; color: var(--text-soft); margin: 0 0 16px; }

/* テーブルアイコン色 */
.tbl-icon-sec4 { background: var(--sec4); }

/* バッジ補助 */
.badge-ml { margin-left: 8px; }

/* ボタンアウトライン色バリエーション */
.btn-outline-sec1 { border-color: var(--sec1); color: var(--sec1); }
.btn-outline-sec1:hover { background: var(--sec1); color: #fff; }
.btn-outline-sec2 { border-color: var(--sec2); color: var(--sec2); }
.btn-outline-sec2:hover { background: var(--sec2); color: #fff; }
.btn-outline-sec3 { border-color: var(--sec3); color: var(--sec3); }
.btn-outline-sec3:hover { background: var(--sec3); color: #fff; }
.btn-outline-sec4 { border-color: var(--sec4); color: var(--sec4); }
.btn-outline-sec4:hover { background: var(--sec4); color: #fff; }
.btn-outline-sec7 { border-color: var(--sec7); color: var(--sec7); }
.btn-outline-sec7:hover { background: var(--sec7); color: #fff; }

/* テーブルスクロール・幅 */
.tbl-scroll { overflow-x: auto; }
.dt-wide { min-width: 1200px; }

/* 商品明細テーブルヘッダー幅
 * 品名・材質・サイズは構成一覧(BOM)と同等の入力スペースを確保するため広め */
.th-number { width: 32px; text-align: center; }
.th-type { width: 56px; }
.th-name { min-width: 220px; }
/* 品名列。仕様はサブ行に落ちるので th-name(220px) より詰められる。
   .th-item は system_settings のフィールド行列が別用途で使っているため名前を分ける
   （td 側の .td-item-name と対になる命名に揃える）。 */
.th-item-name { min-width: 190px; }
.th-material { min-width: 180px; }
.th-size { min-width: 220px; }
.th-drawing { min-width: 180px; }
.th-qty { width: 100px; text-align: right; }
.th-mfg-qty { width: 100px; text-align: right; }
.th-mfg-input-qty { width: 100px; text-align: right; }
.th-stock-use { width: 75px; text-align: center; }
.th-price { width: 130px; text-align: right; }
.th-lead-days { width: 90px; text-align: right; }
.th-amount { width: 130px; text-align: right; }
.th-mfg-date { width: 150px; }
.th-memo { width: 36px; text-align: center; font-size: 11px; }
.th-spec { width: 52px; text-align: center; font-size: 11px; }
.th-spec-list { min-width: 140px; }
.th-delete { width: 44px; text-align: center; font-size: 11px; }
/* 行操作（上へ／下へ／下に挿入／削除）をまとめた列 */
.th-row-ops { width: 132px; text-align: center; font-size: 11px; }

/* BOMテーブルヘッダー幅 */
.th-expand { width: 36px; }
.th-sub-num { width: 70px; }
.th-kosei { width: 100px; }
.th-seizou { width: 100px; }
.th-mfg { width: 100px; text-align: right; }

/* 型式・在庫数列 */
.th-katashiki { width: 180px; }
.th-stock { width: 75px; text-align: center; }
.dt-bom .th-number { width: 50px; }
.dt-bom .th-type { width: 80px; }
.dt-bom .th-stock { width: 75px; }

/* Tab②追加ヘッダー幅 */
.th-supplier     { width: 140px; }
.th-vendor       { width: 140px; }
.th-process-name { width: 140px; }
.th-person       { width: 120px; }
.th-status       { width: 120px; }
.th-shipno       { width: 140px; }
.cw-shipno       { text-align: center; }
.th-customer     { width: 160px; }
.th-actual-done  { width: 72px; text-align: right; }
.th-kubun        { width: 100px; }
/* 受注拠点列など: 全角6文字目安の固定幅。超過は省略記号(…)、全文は title でホバー表示 */
.th-branch       { width: 124px; }
.td-branch       { max-width: 124px; overflow: hidden; text-overflow: ellipsis; }
.th-completion   { width: 48px; text-align: center; } /* ※未使用: 工程の完成列は#列へ統合し廃止（2026-07-29） */
.th-keyword      { width: 120px; }
.th-check        { width: 60px; text-align: center; }
.th-date         { width: 150px; }
.th-rn           { width: 40px; text-align: center; }
.th-category     { width: 100px; }
.th-code         { width: 120px; }
.th-tracking     { width: 210px; }  /* 送り状No: 入力欄＋保存ボタンが並ぶ幅 */

/* 外注受入モーダル 受入記録テーブルヘッダー幅 */
.th-osr-date     { width: 120px; }
.th-osr-qty      { width: 80px; text-align: right; }
.th-osr-defect   { width: 80px; text-align: right; }
.th-osr-note     { width: auto; }
.th-action-edit  { width: 100px; text-align: center; }
.th-action-print { width: 130px; text-align: center; }
.th-action       { width: 96px; text-align: center; }
.th-lot          { width: 120px; }
.th-order-no     { width: 140px; }
.th-note         { min-width: 160px; }
.th-branch       { width: 56px; text-align: center; }
.th-qr           { width: 180px; }
.th-action-multi { width: 230px; text-align: center; }
.th-progress     { width: 140px; }

/* 進捗セル（状態バッジ＋数量サブを縦積み・入荷進捗等で共用） */
.progress-cell { display: flex; flex-direction: column; gap: 4px; min-width: 110px; }

/* 汎用ユーティリティ: 要素を非表示（JSトグル等の display 切替用） */
.is-hidden { display: none !important; }

/* 列の表示/非表示: 設定でOFFにした列（th/td）を非表示にする */
.col-hidden { display: none !important; }

/* 箱・枝番管理（仕入登録・製造調達など複数ページで共用） */
.th-box-manage    { width: 60px; text-align: center; }
.cw-box-manage    { width: 60px; }
.th-box-count     { width: 74px; text-align: right; }
.cw-box-count     { width: 110px; }
.cw-box-count .ci { min-width: 80px; }
.th-unit-per-box     { width: 120px; text-align: right; }
.cw-unit-per-box     { width: 120px; }
.cw-unit-per-box .ci { min-width: 90px; }
/* 「最大セット数/梱包」は見出しが長く、nowrap のままだと列幅の下限が 138px になる。
   ラベルは意味が分かる形で残したいので短縮せず、th 側に <br> を入れて
   「最大セット数 / /梱包」の2行で折る。min-width は1行目が入る幅。
   width だと auto レイアウトで圧縮に耐えられず、潰れた幅で折り返しが暴走する。 */
.th-sets-per-bag     { min-width: 108px; text-align: right; }
.dt thead th.th-sets-per-bag { white-space: normal; }
.cw-sets-per-bag     { width: 120px; }
.cw-sets-per-bag .ci { min-width: 90px; }

/* セル配置 */
.ci-right { text-align: right; }
.ci-readonly-amount { text-align: right; background: var(--bg); color: var(--text-soft); }
/*----------------------------------------------------------
 * テーブル内 日付入力（flatpickr 用）ヘルパー
 * order.css / purchase_order_detail.css に重複していた同名定義を共通化。
 * .ci-date-wrap でアイコンを重ね、.flatpickr-ci は JS 初期化対象の識別マーカー。
 *----------------------------------------------------------*/
.ci-date-wrap { position: relative; display: inline-block; width: 100%; }
.ci-date-wrap .ci { padding-right: 32px; cursor: pointer; }
.ci-date-icon {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  color: var(--sec1); font-size: 14px; pointer-events: none;
}
/* flatpickr は allowInput 未指定だと input に readonly を自動付与するため、
 * `.ci.is-locked, .ci[readonly]`（order.css）の編集ロック用グレーに巻き込まれ、
 * カレンダーで編集できる日付セルまでグレー＝ロック済みに見えてしまう。
 * フォーム側 `.fi-date-wrap .fi[readonly]`（下部）と対称に、ci-date-wrap 内の
 * flatpickr 日付セルは白＝編集可の見た目へ戻す。真のロック（disabled + is-locked）は除外して従来どおりグレー維持。 */
.ci-date-wrap .ci[readonly]:not(.is-locked):not([disabled]) {
  background-color: #fff !important;
  color: var(--text);
  cursor: pointer;
}
/* flatpickr-ci: 親 .ci のスタイルを継承（flatpickr 初期化対象の識別用マーカー） */
.flatpickr-ci {}
/* 入荷予定ワークリスト等で「処理済み」になった行の抑制表示 */
tr.is-received { opacity: 0.6; background: var(--bg); }
/* 箱管理 ON 時、数量は自動算出（手入力不可）であることを示す汎用 readonly セル */
.ci-readonly { background: var(--bg); color: var(--text-soft); }
.td-center { text-align: center; }
.ta-right { text-align: right; }
.cw-check { text-align: center; }
.td-nowrap { white-space: nowrap; }
/* 操作セルのボタン群を横1行に並べる（折返し不可・はみ出しはテーブル横スクロールで対応） */
.cw-action-inline {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* 操作セル: ボタンが3つ以上入る一覧で行に分けて畳む。
   .dt tbody td の white-space: nowrap のままだと全ボタンが一列に伸び、
   列幅（＝テーブル幅）を押し広げて横スクロールの原因になる。
   セレクタは .dt tbody td の詳細度(0,1,2)を上回る必要がある。 */
.dt tbody td.cw-action-wrap { white-space: normal; }
.dt tbody td.cw-action-wrap .act-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}
/* 1行分（種別ラベル＋出力形式ボタン群）。例: 「現品票 [A4][ラベル]」 */
.dt tbody td.cw-action-wrap .act-row {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.dt tbody td.cw-action-wrap .act-row-label {
  font-size: 11px;
  color: var(--text-soft);
  min-width: 44px;
  text-align: right;
}

/* 統合フィールド設定マトリクス（system_settings.php 表A〜D） */
.th-item { min-width: 120px; }
.th-toggle { width: 110px; text-align: center; }
.th-cat { width: 88px; }
.ck-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.ck-cell input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--sec6);
  cursor: pointer;
}
.cell-na { color: var(--text-muted); }
.cell-fixed { color: var(--text-soft); font-weight: 700; font-size: 13px; }
.matrix-cat { font-weight: 700; color: var(--text-soft); vertical-align: middle; }

/* セル内の補助テキスト（品名の下の材質・得意先名など。小さく薄く改行表示） */
.td-sub {
    display: block;
    font-size: 11px;
    color: var(--text-soft);
    margin-top: 2px;
}

/* セル内アクションアイコン群（詳細一覧へ / レコードへ / コピー）
 * 主値の脇に小さく添え、一覧の回遊とコピーを助ける汎用パーツ */
.cell-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 6px;
    vertical-align: middle;
}
.cell-action {
    display: inline-flex;
    align-items: center;
    border: none;
    background: none;
    padding: 2px;
    cursor: pointer;
    color: var(--text-soft);
    font-size: 12px;
    line-height: 1;
    text-decoration: none;
    transition: color 0.15s;
}
.cell-action:hover { color: var(--sec1); }
.cell-action.is-copied { color: var(--sec2); }
/* 無効（グレーアウト）: 遷移先が無い行き先アイコン。span＝非クリックだが理由ツールチップは出す */
.cell-action.is-disabled {
    color: var(--border);
    cursor: not-allowed;
}
.cell-action.is-disabled:hover { color: var(--border); }

/* 階層（ルート）列: 受注→受注明細… を縦に。各レベル=行き先アイコン＋番号＋コピー */
.route-level {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.route-level + .td-sub { margin-top: 1px; }
.route-num { font-size: 13px; }
/* 遷移先を持たないレベルの静的アイコン（在庫向け製造Lot 等） */
.route-icon-static { color: var(--text-soft); font-size: 12px; }
/* 値なしを示す薄いダッシュ */
.td-muted { color: var(--text-soft); }
/* セル内の警告値（不良数など、0超で注意喚起する数値）を赤字表示 */
.td-danger { color: var(--danger); }

/* 一覧の主キー的リンク（受注番号・得意先名など） */
.customer-name-link {
    color: var(--sec1);
    font-weight: 700;
    text-decoration: none;
}
.customer-name-link:hover {
    color: var(--sec1);
    text-decoration: underline;
}
.td-memo {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: help;
}
.td-memo-empty {
    color: var(--text-muted);
}
/* カスタムツールチップ（common-tooltip.js が生成、position: fixed で body 直下に配置）
 * - data-tooltip 属性を持つ要素に hover/focus で即時表示
 * - 祖先 overflow に切られず、ビューポート末尾なら上側に自動切替
 */
.badge-tip {
    cursor: help;
}
.tooltip-popup {
    position: fixed;
    z-index: 9999;
    background: #2a2218;
    color: #fff;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.65;
    white-space: pre-line;
    text-align: left;
    min-width: 200px;
    max-width: 380px;
    width: max-content;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
    pointer-events: none;
    animation: tooltip-fade-in 0.08s ease-out;
}
@keyframes tooltip-fade-in {
    from { opacity: 0; transform: translateY(-2px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* チェックボックスフォーム要素（検索パネル内など） */
.fg-checkbox {
    display: flex;
    align-items: center;
}
/* 複数チェックを1行に並べるグループ（ラベル＋複数 checkbox-label を折返し可で等間隔に） */
.fg-checkbox-group {
    flex-wrap: wrap;
    gap: 8px 20px;
}
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    user-select: none;
}
.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--sec1);
}

/* 商品明細一覧: 不良・再製造行のマーキング */
.row-defect td {
    background: #fdf3f0;
}
.row-defect:hover td {
    background: #fbe9e3;
}
.badge-defect {
    background: #fde2dc;
    color: #c44a2e;
    margin-left: 4px;
}

/* 商品明細一覧: 商品番号セル（受注番号プレフィックス省略表示、ホバーで完全形） */
.td-item-no {
    font-family: 'M PLUS Rounded 1c', monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--sec1);
    white-space: nowrap;
}

/* 商品明細一覧: 一体ものツリー（メイン→サブ→パーツの入れ子表示） */
/* 行の背景は種別バッジの色をベースにした淡色（メイン=橙/サブ=緑/パーツ=紫）。
   単品は白（既定）。不良(row-defect)の赤は優先するため :not(.row-defect) で除外。 */
.dt tbody tr.item-main:not(.row-defect) > td { background: var(--sec3-bg); }
.dt tbody tr.item-sub:not(.row-defect)  > td { background: var(--sec2-bg); }
.dt tbody tr.item-part:not(.row-defect) > td { background: var(--sec4-bg); }
.tree-name-cell.tree-d1 { padding-left: 24px; }
.tree-name-cell.tree-d2 { padding-left: 46px; }
.tree-name-cell.tree-d3 { padding-left: 68px; }
.tree-name-cell.tree-d4 { padding-left: 90px; }
.tree-branch { color: var(--text-soft); margin-right: 2px; }
/* ルート行(depth0)の上に境界線を引き、一体ものグループの切れ目を明確にする。
   ルート＝グループの先頭なので、ここに区切り線が入ると次のグループとの境界が分かる。 */
.dt tbody tr.tree-depth-0 > td { border-top: 2px solid var(--border); }

/* 納期遅延バッジを日付の上に別行で（列幅を広げない） */
.td-delay { margin-bottom: 2px; line-height: 1; }

/*----------------------------------------------------------
 * 押せるバッジ（badge-link）＝立体で示す
 *
 * 一覧のバッジには「押すと別画面へ飛べるもの」と「ただの状態表示」が
 * 混在する。色と塗りは状態（緑=完了/橙=一部/灰=未着手）が既に使い切って
 * いるため、押せることは色ではなく「浮いているか」で示す。
 * リンクは浮き、hover/focus で沈む。押せないバッジは平らなまま。
 *
 * ■ 同一セル内で浮きと平らが混ざるのは仕様
 *   出荷状況セル（計画/確保/引当/納品）は行によってリンクの立つ数が
 *   変わるため、浮いたバッジと平らなバッジが並ぶ。これは「どれが押せるか」
 *   を示すための意図的な差であり、不揃いではない。揃えないこと。
 *
 * ■ .badge-icon を除外する理由
 *   不良/再製造のアイコンのみバッジ（padding 3px 6px）は
 *   .cell-kind { line-height: 1 } の省スペース行に置かれており、
 *   影が下の受注番号に食い込む。これらは常にリンク付きで
 *   「押せる/押せない」が混在しないため、除外しても支障がない。
 *----------------------------------------------------------*/
a.badge-link {
  display: inline-block;   /* 既定の inline では影・位置ずらしが効かないため必須 */
  text-decoration: none;
  cursor: pointer;
}
a.badge-link:hover { text-decoration: none; }
a.badge-link .badge:not(.badge-icon) {
  position: relative;
  top: -1px;
  border: 1px solid rgba(61, 53, 41, 0.16);
  box-shadow: 0 2px 0 rgba(61, 53, 41, 0.16);
}
/* 押した感触: 影の分だけ沈める（合計の高さは変わらないので行が揺れない） */
a.badge-link:hover .badge:not(.badge-icon),
a.badge-link:focus-visible .badge:not(.badge-icon) {
  top: 1px;
  box-shadow: 0 0 0 rgba(61, 53, 41, 0.16);
}

/* リンクの無い n/m バッジ（ProgressBadge が付与）。
   現状は見た目を変えない。利用者から「まだ分かりにくい」と出た場合に
   ここへ「塗りを外す」定義を足すだけで一段強い区別に切り替えられる。 */
/* .badge-static { } */

/* 一覧の行ハイライト（他画面から highlight_item で誘導された該当 order_item の行）。
   梱包指示一覧・出荷指示一覧で、遷移元の商品行を目立たせる。 */
.dt tbody tr.row-highlight > td { background: #fff5d6 !important; }
.dt tbody tr.row-highlight > td:first-child { box-shadow: inset 3px 0 0 var(--sec1); }

/* 商品明細一覧: 受注グループヘッダ行（同じ受注の明細群を視覚的にまとめる） */
.row-order-header td {
    background: linear-gradient(to right, var(--sec1-bg), #fdfaf3);
    border-left: 4px solid var(--sec1);
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text);
}
.row-order-header .og-order-no {
    color: var(--sec1);
    font-weight: 700;
    text-decoration: none;
    font-size: 14px;
    margin-right: 4px;
}
.row-order-header .og-order-no:hover {
    text-decoration: underline;
}
.row-order-header .og-order-no i {
    margin-right: 4px;
}
.row-order-header .og-customer {
    font-weight: 600;
    color: var(--text);
}
.row-order-header .og-meta {
    color: var(--text-soft);
}
.row-order-header .og-divider {
    color: var(--border);
    margin: 0 10px;
}
.row-order-header .status {
    margin-left: 4px;
}

/* 受注一覧: 商品明細行（with_items フラグON時に展開） */
.row-items td.td-items {
    background: #faf7f2;
    padding: 8px 12px 10px 32px;
    border-bottom: 1px solid var(--border);
}
.row-items .item-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.row-items .item-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
    font-size: 13px;
    color: var(--text);
}
.row-items .item-row--sub  { padding-left: 16px; }
.row-items .item-row--part { padding-left: 32px; }
.row-items .item-type {
    display: inline-block;
    min-width: 48px;
    text-align: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    background: var(--sec1-bg);
    color: var(--sec1);
}
.row-items .item-type--main { background: var(--sec3-bg); color: var(--sec3); }
.row-items .item-type--sub  { background: var(--sec2-bg); color: var(--sec2); }
.row-items .item-type--part { background: var(--sec4-bg); color: var(--sec4); }
.row-items .item-name  { font-weight: 600; }
.row-items .item-size  { color: var(--text-soft); }
.row-items .item-steel { color: var(--text-soft); }
.row-items .item-qty   { color: var(--text); font-weight: 600; margin-left: auto; padding-left: 12px; }

.fi-date-range {
    display: flex;
    gap: 6px;
    align-items: center;
}
.fi-date-range .fi-date-wrap {
    flex: 1;
    min-width: 0;
}
/* 日付レンジ From/To プリセットボタン群（date-range-presets.js と連携） */
.fi-date-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}
.btn-date-preset {
    height: 28px;
    padding: 0 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text-soft);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-date-preset:hover {
    background: var(--sec1-bg);
    border-color: var(--sec1-light);
    color: var(--sec1);
}
.btn-date-preset:active {
    background: var(--sec1-light);
}
/* 検索結果インフォバー（左: 件数表示 / 右: 件数切替フォーム） */
.result-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin: 12px 0;
    flex-wrap: wrap;
}
/* ピンポイント絞り込み中バナー（製造一覧の製造Lot→工程一覧 等の絞り込み明示＋解除導線） */
.filter-pin {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin: 0 0 12px;
    padding: 8px 14px;
    background: var(--sec-info-bg);
    border: 1px solid var(--sec-info);
    border-radius: 6px;
    color: var(--sec-info);
    font-size: 13px;
    font-weight: 600;
}
.result-info-left {
    flex: 1;
    min-width: 0;
}
.result-info-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.result-info-right .fg-label {
    margin: 0;
    white-space: nowrap;
}
/* 件数選択（Select2 化）の最小幅 — 「100件」が見切れないように */
.select2-per-page + .select2-container {
    min-width: 100px;
}
.select2-per-page + .select2-container .select2-selection__rendered {
    padding-right: 24px;
}

/* 所有（汎用／得意先専用／支給材）の内訳を縦に積むセル・情報欄の1行
   在庫一覧の所有列と品目詳細の所有内訳で共有する */
.owner-line { display: block; line-height: 1.8; }
.owner-line + .owner-line { margin-top: 2px; }
/* 区分ラベルと数量の幅を揃え、行どうしを縦に並べて見比べられるようにする
   （得意先名は長さがまちまちなので、数量より後ろに置く） */
.owner-line { white-space: nowrap; }
/* 区分バッジ（汎用／専用／支給材）は文字数が違っても同じ幅にして、
   行どうしで数量の開始位置を揃える */
.owner-line .owner-kind { display: inline-block; }
.owner-line .owner-kind .badge {
  display: inline-block;
  min-width: 62px;
  text-align: center;
}
.owner-line .owner-qty  { display: inline-block; min-width: 48px; text-align: right; margin-right: 4px; }
/* 得意先名は少し小さく。長い社名（最長18文字）でも省略されずに収まりやすくする */
.owner-line .owner-cust { font-size: 12px; }

/* 品名セルの上に出す状態バッジ列（状態を独立列にせず列幅を節約する） */
.item-status-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}
/* 所有セルは「区分＋数量＋得意先名」を1行に収める。得意先名が長い場合は
   セル内で省略し、行が折り返して数量の縦位置がずれるのを防ぐ */
.dt td.td-owner { white-space: nowrap; min-width: 320px; max-width: 360px; }
.dt td.td-owner .owner-line { overflow: hidden; text-overflow: ellipsis; }

/* バッジサイズ */
.badge-sm { font-size: 13px; }
/* 状態内訳など複数バッジを並べるセル: dt-nowrap でも折り返して全バッジを見せる */
.dt-nowrap td.td-breakdown,
.dt td.td-breakdown { white-space: normal; min-width: 240px; line-height: 2; }
/* 長文セル（明細サマリ等）を省略表示にして表の横幅を抑える */
.dt td.td-ellipsis { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
/* 届先（会社名＋拠点名）は 320px でも列を押し広げるため個別に詰める */
.dt td.td-dest { max-width: 134px; }
/* 品名＋仕様サブ行のセル。省略しても仕様がサブ行に残るので短めで足りる */
.dt td.td-item-name { max-width: 182px; }
/* 引当セル。引当ロットのサブ行が長く列を押し広げるため幅を固定する。
   省略（ellipsis）にすると複数Lotの2件目以降がクリックできなくなるので、
   折り返して全Lotをリンクのまま見せる（縦に伸びるだけで列幅は変わらない）。 */
.th-alloc { width: 150px; }
.dt tbody td.td-alloc { max-width: 152px; }
.dt tbody td.td-alloc .td-sub {
  white-space: normal;
  overflow-wrap: anywhere;
}
.badge-xs { font-size: 12px; }

/* バッジ色バリエーション */
.badge-main { font-size: 13px; background: var(--sec3-bg); color: var(--sec3); }
.badge-sub { font-size: 13px; background: var(--sec2-bg); color: var(--sec2); }
.badge-part { font-size: 12px; background: var(--sec4-bg); color: var(--sec4); }
.badge-sub-count { font-size: 12px; background: var(--sec2-bg); color: var(--sec2); }
.badge-part-count { font-size: 12px; background: var(--sec4-bg); color: var(--sec4); }

/* マスタ準拠バッジ（product_id 保持 = マスタ値完全一致時） */
.badge-master { font-size: 11px; background: var(--sec1-bg); color: var(--sec1); }

/* +サブ / +パーツ インライン追加ボタン（pill型） */
.btn-add-sub,
.btn-add-part {
  display: inline-block;
  padding: 2px 10px;
  margin-left: 4px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 20px;
  cursor: pointer;
  vertical-align: middle;
  transition: background 0.15s, color 0.15s;
}
.btn-add-sub {
  color: #fff;
  background: var(--sec-sub);
  border: 1px solid var(--sec-sub);
}
.btn-add-sub:hover {
  background: var(--sec-sub-light);
  color: var(--sec-sub);
}
.btn-add-part {
  color: #fff;
  background: var(--sec-part);
  border: 1px solid var(--sec-part);
}
.btn-add-part:hover {
  background: var(--sec-part-light);
  color: var(--sec-part);
}

/* BOM 構造凍結（製造計画あり）時の操作ボタン無効状態 */
.btn-add-sub:disabled,
.btn-add-part:disabled,
.btn-add-sub.is-locked,
.btn-add-part.is-locked,
.dt .del-btn:disabled,
.dt .del-btn.is-locked {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* 一体もの展開エリア */
.collapse-cell-p0 { padding: 0; }
.onething-detail-content { padding: 16px 24px; background: #fff; border-top: 1px solid var(--sec4-light); }
.detail-header-flex { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.flex-icon-label { display: flex; align-items: center; gap: 8px; }
.detail-title { font-size: 15px; font-weight: 700; }
.icon-sec1 { color: var(--sec1); }
.icon-sec3 { color: var(--sec3); font-size: 16px; }

/* 小サイズテーブルボタン */
.btn-tbl-sm { font-size: 12px; padding: 4px 12px; }
.btn-tbl-xs { font-size: 11px; padding: 3px 10px; }

/* BOMテーブル */
.dt-bom { background: #fff; border-radius: var(--radius-sm); overflow: hidden; }

/* トグルセル */
.td-toggle { text-align: center; cursor: pointer; }
.chevron-toggle { font-size: 11px; }
.chevron-sec2 { color: var(--sec2); }
.chevron-sec3 { color: var(--sec3); margin-right: 4px; }

/* パーツインデント */
.td-indent-parts { white-space: nowrap; padding-left: 6px; }

/* パーツ追加行パディング */
.td-add-part-padding { padding: 6px 6px 6px 20px; }

/* BOMサマリーバー */
.bom-summary-bar { display: flex; gap: 16px; margin-top: 12px; padding: 10px 16px; background: rgba(139,114,184,0.08); border-radius: var(--radius-sm); }
.bom-summary-text { font-size: 12px; color: var(--text-muted); }

/* テキスト色 */
.text-sec1 { color: var(--sec1); }
.text-sec4 { color: var(--sec4); }

/* テキストウェイト */
.text-bold { font-weight: 700; }

/* アイコン色 */
.icon-muted { color: var(--text-muted); }

/* フッターアイコン */
.icon-mr-sm { margin-right: 4px; }

/* モーダル */
.modal-card { border-radius: var(--radius); border: none; box-shadow: 0 8px 32px rgba(0,0,0,0.15); }
.modal-header-styled { background: var(--sec3-bg); border-bottom: 1px solid var(--sec3-light); padding: 16px 24px; }
.modal-title-lg { font-size: 16px; font-weight: 700; }
.modal-icon-sec1 { color: var(--sec1); margin-right: 8px; }
.modal-icon-sec2 { color: var(--sec2); margin-right: 8px; }
.modal-icon-sec3 { color: var(--sec3); margin-right: 8px; }
.modal-header-danger { background: var(--defect-bg); border-bottom: 1px solid var(--defect); padding: 16px 24px; }
.modal-title-danger { color: var(--defect); }
.modal-icon-danger { color: var(--defect); margin-right: 8px; }
.modal-body-padded { padding: 24px; }
.modal-footer-styled { border-top: 1px solid var(--border); padding: 12px 24px; }

/* メモテキストエリア */
.fi-memo { width: 100%; resize: vertical; font-size: 14px; }
.fg-hint-mt { margin-top: 8px; }

/* Select2統合（.fi フォーム入力に合わせたスタイル） */
.select2-container--bootstrap4 .select2-selection--single {
  height: 50px !important;
  border: 2px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  background: #fff;
  font-family: inherit;
  /* × クリアボタンを absolute 配置するため基準を明示（select2既定でも relative だが念のため） */
  position: relative;
}
.select2-container--bootstrap4 .select2-selection--single .select2-selection__rendered {
  line-height: 46px;
  font-size: 18px;
  color: var(--text);
  padding-left: 16px;
  padding-right: 38px;
  /* select2 4.1 の × ボタン（button）が block 化してテキストを次行へ押し出すのを防ぐ */
  white-space: nowrap;
}
.select2-container--bootstrap4 .select2-selection--single .select2-selection__arrow {
  top: 0 !important;
  height: 100%;
  right: 8px;
}
.select2-container--bootstrap4 .select2-selection--single .select2-selection__arrow b {
  border-color: var(--text-muted) transparent transparent transparent;
  border-width: 6px 5px 0 5px;
  top: 50% !important;
  transform: translateY(-50%);
  margin-top: 0 !important;
}
.select2-container--bootstrap4.select2-container--focus .select2-selection--single {
  border-color: var(--sec1) !important;
  box-shadow: 0 0 0 4px var(--sec1-bg) !important;
}
.select2-container--bootstrap4 .select2-selection--single .select2-selection__placeholder {
  color: var(--text-muted);
  font-size: 15px;
}
.select2-container--bootstrap4 .select2-selection--single .select2-selection__clear {
  font-size: 20px;
  /* Bootstrap4 テーマのデフォルト color が #f8f9fa（背景同色）で見えないため上書き
     テーマ側 CSS の優先度が高いため !important で強制 */
  color: #888 !important;
  /* select2 4.1 は × を <button> で描画するが bootstrap4-theme 1.5.2 は未対応。
     ネイティブbutton枠を解除し absolute 配置して、選択テキストを欄外へ押し出さない。
     縦位置は top:0/bottom:0 で選択枠の全高に張り、flex で×グリフを縦中央寄せする
     （旧 top:50%+translateY は containing block の実測とズレ +14px 発生したため廃止）。
     right は矢印(right:8px)と整合。選択中は矢印が非表示になる（下部ルール）ため重ならない */
  position: absolute !important;
  right: 10px;
  top: 0 !important;
  bottom: 0 !important;
  height: auto !important;
  width: auto !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  line-height: 1;
  background: transparent;
  border: 0;
  padding: 0 !important;
  margin: 0 !important;
  -webkit-appearance: none;
  appearance: none;
  z-index: 1;
}
.select2-container--bootstrap4 .select2-selection--single .select2-selection__clear > span {
  color: #888 !important;
}
.select2-container--bootstrap4 .select2-selection--single .select2-selection__clear:hover,
.select2-container--bootstrap4 .select2-selection--single .select2-selection__clear:hover > span {
  color: #d04848 !important;
}
/* 選択中（clearable）は × ボタンが出るため、▼ 矢印を非表示にして重なりを防ぐ */
.select2-container--bootstrap4 .select2-selection--single.select2-selection--clearable .select2-selection__arrow {
  display: none;
}

/* --- Select2 複数選択（pill）補正 ---
 * select2 4.1 は選択pillの remove を <button> で描画するが、bootstrap4-theme 1.5.2 は
 * 旧 <span> 前提のため未対応 → ネイティブbutton枠が出て崩れる。pillの塗り・×ボタンの
 * chrome解除・折り返し（高さauto）を明示補正する。品名結合設定/帳票表示設定で使用。 */
.select2-container--bootstrap4 .select2-selection--multiple {
  /* pill(ul) と inline検索(span) は兄弟要素。外枠を flex にして1行に収め、
     縦の余白を詰める（select2 4.1 では検索欄が別行に落ちて背が高くなるため） */
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  min-height: 34px;
  height: auto !important;
  border: 2px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  background: #fff;
  padding: 2px 6px;
}
.select2-container--bootstrap4.select2-container--focus .select2-selection--multiple {
  border-color: var(--sec1) !important;
  box-shadow: 0 0 0 4px var(--sec1-bg) !important;
}
.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__rendered {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  flex: 0 1 auto;
  width: auto;
  padding: 0;
  margin: 0;
}
.select2-container--bootstrap4 .select2-selection--multiple .select2-search--inline {
  display: flex;
  align-items: center;
  flex: 1 1 30px;
}
.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice {
  display: inline-flex;
  align-items: center;
  background-color: #eef1f5;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 10px;
  margin: 2px 6px 2px 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  float: none;
}
.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice__remove {
  order: 2;
  margin: 0 0 0 8px;
  padding: 0;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  color: #888;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice__remove:hover {
  color: #d04848;
  background: transparent !important;
}
.select2-container--bootstrap4 .select2-selection--multiple .select2-search--inline .select2-search__field {
  margin: 0;
  height: 24px;
}

/* テーブル内 Select2 (.ci) の高さを input.ci (42px) と統一
 * .fi 系の Select2 は既存の 50px を維持（フォーム入力高さに合わせ）
 * 隣接セレクタで element 単位に分離 */
select.ci + .select2-container--bootstrap4 .select2-selection--single {
  height: 42px !important;
}
select.ci + .select2-container--bootstrap4 .select2-selection--single .select2-selection__rendered {
  line-height: 38px;
  font-size: 16px;
  padding-left: 12px;
  padding-right: 32px;
}
/* テーブルセル内 Select2 の「間延び」対策（防御的ルール）
 * 症状: 複数行のテーブルで、下の行ほど select の幅が広がって不揃いになる。
 * 原因: Select2 の width:'resolve' は元 select の幅を読んでコンテナ幅を inline style で
 *   固定するが、table-layout:auto のテーブルでは行ごとに select を隠すたび列幅が
 *   再計算され、後続行が異なる幅に解決されてしまう。
 * 対策: セル内コンテナ幅を 100% に固定（!important で resolve の inline width に勝つ）。
 *   列幅はセル側（.cw-* の min-width 等）で決まり、全行が同一幅で揃う。
 *   併せて高さ 42px 固定・flex セルでの stretch 抑止も行う。 */
.dt td .select2-container {
  width: 100% !important; /* resolve の行ごと inline width を無効化し全行同一幅に */
  align-self: flex-start; /* 親が flex でも縦 stretch させない */
  vertical-align: middle;
}
.dt td .select2-container--bootstrap4 .select2-selection--single {
  height: 42px !important;
  min-height: 42px !important;
}
.dt td .select2-container--bootstrap4 .select2-selection--single .select2-selection__rendered {
  line-height: 38px;
}
.select2-container--bootstrap4 .select2-results__option {
  font-size: 16px;
  padding: 10px 16px;
}
.select2-container--bootstrap4 .select2-results__option--highlighted[aria-selected] {
  background: var(--sec1);
}
.select2-container--bootstrap4 .select2-search--dropdown .select2-search__field {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  padding: 8px 12px;
  font-family: inherit;
}
/* filter-row内のSelect2幅制御 */
.filter-row .select2-container { flex: 1; }

/* flatpickr統合（日付アイコン付きラッパー） */
.fi-date-wrap {
  position: relative;
}
.fi-date-wrap .fi {
  padding-right: 44px;
  cursor: pointer;
}
.fi-date-wrap .fi[readonly] {
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.fi-date-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--sec1);
  font-size: 18px;
  pointer-events: none;
}

/* flatpickr統合（.fi-sm コンパクト版） */
.fi-date-wrap .fi-sm {
  padding-right: 40px;
  cursor: pointer;
}
.fi-date-wrap .fi-sm[readonly] {
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

/* テーブルセル内Select（材質用） */
select.ci {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 14 14'%3E%3Cpath fill='%23a89f93' d='M3 5l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  padding-right: 22px;
  cursor: pointer;
  background-color: #fff;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
}
select.ci:focus {
  outline: none;
  border-color: var(--sec1);
  box-shadow: 0 0 0 3px var(--sec1-bg);
}

/* テーブルセル内Select2（材質用・コンパクト版） */
.ci-select2 .select2-container {
  width: 100% !important;
}
.ci-select2 .select2-container--bootstrap4 .select2-selection--single {
  height: 42px !important;
  min-height: 42px !important;
  border: 1.5px solid var(--border) !important;
  border-radius: 6px !important;
  background: #fff;
  font-family: inherit;
  padding: 0;
}
.ci-select2 .select2-container--bootstrap4 .select2-selection--single .select2-selection__rendered {
  line-height: 40px;
  font-size: 16px;
  font-weight: 400;
  color: var(--text);
  padding-left: 10px;
  padding-right: 26px;
}
.ci-select2 .select2-container--bootstrap4 .select2-selection--single .select2-selection__arrow {
  top: 0 !important;
  height: 100%;
  right: 4px;
}
.ci-select2 .select2-container--bootstrap4 .select2-selection--single .select2-selection__arrow b {
  border-color: var(--text-muted) transparent transparent transparent;
  border-width: 5px 4px 0 4px;
  top: 50% !important;
  transform: translateY(-50%);
  margin-top: 0 !important;
}
.ci-select2 .select2-container--bootstrap4.select2-container--focus .select2-selection--single {
  border-color: var(--sec1) !important;
  box-shadow: 0 0 0 3px var(--sec1-bg) !important;
}
.ci-select2 .select2-container--bootstrap4 .select2-selection--single .select2-selection__placeholder {
  color: var(--text-muted);
  font-size: 13px;
}

/* ============================================================
 * フォーム部品バリアント
 * ============================================================ */

/* .fi-sm — コンパクト版（検索パネル / モーダル用） */
.fi-sm {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.fi-sm:focus {
  outline: none;
  border-color: var(--sec1);
  box-shadow: 0 0 0 4px var(--sec1-bg);
}
.fi-sm::placeholder {
  color: var(--text-muted);
  font-size: 13px;
}
.fi-sm[disabled], .fi-sm[readonly] {
  background: var(--bg);
  color: var(--text-muted);
  cursor: default;
}
select.fi-sm {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath fill='%23a89f93' d='M3 5l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
textarea.fi-sm {
  height: auto;
  min-height: 60px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.6;
}

/* .fi-xs — ページネーション用 */
.fi-xs {
  height: 36px;
  padding: 0 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: auto;
}
.fi-xs:focus {
  outline: none;
  border-color: var(--sec1);
  box-shadow: 0 0 0 3px var(--sec1-bg);
}
select.fi-xs {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 14 14'%3E%3Cpath fill='%23a89f93' d='M3 5l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

/* ============================================================
 * Select2統合（.fi-sm コンパクト版）
 * ============================================================ */
.fi-sm + .select2-container--bootstrap4 .select2-selection--single,
.select2-sm .select2-container--bootstrap4 .select2-selection--single {
  height: 42px !important;
  border: 2px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  background: #fff;
  font-family: inherit;
}
.fi-sm + .select2-container--bootstrap4 .select2-selection--single .select2-selection__rendered,
.select2-sm .select2-container--bootstrap4 .select2-selection--single .select2-selection__rendered {
  line-height: 38px;
  font-size: 15px;
  color: var(--text);
  padding-left: 12px;
  padding-right: 32px;
}
.fi-sm + .select2-container--bootstrap4 .select2-selection--single .select2-selection__arrow,
.select2-sm .select2-container--bootstrap4 .select2-selection--single .select2-selection__arrow {
  top: 0 !important;
  height: 100%;
  right: 6px;
}
.fi-sm + .select2-container--bootstrap4 .select2-selection--single .select2-selection__arrow b,
.select2-sm .select2-container--bootstrap4 .select2-selection--single .select2-selection__arrow b {
  border-color: var(--text-muted) transparent transparent transparent;
  border-width: 5px 4px 0 4px;
  top: 50% !important;
  transform: translateY(-50%);
  margin-top: 0 !important;
}
.fi-sm + .select2-container--bootstrap4.select2-container--focus .select2-selection--single,
.select2-sm .select2-container--bootstrap4.select2-container--focus .select2-selection--single {
  border-color: var(--sec1) !important;
  box-shadow: 0 0 0 4px var(--sec1-bg) !important;
}
.fi-sm + .select2-container--bootstrap4 .select2-selection--single .select2-selection__placeholder,
.select2-sm .select2-container--bootstrap4 .select2-selection--single .select2-selection__placeholder {
  color: var(--text-muted);
  font-size: 13px;
}
.fi-sm + .select2-container--bootstrap4 .select2-selection--single .select2-selection__clear,
.select2-sm .select2-container--bootstrap4 .select2-selection--single .select2-selection__clear {
  /* 縦中央寄せ（top:50%+translateY）は基底ルールを継承。ここは小型の見た目のみ調整。
     水平は基底 right:10px を上書きし、コンパクトの矢印(right:6px)と整合させる */
  font-size: 18px;
  right: 8px;
}

/* ============================================================
 * 検索パネル内ラベル縮小
 * ============================================================ */
.search-panel .fg-label {
  font-size: 14px;
}

/* ============================================================
 * テーブルセル幅ユーティリティ
 * ============================================================ */
.ci-w70  { width: 70px; }
.ci-w90  { width: 90px; }
.ci-w100 { width: 100px; }
.ci-w120 { width: 120px; }
.ci-w130 { width: 130px; }
.ci-w150 { width: 150px; }
.ci-w160 { width: 160px; }
.ci-w180 { width: 180px; }

/* Select2コンテナへの幅伝播 */
.ci-w70  + .select2-container { width: 70px !important; }
.ci-w90  + .select2-container { width: 90px !important; }
.ci-w100 + .select2-container { width: 100px !important; }
.ci-w120 + .select2-container { width: 120px !important; }
.ci-w130 + .select2-container { width: 130px !important; }
.ci-w150 + .select2-container { width: 150px !important; }
.ci-w160 + .select2-container { width: 160px !important; }
.ci-w180 + .select2-container { width: 180px !important; }

/* 用途別テーブルセル幅 */
.ci-date   { width: 150px; }
.ci-qty    { width: 100px; }
.ci-price  { width: 130px; }
.ci-amount { width: 130px; }

/* 用途別Select2コンテナへの幅伝播 */
.ci-date   + .select2-container { width: 150px !important; }
.ci-qty    + .select2-container { width: 100px !important; }
.ci-price  + .select2-container { width: 130px !important; }
.ci-amount + .select2-container { width: 130px !important; }

/* ============================================================
 * データ型グループ幅クラス（tdに付与）
 * cw = column-width
 * ============================================================ */
.cw-text-s             { min-width: 180px; white-space: nowrap; }
.cw-text-s > *         { white-space: nowrap; }
.cw-text-l .ci { min-width: 220px; }
.cw-text-m .ci { min-width: 170px; }
.cw-qty .ci    { min-width: 100px; }
.cw-amount .ci { min-width: 130px; }
.cw-date .ci   { min-width: 150px; }
.cw-subject { min-width: 200px; }
.cw-subject .ci, .cw-subject .select2-container { min-width: 180px; }
/* 一括操作/発注などのコントロールバー（purchase_list.css から共通化） */
.po-control-bar { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
/* コントロールバー内の .fg は下マージンを消す。
 * align-items:flex-end はマージンボックス下端で揃うため、.fg の margin-bottom(18px)
 * が入力欄を素のボタンより上へずらして「上下が揃わない」原因になる。 */
.po-control-bar .fg { max-width: 220px; margin-bottom: 0; }
.cw-datetime .ci { min-width: 185px; }
.cw-select-l .ci, .cw-select-l .select2-container { min-width: 140px; }
.cw-select-m .ci, .cw-select-m .select2-container { min-width: 120px; }
.cw-select-s .ci, .cw-select-s .select2-container { min-width: 100px; }
.cw-customer .ci, .cw-customer .select2-container { min-width: 150px; }

/* 入荷計画テーブル(.dt-delivery)の列幅: 数量は5桁・日付はY-m-dちょうど・Lotは広め */
.dt-delivery .cw-amount .ci { min-width: 70px; }
.dt-delivery .cw-date .ci   { min-width: 120px; }
.dt-delivery .cw-lot .ci    { min-width: 200px; }

/* ----------------------------------------------------------
 * 入荷計画パネル（調達テーブル内インライン展開・共通）
 * 受注画面/発注書詳細など複数ページで使用
 *----------------------------------------------------------*/
.btn-delivery-toggle {
  border: none;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}
.btn-delivery-toggle:hover {
  background: var(--bg);
  color: var(--sec1);
}
.btn-delivery-toggle.active {
  color: var(--sec1);
}
.delivery-panel-row > td {
  padding: 0 !important;
  border-top: none !important;
}
.delivery-panel {
  background: var(--bg);
  border-top: 2px solid var(--border);
  border-bottom: 2px solid var(--border);
  padding: 12px 24px;
}
.delivery-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.delivery-panel-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}
.delivery-panel-title i {
  color: var(--sec1);
  margin-right: 6px;
}
.delivery-panel-summary {
  font-size: 13px;
  color: var(--text-soft);
}
.delivery-panel-summary strong {
  color: var(--text);
}
.dt-delivery {
  width: 100%;
  margin-bottom: 8px;
}
.delivery-actual {
  font-weight: 600;
}
.delivery-pending {
  color: var(--text-muted);
}
.mat-delivery-received {
  font-size: 12px;
  color: var(--text-soft);
  margin-left: 4px;
}
.th-delivery-toggle {
  width: 40px;
  text-align: center;
}

/* 日時用セル幅 */
.ci-datetime { width: 210px; }
.ci-datetime + .select2-container { width: 210px !important; }

/* ----------------------------------------------------------
 * ロックフィールド表示（共通）
 *----------------------------------------------------------*/
.ci-locked {
  position: relative;
}
.ci-locked::after {
  content: '\f023';
  font-family: 'Font Awesome 5 Free';
  font-weight: 900;
  position: absolute;
  top: 3px;
  right: 3px;
  font-size: 9px;
  color: #d4a017;
  opacity: 0.6;
  pointer-events: none;
  z-index: 5;
  line-height: 1;
}
.ci-locked:hover::after {
  opacity: 0.8;
}

/* ============================================================
 * Icon Color Utilities
 * data-driven な color/background を共通化（インラインCSS禁止対応）
 * ============================================================ */
.icon-color-sec1 { color: var(--sec1); }
.icon-color-sec2 { color: var(--sec2); }
.icon-color-sec3 { color: var(--sec3); }
.icon-color-sec4 { color: var(--sec4); }
.icon-color-sec5 { color: var(--sec5); }
.icon-color-sec6 { color: var(--sec6); }
.icon-color-sec7 { color: var(--sec7); }
.icon-color-process-accent { color: var(--process-accent); }

.icon-bg-sec1 { background: var(--sec1); }
.icon-bg-sec2 { background: var(--sec2); }
.icon-bg-sec3 { background: var(--sec3); }
.icon-bg-sec4 { background: var(--sec4); }
.icon-bg-sec5 { background: var(--sec5); }
.icon-bg-sec6 { background: var(--sec6); }
.icon-bg-sec7 { background: var(--sec7); }
.icon-bg-process-accent { background: var(--process-accent); }

/* ============================================================
 * Input Quick Symbols（記号挿入ボタン）
 * input-normalize.js が生成する記号挿入UIのスタイル
 * ============================================================ */
.quick-symbols {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.quick-symbol-btn {
  min-width: 36px;
  height: 28px;
  padding: 0 10px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.quick-symbol-btn:hover {
  background: var(--sec1-bg);
  border-color: var(--sec1);
}

.quick-symbol-btn:active {
  transform: translateY(1px);
}

/************************************************************
 * バリデーション赤枠（必須未入力等）
 * - .fi-error: フォーム input/select 用（fi クラス側）
 * - .ci-error: テーブル内 input/select 用（ci クラス側）
 ************************************************************/
.fi-error,
.ci-error {
    border: 2px solid #e74c3c !important;
}

/* Select2 はラッパー要素を生成するため、隣接する .select2-container 内の選択表示にも赤枠を伝播 */
.fi-error + .select2-container .select2-selection,
.ci-error + .select2-container .select2-selection {
    border: 2px solid #e74c3c !important;
}

/* テーブル内のクイック挿入ボタンは折返ささず、ボタンも小さくして input 幅に収める */
td .quick-symbols {
    flex-wrap: nowrap;
    gap: 4px;
}
td .quick-symbol-btn {
    min-width: 28px;
    height: 24px;
    padding: 0 6px;
    font-size: 12px;
}

/* ============================================================
 * ③在庫向け製造 調達画面の受注専用UI非表示
 * ③在庫向け製造(supply=stock)（body[data-mode="stock"]）は共有JS
 * mfg-procurement.js を流用するため、受注専用の在庫確保/在庫入庫/
 * 在庫確保サマリを CSS で隠す。全セレクタに body[data-mode="stock"]
 * を前置し、①受注の調達画面（data-mode="edit"等）には一切影響しない。
 * ============================================================ */
/* 在庫確保: 見出し（在庫から確保ボタン内包）＋在庫引当領域をペアで非表示 */
body[data-mode="stock"] .procurement-section-label.section-stock,
body[data-mode="stock"] .mat-stock-section {
    display: none;
}

/* 在庫確保ボタン本体も明示的に非表示（見出し外で生成されても確実に隠す） */
body[data-mode="stock"] [data-action="open-reserve-modal"] {
    display: none;
}

/* 在庫入庫ボタン: 材料プール見出しは残し、ボタンのみ非表示 */
body[data-mode="stock"] [data-action="open-stock-in-modal"] {
    display: none;
}

/* 在庫確保サマリ項目を丸ごと非表示（:has() 対応ブラウザ前提） */
body[data-mode="stock"] .procurement-summary-item:has([data-field="summary-reserved"]) {
    display: none;
}

/* ============================================================
 * 情報グリッド（ヘッダ項目のラベル＋値カード表示）
 * 詳細ページのヘッダ情報（発注No・仕入先・日付・ステータス等）を
 * ラベル＋値のペアで並べる汎用レイアウト。
 * ============================================================ */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px 24px;
  padding: 20px 24px;
}
.info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.info-item.info-item-wide {
  grid-column: 1 / -1;
}
.info-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
}
.info-value {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
}

/* 詳細ヘッダの操作ボタン群 */
.detail-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/*----------------------------------------------------------
 * 共通ローディングバー（処理中表示）
 * AJAX(postJson)処理中／フォーム送信中に画面上部で表示し、
 * 「処理中」を一貫して伝える（AJAX・フォームPOSTでUXを揃える）。
 * body 直下に1つだけ生成し、ref-count で複数同時でも整合。
 *----------------------------------------------------------*/
.pcn-loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 100000;
  background: rgba(0, 0, 0, 0.06);
  opacity: 0;
  transition: opacity .15s ease;
  pointer-events: none;
}
.pcn-loading-bar.is-active { opacity: 1; }
.pcn-loading-bar::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -40%;
  width: 40%;
  background: var(--sec1);
  animation: pcn-loading-slide 1.1s ease-in-out infinite;
}
@keyframes pcn-loading-slide {
  0%   { left: -40%; width: 40%; }
  50%  { width: 55%; }
  100% { left: 100%; width: 40%; }
}
/* 送信中ボタン（フォームsubmit中）: クリック抑止の視覚化 */
button.is-loading,
.btn.is-loading { opacity: .7; cursor: progress; }

/*----------------------------------------------------------
 * 入力候補オートコンプリート（suggest.js）
 * body 直下に1つだけ生成される再利用ドロップダウン
 *----------------------------------------------------------*/
.suggest-dropdown {
  position: absolute;
  z-index: 3000;
  max-height: 240px;
  overflow-y: auto;
  /* 候補を内部スクロールした時、境界でページへスクロールチェーンして
     window scroll が発火し closeDropdown で候補が消える現象を防ぐ */
  overscroll-behavior: contain;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .12);
  padding: 2px 0;
  margin: 0;
  list-style: none;
}
.suggest-dropdown .suggest-item {
  padding: 4px 10px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.suggest-dropdown .suggest-item.is-active,
.suggest-dropdown .suggest-item:hover {
  background: var(--sec1-bg);
}
/* 候補左側: 名称＋マスタコードを1グループにまとめる */
.suggest-dropdown .suggest-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}
.suggest-dropdown .suggest-value {
  overflow: hidden;
  text-overflow: ellipsis;
}
/* マスタ由来候補のコード（名称の脇に控えめ表示） */
.suggest-dropdown .suggest-code {
  font-size: 11px;
  color: var(--text-soft);
  white-space: nowrap;
}
/* 候補の由来バッジ（マスタ由来 / 手入力履歴） */
.suggest-badge {
  font-size: 10px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 10px;
  white-space: nowrap;
}
.suggest-badge-master  { background: var(--sec1-bg); color: var(--sec1); }
.suggest-badge-history { background: var(--sec7-bg); color: var(--text-soft); }
.ppm-opt-name .suggest-badge { margin-left: 6px; }
.suggest-dropdown.is-hidden {
  display: none;
}

/* 負額（過払い・マイナス残高）の赤字表示 */
.amount-negative { color: var(--danger); }

/* ============================================================
 * Lot引当モーダル（#shipAllocModal）共通スタイル
 * order.css から移設。shipment_list.php（common.css のみ読込）と
 * order_shipment.php（order.css+common.css）の両方で使用する。
 * ship_alloc_modal.php / js/ship-alloc.js が依存。
 * ============================================================ */

/* モーダルタイトル脇の対象表示 */
.alloc-modal-target {
  font-size: 14px;
  font-weight: 400;
  opacity: 0.9;
}

/* 参考情報 */
.alloc-ref-info {
  display: flex;
  gap: 24px;
  padding: 12px 16px;
  background: var(--sec1-bg);
  border-radius: 8px;
  margin-bottom: 16px;
}
.alloc-ref-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-soft);
}
.alloc-ref-item i {
  color: var(--sec2);
  font-size: 14px;
}
.alloc-ref-label {
  font-weight: 500;
}
.alloc-ref-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

/* モーダル説明文 */
.alloc-modal-desc {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  margin: 0 0 16px;
  background: #e8f4fd;
  border: 1px solid #b3d9f2;
  border-radius: var(--radius);
  color: #1565c0;
  font-size: 13px;
  line-height: 1.5;
}
.alloc-modal-desc i {
  font-size: 15px;
  flex-shrink: 0;
  color: #1976d2;
}
/* 複数行の説明（箇条書き）用: アイコンを1行目に揃える */
.alloc-modal-desc-top {
  align-items: flex-start;
}
.alloc-modal-desc-top i {
  margin-top: 2px;
}

/* 引当方式選択 */
.alloc-mode-selector {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}
.alloc-mode-radio {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin: 0;
}
.alloc-mode-radio:hover {
  border-color: var(--sec2);
  background: var(--sec2-bg);
}
.alloc-mode-radio input[type="radio"] {
  margin-right: 6px;
}
.alloc-mode-radio:has(input:checked) {
  border-color: var(--sec2);
  background: var(--sec2-bg);
}
.alloc-mode-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}
.alloc-mode-label i {
  color: var(--sec2);
  margin-right: 4px;
}
.alloc-mode-desc {
  font-size: 12px;
  color: var(--text-muted);
  padding-left: 22px;
}

/* 得意先絞り込みフィルタ（モードとLotテーブルの間） */
.alloc-filter {
  margin: 6px 0 10px;
}
.alloc-filter-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  cursor: pointer;
  margin: 0;
}

/* Lotテーブル */
.alloc-lot-table {
  margin-bottom: 16px;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.alloc-lot-table .dt {
  margin: 0;
}
.alloc-lot-table th {
  position: sticky;
  top: 0;
  z-index: 1;
}
.alloc-lot-table .th-lot-check {
  width: 40px;
}
.alloc-lot-table .alloc-lot-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.alloc-lot-table .alloc-qty-input {
  width: 70px;
  height: 32px;
  font-size: 13px;
  text-align: right;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
}
.alloc-lot-table .alloc-qty-input:disabled {
  background: var(--sec1-bg);
  color: var(--text-muted);
}

/* 引当可能セル: FIFO 配分時の「元値 → 残数」表示 */
.alloc-lot-table .alloc-avail-cell { white-space: nowrap; }
.alloc-lot-table .avail-old   { color: var(--text-muted); font-size: 0.85em; }
.alloc-lot-table .avail-arrow { color: var(--text-muted); font-size: 0.85em; }
.alloc-lot-table .avail-new   { color: var(--sec2); font-weight: 600; font-size: 1.1em; }

/* 引当元バッジ（在庫 / 製造） */
.alloc-source {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.alloc-source-stock {
  background: #e3f2fd;
  color: #1565c0;
}
.alloc-source-mfg {
  background: #fff3e0;
  color: #e65100;
}

/* 引当状態バッジ色（全量 / 一部 / 未引当） */
.alloc-full {
  background: var(--sec2-bg);
  color: var(--sec2);
}
.alloc-partial {
  background: #fef9e7;
  color: #d4a017;
}
.alloc-none {
  background: #fdf0ed;
  color: #e74c3c;
}

/* 出荷待ち一覧の引当バッジ（N/M 表示・未梱包行はクリック可） */
.ship-alloc-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
button.ship-alloc-badge {
  border: none;
  cursor: pointer;
  transition: opacity 0.2s, box-shadow 0.2s;
}
button.ship-alloc-badge:hover:not(:disabled) {
  opacity: 0.85;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/************************************************************
 * タブ⑤ 工程タイムライン（ガントチャート）専用スタイル
 * （docs/design/pages/css/order.css より移植）
 ************************************************************/
.gantt-header {
  display: flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
}
.gantt-label-col {
  width: 300px;
  min-width: 300px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  border-right: 1px solid var(--border);
}
.gantt-timeline-col {
  flex: 1;
  position: relative;
  min-height: 36px;
}
.gantt-week-headers {
  display: flex;
  height: 100%;
}
.gantt-week {
  flex: 1;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 0;
  border-right: 1px solid var(--border);
  color: var(--text-soft);
}
.gantt-week span {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted);
}
.gantt-milestones {
  display: flex;
  height: 24px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: none;
}
.gantt-milestone {
  position: absolute;
  top: 0;
  height: 100%;
}
/* 納期マイルストーン線。受注進捗ガントの納期ティック様式に統一:
   社内納期=青(sec1)破線 / 顧客納期=橙(sec3)点線＋上端キャップ。
   （今日線=赤実線は別。顧客を赤にしないのは今日線との混同回避）
   ラベルと全高線(rows貫通)は単一受注で見やすいため維持しつつ、線種・色・キャップをガントと揃える。 */
.gantt-milestone-line {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 500px;
  border-left: 2px dashed var(--sec1);
  opacity: 0.8;
  z-index: 1;
}
/* 上端キャップ（線が重なっても色で社内/客先を判別）。ガントの gantt-tick-cap と同型 */
.gantt-milestone-cap {
  position: absolute;
  top: 0;
  left: -3px;
  width: 7px;
  height: 5px;
  background: var(--sec1);
  z-index: 2;
}
.gantt-milestone-label {
  position: absolute;
  top: 2px;
  left: 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--sec1);
  white-space: nowrap;
}
.gantt-milestone-customer .gantt-milestone-line {
  border-left: 3px dotted var(--sec3);
}
.gantt-milestone-customer .gantt-milestone-cap {
  top: 5px;
  background: var(--sec3);
}
.gantt-milestone-customer .gantt-milestone-label {
  color: var(--sec3);
}

.gantt-row {
  display: flex;
  border: 1px solid var(--border);
  border-top: none;
  background: var(--card);
  min-height: 44px;
}
.gantt-row:last-of-type {
  border-radius: 0 0 var(--radius) var(--radius);
}
.gantt-row-main {
  background: var(--sec3-bg);
}
.gantt-row .gantt-timeline-col,
.gantt-group-header .gantt-timeline-col {
  display: flex;
  align-items: flex-start;
  padding: 4px 0;
  min-height: 34px;
  /* 日単位縦線（1日幅% は各ページ JS が --gantt-day-w に設定。未設定時は線なし=100%周期） */
  background-image: repeating-linear-gradient(
    to right,
    var(--border) 0,
    var(--border) 1px,
    transparent 1px,
    transparent var(--gantt-day-w, 100%)
  );
  background-position: -1px 0;
}

/* ============================================================
 * 日ヘッダ・今日縦線・納期ティック（共通ビジュアル）
 * 受注進捗ガント(order_progress_gantt) と 工程タイムライン(mfg_timeline) で共用。
 * ページ固有スコープに閉じず common に一本化する（DRY）。
 * ============================================================ */
/* ヘッダのタイムライン列は日ヘッダを縦積み上詰めにして高さに収める */
.gantt-header .gantt-timeline-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.gantt-day-headers {
  display: flex;
  flex: 1;
}
.gantt-day {
  flex: 1;
  min-width: 0;
  padding: 2px 0;
  border-left: 1px solid var(--border);
  line-height: 1.25;
  text-align: center;
  color: var(--text-soft);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.gantt-day:first-child {
  border-left: none;
}
/* 上段: 曜日（月初は「n月」）／下段: 日 */
.gantt-day-dow {
  font-size: 9px;
  font-weight: 500;
  color: var(--text-muted);
}
.gantt-day-num {
  font-size: 11px;
  font-weight: 700;
}
/* 休日は淡色背景（土日 + holiday。workday は出勤扱い） */
.gantt-day-rest {
  background: var(--bg);
}
/* 日曜=赤系 / 土曜=青系（カレンダー慣習） */
.gantt-day-sun .gantt-day-dow,
.gantt-day-sun .gantt-day-num {
  color: var(--danger);
}
.gantt-day-sat .gantt-day-dow,
.gantt-day-sat .gantt-day-num {
  color: var(--sec1);
}
/* 月初は左境界を濃くして月の切れ目を明示 */
.gantt-day-month-start {
  border-left: 2px solid var(--text-soft);
}
/* 月ラベル（先頭セル＋各月初）は上段を強調 */
.gantt-day-month-label .gantt-day-dow {
  font-weight: 700;
  color: var(--text);
}
/* 今日は黄色背景で強調（赤文字は休日と紛らわしいため背景で区別する） */
.gantt-day-today {
  background: #fff3cd;
  box-shadow: inset 0 0 0 1px #f0c36d;
}
.gantt-day-today .gantt-day-dow,
.gantt-day-today .gantt-day-num {
  color: var(--text);
  font-weight: 700;
}
/* 今日縦線（行タイムライン内、data-left で位置設定） */
.gantt-today-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--danger);
  z-index: 3;
  pointer-events: none;
}
/* 納期縦ティック（種別ごとに色・線種。上端キャップを縦にずらし重なりでも判別可） */
.gantt-deadline-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left-width: 2px;
  border-left-color: var(--tick-color, var(--sec4));
  z-index: 3;
}
.gantt-tick-internal { --tick-color: var(--sec1); border-left-style: dashed; }
.gantt-tick-customer { --tick-color: var(--sec3); border-left-style: dotted; border-left-width: 3px; }
.gantt-tick-mfg      { --tick-color: var(--sec4); border-left-style: solid; }
.gantt-tick-cap {
  position: absolute;
  left: -3px;
  width: 7px;
  height: 5px;
  background: var(--tick-color, var(--sec4));
  z-index: 4;
  pointer-events: none;
}
.gantt-tick-internal .gantt-tick-cap { top: 0; }
.gantt-tick-customer .gantt-tick-cap { top: 5px; }
.gantt-tick-mfg      .gantt-tick-cap { top: 10px; }

.gantt-bar {
  position: absolute;
  height: 24px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  white-space: nowrap;
  overflow: hidden;
}
/* 計画 / 実績の 2 トラック化（縦に重ねず併記。height はトラックが上書き） */
.gantt-bar-track-plan {
  top: 4px;
  height: 12px;
  line-height: 12px;
}
.gantt-bar-track-actual {
  top: 18px;
  height: 12px;
  line-height: 12px;
}
.gantt-bar-purchase {
  background: var(--sec1);
}
.gantt-bar-process {
  background: var(--sec2);
}
.gantt-bar-assembly {
  background: var(--sec3);
}
.gantt-bar-inspect {
  background: var(--sec4);
}

.gantt-legend {
  display: flex;
  gap: 16px;
  padding: 16px;
  justify-content: center;
  flex-wrap: wrap;
}
.gantt-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-soft);
}
.gantt-legend-color {
  width: 16px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}
.gantt-milestone-line-legend {
  width: 3px;
  height: 14px;
  background: var(--sec1);
  border-radius: 0;
}
.gantt-milestone-customer-legend {
  width: 3px;
  height: 14px;
  background: var(--sec3);
  border-radius: 0;
}
/* 今日線の凡例スウォッチ（赤実線）と注記（全幅・小さめ淡色）。ガントと共用の汎用版。 */
.gantt-legend-today {
  width: 3px;
  height: 14px;
  background: var(--danger);
  border-radius: 0;
}
.gantt-legend-note {
  flex-basis: 100%;
  font-size: 11px;
  color: var(--text-muted);
}

.gantt-bar-shipping {
  background: var(--shipping);
}
.gantt-bar-defect {
  background: var(--defect);
}
.gantt-bar-defect-purchase {
  background: var(--defect-purchase);
}

/* 実績バー（-actual）: 計画色を薄め（opacity）＋破線枠で区別 */
.gantt-bar-purchase-actual,
.gantt-bar-process-actual,
.gantt-bar-shipping-actual,
.gantt-bar-defect-actual,
.gantt-bar-defect-purchase-actual {
  color: #fff;
  opacity: 0.7;
  border: 1px dashed rgba(255, 255, 255, 0.85);
}
.gantt-bar-purchase-actual {
  background: var(--sec1);
}
.gantt-bar-process-actual {
  background: var(--sec2);
}
.gantt-bar-shipping-actual {
  background: var(--shipping);
}
.gantt-bar-defect-actual {
  background: var(--defect);
}
.gantt-bar-defect-purchase-actual {
  background: var(--defect-purchase);
}
/* 納品バー（工程バーと同じ塗りバー・1日幅）。sec5(ピンク)で仕入/工程/出荷と区別。
   予定=淡ピンク(上段トラック) / 実績=濃ピンク(下段トラック)。受注進捗ガントと同一の視覚言語。
   （受注進捗ガント order_progress_gantt.php ／ 工程タイムライン mfg_timeline.php で共用） */
.gantt-bar-delivery {
  background: var(--sec5-light);
  border: 1px solid var(--sec5);
  color: var(--text);
}
/* バー内ラベル: 折り返さず1行（fitBarLabels が幅に合わせ縮小、はみ出しは親で見切れ）
   （受注進捗ガント order_progress_gantt.php ／ 工程タイムライン mfg_timeline.php で共用） */
.gantt-bar-label {
  display: inline-block;
  white-space: nowrap;
  line-height: 1;
  padding: 0 2px;
}
.gantt-bar-delivery-actual {
  background: var(--sec5);
  border: 1px solid var(--sec5);
  color: #fff;
  opacity: 1;
}
.gantt-row-defect {
  background: var(--defect-bg);
}
.gantt-row-child .gantt-label-col {
  padding-left: 32px;
}
.gantt-row-child.gantt-row-part .gantt-label-col {
  padding-left: 48px;
}
.gantt-children {
  /* コンテナ — 表示制御用 */
}
.gantt-children.collapsed {
  display: none;
}
/* 受注明細ツリー: 主明細の配下（サブ/部品の行）を束ねるコンテナ。開閉制御用。
   （受注進捗ガント order_progress_gantt.php で使用） */
.gantt-item-children.collapsed {
  display: none;
}
.gantt-toggle {
  cursor: pointer;
  font-size: 10px;
  color: var(--text-muted);
  margin-right: 4px;
  transition: transform 0.2s;
}
.gantt-toggle:hover {
  color: var(--text);
}
