:root {
  --ink: #1a1f1c;
  --ink-soft: #3d4741;
  --muted: #6b756f;
  --line: #d5ddd6;
  --paper: #f3f5f1;
  --panel: #ffffff;
  --accent: #1f6b4a;
  --accent-deep: #144832;
  --accent-soft: #e4f0ea;
  --warn: #b45309;
  --danger: #b42318;
  --profit: #0f6b46;
  --loss: #b42318;
  --phase: #f0ebe0;
  --phase-strong: #e2d4b8;
  --shadow: 0 12px 40px rgba(26, 31, 28, 0.08);
  --radius: 10px;
  --font: "Zen Kaku Gothic New", "Hiragino Sans", "Noto Sans JP", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --fs: 16px;
  --fs-sm: 14px;
  --fs-xs: 13px;
  --fs-lg: 18px;
  --fs-xl: 22px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: var(--fs);
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #dce8e1 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #ebe4d4 0%, transparent 50%),
    linear-gradient(180deg, #eef1ec 0%, #e7ebe6 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.app.nav-mode-left {
  grid-template-columns: 240px 1fr;
  grid-template-rows: 1fr;
}

.app.nav-mode-top {
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
}

.app.nav-mode-hidden {
  grid-template-columns: 1fr;
}

.app.nav-mode-hidden .sidebar {
  display: none;
}

/* 上部ヘッダー表示 — 濃緑 #0f3d2d + 白文字 */
.app.nav-mode-top .sidebar {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 20px;
  padding: 12px 20px;
  position: sticky;
  top: 0;
  z-index: 40;
  background: #0f3d2d;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 2px 10px rgba(15, 61, 45, 0.35);
}

.app.nav-mode-top .brand {
  padding: 0;
  flex: 0 0 auto;
}

.app.nav-mode-top .brand-kicker {
  color: rgba(255, 255, 255, 0.75);
  opacity: 1;
}

.app.nav-mode-top .brand h1 {
  font-size: 18px;
  color: #fff;
}

.app.nav-mode-top .brand p {
  display: none;
}

.app.nav-mode-top .nav {
  flex-direction: row;
  flex-wrap: wrap;
  flex: 1 1 auto;
  gap: 4px;
  min-width: 0;
}

.app.nav-mode-top .nav button {
  padding: 10px 12px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  opacity: 1;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.app.nav-mode-top .nav button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.app.nav-mode-top .nav button.active {
  color: #fff;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 -3px 0 #7dcea0;
}

.app.nav-mode-top .role-box {
  margin-top: 0;
  flex: 0 0 auto;
  min-width: 200px;
  max-width: 260px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
}

.app.nav-mode-top .role-box label {
  margin-bottom: 4px;
  color: rgba(255, 255, 255, 0.75);
}

.app.nav-mode-top .role-user {
  padding: 6px 8px;
  font-size: 11px;
  background: #fff;
  color: #0f3d2d;
  font-weight: 700;
}

.app.nav-mode-top .btn-logout {
  padding: 6px 8px;
  font-size: 11px;
  color: #0f3d2d;
  background: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

.app.nav-mode-top .btn-logout:hover {
  background: #eef6f2;
  color: #0f3d2d;
}

.app.nav-mode-top .role-meta {
  display: none;
}

.app.nav-mode-top .nav-chrome-side {
  display: none;
}

.app.nav-mode-left .nav-chrome-top {
  display: none;
}

.app.nav-mode-top .nav-chrome-top,
.app.nav-mode-hidden .nav-chrome-top {
  display: flex;
}

.nav-chrome {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-chrome-side {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.nav-chrome-label {
  font-size: 10px;
  letter-spacing: 0.06em;
  opacity: 0.65;
  white-space: nowrap;
}

.nav-chrome-top .nav-chrome-label {
  color: var(--muted);
  opacity: 1;
}

.app.nav-mode-top .nav-chrome-top .nav-chrome-label {
  color: rgba(255, 255, 255, 0.75);
}

.nav-chrome-btns {
  display: inline-flex;
  gap: 4px;
}

.nav-mode-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: #e8f2ec;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  min-width: 28px;
}

.nav-chrome-top .nav-mode-btn {
  border-color: var(--line);
  background: #fff;
  color: var(--ink-soft);
}

.app.nav-mode-top .nav-chrome-top .nav-mode-btn {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-mode-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.nav-chrome-top .nav-mode-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.app.nav-mode-top .nav-chrome-top .nav-mode-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.nav-mode-btn.is-active {
  background: #8fd6b3;
  border-color: #8fd6b3;
  color: #10261e;
}

.nav-chrome-top .nav-mode-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.topbar-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.nav-reopen-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  margin-top: 4px;
}

.nav-reopen-btn:hover {
  background: var(--accent-soft);
  border-color: #b7d6c6;
  color: var(--accent-deep);
}

.sidebar {
  background: linear-gradient(180deg, #17352a 0%, #10261e 100%);
  color: #e8f2ec;
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  padding: 0 8px;
}

.brand-kicker {
  font-size: var(--fs-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.65;
  margin-bottom: 6px;
}

.brand h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand p {
  margin: 8px 0 0;
  font-size: var(--fs-sm);
  line-height: 1.5;
  opacity: 0.72;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav button {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 12px 12px;
  border-radius: 8px;
  opacity: 0.78;
  transition: 0.18s ease;
  font-size: var(--fs);
}

.nav button:hover,
.nav button.active {
  background: rgba(255, 255, 255, 0.1);
  opacity: 1;
}

.nav button.active {
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 3px 0 0 #8fd6b3;
}

.role-box {
  margin-top: auto;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px;
}

.role-box label {
  display: block;
  font-size: 11px;
  opacity: 0.7;
  margin-bottom: 8px;
}

.role-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.role-user {
  flex: 1;
  min-width: 0;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.role-meta {
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.45;
  opacity: 0.85;
}

.btn-logout {
  flex: 0 0 auto;
  width: auto;
  margin: 0;
  font-size: 11px;
  padding: 8px 10px;
  white-space: nowrap;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 15% 0%, rgba(31, 107, 74, 0.28), transparent 55%),
    radial-gradient(700px 360px at 90% 10%, rgba(201, 133, 45, 0.18), transparent 50%),
    #1a2430;
}

.login-overlay[hidden] {
  display: none !important;
}

.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 28px 26px 22px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  color: #1a2433;
}

.login-brand {
  font-size: 12px;
  font-weight: 700;
  color: #1f6b4a;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 1.45rem;
}

.login-card .muted {
  color: #5c6b7a;
  margin: 0 0 8px;
}

.login-card .field {
  display: grid;
  gap: 6px;
  margin: 12px 0;
}

.login-card .field label {
  font-size: 12px;
  color: #5c6b7a;
  font-weight: 600;
}

.login-card .field input,
.login-card .field select {
  border: 1px solid #cfd8e0;
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}

.login-card .error {
  color: #b42318;
  font-size: 13px;
  margin: 4px 0 0;
}

.login-hint {
  margin-top: 14px;
  font-size: 12px;
  line-height: 1.55;
}

.app.is-locked {
  visibility: hidden;
  pointer-events: none;
}

.main {
  padding: 28px 32px 48px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 22px;
}

.topbar h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.topbar .sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.badge-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-soft);
}

.badge strong {
  color: var(--accent-deep);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel + .panel,
.grid-2 > .panel {
  margin-top: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fbfcfb, #f5f7f4);
}

.panel-head h3 {
  margin: 0;
  font-size: var(--fs-lg);
}

.panel-body {
  padding: 18px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.stat .label {
  font-size: 12px;
  color: var(--muted);
}

.stat .value {
  margin-top: 8px;
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.stat .hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.stat.good .value {
  color: var(--profit);
}

.stat.bad .value {
  color: var(--loss);
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: var(--fs);
  transition: 0.15s ease;
}

.btn:hover {
  background: var(--accent-deep);
}

.btn.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.btn.secondary:hover {
  background: var(--paper);
}

.btn.ghost {
  background: transparent;
  color: var(--accent-deep);
  border-color: transparent;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.table-wrap {
  overflow: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs);
}

table.data th,
table.data td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

table.data th {
  font-size: var(--fs-sm);
  letter-spacing: 0.04em;
  color: var(--muted);
  background: #f7f9f7;
  position: sticky;
  top: 0;
  z-index: 1;
}

table.data th.th-sort {
  cursor: pointer;
  user-select: none;
}
table.data th.th-sort:hover {
  color: var(--ink);
  background: #eef3ef;
}
table.data th.th-sort.is-sorted {
  color: var(--ink);
  font-weight: 700;
}

table.data td.num,
table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: var(--fs-sm);
}

table.data tr:hover td {
  background: #f7faf8;
}

table.data tr.clickable {
  cursor: pointer;
}

.tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.tag.public {
  background: #e8f0ff;
  color: #1d4f91;
}

.tag.dept {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.tag.done {
  background: #eceff1;
  color: #455a64;
}

.tag.active {
  background: #fff4e5;
  color: #9a5b00;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 12px;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.field textarea {
  min-height: 80px;
  resize: vertical;
}

.process-picker {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.process-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.process-card > label.head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--phase);
  cursor: pointer;
  font-weight: 700;
}

.process-card .children {
  padding: 8px 10px 12px 34px;
  display: grid;
  gap: 6px;
}

.process-card .children label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
}

.source-dot {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--line);
}

.source-dot.shot {
  color: var(--accent-deep);
  border-color: #b7d6c6;
  background: var(--accent-soft);
}

.workspace {
  display: grid;
  grid-template-columns: 390px 1fr;
  align-items: start;
  min-height: 560px;
  gap: 0;
}

.tree {
  position: sticky;
  top: 8px;
  max-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #f4f6f5;
  padding: 12px;
  overflow: hidden;
  min-height: 0;
}

.folder-tree {
  display: flex;
  flex-direction: column;
  gap: 0;
  font-size: var(--fs);
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
  margin-right: -2px;
}

.tree-item {
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0;
  border-radius: 0;
  color: inherit;
  font-size: 13px;
  font: inherit;
  cursor: pointer;
  min-width: 0;
  flex: 1;
}

.tree-item:hover,
.tree-item.active {
  background: transparent;
  box-shadow: none;
}

.detail-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.toc-workspace .detail-pane {
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
  scroll-behavior: smooth;
}

.meisai-doc-wrap {
  overflow-x: auto;
  overflow-y: auto;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  max-height: min(560px, calc(100vh - 360px));
  border: 1px solid var(--line, #d5ddd8);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #fff;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

/* Native H/V bars off — only .meisai-hscroll is visible */
.meisai-doc-wrap::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}

.meisai-cost-grid {
  --meisai-head-row1: 40px;
  border-collapse: separate;
  border-spacing: 0;
}

.meisai-cost-grid thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink);
  padding: 8px 10px;
  white-space: nowrap;
  line-height: 1.3;
  background: #f7f8f9;
  /* table.data の border-bottom を打ち消し、2行ヘッダー間の隙間をなくす */
  border-bottom: 0 !important;
  box-shadow: none;
}

/* 2行ヘッダーを両方固定：1行目（隙間ゼロ） */
.meisai-cost-grid thead tr.meisai-head-group th {
  top: 0;
  z-index: 5;
  height: var(--meisai-head-row1);
  padding: 8px 8px;
  box-sizing: border-box;
  vertical-align: middle;
}

/* 2行ヘッダーを両方固定：2行目（1行目の直下に密着） */
.meisai-cost-grid thead tr.meisai-head-sub th {
  top: var(--meisai-head-row1);
  z-index: 4;
  padding: 8px 8px;
  box-shadow: 0 1px 0 var(--line, #d5ddd8);
}

.meisai-cost-grid thead th.col-code,
.meisai-cost-grid thead th.col-trade,
.meisai-cost-grid thead th.num,
.meisai-cost-grid thead th.col-no {
  font-size: var(--fs-lg);
  font-family: inherit;
}

.meisai-cost-grid tr.proc-anchor {
  cursor: pointer;
}

.meisai-cost-grid tr.proc-anchor:hover td {
  filter: brightness(0.985);
}

.detail-sticky-head {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #fff;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}

.cost-summary-host {
  margin-bottom: 12px;
}

.detail-shared-above-tabs {
  padding: 12px 14px 14px;
}

.meisai-condition-host {
  margin: 0 0 8px;
}

.cost-summary-panel {
  background: #fff;
  border: 1px solid var(--line, #d5ddd8);
  border-radius: 6px;
  padding: 10px 12px 12px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.cost-tax-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.cost-tax-select select {
  min-width: 88px;
  padding: 4px 8px;
  border: 1px solid #b8c0c8;
  border-radius: 4px;
  background: #fff;
  font-size: 13px;
}

.cost-tax-hint {
  font-size: 12px;
  font-weight: 500;
}

.cost-summary-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.cost-summary-actions-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-edit-summary {
  background: #e67e22 !important;
  border-color: #d35400 !important;
  color: #fff !important;
  padding: 4px 16px;
  font-size: 13px;
  font-weight: 700;
}

.cost-summary-wrap {
  overflow-x: auto;
  width: 100%;
}

.cost-summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

.cost-summary-table th,
.cost-summary-table td {
  border: 1px solid #b8c0c6;
  padding: 8px 12px;
  white-space: nowrap;
  line-height: 1.35;
}

.cost-summary-table thead th {
  background: #4a5560;
  color: #fff;
  font-weight: 600;
  text-align: center;
  font-size: 12px;
  padding: 8px 10px;
}

.cost-summary-table tbody th {
  background: #4a5560;
  color: #fff;
  font-weight: 600;
  text-align: center;
  width: 72px;
  padding: 8px 10px;
  font-size: 12px;
}

.cost-summary-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  background: #fff;
  padding-left: 16px;
  padding-right: 14px;
}

.proc-anchor {
  scroll-margin-top: 8px;
}

.proc-anchor.is-current td:first-child {
  box-shadow: inset 3px 0 0 var(--brand, #1f6b4a);
}

.proc-anchor-flash td {
  animation: procFlash 1.2s ease;
}

@keyframes procFlash {
  0% { background: #dff3e8; }
  100% { background: transparent; }
}

.meisai-cost-grid col.col-check { width: 44px; }
.meisai-cost-grid col.col-no { width: 48px; }
.meisai-cost-grid col.col-trade { width: 72px; }
.meisai-cost-grid col.col-code { width: 140px; }
.meisai-cost-grid col.col-name { width: auto; }

.meisai-cost-grid td.col-no,
.meisai-cost-grid th.col-no {
  width: 48px;
  min-width: 48px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}

.meisai-cost-grid td.col-code,
.meisai-cost-grid th.col-code {
  font-family: var(--mono);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.meisai-cost-grid td.col-trade,
.meisai-cost-grid th.col-trade {
  text-align: center;
  font-size: var(--fs-sm);
  line-height: 1.3;
  white-space: nowrap;
}

.col-trade .trade-code {
  font-family: var(--mono);
  font-weight: 600;
}

.field-group-label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #2a3138;
  line-height: 1.3;
}

.meisai-cost-grid th .field-group-label {
  font-size: 14px;
}

th.col-element,
th.col-vendor {
  background: #eceff3;
  color: #2a3138;
  text-align: center;
  min-width: 160px;
  font-size: 14px;
}

.code-name-pair {
  display: grid;
  grid-template-columns: 76px minmax(100px, 1fr);
  gap: 0;
  align-items: stretch;
  min-width: 170px;
  border: 1px dashed var(--line, #cfd6d1);
  border-radius: 2px;
  overflow: hidden;
  background: #fff;
}

.code-name-pair.no-code {
  grid-template-columns: 1fr;
}

.code-name-pair.no-code .cn-code {
  display: none;
}

/* 要素内訳: コードは数字のみ表示、選択肢は日本語名のみ */
.col-element-pair .element-select {
  font-family: inherit;
}

.code-name-pair .cn-code {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 5px 7px;
  font-family: var(--mono);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  border-right: 1px dashed var(--line, #cfd6d1);
  background: #fafbfa;
  color: var(--ink, #222);
  white-space: nowrap;
}

.code-name-pair .cn-select,
.code-name-pair select.vendor-select,
.code-name-pair select.element-select {
  width: 100%;
  min-width: 0;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 5px 7px;
  font-size: var(--fs);
  background: transparent;
}

.col-agg {
  font-weight: 700;
}

.row-phase td.col-agg,
.row-cat td.col-agg {
  background: inherit;
}

.row-phase .dual-current,
.row-cat .dual-current {
  font-weight: 700;
}

.col-sec-name {
  min-width: 220px;
}

.sec-name-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}

.sec-name-text {
  min-width: 0;
  flex: 1;
}

.sec-name-row .tree-actions {
  opacity: 1;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-top: 0;
  margin-left: 0;
}

.row-phase:hover .sec-name-row .tree-actions,
.row-cat:hover .sec-name-row .tree-actions,
.proc-anchor.is-current .sec-name-row .tree-actions,
tr[data-item-line]:hover .sec-name-row .tree-actions {
  opacity: 1;
}

.sec-name-row .tree-act:hover {
  background: rgba(255, 255, 255, 0.9);
}

.line-actions .tree-act {
  opacity: 0.75;
}

tr[data-item-line]:hover .line-actions .tree-act {
  opacity: 1;
}

.ft-l2 .tree-actions {
  flex-shrink: 0;
}



.meisai-cost-grid .col-check .cell-spacer {
  display: inline-block;
  width: 14px;
  height: 14px;
  vertical-align: middle;
}

.row-phase td,
.row-cat td,
.row-root-doc td,
.row-empty-items td {
  vertical-align: middle;
}

.row-phase td {
  background: #eef6f1 !important;
  font-weight: 700;
}

.row-root-doc td {
  background: #c9852d !important;
  color: #fff;
  font-weight: 700;
}

.row-root-doc .meisai-toolbar-hint {
  color: rgba(255, 255, 255, 0.85);
  margin-left: 8px;
}

.sec-label {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  margin-right: 8px;
  background: rgba(169, 68, 82, 0.15);
  color: #a94452;
}

.sec-label.child {
  background: rgba(138, 122, 58, 0.18);
  color: #6d5f20;
}

.row-empty-items td {
  color: var(--ink-soft);
  font-size: 12px;
}

.toc-workspace .detail-pane .table-wrap,
.toc-workspace .detail-pane .meisai-doc-wrap {
  overflow-x: auto;
  overflow-y: auto;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  max-height: min(560px, calc(100vh - 360px));
}

.detail-pane table.data {
  width: max-content;
  min-width: 100%;
}

/* フォルダ形式ツリー（参照UI風） */
.ft-row {
  display: grid;
  grid-template-columns: 1.25rem 2rem minmax(0, 1fr);
  gap: 2px 4px;
  align-items: stretch;
  min-height: 32px;
}

.ft-drag,
.ft-drag-spacer {
  width: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
}

.ft-drag {
  border: 0;
  padding: 0;
  background: rgba(0, 0, 0, 0.04);
  color: #4a5560;
  cursor: grab;
  opacity: 0.85;
  border-radius: 5px;
  width: 22px;
  height: 24px;
}

.ft-drag:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.1);
  color: var(--ink);
}

.ft-drag:active {
  cursor: grabbing;
}

.ft-row.is-dragging,
tr.is-dragging {
  opacity: 0.45;
}

.ft-row.drag-over > .ft-main,
tr.drag-over > td {
  outline: 2px dashed var(--brand, #1f6b4a);
  outline-offset: -2px;
}

.meisai-cost-grid col.col-drag,
.meisai-cost-grid th.col-drag,
.meisai-cost-grid td.col-drag {
  width: 28px;
  min-width: 28px;
  max-width: 32px;
  text-align: center;
  padding-left: 2px;
  padding-right: 2px;
}

.meisai-cost-grid th.col-drag {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.meisai-cost-grid .meisai-drag {
  margin: 0 auto;
}

.ft-no {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-soft);
  text-align: right;
  padding-top: 10px;
  line-height: 1;
}

.ft-main {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 4px 6px 4px 8px;
  border-radius: 4px;
  position: relative;
}

.ft-l0 .ft-main {
  background: #c9852d;
  color: #fff;
  font-weight: 700;
}

.ft-l0 .ft-icon {
  color: #fff8e8;
}

.ft-l1 .ft-main {
  background: #f0d5d8;
  color: var(--ink);
  font-weight: 700;
}

.ft-l1 .ft-icon.ft-folder {
  color: #a94452;
}

.ft-l2 .ft-main {
  background: #f7efc8;
  color: var(--ink);
  padding-left: 10px;
}

.ft-row.active .ft-main {
  outline: 2px solid rgba(31, 107, 74, 0.55);
  outline-offset: -1px;
  background: #fff;
}

.ft-l0.active .ft-main {
  background: #b87420;
  outline-color: rgba(255, 255, 255, 0.5);
}

.ft-name,
.ft-name-static {
  flex: 1;
  min-width: 0;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.35;
}

.ft-name-static {
  padding: 2px 0;
}

.ft-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
}

.ft-tree-pad {
  width: 10px;
  flex: 0 0 10px;
}

.ft-children {
  position: relative;
  margin: 0 0 2px 0;
}

.ft-group:not(.ft-group-last) {
  margin-bottom: 2px;
}

/* 子行のツリー線 */
.ft-l2 .ft-guide {
  position: relative;
  flex: 0 0 18px;
  width: 18px;
  align-self: stretch;
  margin: -4px 0;
}

.ft-l2 .ft-guide::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #b8c0bc;
}

.ft-l2 .ft-guide::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 50%;
  width: 10px;
  height: 1px;
  background: #b8c0bc;
}

.ft-l2 .ft-guide-last::before {
  bottom: 50%;
}

.ft-row.proc-disabled .ft-name {
  opacity: 0.45;
  text-decoration: line-through;
}

.ft-l2 .ft-main {
  padding-left: 4px;
}

.ft-l1 + .ft-children .ft-l2 .ft-main {
  margin-left: 12px;
}

.summary-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}

.summary-bar .cell {
  padding: 12px 14px;
  border-right: 1px solid var(--line);
}

.summary-bar .cell:last-child {
  border-right: 0;
}

.summary-bar .cell span {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.summary-bar .cell strong {
  display: block;
  margin-top: 4px;
  font-size: var(--fs-lg);
  font-variant-numeric: tabular-nums;
}

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  padding: 0 12px;
  background: #fff;
}

.tabs button {
  border: 0;
  background: transparent;
  padding: 13px 18px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  font-weight: 600;
  font-size: var(--fs);
}

.tabs button.active {
  color: var(--accent-deep);
  border-bottom-color: var(--accent);
}

.input-grid input {
  width: 104px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 8px;
  text-align: right;
  font-family: var(--mono);
  font-size: var(--fs-sm);
}

.input-grid input[type="checkbox"],
.col-check input[type="checkbox"] {
  width: auto;
  min-width: 0;
  padding: 0;
  border: 0;
  text-align: center;
  font-family: inherit;
  cursor: pointer;
  accent-color: var(--brand, #1f6b4a);
}

.col-check {
  width: 44px;
  text-align: center;
  vertical-align: middle;
}

.print-col-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 4px;
  line-height: 1;
}

th.col-check {
  white-space: normal;
  line-height: 1.2;
}

.row-cat td {
  background: #fff8e8 !important;
  font-weight: 700;
}

.variance-pos {
  color: var(--profit);
}

.variance-neg {
  color: var(--loss);
}

.hidden {
  display: none !important;
}

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

.chart-bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 140px 1fr 90px;
  gap: 10px;
  align-items: center;
  font-size: 12px;
}

.bar-track {
  height: 10px;
  background: #e8ece9;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #2d8a62, #1f6b4a);
  border-radius: 999px;
}

.bar-fill.actual {
  background: linear-gradient(90deg, #c9852d, #9a5b00);
}

.legend {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--ink);
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(8px);
  transition: 0.25s ease;
  pointer-events: none;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.stack {
  display: grid;
  gap: 16px;
}

.section-title {
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
  grid-column: 1 / -1;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.section-title:first-child {
  border-top: 0;
  padding-top: 0;
}

.tax-pair {
  display: grid;
  gap: 4px;
}

.tax-pair .ex {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tax-pair .in {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tax-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 11px;
  font-weight: 700;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 18px;
}

.info-item label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.info-item .val {
  font-size: 14px;
  font-weight: 600;
  word-break: break-all;
}

.info-item .val.muted {
  font-weight: 400;
  color: var(--ink-soft);
}

.money-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #f7faf8, #fff);
  padding: 14px;
  display: grid;
  gap: 8px;
}

.money-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 13px;
}

.money-row.total {
  border-top: 1px solid var(--line);
  padding-top: 8px;
  margin-top: 4px;
  font-weight: 700;
  font-size: 15px;
}

.money-row .amt {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 13px;
}

.attach-panel {
  border-top: 1px solid var(--line);
  padding: 8px 12px;
  background: #f8faf8;
}

.attach-panel-compact .attach-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.attach-panel h4 {
  margin: 0;
  font-size: var(--fs-sm);
  font-weight: 700;
}

.attach-list {
  display: grid;
  gap: 4px;
  margin-bottom: 0;
}

.attach-empty {
  margin: 0;
  padding: 2px 0 0;
  font-size: var(--fs-xs);
}

.attach-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: var(--fs-sm);
}

.attach-item .meta {
  color: var(--muted);
  margin-left: auto;
  white-space: nowrap;
  font-size: var(--fs-xs);
}

.attach-item-name {
  border: 0;
  background: transparent;
  color: var(--accent, #1d4ed8);
  font-weight: 700;
  font-size: inherit;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.attach-item-name:hover {
  text-decoration: underline;
}

.attach-item [data-del-file] {
  border: 0;
  background: transparent;
  color: var(--danger);
  font-size: var(--fs-sm);
  padding: 2px 4px;
}

.file-drop {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.file-drop input[type="file"] {
  font-size: var(--fs-xs);
  max-width: 180px;
}

.attach-comment {
  flex: 1 1 220px;
  min-width: 180px;
  min-height: 32px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: var(--fs-sm);
  background: #fff;
}

.attach-comment-count {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.attach-item-body {
  min-width: 0;
  flex: 1;
}

.attach-item-comment {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
  word-break: break-word;
}

.btn-sm {
  padding: 4px 10px !important;
  font-size: var(--fs-sm) !important;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.summary-bar.taxed {
  grid-template-columns: repeat(3, 1fr);
}

.summary-bar .cell small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.chart-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px 18px;
  min-height: 280px;
}

.chart-card h4 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
}

.chart-card canvas {
  max-height: 260px;
}

.chart-card.tall {
  min-height: 360px;
}

.chart-card.tall canvas {
  max-height: 320px;
}

.chart-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
}

.chart-grid.three {
  grid-template-columns: repeat(3, 1fr);
}

.project-chart-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.project-chart-block .block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(180deg, #fbfcfb, #f3f7f4);
  border-bottom: 1px solid var(--line);
}

.project-chart-block .block-head h3 {
  margin: 0;
  font-size: 14px;
}

.project-chart-block .block-body {
  padding: 14px;
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 12px;
}

/* 集計・損益レポート */
.rpt-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 12px;
}
.rpt-title {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-deep, #0f3d2d);
}
.rpt-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.rpt-kpis .kpi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.rpt-kpis .kpi .k { font-size: 11px; color: var(--muted); font-weight: 600; }
.rpt-kpis .kpi .v { font-size: 20px; font-weight: 700; margin-top: 6px; line-height: 1.2; }
.rpt-kpis .kpi .v .unit { font-size: 12px; margin-left: 4px; color: var(--muted); }
.rpt-kpis .kpi .s { font-size: 11px; color: var(--muted); margin-top: 6px; }
.rpt-kpis .kpi-good { border-color: #86efac; background: linear-gradient(180deg, #f0fdf4, #fff); }
.rpt-kpis .kpi-bad { border-color: #fca5a5; background: linear-gradient(180deg, #fef2f2, #fff); }
.rpt-alert-panel { margin-bottom: 14px; }
.rpt-alert-list {
  display: grid;
  gap: 8px;
}
.rpt-alert-item {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
}
.rpt-alert-item:hover { border-color: #c9852d; background: #fff8ed; }
.rpt-house { margin-bottom: 16px; }
.rpt-house-head { align-items: flex-start; }
.rpt-house-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.rpt-progress-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.rpt-progress-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: #f8faf9;
}
.rpt-progress-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 8px;
}
.rpt-bar {
  height: 10px;
  border-radius: 999px;
  background: #e5ebe7;
  overflow: hidden;
}
.rpt-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: #1f6b4a;
  transition: width .25s ease;
}
.rpt-bar-fill.tone-schedule { background: #2b6cb0; }
.rpt-bar-fill.tone-burn { background: #c9852d; }
.rpt-bar-fill.tone-danger { background: #b91c1c; }
.rpt-chart-grid {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 12px;
}
.row-alert td { background: #fff5f5; }
.badge.good { color: #166534; background: #dcfce7; border-color: #86efac; }
.badge.warn { color: #9a3412; background: #ffedd5; border-color: #fdba74; }
.badge.bad { color: #991b1b; background: #fee2e2; border-color: #fca5a5; }

@media (max-width: 960px) {
  .rpt-kpis,
  .rpt-house-kpis,
  .rpt-progress-grid,
  .rpt-chart-grid { grid-template-columns: 1fr; }
  .rpt-alert-item { grid-template-columns: 1fr 1fr; }
}

.common-info {
  padding: 18px;
}

.project-header-panel {
  overflow: visible;
}

.project-header-merged {
  padding: 12px 16px 10px;
}

.project-header-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.project-switch-field {
  flex: 1 1 280px;
  min-width: 220px;
  margin: 0;
}

.project-switch-field label {
  font-size: var(--fs-xs);
  margin-bottom: 4px;
}

.project-switch-field select,
.project-switch-field .project-switch-btn {
  width: 100%;
  max-width: 520px;
}

.project-switch {
  position: relative;
  z-index: 20;
  width: 100%;
  max-width: 520px;
}

.project-switch-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.project-switch-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.project-switch.is-open .project-switch-btn {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.project-switch-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-switch-caret {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  margin-top: -3px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
}

.project-switch.is-open .project-switch-caret {
  margin-top: 3px;
  transform: rotate(-135deg);
}

.project-switch-panel {
  position: absolute;
  z-index: 50;
  left: 0;
  width: 100%;
  top: calc(100% + 6px);
  display: none;
  flex-direction: column;
  box-sizing: border-box;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(26, 31, 28, 0.16);
}

.project-switch.is-open .project-switch-panel:not([hidden]) {
  display: flex;
}

.project-switch-panel[hidden] {
  display: none !important;
}

.project-switch-filter {
  flex-shrink: 0;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: #f6f8f6;
  box-sizing: border-box;
}

.project-switch-field .project-switch-filter input,
.project-switch-filter input {
  display: block;
  width: 100%;
  max-width: none;
  min-width: 0;
  min-height: 36px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-sizing: border-box;
  font: inherit;
  font-size: 13px;
  line-height: 1.3;
  outline: none;
  box-shadow: none;
}

.project-switch-filter input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
  outline: none;
}

.project-switch-list {
  margin: 0;
  padding: 4px 0;
  list-style: none;
  max-height: 260px;
  overflow-x: hidden;
  overflow-y: auto;
}

.project-switch-list li {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.35;
}

.project-switch-list li.is-empty {
  cursor: default;
  color: var(--muted);
}

.project-switch-list li.is-current {
  font-weight: 600;
  color: var(--accent-deep);
}

.project-switch-list li.is-hi,
.project-switch-list li:hover:not(.is-empty) {
  background: var(--accent-soft);
}

.project-header-badges {
  flex: 0 0 auto;
  padding-bottom: 2px;
}

.project-header-merged .common-info-header {
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
}

.project-header-merged .common-info-toggle {
  padding: 0;
  min-width: 0;
}

.project-header-merged .common-title,
.project-header-merged .common-kicker {
  display: none;
}

.project-header-merged .common-meta {
  font-size: var(--fs-sm);
  line-height: 1.45;
}

.project-header-merged .common-info-actions .btn {
  padding: 6px 10px;
  font-size: var(--fs-sm);
}

.project-header-merged.is-closed {
  padding-bottom: 10px;
}

.common-info-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.common-info-header .common-info-toggle {
  flex: 1;
  min-width: 0;
}

.common-info-actions {
  flex: 0 0 auto;
}

.common-info-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0;
  cursor: pointer;
  color: inherit;
}

.common-info-summary {
  min-width: 0;
}

.common-toggle-label {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-deep);
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--accent-soft);
  white-space: nowrap;
}

.common-info-toggle:hover .common-toggle-label {
  background: #d5e8dd;
}

.common-info-detail {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.common-info-form .section-title {
  margin: 14px 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: #3d4a55;
}

.common-info-form .section-title:first-child {
  margin-top: 0;
}

.common-info-form .info-item input,
.common-info-form .info-item select,
.common-info-form .info-item textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #c5ccd4;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}

.common-info-form .info-item input:disabled,
.common-info-form .info-item select:disabled {
  background: #f0f2f4;
  color: #6a7380;
}

.common-info-form .info-item textarea {
  resize: vertical;
  min-height: 72px;
}

.common-info-form .info-item.full {
  grid-column: 1 / -1;
}

.common-info-form .check-inline,
.form-grid .check-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-wrap: nowrap;
}

.common-info-form .info-item:has(.check-inline) {
  grid-column: 1 / -1;
}

.common-info-edit-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.common-info-hint {
  margin: 10px 0 0;
  font-size: 12px;
}

.common-info .area-summary {
  margin: 0 0 14px;
}

.common-info .remarks-view {
  margin-top: 10px;
}

.common-info.is-editing .common-info-toggle {
  opacity: 0.55;
  cursor: default;
}

.common-info-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.common-info.is-closed .common-info-detail {
  display: none;
}

.common-info.is-closed {
  padding-bottom: 4px;
}

.common-kicker {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

.common-title {
  margin: 4px 0 6px;
  font-size: 20px;
}

.common-meta {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.info-grid.compact {
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 14px;
  margin-bottom: 12px;
}

.inline-money {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px 18px;
}

.inline-money .money-row {
  margin: 0;
}

.inline-money .money-row.total {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.tree-toolbar {
  flex: 0 0 auto;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}

.tree-check-all {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-soft);
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tree-row.active {
  background: #fff;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--line);
}

.tree-row .tree-item {
  flex: 1;
  min-width: 0;
}

.tree-row .proc-check {
  margin-left: 4px;
  flex: 0 0 auto;
}

.tree-check-spacer {
  width: 16px;
  flex: 0 0 auto;
  margin-left: 4px;
}

.tree-hint {
  margin: 10px 0 0;
  font-size: var(--fs-sm);
  line-height: 1.45;
  color: var(--ink-soft);
}

.tree-row.proc-disabled .tree-item {
  opacity: 0.45;
  text-decoration: line-through;
}

.process-edit-panel {
  margin-bottom: 8px;
  padding: 8px 10px;
  background: linear-gradient(180deg, #f7faf8 0%, #fff 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.process-edit-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: var(--fs-sm);
}

.process-edit-grid {
  display: grid;
  grid-template-columns: 1.4fr auto 1fr;
  gap: 10px 14px;
  align-items: end;
}

.process-edit-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: var(--fs-sm);
  color: var(--ink-soft);
}

.process-edit-grid input[type="text"],
.process-edit-grid select.vendor-select,
#detailTable select.vendor-select {
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  min-width: 0;
  width: 100%;
}

.process-edit-check {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  padding-bottom: 6px;
  white-space: nowrap;
}

.muted.small {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--ink-soft);
}

@media (max-width: 900px) {
  .process-edit-grid {
    grid-template-columns: 1fr;
  }
}

/* 工程名変更ポップアップ */
.modal-card-wide {
  width: min(520px, 100%);
}

.modal-card.modal-card-cost-edit {
  width: min(960px, 96vw);
  max-width: 960px;
}

.cost-edit-table-wrap {
  overflow-x: auto;
}

.cost-edit-table {
  width: 100%;
  min-width: 720px;
  table-layout: fixed;
}

.cost-edit-table th:first-child,
.cost-edit-table td:first-child,
.cost-edit-table tbody th {
  width: 72px;
  white-space: nowrap;
}

.cost-edit-table thead th {
  font-size: var(--fs);
  font-weight: 700;
  white-space: nowrap;
  padding: 12px 10px;
}

.cost-edit-table tbody th,
.cost-edit-table tbody td {
  padding: 12px 10px;
  vertical-align: middle;
}

.cost-edit-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: var(--fs);
}

.cost-edit-profit,
.cost-edit-rate {
  font-family: var(--mono);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.vendor-check-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow: auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafbfa;
}

.vendor-check-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}

.vendor-check-item small {
  color: var(--ink-soft);
  font-size: 11px;
}

.vendor-check-item input {
  margin-top: 2px;
  accent-color: var(--brand, #1f6b4a);
}

/* どっと原価風 — 表示条件バー */
.meisai-condition-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 10px;
  background: #eef2f5;
  border: 1px solid #c5ced6;
  border-radius: 4px;
}

.meisai-cond-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.meisai-cond-row-filters,
.meisai-cond-row-search {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: stretch;
}

.meisai-cond-row-print {
  flex-wrap: wrap;
}

.meisai-cond-group {
  display: flex;
  align-items: stretch;
  width: 100%;
  min-width: 0;
  border: 1px solid #3d4a56;
  border-radius: 2px;
  overflow: hidden;
  background: #fff;
  min-height: 28px;
}

.meisai-cond-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 7.5em;
  width: 7.5em;
  padding: 0 6px;
  background: #3d4a56;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  box-sizing: border-box;
}

.meisai-cond-select {
  flex: 1 1 auto;
  border: 0;
  padding: 4px 8px;
  font: inherit;
  font-size: 12px;
  min-width: 0;
  width: 100%;
  background: #fff;
  color: var(--ink);
}

.meisai-cond-input {
  flex: 1 1 auto;
  border: 0;
  padding: 4px 8px;
  font: inherit;
  font-size: 12px;
  min-width: 0;
  width: 100%;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.meisai-cond-input::-webkit-search-cancel-button {
  cursor: pointer;
}

.meisai-cond-check {
  cursor: pointer;
}

.meisai-cond-check .meisai-cond-check-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  padding: 0 10px;
  background: #fff;
  min-width: 0;
}

.meisai-cond-check input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: #3d4a56;
  pointer-events: auto;
  cursor: pointer;
}

.meisai-cond-actions {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  .meisai-cond-row-filters,
  .meisai-cond-row-search {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.meisai-cond-actions .btn-sm {
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 11px;
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}
.meisai-cond-actions .btn.btn-sm:not(.secondary):not(.ghost) {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.meisai-view-initial .dual-current,
.meisai-view-change .dual-initial {
  display: none;
}

.meisai-view-initial .dual-initial,
.meisai-view-change .dual-current {
  margin-bottom: 0;
}

.meisai-hide-tax .col-tax-amt {
  display: none;
}

.meisai-cost-grid th.col-grp-budget-head,
.meisai-cost-grid th.col-grp-actual-head {
  text-align: center;
  font-size: 14px;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.meisai-cost-grid th.col-grp-budget-head,
.meisai-cost-grid th.col-grp-budget,
.meisai-cost-grid td.col-grp-budget {
  background: #f3faf6;
}

.meisai-cost-grid th.col-grp-actual-head,
.meisai-cost-grid th.col-grp-actual,
.meisai-cost-grid td.col-grp-actual {
  background: #f4f7fb;
}

.meisai-cost-grid th.col-grp-budget-head {
  background: #d8eee3;
  color: #1f5c40;
  box-shadow: inset 0 -2px 0 #8fbfa5;
}

.meisai-cost-grid th.col-grp-actual-head {
  background: #dce6f2;
  color: #2a3f5c;
  box-shadow: inset 0 -2px 0 #9ab0c4;
}

.meisai-cost-grid thead tr.meisai-head-sub th {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  min-width: 76px;
  color: #2c3530;
}

.meisai-cost-grid th.col-money-head {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
  background: #eceff3;
  color: #2a3138;
  min-width: 88px;
  box-shadow: inset 0 -2px 0 #b8c0c9;
}

.meisai-cost-grid th.col-element,
.meisai-cost-grid th.col-vendor {
  box-shadow: inset 0 -2px 0 #b8c0c9;
}

.meisai-cost-grid td.col-money-auto,
.meisai-cost-grid th.col-money-head {
  text-align: right;
  white-space: nowrap;
}

.meisai-cost-grid .col-money-auto {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-weight: 600;
}

.meisai-cost-grid td.col-money-auto.col-grp-budget {
  background: #eaf6ef;
}

.meisai-cost-grid td.col-money-auto.col-grp-actual {
  background: #ebf0f7;
}

.meisai-cost-grid tr.proc-anchor td.col-grp-budget,
.meisai-cost-grid tr.proc-anchor td.col-money-auto.col-grp-budget {
  background: rgba(47, 107, 79, 0.1);
}

.meisai-cost-grid tr.proc-anchor td.col-grp-actual,
.meisai-cost-grid tr.proc-anchor td.col-money-auto.col-grp-actual {
  background: rgba(61, 79, 102, 0.08);
}

.meisai-cost-grid .diff-pos {
  color: #067647;
}

.meisai-cost-grid .diff-neg {
  color: #b42318;
}

.meisai-cost-grid .diff-zero {
  color: inherit;
}

.meisai-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.btn-add-meisai-proc {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--brand, #1f6b4a);
  background: #fff;
  border: 1px solid #b7d6c6;
  border-radius: 7px;
  cursor: pointer;
}

.btn-add-meisai-proc:hover:not(:disabled) {
  background: #e6f4ec;
}

.btn-add-meisai-proc:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.meisai-toolbar-hint {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
}

.meisai-dual-hint {
  margin-left: auto;
  color: #9a6700;
  font-weight: 600;
}

.meisai-cost-grid .money-input {
  width: 100%;
  min-width: 88px;
  text-align: right;
}

.meisai-cost-grid select.meisai-tax-type,
.meisai-cost-grid select.meisai-actual-tax-rate,
.meisai-cost-grid select.vendor-select {
  font: inherit;
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  max-width: 110px;
}

.meisai-cost-grid select.meisai-actual-tax-rate {
  max-width: 72px;
  min-width: 64px;
}

.meisai-cost-grid input.meisai-actual-tax-date {
  font: inherit;
  font-size: 11px;
  padding: 3px 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  max-width: 132px;
  min-width: 118px;
}

.dual-cell {
  vertical-align: middle;
}

.dual-initial {
  font-size: 11px;
  color: var(--ink-soft);
  line-height: 1.2;
  margin-bottom: 2px;
}

.dual-current {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.meisai-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.meisai-actions .btn:disabled,
.meisai-actions .btn.secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 28, 24, 0.45);
  backdrop-filter: blur(2px);
}

.modal-overlay-sheet {
  align-items: stretch;
  justify-content: center;
  padding: 28px 24px;
  background: rgba(16, 22, 20, 0.55);
}

body.modal-open {
  overflow: hidden;
}

.modal-sheet {
  width: min(1100px, 96vw);
  max-height: calc(100vh - 56px);
  margin: auto;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  overflow: hidden;
}

.modal-sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.modal-sheet-head h3 {
  margin: 0 0 6px;
  font-size: var(--fs-xl);
  font-weight: 700;
}

.modal-sheet-head .modal-lead {
  margin: 0;
  max-width: 48em;
}

.modal-sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 18px 24px;
}

.modal-sheet-foot {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px 18px;
  border-top: 1px solid var(--line);
  background: #fafbfa;
}

.modal-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
  padding: 18px 20px 16px;
  border: 1px solid var(--line);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.modal-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}

.modal-close {
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}

.modal-close:hover {
  background: #f0f2f1;
  color: var(--ink);
}

.modal-lead {
  margin: 0 0 14px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 16px;
}

.modal-field input {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.modal-field input:focus {
  outline: 2px solid rgba(31, 107, 74, 0.35);
  border-color: var(--brand, #1f6b4a);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.tree-item-name {
  word-break: break-word;
}

.tree-meta {
  opacity: 0.75;
  font-weight: 500;
  white-space: nowrap;
}

.tree-rename-btn {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  opacity: 0.55;
}

.tree-rename-btn:hover,
.tree-row.active .tree-rename-btn {
  opacity: 1;
  background: #fff;
  color: var(--brand, #1f6b4a);
  box-shadow: inset 0 0 0 1px var(--line);
}

.tree-seq {
  flex: 0 0 1.6rem;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  text-align: right;
  line-height: 1;
}

.tree-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  margin-left: auto;
  position: relative;
}

.tree-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  opacity: 0.7;
}

.tree-menu-btn:hover,
.tree-menu.is-open .tree-menu-btn {
  opacity: 1;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
}

.tree-menu-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 40;
  min-width: 180px;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(20, 30, 40, 0.14);
}

.tree-menu-panel.is-ported {
  position: fixed;
  z-index: 4000;
}

.tree-menu-panel[hidden] {
  display: none !important;
}

.tree-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}

.tree-menu-item:hover {
  background: #f3f6f4;
}

.tree-menu-item.danger {
  color: #9b2c2c;
}

.tree-menu-item.danger:hover {
  background: #fdecee;
}

.tree-act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  opacity: 0.65;
}

.tree-menu-item.tree-act {
  width: 100%;
  height: auto;
  opacity: 1;
  justify-content: flex-start;
}

.tree-act:hover {
  opacity: 1;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
}

.tree-menu-item.tree-act:hover {
  box-shadow: none;
}

.tree-act-add:hover {
  color: var(--brand, #1f6b4a);
}

.tree-act-edit:hover {
  color: #2b6cb0;
}

.tree-act-copy:hover {
  color: #6b46c1;
}

.tree-act-del:hover {
  color: #9b2c2c;
}

.tree-act-restore {
  color: var(--brand, #1f6b4a);
  opacity: 1;
}

.tree-act-restore:hover {
  color: #145c3c;
  background: #e6f4ec;
}

.ft-row.proc-deleted .ft-main {
  opacity: 0.55;
  filter: grayscale(0.35);
}

.ft-row.proc-deleted .ft-name .tree-item-name {
  text-decoration: line-through;
}

.row-phase.proc-deleted td,
.row-cat.proc-deleted td,
.meisai-cost-grid tr.row-disabled td {
  opacity: 0.55;
  background: #f3f3f3 !important;
}

.row-phase.proc-deleted .sec-name-text,
.row-cat.proc-deleted .sec-name-text,
.meisai-cost-grid tr.row-disabled .name-editable {
  text-decoration: line-through;
}

.meisai-cost-grid tr.row-disabled input,
.meisai-cost-grid tr.row-disabled select {
  pointer-events: none;
  opacity: 0.7;
}

.del-badge {
  color: #9b2c2c !important;
  font-weight: 700;
  font-size: 10px;
}

.process-history-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px 10px;
}

.process-history-panel.hist-compact {
  padding: 6px 10px 8px;
}

.process-history-panel .process-history-list {
  max-height: none;
  overflow: visible;
}

.hist-action.hist-restore {
  background: #e6f4ec;
  color: #1f6b4a;
}

.tree-row.active .tree-act {
  opacity: 0.9;
}

.process-history-host {
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
  margin-top: 8px;
  margin-bottom: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  max-height: none;
  overflow: visible;
  background: transparent;
  scroll-margin-bottom: 16px;
  scroll-margin-top: 8px;
}

#attachHost {
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
  background: transparent;
  margin-top: 4px;
}

#costSummaryHost,
#processEditHost {
  flex: 0 0 auto;
}

/* 明細表は内容高さに合わせる（flex伸縮で添付・履歴に重ならないよう） */
#detailTable {
  flex: 0 0 auto;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  overflow: visible;
  position: relative;
  z-index: 1;
}

.meisai-scroll-host {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.meisai-hscroll {
  flex: 0 0 22px;
  height: 22px;
  min-height: 22px;
  position: relative;
  background: #c5d0d8;
  border: 1px solid var(--line, #d5ddd8);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  cursor: pointer;
  user-select: none;
  z-index: 4;
}

.meisai-hscroll-thumb {
  position: absolute;
  top: 4px;
  left: 0;
  height: 14px;
  min-width: 48px;
  background: #3d5564;
  border-radius: 7px;
  pointer-events: none;
  box-sizing: border-box;
}

.meisai-hscroll.is-dragging .meisai-hscroll-thumb {
  background: #2c3f4a;
}

.process-history-panel.is-active {
  box-shadow: 0 0 0 2px rgba(31, 107, 74, 0.25);
}

.history-flash .process-history-panel {
  animation: histFlash 1.1s ease;
}

@keyframes histFlash {
  0% { background: #e8f6ef; }
  100% { background: #fff; }
}

.meisai-cost-grid tr[data-item-line] {
  cursor: pointer;
}

.meisai-cost-grid tr.is-line-selected td {
  background: #eef6f1 !important;
  box-shadow: inset 3px 0 0 var(--brand, #1f6b4a);
}

.badge.mono {
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.process-history-head {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.hist-meta-line {
  margin: 0 0 4px;
  font-size: var(--fs-xs);
  line-height: 1.35;
}

.hist-create-box {
  padding: 6px 8px;
  border-radius: 6px;
  background: #f7faf8;
  border: 1px solid var(--line);
  margin-bottom: 6px;
}

.hist-create-compact {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
}

.hist-create-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
}

.hist-create-value {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin: 4px 0 6px;
}

.hist-create-compact time {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  color: var(--ink);
}

.hist-diff-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  font-size: 12px;
  margin: 4px 0 2px;
}

.hist-field {
  font-weight: 700;
  color: var(--ink-soft);
  min-width: 3.5em;
}

.hist-before {
  color: #9b2c2c;
  text-decoration: line-through;
  opacity: 0.85;
}

.hist-arrow {
  color: var(--muted);
}

.hist-after {
  color: #1f6b4a;
  font-weight: 600;
}

.hist-table-wrap {
  max-height: 180px;
  overflow: auto;
}

.hist-diff-table {
  width: 100%;
  min-width: 560px;
}

.hist-diff-table .hist-time {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  white-space: nowrap;
}

.hist-before-cell {
  color: #9b2c2c;
  background: #fde8e8;
}

.hist-after-cell {
  color: #1f6b4a;
  background: #e6f4ec;
  font-weight: 600;
}

.hist-diff-table .meta {
  font-size: 10px;
  color: var(--ink-soft);
}

.process-history-empty {
  font-size: var(--fs-xs);
  color: var(--ink-soft);
  margin: 0;
}

.process-history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.process-history-list li {
  padding: 8px;
  border-radius: 8px;
  background: #f7faf8;
  border: 1px solid var(--line);
}

.hist-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px;
}

.hist-top time {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.hist-action {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: #e8eee9;
  color: var(--ink);
}

.hist-action.hist-add {
  background: #e6f4ec;
  color: #1f6b4a;
}

.hist-action.hist-edit {
  background: #e8f0fa;
  color: #2b6cb0;
}

.hist-action.hist-delete {
  background: #fde8e8;
  color: #9b2c2c;
}

.hist-action.hist-vendor {
  background: #f7f0e6;
  color: #9a6700;
}

.hist-body {
  font-size: 12px;
  color: var(--ink);
  line-height: 1.35;
}

.hist-user {
  margin-top: 3px;
  font-size: 10px;
  color: var(--ink-soft);
}

.name-editable {
  cursor: pointer;
  border-bottom: 1px dashed transparent;
}

.name-editable:hover {
  border-bottom-color: var(--brand, #1f6b4a);
  color: var(--brand, #1f6b4a);
}

.tree-group {
  margin-bottom: 4px;
}

@media (max-width: 1100px) {
  .info-grid.compact,
  .inline-money {
    grid-template-columns: 1fr;
  }

  .common-info-top {
    flex-direction: column;
  }

  .common-info-header {
    flex-direction: column;
    align-items: stretch;
  }
}

.badge input[type="checkbox"] {
  margin-right: 4px;
  vertical-align: middle;
}

.filter-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

@media (max-width: 1100px) {
  .app.nav-mode-left {
    grid-template-columns: 1fr;
  }

  .chart-grid,
  .chart-grid.three,
  .project-chart-block .block-body {
    grid-template-columns: 1fr;
  }

  .badge input[type="checkbox"] {
    margin-right: 4px;
    vertical-align: middle;
  }

  .app.nav-mode-left .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
  }

  .app.nav-mode-left .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .app.nav-mode-left .role-box {
    margin-top: 0;
    min-width: 220px;
  }

  .nav-chrome-top {
    display: flex !important;
  }

  .grid-2,
  .grid-3,
  .workspace,
  .form-grid,
  .summary-bar {
    grid-template-columns: 1fr;
  }

  .summary-bar .cell {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

/* —— AI Assistant —— */
.ai-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 40;
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, #2d8a62, #1f6b4a);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 28px rgba(31, 107, 74, 0.35);
  cursor: pointer;
}

.ai-fab:hover {
  transform: translateY(-1px);
  background: linear-gradient(145deg, #1f6b4a, #144832);
}

#view-ai {
  min-width: 0;
  max-width: 100%;
}

.ai-layout {
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: calc(100vh - 160px);
  align-items: stretch;
}

.ai-side {
  display: grid;
  gap: 14px;
  align-content: start;
  min-width: 0;
  max-width: 100%;
}

.ai-side .panel,
.ai-side .panel-body,
.ai-side .stack,
.ai-side .field {
  min-width: 0;
  max-width: 100%;
}

.ai-side .field select {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-project-select {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.ai-side .ai-open-detail {
  display: block;
  width: 100%;
  max-width: 100%;
  text-align: center;
}

.ai-context-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  padding: 10px;
  border-radius: 10px;
  background: var(--accent-soft);
  min-width: 0;
  max-width: 100%;
}

.ai-context-card > div {
  min-width: 0;
}

.ai-context-card span {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.ai-context-card strong {
  display: block;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  word-break: break-all;
  line-height: 1.3;
}

.ai-feature-list {
  display: grid;
  gap: 8px;
}

.ai-feature {
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

.ai-feature:hover {
  border-color: #b7d6c6;
  background: #f7faf8;
}

.ai-feature strong {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}

.ai-feature span {
  font-size: 12px;
  color: var(--muted);
}

.ai-chat {
  display: flex;
  flex-direction: column;
  min-height: 620px;
  overflow: hidden;
}

.ai-messages {
  flex: 1;
  overflow: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background:
    radial-gradient(600px 240px at 100% 0%, rgba(228, 240, 234, 0.7), transparent 60%),
    #fbfcfb;
}

.ai-bubble {
  max-width: min(720px, 92%);
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 4px 14px rgba(26, 31, 28, 0.04);
}

.ai-bubble.user {
  align-self: flex-end;
  background: #17352a;
  border-color: #17352a;
  color: #e8f2ec;
}

.ai-bubble.assistant {
  align-self: flex-start;
}

.ai-bubble-meta {
  font-size: 11px;
  opacity: 0.7;
  margin-bottom: 4px;
}

.ai-bubble-text {
  font-size: 13.5px;
  line-height: 1.65;
  white-space: normal;
}

.ai-typing {
  color: var(--muted);
  font-style: italic;
}

.ai-suggest-wrap {
  border-top: 1px solid var(--line);
  background: #f7faf8;
  padding: 10px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-suggest-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.ai-suggest-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

.ai-suggest-group-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-deep);
  min-width: 2.5em;
}

.ai-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.ai-chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
}

.ai-chip:hover {
  background: var(--accent-soft);
  border-color: #b7d6c6;
  color: var(--accent-deep);
}

.ai-scope-note {
  font-size: 12px;
  margin: 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ai-composer {
  border-top: 1px solid var(--line);
  padding: 12px 16px 14px;
  background: #fff;
}

.ai-composer-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: end;
}

.ai-composer textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  resize: none;
  font: inherit;
  min-height: 44px;
}

.ai-attach {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f7faf8;
  cursor: pointer;
  font-size: 16px;
}

.ai-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .ai-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .ai-chat {
    min-height: 520px;
  }
}

/* —— BIM —— */
.bim-panel {
  padding: 16px 18px 20px;
}

.bim-hero {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.bim-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent-deep);
  margin-bottom: 4px;
}

.bim-hero h3 {
  margin: 0 0 8px;
  font-size: 20px;
}

.bim-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.bim-status {
  border-radius: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: #fff;
}

.bim-status .label {
  font-size: 11px;
  color: var(--muted);
}

.bim-status .value {
  font-size: 16px;
  font-weight: 800;
  margin: 4px 0;
}

.bim-status .hint {
  font-size: 11px;
  color: var(--muted);
}

.bim-status.bim-ok {
  background: #eef8f2;
  border-color: #b7dcc8;
}

.bim-status.bim-ok .value {
  color: var(--accent-deep);
}

.bim-status.bim-mid {
  background: #fff8eb;
  border-color: #f0d9a8;
}

.bim-status.bim-mid .value {
  color: #9a5b00;
}

.bim-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.bim-step {
  display: flex;
  gap: 10px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.bim-step span {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
}

.bim-step strong {
  display: block;
  font-size: 13px;
}

.bim-step small {
  color: var(--muted);
  font-size: 11px;
}

.bim-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.bim-file-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.bim-select-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
}

.bim-select-bar .muted {
  color: var(--muted);
}

.bim-table-wrap {
  max-height: 420px;
}

.bim-table input[type="number"] {
  width: 88px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}

.bim-table select {
  min-width: 140px;
  max-width: 200px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
}

.bim-table tr.bim-applied {
  background: #f3faf6;
}

.bim-badge-ok {
  background: #e4f0ea !important;
  color: var(--accent-deep) !important;
}

.bim-note {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

.bim-empty {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 28px 20px;
  background: #fff;
  text-align: center;
}

.bim-empty p {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 14px;
}

.bim-empty .muted {
  color: var(--muted);
  font-size: 12px;
}

.bim-foot-note {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
}

/* —— 工程マスター —— */
.master-intro {
  display: flex;
  gap: 20px;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
}

.master-hint {
  font-size: 13px;
  line-height: 1.65;
  padding: 10px 12px;
  background: var(--accent-soft, #e8f3ed);
  border-radius: 8px;
  margin-bottom: 12px;
}

.master-hint .muted {
  color: var(--muted);
  font-size: 12px;
}

.structure-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.structure-tab {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.structure-tab strong {
  font-size: 16px;
  color: var(--accent-deep);
}

.structure-tab span {
  font-size: 12px;
  color: var(--ink);
}

.structure-tab small {
  font-size: 11px;
  color: var(--muted);
}

.structure-tab.active {
  border-color: var(--accent);
  background: #f3faf6;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.structure-tab.disabled,
.structure-tab:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

tr.row-dim {
  opacity: 0.45;
  background: #f5f5f5;
}

.master-import-banner {
  margin: 0 0 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #eef6f1;
  border: 1px solid #cfe3d7;
  color: var(--ink);
  font-size: var(--fs-sm);
}

.master-import-errors {
  padding: 10px 12px;
  border-radius: 8px;
  background: #fdf2f2;
  border: 1px solid #f0c2c2;
  color: #9b2c2c;
  font-size: var(--fs-sm);
}

.master-import-errors ul {
  margin: 6px 0 0;
  padding-left: 1.2em;
}

.mono {
  font-family: var(--mono);
}

@media (max-width: 900px) {
  .structure-tabs {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 900px) {
  .bim-hero {
    grid-template-columns: 1fr;
  }

  .bim-steps {
    grid-template-columns: 1fr 1fr;
  }
}

/* ===== 予算書タブ（予算集計：費目×要素） ===== */
.yosan-doc {
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 15px;
  padding-top: 8px;
}

.yosan-meta-sheet {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 8px 28px;
  border: 1px solid #c5ccd4;
  background: #fff;
  padding: 14px 18px;
}

.yosan-meta-row {
  display: grid;
  grid-template-columns: 7.5em 1fr;
  gap: 8px;
  align-items: baseline;
  padding: 3px 0;
  font-size: 14px;
}

.yosan-meta-row .lbl {
  color: #5a6570;
  font-weight: 600;
}

.yosan-meta-row .val {
  color: #1a1f24;
  font-weight: 500;
}

.yosan-shukei-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.yosan-shukei-title {
  font-size: 17px;
  font-weight: 700;
  color: #1a1f24;
}

.yosan-mode-select {
  min-width: 160px;
  padding: 6px 10px;
  border: 1px solid #b8c0c8;
  border-radius: 4px;
  background: #fff;
  font-size: 14px;
  color: #1a1f24;
}

.yosan-tax-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.yosan-tax-select select {
  min-width: 88px;
  padding: 6px 10px;
  border: 1px solid #b8c0c8;
  border-radius: 4px;
  background: #fff;
  font-size: 14px;
  color: #1a1f24;
}

.yosan-tax-hint {
  font-size: 12px;
  font-weight: 500;
}

.yosan-combined-wrap {
  border: 1px solid #9aa3ad;
  background: #fff;
  overflow-x: auto;
}

.yosan-combined-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 14px;
}

.yosan-combined-table thead th {
  background: #2c3e50;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  padding: 9px 10px;
  border: 1px solid #1f2d3a;
  text-align: center;
  white-space: nowrap;
}

.yosan-combined-table thead th:nth-child(1),
.yosan-combined-table thead th:nth-child(5) {
  text-align: left;
  width: 12%;
}

.yosan-combined-table thead th:nth-child(2),
.yosan-combined-table thead th:nth-child(6) {
  width: 14%;
}

.yosan-combined-table thead th:nth-child(3),
.yosan-combined-table thead th:nth-child(4),
.yosan-combined-table thead th:nth-child(7),
.yosan-combined-table thead th:nth-child(8) {
  width: 9%;
}

.yosan-combined-table tbody td {
  padding: 8px 10px;
  border: 1px solid #c5ccd4;
  color: #1a1f24;
  background: #fff;
  vertical-align: middle;
}

.yosan-combined-table tbody td.yosan-label {
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

.yosan-combined-table tbody td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono, ui-monospace, monospace);
}

/* 費目ブロックと要素ブロックの区切り */
.yosan-combined-table thead th:nth-child(5),
.yosan-combined-table tbody td:nth-child(5) {
  border-left: 2px solid #6b7785;
}

.yosan-combined-table tbody td.yosan-row-hl {
  background: #d6eaf8 !important;
  font-weight: 700;
}

.yosan-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.yosan-chart-card {
  min-height: 300px;
}

.yosan-chart-card h4 {
  font-size: 16px;
}

.yosan-chart-card canvas {
  max-height: 260px;
}

@media (max-width: 980px) {
  .yosan-meta-sheet,
  .yosan-charts-grid {
    grid-template-columns: 1fr;
  }

  .yosan-combined-table {
    table-layout: auto;
  }
}

/* —— PDFプレビュー（A3 横/縦） —— */
.pdf-preview-overlay {
  z-index: 1400;
  padding: 16px;
}

.pdf-preview-sheet {
  width: min(1280px, 98vw);
  max-height: calc(100vh - 32px);
  height: calc(100vh - 32px);
}

.pdf-preview-head {
  padding-bottom: 10px;
}

.pdf-preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--line);
  background: #f6f7f6;
  flex: 0 0 auto;
}

.pdf-orient-group {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.pdf-orient-btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 9px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-right: 1px solid var(--line);
}

.pdf-orient-btn:last-child {
  border-right: 0;
}

.pdf-orient-btn:hover {
  background: #eef2ef;
  color: var(--ink);
}

.pdf-orient-btn.is-active {
  background: #2c3e50;
  color: #fff;
}

.pdf-preview-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pdf-preview-hint {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.pdf-preview-body {
  padding: 12px 16px !important;
  display: flex;
  flex-direction: column;
  background: #cfd4d8;
}

.pdf-preview-stage {
  flex: 1 1 auto;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  position: relative;
}

.pdf-preview-scale-wrap {
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.28);
  background: #fff;
  flex: 0 0 auto;
  overflow: hidden;
}

.pdf-preview-scale-wrap iframe {
  display: block;
  border: 0;
  background: #fff;
}

.pdf-preview-foot-note {
  margin: 0;
  margin-right: auto;
  max-width: 52em;
  line-height: 1.5;
}

.pdf-preview-sheet .modal-sheet-foot {
  align-items: center;
}

@media (max-width: 720px) {
  .pdf-preview-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .pdf-orient-group {
    width: 100%;
  }

  .pdf-orient-btn {
    flex: 1;
    text-align: center;
  }

  .pdf-preview-actions {
    justify-content: space-between;
  }
}

/* 物件一覧: 検索・ページング */
.project-list-filters {
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--line);
  background: #f8faf8;
}

.project-list-filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: flex-end;
}

.project-filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 120px;
  font-size: 12px;
  color: var(--muted);
}

.project-filter-field span {
  font-weight: 600;
  color: #3d4a56;
}

.project-filter-field input,
.project-filter-field select {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  background: #fff;
  color: var(--text);
}

.project-filter-grow {
  flex: 1 1 220px;
  min-width: 200px;
}

.project-filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-bottom: 1px;
}

.project-list-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

.project-page-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.project-page-size select {
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  background: #fff;
}

.project-list-sub {
  font-size: 11px;
  margin-top: 2px;
}

.project-list-addr {
  font-size: 12px;
  max-width: 12em;
  line-height: 1.35;
}

.project-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--line);
  background: #fbfcfb;
}

.project-pager .project-page-num {
  min-width: 36px;
  padding-left: 8px;
  padding-right: 8px;
}

.project-pager-info {
  margin-left: 4px;
  font-size: 12px;
}

@media (max-width: 720px) {
  .project-list-meta {
    flex-direction: column;
    align-items: flex-start;
  }
}
