/* 建築費 予実 — 白地に数字が読みやすいこと。色は意味のある所（承認済＝青・申請中＝橙・超過＝赤）にだけ使う */
:root {
  --bg: #f5f6f8;
  --paper: #ffffff;
  --ink: #16202a;
  --muted: #4a5663;      /* 白地で 7:1 */
  --faint: #6b7680;      /* 白地で 4.6:1 */
  --line: #d5dbe2;
  --line-soft: #e8ecf0;
  --tint: #fafbfc;
  --ai: #1f5fad;         /* リンク・ブランド */
  --ai-deep: #174a87;
  --ap: #1f5fad;         /* 承認済 */
  --pe: #e08a1e;         /* 申請中（バー） */
  --pe-ink: #8a5300;     /* 申請中（文字） */
  --ov: #c4321f;         /* 超過（バー） */
  --ov-ink: #a1261a;     /* 超過（文字） */
  --ov-bg: #fdf3f1;
  --pe-bg: #fff8ec;
  --pe-line: #eed9ae;
  --track: #e9edf1;
  --focus: #2a6fdb;
  --radius: 10px;
  --font: Inter, "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11161c; --paper: #1a2129; --ink: #e6ebf0; --muted: #a6b1bc; --faint: #8592a0;
    --line: #34404c; --line-soft: #27313b; --tint: #1e262f; --ai: #8ab6ec; --ai-deep: #6f9fd9;
    --ap: #5f9be4; --pe: #e6a14a; --pe-ink: #f0bb72; --ov: #e5604f; --ov-ink: #f08a7c; --ov-bg: #3a2220;
    --pe-bg: #33291a; --pe-line: #5a4626; --track: #2b343e; --focus: #7aa7f0;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.65 var(--font); font-variant-numeric: tabular-nums;
}
a { color: var(--ai); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.pre { white-space: pre-wrap; }
small { font-size: 12px; }

/* ヘッダー：濃い墨色の帯（ボタンと同じ色） */
.top {
  display: flex; align-items: center; gap: 28px; padding: 0 24px; height: 56px;
  background: #16202a; color: #fff;
}
.top a { color: rgba(255, 255, 255, .78); text-decoration: none; }
.top .brand { white-space: nowrap; flex: none; font-weight: 700; letter-spacing: .04em; font-size: 15px; color: #fff; }
.top nav { display: flex; gap: 22px; font-size: 13px; }
.top nav a { padding: 17px 0 15px; border-bottom: 2px solid transparent; white-space: nowrap; }
.top nav a:hover { color: #fff; border-bottom-color: rgba(255, 255, 255, .5); text-decoration: none; }
.top .who { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 12px; white-space: nowrap; color: rgba(255, 255, 255, .78); }
.top .env { font-size: 11px; padding: 1px 9px; border-radius: 99px; background: #f0bb72; color: #16202a; font-weight: 600; }
.top button.link { color: rgba(255, 255, 255, .78); font-size: 12px; text-decoration: none; }
.top button.link:hover { color: #fff; text-decoration: underline; }
.top :focus-visible { outline-color: #9fc4f5; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .top { background: #0b1015; border-bottom: 1px solid var(--line-soft); }
}

main { max-width: 1200px; margin: 0 auto; padding: 28px 24px 64px; }

/* 見出し（物件以外のページ） */
.pagehead { margin: 0 0 20px; }
.pagehead h1 { font-size: 24px; line-height: 1.35; margin: 0 0 6px; font-weight: 700; letter-spacing: .02em; }
.pagehead .sub { color: var(--muted); margin: 0; max-width: 70ch; font-size: 13px; }
.pagehead .sub a { margin-right: 18px; }
.crumb { margin: 0 0 4px; font-size: 13px; }
.pagehead .jump { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.jump input { width: 7em; }

/* フォーム部品 */
input, select, button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=file]), select {
  background: var(--paper); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 10px; min-height: 38px;
}
input.num { text-align: right; }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
  background: var(--ink); color: var(--paper); border: 0; border-radius: 6px;
  padding: 8px 16px; min-height: 38px; font-weight: 500; font-size: 13px; text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; opacity: .9; }
.btn.small { min-height: 34px; padding: 4px 14px; }
.btn.ghost { background: var(--paper); color: var(--ai); box-shadow: inset 0 0 0 1px var(--ai); }
.btn.ghost:hover { background: color-mix(in srgb, var(--ai) 6%, var(--paper)); opacity: 1; }
.btn[disabled] { opacity: .6; cursor: progress; }
button.link { background: none; color: var(--ai); padding: 0; min-height: 0; text-decoration: underline; font-weight: 400; }
.field { display: grid; gap: 4px; }
.field > label:not(.dropzone), .field > .label { font-size: 12px; color: var(--muted); }
.field .value { margin: 0; font-weight: 700; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }
.check { display: flex; align-items: center; gap: 8px; }

/* ============ 物件の予実 ============ */
.phead { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 24px; flex-wrap: wrap; margin: 0 0 16px; }
.phead-title { display: grid; gap: 6px; min-width: 0; }
.phead h1 { margin: 0; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; line-height: 1.3; }
.pcode { font-size: 14px; font-weight: 600; color: var(--paper); background: var(--ink); padding: 3px 10px; border-radius: 4px; }
.pname { font-size: 26px; font-weight: 700; letter-spacing: .02em; }
.pmeta { margin: 0; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; }

.sync { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }

/* 物件・予算の選択と、表示の切り替えを1段に */
.controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 20px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 1 1 560px; min-width: 0; }
.tb-field {
  display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 6px;
  background: var(--paper); min-width: 0; flex: 0 1 260px;
}
.tb-field.tb-prop { flex-basis: 300px; }
.tb-field > span { font-size: 12px; color: var(--muted); padding: 0 4px 0 10px; white-space: nowrap; }
.tb-field select { border: 0; min-height: 36px; width: 100%; min-width: 0; background: transparent; padding-left: 4px; }
.toggles { display: flex; gap: 8px; flex-wrap: wrap; }
.seg-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--paper); }
.seg-toggle a { padding: 0 14px; text-decoration: none; color: var(--ink); min-height: 36px; display: inline-flex; align-items: center; font-size: 13px; }
.seg-toggle a:hover { background: var(--tint); text-decoration: none; }
.seg-toggle a[aria-current] { background: var(--ink); color: var(--paper); }

