* { box-sizing: border-box; }
/* 検証環境(STG)の帯：本番と取り違えないための警告色 */
.env-banner { background: #b45309; color: #fff; text-align: center; font-weight: 700;
  padding: 4px 10px; font-size: 13px; letter-spacing: .04em; }
body { margin: 0; font-family: "Segoe UI", "Meiryo", system-ui, sans-serif;
  color: #1f2937; background: #f4f6f8; font-size: 14px; }
header { background: #1f3a5f; color: #fff; padding: 10px 20px; }
header h1 { margin: 0 0 6px; font-size: 18px; }
.head-top { display: flex; justify-content: space-between; align-items: center; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #cde; }
.userlink { color: #cde; font-size: 12px; text-decoration: none; }
.userlink:hover { color: #fff; text-decoration: underline; }
.link-logout { background: none; border: 1px solid #6f8bad; color: #cde; border-radius: 4px;
  padding: 3px 10px; cursor: pointer; font-size: 12px; }
.link-logout:hover { background: #29507f; color: #fff; }

/* 右上「⚙ 管理」ドロップダウン（マスタ／設定・ユーザー・取込・アカウント） */
.admin-menu { position: relative; }
.admin-menu > summary { list-style: none; cursor: pointer; color: #cde; font-size: 12px;
  border: 1px solid #6f8bad; border-radius: 4px; padding: 3px 10px; user-select: none;
  white-space: nowrap; }
.admin-menu > summary::-webkit-details-marker { display: none; }
.admin-menu > summary:hover { background: #29507f; color: #fff; }
.admin-menu[open] > summary { background: #29507f; color: #fff; }
.admin-menu-body { position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
  background: #fff; border: 1px solid #d3d9e0; border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,.18); min-width: 168px; padding: 6px;
  display: flex; flex-direction: column; }
.admin-menu-body a, .admin-menu-body .menu-logout { color: #1f2937; text-decoration: none;
  font-size: 13px; padding: 8px 12px; border-radius: 4px; text-align: left;
  background: none; border: none; cursor: pointer; width: 100%; }
.admin-menu-body a:hover, .admin-menu-body .menu-logout:hover { background: #eef2f7; color: #1f3a5f; }
.admin-menu-body form { margin: 0; }
.admin-menu-body hr { border: none; border-top: 1px solid #e5e9ef; margin: 4px 2px; }

.login-wrap { max-width: 360px; margin: 8vh auto; background: #fff; border: 1px solid #e2e6ea;
  border-radius: 8px; padding: 28px; box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.login-wrap h1 { font-size: 18px; margin: 0 0 18px; color: #1f3a5f; text-align: center; }
.login-form { display: flex; flex-direction: column; gap: 6px; }
.login-form label { font-size: 13px; color: #374151; margin-top: 6px; }
.login-form input { padding: 8px; border: 1px solid #cbd2d9; border-radius: 4px; }
.login-form .btn { margin-top: 14px; text-align: center; }
.login-error { background: #fdeaea; color: #c0392b; border: 1px solid #f3c6c6;
  padding: 8px; border-radius: 4px; font-size: 13px; }
nav a { color: #cde; text-decoration: none; margin-right: 16px; font-size: 14px; }
nav a:hover { color: #fff; text-decoration: underline; }
main { padding: 18px 20px; max-width: 1400px; }

h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }

.bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.fy-form { display: flex; align-items: center; gap: 8px; }
.fy-form label { color: #555; }

.btn { display: inline-block; background: #1f3a5f; color: #fff; padding: 7px 14px;
  border: none; border-radius: 4px; text-decoration: none; cursor: pointer; font-size: 14px; }
.btn:hover { background: #29507f; }
.btn.ghost { background: #fff; color: #1f3a5f; border: 1px solid #1f3a5f; }
.btn.sm { padding: 5px 10px; }

.cards { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.card { background: #fff; border: 1px solid #e2e6ea; border-radius: 6px; padding: 12px 16px;
  min-width: 170px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.card span { display: block; color: #6b7280; font-size: 12px; margin-bottom: 4px; }
.card b { font-size: 18px; }
.card.kansei b { color: #1d7a46; }
.card.mikomi b { color: #b06f1a; }
.card.target b { color: #444; }
.card.plus b { color: #1d7a46; }
.card.minus b { color: #c0392b; }
.card small { display: block; color: #6b7280; font-size: 11px; margin-top: 3px; }
/* 粗利（MQ）＝会社の目標指標。売上カードと視覚的に区別（青系＋強調） */
.mq-title { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px;
  color: #1f3a5f; font-size: 14px; }
.mq-tag { background: #1f3a5f; color: #fff; font-size: 11px; font-weight: 600;
  border-radius: 10px; padding: 1px 9px; }
.sub-note { font-size: 12px; font-weight: 400; color: #6b7280; margin-left: 8px;
  padding: 1px 8px; border: 1px solid #d7dbe0; border-radius: 10px; }
/* 経営ダッシュ：資金ショート警告の要約 */
.short-alert { background: #fdf2f2; border: 1px solid #f0c4c4; border-radius: 8px;
  padding: 10px 12px; margin: 8px 0 10px; }
.short-alert > b { color: #b3261e; display: block; margin-bottom: 6px; }
.short-alert .cards { margin: 0; }
/* 経営ダッシュ：必要運転資金の簡易設定フォーム（カード内） */
.card.mincash-set { border-style: dashed; }
.mincash-form { display: flex; gap: 6px; align-items: center; margin: 4px 0 2px; }
.mincash-form input[name=min_cash] { flex: 1; min-width: 90px; text-align: right;
  padding: 5px 7px; border: 1px solid #cbd2d9; border-radius: 4px;
  font-variant-numeric: tabular-nums; }
.card.mq { border-color: #cdd8e6; background: #f7faff; }
.card.mq b { color: #1f3a5f; }
.card.mq.goal { border: 2px solid #1f3a5f; background: #eef4ff; }
.card.mq.goal b { font-size: 20px; }

/* 経営ダッシュ：売上／粗利(MQ) を段階×行の横持ちで対比（縦を圧縮） */
h3.sub .unit { font-weight: 400; font-size: 12px; color: #6b7280; margin-left: 8px; }
.svmq-strip { border-collapse: collapse; font-size: 13px; min-width: 620px; margin-bottom: 12px; }
.svmq-strip th, .svmq-strip td { border: 1px solid #e2e6ea; padding: 6px 12px;
  text-align: right; white-space: nowrap; }
.svmq-strip thead th { background: #eef2f6; text-align: center; color: #35506f;
  font-size: 12px; font-weight: 600; }
.svmq-strip thead th.hl { background: #e2ecfb; }
.svmq-strip tbody th { text-align: left; background: #f7faff; color: #35506f; font-weight: 600; }
.svmq-strip .r-mq td, .svmq-strip .r-mq th { color: #1f3a5f; font-weight: 600; }
.svmq-strip td.hl { background: #eef4ff; }
.svmq-strip small { color: #6b7280; font-weight: 400; font-size: 11px; }
.svmq-strip td.plus { color: #1d7a46; } .svmq-strip td.minus { color: #c0392b; }
.svmq-strip .muted { color: #9ca3af; font-weight: 400; }
/* 率・差は別項目としてサマリー表の下にまとめる */
.svmq-sub { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 12px; font-size: 12px;
  color: #6b7280; }
.svmq-sub span { display: inline-flex; align-items: baseline; gap: 6px; }
.svmq-sub b { font-size: 13px; color: #35506f; font-weight: 600; }
.svmq-sub b.minus { color: #c0392b; } .svmq-sub b.plus { color: #1d7a46; }

/* 経営ダッシュ：相手科目×月の明細（開閉式） */
.cfmatrix-block { margin: 4px 0 16px; border: 1px solid #e2e6ea; border-radius: 6px;
  background: #fff; padding: 8px 12px; }
.cfmatrix-block > summary { cursor: pointer; font-weight: 600; color: #1f3a5f; font-size: 14px;
  list-style: none; }
.cfmatrix-block > summary::-webkit-details-marker { display: none; }
.cfmatrix-block > summary::before { content: "▶ "; color: #6b7280; font-size: 11px; }
.cfmatrix-block[open] > summary::before { content: "▼ "; }
.cfmatrix-block > summary::after { content: "（クリックで開く）"; color: #9ca3af;
  font-weight: 400; font-size: 12px; margin-left: 8px; }
.cfmatrix-block[open] > summary::after { content: "（クリックで閉じる）"; }
.cfmatrix-block .table-scroll { margin-top: 8px; }
table.grid.cfmatrix { font-size: 12px; }
table.grid.cfmatrix th, table.grid.cfmatrix td { padding: 5px 9px; }
/* 予測列は薄い青で実績と区別 */
table.grid.cfmatrix .fcol { background: #eef4ff; }
table.grid.cfmatrix thead .fcol { background: #dfe9fb; color: #1f3a5f; }
table.grid.cfmatrix .cfm-grp th { text-align: center; background: #eef2f6; font-size: 11px;
  color: #6b7280; border-bottom: 2px solid #cdd8e6; }
table.grid.cfmatrix .cfm-grp th.fcol { background: #dfe9fb; color: #1f3a5f; }
.cfmatrix-block .fc-lgnd { color: #1f3a5f; background: #dfe9fb; padding: 0 4px; border-radius: 3px; }
/* 明細内の資金投入・借入返済行 */
/* 資金繰り表ブロックの見出し行（現預金／入金関係／…／税金）と小計 */
table.grid.cfmatrix tr.cfm-head th { background: #eef1f5; color: #24405e;
  font-weight: 700; border-top: 2px solid #9fb2c9; }
table.grid.cfmatrix tr.cfm-head th.fcol { background: #e4ecf8; }
table.grid.cfmatrix td.cfm-name { padding-left: 16px; }
/* 補助科目（取引先）の内訳：親行の▶で開閉 */
table.grid.cfmatrix button.subtog { border: 0; background: none; cursor: pointer;
  color: #2f6fb0; font-size: .8rem; padding: 0 4px 0 0; line-height: 1; }
table.grid.cfmatrix .subcnt { font-size: .75rem; }
table.grid.cfmatrix tr.subrow td { background: #fbfcfe; color: #4a5666; font-size: .82rem; }
table.grid.cfmatrix tr.subrow td.fcol { background: #f2f6fd; }
table.grid.cfmatrix td.cfm-sub { padding-left: 34px; }
/* 資金繰り主表（全社ベース）：予測月の行は薄い青、資金投入セルは橙 */
table.grid tr.fcol > td { background: #f6f9ff; }
table.grid td.inject-cell { background: #fff4e6; font-weight: 600; }
table.grid.cfmatrix .inject-row td { background: #fff4e6; font-weight: 600; }
table.grid.cfmatrix .inject-row td.fcol { background: #ffedd6; }
/* 資金投入の入力ブロック */
.inject-block .inject-form { margin-top: 8px; flex-wrap: wrap; gap: 6px; }
.inject-list { margin-top: 8px; max-width: 760px; }

table.grid { border-collapse: collapse; width: 100%; background: #fff; }
table.grid th, table.grid td { border: 1px solid #e2e6ea; padding: 7px 10px; text-align: left; }
table.grid thead th { background: #eef2f6; font-weight: 600; }
table.grid tfoot th { background: #eef2f6; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.ccode-col { color: #6b7280; font-variant-numeric: tabular-nums; white-space: nowrap; width: 64px; }
/* 期首現預金（スタートの現預金）の手入力欄 */
.opening-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 2px 0 6px; }
.opening-form label { font-size: 13px; color: #374151; font-weight: 600; }
.opening-form input[name=opening] { width: 150px; text-align: right; padding: 6px 8px;
  border: 1px solid #cbd2d9; border-radius: 4px; font-variant-numeric: tabular-nums; }
.opening-form .note { margin: 0; }
/* 月末現預金の推移：実績（青実線）／予測（橙破線）の凡例 */
.lgnd { font-size: 12px; font-weight: 400; color: #6b7280; margin-left: 10px; }
.lgnd .ln { display: inline-block; width: 18px; height: 0; vertical-align: middle;
  margin: 0 4px 0 10px; border-top-width: 2px; border-top-style: solid; }
.lgnd .ln.act { border-top-color: #2f6fb0; }
.lgnd .ln.fc { border-top-color: #e08a1e; border-top-style: dashed; }
/* 未来の経費・入金（予測）の入力欄 */
.fcform { margin: 4px 0 6px; }
.fcform .fcnet { width: 120px; text-align: right; padding: 4px 6px; border: 1px solid #cbd2d9;
  border-radius: 4px; font-variant-numeric: tabular-nums; }
.fcform .fcnote { width: 100%; min-width: 120px; padding: 4px 6px; border: 1px solid #cbd2d9; border-radius: 4px; }
.fcform .fcnet:focus, .fcform .fcnote:focus { outline: 2px solid #9cc0e6; border-color: #9cc0e6; }
.fcdetail { margin: 4px 0 8px; }
.fcdetail summary { cursor: pointer; color: #1f3a5f; font-size: 13px; }
/* 経営ダッシュ：数字の推移（直近から2年間・横持ち＝月が横に並ぶ） */
.cfstrip th, .cfstrip td { white-space: nowrap; }
.cfstrip thead th:first-child, .cfstrip tbody th {
  position: sticky; left: 0; background: #eef2f6; z-index: 1; }
.cfstrip thead th small { font-weight: 400; color: #5b6b7c; margin-left: 4px; }
.cfstrip td.future { background: #fffdf3; }
.cfstrip td.warn { background: #fdecec; }
.cfstrip .minusv { color: #b3261e; }
.fmark { display: inline-block; margin-left: 6px; padding: 0 4px; font-size: 10px;
         border-radius: 3px; background: #f4e3c2; color: #7a5b16; vertical-align: 1px; }
.fmark.over { background: #dbe7f6; color: #1f3a5f; }
.alert-note { margin: 10px 2px 0; font-size: 12px; line-height: 1.7; color: #6b4a46; }
code.slug { background: #eef2f6; border: 1px solid #d7dde3; border-radius: 3px;
            padding: 1px 6px; font-weight: 600; margin-right: 6px; }
.landing-fy { margin-top: 6px; font-size: 12px; color: #5b6b7c; }
.landing-fy select { font-size: 12px; padding: 2px 4px; }

.acctdetail { margin: 14px 0 8px; }
.acctdetail summary { cursor: pointer; color: #1f3a5f; font-size: 15px; font-weight: 600; padding: 4px 0; }
.acctdetail > .table-scroll { margin-top: 8px; }
.fcopts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 2px 0 8px; }
.fcopts label { font-size: 13px; color: #374151; font-weight: 600; }
.fcopts select { padding: 5px 8px; border: 1px solid #cbd2d9; border-radius: 4px; }
.fcopts .note { margin: 0; }
.num.minus, td.minus, th.minus { color: #c0392b; }   /* 収支マイナスの赤字表示 */
.strong { font-weight: 700; }
.empty { color: #999; text-align: center; }
.note { color: #6b7280; font-size: 12px; margin-top: 8px; }

.badge { padding: 2px 8px; border-radius: 10px; font-size: 12px; color: #fff; }
.s-見込 { background: #6b7280; } .s-着工 { background: #2563eb; }
.s-竣工 { background: #1d7a46; } .s-中止 { background: #9ca3af; }
.rv-wait { background: #d9822b; }
.rv-ok { color: #1d7a46; font-size: 12px; }
.navbadge { background: #d9822b; color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; }

.upd { color: #8a93a0; font-size: 12px; white-space: nowrap; }
.ops { white-space: nowrap; }
.ops form { display: inline; }
.link-danger { background: none; border: none; color: #c0392b; cursor: pointer;
  text-decoration: underline; font-size: 13px; padding: 0 0 0 8px; }

/* 工程マトリクス */
.scroll-x { overflow-x: auto; }
table.matrix .mcol { width: 34px; text-align: center; padding: 6px 2px; }
table.matrix .mcell { width: 34px; padding: 0; }
table.matrix .mcell.on { background: #2f6fb0; }
/* 工程表ドラッグ描画：マスにカーソル・ドラッグ範囲プレビュー */
table.matrix.editable .mcell { cursor: cell; }
table.matrix.editable tbody tr:hover .mcell { box-shadow: inset 0 0 0 9px rgba(47,111,176,.03); }
table.matrix .mcell.draw-preview { background: #7db0e0; box-shadow: inset 0 0 0 1px #2f6fb0; }
table.matrix .mcell.on.draw-preview { background: #255e9c; }
.drawhint { background: #eef4fb; border-color: #cdd8e6; }
.matrix.editable { user-select: none; }
/* ドラッグ中の全体演出：カーソル・対象行のハイライト */
body.drawing { cursor: crosshair; }
body.drawing .mcell { cursor: crosshair; }
table.matrix tbody tr.drawing-row { background: #f0f6fc; }
table.matrix tbody tr.drawing-row td.sticky { background: #e6f0fa; box-shadow: inset 3px 0 0 #2f6fb0; }
table.matrix tbody tr.saving { opacity: .7; }
/* カーソル追従の範囲ラベル */
.draw-label { position: fixed; z-index: 1000; pointer-events: none; background: #1f3a5f;
  color: #fff; font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 5px;
  box-shadow: 0 3px 10px rgba(0,0,0,.25); white-space: nowrap; }
/* 保存直後のフラッシュ（緑→通常の青へ戻る） */
@keyframes savedflash { 0% { background: #34c759; box-shadow: inset 0 0 0 2px #1d7a46; }
  100% { background: #2f6fb0; box-shadow: none; } }
table.matrix .mcell.just-saved { animation: savedflash .7s ease-out; }
table.matrix .sticky { position: sticky; left: 0; background: #fff; z-index: 1; }
table.matrix thead .sticky { background: #eef2f6; }

/* フォーム */
.form { background: #fff; border: 1px solid #e2e6ea; border-radius: 6px; padding: 18px; max-width: 760px; }
.form .row { display: flex; gap: 14px; }
.form .field { margin-bottom: 12px; flex: 1; }
.form label { display: block; font-size: 13px; color: #374151; margin-bottom: 4px; }
.form input, .form select, .form textarea { width: 100%; padding: 7px 8px;
  border: 1px solid #cbd2d9; border-radius: 4px; font-size: 14px; }
.form small { color: #6b7280; }
.req { color: #c0392b; font-size: 11px; }
.actions { margin-top: 8px; display: flex; gap: 10px; }

.panel { background: #fff; border: 1px solid #e2e6ea; border-radius: 6px; padding: 14px 16px; margin-bottom: 16px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.inline-form input { padding: 6px 8px; border: 1px solid #cbd2d9; border-radius: 4px; }
table.mini th, table.mini td { padding: 5px 8px; }

/* 印刷（PDF保存）時はナビ・ボタンを隠す */
@media print {
  header, .no-print { display: none !important; }
  main { padding: 0; max-width: none; }
  body { background: #fff; }
}

/* 一覧入力（Excel風） */
.grid-actions { display: flex; gap: 8px; }
.savemsg { color: #1d7a46; margin-left: 8px; }
table.entry td { padding: 2px; }
table.entry input, table.entry select { width: 100%; border: 1px solid transparent;
  background: transparent; padding: 5px 6px; font-size: 13px; border-radius: 3px; }
table.entry input:focus, table.entry select:focus { border-color: #2f6fb0;
  background: #fff; outline: none; box-shadow: 0 0 0 2px rgba(47,111,176,.15); }
table.entry input:hover, table.entry select:hover { border-color: #d0d7de; }
table.entry input[type=date] { min-width: 130px; }
table.entry input.datecell { min-width: 116px; }
table.entry input[data-f=name] { min-width: 160px; }
table.entry input[data-f=note] { min-width: 140px; }
table.entry .num { text-align: right; }
/* 日付が解釈できないときの警告表示 */
table.entry input.datecell.badval { border-color: #c0392b; background: #fdeaea; }
/* 一覧入力：新規入力を最上段に置く（A案）。区切りの帯と、新規行の色分け */
table.entry tbody.gridband th { background: #eef1f5; color: #24405e; text-align: left;
  font-weight: 700; padding: 4px 8px; border-top: 2px solid #9fb2c9; }
table.entry tbody.gridband.new th { background: #eaf4ff; color: #1f4d80; border-top: 0; }
table.entry tbody.newrows td { background: #fbfdff; }
/* 金額欄の上下スピンボタンを出さない（type=numberが残っても保険） */
.grid.entry input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.grid.entry input[type=number]::-webkit-outer-spin-button,
.grid.entry input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
table.entry thead th { position: sticky; top: 0; z-index: 2; }
.delcol { width: 28px; text-align: center; padding: 0; }
button.del { border: none; background: none; color: #c0392b; cursor: pointer;
  font-size: 16px; line-height: 1; padding: 4px 6px; }
button.del:hover { color: #fff; background: #c0392b; border-radius: 3px; }

/* ダッシュボードのバー右寄せ・出力ボタン */
.bar-right { display: flex; align-items: center; gap: 8px; }
.btn.ghost.sm { padding: 5px 10px; font-size: 13px; }

/* 売上グラフ */
.chartbox { background: #fff; border: 1px solid #e2e6ea; border-radius: 6px;
  padding: 12px 16px; margin-bottom: 16px; }
.chart .cax { font-size: 11px; fill: #6b7280; }
.chart .dlabel { font-size: 10px; fill: #1f3a5f; font-weight: 600; }
.chart .tline-label { font-size: 10px; fill: #8a6d1a; }
.seg { display: inline-flex; border: 1px solid #cbd2d9; border-radius: 5px; overflow: hidden; }
.seg-btn { padding: 4px 12px; font-size: 12px; color: #1f3a5f; text-decoration: none; background: #fff; }
.seg-btn + .seg-btn { border-left: 1px solid #cbd2d9; }
.seg-btn.on { background: #1f3a5f; color: #fff; }
.legend { font-size: 12px; color: #555; margin-top: 6px; }
.legend .lg { display: inline-block; width: 12px; height: 12px; border-radius: 2px;
  vertical-align: middle; margin-right: 4px; }

/* ガントチャート */
.gantt { display: grid; gap: 1px; background: #e2e6ea; min-width: 760px;
  border: 1px solid #e2e6ea; }
.grow { display: grid; grid-template-columns: 200px repeat(var(--cols), 1fr);
  background: #fff; position: relative; align-items: stretch; }
.grow.head { background: #eef2f6; font-weight: 600; }
.glabel { padding: 7px 10px; border-right: 1px solid #e2e6ea; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.gmonth { padding: 7px 0; text-align: center; font-size: 12px; border-left: 1px solid #eef1f4; }
.gcell { border-left: 1px solid #eef1f4; min-height: 30px; }
.gbar { grid-row: 1; align-self: center; height: 20px; margin: 0 3px; border-radius: 3px;
  color: #fff; font-size: 11px; line-height: 20px; text-align: center; overflow: hidden;
  white-space: nowrap; }
.gbar.s-見込 { background: #6b7280; } .gbar.s-着工 { background: #2563eb; }
.gbar.s-竣工 { background: #1d7a46; } .gbar.s-中止 { background: #b9bfc7; }
.glabel.sub { padding-left: 22px; color: #333; }
.glabel.grouphdr { font-weight: 600; background: #f3f6f9; }
.grouprow { background: #f3f6f9; }
.gmonth.today { background: #fde7c8; border-radius: 3px 3px 0 0; }
.gcell.todaycol { background: rgba(253, 167, 60, .12); }
/* 2年間（24か月）表示：年度の帯と境界線 */
.grow.yearhead { background: #e7edf4; font-weight: 600; }
.gyear { text-align: center; font-size: 12px; color: #1f3a5f; padding: 5px 0;
  border-left: 1px solid #cdd8e6; }
.gmonth.yearstart, .gcell.yearstart { border-left: 2px solid #9fb2c9; }

.hint { background: #fff7e6; border: 1px solid #f0d9a8; color: #8a5a00;
  padding: 9px 12px; border-radius: 5px; margin-bottom: 12px; font-size: 13px; }
.hint a { color: #1f3a5f; }

/* 工程表：状態フィルタのタブ */
.gantt-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 0 0 10px; }
.gtab { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px;
  border: 1px solid #cdd8e6; border-radius: 999px; background: #fff; color: #35506f;
  font-size: 13px; text-decoration: none; }
.gtab:hover { background: #eef3f9; }
.gtab.on { background: #1f3a5f; border-color: #1f3a5f; color: #fff; }
.gtab-n { font-size: 11px; background: rgba(31,58,95,.10); color: #35506f;
  border-radius: 999px; padding: 0 6px; min-width: 16px; text-align: center; }
.gtab.on .gtab-n { background: rgba(255,255,255,.22); color: #fff; }

/* 工程表：行内の状態プルダウン／バッジ */
.prowlabel { display: flex; align-items: center; gap: 6px; }
.prowlabel .pname { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; text-decoration: none; color: #333; }
.prowlabel .pname:hover { text-decoration: underline; color: #1f3a5f; }
.stsel { flex: 0 0 auto; font-size: 11px; padding: 1px 2px; border-radius: 3px;
  border: 1px solid rgba(0,0,0,.15); color: #fff; cursor: pointer; -webkit-appearance: none; appearance: none; }
.stsel.s-見込 { background: #6b7280; } .stsel.s-着工 { background: #2563eb; }
.stsel.s-竣工 { background: #1d7a46; } .stsel.s-中止 { background: #9ca3af; }
.stsel option { background: #fff; color: #222; }
.stbadge { flex: 0 0 auto; font-size: 11px; padding: 1px 6px; border-radius: 3px; color: #fff; }
.stbadge.s-見込 { background: #6b7280; } .stbadge.s-着工 { background: #2563eb; }
.stbadge.s-竣工 { background: #1d7a46; } .stbadge.s-中止 { background: #9ca3af; }
.grow.prow.st-saving { opacity: .55; }

/* 粗利ガント */
.tag { font-size: 11px; background: #e7eef5; color: #1f3a5f; border-radius: 3px;
  padding: 2px 6px; vertical-align: middle; }
.gantt.profit .grow { grid-template-columns: 180px repeat(4, 84px) repeat(var(--cols), 1fr); }
.pcol { padding: 7px 8px; border-left: 1px solid #eef1f4; font-size: 12px; }
.pcol.num { text-align: right; }
.profitrow .glabel { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.neg { color: #c0392b; }
.m-loss { color: #fff; background: #c0392b; }
.m-low  { color: #fff; background: #e08a2a; }
.m-mid  { color: #fff; background: #2f8fc0; }
.m-high { color: #fff; background: #1d7a46; }
.pcol.m-loss, .pcol.m-low, .pcol.m-mid, .pcol.m-high { color: #1f2937; background: none; font-weight: 600; }
.pcol.m-loss { color: #c0392b; } .pcol.m-high { color: #1d7a46; }
.sw { display: inline-block; width: 11px; height: 11px; border-radius: 2px; vertical-align: middle; }

/* ガントの棒・作業名をリンク化（クリックでタスクボード） */
a.gbar { display: block; text-decoration: none; cursor: pointer; }
a.gbar:hover { filter: brightness(1.12); box-shadow: 0 0 0 2px rgba(31,58,95,.25); }
a.glabel.sub { text-decoration: none; cursor: pointer; }
a.glabel.sub:hover { text-decoration: underline; color: #1f3a5f; }

/* ガント編集モード：バーの帯をドラッグして工期を引く */
.gantt.editable { user-select: none; }
.gantt .grow.prow .gcell { grid-row: 1; }                /* セルを1段目に固定（バーと正しく重ねる） */
.gantt.editable .gcell[data-mo] { cursor: crosshair; }
.gantt.editable .gbar { pointer-events: none; }          /* 下のマスにドラッグを通す */
.gantt.editable .grow.prow:hover .gcell[data-mo] { background: rgba(47,111,176,.04); }
.gantt .gcell.draw-preview { background: #7db0e0; box-shadow: inset 0 0 0 1px #2f6fb0; }
.gantt .grow.drawing-row { background: #f0f6fc; }
.gantt .grow.drawing-row .glabel { box-shadow: inset 3px 0 0 #2f6fb0; }
.gantt .gbar.just-saved { animation: savedflash .7s ease-out; }

/* ---- タスクボード（カンバン） ---- */
.board-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0; }
.board-meta .bm-motouke { color: #6b7280; font-size: 13px; }
.board-meta .bm-name { font-weight: 600; }
.board-meta .bm-due { color: #6b7280; font-size: 13px; }
.board-links { display: flex; gap: 14px; margin: 2px 0 8px; font-size: 13px; }

.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: start; }
.kcol { background: #f3f6f9; border: 1px solid #e3e8ee; border-radius: 7px; padding: 8px; }
.kcol-head { display: flex; justify-content: space-between; align-items: center;
  font-weight: 600; color: #fff; padding: 6px 10px; border-radius: 5px; font-size: 13px; }
.kcol-head.s-未着手 { background: #6b7280; }
.kcol-head.s-進行中 { background: #2563eb; }
.kcol-head.s-保留   { background: #b8860b; }
.kcol-head.s-完了   { background: #1d7a46; }
.kcount { background: rgba(255,255,255,.3); border-radius: 9px; padding: 0 7px; font-size: 12px; }
.kcol-body { min-height: 48px; padding: 6px 2px; display: flex; flex-direction: column; gap: 7px; }
.kcol-body.over { background: #e7f0fb; border-radius: 5px; outline: 2px dashed #2563eb; }
.kcard { background: #fff; border: 1px solid #dde3ea; border-radius: 5px; padding: 8px 9px;
  box-shadow: 0 1px 2px rgba(0,0,0,.05); cursor: grab; }
.kcard.dragging { opacity: .45; }
.kcard.overdue { border-left: 4px solid #c0392b; }
.kcard.overdue .kdue { color: #c0392b; font-weight: 600; }
.kcard.soon { border-left: 4px solid #b8860b; }
.kcard.soon .kdue { color: #b8860b; font-weight: 600; }

/* 進捗バー（ボード上部・案件一覧） */
.kprogress { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; }
.kprogress-bar { flex: 1; max-width: 360px; height: 10px; background: #e3e8ee;
  border-radius: 6px; overflow: hidden; }
.kprogress-bar span { display: block; height: 100%; background: #1d7a46; border-radius: 6px; }
.kprogress-text { font-size: 12px; color: #4b5563; white-space: nowrap; }
.miniprog { display: flex; align-items: center; gap: 6px; }
.miniprog-bar { width: 64px; height: 7px; background: #e3e8ee; border-radius: 5px; overflow: hidden; }
.miniprog-bar span { display: block; height: 100%; background: #1d7a46; }
.miniprog-text { font-size: 11px; color: #6b7280; white-space: nowrap; }
.miniprog-none { font-size: 11px; color: #b6c0cc; }
.kcard-title { font-size: 13px; line-height: 1.4; word-break: break-word; }
.kcard-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px;
  color: #6b7280; font-size: 11px; }
.kcard-edit { margin-top: 5px; }
.kcard-edit summary { font-size: 11px; color: #1f3a5f; cursor: pointer; }
.ktaskform { display: flex; flex-direction: column; gap: 4px; margin-top: 5px; }
.ktaskform input { font-size: 12px; padding: 3px 5px; border: 1px solid #cfd6de; border-radius: 4px; }
.krow { display: flex; gap: 6px; }
.krow button { font-size: 12px; padding: 3px 9px; }
.kdel { background: #c0392b; }
.kadd { margin-top: 8px; }
.kadd input { width: 100%; box-sizing: border-box; font-size: 12px; padding: 6px 8px;
  border: 1px dashed #b6c0cc; border-radius: 5px; background: #fff; }
.kadd input:focus { border-style: solid; border-color: #2563eb; outline: none; }
.badge.s-未着手 { background: #6b7280; } .badge.s-進行中 { background: #2563eb; }
.badge.s-保留 { background: #b8860b; } .badge.s-完了 { background: #1d7a46; }
@media (max-width: 820px) { .kanban { grid-template-columns: 1fr 1fr; } }

/* 資金繰り実績（総勘定元帳CSV取込→科目×月マトリクス） */
.table-scroll { overflow-x: auto; margin-bottom: 16px; }
.table-scroll table.grid { min-width: max-content; }
table.grid td.num, table.grid th.num { text-align: right; white-space: nowrap; }
table.grid .strong { font-weight: 700; }
table.grid .minus { color: #c0392b; }
h3.sub { font-size: 15px; margin: 18px 0 8px; color: #1f3a5f; }
table.grid.narrow { width: auto; min-width: 420px; }
.fld { display: block; margin-bottom: 10px; }
.fld > span { display: block; font-size: 13px; color: #444; margin-bottom: 4px; }
.chip { display: inline-block; background: #fff; border: 1px solid #e0c88a; color: #8a5a00;
  border-radius: 12px; padding: 2px 10px; margin: 3px 4px 0 0; font-size: 12px; }
td.ok { color: #1d7a46; font-weight: 600; }
tr.skip { color: #8a8f98; background: #fafafa; }
.skip-tag { color: #b06f1a; font-weight: 600; }

/* 資金繰り実績ダッシュボード */
.cfchart { display: block; max-width: 720px; background: #fff; border: 1px solid #e2e6ea;
  border-radius: 6px; margin: 4px 0 14px; }
.muted { color: #8a8f98; font-size: 12px; margin-left: 6px; }
table.grid th.grp { background: #e3e9f0; text-align: center; }

/* 実績CF ドリルダウンのリンク */
.drill { color: inherit; text-decoration: none; border-bottom: 1px dotted #9aa4b0; }
td.num a.drill { color: inherit; }
.drill:hover { color: #1f3a5f; border-bottom-color: #1f3a5f; background: #eef4fb; }

/* 実績CF 追加分（プリセット・アラート・コメント） */
.tag.ovr { background: #1d7a46; color: #fff; }
tr.cf-alert > td { background: #fdecea; }
tr.cf-alert > td:first-child { font-weight: 700; color: #a3271b; }
tr.fy-boundary > td { border-top: 2px solid #9fb2c9; }
.cf-note-form { display: flex; gap: 4px; align-items: center; }
.cf-note { width: 12em; padding: 3px 6px; border: 1px solid #cbd2da; border-radius: 4px; font-size: 12px; }

/* プリセットJSON編集・CF計算書印刷ビュー */
.jsonarea { width: 100%; min-height: 360px; font-family: ui-monospace, "Consolas", monospace;
  font-size: 13px; line-height: 1.5; padding: 10px; border: 1px solid #cbd2da;
  border-radius: 6px; box-sizing: border-box; }
.cfstmt { background: #fff; border: 1px solid #e2e6ea; border-radius: 6px; padding: 20px; max-width: 760px; }
.cfstmt-title { text-align: center; margin: 0 0 4px; font-size: 18px; }
.cfstmt-sub { text-align: center; color: #6b7280; font-size: 12px; margin: 0 0 14px; }
.cfstmt-table tr.cfsec > td { background: #eef2f6; font-weight: 700; }
.cfstmt-table tr.cfsub > td { border-top: 1px solid #b6c0cc; font-weight: 700; background: #f6f8fa; }
.cfstmt-table tr.cfgrand > td { border-top: 2px solid #1f3a5f; font-weight: 700; }
.cfstmt-notes { margin-top: 14px; font-size: 12px; color: #444; }
.cfstmt-notes ul { margin: 4px 0 0 18px; }
@media print {
  header, .noprint { display: none !important; }
  main { margin: 0; }
  .cfstmt { border: none; padding: 0; max-width: none; }
  body { background: #fff; }
}

/* CF計算書の会社名ヘッダ */
.cfstmt-company { font-size: 13px; color: #333; margin-bottom: 2px; font-weight: 600; }

/* CF計算書ヘッダ/フッタ（会社名・ロゴ・住所・作成日） */
.cfstmt-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.cfstmt-logo { max-height: 44px; max-width: 160px; object-fit: contain; }
.cfstmt-address { font-size: 11px; color: #666; }
.cfstmt-foot { margin-top: 14px; text-align: right; font-size: 11px; color: #666; }

/* 資金調達計画（借入） */
.loanplan { border: 1px solid #e2e6ea; border-radius: 6px; padding: 8px 12px; margin-bottom: 14px; background: #fff; }
.loanplan > summary { cursor: pointer; font-weight: 600; color: #1f3a5f; }

/* CF計算書 承認欄・社印・ページ番号 */
.cfstmt-approval { border-collapse: collapse; margin: 16px 0 4px auto; }
.cfstmt-approval th, .cfstmt-approval td { border: 1px solid #999; width: 74px; height: 30px;
  text-align: center; font-size: 12px; }
.cfstmt-approval td { height: 44px; }
.cfstmt-approval .stamp { color: #c0392b; }
.cfstmt-print-foot { display: none; }
.cfstmt .cfstmt-head { border-bottom: 1px solid #d0d6dd; padding-bottom: 6px; }
@media print {
  @page {
    margin: 16mm 14mm 18mm 14mm;
    @bottom-right { content: "ページ " counter(page) " / " counter(pages); font-size: 9pt; color: #666; }
  }
  .cfstmt-approval { page-break-inside: avoid; }
  .cfstmt-print-foot { display: block !important; position: fixed; bottom: 4mm; left: 0; right: 0;
    text-align: center; font-size: 9px; color: #888; }
}

/* シナリオ比較：推奨行 */
tr.cf-recommend > td { background: #eaf7ee; }
tr.cf-recommend > td:first-child { font-weight: 700; color: #1d7a46; }

/* インライン操作ボタン（並べ替え・複製） */
button.link { background: none; border: none; color: #1f3a5f; cursor: pointer;
  text-decoration: underline; font-size: 12px; padding: 0 4px; }
button.link:hover { color: #29507f; }

/* 品質検証：重大度別の集計バッジ */
.sevbadges { display: inline-flex; gap: 6px; margin-left: 8px; vertical-align: middle; }
.sevbadge { border-radius: 10px; padding: 1px 8px; font-size: 11px; font-weight: 700; color: #fff; }
.sevbadge.high { background: #b00020; }
.sevbadge.warn { background: #d9822b; }
.sevbadge.info { background: #6b7f99; }

/* ── 資金繰りシミュレーション（/cfsim）。既存画面は不変・この画面専用 ── */
.cfsim td.cell-fc{padding:2px;background:#fffef7}
.cfsim-in{width:76px;border:1px solid #d7dde5;border-radius:4px;padding:4px 6px;text-align:right;font-variant-numeric:tabular-nums;font-size:.86rem}
.cfsim-in:focus{outline:none;border-color:#2f6fb0;background:#fff}
.cfsim tfoot .cfsim-net td{border-top:2px solid #9aa4b0;font-weight:600}
.cfsim tfoot .cfsim-bal td{background:#f3f6fa}
.cfsim tr.inject td{color:#666;font-style:italic}
/* ブロック見出し（現預金／入金関係／…／税金）と、その配下の科目名インデント */
.cfsim tr.cfsim-head th,.cfsim tr.cfsim-head td{background:#eef1f5;color:#24405e;
  font-weight:700;border-top:2px solid #9fb2c9;text-align:left}
.cfsim td.cfsim-name{padding-left:16px}
.cfsim td.warn{color:#c0392b;font-weight:700}
.cfsim td.minusv{color:#c0392b}
.cfsim-actions{margin:10px 0;display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.cfsim-short{color:#c0392b;font-weight:600}
/* /cfsim 手入力の予定項目一覧 */
.cfsim tr.manual td{background:#f7fbf4}
.cfsim tr.manual .tag{background:#5a8f3a;color:#fff}
.cfsim-manual input{width:100%;border:1px solid #d7dde5;border-radius:4px;padding:5px 7px;font-size:.86rem;box-sizing:border-box}
.cfsim-manual input.num{text-align:right;font-variant-numeric:tabular-nums}
.cfsim-manual input:focus{outline:none;border-color:#2f6fb0}
.cfsim-manual .cfsim-newrow td{background:#fffef7}
.cfsim-del{font-size:.8rem;color:#c0392b;white-space:nowrap}
