:root {
  --bg: #f5f5f3;
  --bg-card: #ffffff;
  --bg-sidebar: #1a1a1a;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --text-light: #999;
  --border: #e5e5e5;
  --accent: #0066ff;
  --accent-light: #e8f0ff;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --purple: #7c3aed;
  --purple-light: #ede9fe;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, 'Hiragino Sans', 'Yu Gothic', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { text-decoration: none; cursor: pointer; }

.app { display: flex; height: 100vh; overflow: hidden; }

/* サイドバー */
.sidebar { width: 220px; background: var(--bg-sidebar); display: flex; flex-direction: column; flex-shrink: 0; }
.logo { display: flex; align-items: center; gap: 10px; padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.logo-mark { width: 32px; height: 32px; background: var(--accent); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; color: white; flex-shrink: 0; }
.logo-title { color: white; font-size: 13px; font-weight: 600; }
.logo-sub { color: rgba(255,255,255,0.4); font-size: 11px; }
.nav { padding: 12px 8px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: var(--radius-sm); color: rgba(255,255,255,0.55); font-size: 13px; margin-bottom: 2px; transition: all 0.15s; user-select: none; }
.nav-item:hover { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.85); }
.nav-item.active { background: rgba(0,102,255,0.2); color: white; }
.nav-icon { font-size: 15px; width: 20px; text-align: center; }
.badge { margin-left: auto; background: var(--accent); color: white; font-size: 10px; padding: 2px 6px; border-radius: 10px; font-weight: 600; }
.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,0.08); }
.user-info { display: flex; align-items: center; gap: 8px; }
.user-avatar { width: 30px; height: 30px; background: var(--accent); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.user-name { color: white; font-size: 12px; font-weight: 500; }
.user-role { color: rgba(255,255,255,0.4); font-size: 11px; }

/* コンテンツ */
.content { flex: 1; overflow-y: auto; }
.page { display: none; padding: 28px 32px; }
.page.active { display: block; }

.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 600; }
.page-header p { color: var(--text-muted); font-size: 13px; margin-top: 3px; }
.header-actions { display: flex; gap: 8px; }

/* メトリクス */
.metrics { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 20px; }
.metric-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; align-items: center; gap: 12px; }
.metric-icon { font-size: 24px; }
.metric-label { font-size: 12px; color: var(--text-muted); }
.metric-value { font-size: 24px; font-weight: 600; }

/* カード */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; }
.card-actions { display: flex; gap: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ボタン */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-sm); font-size: 13px; cursor: pointer; border: 1px solid var(--border); background: var(--bg-card); color: var(--text); transition: all 0.15s; font-family: inherit; }
.btn:hover { background: var(--bg); border-color: #ccc; }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: #0052cc; }
.btn-success { background: var(--success); color: white; border-color: var(--success); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; padding: 11px; }

/* フォーム */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 5px; font-weight: 500; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.label-note { color: var(--text-light); font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=file], select, textarea {
  width: 100%; padding: 8px 10px; font-size: 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-card); color: var(--text); font-family: inherit; outline: none; transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }

/* フィルターバー */
.filter-bar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-bar input { max-width: 220px; }
.filter-bar select { width: 140px; }

/* テーブル */
.table-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 10px 14px; font-size: 11px; font-weight: 600; color: var(--text-muted); background: var(--bg); border-bottom: 1px solid var(--border); text-transform: uppercase; letter-spacing: 0.04em; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }
.company-name { font-weight: 500; }
.industry-tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; background: var(--bg); color: var(--text-muted); }
.action-date { font-size: 12px; color: var(--text-light); }

/* ステータスバッジ */
.status { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.status-未接触 { background: var(--accent-light); color: var(--accent); }
.status-送信済 { background: var(--warning-light); color: var(--warning); }
.status-返信あり { background: var(--success-light); color: var(--success); }
.status-商談中 { background: var(--purple-light); color: var(--purple); }
.status-受注 { background: #f0fdf4; color: #15803d; }

/* バルクアクション */
.bulk-actions { margin-top: 10px; display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--accent-light); border-radius: var(--radius-sm); font-size: 13px; }

/* ファネル */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row { display: flex; align-items: center; gap: 10px; }
.funnel-label { font-size: 12px; color: var(--text-muted); width: 75px; flex-shrink: 0; }
.funnel-bar-wrap { flex: 1; background: var(--bg); border-radius: 4px; height: 26px; }
.funnel-bar { height: 100%; border-radius: 4px; display: flex; align-items: center; padding: 0 8px; transition: width 0.4s; min-width: 40px; }
.funnel-count { font-size: 12px; font-weight: 600; }

/* アクティビティログ */
.activity-log { display: flex; flex-direction: column; gap: 1px; max-height: 240px; overflow-y: auto; }
.activity-item { padding: 8px 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: none; }
.activity-msg { font-size: 13px; }
.activity-time { font-size: 11px; color: var(--text-light); margin-top: 2px; }

/* パイプライン */
.pipeline { display: grid; grid-template-columns: repeat(5,1fr); gap: 12px; }
.pipeline-col { background: var(--bg); border-radius: var(--radius); padding: 12px; min-height: 400px; }
.pipeline-col-title { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; display: flex; justify-content: space-between; }
.pipeline-count { background: var(--border); color: var(--text-muted); padding: 1px 6px; border-radius: 8px; }
.pipeline-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px; cursor: pointer; transition: box-shadow 0.15s; }
.pipeline-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.pipeline-card-name { font-size: 13px; font-weight: 500; }
.pipeline-card-sub { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* メール出力 */
.email-output { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; font-size: 13px; line-height: 1.8; min-height: 200px; white-space: pre-wrap; color: var(--text); }
.placeholder { color: var(--text-light); font-style: italic; }
.gmail-note { margin-top: 10px; padding: 10px 12px; background: var(--accent-light); border-radius: var(--radius-sm); font-size: 12px; color: var(--accent); line-height: 1.6; }

/* クイックスクリプト */
.quick-scripts { margin-top: 16px; }
.quick-title { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; font-weight: 500; }
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.quick-btn { padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-card); cursor: pointer; font-size: 12px; transition: all 0.15s; font-family: inherit; }
.quick-btn:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

/* Gmail連携 */
.gmail-connect { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.gmail-status { font-size: 12px; padding: 4px 10px; border-radius: 10px; background: var(--danger-light); color: var(--danger); font-weight: 600; }
.gmail-status.connected { background: var(--success-light); color: var(--success); }

/* モーダル */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--bg-card); border-radius: var(--radius); padding: 24px; width: 500px; max-width: 95vw; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { background: var(--bg); }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* CSVインポート */
.import-format { background: var(--bg); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 14px; }
.import-label { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; }
.import-format code { font-family: monospace; font-size: 12px; }
.import-preview { margin-top: 10px; font-size: 12px; color: var(--text-muted); }

/* ローディング */
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
.loading { animation: pulse 1.2s infinite; color: var(--text-muted); }

/* スクロールバー */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