.notice { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; background: var(--pe-bg); border: 1px solid var(--pe-line); padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }

/* 全体：3つの数字を同じ並びで */
.overview {
  background: var(--paper); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 24px 28px; margin-bottom: 20px; display: grid; gap: 18px;
}
.ov-figs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 24px; }
.fig { display: grid; gap: 2px; align-content: start; }
.fig-label { font-size: 12px; color: var(--muted); }
.fig-num { font-size: 30px; line-height: 1.2; font-weight: 600; letter-spacing: -.01em; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.fig-rate { font-size: 15px; font-weight: 500; color: var(--muted); }
.fig-sub { font-size: 12px; color: var(--pe-ink); }
.fig-rem .fig-num { color: var(--ai); font-weight: 700; }
.overview.is-over .fig-rem .fig-num, .overview.is-over .fig-rem .fig-label { color: var(--ov-ink); }

.ov-cats { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 4px 32px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.oc {
  display: grid; grid-template-columns: 96px minmax(0, 1fr) 56px; gap: 2px 12px; align-items: center;
  padding: 6px 8px; margin: 0 -8px; border-radius: 6px; text-decoration: none; color: var(--ink);
}
.oc:hover { background: var(--tint); text-decoration: none; }
.oc-name { font-weight: 500; font-size: 13px; }
.oc-rate { font-size: 13px; text-align: right; }
.oc-rest { grid-column: 2 / -1; font-size: 12px; color: var(--muted); }
.oc-rest b { color: var(--ink); font-weight: 600; }
.oc.is-over .oc-rate, .oc.is-over .oc-rest b { color: var(--ov-ink); }

.ov-alert {
  margin: 0; display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--ov-ink);
  background: var(--ov-bg); border-radius: 6px; padding: 8px 12px;
}
.ov-alert svg { flex: none; margin-top: 3px; }

/* 凡例キー */
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; flex: none; }
.key.ap { background: var(--ap); }
.key.pe { background: var(--pe); }
.key.ov { background: var(--ov); }
.key.mk { width: 2px; height: 12px; background: var(--muted); border-radius: 0; }

