* { box-sizing: border-box; }
:root {
  --blue: #2563eb;
  --blue-d: #1d4ed8;
  --bg: #f4f6fb;
  --card: #ffffff;
  --line: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --green: #16a34a;
}
body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

/* ---------- ログイン ---------- */
.login-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  padding: 20px;
}
.login-card {
  background: var(--card);
  border-radius: 16px;
  padding: 32px 26px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}
.login-wizard { display: block; width: 120px; height: 120px; object-fit: contain; margin: 0 auto 6px; }
.login-card h1 { margin: 0; font-size: 22px; text-align: center; }
.login-card .sub { margin: 4px 0 22px; text-align: center; color: var(--muted); font-size: 13px; }
.login-card label { display: block; font-size: 13px; margin: 12px 0 5px; font-weight: 600; }
.login-card input {
  width: 100%; padding: 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 16px;
}
.login-card button {
  width: 100%; margin-top: 20px; padding: 13px; border: 0; border-radius: 10px;
  background: var(--blue); color: #fff; font-size: 16px; font-weight: 700; cursor: pointer;
}
.login-card button:active { background: var(--blue-d); }
.err { color: #dc2626; font-size: 13px; min-height: 18px; margin: 8px 0 0; }
.hint {
  margin-top: 22px; padding: 12px; background: #f8fafc; border: 1px dashed var(--line);
  border-radius: 10px; font-size: 12px; color: var(--muted); line-height: 1.7;
}
code { background: #eef2ff; padding: 1px 6px; border-radius: 5px; color: var(--blue-d); }

/* ---------- 共通レイアウト ---------- */
.topbar {
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 12px 16px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.topbar-wizard { width: 40px; height: 40px; object-fit: contain; flex: none; }
.topbar .title { font-weight: 700; font-size: 16px; }
.topbar .who { font-size: 12px; color: var(--muted); }
.topbar button {
  background: #f1f5f9; border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 12px; font-size: 13px; cursor: pointer;
}
.wrap { max-width: 820px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.card h2 .emoji { font-size: 18px; }

textarea, .card input[type="text"], .card input[type="number"] {
  width: 100%; padding: 11px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; font-family: inherit; resize: vertical;
}
.expense { margin-top: 8px; font-size: 14px; font-weight: 600; color: #b45309;
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 6px 10px; display: inline-block; }
.btn {
  background: var(--blue); color: #fff; border: 0; border-radius: 10px;
  padding: 11px 16px; font-size: 15px; font-weight: 700; cursor: pointer;
}
.btn:active { background: var(--blue-d); }
.btn.sub { background: #eef2ff; color: var(--blue-d); }
.btn.gray { background: #f1f5f9; color: var(--text); }
.btn.small { padding: 7px 12px; font-size: 13px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

/* タブ切替（モード） */
.tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.tab {
  flex: 1; min-width: 100px; text-align: center; padding: 10px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 14px; font-weight: 600;
}
.tab.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* チャット */
.chat-title { font-size: 13px; font-weight: 700; color: var(--blue-d); margin-top: 4px; }
.chat { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; min-height: 40px; }
.msg { padding: 11px 13px; border-radius: 12px; font-size: 15px; line-height: 1.6; white-space: pre-wrap; }
.msg.user { background: var(--blue); color: #fff; align-self: flex-end; max-width: 85%; }
.msg.ai { background: #f1f5f9; align-self: flex-start; max-width: 92%; }
.msg.ai b { color: var(--blue-d); }

.file-list { margin: 8px 0 0; font-size: 13px; }
.file-list a { color: var(--blue-d); display: inline-block; margin: 2px 8px 2px 0; }

.item { border-top: 1px solid var(--line); padding: 12px 0; }
.item:first-child { border-top: 0; }
.item .meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.item .body { font-size: 15px; white-space: pre-wrap; line-height: 1.6; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px; background: #eef2ff; color: var(--blue-d); margin-left: 6px; }
.review-box { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 10px; padding: 10px; margin-top: 8px; font-size: 14px; white-space: pre-wrap; line-height: 1.6; }
.ai-box { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 10px; padding: 10px; margin-top: 8px; font-size: 14px; white-space: pre-wrap; line-height: 1.6; }
.ai-box b { color: var(--blue-d); }
.rules-box { background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 12px 14px; font-size: 15px; white-space: pre-wrap; line-height: 1.7; }
.dm-count { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.dm-card { border: 1px solid #e5e7eb; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; background: #fff; }
.dm-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dm-num { background: var(--blue); color: #fff; width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; flex: none; }
.dm-genre { background: #eef2ff; color: #4338ca; font-size: 12px; padding: 1px 8px; border-radius: 999px; }
.dm-meta { font-size: 13px; color: var(--muted); margin: 4px 0 8px; }
.dm-links { display: flex; gap: 10px; flex-wrap: wrap; }
.dm-links a { font-size: 13px; text-decoration: none; background: #f1f5f9; padding: 4px 10px; border-radius: 8px; color: var(--blue-d); }
.dm-links a:hover { background: #e2e8f0; }
.dm-noig { font-size: 12px; color: #b91c1c; }
.dm-sent { margin-left: auto; font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; cursor: pointer; white-space: nowrap; }
.dm-sent input { width: 16px; height: 16px; cursor: pointer; }
.report-chat { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.report-chat:empty { margin-top: 0; }
.report-chat-row { display: flex; gap: 6px; margin-top: 6px; align-items: flex-end; }
.report-chat-row textarea { flex: 1; }
.fc-row { display:flex; align-items:center; gap:10px; border:1px solid #e5e7eb; border-radius:10px; padding:9px 12px; margin-bottom:6px; cursor:pointer; background:#fff; }
.fc-row:hover { background:#f8fafc; }
.fc-sub { font-size:12px; color:var(--muted); margin-top:2px; }
.fc-brand { background:#eef2ff; color:#4338ca; font-size:11px; padding:1px 7px; border-radius:999px; }
.fc-status { font-size:12px; background:#f1f5f9; color:#334155; padding:3px 9px; border-radius:999px; white-space:nowrap; flex:none; }
.fc-infos { display:grid; grid-template-columns:1fr 1fr; gap:6px 14px; }
.fc-info span { font-size:11px; color:var(--muted); display:block; }
.fc-info div { font-size:14px; word-break:break-word; }
.fc-hist { background:#f8fafc; border:1px solid #e5e7eb; border-radius:8px; padding:8px 10px; margin-bottom:6px; font-size:13px; white-space:pre-wrap; line-height:1.5; }
.fc-by { color:var(--muted); font-size:11px; }

/* 進化ステータス */
.status-hero { display: flex; gap: 14px; align-items: center; }
.status-wizard { width: 110px; height: 116px; flex: none; }
.status-info { flex: 1; }
.status-stage { font-size: 12px; color: var(--muted); }
.status-name { font-size: 20px; font-weight: 700; color: var(--blue-d); margin: 2px 0 4px; }
.status-next { font-size: 13px; color: var(--text); }
.rank-dots { display: flex; gap: 6px; margin-top: 10px; }
.rank-dots .dot { width: 12px; height: 12px; border-radius: 50%; background: #e5e7eb; border: 1px solid var(--line); }
.rank-dots .dot.on { background: var(--blue); border-color: var(--blue); }
.skills { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.skill-top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; }
.skill-lv { font-weight: 700; color: var(--blue-d); }
.skill-bar { height: 10px; background: #eef2ff; border-radius: 20px; overflow: hidden; }
.skill-fill { height: 100%; background: var(--blue); border-radius: 20px; }
.skill-detail { font-size: 11px; color: var(--muted); font-weight: 400; }
.skill.off .skill-top { color: var(--muted); }
.skill-na { font-size: 12px; color: var(--muted); }

/* 今日の数字グリッド */
.num-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 6px; }
.num-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }
.num-item span { font-size: 13px; color: var(--text); }
.num-item input { width: 70px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; }

/* 管理者：進化モーダルのスキル行 */
.gskill { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.gskill:first-of-type { border-top: 0; }
.gskill-name { flex: 1; min-width: 130px; font-size: 14px; font-weight: 600; }
.gskill-type { font-size: 11px; color: var(--muted); font-weight: 400; }
.gskill-ctrl { display: flex; align-items: center; gap: 6px; }
.skill-auto { font-weight: 700; color: var(--blue-d); font-size: 14px; }
.gskill-off { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.gskill.off .gskill-name { color: var(--muted); }

/* 見込み案件 */
.deal-summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
.deal-tile { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.deal-tile span { display: block; font-size: 11px; color: var(--muted); }
.deal-tile b { font-size: 16px; }
.deal-tile.won { background: #f0fdf4; border-color: #bbf7d0; }
.deal-add-box { margin-bottom: 12px; }
.deal-add-box summary { cursor: pointer; font-weight: 700; color: var(--blue-d); font-size: 14px; padding: 6px 0; }
.deal-add-form { display: flex; flex-direction: column; gap: 8px; padding: 10px 0; }
.deal-add-form input, .deal-add-form select { padding: 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; }
.deal { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.deal.won { background: #f0fdf4; border-color: #bbf7d0; }
.deal.lost { background: #f8fafc; opacity: 0.75; }
.deal-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.deal-head { font-size: 15px; }
.deal-who { display: inline-block; font-size: 11px; background: #eef2ff; color: var(--blue-d); padding: 1px 7px; border-radius: 20px; margin-right: 6px; }
.deal-amount { font-weight: 700; white-space: nowrap; }
.deal-mid { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.deal-stage-sel { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.deal-conf { font-size: 12px; color: var(--muted); }
.deal-next { font-size: 13px; color: var(--text); }
.deal-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.deal-panel { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.deal-panel input { padding: 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; flex: 1; min-width: 120px; }
.deal-notes { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 8px; }
.deal-note { font-size: 13px; margin-bottom: 4px; }
.deal-note-meta { color: var(--muted); font-size: 11px; }
.loading { color: var(--muted); font-size: 14px; }
.empty { color: var(--muted); font-size: 14px; padding: 10px 0; }
.aistatus { font-size: 11px; padding: 2px 8px; border-radius: 20px; }
.aistatus.live { background: #dcfce7; color: #15803d; }
.aistatus.demo { background: #fef9c3; color: #a16207; }
.flabel { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 5px; }
.card textarea { margin-bottom: 2px; }
.fselect { width: 100%; padding: 11px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; font-family: inherit; background: #fff; }

/* 登録者一覧テーブル */
.utable { width: 100%; border-collapse: collapse; font-size: 14px; }
.utable th { text-align: left; font-size: 12px; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.utable td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.utable code { font-size: 13px; }
.user-add { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.pw-set { font-size: 12px; color: var(--muted); }
.urow-actions { white-space: nowrap; }
.urow-actions .btn { margin-left: 4px; }

/* モーダル */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 14px; max-width: 600px; width: 100%; max-height: 85vh; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 15px; }
.modal-head button { background: #f1f5f9; border: 1px solid var(--line); border-radius: 8px; padding: 4px 11px; cursor: pointer; font-size: 14px; }
.modal-body { padding: 16px; overflow: auto; line-height: 1.7; font-size: 14px; }
.modal-body b { color: var(--blue-d); }
#summaryBody { white-space: pre-wrap; }

/* 割り当てタスク（従業員側） */
.task-item { display: flex; gap: 10px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); }
.task-item:first-child { border-top: 0; }
.task-item input[type="checkbox"] { width: 22px; height: 22px; margin-top: 2px; flex: none; }
.task-body { flex: 1; }
.task-title { font-weight: 700; font-size: 15px; }
.task-detail { font-size: 14px; color: var(--text); margin-top: 3px; white-space: pre-wrap; }
.task-meta { font-size: 12px; color: var(--muted); margin-top: 5px; }
.task-item.done .task-title { text-decoration: line-through; color: var(--muted); }
.task-donesep { font-size: 12px; color: var(--muted); margin: 14px 0 4px; border-top: 1px dashed var(--line); padding-top: 10px; }
.due { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 20px; background: #eef2ff; color: var(--blue-d); }
.due.soon { background: #fef3c7; color: #b45309; }
.due.over { background: #fee2e2; color: #b91c1c; }

/* AI部下 営業アシスト */
.ot-box { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.ot-item { border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; margin-top: 10px; background: #fff; }
.ot-item.picked { border-color: #6366f1; box-shadow: 0 0 0 2px #e0e7ff; }
.ot-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ot-top b { font-size: 15px; }
.ot-meta { font-size: 12px; color: var(--muted); margin-left: auto; }
.ot-meta a { color: var(--blue-d); }
.ot-badge { display: inline-block; font-size: 11px; padding: 1px 9px; border-radius: 20px; font-weight: 700; }
.ot-badge.ok { background: #dcfce7; color: #15803d; }
.ot-badge.ng { background: #fee2e2; color: #b91c1c; }
.ot-badge.gray { background: #eef2f7; color: var(--muted); }
.ot-status { font-size: 11px; padding: 1px 9px; border-radius: 20px; font-weight: 700; }
.ot-status.sent { background: #dbeafe; color: #1d4ed8; }
.ot-status.skipped { background: #f3f4f6; color: var(--muted); }
.ot-reason { font-size: 13px; color: #4338ca; margin-top: 5px; font-weight: 600; }
.ot-sum { font-size: 13px; color: var(--text); margin-top: 5px; white-space: pre-wrap; }
.ot-err { font-size: 12px; color: #b45309; margin-top: 4px; }
.ot-contact { font-size: 13px; margin-top: 6px; }
.ot-contact a { color: var(--blue-d); font-weight: 600; }
.ot-draft { margin-top: 8px; }
.ot-draft textarea { width: 100%; box-sizing: border-box; font-size: 14px; padding: 9px; border: 1px solid var(--line); border-radius: 8px; resize: vertical; }
