:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e3e8f0;
  --text: #1f2733;
  --muted: #6b7686;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --gray: #94a3b8;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Meiryo", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  background: var(--primary);
  color: #fff;
  transition: background 0.15s;
}
button:hover { background: var(--primary-dark); }
button.secondary { background: #eef2f8; color: var(--text); }
button.secondary:hover { background: #e2e8f3; }
button.ghost { background: transparent; color: var(--primary); padding: 6px 8px; }
button.ghost:hover { background: #eef2ff; }
button.danger { background: #fee2e2; color: var(--red); }
button.danger:hover { background: #fecaca; }
button.tiny { padding: 4px 10px; font-size: 12.5px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.field { margin-bottom: 14px; }

/* --- レイアウト --- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 10px; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  display: grid; place-items: center; color: #fff; font-size: 15px;
}
.user-chip { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.role-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
}
.role-staff { background: #ede9fe; color: #6d28d9; }
.role-client { background: #dbeafe; color: #1d4ed8; }

.container { max-width: 1080px; margin: 0 auto; padding: 24px; }
.tabs { display: flex; gap: 6px; margin-bottom: 20px; }
.tab { padding: 8px 16px; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 600; }
.tab.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.page-head h2 { margin: 0; font-size: 18px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.card-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }

.grid { display: grid; gap: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tag { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px; background: #eef2f8; color: var(--muted); }

/* --- 進捗バー --- */
.progress { height: 8px; background: #eef2f8; border-radius: 999px; overflow: hidden; display: flex; }
.progress > span { display: block; height: 100%; }
.progress .s-approved { background: var(--green); }
.progress .s-submitted { background: var(--amber); }
.progress .s-rejected { background: var(--red); }

/* 凡例（色の見本） */
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 3px 0 8px; vertical-align: middle; }
.lg-approved { background: var(--green); }
.lg-submitted { background: var(--amber); }
.lg-rejected { background: var(--red); }
.lg-pending { background: #eef2f8; border: 1px solid var(--border); }

/* --- ステータスバッジ --- */
.status { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.st-pending { background: #f1f5f9; color: var(--gray); }
.st-submitted { background: #fef3c7; color: var(--amber); }
.st-approved { background: #dcfce7; color: var(--green); }
.st-rejected { background: #fee2e2; color: var(--red); }
.st-progress { background: #dbeafe; color: var(--primary); }       /* 回答中 */
.st-review { background: #fef08a; color: #b91c1c; }                 /* 確認待ち：黄色背景・赤字 */
/* 社内工程（当社側のみ・段階で色分け） */
/* 検索候補ドロップダウン（クライアント名オートコンプリート等） */
.ac-list {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 30;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; margin-top: 2px;
}
.ac-item { padding: 8px 11px; cursor: pointer; border-bottom: 1px solid #f1f5f9; }
.ac-item:last-child { border-bottom: none; }
.ac-item:hover { background: #eff6ff; }
.ac-empty { padding: 8px 11px; }

/* 一覧表（2次チェック一覧など） */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl thead th { background: #f8fafc; font-weight: 700; color: var(--muted); white-space: nowrap; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: #faf5ff; }

.st-filename_check { background: #e0f2fe; color: #0369a1; }         /* ファイル名確認：水色 */
.st-registered    { background: #ede9fe; color: #6d28d9; }         /* 正登録：紫 */
.st-second_check  { background: #fef08a; color: #b45309; }         /* 2次チェック：黄 */

/* 必要書類カードは全幅・縦に並べる（縦幅はコンパクトに） */
.req-grid { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 6px; }

/* 一括操作バー */
.bulk-bar {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: #eef2f8; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; margin-bottom: 10px;
}
.bulk-bar .bulk-chk { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; margin: 0; color: var(--text); cursor: pointer; }

/* アカウント管理テーブル */
.acct-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.acct-table th { text-align: left; color: var(--muted); font-weight: 700; font-size: 12px; padding: 8px 10px; border-bottom: 2px solid var(--border); white-space: nowrap; }
.acct-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.acct-table tbody tr:hover { background: #f8fafc; }
.acct-table .ac-ops { white-space: nowrap; }
.acct-table .ac-ops a { margin-right: 10px; font-size: 12.5px; }

/* リマインドの書類選択行 */
.rm-item { display: flex; align-items: center; gap: 8px; padding: 5px 2px; font-size: 13px; cursor: pointer; border-bottom: 1px solid #f1f5f9; }
.rm-item:last-child { border-bottom: none; }
.rm-item span:nth-of-type(1) { flex: 1; }

/* ステータスに応じて枠（左帯）と背景色を変え、回収状況を一目で分かるように */
.req { border-left: 5px solid #cbd5e1; }
.req-st-pending    { border-left-color: #94a3b8; background: #ffffff; }
.req-st-in_progress{ border-left-color: #3b82f6; background: #eff6ff; }
.req-st-submitted  { border-left-color: #f59e0b; background: #fffbeb; }
.req-st-rejected   { border-left-color: #ef4444; background: #fef2f2; }
/* 不備（差戻し）・未提出/未回収は赤枠＋書類名を赤字で要対応を強調 */
.req.req-st-pending, .req.req-st-rejected { border: 1px solid #ef4444; border-left: 5px solid #ef4444; }
.req-st-pending .req-name, .req-st-rejected .req-name { color: #dc2626; }
/* 完了はやや暗いグレー背景＋枠線で「済み」を明示（当社・クライアント双方） */
.req.req-st-approved { border: 1px solid #94a3b8; border-left: 5px solid #64748b; background: #d7dde5; opacity: 0.8; }
.req-st-approved .req-name { color: #475569; }

/* 不備事項：当社側の入力欄 */
.reject-edit { margin-top: 8px; background: #fff; border: 1px dashed #fca5a5; border-radius: 8px; padding: 8px 10px; }
.reject-edit label { display: block; }
/* 不備事項：クライアント側の表示（赤字・黄背景） */
.reject-note {
  margin-top: 8px; background: #fef08a; color: #b91c1c; font-weight: 700;
  border-radius: 8px; padding: 8px 12px; font-size: 13px; line-height: 1.6;
}

/* ボタンの色合い：主要操作のみ色付き、補助操作は控えめに統一 */
button.btn-green { background: var(--green); }
button.btn-green:hover { background: #15803d; }
button.btn-outline-red { background: #fff; color: var(--red); border: 1px solid #fca5a5; }
button.btn-outline-red:hover { background: #fef2f2; }

/* --- 必要書類リスト --- */
.req {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 14px;
  margin-bottom: 0;
  background: #fff;
}
.req-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.req-name { font-weight: 600; }
.doc-list { margin-top: 7px; display: grid; gap: 5px; }
.doc {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: #f8fafc; border-radius: 8px; padding: 6px 12px; font-size: 13px;
}
.doc > span { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.modal-body { overflow-x: hidden; }
.doc[draggable="true"] { cursor: grab; }
.doc.dragging { opacity: 0.5; background: #dbeafe; }
.grip { color: var(--gray); cursor: grab; user-select: none; margin-right: 2px; }
.req-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; align-items: center; }

/* カテゴリ見出し */
.cat-head {
  font-size: 12.5px; font-weight: 700; color: var(--muted);
  margin: 16px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border);
}
.cat-head:first-child { margin-top: 4px; }

/* アップロードボタン（label を擬似ボタン化）＝グレー */
.upload-label {
  display: inline-flex; align-items: center; margin: 0; cursor: pointer;
  background: #eef2f8; color: var(--text); border-radius: 8px; padding: 6px 12px; font-size: 12.5px;
}
.upload-label:hover { background: #e2e8f3; }
.ghost-upload { background: #eef2f8; color: var(--text); }
.ghost-upload:hover { background: #e2e8f3; }
.ghost-upload-inline {
  display: inline-flex; align-items: center; margin: 0; cursor: pointer;
  color: var(--primary); font-size: 12.5px; padding: 4px 8px; border-radius: 8px;
}
.ghost-upload-inline:hover { background: #eef2ff; }

.answer-box {
  margin-top: 6px; font-size: 13px; background: #f0f9ff; border-left: 3px solid var(--primary);
  padding: 6px 10px; border-radius: 0 6px 6px 0;
}

/* --- メッセージ --- */
.msg { padding: 10px 12px; border-radius: 10px; margin-bottom: 8px; max-width: 85%; }
.msg .meta { font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.msg.staff { background: #ede9fe; margin-right: auto; }
.msg.client { background: #dbeafe; margin-left: auto; }

/* --- モーダル --- */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  display: grid; place-items: center; z-index: 50; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: 14px; width: 100%; max-width: 560px;
  max-height: 88vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.modal-head { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.close-x { background: transparent; color: var(--muted); font-size: 20px; padding: 0 6px; }
.close-x:hover { background: #f1f5f9; }

/* --- ログイン --- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 380px; }
.login-card h1 { font-size: 19px; margin: 0 0 4px; }
.login-card .sub { color: var(--muted); margin-bottom: 22px; font-size: 13px; }
.demo-hint { margin-top: 18px; font-size: 12px; color: var(--muted); background: #f8fafc; border-radius: 8px; padding: 10px 12px; line-height: 1.7; }

.error-banner { background: #fee2e2; color: var(--red); padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.row-gap { display: flex; gap: 8px; flex-wrap: wrap; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
a.link { color: var(--primary); cursor: pointer; text-decoration: none; }
a.link:hover { text-decoration: underline; }

/* 2次チェック一覧：1レコード2行表示 */
.sc2-item { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; background: #fff; }
.sc2-item:hover { background: #faf5ff; }
.sc2-row1 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sc2-row1 .sc2-doc { font-weight: 700; }
.sc2-row1 .sc2-people { color: var(--muted); white-space: nowrap; }
.sc2-row1 .sc2-ops { margin-left: auto; display: flex; gap: 6px; flex-shrink: 0; }
.sc2-row2 { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 6px; padding-left: 26px; color: var(--muted); }
.sc2-round { white-space: nowrap; }
.sc2-file { cursor: pointer; color: var(--primary); text-decoration: none; margin-right: 10px; }
.sc2-file:hover { text-decoration: underline; }
.sc2-note { color: #b45309; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc2-memo { display: flex; align-items: center; gap: 6px; }
.sc2-note-log { max-height: 200px; overflow: auto; margin-bottom: 12px; }
.sc2-note-item { border-left: 3px solid #fcd34d; background: #fffbeb; border-radius: 6px; padding: 6px 10px; margin-bottom: 6px; }