/* 消化バー */
.bar {
  position: relative; display: inline-block; vertical-align: middle;
  width: calc(100% - 66px); height: 6px; background: var(--track); border-radius: 3px;
}
.bar.is-empty { background: var(--track); opacity: .6; }
.bar.wide { display: block; width: 100%; height: 10px; border-radius: 5px; }
.bar.tall { display: block; width: 100%; height: 8px; }
.bar.thin { display: block; width: 100%; height: 6px; }
.bar .seg { position: relative; float: left; height: 100%; }
.bar .seg:first-child { border-radius: 3px 0 0 3px; }
.bar .ap { background: var(--ap); }
.bar .pe { background: var(--pe); }
.bar .ov { position: absolute; top: 0; background: var(--ov); border-radius: 0 3px 3px 0; }
.bar .mark { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--muted); border-radius: 1px; }
.rate { display: inline-block; width: 62px; text-align: right; font-size: 12.5px; color: var(--muted); }
.is-over .rate { color: var(--ov-ink); font-weight: 600; }

/* 費目が決まっていない申請 */
.alert {
  background: var(--pe-bg); border: 1px solid var(--pe-line); border-radius: var(--radius);
  padding: 16px 20px; margin-bottom: 20px; display: grid; gap: 10px;
}
.alert h2 { font-size: 14px; margin: 0; color: var(--pe-ink); }
.alert h2 span { font-weight: 400; }
.alert ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.alert li {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto auto auto; gap: 6px 14px; align-items: center;
  background: var(--paper); border: 1px solid var(--line-soft); border-radius: 8px; padding: 8px 12px;
}
.alert .rtitle { min-width: 0; }
.alert li small { display: block; color: var(--muted); }
.alert .ramt { text-align: right; white-space: nowrap; }

/* 申請の一覧（展開部分） */
.reqitems { list-style: none; margin: 0; padding: 0; }
.reqitems li {
  display: grid; grid-template-columns: 64px 84px minmax(0, 1fr) auto auto auto; gap: 4px 16px; align-items: center;
  padding: 8px 0; font-size: 13px;
}
.reqitems li + li { border-top: 1px dashed var(--line); }
.reqitems .rdate { color: var(--muted); font-size: 12px; }
.reqitems small { display: block; color: var(--muted); }
.reqitems .ramt { text-align: right; white-space: nowrap; }
.reqitems .redit { font-size: 12px; white-space: nowrap; }

.tag { display: inline-block; font-size: 12px; padding: 1px 10px; border-radius: 99px; white-space: nowrap; line-height: 1.7; }
.tag-approved { color: var(--ai); background: color-mix(in srgb, var(--ap) 10%, var(--paper)); }
.tag-pending { color: var(--pe-ink); background: var(--pe-bg); box-shadow: inset 0 0 0 1px var(--pe-line); }
.tag-x { color: var(--muted); background: var(--tint); box-shadow: inset 0 0 0 1px var(--line-soft); }

.foot { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 24px; margin-top: 14px; font-size: 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); margin: 0; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* 表まわり共通 */
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 12px; text-align: left; vertical-align: middle; }
.num { text-align: right; white-space: nowrap; }
.code { width: 4em; white-space: nowrap; }
.neg, .up { color: var(--ov-ink); }
.down { color: var(--ap); }
.strong { font-weight: 700; }

