/* 契約内容管理 Webアプリ スタイル */

:root {
  --bg: #f1f5f9;
  --header-bg: #2c3e50;
  --header-fg: #ecf0f1;
  --sidebar-bg: #1f2a37;
  --sidebar-fg: #e5e9f0;
  --link: #3498db;
  --accent: #3b82f6;
  --border: #d5dbe1;
  --row-unpaid: #fff8c5;
  --row-requested: #ffd9d9;
  --row-paid: #d5f5dd;
  --danger: #c0392b;
  --success: #27ae60;
  --panel-bg: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  height: 100%;
  font-family: "Meiryo", "Yu Gothic UI", sans-serif;
  background: var(--bg);
  color: #333;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* アプリシェル（サイドバー＋メイン） */
.app-shell { display: flex; height: 100%; overflow: hidden; }

.sidebar {
  flex-shrink: 0;
  width: 220px;
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  transition: width 0.18s ease;
  overflow: hidden;
}
.app-shell.sidebar-collapsed .sidebar { width: 58px; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.brand-icon { font-size: 1.3rem; flex-shrink: 0; }
.brand-text { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.sidebar-toggle {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--sidebar-fg);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.14); }

.sidebar-nav { flex: 1; padding: 0.5rem 0; overflow-y: auto; overflow-x: hidden; }
.sidebar-footer { padding: 0.5rem 0; border-top: 1px solid rgba(255,255,255,0.1); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  color: var(--sidebar-fg);
  white-space: nowrap;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.08); text-decoration: none; }
.nav-item.active { background: rgba(255,255,255,0.16); border-left-color: var(--accent); }
.nav-icon { font-size: 1.15rem; flex-shrink: 0; width: 1.5rem; text-align: center; }
.nav-label { overflow: hidden; text-overflow: ellipsis; }
.nav-user { cursor: default; opacity: 0.85; font-size: 0.9rem; }
.nav-user:hover { background: transparent; }

