* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2f5fd0;
  --primary-dark: #1e3a8a;
  --navy: #0e1b46;
  --navy-light: #1b3a85;
  --royal: #3a63c9;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #eef2fb;
  color: var(--gray-900);
  font-size: 14px;
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* ── Top Nav ── */
.topnav {
  background: linear-gradient(90deg, #0e1b46 0%, #1b3a85 60%, #3a63c9 100%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 16px;
  flex-shrink: 0;
  height: 48px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.logo {
  font-size: 16px;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 16px;
  border-right: 1px solid #334155;
  margin-right: 8px;
  white-space: nowrap;
}

.nav-menu { list-style: none; display: flex; align-items: center; gap: 2px; }
.nav-menu a {
  display: block;
  padding: 6px 12px;
  color: #94a3b8;
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.15s;
  font-size: 13px;
  white-space: nowrap;
}
.nav-menu a:hover { background: #2a4a9a; color: white; }
.nav-menu a.active { background: var(--primary); color: white; }

/* ── ナビ ドロップダウングループ ── */
.nav-group { position: relative; }
.nav-group > .nav-group-label {
  display: block;
  padding: 6px 12px;
  color: #94a3b8;
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
  cursor: default;
  transition: all 0.15s;
}
.nav-group:hover > .nav-group-label { background: #2a4a9a; color: #fff; }
.nav-group.has-active > .nav-group-label { background: var(--primary); color: #fff; }
.nav-dropdown {
  list-style: none;
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #13245c;
  border: 1px solid #2a4a9a;
  border-radius: 8px;
  padding: 6px;
  min-width: 200px;
  z-index: 200;
  box-shadow: 0 10px 28px rgba(0,0,0,0.45);
}
.nav-group:hover .nav-dropdown { display: block; }
.nav-dropdown li { display: block; }
.nav-dropdown a { display: block; }

/* ── Main ── */
.main-content { flex: 1; overflow-y: auto; }

.page { display: none; padding: 24px; }
.page.active { display: block; }

/* ── Page Header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-title { font-size: 22px; font-weight: 700; }

/* ── Cards ── */
.card {
  background: white;
  border-radius: 10px;
  border: 1px solid var(--gray-200);
  padding: 20px;
  margin-bottom: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: 10px;
  border: 1px solid var(--gray-200);
  padding: 20px;
  text-align: center;
}
.stat-number { font-size: 36px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

/* ── Table ── */
.table-wrap { background: white; border-radius: 10px; border: 1px solid var(--gray-200); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}
td { padding: 12px 16px; border-bottom: 1px solid var(--gray-100); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }
tr { cursor: pointer; }

/* ── Status Badge ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-new       { background: #dbeafe; color: #1d4ed8; }
.badge-screening { background: #fef9c3; color: #a16207; }
.badge-first_interview  { background: #dcfce7; color: #15803d; }
.badge-second_interview { background: #d1fae5; color: #065f46; }
.badge-final_interview  { background: #ecfdf5; color: #065f46; }
.badge-offer     { background: #f3e8ff; color: #7c3aed; }
.badge-accepted  { background: #ede9fe; color: #6d28d9; }
.badge-declined  { background: #fee2e2; color: #991b1b; }
.badge-rejected  { background: #f1f5f9; color: #475569; }
.badge-placed    { background: #052e16; color: #86efac; }

.source-badge { font-size: 11px; color: var(--gray-500); }

/* ── Buttons ── */
.btn {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-success { background: var(--success); color: white; }
.btn-icon { background: none; border: none; cursor: pointer; font-size: 16px; padding: 4px 8px; }

/* ── Filters ── */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar input, .filter-bar select {
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 13px;
  background: white;
  outline: none;
}
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--primary); }

/* ── Pipeline ── */
.pipeline-board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 16px;
}
.pipeline-col {
  flex-shrink: 0;
  width: 220px;
  background: var(--gray-100);
  border-radius: 10px;
  padding: 12px;
}
.pipeline-col-header {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-700);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pipeline-card {
  background: white;
  border-radius: 8px;
  border: 1px solid var(--gray-200);
  padding: 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-weight: 600; font-size: 13px; margin-bottom: 4px; }
.pipeline-card-sub { font-size: 11px; color: var(--gray-500); }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: white;
  border-radius: 12px;
  width: 680px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 { font-size: 18px; font-weight: 700; }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.detail-item label { font-size: 11px; font-weight: 600; color: var(--gray-500); text-transform: uppercase; display: block; margin-bottom: 4px; }
.detail-item span { font-size: 14px; }

.status-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 13px;
  margin-top: 4px;
}

textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 13px;
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}

.activity-log { margin-top: 20px; }
.activity-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
}
.activity-item:last-child { border-bottom: none; }
.activity-time { font-size: 11px; color: var(--gray-500); }

.resume-box {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 12px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
}

/* ── Email page ── */
.email-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: white;
  border-radius: 10px;
  border: 1px solid var(--gray-200);
  margin-bottom: 16px;
}
.status-dot { width: 10px; height: 10px; border-radius: 50%; }
.status-dot.connected { background: var(--success); }
.status-dot.disconnected { background: var(--danger); }