.expand {
  background: none; color: var(--ink); padding: 0; min-height: 0; text-align: left; font-weight: inherit; font-size: inherit;
  display: inline-flex; align-items: center; gap: 8px; white-space: normal;
}
.expand::before {
  content: ""; width: 0; height: 0; border-left: 5px solid var(--faint);
  border-top: 4px solid transparent; border-bottom: 4px solid transparent; transition: transform .15s; margin-left: -13px;
}
.expand[aria-expanded="true"]::before { transform: rotate(90deg); }
.expand:hover { opacity: 1; }
.expand .count { font-size: 11px; color: var(--ai); background: color-mix(in srgb, var(--ai) 9%, transparent); padding: 0 7px; border-radius: 99px; font-weight: 500; }
tr.reqs > td { background: var(--tint); padding: 4px 24px 10px 40px; border-top: 1px solid var(--line-soft); }

/* ---------- 一覧：1行1費目 ---------- */
.lgroups { display: grid; gap: 20px; }
.lgroup { background: var(--paper); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.lg-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 20px; padding: 18px 24px 12px; }
.lg-head h2 { margin: 0; font-size: 17px; }
.lg-sum { font-size: 13px; color: var(--muted); }
.lg-sum b { color: var(--ink); font-weight: 600; }
.lg-rate { margin-left: auto; font-size: 13px; color: var(--muted); }
.lg-head.is-over .lg-rate { color: var(--ov-ink); font-weight: 600; }