/* 折りたたみ時：アイコンのみ */
.app-shell.sidebar-collapsed .nav-label,
.app-shell.sidebar-collapsed .brand-text { display: none; }
.app-shell.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0.9rem 0; }
.app-shell.sidebar-collapsed .sidebar-toggle { margin-left: 0; }
.app-shell.sidebar-collapsed .nav-item { justify-content: center; padding: 0.6rem 0; gap: 0; }

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1rem 1.5rem;
}
.main .main-content {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.main .main-content:has(.list-page),
.main .main-content:has(.stats-page),
body.page-list .main .main-content,
body.page-stats .main .main-content {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.list-page,
.stats-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.list-page .toolbar,
.list-page .actions,
.list-page .status { flex-shrink: 0; }
.list-page .table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.stats-page .stats-toolbar { flex-shrink: 0; }
.stats-page .stats-charts {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.flash { list-style: none; padding: 0; margin: 0 0 1rem; }
.flash-error { color: var(--danger); }
.flash-success { color: var(--success); }

/* ログイン */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { background: #fff; padding: 2rem; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); width: 100%; max-width: 360px; }
.login-box h1 { margin: 0 0 0.5rem; text-align: center; }
.login-desc { margin: 0 0 1rem; color: #666; font-size: 0.9rem; text-align: center; }
.login-form .form-row { margin-bottom: 1rem; }
.login-form label { display: block; margin-bottom: 0.25rem; font-weight: 500; }
.login-form input[type="text"], .login-form input[type="password"] {
  width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 4px; font-size: 1rem;
}
.login-form button { width: 100%; padding: 0.6rem; background: var(--header-bg); color: var(--header-fg); border: none; border-radius: 4px; font-size: 1rem; cursor: pointer; }
.login-form button:hover { opacity: 0.9; }

/* ツールバー・検索 */
.toolbar { margin-bottom: 1rem; padding: 0.75rem; background: #fff; border: 1px solid var(--border); border-radius: 4px; }
.search-form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.search-form input[type="text"] { padding: 0.35rem 0.5rem; width: 220px; }
.search-form .btn-clear-filters { margin-left: 0.5rem; font-size: 0.9rem; padding: 0.25rem 0.5rem; border: 1px solid var(--border); border-radius: 2px; background: #fff; color: #333; }
.search-form .btn-clear-filters:hover { background: #f5f5f5; }
.checkbox-inline { display: inline-flex; align-items: center; gap: 0.25rem; margin-right: 0.5rem; font-weight: normal; }

/* 操作ボタン */
.actions { margin-bottom: 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.btn { display: inline-block; padding: 0.4rem 0.75rem; background: #ecf0f1; border: 1px solid var(--border); border-radius: 4px; color: #333; font-size: 0.9rem; cursor: pointer; }
.btn:hover { background: #dfe6e9; }
.btn-primary { background: var(--header-bg); color: var(--header-fg); border-color: var(--header-bg); }
.btn-primary:hover { opacity: 0.9; color: var(--header-fg); }
.btn-danger { background: #e74c3c; color: #fff; border-color: #c0392b; }
.btn-danger:hover { background: #c0392b; color: #fff; }
.inline-form { display: inline; }
.inline-form button { margin-right: 0.25rem; }

/* テーブル */
.table-wrap { background: #fff; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 0.5rem; box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.85rem; min-width: 800px; }
.data-table th, .data-table td { padding: 0.45rem 0.65rem; border-right: 1px solid #eef1f4; border-bottom: 1px solid #eef1f4; text-align: left; white-space: nowrap; }
.data-table thead th { background: #f2f5f8; color: #334155; font-weight: 600; position: sticky; z-index: 2; }
.data-table thead tr:first-child th { top: 0; box-shadow: inset 0 -2px 0 #cbd5e1; }
.data-table thead tr.filter-row th { top: 2.45rem; padding: 0.25rem 0.4rem; background: #f4f7fa; font-weight: normal; vertical-align: middle; box-shadow: 0 2px 5px rgba(15,23,42,0.06); }
/* ヘッダーセル内: 列名 + フィルタボタン */
.data-table thead th .th-inner { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; }
.data-table thead th .th-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }

/* 横スクロール時、左側（No.〜契約人数）を固定 */
.data-table th.sticky-col,
.data-table td.sticky-col {
  position: sticky;
  z-index: 1;
  background: #fff;
}
.data-table thead th.sticky-col { z-index: 3; background: #eef2f7; }
.data-table thead tr.filter-row th.sticky-col { z-index: 3; background: #f4f7fa; }
.data-table tbody tr.row-unpaid td.sticky-col { background: var(--row-unpaid); }
.data-table tbody tr.row-requested td.sticky-col { background: var(--row-requested); }
.data-table tbody tr.row-paid td.sticky-col { background: var(--row-paid); }
/* 最右の固定列だけ立体的な影で境界を表現 */
.data-table th.sticky-last, .data-table td.sticky-last { box-shadow: 6px 0 8px -6px rgba(15,23,42,0.28); }
.data-table thead th.sticky-last { box-shadow: 6px 0 8px -6px rgba(15,23,42,0.28), inset 0 -1px 0 var(--border); }
.data-table th.sticky-col-check, .data-table td.sticky-col-check { left: 0; width: 2.2rem; min-width: 2.2rem; }
.data-table th.col-check, .data-table td.col-check { text-align: center; padding: 0.35rem 0.2rem; }
.data-table th.sticky-col-0, .data-table td.sticky-col-0 { left: 2.2rem; min-width: 2.5rem; }
.data-table th.sticky-col-1, .data-table td.sticky-col-1 { left: 4.7rem; min-width: 4.5rem; }
.data-table th.sticky-col-2, .data-table td.sticky-col-2 { left: 9.2rem; min-width: 5rem; }
.data-table th.sticky-col-3, .data-table td.sticky-col-3 { left: 14.2rem; min-width: 3.5rem; }
.data-table th.sticky-col-4, .data-table td.sticky-col-4 { left: 17.7rem; min-width: 4rem; }
.data-table th.sticky-col-5, .data-table td.sticky-col-5 { left: 21.7rem; min-width: 4rem; }
.data-table .filter-cell { white-space: nowrap; vertical-align: middle; }
/* 取引先テーブルの左固定列（チェック・ID・会社名） */
.counterparties-table th.sticky-col-0, .counterparties-table td.sticky-col-0 { left: 2.2rem; min-width: 3rem; }
.counterparties-table th.sticky-col-1, .counterparties-table td.sticky-col-1 { left: 5.2rem; min-width: 14rem; }
.header-filter-wrap { position: relative; display: flex; align-items: center; }
.header-filter-btn {
  padding: 0.1rem 0.35rem;
  font-size: 0.65rem;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
}
.header-filter-btn:hover { background: #e2e8f0; color: #475569; }
.header-filter-btn.active { background: var(--accent); color: #fff; }
/* フィルタ適用中の列を強調 */
.filter-cell.has-filter { background: #e0edff !important; }
.filter-cell.has-filter .header-filter-btn { background: var(--accent); color: #fff; }
.header-filter-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  left: auto;
  margin-top: 4px;
  min-width: 190px;
  max-width: 280px;
  max-height: 300px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15,23,42,0.18);
  z-index: 100;
  overflow: hidden;
  flex-direction: column;
}
.header-filter-dropdown.is-open { display: flex; }
.header-filter-options {
  overflow-y: auto;
  max-height: 230px;
  padding: 0.35rem 0;
}
.header-filter-option {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
  font-weight: normal;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-filter-option:hover { background: #eff5ff; }
.header-filter-option input { margin: 0; vertical-align: middle; accent-color: var(--accent); }
.header-filter-actions {
  padding: 0.5rem 0.6rem;
  border-top: 1px solid #eef1f4;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  background: #f8fafc;
}
.header-filter-actions button {
  padding: 0.3rem 0.55rem;
  font-size: 0.78rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
}
.header-filter-actions button:hover { background: #eef2f7; }
.header-filter-actions .header-filter-apply {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  margin-left: auto;
}
.header-filter-actions .header-filter-apply:hover { background: #2563eb; color: #fff; }
.data-table tbody tr.row-unpaid { background: var(--row-unpaid); }
.data-table tbody tr.row-requested { background: var(--row-requested); }
.data-table tbody tr.row-paid { background: var(--row-paid); }
.data-table tbody tr.row-clickable { cursor: pointer; }
.data-table tbody tr:hover { filter: brightness(0.96); }
.data-table tbody tr.selected td { background: #dbeafe; }
.data-table tbody tr.selected td.sticky-col { background: #dbeafe; }
.data-table tbody tr.selected { outline: 2px solid var(--accent); outline-offset: -2px; }
.data-table tbody tr.selected:hover { filter: none; }
.status .selected-count { margin-left: 0.5rem; color: var(--link); font-weight: 500; }

.status { font-size: 0.9rem; color: #666; }

/* 編集フォーム（横並びで1ページに収める） */
.edit-form-wrap {
  width: 100%;
  max-width: none;
  background: #fff;
  padding: 1rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.edit-form-wrap h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}
.edit-form-wrap form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.edit-panel {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fafafa;
}
.edit-panel[open] { background: #fff; }
.edit-panel-summary {
  padding: 0.5rem 0.75rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.edit-panel-summary::-webkit-details-marker { display: none; }
.edit-panel-summary::before {
  content: "▼ ";
  font-size: 0.7rem;
  vertical-align: middle;
  margin-right: 0.25rem;
}
.edit-panel:not([open]) .edit-panel-summary::before { content: "▶ "; }
.edit-panel-body {
  padding: 0.5rem 0.75rem 0.75rem;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem 1rem;
  align-content: start;
}
.edit-form-wrap .form-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  min-width: 0;
}
.edit-panel-body .form-row-wide { grid-column: 1 / -1; }
.edit-panel-body .form-row-span2 { grid-column: span 2; }
.edit-form-wrap .form-row label {
  flex-shrink: 0;
  min-width: 0;
  max-width: 10em;
  font-weight: 500;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.edit-form-wrap .form-row input[type="text"],
.edit-form-wrap .form-row input[type="number"],
.edit-form-wrap .form-row select {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  padding: 0.3rem 0.45rem;
  font-size: 0.85rem;
}
/* 短い数値フィールド（人月: 最大3文字, 契約人数: 最大3文字）はデータ長に合わせて縮める */
.edit-form-wrap .form-row input.input-manmonth,
.edit-form-wrap .form-row input.input-count {
  flex: 0 0 auto;
  width: 5em;
  max-width: 5em;
}
.edit-form-wrap .form-row input[readonly] { background: #eee; color: #555; }
.edit-form-wrap .form-row .radio-group {
  flex: 1;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  font-weight: normal;
}
.edit-form-wrap .form-row .radio-group label { max-width: none; font-weight: normal; }
.edit-form-wrap .form-row .checkbox-inline {
  flex: 1;
  margin: 0;
  font-weight: normal;
  font-size: 0.85rem;
}
.edit-form-wrap .form-actions {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.5rem;
}
@media (max-width: 1200px) {
  .edit-panel-body { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .edit-panel-body { grid-template-columns: repeat(2, 1fr); }
}
.form-actions button { padding: 0.5rem 1rem; background: var(--header-bg); color: var(--header-fg); border: none; border-radius: 4px; cursor: pointer; font-size: 0.9rem; }
.form-actions button:hover { opacity: 0.9; }

/* インポート */
.import-csv { max-width: 480px; background: #fff; padding: 1.5rem; border: 1px solid var(--border); border-radius: 4px; }
.import-csv h2 { margin: 0 0 0.5rem; }
.import-csv p { margin: 0 0 1rem; color: #666; font-size: 0.9rem; }
.import-csv .form-row { margin-bottom: 1rem; }
.import-csv .form-actions { margin-top: 1rem; }

/* 詳細モーダル */
body.modal-open { overflow: hidden; }
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3vh 1rem;
  z-index: 1000;
  overflow-y: auto;
}
.modal-overlay[hidden] { display: none; }
.modal-dialog {
  position: relative;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 960px;
  margin: auto;
  animation: modal-pop 0.14s ease-out;
}
@keyframes modal-pop {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-close {
  position: absolute;
  top: 0.4rem;
  right: 0.6rem;
  background: transparent;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  z-index: 1;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}
.modal-close:hover { background: #eef2f7; color: #334155; }
.modal-body .edit-form-wrap { border: none; box-shadow: none; margin: 0; }

/* 確認ダイアログ（契約書の再作成など） */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 1rem;
}
.confirm-overlay[hidden] { display: none; }
.confirm-box {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  padding: 1.25rem 1.5rem;
  max-width: 460px;
  width: 100%;
  animation: modal-pop 0.14s ease-out;
}
.confirm-box h3 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.confirm-box p { margin: 0 0 1rem; color: #444; font-size: 0.92rem; line-height: 1.5; }
.confirm-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }

/* ホーム（TODO） */
.home-page { display: flex; flex-direction: column; height: 100%; }
.home-header { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 0.75rem; flex-shrink: 0; }
.home-header h2 { margin: 0; font-size: 1.3rem; }
.home-today { color: #666; font-size: 0.9rem; }
.todo-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  flex: 1;
  min-height: 0;
  overflow: auto;
  align-content: start;
}
.todo-card { background: var(--panel-bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.todo-card-head { display: flex; align-items: center; gap: 0.5rem; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); background: #f8fafc; }
.todo-icon { font-size: 1.2rem; }
.todo-title { font-weight: 600; font-size: 0.95rem; flex: 1; }
.todo-count { background: var(--accent); color: #fff; border-radius: 10px; padding: 0.05rem 0.55rem; font-size: 0.8rem; font-weight: 600; }
.todo-card-body { padding: 0.25rem 0; overflow-y: auto; max-height: 60vh; }
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-item { border-bottom: 1px solid #eef1f4; }
.todo-item:last-child { border-bottom: none; }
.todo-link { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.5rem 0.9rem; color: #333; }
.todo-link:hover { background: #f5f8fc; text-decoration: none; }
.todo-company { font-weight: 600; font-size: 0.9rem; }
.todo-dir { font-size: 0.7rem; padding: 0.05rem 0.4rem; border-radius: 6px; margin-right: 0.35rem; font-weight: 700; }
.todo-dir.in { background: #d1fae5; color: #065f46; }
.todo-dir.out { background: #fee2e2; color: #991b1b; }
.todo-meta { display: flex; gap: 0.75rem; font-size: 0.8rem; color: #666; }
.todo-amount { color: #333; }
.todo-date { font-size: 0.8rem; color: #555; display: flex; gap: 0.5rem; align-items: center; }
.todo-days { font-size: 0.72rem; padding: 0.05rem 0.4rem; border-radius: 8px; background: #e5e7eb; color: #555; }
.todo-days.soon { background: #fef3c7; color: #92400e; }
.todo-days.over { background: #fee2e2; color: #991b1b; }
.todo-item.overdue .todo-company { color: #b91c1c; }
.todo-empty { padding: 1rem 0.9rem; color: #999; font-size: 0.85rem; }

/* 検索パネル */
.search-panel { background: var(--panel-bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); margin-bottom: 0.75rem; overflow: hidden; }
.search-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 0.9rem; background: #f8fafc; border-bottom: 1px solid var(--border); }
.search-panel.collapsed .search-panel-head { border-bottom: none; }
.search-panel-title { font-weight: 600; font-size: 0.95rem; }
.search-panel-tools { display: flex; gap: 0.3rem; }
.panel-btn { background: transparent; border: 1px solid transparent; border-radius: 4px; cursor: pointer; font-size: 0.95rem; padding: 0.15rem 0.45rem; line-height: 1; }
.panel-btn:hover { background: #eef2f7; }
.panel-btn.active { background: #dbeafe; border-color: #93c5fd; }
.panel-btn:disabled { opacity: 0.4; cursor: default; }
.search-panel-body { padding: 0.75rem 0.9rem; }
.search-panel.collapsed .search-panel-body { display: none; }
.search-grid { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; align-items: flex-end; margin: 0; }
.search-field { display: flex; flex-direction: column; gap: 0.2rem; }
.search-field label { font-size: 0.75rem; color: #555; font-weight: 500; }
.search-field input[type="text"], .search-field select {
  padding: 0.35rem 0.5rem; border: 1px solid var(--border); border-radius: 4px; font-size: 0.85rem; min-width: 150px;
}
.search-actions { display: flex; gap: 0.5rem; align-items: flex-end; }

/* バッジ */
.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 10px; font-size: 0.75rem; background: #e5e7eb; color: #555; }
.badge-done { background: #d1fae5; color: #065f46; }

/* 詳細ナビ（前/次レコード） */
.record-nav { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.record-nav .nav-btn {
  display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.4rem 0.8rem;
  background: var(--panel-bg); border: 1px solid var(--border); border-radius: 6px; color: #333; font-size: 0.9rem; cursor: pointer;
}
.record-nav .nav-btn:hover { background: #eef2f7; text-decoration: none; }
.record-nav .nav-btn.disabled { opacity: 0.4; pointer-events: none; }
.record-nav .record-position { font-size: 0.85rem; color: #666; margin-left: auto; }
.record-nav .back-list { margin-right: auto; }

/* 統計 */
.stats-toolbar { margin-bottom: 1rem; }
.stats-toolbar a { margin-right: 1rem; }
.stats-toolbar a.active { font-weight: bold; }
.stats-charts { background: #fff; padding: 1rem; border: 1px solid var(--border); border-radius: 4px; }
.chart-container { margin-bottom: 2rem; width: 100%; height: 320px; }
.chart-container canvas { display: block; }
.chart-container h3 { margin: 0 0 0.5rem; font-size: 1rem; }

/* 共通ユーティリティ */
.btn-xs { padding: 0.2rem 0.5rem; font-size: 0.8rem; }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* 契約シミュレート */
.simulate-edit .simulate-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.75rem; }
.simulate-edit .simulate-head h2 { margin: 0; }
.sim-name-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.sim-name-row label { font-weight: 500; }
.sim-name-row input { flex: 1; max-width: 28rem; padding: 0.35rem 0.5rem; font-size: 0.9rem; }
.sim-toolbar { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.5rem; }
.sim-toolbar .sim-hint { color: #64748b; font-size: 0.8rem; }
.simulate-edit .table-wrap { overflow-x: auto; }
.sim-table { min-width: 1320px; }
.sim-table th, .sim-table td { padding: 0.25rem 0.4rem; }
.sim-table th.sim-th-calc { background: #eef2f7; }
.sim-table th.sim-th-del { width: 2rem; }
.sim-table .sim-cell-input { padding: 0.15rem 0.25rem; }
.sim-table .sim-input { width: 100%; box-sizing: border-box; padding: 0.25rem 0.35rem; font-size: 0.82rem; border: 1px solid var(--border); border-radius: 3px; }
.sim-table .sim-input-text { min-width: 6rem; }
.sim-table .sim-input-pct { width: 4.5rem; text-align: right; }
.sim-table .sim-input-yen { width: 6.5rem; text-align: right; }
.sim-table .sim-input-select { min-width: 6.5rem; }
.sim-table .sim-input-cp { min-width: 8rem; }
.sim-table select.sim-input:disabled,
.sim-table input.sim-input:disabled { background: #f1f5f9; color: #94a3b8; cursor: not-allowed; }
/* 大川さん割合セル：モード（％/固定）＋％値 */
.sim-table td.sim-okawa-rate-cell { white-space: nowrap; }
.sim-table .sim-okawa-mode { width: 4rem; margin-right: 0.25rem; }
.sim-table .sim-okawa-pct { width: 3.8rem; text-align: right; }
/* 大川さん：％指定時（自動計算・readonly）は計算列と同じ見た目 */
.sim-table input.sim-input-readonly { background: #f7f9fb; color: #334155; }
/* 案件・参画者別サマリ */
.sim-summary { margin-top: 1.25rem; }
.sim-summary h3 { margin: 0 0 0.4rem; font-size: 1rem; }
.sim-summary-table { min-width: 0; max-width: 640px; }
.sim-summary2-table { max-width: 760px; }
.sim-summary-table th, .sim-summary-table td { padding: 0.3rem 0.6rem; }
.sim-summary-empty { color: #94a3b8; }
.sim-table td.sim-calc { background: #f7f9fb; color: #334155; }
.sim-table .sim-del { line-height: 1; padding: 0.1rem 0.4rem; }
.sim-table tfoot td { background: #eef2f7; font-weight: 600; border-top: 2px solid #cbd5e1; }
.sim-table tfoot td.sim-total-label { text-align: right; }
.simulate-edit .form-actions { margin-top: 1rem; display: flex; gap: 0.5rem; }
/* シミュレート一覧：ドラッグ&ドロップ並び替え */
.col-drag { width: 1.8rem; text-align: center; color: #94a3b8; }
.drag-handle { cursor: grab; font-size: 1.1rem; user-select: none; }
.drag-handle:active { cursor: grabbing; }
tr[draggable="true"].dragging { opacity: 0.4; }
tr[draggable="true"].drag-over { outline: 2px solid var(--accent, #3b82f6); outline-offset: -2px; }