/* ── Form ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}
.form-group input:focus, .form-group select:focus { border-color: var(--primary); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-500);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }

/* ── CA統計サマリー ── */
.ca-sum-tbl {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 10px;
  border: 1px solid var(--gray-200);
  margin-bottom: 16px;
  overflow: hidden;
  table-layout: fixed;
}
.ca-sum-hd {
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  border: 1px solid var(--gray-200);
}
.ca-sum-th {
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
  text-align: center;
  white-space: nowrap;
  background: #fafafa;
}
.ca-sum-td {
  padding: 6px 8px;
  border: 1px solid var(--gray-100);
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-800);
}
.ca-sum-row:hover .ca-sum-td { background: #f8faff; }
.ca-sum-ng-hd {
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 700;
  color: #9a3412;
  background: #fff7ed;
  border: 1px solid var(--gray-200);
  text-align: center;
  white-space: nowrap;
}
.ca-div-zero { color: #d1d5db !important; }

/* ── CA統計シート ── */
.ca-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 10px;
  border: 1px solid var(--gray-200);
  font-size: 12px;
  white-space: nowrap;
}
.ca-th {
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  border: 1px solid var(--gray-200);
  text-align: center;
  white-space: nowrap;
}
.ca-section-header {
  background: #fef9c3;
  color: #92400e;
  font-size: 12px;
  text-align: center;
}
.ca-section-second { background: #dbeafe; color: #1e40af; }
.ca-td {
  padding: 4px 8px;
  border: 1px solid var(--gray-100);
  vertical-align: middle;
  font-size: 12px;
}
.ca-day-cell {
  padding: 6px 10px;
  border: 1px solid var(--gray-200);
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-700);
  text-align: center;
  vertical-align: middle;
  background: #f8fafc;
  min-width: 36px;
}
.ca-row:hover .ca-td { background: #f8faff; }
.ca-name { min-width: 90px; }
.ca-editable { cursor: pointer; min-width: 80px; }
.ca-editable:hover { background: #eff6ff !important; }
.ca-sel {
  padding: 2px 4px;
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  font-size: 11px;
  background: white;
  max-width: 90px;
}

/* ── CS Tabs ── */
.cs-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--gray-200);
  padding-bottom: 0;
}
.cs-tab {
  padding: 8px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: 4px 4px 0 0;
  transition: all 0.15s;
  white-space: nowrap;
}
.cs-tab:hover { background: var(--gray-100); color: var(--gray-700); }
.cs-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-count {
  display: inline-block;
  background: var(--gray-200);
  color: var(--gray-700);
  border-radius: 9999px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 4px;
}
.cs-tab.active .tab-count { background: #dbeafe; color: var(--primary); }
.tab-del {
  font-size: 10px;
  color: #94a3b8;
  margin-left: 4px;
  padding: 0 2px;
  border-radius: 3px;
  cursor: pointer;
}
.tab-del:hover { background: #fee2e2; color: #dc2626; }

.tb-condition-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-100);
}
.tb-condition-row:last-child { border-bottom: none; }
.tb-condition-row select {
  padding: 6px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 13px;
}
.tb-mode { width: 100px; flex-shrink: 0; margin-top: 4px; }

/* ── CS Table ── */
.cs-th {
  text-align: left;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-200);
  border-right: 1px solid var(--gray-100);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cs-td {
  padding: 4px 10px;
  border-bottom: 1px solid var(--gray-100);
  border-right: 1px solid var(--gray-100);
  vertical-align: middle;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1.4;
}
.cs-row:hover .cs-td { background: #f8faff; }
.cs-memo { cursor: pointer; min-width: 220px; color: var(--gray-700); }
.cs-memo:hover { background: #eff6ff !important; }
.cs-checked .cs-td { background: #fff7ed !important; }
.cs-checked:hover .cs-td { background: #ffedd5 !important; }
.cs-check { cursor: pointer; width: 14px; height: 14px; accent-color: #f97316; }

.cs-editable { cursor: pointer; position: relative; }
.cs-editable:hover { background: #eff6ff !important; }
.edit-hint {
  font-size: 10px;
  color: #c7d2fe;
  margin-left: 3px;
  opacity: 0;
  transition: opacity 0.1s;
}
.cs-editable:hover .edit-hint { opacity: 1; }
.cs-status-sel {
  padding: 2px 4px;
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  font-size: 11px;
  background: white;
  cursor: pointer;
  max-width: 110px;
}

.notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 200;
  animation: slideIn 0.3s ease;
}
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── CA面接管理シート ── */
.cm-table {
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
  background: white;
}
.cm-lbl {
  position: sticky;
  left: 0;
  z-index: 2;
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  font-size: 11px;
  width: 64px;
  text-align: right;
  background: inherit;
  overflow: hidden;
  white-space: nowrap;
}
.cm-head {
  padding: 4px 4px;
  border: 1px solid #d1d5db;
  background: #1e293b;
  color: #f1f5f9;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  width: 76px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cm-td {
  padding: 4px 8px;
  border: 1px solid #e5e7eb;
  font-size: 12px;
  width: 76px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}
.cm-readonly { color: #64748b; }
.cm-edit { cursor: pointer; position: relative; }
.cm-edit:hover { background: #f0f9ff !important; }
.cm-edit .edit-hint { font-size: 9px; color: #93c5fd; margin-left: 2px; opacity: 0; }
.cm-edit:hover .edit-hint { opacity: 1; }
.cm-sel {
  padding: 2px 4px;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  font-size: 11px;
  background: white;
  max-width: 68px;
  cursor: pointer;
}