table.lt { min-width: 720px; }
.lt thead th {
  font-size: 12px; color: var(--muted); font-weight: 400; padding: 8px 24px;
  background: var(--tint); border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft);
}
.lt .item { width: 30%; padding-left: 24px; }
.lt .use { width: auto; white-space: nowrap; }
.lt th.num, .lt td.num { width: 200px; }
.lt td.rem { width: 140px; padding-right: 24px; }
.lt thead .num:last-child { padding-right: 24px; }
.lt tr.line > * { border-bottom: 1px solid var(--line-soft); padding-top: 11px; padding-bottom: 11px; }
.lt tr.line:last-child > * { border-bottom: 0; }
.lt tr.line > th { font-weight: 500; font-size: 14px; }
.lt tr.line > th.item { padding-left: 24px; }
.lt .name, .lt .expand { font-weight: 500; }
.lt .memo { display: block; font-size: 11.5px; color: var(--faint); font-weight: 400; max-width: 36ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lt .fb { color: var(--muted); font-size: 13px; }
.lt .rem { font-size: 15px; font-weight: 600; color: var(--muted); }
.lt .is-used .rem { color: var(--ink); }
.lt .rem small { display: block; font-size: 11px; font-weight: 400; }
.lt tr.line.is-over > * { background: var(--ov-bg); }
.lt .is-over .rem { color: var(--ov-ink); }
.lt tr.line:hover > * { background: color-mix(in srgb, var(--ai) 3%, var(--paper)); }
.lt tr.line.is-over:hover > * { background: var(--ov-bg); }
.lt .is-zero th, .lt .is-zero td { color: var(--faint); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; margin-top: 4px; }
.chip { font-size: 11.5px; padding: 1px 8px; border-radius: 99px; white-space: nowrap; }
.chip-pe { color: var(--pe-ink); background: var(--pe-bg); box-shadow: inset 0 0 0 1px var(--pe-line); }
.chip-up { color: var(--ov-ink); background: var(--ov-bg); }
.chip-down { color: var(--ai); background: color-mix(in srgb, var(--ap) 9%, var(--paper)); }

/* ---------- 表 ---------- */
table.yj { background: var(--paper); border-radius: var(--radius); min-width: 860px; border: 1px solid var(--line-soft); }
.yj thead th {
  font-size: 12px; color: var(--muted); font-weight: 400; white-space: nowrap; padding-top: 12px; padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.yj .item { width: 26%; }
.yj .use { width: 24%; white-space: nowrap; }
.yj td.num { font-size: 14px; }
.yj .cmp { color: var(--muted); background: var(--tint); }
.yj tr.cat > * { background: var(--tint); font-weight: 700; padding-top: 12px; padding-bottom: 12px; border-top: 1px solid var(--line); }
.yj tr.cat th { font-size: 14px; }
.yj tr.line > * { border-top: 1px solid var(--line-soft); height: 48px; }
.yj tr.line > .item { padding-left: 24px; font-weight: 400; }
.yj tr.line:hover > * { background: color-mix(in srgb, var(--ai) 3%, var(--paper)); }
.yj .pend { color: var(--pe-ink); }
.yj tr.line.is-over > * { background: var(--ov-bg); }
.yj .is-over .rem { color: var(--ov-ink); font-weight: 700; }
.yj tfoot tr.total > * { border-top: 2px solid var(--ink); font-weight: 700; font-size: 15px; padding-top: 14px; padding-bottom: 14px; }
.yj .memo { display: block; font-size: 12px; color: var(--faint); font-weight: 400; }
.is-zero th, .is-zero td { color: var(--faint); }

/* ============ その他のページ ============ */
table.list { background: var(--paper); border-radius: var(--radius); border: 1px solid var(--line-soft); }
.list thead th { font-size: 12px; color: var(--muted); font-weight: 400; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--tint); }
.list tbody td { border-top: 1px solid var(--line-soft); }
.list caption { text-align: left; font-weight: 700; padding: 0 0 8px; }
.list tfoot th, .list tfoot td { border-top: 1px solid var(--line); }
.list.narrow { max-width: 720px; }
.list .use { width: 220px; white-space: nowrap; }
.is-excluded td { color: var(--muted); }
.is-excluded td:nth-child(3) { text-decoration: line-through; }
.payee { display: block; font-size: 12px; color: var(--muted); }

.card-form {
  display: grid; gap: 16px; align-content: start; max-width: 520px;
  background: var(--paper); border-radius: var(--radius); border: 1px solid var(--line-soft); padding: 20px;
}
.import-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin: 8px 0 16px; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 700; }
.filename { margin: 0; color: var(--muted); }
.warnings, .errors { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; }
.warnings { background: var(--pe-bg); border: 1px solid var(--pe-line); }
.errors { background: var(--ov-bg); color: var(--ov-ink); }
.warnings ul, .errors ul { margin: 0; padding-left: 1.2em; }
.errors p { margin: 0 0 4px; font-weight: 700; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 24px; background: var(--paper); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 16px 20px; margin: 0 0 20px; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 0; }
.facts .wide { grid-column: 1 / -1; }
.alloc { max-width: 820px; }
.form-table { background: var(--paper); border: 1px solid var(--line-soft); border-radius: var(--radius); margin: 8px 0 16px; }
.form-table th { font-size: 12px; color: var(--muted); font-weight: 400; }
.form-table td { border-top: 1px solid var(--line-soft); }
.form-table select, .form-table input { width: 100%; }
.form-table tfoot td, .form-table tfoot th { border-top: 1px solid var(--line); font-weight: 700; }
.form-table [data-rest].neg { color: var(--ov-ink); }
.actions { display: flex; align-items: center; gap: 20px; }

.flash { padding: 10px 14px; border-radius: var(--radius); margin: 0 0 16px; background: color-mix(in srgb, var(--ap) 9%, var(--paper)); font-size: 13px; }
.flash-warn { background: var(--pe-bg); }

.empty { background: var(--paper); border: 1px dashed var(--line); border-radius: var(--radius); padding: 32px; text-align: center; }
.empty p { color: var(--muted); }

