/* ============================================================
   イチグチ販売管理システム 共通スタイル
   Navisia / 奉行シリーズ風 (ネイビータイトルバー + 淡青グレー背景)
   ============================================================ */
:root {
  --navy: #1a2a6c;
  --navy-dark: #101c4e;
  --panel: #d6d9e8;
  --panel-light: #e4e6f0;
  --btn-face: #f0f0f4;
  --btn-border: #8a8fa8;
  --accent: #2b4bb5;
  --yellow: #ffff99;
  --red: #cc0000;
  --green: #0a7a2a;
  --orange: #c8760a;
  --grid-line: #b8bcd0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Yu Gothic UI", "Meiryo UI", "MS UI Gothic", sans-serif;
  font-size: 13px;
  background: #c8ccdc;
  color: #111;
  height: 100%;
}

/* ---------- アプリ全体枠 ---------- */
.app-frame {
  display: flex;
  flex-direction: column;
  height: 100vh;
  border: 2px solid #9aa0b8;
  background: var(--panel);
}

/* ---------- タイトルバー ---------- */
.title-bar {
  background: linear-gradient(to bottom, #3a4a8c, var(--navy));
  color: #fff;
  padding: 5px 12px;
  font-weight: bold;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.title-bar .logo { color: #7ec8ff; font-size: 16px; }
.title-bar .tb-sub { font-weight: normal; font-size: 11.5px; color: #b8c8f0; }

/* ---------- ヘッダー (MEMO / DATE / USER / TERM) ---------- */
.app-header {
  display: flex;
  background: var(--panel-light);
  border-bottom: 2px solid #9aa0b8;
  padding: 6px 10px;
  gap: 10px;
  align-items: stretch;
}
.memo-box { flex: 1; display: flex; gap: 6px; }
.memo-label {
  background: var(--navy);
  color: #fff;
  padding: 8px 10px;
  font-weight: bold;
  display: flex;
  align-items: center;
}
.memo-rows { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.memo-row { display: flex; align-items: center; gap: 4px; flex: 1; }
.memo-tag {
  background: var(--navy);
  color: #fff;
  font-size: 10.5px;
  font-weight: bold;
  padding: 2px 6px;
  min-width: 34px;
  text-align: center;
}
.memo-tag.personal { background: #0a6a3a; }
.memo-input {
  flex: 1;
  border: 1px solid var(--btn-border);
  background: #fff;
  padding: 3px 8px;
  font-size: 12.5px;
  font-family: inherit;
}
.memo-input.dirty { background: #fff8dc; }
.memo-save {
  border: 1px solid var(--btn-border);
  background: linear-gradient(to bottom, #fff, #d8d8e0);
  border-radius: 3px;
  cursor: pointer;
  padding: 2px 7px;
  font-size: 12px;
  visibility: hidden;
}
.memo-row:hover .memo-save, .memo-save.show { visibility: visible; }
.info-box { min-width: 220px; }
.info-box table { border-collapse: collapse; width: 100%; }
.info-box td { border: 1px solid var(--btn-border); padding: 2px 8px; background: #fff; }
.info-box td.k {
  background: var(--navy);
  color: #fff;
  font-weight: bold;
  width: 52px;
  text-align: center;
}

/* ---------- 本体レイアウト ---------- */
.app-body { display: flex; flex: 1; overflow: hidden; }

.side-menu {
  width: 185px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--panel);
  border-right: 2px solid #9aa0b8;
  overflow-y: auto;
}
.side-menu .m-btn {
  display: block;
  width: 100%;
  padding: 9px 6px;
  text-align: center;
  background: linear-gradient(to bottom, #ffffff, var(--btn-face) 45%, #d8d8e0);
  border: 1px solid var(--btn-border);
  border-radius: 3px;
  box-shadow: 1px 1px 2px rgba(0,0,0,.25);
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  color: #111;
  text-decoration: none;
}
.side-menu .m-btn:hover { background: #fdf6d8; }
.side-menu .m-btn.active {
  background: linear-gradient(to bottom, #dce8ff, #b8ccf5);
  border: 2px solid var(--accent);
}
.side-menu .m-btn.quit { margin-top: auto; }
.fiscal-badge {
  background: var(--yellow);
  border: 1px solid #b8a800;
  text-align: center;
  padding: 4px;
  font-weight: bold;
  margin-top: 6px;
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel-light);
}
.content-title {
  background: var(--navy);
  color: #fff;
  font-weight: bold;
  font-size: 15px;
  padding: 5px 10px;
  display: flex;
  align-items: center;
}
.content-title .ct-text { flex: 1; text-align: center; letter-spacing: .5em; }
.fs-btn {
  background: linear-gradient(to bottom, #4a5a9c, #2a3a7c);
  color: #fff;
  border: 1px solid #7a8ac0;
  border-radius: 3px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.fs-btn:hover { background: #5a6aac; }

/* ---------- 全画面モード ---------- */
body.fullscreen-mode .title-bar,
body.fullscreen-mode .app-header,
body.fullscreen-mode .side-menu { display: none; }
body.fullscreen-mode .app-frame { border: none; }
.content-inner { flex: 1; overflow: auto; padding: 14px; }

/* ---------- メニューボタン群 ---------- */
.menu-grid { display: flex; flex-direction: column; gap: 10px; }
.menu-row { display: flex; gap: 10px; flex-wrap: wrap; }
.menu-btn {
  min-width: 190px;
  padding: 9px 14px;
  background: linear-gradient(to bottom, #ffffff, var(--btn-face) 45%, #d8d8e0);
  border: 1px solid var(--btn-border);
  border-radius: 3px;
  box-shadow: 1px 1px 3px rgba(0,0,0,.3);
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  text-decoration: none;
  color: #111;
  text-align: center;
}
.menu-btn:hover { background: #fdf6d8; }
.menu-btn:active { box-shadow: inset 1px 1px 3px rgba(0,0,0,.3); }
.menu-cat-title { font-weight: bold; margin-bottom: 8px; color: var(--navy); }
.flow-box {
  background: #fff;
  border: 1px solid var(--grid-line);
  padding: 8px 12px;
  font-size: 12px;
  line-height: 1.9;
}
.flow-box b { color: var(--navy); }

/* ---------- フォーム部品 ---------- */
.form-section {
  background: var(--panel-light);
  border: 1px solid var(--grid-line);
  padding: 10px;
  margin-bottom: 10px;
}
.frm-row { display: flex; gap: 14px; margin-bottom: 6px; flex-wrap: wrap; align-items: center; }
.fld { display: flex; align-items: center; gap: 4px; }
.fld > label {
  background: var(--navy);
  color: #fff;
  font-weight: bold;
  padding: 4px 8px;
  min-width: 74px;
  text-align: center;
  font-size: 12px;
}
.fld input[type=text], .fld input[type=date], .fld input[type=number],
.fld input[type=password], .fld input[type=month], .fld select, .fld textarea {
  border: 1px solid var(--btn-border);
  padding: 4px 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
}
.fld input:read-only { background: #eef0f6; }
.fld textarea.mail-input { font-family: "Consolas", "Yu Gothic UI", monospace; font-size: 12.5px; line-height: 1.5; }
.fld .mail-count { min-width: 60px; }
.fld .code-input { width: 90px; }
.fld .name-display {
  min-width: 220px; background: #eef0f6; padding: 5px 6px;
  border: 1px solid var(--btn-border); min-height: 26px;
}

.search-btn {
  padding: 3px 9px;
  background: linear-gradient(to bottom, #fff, #d8d8e0);
  border: 1px solid var(--btn-border);
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
}
.search-btn:hover { background: #fdf6d8; }

.btn {
  padding: 6px 18px;
  background: linear-gradient(to bottom, #ffffff, var(--btn-face) 45%, #d8d8e0);
  border: 1px solid var(--btn-border);
  border-radius: 3px;
  box-shadow: 1px 1px 2px rgba(0,0,0,.25);
  font-weight: bold;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  color: #111;
  display: inline-block;
}
.btn:hover { background: #fdf6d8; }
.btn.primary { background: linear-gradient(to bottom, #dce8ff, #9fbcf0); border-color: var(--accent); }
.btn.danger { background: linear-gradient(to bottom, #ffe0e0, #f0a8a8); border-color: #c06060; }
.btn.print { background: linear-gradient(to bottom, #e0ffe8, #a8e0b8); border-color: #4c9a60; }
.btn.mail { background: linear-gradient(to bottom, #fde8e6, #f4b8b2); border-color: #c5372c; color: #7a1a12; }
.btn.mail:hover { background: #fff3d8; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- 一覧テーブル ---------- */
.grid-wrap {
  overflow: auto;
  background: #fff;
  border: 1px solid var(--grid-line);
  resize: vertical;
}
table.grid {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  font-size: 12.5px;
}
table.grid th {
  background: linear-gradient(to bottom, #eef1fa, #cfd5ea);
  border: 1px solid var(--grid-line);
  padding: 5px 8px;
  white-space: nowrap;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 2;
}
table.grid th.sortable-th { cursor: pointer; }
table.grid th.sortable-th:hover { background: #dde5f5; }
table.grid th .sort-mark { color: var(--accent); font-size: 11px; margin-left: 3px; }
table.grid td {
  border: 1px solid var(--grid-line);
  padding: 4px 8px;
  white-space: nowrap;
  background: #fff;
}
table.grid tbody tr:nth-child(even) td { background: #eef1fa; }
table.grid tbody tr:hover td { background: #fdf6d8; }
table.grid tbody tr.selected td { background: #cce0ff; }
table.grid td.num, table.grid th.num { text-align: right; }
table.grid tfoot td {
  border: 1px solid var(--grid-line);
  padding: 5px 8px;
  background: #f5f5fa;
  font-weight: bold;
  white-space: nowrap;
  position: sticky;
  bottom: 0;
}
table.grid tfoot td.num { text-align: right; }
table.grid td.minus, table.grid td .minus { color: var(--red); }

/* ---------- 検索モーダル ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal-win {
  width: 760px;
  max-width: 94vw;
  max-height: 84vh;
  background: var(--panel-light);
  border: 2px solid var(--navy);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 4px 16px rgba(0,0,0,.5);
}
.modal-title {
  background: linear-gradient(to bottom, #3a4a8c, var(--navy));
  color: #fff;
  font-weight: bold;
  padding: 6px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-title .close-x { cursor: pointer; padding: 0 6px; font-size: 15px; }
.modal-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.modal-search-row { display: flex; gap: 6px; }
.modal-search-row input { flex: 1; border: 1px solid var(--btn-border); padding: 6px 8px; font-size: 14px; }
.modal-result { flex: 1; overflow: auto; border: 1px solid var(--grid-line); background: #fff; min-height: 260px; max-height: 55vh; }
.modal-hint { color: #555; font-size: 11.5px; }

/* 検索モーダルの一覧: いま選んでいる行 (Enterで確定する行) をはっきり見せる */
.modal-result tbody tr { cursor: pointer; }
.modal-result tbody tr:focus { outline: none; }
.modal-result table.grid tbody tr.selected td,
.modal-result table.grid tbody tr:focus td { background: #b9d5ff; font-weight: bold; }
.modal-result table.grid tbody tr.selected td:first-child,
.modal-result table.grid tbody tr:focus td:first-child { box-shadow: inset 3px 0 0 var(--navy); }

/* ---------- 明細グリッド ---------- */
.detail-grid input, .detail-grid select {
  width: 100%;
  border: 1px solid #ccc;
  padding: 3px 4px;
  font-size: 12.5px;
  font-family: inherit;
}
.detail-grid input.num { text-align: right; }
.detail-grid td { padding: 2px 3px; }
.detail-grid td.rowno { text-align: center; background: #eef1fa; }
.detail-grid tr.linked td.rowno { background: #d8f0d8; }

/* ---------- ツールバー・ページャ ---------- */
.toolbar { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; flex-wrap: wrap; }
.pager { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.status-bar {
  background: var(--navy);
  color: #9fd0ff;
  padding: 3px 12px;
  font-size: 11.5px;
  text-align: right;
}
.total-box {
  background: #fff; border: 1px solid var(--btn-border);
  padding: 4px 12px; font-weight: bold; text-align: right; min-width: 120px;
}
.err-msg { color: var(--red); font-weight: bold; }
.ok-msg { color: var(--green); font-weight: bold; }
.warn-msg { color: var(--orange); font-weight: bold; }

/* ---------- バッジ ---------- */
.badge { display: inline-block; padding: 1px 7px; border-radius: 9px; font-size: 11px; font-weight: bold; border: 1px solid; }
.badge.open { background: #fff3d0; border-color: #c8a020; color: #7a5c00; }
.badge.done { background: #dff0df; border-color: #4c9a60; color: #14601f; }
.badge.part { background: #e0e8ff; border-color: #4a6ac0; color: #1a2a6c; }
.badge.cancel { background: #fde8e6; border-color: #c5372c; color: #7a1a12; }
.badge.short { background: #fde8e6; border-color: #c5372c; color: #7a1a12; }

/* ---------- 一括処理 ---------- */
.bulk-bar {
  background: #eef3ff; border: 1px solid var(--accent);
  padding: 6px 10px; margin-bottom: 8px;
}
.bulk-bar .bulk-count { font-weight: bold; }
.bulk-bar .bulk-count b { color: var(--accent); font-size: 15px; }
.bulk-result { border: 2px solid var(--navy); background: var(--panel-light); margin-top: 10px; }
.bulk-result .bulk-head {
  background: linear-gradient(to bottom, #3a4a8c, var(--navy));
  color: #fff; font-weight: bold; padding: 6px 10px;
  display: flex; gap: 14px; align-items: center;
}
.bulk-result .bulk-head span { font-size: 12.5px; }
.bulk-result .bulk-progress { height: 8px; background: #fff; border-bottom: 1px solid var(--grid-line); }
.bulk-result .bulk-progress > div { height: 100%; width: 0; background: linear-gradient(to right, #4a6ac0, #2b4bb5); transition: width .25s; }
.bulk-result .grid-wrap { border: none; }
.bulk-result .toolbar { padding: 0 10px; margin-bottom: 0; }

/* ---------- 構成表ツリー ---------- */
.bom-tree { background: #fff; border: 1px solid var(--grid-line); padding: 8px; font-size: 12.5px; overflow: auto; }
.bom-tree ul { list-style: none; margin: 0; padding-left: 18px; }
.bom-tree > ul { padding-left: 2px; }
.bom-node { display: flex; align-items: center; gap: 6px; padding: 2px 0; white-space: nowrap; }
.bom-node .tw { cursor: pointer; width: 15px; text-align: center; color: var(--accent); font-weight: bold; user-select: none; }
.bom-node .cd { font-weight: bold; }
.bom-node .qty { color: var(--navy); }
.bom-node .zk { color: #555; }
.bom-node .short { color: var(--red); font-weight: bold; }
.bom-node.lv0 { font-size: 13.5px; }

/* ---------- 在庫の過不足 ---------- */
tr.row-short td { background: #fff3f2 !important; }
tr.row-ok td { background: #f4fbf4 !important; }

/* ---------- エラーの対処ガイド ---------- */
.err-help { border: 2px solid var(--red); background: #fff; margin-bottom: 12px; }
.err-help .eh-title { background: var(--red); color: #fff; font-weight: bold; padding: 5px 10px; }
.err-help .eh-body { padding: 10px 12px; }
.err-help .eh-detail { line-height: 1.7; }

/* ---------- 社印プレビュー ---------- */
.seal-preview { border: 1px dashed var(--btn-border); background: #fff; padding: 8px; display: inline-block; }
.seal-preview img { max-width: 120px; max-height: 120px; }

/* ---------- 印刷プレビューの案内 ---------- */
.print-hint { background: #fff8dc; border: 1px solid #c8a020; padding: 6px 10px; margin-bottom: 8px; }

/* ---------- 在庫ポップアップ (明細の在庫欄) ---------- */
.stock-pop {
  position: absolute;
  z-index: 80;
  min-width: 560px;
  max-width: 94vw;
  background: var(--panel-light);
  border: 2px solid var(--navy);
  border-radius: 4px;
  box-shadow: 4px 4px 16px rgba(0,0,0,.35);
  font-size: 12.5px;
}
.stock-pop .sp-head {
  background: linear-gradient(to bottom, #3a4a8c, var(--navy));
  color: #fff; font-weight: bold; padding: 4px 10px;
  display: flex; justify-content: space-between; align-items: center;
}
.stock-pop .sp-x { cursor: pointer; padding: 0 4px; }
.stock-pop .sp-body { padding: 8px 10px; }
.stock-pop .sp-title { font-weight: bold; margin-bottom: 5px; }
.stock-pop .sp-need {
  background: #fff8dc; border: 1px solid #c8a020;
  padding: 3px 8px; margin-bottom: 6px;
}
.stock-pop table.sp-tbl { border-collapse: collapse; width: 100%; background: #fff; }
.stock-pop table.sp-tbl th {
  background: linear-gradient(to bottom, #eef1fa, #cfd5ea);
  border: 1px solid var(--grid-line); padding: 3px 6px; white-space: nowrap;
}
.stock-pop table.sp-tbl td {
  border: 1px solid var(--grid-line); padding: 2px 6px; white-space: nowrap;
}
.stock-pop table.sp-tbl td.num, .stock-pop table.sp-tbl th.num { text-align: right; }
.stock-pop table.sp-tbl tr.sp-now td { background: #fff8dc; }
.stock-pop table.sp-tbl tr.sp-minus td { background: #fff3f2; }
.stock-pop table.sp-tbl tfoot td { background: #eef1fa; font-weight: bold; }
.stock-pop table.sp-tbl .btn { padding: 0 8px; font-size: 11px; box-shadow: none; }
.stock-pop .sp-foot { margin-top: 6px; }
.stock-pop .sp-links { margin-top: 8px; display: flex; gap: 6px; align-items: center; }
.stock-pop .sp-links .btn { padding: 2px 10px; font-size: 11.5px; }

/* 在庫欄 (読み取り専用だがカーソルは入る) */
.detail-grid input.zk-cell {
  text-align: right;
  background: #eef4ff;
  border: 1px solid #b8c8e8;
  cursor: help;
  font-weight: bold;
}
.detail-grid input.zk-cell:focus { background: #fffbe6; outline: 2px solid var(--accent); }
.detail-grid input.zk-cell.zk-short { background: #fdeceb; color: var(--red); }
.detail-grid input.zk-cell.zk-ok { color: var(--green); }

/* ---------- ファンクションキー ドック (画面下部のフッター) ----------
   本文 (.content-inner) の外に置くので、明細をスクロールしても隠れない。
   全画面モードでもタイトル・メニューが消えるだけで、この位置は変わらない。
   ・固定表示 … バーを常に出す (従来どおり)
   ・自動表示 … つまみだけ残してバーを隠し、下端にマウスを近づけたときや
                F1〜F12 を押したときに本文へ重ねて出す (明細をいちばん広く使える) */
.fn-dock {
  position: relative;
  flex: 0 0 auto;
  background: var(--panel);
  border-top: 2px solid #9aa0b8;
  z-index: 7;
}
.fn-handle {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 21px;
  padding: 0 8px;
  font-size: 11.5px;
  font-weight: bold;
  color: var(--navy);
  background: linear-gradient(to bottom, #eaecf6, #d2d6e6);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
}
.fn-handle:hover { background: #fdf6d8; }
.fn-handle .fh-ico { font-size: 13px; }
.fn-handle .fh-keys {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: normal;
  color: #555;
}
.fn-handle .fh-state {
  background: var(--navy);
  color: #fff;
  border-radius: 2px;
  padding: 1px 8px;
  white-space: nowrap;
}
.fn-bar {
  display: flex;
  gap: 4px;
  background: var(--panel);
  padding: 5px 6px;
  flex: 0 0 auto;
}
/* 自動表示: バーは普段隠れ、必要なときだけ本文の上へ浮かせる (レイアウトを動かさない) */
.fn-dock.auto .fn-bar {
  display: none;
  position: absolute;
  left: 0; right: 0; bottom: 21px;
  border-top: 2px solid #9aa0b8;
  box-shadow: 0 -5px 14px rgba(0,0,0,.28);
}
.fn-dock.auto.peek .fn-bar { display: flex; }

/* 設定画面の表示イメージ (押せないバー) */
.fn-dock.fn-preview { border: 1px solid var(--grid-line); }
.fn-dock.fn-preview .fn-key { cursor: default; }
.fn-key {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 4px 2px;
  background: linear-gradient(to bottom, #ffffff, var(--btn-face) 45%, #d8d8e0);
  border: 1px solid var(--btn-border);
  border-radius: 3px;
  box-shadow: 1px 1px 2px rgba(0,0,0,.2);
  cursor: pointer;
  font-family: inherit;
  color: #111;
}
.fn-key .fk {
  font-size: 10.5px;
  font-weight: bold;
  color: #fff;
  background: var(--navy);
  border-radius: 2px;
  padding: 0 6px;
  line-height: 1.5;
}
.fn-key .fl {
  font-size: 12px;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  min-height: 17px;
}
.fn-key:hover:not(:disabled) { background: #fdf6d8; }
.fn-key:active:not(:disabled), .fn-key.pressed { background: #dce8ff; box-shadow: inset 1px 1px 3px rgba(0,0,0,.3); }
.fn-key.empty, .fn-key:disabled {
  background: #e6e6ec;
  box-shadow: none;
  cursor: default;
  opacity: .55;
}
.fn-key.empty .fk { background: #9aa0b8; }

/* 伝票入力の明細 — 画面の残りいっぱいまで広げる */
.grid-wrap.detail-wrap {
  min-height: 160px;
  flex: 1 1 auto;
}

/* 高さを自分で決めた一覧は、まわりの都合で伸び縮みさせない */
.grid-wrap.gs-fixed, .xtab-wrap.gs-fixed { flex: 0 0 auto; }

/* Enterキー送りで登録ボタンへ来たときの強調 */
.btn.key-ready, .key-ready {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
  background: linear-gradient(to bottom, #dce8ff, #9fbcf0) !important;
}

/* 入力中の項目を分かりやすく (Enterキー送りで目が追えるように) */
.form-section input:focus, .form-section select:focus,
.detail-grid input:focus, .detail-grid select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  background: #fffbe6;
}
.detail-grid tr:focus-within td.rowno { background: #ffe9a8; }

/* ---------- 操作説明・短縮設定のダイアログ ---------- */
.key-help { font-size: 12.5px; line-height: 1.9; }
.key-help table { border-collapse: collapse; width: 100%; }
.key-help th, .key-help td { border: 1px solid var(--grid-line); padding: 3px 8px; text-align: left; }
.key-help th { background: #eef1fa; white-space: nowrap; width: 96px; }

/* ============================================================
   ヘルプ (取扱説明書)
   ============================================================ */
.m-btn.help { background: linear-gradient(to bottom, #3a6a4a, #24482f); }
.fs-btn.help-btn { text-decoration: none; margin-right: 6px;
  background: linear-gradient(to bottom, #3a6a4a, #24482f); border-color: #6aa07c; }
.fs-btn.help-btn:hover { background: #47805a; }

.hp-bar .hp-count { font-weight: bold; color: var(--navy); margin-left: 4px; }

.hp-wrap { display: flex; gap: 12px; align-items: flex-start; }

/* 目次 */
.hp-toc {
  flex: 0 0 258px; position: sticky; top: 0; align-self: flex-start;
  max-height: calc(100vh - 210px); overflow: auto;
  background: #fff; border: 1px solid var(--grid-line); padding: 8px 6px 12px; font-size: 12px;
}
.hp-toc-title { background: var(--navy); color: #fff; font-weight: bold; text-align: center;
  letter-spacing: .4em; padding: 4px; margin: -8px -6px 8px; }
.hp-toc-ch { margin-bottom: 6px; }
.hp-toc-chlink { display: block; font-weight: bold; color: var(--navy); text-decoration: none;
  padding: 3px 5px; border-left: 4px solid transparent; }
.hp-toc-chlink:hover { background: var(--panel-light); }
.hp-toc-ch.now > .hp-toc-chlink { border-left-color: var(--accent); background: #e8ecfa; }
.hp-toc ul { list-style: none; margin: 2px 0 0; padding: 0 0 0 10px; }
.hp-toc li a { display: block; color: #333; text-decoration: none; padding: 2px 5px; line-height: 1.5; }
.hp-toc li a:hover { background: var(--panel-light); color: var(--navy); }
.hp-ico { margin-right: 4px; }

/* 本文 */
.hp-main { flex: 1 1 auto; min-width: 0; background: #fff;
  border: 1px solid var(--grid-line); padding: 4px 18px 18px; }
.hp-ch-title { font-size: 16px; letter-spacing: .2em; background: var(--navy); color: #fff;
  padding: 6px 12px; margin: 16px -18px 12px; }
.hp-ch:first-child .hp-ch-title { margin-top: 6px; }
.hp-topic { padding: 2px 0 10px; margin-bottom: 12px; border-bottom: 1px dashed #ccd; scroll-margin-top: 10px; }
.hp-topic:last-child { border-bottom: none; }
.hp-topic-title { font-size: 14.5px; color: var(--navy); margin: 10px 0 6px;
  border-left: 5px solid var(--navy); border-bottom: 1px solid var(--navy); padding: 3px 0 3px 8px; }
.hp-topic-title .hp-num { color: var(--accent); margin-right: 8px; font-family: Consolas, monospace; }
.hp-anchor { font-size: 12px; text-decoration: none; margin-left: 6px; opacity: .45; }
.hp-anchor:hover { opacity: 1; }
.hp-focus { background: #fffbe6; box-shadow: 0 0 0 3px #ffe07a; border-radius: 3px; }

.hp-links { margin: 0 0 8px; }
.hp-open { display: inline-block; background: var(--panel-light); border: 1px solid var(--btn-border);
  border-radius: 3px; padding: 2px 10px; font-size: 12px; text-decoration: none;
  color: var(--navy); font-weight: bold; margin-right: 6px; }
.hp-open:hover { background: #fff; border-color: var(--accent); }

.hp-body { font-size: 13px; line-height: 1.85; }
.hp-body h4 { font-size: 13px; margin: 12px 0 4px; padding-left: 8px;
  border-left: 4px solid var(--btn-border); color: #24305e; }
.hp-body p { margin: 0 0 7px; }
.hp-body ul, .hp-body ol { margin: 0 0 8px; padding-left: 24px; }
.hp-body li { margin-bottom: 3px; }
.hp-body b { color: #101c4e; }
.hp-body code { font-family: Consolas, monospace; background: var(--btn-face); padding: 0 4px; }
table.hp-tbl { border-collapse: collapse; width: 100%; margin: 4px 0 10px; font-size: 12.5px; }
table.hp-tbl th { background: #e8ebf5; border: 1px solid var(--grid-line); padding: 4px 7px;
  text-align: left; white-space: nowrap; }
table.hp-tbl td { border: 1px solid var(--grid-line); padding: 4px 7px; vertical-align: top; }
table.hp-index td { white-space: normal; }
.hp-dim { color: #999; }
.hp-note { border-left: 5px solid var(--accent); background: #eef2ff; padding: 6px 12px; margin: 8px 0; }
.hp-warn { border-left: 5px solid var(--red); background: #fff0ef; padding: 6px 12px; margin: 8px 0; }
pre.hp-flow { background: #f4f5fa; border: 1px solid var(--grid-line); padding: 8px 10px;
  font-size: 12px; line-height: 1.7; overflow-x: auto; margin: 4px 0 10px; }

.hp-hits { background: #f7f9ff; border: 1px solid var(--accent); padding: 8px 14px; margin: 8px 0 14px; }
.hp-hits ol { margin: 6px 0 2px; padding-left: 22px; }
.hp-hits li { margin-bottom: 6px; }
.hp-hits a { color: var(--navy); }
.hp-snip { color: #444; font-size: 12px; line-height: 1.6; }
.hp-body mark, .hp-snip mark { background: #ffec8b; }
.hp-foot { text-align: center; color: #777; font-size: 11.5px; margin-top: 18px;
  border-top: 1px solid var(--grid-line); padding-top: 8px; }

@media print {
  .side-menu, .app-header, .title-bar, .status-bar, .hp-bar, .hp-toc, .content-title { display: none !important; }
  .hp-main { border: none; padding: 0; }
  .hp-anchor { display: none; }
}

/* ---------- 商品画像 ---------- */
img.item-thumb { width: 40px; height: 40px; object-fit: contain; background: #fff;
  border: 1px solid var(--grid-line); border-radius: 2px; vertical-align: middle; }
.item-img-box { display: inline-flex; align-items: center; justify-content: center;
  width: 132px; height: 132px; background: #fff; border: 1px solid var(--grid-line); padding: 4px; }
.item-img-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.item-img-box.empty { color: #999; font-size: 11.5px; text-align: center; background: var(--btn-face); }

/* ---- suwa2 追加 ---------------------------------------------- */
tr.row-done td   { background: #f2f6ff !important; color: #667; }
tr.row-cancel td { background: #f0f0f0 !important; color: #999; text-decoration: line-through; }
tr.row-late td   { background: #fff0ee !important; }
tr.row-warn td   { background: #fffbe6 !important; }
table.grid td.pos { color: #1a6b1a; }
table.grid td.neg { color: #c02020; }
.xtab-wrap { overflow: auto; max-height: 62vh; border: 1px solid var(--grid-line); background: #fff; resize: vertical; }
table.xtab { border-collapse: collapse; font-size: 12px; white-space: nowrap; }
table.xtab th, table.xtab td { border: 1px solid var(--grid-line); padding: 2px 6px; }
table.xtab thead th { position: sticky; top: 0; background: #dbe3f5; z-index: 2; }
table.xtab tbody th { position: sticky; left: 0; background: #eef1fa; text-align: left; z-index: 1; }
table.xtab td { text-align: right; }
table.xtab tr.total-row td, table.xtab tr.total-row th { background: #fff3cc; font-weight: bold; }

.prog-bar { display: inline-block; width: 90px; height: 10px; background: #e3e6ef; border: 1px solid var(--grid-line); vertical-align: middle; }
.prog-bar > span { display: block; height: 100%; background: linear-gradient(to right, #4a6ac0, #2b4bb5); }

/* 集計表の数字から明細へ飛べることを示す (クリック可能な数字) */
table.xtab td a, table.xtab tbody th a {
  color: var(--navy); text-decoration: none; border-bottom: 1px dotted #8892c0;
}
table.xtab td a:hover, table.xtab tbody th a:hover {
  background: #fdf6d8; border-bottom: 1px solid var(--accent); color: var(--accent);
}

/* 予定 (納期をもとに積んだ、まだ済んでいない分) — 実績と見分けられるよう色を変える */
.plan-val { color: var(--orange); }
table.xtab td .plan-val, table.xtab td a .plan-val { color: var(--orange); }
.plan-sub { font-size: 10px; margin-left: 3px; font-weight: normal; }
table.xtab tr.plan-row th, table.xtab tr.plan-row td { color: var(--orange); }
table.xtab tr.plan-row th { font-style: italic; }

/* 一覧の右下のつまみ (ここを引くと高さを変えられる) */
.grid-wrap, .xtab-wrap { position: relative; }
.grid-wrap::after, .xtab-wrap::after {
  content: ''; position: absolute; right: 0; bottom: 0; width: 14px; height: 14px;
  pointer-events: none; opacity: .5;
  background: linear-gradient(135deg, transparent 55%, var(--grid-line) 55%, var(--grid-line) 65%,
              transparent 65%, transparent 78%, var(--grid-line) 78%, var(--grid-line) 88%, transparent 88%);
}

/* ---------- かんたんなグラフ (includes/chart.php) ----------
   棒はリンクなので、クリックすると該当の明細へ飛びます。 */
.chart-wrap { display: flex; gap: 10px; flex-wrap: wrap; }
.chart-box {
  flex: 1 1 380px; min-width: 340px;
  border: 1px solid var(--grid-line); background: #fff; border-radius: 4px; padding: 8px 10px;
}
.chart-title { font-weight: bold; font-size: 12.5px; margin-bottom: 6px; }

.cbar { display: flex; height: 26px; border: 1px solid var(--grid-line);
        background: #f4f4f8; border-radius: 3px; overflow: hidden; }
.cbar > a, .cbar > span {
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #fff; text-decoration: none;
  min-width: 0; overflow: hidden; white-space: nowrap;
}
.cbar > a { cursor: pointer; }
.cbar > a:hover { outline: 2px solid #111; outline-offset: -2px; filter: brightness(1.12); }

.cbar-legend { display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
               font-size: 11.5px; margin-top: 6px; }
.cbar-legend .sw { width: 11px; height: 11px; display: inline-block;
                   border-radius: 2px; vertical-align: -1px; margin-right: 4px; }
a.cbar-key { color: #111; text-decoration: none; border-bottom: 1px dotted #8892c0; }
a.cbar-key:hover { background: #fdf6d8; border-bottom-color: var(--accent); }

.cmp-row { display: grid; grid-template-columns: 92px 1fr 190px; gap: 8px;
           align-items: center; margin-bottom: 5px; }
.cmp-name { font-size: 12px; text-align: right; white-space: nowrap;
            overflow: hidden; text-overflow: ellipsis; }
.cmp-name a { color: var(--navy); text-decoration: none; border-bottom: 1px dotted #8892c0; }
.cmp-name a:hover { background: #fdf6d8; color: var(--accent); }
.cmp-track { background: #f4f4f8; border: 1px solid var(--grid-line); border-radius: 3px;
             padding: 2px; min-width: 60px; }
.cmp-track > a, .cmp-track > span { display: block; height: 8px; border-radius: 2px; margin: 1px 0; }
.cmp-track > a { cursor: pointer; }
.cmp-track > a:hover { outline: 2px solid #111; outline-offset: 1px; filter: brightness(1.12); }
.cmp-track .cmp-act { height: 11px; }
.cmp-track.one { padding: 3px 2px; }
.cmp-track .tall { height: 14px; }
.cmp-val { font-size: 11.5px; text-align: right; white-space: nowrap; }

/* グラフから飛んだ先を少しの間光らせる */
.rel-hit { animation: relHit 1.6s ease-out 1; }
@keyframes relHit {
  0%   { background: #fff3b0; box-shadow: 0 0 0 3px #ffd24d; }
  100% { background: transparent; box-shadow: none; }
}

/* 工程明細の状態で行の色を変える (0:未着手 1:着手 2:完了) */
table.grid tr.kt-st1 > td { background: #fffbe6; }
table.grid tr.kt-st2 > td { background: #eef7ee; }

/* ---------- ガントチャート (views/gantt.php) ---------- */
.gt-wrap { background: #fff; }
table.gt { border-collapse: collapse; width: auto; min-width: 100%; table-layout: fixed; }
table.gt th.gt-name { width: 210px; }
table.gt thead th {
  position: sticky; top: 0; z-index: 3; background: #dbe3f5;
  border: 1px solid var(--grid-line); padding: 2px 6px; font-size: 11.5px; text-align: left;
}
table.gt tbody th.gt-name {
  position: sticky; left: 0; z-index: 2; background: #eef1fa;
  border: 1px solid var(--grid-line); padding: 3px 6px; text-align: left;
  font-size: 12px; vertical-align: top; overflow: hidden;
}
table.gt tbody th.gt-name a { color: var(--navy); text-decoration: none; border-bottom: 1px dotted #8892c0; }
table.gt tbody th.gt-name a:hover { background: #fdf6d8; color: var(--accent); }
.gt-sub { font-size: 10px; color: #555; font-weight: normal; white-space: nowrap;
          overflow: hidden; text-overflow: ellipsis; }
table.gt td.gt-track { border: 1px solid var(--grid-line); padding: 0; }

.gt-scale { position: relative; height: 16px; }
.gt-scale.hour { height: 30px; }
.gt-tick { position: absolute; top: 0; font-size: 10px; color: #555;
           border-left: 1px solid #c3c8dc; padding-left: 2px; white-space: nowrap; }
.gt-tick.mon { color: #111; font-weight: bold; border-left: 2px solid #8892c0; }

.gt-lanes { position: relative; }
.gt-col { position: absolute; top: 0; bottom: 0; pointer-events: none; }
.gt-col.wknd { background: #f2f3f8; }
.gt-col.mon { border-left: 1px solid #c3c8dc; }
/* 目盛りと今日の線は飾りなので、下にある棒のクリック・ドラッグを邪魔しない */
.gt-today { position: absolute; top: 0; bottom: 0; width: 2px; background: #cc0000; z-index: 2;
            pointer-events: none; }

.gt-bar {
  position: absolute; height: 16px; border-radius: 3px; overflow: hidden;
  display: flex; align-items: center; text-decoration: none; z-index: 1;
  box-shadow: 0 1px 0 rgba(0,0,0,.18);
}
.gt-bar span { font-size: 10px; color: #fff; padding: 0 4px; white-space: nowrap; }
.gt-bar:hover { outline: 2px solid #111; outline-offset: 1px; z-index: 4; filter: brightness(1.1); }
.gt-s0   { background: #7f8bbf; }   /* 未着手 */
.gt-s1   { background: #2b4bb5; }   /* 着手 */
.gt-s2   { background: #0a7a2a; }   /* 完了 */
.gt-gai  { background: #c8760a; }   /* 外注 */
.gt-late { background: #cc0000; }   /* 予定完了を過ぎて未完了 */

.gt-legend { display: inline-flex; gap: 10px; align-items: center; font-size: 11.5px; }
.gt-legend i.gt-b { display: inline-block; width: 12px; height: 10px; border-radius: 2px;
                    margin-right: 3px; vertical-align: -1px; }

/* 検索モーダル: 目印の付いた行 (工順が登録済みの製番など) */
.modal-result table.grid tbody tr.sm-mark td:first-child { color: #0b6b2f; font-weight: bold; }
.modal-result table.grid tbody tr.sm-mark.selected td:first-child,
.modal-result table.grid tbody tr.sm-mark:focus td:first-child { color: #064a20; }
.modal-result .sm-legend { padding: 4px 8px; background: #f2f8f2; border-bottom: 1px solid var(--grid-line); }

/* ---------- ガントチャート: 棒をドラッグして予定をずらす ---------- */
.gt-bar { cursor: grab; user-select: none; -webkit-user-select: none; }
body.gt-dragging { cursor: grabbing; user-select: none; }
body.gt-dragging .gt-bar { cursor: grabbing; }
.gt-bar.gt-moving { opacity: .9; z-index: 6; box-shadow: 0 0 0 1px #fff, 0 0 0 2px #222; }
.gt-bar.gt-saving { opacity: .45; }
.gt-tip {
  position: fixed; z-index: 4000; pointer-events: none;
  background: #1b2a4a; color: #fff; border: 1px solid #0d1830;
  padding: 5px 9px; font-size: 12px; line-height: 1.6; border-radius: 3px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35); white-space: nowrap;
}
.gt-tip-w { color: #ffd37a; }
.gt-tip-s { color: #bcd0f0; font-size: 11.5px; }
.gt-toast {
  position: fixed; left: 16px; bottom: 16px; z-index: 4000;
  display: flex; align-items: center; gap: 10px;
  background: #fffbe8; border: 1px solid #c8b26a; border-left: 5px solid #c8951f;
  padding: 8px 12px; font-size: 12.5px; box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
}
.gt-toast-w { color: #b00; font-weight: bold; margin-left: 8px; }
.gt-toast-x { border: 0; background: none; cursor: pointer; font-size: 13px; color: #666; }

/* ---------- 指示のつながり (棒を1クリックすると出る線) ---------- */
.gt-wrap { position: relative; }
.gt-links {
  position: absolute; left: 0; top: 0; z-index: 1;
  pointer-events: none; overflow: visible;
}
.gt-links path { fill: none; }
.gt-link-u { stroke: #fff; stroke-width: 4; stroke-linejoin: round; opacity: .9; }
.gt-link {
  stroke: #c2410c; stroke-width: 1.6; stroke-linejoin: round;
  marker-end: url(#gtArrow);
}
#gtArrow path { fill: #c2410c; }
.gt-wrap.gt-picking .gt-bar { opacity: .22; }
.gt-wrap.gt-picking .gt-bar.gt-pick {
  opacity: 1; outline: 2px solid #c2410c; outline-offset: 1px;
}
.gt-wrap.gt-picking .gt-bar.gt-moving { opacity: .95; }
/* 帯そのものが「消す」ボタン。どこを押しても消える */
.gt-pick-bar {
  position: fixed; left: 12px; bottom: 12px; z-index: 4000;
  display: flex; align-items: center; gap: 10px;
  background: #7c2d12; color: #fff; border: 1px solid #431407;
  padding: 5px 7px 5px 10px; font-size: 12px; line-height: 1.5;
  border-radius: 3px; box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
  cursor: pointer; user-select: none; -webkit-user-select: none;
}
.gt-pick-bar:hover { background: #8f3516; }
.gt-pick-bar b { color: #ffd9bd; }
.gt-pick-x {
  background: rgba(255, 255, 255, .16); color: #fff; border: 1px solid #ffd9bd;
  border-radius: 3px; padding: 1px 8px; font-size: 12px; white-space: nowrap;
}
.gt-pick-bar:hover .gt-pick-x { background: #fff; color: #7c2d12; }

/* ---------- 設備候補のチップ (工順 / 受注の工程明細) ---------- */
.kouho-box { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin-top: 2px; }
.kouho-chip {
  display: inline-flex; align-items: center; gap: 2px;
  background: #e8eefb; border: 1px solid #a9bce0; border-radius: 9px;
  padding: 0 2px 0 6px; font-size: 10.5px; line-height: 15px; white-space: nowrap;
}
.kouho-x { border: 0; background: none; cursor: pointer; color: #667; font-size: 10px; padding: 0 2px; }
.kouho-x:hover { color: #b00; }
.btn.kouho-add { padding: 0 5px; font-size: 10.5px; line-height: 15px; }

/* ---------- 設備割り付け ---------- */
table.grid tbody tr.wari-sel td { background: #eef3ff; box-shadow: inset 3px 0 0 var(--navy); }
table.grid tbody tr.wari-best td { background: #eefaf0; }

/* ガントの行に出す稼働時間 (稼働時間マスタ) */
.gt-kado { font-size: 10px; color: #4a6; margin-top: 1px; }
.gt-off-l i {
  display: inline-block; width: 10px; height: 10px; vertical-align: -1px;
  background: #f2f3f8; border: 1px solid #c3c8dc; margin-right: 3px;
}
/* 稼働時間マスタ: 曜日のチェック */
.kd-w { display: inline-block; font-size: 11px; margin-right: 4px; white-space: nowrap; }
.kd-w.off { color: #a33; }

/* ---------- ガントチャートの拡大 (日・時間) ---------- */
/* 日の見出し。押すとその1日だけを時間で開く */
.gt-day {
  position: absolute; top: 0; height: 15px; box-sizing: border-box;
  border-left: 1px solid #c3c8dc; padding-left: 2px; overflow: hidden;
  font-size: 10px; line-height: 15px; color: #333; text-decoration: none; white-space: nowrap;
}
.gt-day:hover { background: #fdf6d8; color: var(--accent); }
.gt-day.mon { font-weight: bold; border-left: 2px solid #8892c0; }
.gt-day.wknd { background: #e7e9f2; color: #777; }
.gt-dw { font-size: 9px; color: #777; margin-left: 1px; }
/* 時間の目盛り */
.gt-htick {
  position: absolute; top: 15px; height: 15px; box-sizing: border-box;
  border-left: 1px dotted #ccd2e4; padding-left: 1px;
  font-size: 9px; line-height: 15px; color: #888;
}
.gt-htick.d0 { border-left: 1px solid #c3c8dc; }
/* 日の区切り線 (日・時間のとき) */
.gt-col.d { border-left: 1px solid #e3e6f0; }
/* 前の日からの続き。左の角を落として「つながり」を見せる */
.gt-bar.cont { border-top-left-radius: 0; border-bottom-left-radius: 0; opacity: .92; }

/* ---------- ガント: 工程の設定パネル ---------- */
.gt-panel {
  position: fixed; z-index: 4100; width: 330px;
  background: #fff; border: 1px solid var(--navy); box-shadow: 0 4px 16px rgba(0,0,0,.3);
  font-size: 12px;
}
.gt-panel-h {
  background: var(--navy); color: #fff; padding: 4px 8px; font-weight: bold;
  display: flex; justify-content: space-between; align-items: center;
}
.gt-panel-x { border: 0; background: none; color: #fff; cursor: pointer; font-size: 13px; }
.gt-panel-b { padding: 8px; max-height: 70vh; overflow: auto; }
.gt-panel-b label { display: block; font-weight: bold; margin: 6px 0 2px; font-size: 11.5px; }
.gt-panel-b label input[type=checkbox] { font-weight: normal; }
.gt-panel-b select, .gt-panel-b input[type=date], .gt-panel-b input.num { width: 100%; box-sizing: border-box; }
.gt-panel-s { color: #555; font-size: 11px; line-height: 1.6; margin-top: 2px; }
.gt-panel-ro { background: #f2f3f8; border: 1px solid var(--grid-line); padding: 3px 6px; }
.gt-panel-f { display: flex; gap: 4px; margin-top: 10px; flex-wrap: wrap; }
.gt-setmode { font-size: 11.5px; white-space: nowrap; }

/* ---------- ガント: 指示 (受注明細) ごとの色 ---------- */
.gt-c0  { background: #2b4bb5; }
.gt-c1  { background: #0a7a2a; }
.gt-c2  { background: #c8760a; }
.gt-c3  { background: #8d2f8d; }
.gt-c4  { background: #0f7b8a; }
.gt-c5  { background: #a8431f; }
.gt-c6  { background: #4a6b1f; }
.gt-c7  { background: #b5105f; }
.gt-c8  { background: #1f5f9e; }
.gt-c9  { background: #6b4bb5; }
.gt-c10 { background: #7a6b10; }
.gt-c11 { background: #0e6b5a; }
/* 指示ごとの色のときは、状態をふち と 濃さ で見せる */
.gt-bar.gt-done { opacity: .5; }
.gt-bar.gt-wip  { box-shadow: inset 3px 0 0 #fff, 0 1px 0 rgba(0,0,0,.18); }
.gt-bar.gt-gaio { border: 1px dashed #fff; }
.gt-bar.gt-lateo { outline: 2px solid #cc0000; outline-offset: -2px; }
.gt-legend i.gt-b.gt-wip { box-shadow: inset 3px 0 0 #fff; }
.gt-legend i.gt-b.gt-lateo { outline: 2px solid #cc0000; outline-offset: -2px; }

/* ---------- スケジュール表だけの全画面 ---------- */
#gtFull:fullscreen,
#gtFull:-webkit-full-screen,
#gtFull.gt-fs {
  background: var(--panel-light); padding: 6px 10px; box-sizing: border-box;
  display: flex; flex-direction: column; overflow: hidden;
}
/* API が使えないときは、画面の上にかぶせる */
#gtFull.gt-fs { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 5000; }
#gtFull:fullscreen > *,
#gtFull:-webkit-full-screen > *,
#gtFull.gt-fs > * { flex: 0 0 auto; }
/* 表を のこり全部の高さに広げる (ふだんの max-height と、保存した高さより優先する) */
#gtFull:fullscreen .gt-wrap,
#gtFull:-webkit-full-screen .gt-wrap,
#gtFull.gt-fs .gt-wrap {
  flex: 1 1 auto; height: auto !important; max-height: none !important; min-height: 0;
}
/* 場所をとる説明は、全画面では出さない */
#gtFull:fullscreen .gt-hint,
#gtFull:-webkit-full-screen .gt-hint,
#gtFull.gt-fs .gt-hint { display: none; }
#gtFull:fullscreen .form-section,
#gtFull:-webkit-full-screen .form-section,
#gtFull.gt-fs .form-section { margin-bottom: 4px; }
#gtFull:fullscreen .toolbar,
#gtFull:-webkit-full-screen .toolbar,
#gtFull.gt-fs .toolbar { margin-bottom: 4px; }
/* ページ全体の全画面 (ヘッダ・メニューを消すほう) のときも、表を広く */
body.fullscreen-mode .gt-wrap { max-height: 82vh; }

/* ---------- 受注明細の 在庫数・引当数・加工指示数 ---------- */
.jc-zk { background: #f3f6fd; color: #1b2a4a; font-weight: bold; }
th.jc-zk { background: #ccd6ee; }
td.jc-zk { padding: 2px 6px; }
.jc-zk-0 { color: #888; font-weight: normal; }

/* 加工指示数 … 現場に出す数。受注数とちがうときに目立たせる */
th.jc-sh { background: #f3dfd0; }
td.jc-sh { background: #fdf6f0; padding: 2px 4px; }
.j-shiji { width: 100%; text-align: right; }
.j-shiji::placeholder { color: #999; font-style: italic; }
.j-shiji.jc-sh-plus  { background: #fff3e0; border-color: #c2410c; color: #7c2d12; font-weight: bold; }
.j-shiji.jc-sh-minus { background: #eef5ff; border-color: #3a6ea5; color: #1b3a63; font-weight: bold; }
.jc-zk-sh { color: #b00; }                 /* 在庫＋加工指示 で足りない */

/* ---------- 入出庫入力 ---------- */
.ns-in  { color: #0a6b2d; font-weight: bold; }
.ns-out { color: #b00;    font-weight: bold; }
.ns-adj { color: #8a5a00; font-weight: bold; }
.ns-auto { font-size: 10px; color: #555; background: #eef1fa;
           border: 1px solid #c3c8dc; border-radius: 8px; padding: 0 5px; }
.ns-card { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.ns-card .total-box { min-width: 92px; }
tr.row-sel td { background: #fff8dc !important; }
.zk-old { color: #888; font-size: 10.5px; }

/* ---------- 在庫の内わけ 吹き出し ---------- */
.zk-cell { cursor: help; outline-offset: -2px; }
.zk-cell:focus { outline: 2px solid var(--accent, #c2410c); }
.zk-pop {
  position: fixed; z-index: 4200; min-width: 268px; max-width: 340px;
  background: #fff; border: 1px solid #1b2a4a; border-top: 4px solid #1b2a4a;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .3); padding: 7px 9px 8px;
  font-size: 12px; line-height: 1.5;
}
.zk-pop-h { font-weight: bold; color: #1b2a4a; border-bottom: 1px solid #c3c8dc;
            padding-bottom: 3px; margin-bottom: 5px; }
.zk-pop-n { font-weight: normal; color: #555; font-size: 11px; }
.zk-pop-t { width: 100%; border-collapse: collapse; }
.zk-pop-t th { text-align: left; font-weight: normal; color: #333; padding: 2px 0; }
.zk-pop-t td { text-align: right; font-weight: bold; padding: 2px 0; white-space: nowrap; }
.zk-pop-t tr.zk-sep th, .zk-pop-t tr.zk-sep td { border-top: 1px solid #e3e6ef; padding-top: 4px; }
.zk-pop-t tr.zk-tot th, .zk-pop-t tr.zk-tot td {
  border-top: 2px solid #1b2a4a; padding-top: 4px; font-size: 13px; }
.zk-pop-t tr.zk-tot th { font-weight: bold; }
.zk-plus  { color: #0a6b2d; }
.zk-minus { color: #b00; }
.zk-ok { color: #0a6b2d; }
.zk-ng { color: #b00; }
.zk-pop-s { margin-top: 6px; padding-top: 5px; border-top: 1px dotted #c3c8dc;
            font-size: 10.5px; color: #555; }
/* 集計表の 右(月)の前に足す列 (在庫数・引当数など) */
.xtab th.xtab-ex { background: #ccd6ee; }
.xtab td.xtab-ex { background: #f3f6fd; text-align: right; font-weight: bold; }

/* ---------- 工程の表 (作業指示入力・受注明細の詳細・工順登録) ----------
   数・段取・加工 は 2〜3桁しか入らないので、入力欄を半分の幅にする */
#ktGrid input.t-yotei,
#ktGrid input.t-dan,
#ktGrid input.t-kako,
#kjGrid input.k-dan,
#kjGrid input.k-kako { width: 72px; }
/* 工順は 2〜3桁、工程名も短いので、そのぶんせまくする */
#ktGrid input.t-seq,
#kjGrid input.k-seq  { width: 77px; }
#ktGrid input.t-name,
#kjGrid input.k-name { width: 108px; }
/* 外注単価も となりに並ぶ数字なので、そろえてせまくする
   (工程の表では「加工(h/個)」と同じマス、工順登録では となりの列) */
#ktGrid input.t-tanka { width: 50px; }
#kjGrid input.k-tanka { width: 90px; }

/* ---------- バーコードの読み取り (作業実績入力) ---------- */
.se-scan { background: #eef5ff; border: 2px solid var(--navy, #1b2a4a); }
.se-scan-in {
  width: 340px; font-size: 16px; font-family: monospace;
  padding: 5px 8px; border: 2px solid var(--navy, #1b2a4a);
}
.se-scan-in:focus { background: #fffbe6; outline: 2px solid var(--accent, #c2410c); }
tr.se-hit > td, tr.se-hit > th { background: #fff3c4 !important; box-shadow: inset 0 0 0 2px #c2410c; }

/* 業務の流れ (メインメニュー) … 字の折り返しで崩れないよう、表にして並べる */
.flow-tbl { border-collapse: collapse; margin-top: 4px; }
.flow-tbl th {
  text-align: center; white-space: nowrap; vertical-align: top;
  background: var(--navy, #1b2a4a); color: #fff;
  padding: 2px 10px; font-size: 11.5px; border: 1px solid #fff;
}
.flow-tbl td { padding: 3px 10px; vertical-align: top; line-height: 1.8; }
.flow-tbl i { font-style: normal; color: #555; }

/* ---------- 作業指示の進捗 (工程を横にならべる) ---------- */
.pg-tbl td { vertical-align: top; }
td.pg-flow { white-space: nowrap; padding: 3px 4px; }
.pg-chip {
  display: inline-block; vertical-align: middle; text-decoration: none;
  min-width: 86px; max-width: 150px; padding: 2px 6px; border-radius: 3px;
  font-size: 11.5px; line-height: 1.35; border: 2px solid transparent;
  overflow: hidden; text-overflow: ellipsis;
}
.pg-chip .pg-sub { display: block; font-size: 9.5px; opacity: .85; white-space: nowrap;
                   overflow: hidden; text-overflow: ellipsis; }
.pg-chip:hover { filter: brightness(1.08); box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.pg-todo { background: #e3e6ef; color: #333; }
.pg-wip  { background: #1b58a8; color: #fff; font-weight: bold; }
.pg-done { background: #0a6b2d; color: #fff; }
.pg-late { border-color: #c00 !important; }
.pg-gai  { border-style: dashed; border-color: #8a5a00; }
.pg-arw  { color: #8892c0; margin: 0 2px; font-size: 11px; }

.pg-bar { height: 8px; background: #e3e6ef; border: 1px solid #c3c8dc; }
.pg-bar > i { display: block; height: 100%; background: #0a6b2d; }

.pg-legend { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pg-legend .pg-chip { min-width: 0; font-style: normal; }
.pg-n-done { color: #0a6b2d; }
.pg-n-wip  { color: #1b58a8; }
.pg-n-late { color: #c00; font-weight: bold; }
.se-set { color: #7c2d12; background: #fff3e0; border: 1px solid #c2410c;
          padding: 2px 8px; font-size: 12px; }

/* ---------- 表だけを全画面にする (作業指示の進捗など) ---------- */
.pf-full {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 5000;
  background: var(--panel-light); padding: 6px 10px; box-sizing: border-box;
  display: flex; flex-direction: column; overflow: hidden;
}
.pf-full > * { flex: 0 0 auto; }
.pf-full .grid-wrap {
  flex: 1 1 auto; height: auto !important; max-height: none !important; min-height: 0;
}
.pf-full .form-section, .pf-full .toolbar { margin-bottom: 4px; }
.pf-full .gt-hint { display: none; }
/* ページ全体の全画面 (ヘッダ・メニューを消すほう) のときも、表を広く */
body.fullscreen-mode .pg-tbl { }

/* ===== 権限グループマスタ ===== */
.kg-grid {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.kg-cat {
  border: 1px solid #c3cbd8; border-radius: 4px; background: #fbfcff; padding: 4px 6px 6px;
}
.kg-cat-h { font-weight: bold; font-size: 12px; margin-bottom: 3px; border-bottom: 1px dotted #c3cbd8; }
.kg-cat-h a { text-decoration: none; color: #1b4a8a; }
.kg-cat-h a:hover { text-decoration: underline; }
.kg-chk {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; line-height: 1.7; cursor: pointer; white-space: nowrap;
}
.kg-chk:hover { background: #eef3fb; }
.kg-chk input { margin: 0; }
.kg-chk.kg-lock { color: #777; cursor: not-allowed; }
.kg-all { color: var(--green); }
.kg-dim .kg-grid { opacity: .4; pointer-events: none; }

/* ===== 工順パターン ===== */
.kp-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.kp-tab {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border: 1px solid #c3cbd8; border-radius: 4px;
  background: linear-gradient(to bottom, #fff, #eef1f6);
  color: #203050; text-decoration: none; font-size: 12.5px; white-space: nowrap;
}
.kp-tab:hover { background: #e4ecf8; }
.kp-tab.on {
  border-color: var(--navy); background: linear-gradient(to bottom, #dce9fb, #bcd4f3);
  font-weight: bold; box-shadow: inset 0 0 0 1px #fff;
}
.kp-tab.off { opacity: .55; }
.kp-tab .kp-star { color: #e0a000; }
.kp-tab .kp-n { color: #666; font-size: 11px; }

/* ===== 不良の内わけ ===== */
.fr-panel {
  border: 2px solid #c06060; border-radius: 4px; background: #fff8f8;
  padding: 6px 8px; margin: 2px 0 6px;
}
.fr-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.fr-head .fr-furyo { color: var(--red); font-size: 14px; }
.fr-sum { font-size: 12px; font-weight: bold; padding: 1px 8px; border-radius: 3px; }
.fr-sum.ok { color: var(--green); background: #eaf7ea; }
.fr-sum.ng { color: var(--red); background: #fdeaea; }
.fr-grid select, .fr-grid input { width: 100%; }
.fr-mark { color: var(--red); font-weight: bold; }

/* ===== 良品数 (加工数 − 不良数) ===== */
.se-ryohin {
  display: inline-block; padding: 1px 7px; border-radius: 3px;
  background: #eaf7ea; color: var(--green); font-size: 12px; white-space: nowrap;
}
.se-ryohin.warn { background: #fff4e0; color: #b06000; }
.se-ryohin.ng   { background: #fdeaea; color: var(--red); }
.se-ok { color: var(--green); }
.t-ryohin { font-weight: bold; color: var(--green); }
.t-ryohin-ng { color: #b06000; }
.pg-ng { color: var(--red); font-weight: bold; margin-left: 2px; }

/* ============================================================
   原本ならべ表示 (AI-OCR の取込チェック)
   左に 取り込んだ原本、右に 入力画面。幅はドラッグで変えられる。
   ============================================================ */
:root { --ocr-w: 46vw; }

body.ocr-split .app-frame { margin-left: var(--ocr-w); }

.ocr-pane {
  position: fixed; left: 0; top: 0; z-index: 900;
  width: var(--ocr-w); height: 100vh;
  display: flex; flex-direction: column;
  background: #2b2f36; border-right: 1px solid #11141a;
  box-shadow: 2px 0 6px rgba(0,0,0,.25);
}
.ocr-pane-bar {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 6px; background: #1f2329; color: #e8ebf0;
  font-size: 12px; flex: 0 0 auto;
}
.ocr-pane-foot { border-top: 1px solid #11141a; border-bottom: none; }
.ocr-pane-ttl { font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ocr-pane-sub { color: #9aa4b2; font-size: 11px; white-space: nowrap; }
.ocr-pane-btn {
  display: inline-block; padding: 1px 7px; border: 1px solid #4a515c; border-radius: 3px;
  background: #343a43; color: #e8ebf0; text-decoration: none; font-size: 11px;
  cursor: pointer; white-space: nowrap; line-height: 18px;
}
.ocr-pane-btn:hover { background: #434b57; }
.ocr-pane-body { flex: 1 1 auto; min-height: 0; background: #3a3f47; }
.ocr-pane-body iframe { width: 100%; height: 100%; border: 0; display: block; }
.ocr-img-wrap { width: 100%; height: 100%; overflow: auto; text-align: center; }
.ocr-img-wrap img { width: 100%; display: inline-block; }
.ocr-pane-grip {
  position: absolute; right: -3px; top: 0; width: 7px; height: 100%;
  cursor: col-resize; z-index: 901;
}
.ocr-pane-grip:hover { background: rgba(90,140,220,.45); }

/* 原本を見ながらの確認用。確かめた行に印を付けて 薄くする */
tr.ocr-done > td { background: #eef5ee !important; color: #6b7a6b; }
.ocr-chk { cursor: pointer; }

@media print { .ocr-pane { display: none; } body.ocr-split .app-frame { margin-left: 0; } }
