:root {
  --navy: #173a57;
  --navy2: #0f2d45;
  --blue: #2877b7;
  --bg: #f3f6f8;
  --line: #dfe6eb;
  --text: #1d2a34;
  --muted: #6b7b88;
  --white: #fff;
  --shadow: 0 8px 30px rgba(28, 53, 72, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Yu Gothic UI", "Noto Sans JP", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 16px;
}

/* ==========================================
   レイアウト・骨組み
   ========================================== */
.app-shell {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(180deg, var(--navy2), var(--navy));
  color: #fff;
  padding: 24px 15px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 10px 27px;
  font-weight: 700;
  font-size: 20px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  border-radius: 10px;
  background: #fff;
  color: var(--navy);
  font-size: 13px;
}

.sidebar nav {
  display: grid;
  gap: 7px;
}

.nav-item,
.profile {
  width: 100%;
  border: 0;
  color: #d9e7f2;
  background: transparent;
  border-radius: 9px;
  text-align: left;
  cursor: pointer;
}

.nav-item {
  padding: 12px 13px;
  font-size: 14px;
  display: flex;
  gap: 12px;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
}

.side-note {
  margin-top: auto;
  padding: 14px;
  background: rgba(255, 255, 255, 0.09);
  border-radius: 9px;
  font-size: 12px;
}

.side-note p {
  margin: 5px 0 0;
  color: #c5d8e5;
}

.profile {
  margin-top: 15px;
  padding: 12px 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile span:last-child {
  display: grid;
}

.profile small {
  color: #bad0df;
  margin-top: 2px;
}

.avatar,
.large-avatar {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #dcebf5;
  color: var(--navy);
  font-weight: 700;
}

.avatar {
  width: 34px;
  height: 34px;
}

/* ==========================================
   ヘッダー・トップバー
   ========================================== */
.topbar {
  height: 82px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 15px 30px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar h1 {
  font-size: 21px;
  margin: 0;
}

.topbar p {
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 0;
}

.top-actions {
  margin-left: auto;
  display: flex;
  gap: 12px;
  align-items: center;
}

/* ==========================================
   ボタン・UIパーツ
   ========================================== */
.primary,
.secondary,
.icon-btn,
.close-btn {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.primary {
  background: var(--navy);
  color: #fff;
  border-radius: 8px;
  padding: 11px 17px;
  font-size: 14px;
  font-weight: 700;
}

.primary:hover {
  background: #235473;
}

.secondary {
  background: #fff;
  border: 1px solid #cfd9df;
  color: #3d4e5a;
  border-radius: 7px;
  padding: 9px 13px;
  font-size: 13px;
}

.secondary:hover {
  background: #f5f8fa;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #f4f7f9;
  position: relative;
}

.icon-btn i {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #df5b5b;
  right: 8px;
  top: 7px;
}

.menu-btn {
  display: none;
}

/* ==========================================
   メインコンテンツ・パネル
   ========================================== */
.content {
  padding: 25px 30px;
  max-width: 1500px;
  margin: auto;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}

.stats article {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 17px;
  display: flex;
  gap: 14px;
  align-items: center;
}

.stat-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-weight: 700;
}

.stat-icon.blue {
  background: #e6f1fa;
  color: #2678b5;
}

.stat-icon.teal {
  background: #e5f5f2;
  color: #20877b;
}

.stat-icon.amber {
  background: #fff2dc;
  color: #b87b18;
}

.stat-icon.violet {
  background: #f0eafb;
  color: #7255a9;
}

.stats small {
  color: var(--muted);
  display: block;
}

.stats strong {
  font-size: 24px;
}

.stats em {
  font-size: 12px;
  font-style: normal;
  margin-left: 3px;
}

.stats p {
  font-size: 11px;
  color: #338064;
  margin: 2px 0 0;
}

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.toolbar {
  padding: 14px;
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.search {
  flex: 1;
  min-width: 260px;
  border: 1px solid #ccd7de;
  border-radius: 7px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
}

.search input {
  border: 0;
  outline: 0;
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 10px 0;
}

.toolbar select,
.form-grid select,
.form-grid input {
  border: 1px solid #ccd7de;
  border-radius: 7px;
  padding: 10px;
  background: #fff;
  font: inherit;
  font-size: 14px;
  color: #33434f;
}

/* ==========================================
   テーブル・リスト
   ========================================== */
.table-panel {
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  font-size: 16px;
  margin: 0;
}

.panel-head p {
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 0;
}

.table-wrap {
  overflow: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 900px;
}

th,
td {
  text-align: left;
  padding: 13px 18px;
  border-bottom: 1px solid #edf1f3;
  font-size: 13px;
}

th {
  color: #6c7b87;
  font-weight: 600;
  background: #fafbfc;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f7fafc;
}

.name-cell {
  display: flex;
  gap: 10px;
  align-items: center;
}

.initial {
  width: 35px;
  height: 35px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #e8f0f6;
  color: var(--navy);
  font-weight: 700;
}

.name-cell b {
  display: block;
}

.name-cell small {
  color: var(--muted);
}

.badge {
  display: inline-block;
  border-radius: 20px;
  padding: 5px 9px;
  font-size: 12px;
}

.badge.対応予定 {
  background: #fff0dc;
  color: #9a6410;
}

.badge.商談中 {
  background: #e7f0fb;
  color: #29649a;
}

.badge.フォロー済 {
  background: #e5f4ea;
  color: #287748;
}

.more {
  font-size: 20px;
  color: #768894;
}

.empty {
  text-align: center;
  padding: 55px;
}

.empty span {
  font-size: 32px;
}

.empty h3 {
  margin: 10px 0 5px;
}

.empty p {
  color: var(--muted);
}

/* ==========================================
   オーバーレイ・モーダル・ドロワー
   ========================================== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 31, 43, 0.38);
  z-index: 20;
  display: flex;
  justify-content: flex-end;
}

.overlay[hidden] {
  display: none;
}

.detail-drawer {
  height: 100%;
  width: min(510px, 100%);
  background: #fff;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.15);
  padding: 25px;
  overflow: auto;
  animation: slideIn 0.22s ease;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.drawer-head small {
  color: var(--muted);
}

.drawer-head h2 {
  margin: 3px 0 0;
  font-size: 22px;
}

.close-btn {
  background: #eef2f4;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 22px;
}

.person-card {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 21px 0;
}

.large-avatar {
  width: 58px;
  height: 58px;
  font-size: 20px;
}

.person-card h3 {
  margin: 0;
  font-size: 17px;
}

.person-card p {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.contact-list {
  margin: 0;
}

.contact-list div {
  display: grid;
  grid-template-columns: 90px 1fr;
  border-top: 1px solid #edf1f3;
  padding: 12px 3px;
}

.contact-list dt {
  color: var(--muted);
  font-size: 13px;
}

.contact-list dd {
  margin: 0;
  font-size: 14px;
}

.ai-box {
  margin: 18px 0;
  padding: 16px;
  background: linear-gradient(135deg, #f0f6fb, #f5f0fb);
  border: 1px solid #dfe5f0;
  border-radius: 10px;
}

.ai-title {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
}

.ai-title button,
.section-title button {
  border: 0;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
}

.ai-box p {
  line-height: 1.7;
  font-size: 13px;
}

.tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tags span {
  font-size: 11px;
  background: #fff;
  border: 1px solid #d7e1e8;
  border-radius: 20px;
  padding: 4px 8px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title h3 {
  font-size: 16px;
}

.history-item {
  border-left: 2px solid #bbd4e6;
  margin-left: 6px;
  padding: 2px 0 15px 16px;
}

.history-item b {
  font-size: 13px;
}

.history-item p {
  font-size: 13px;
  color: #4e5d68;
  margin: 4px 0;
}

.history-item small {
  color: var(--muted);
}

.centered {
  justify-content: center;
  align-items: center;
  padding: 20px;
}

/* ==========================================
   モーダル（ポップアップ）とフォーム
   ========================================== */
.modal {
  width: min(600px, 100%);
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow);
  max-height: 90vh; /* 画面の高さの最大90%までに制限する */
  overflow-y: auto; /* はみ出した場合は縦スクロールバーを出す */
}

/* スクロールバーのデザイン（Windows向け） */
.modal::-webkit-scrollbar {
  width: 8px;
}

.modal::-webkit-scrollbar-thumb {
  background: #ccd7de;
  border-radius: 4px;
}

.modal::-webkit-scrollbar-track {
  background: transparent;
}

.scan-area {
  margin: 20px 0;
  background: #f5f8fa;
  border: 1px dashed #adbdc8;
  border-radius: 9px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 13px;
}

.scan-area > span {
  font-size: 24px;
}

.scan-area div {
  flex: 1;
}

.scan-area b {
  font-size: 14px;
}

.scan-area p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

.form-grid label {
  font-size: 13px;
  font-weight: 600;
  display: grid;
  gap: 7px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

/* ==========================================
   トースト通知
   ========================================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 25px;
  transform: translate(-50%, 20px);
  background: #173a57;
  color: #fff;
  padding: 11px 18px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
  z-index: 50;
  font-size: 14px;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ==========================================
   プレースホルダー・空の状態
   ========================================== */
.placeholder-view {
  display: grid;
  place-items: center;
  min-height: 70vh;
}

.placeholder-view .panel {
  text-align: center;
  max-width: 520px;
  padding: 50px;
}

.big-icon {
  font-size: 42px;
  color: var(--blue);
}

.placeholder-view p {
  color: var(--muted);
  line-height: 1.8;
  margin-bottom: 20px;
}

@keyframes slideIn {
  from {
    transform: translateX(40px);
    opacity: 0.7;
  }
}

/* ==========================================
   レスポンシブデザイン（スマホ・タブレット対応）
   ========================================== */
@media (max-width: 1050px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .toolbar {
    flex-wrap: wrap;
  }
  .search {
    flex-basis: 100%;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }
  .sidebar {
    display: none;
  }
  .topbar {
    padding: 13px 16px;
    height: auto;
  }
  .menu-btn {
    display: block;
    border: 0;
    background: #edf2f5;
    border-radius: 7px;
    padding: 8px;
  }
  .topbar p {
    display: none;
  }
  .primary {
    padding: 10px 12px;
  }
  .content {
    padding: 16px;
  }
  .stats {
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }
  .stats article {
    padding: 12px;
    gap: 8px;
  }
  .stat-icon {
    width: 34px;
    height: 34px;
  }
  .stats strong {
    font-size: 19px;
  }
  .toolbar select,
  .toolbar .secondary {
    flex: 1;
  }
  .panel-head {
    padding: 14px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-grid .wide {
    grid-column: auto;
  }
  .scan-area {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .scan-area button {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .stats {
    grid-template-columns: 1fr;
  }
  .topbar h1 {
    font-size: 18px;
  }
  .top-actions .icon-btn {
    display: none;
  }
}