@media (max-width: 900px) {
  .top { gap: 14px; padding: 0 16px; overflow-x: auto; }
  .top nav { gap: 14px; }
  main { padding: 20px 16px 48px; }
  .pname { font-size: 20px; }
  .sync { justify-content: flex-start; }
  .tb-field, .tb-field.tb-prop { flex: 1 1 100%; }
  .ov-figs { grid-template-columns: 1fr 1fr; }
  .fig-rem { grid-column: 1 / -1; }
  .fig-num { font-size: 24px; }
  .ov-cats { grid-template-columns: 1fr; }
  .overview { padding: 18px; }
  .alert li { grid-template-columns: auto 1fr auto; }
  .alert .rtitle { grid-column: 1 / -1; order: -1; }
  .lg-head { padding: 14px 16px 10px; }
  /* 一覧：1費目を2段に（名前・残額／バー・見込と予算） */
  table.lt, .lt tbody { display: block; min-width: 0; }
  .lt thead { display: none; }
  .lt tr.line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 10px 16px; border-bottom: 1px solid var(--line-soft); }
  .lt tr.line:last-child { border-bottom: 0; }
  .lt tr.line > * { display: block; padding: 0 !important; border: 0 !important; width: auto !important; }
  .lt tr.line > th.item { padding-left: 14px !important; }
  .lt tr.line > th.item { grid-column: 1; grid-row: 1; }
  .lt td.rem { grid-column: 2; grid-row: 1; align-self: center; text-align: right; }
  .lt td.use { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
  .lt td.use .bar { flex: 1; width: auto; }
  .lt td.fb { grid-column: 1 / -1; text-align: left; font-size: 12px; }
  .lt .chips { justify-content: flex-start; }
  .lt tr.line.is-over { background: var(--ov-bg); }
  .lt tr.reqs { display: block; }
  .lt tr.reqs > td { display: block; padding: 4px 16px 10px; }
  .reqitems li { grid-template-columns: 1fr auto; }
  .reqitems .rtitle { grid-column: 1 / -1; order: -1; }
  .import-grid { grid-template-columns: 1fr; }
  .top .uname { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  .top, .controls, .sync, .alert .btn, .switcher { display: none; }
  body { background: #fff; }
}

/* ログイン */
.card-form.login { margin: 48px auto; max-width: 400px; }
.card-form.login h1 { font-size: 22px; margin: 0; }
.card-form.login .btn.google { background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); min-height: 44px; font-size: 14px; gap: 10px; }
.card-form.login .btn.google:hover { background: var(--tint); opacity: 1; }
.card-form.login .pw-form { display: grid; gap: 16px; }
.card-form.login .or { display: flex; align-items: center; gap: 12px; margin: 0; color: var(--muted); font-size: 12px; }
.card-form.login .or::before, .card-form.login .or::after { content: ""; flex: 1; border-top: 1px solid var(--line-soft); }

/* 収支表の選択（押しても、ドラッグしても） */
.dropzone {
  position: relative; display: flex; align-items: center; gap: 14px; cursor: pointer;
  border: 1.5px dashed var(--line); border-radius: 8px; background: var(--tint);
  padding: 18px 18px; color: var(--muted); transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--ai); background: color-mix(in srgb, var(--ai) 5%, var(--paper)); color: var(--ai); }
.dropzone:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.dropzone input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone svg { flex: none; }
.dz-text { display: grid; gap: 2px; line-height: 1.5; min-width: 0; }
.dz-text b { color: var(--ink); font-weight: 600; font-size: 14px; }
.dz-text span { font-size: 12px; }
.dropzone.has-file { border-style: solid; border-color: var(--ai); background: var(--paper); color: var(--ai); }
.dz-file b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dz-text[hidden] { display: none; }

/* 物件の終了 */
.phead-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.btn.quiet { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); font-weight: 400; }
.btn.quiet:hover { color: var(--ink); background: var(--paper); opacity: 1; }
.tag-closed { color: var(--paper); background: var(--muted); font-size: 12px; font-weight: 500; align-self: center; }
.closed-note { margin: -4px 0 16px; padding: 8px 12px; border-radius: 6px; background: var(--tint); border: 1px solid var(--line-soft); color: var(--muted); font-size: 13px; }
.tab-count { display: inline-block; min-width: 1.6em; padding: 0 6px; margin-left: 4px; border-radius: 99px; background: var(--track); color: var(--muted); font-size: 12px; text-align: center; font-weight: 500; }
.tabs a[aria-current] .tab-count { background: var(--ink); color: var(--paper); }
@media (max-width: 900px) { .phead-side { align-items: flex-start; width: 100%; } }
.is-saved-only td { color: var(--muted); }
.is-saved-only td.strong { font-weight: 400; }

/* 利益：ふだんは閉じておき、開くと見られる */
.profit { background: var(--paper); border: 1px solid var(--line-soft); border-radius: var(--radius); margin-top: 20px; }
.profit[open] { padding-bottom: 22px; display: grid; gap: 16px; }
.profit > :not(summary) { margin-left: 28px; margin-right: 28px; }
.pf-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; padding: 14px 28px; cursor: pointer; list-style: none; border-radius: var(--radius); }
.pf-head::-webkit-details-marker { display: none; }
.pf-head::before { content: ""; border-left: 6px solid var(--faint); border-top: 5px solid transparent; border-bottom: 5px solid transparent; transition: transform .15s; }
.profit[open] > .pf-head::before { transform: rotate(90deg); }
.profit[open] > .pf-head { border-bottom: 1px solid var(--line-soft); border-radius: var(--radius) var(--radius) 0 0; }
.pf-head:hover { background: var(--tint); }
.pf-title { font-size: 15px; font-weight: 700; }
.pf-title small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.pf-peek { margin-left: auto; display: flex; align-items: baseline; gap: 10px; font-size: 13px; }
.pf-peek b { font-size: 17px; font-weight: 600; }
.pf-warn { margin: 0; font-size: 13px; color: var(--pe-ink); background: var(--pe-bg); border: 1px solid var(--pe-line); border-radius: 6px; padding: 8px 12px; }
.pf-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px 32px; }
.pf-col h3 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.pf-col.is-actual h3 { color: var(--ai); }
.pf-col dl { margin: 0; display: grid; }
.pf-col dl > div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.pf-col dt { font-size: 13px; color: var(--muted); display: grid; }
.pf-col dt small { font-size: 11.5px; color: var(--faint); }
.pf-col dd { margin: 0; font-size: 16px; font-weight: 500; text-align: right; white-space: nowrap; }
.pf-col dd small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 8px; }
.pf-col .pf-total { border-bottom: 0; padding-top: 10px; }
.pf-col .pf-total dt { color: var(--ink); font-weight: 600; font-size: 14px; }
.pf-col .pf-total dd { font-size: 26px; font-weight: 700; color: var(--ai); }
.pf-col .pf-total.is-neg dd { color: var(--ov-ink); }
.pf-edit { display: grid; gap: 12px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.pf-sales, .pf-int-add { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; }
.pf-sales .field input { width: 220px; }
.pf-int-add .grow { flex: 1 1 200px; }
.pf-int-add .grow input { width: 100%; }
.pf-interest summary { cursor: pointer; font-size: 13px; color: var(--ai); }
.pf-interest[open] { display: grid; gap: 10px; }
.pf-int-list { max-width: 720px; }
.field-error { margin: 0; color: var(--ov-ink); font-size: 12px; flex-basis: 100%; }
@media (max-width: 900px) { .profit > :not(summary) { margin-left: 16px; margin-right: 16px; } .pf-head { padding: 12px 16px; } .pf-peek { margin-left: 0; } .pf-sales .field, .pf-sales .field input { width: 100%; } }
.pf-int-import { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.pf-int-import .dropzone { flex: 1 1 360px; padding: 10px 14px; }

/* 必ずかかる費用（公租公課など）：未払分も見込に入れる。灰の斜線で「まだ払っていないが必ず出ていく」 */
:root { --cm: #7b8794; }
.bar .cm { background: repeating-linear-gradient(135deg, var(--cm) 0 3px, transparent 3px 6px); box-shadow: inset 0 0 0 1px var(--cm); }
.key.cm { background: repeating-linear-gradient(135deg, var(--cm) 0 2px, transparent 2px 4px); box-shadow: inset 0 0 0 1px var(--cm); }
.tag-committed { font-size: 11px; padding: 0 8px; margin-left: 8px; color: var(--muted); background: var(--tint); box-shadow: inset 0 0 0 1px var(--line); vertical-align: 1px; font-weight: 500; }
.chip-cm { color: var(--muted); background: var(--tint); box-shadow: inset 0 0 0 1px var(--line); }
.fig-sub.cm { color: var(--muted); }
.cm-note { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }

/* 主役は建築費。全体と土地は小さく */
.ov-title { margin: 0 0 -6px; font-size: 15px; font-weight: 700; }
.ov-title small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.ov-minor { display: grid; gap: 2px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.om {
  display: grid; grid-template-columns: 84px minmax(80px, 200px) 52px minmax(0, 1fr); gap: 4px 12px; align-items: center;
  padding: 4px 8px; margin: 0 -8px; border-radius: 6px; text-decoration: none; color: var(--muted); font-size: 12px;
}
a.om:hover { background: var(--tint); text-decoration: none; }
a.om[aria-disabled] { pointer-events: none; }
.om-name { color: var(--ink); font-weight: 500; }
.om-rate { text-align: right; }
.om-figs b { color: var(--ink); font-weight: 600; }
.om.is-over .om-rate, .om.is-over .om-figs b { color: var(--ov-ink); }
.lgroup.is-minor > summary { cursor: pointer; list-style: none; padding: 12px 24px; }
.lgroup.is-minor > summary::-webkit-details-marker { display: none; }
.lgroup.is-minor > summary::before { content: ""; border-left: 6px solid var(--faint); border-top: 5px solid transparent; border-bottom: 5px solid transparent; transition: transform .15s; align-self: center; }
.lgroup.is-minor[open] > summary::before { transform: rotate(90deg); }
.lgroup.is-minor > summary h2 { font-size: 14px; }
.lgroup.is-minor > summary .lg-sum, .lgroup.is-minor > summary .lg-rate { font-size: 12px; }
.lgroup.is-minor > summary:hover { background: var(--tint); }
@media (max-width: 900px) { .om { grid-template-columns: 1fr auto; } .om .bar { grid-column: 1 / -1; order: 3; } .om-figs { grid-column: 1 / -1; order: 4; } }

/* 期中金利（予実の対象外） */
.om-name small { display: block; font-size: 10.5px; color: var(--faint); font-weight: 400; line-height: 1.3; }
.lgroup.interest { margin-top: 20px; }
.it-body { display: grid; gap: 10px; padding-bottom: 14px; }
.it-body > .hint, .it-link { margin: 0 24px; }
.it-link { font-size: 13px; }

/* 物件一覧：予算も申請もない物件はまとめて畳む */
.idle-props { margin-top: 20px; background: var(--paper); border: 1px solid var(--line-soft); border-radius: var(--radius); }
.idle-props > summary { cursor: pointer; padding: 12px 18px; font-size: 13px; font-weight: 600; }
.idle-props > summary .muted { font-weight: 400; font-size: 12px; margin-left: 8px; }
.idle-list { list-style: none; margin: 0; padding: 4px 18px 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 2px 24px; font-size: 13px; }
.idle-list a { display: flex; gap: 10px; padding: 4px 0; color: var(--ink); }
.idle-list .code { width: 3.2em; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }

/* 金額の単位（千円／円）：数字のすぐ後ろに小さく */
.unit { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 3px; letter-spacing: 0; }
.fig-num .unit { font-size: 13px; margin-left: -6px; }
.fig-num .unit + .fig-rate { margin-left: 8px; }
.om-figs .unit, .oc-rest .unit { font-size: 11px; }

/* 物件の対象外 */
.tag-excluded { color: var(--muted); background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); font-size: 12px; font-weight: 500; align-self: center; margin-left: 4px; }
.idle-form { display: grid; }
.idle-bar { display: flex; align-items: center; gap: 16px; padding: 0 18px 4px; font-size: 13px; }
.idle-list li { display: flex; align-items: center; gap: 8px; }
.idle-list li input { flex: none; margin: 0; }
.excluded-list { max-width: 880px; }
.status-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 900px) { .status-btns { justify-content: flex-start; } }
