:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --text: #212b36;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-dark: #d9dde4;
  --active: #1f2937;
  --tag-green-bg: #e8f7ef;
  --tag-green: #047857;
  --tag-amber-bg: #fff4df;
  --tag-amber: #b45309;
  --tag-gray-bg: #eef2f7;
  --tag-gray: #4b5563;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "Inter", "Segoe UI", "PingFang SC", sans-serif;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 230px 1fr;
}

.sidebar {
  border-right: 1px solid var(--line-dark);
  background: #f7f7f8;
  padding: 18px 14px;
}

.brand {
  font-size: 34px;
  font-family: "Georgia", serif;
  font-style: italic;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin-bottom: 18px;
}

.menu {
  margin-top: 18px;
  display: grid;
  gap: 4px;
}

.menu-item {
  text-decoration: none;
  color: var(--muted);
  font-size: 14px;
  border-radius: 10px;
  padding: 9px 10px;
}

.menu-item.active {
  color: #111827;
  background: #ededf0;
  font-weight: 600;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: 62px 1fr;
}

.workspace-header {
  border-bottom: 1px solid var(--line-dark);
  background: #f7f8fa;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
}

.workspace-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-btn {
  border: 1px solid var(--line-dark);
  background: #fff;
  color: #374151;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.workspace-content {
  min-height: 0;
  display: grid;
  grid-template-columns: 370px 1fr;
}

.workspace-content.table-collapsed {
  grid-template-columns: 1fr;
}

.workspace-content.table-collapsed .chat-panel {
  border-right: none;
}

.workspace-content.table-collapsed .table-panel {
  display: none;
}

.chat-panel {
  border-right: 1px solid var(--line-dark);
  background: #fafafa;
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 0;
}

.chat-scroller {
  padding: 16px;
  overflow: auto;
}

.slot-title {
  font-size: 13px;
  color: #4b5563;
  margin-bottom: 10px;
  font-weight: 600;
}

.dialogue-list {
  display: grid;
  gap: 10px;
}

.dialogue-item {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 12px 13px;
}

.dialogue-item.user {
  background: #f8fafc;
}

.dialogue-item.assistant {
  background: #ffffff;
}

.dialogue-text {
  font-size: 14px;
  line-height: 1.6;
  color: #1f2937;
}

.dialogue-points {
  margin: 8px 0 0;
  padding-left: 18px;
}

.dialogue-points li {
  font-size: 13px;
  line-height: 1.5;
  color: #4b5563;
  margin: 4px 0;
}

.dialogue-empty {
  border: 1px dashed var(--line-dark);
  border-radius: 12px;
  padding: 12px 13px;
  font-size: 13px;
  color: #6b7280;
  background: #fff;
}

.chat-input-panel {
  border-top: 1px solid var(--line-dark);
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.chat-input-panel label {
  font-size: 12px;
  color: #374151;
  font-weight: 600;
}

#queryInput,
#countInput {
  border: 1px solid var(--line-dark);
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: #fff;
}

#queryInput {
  width: 100%;
  resize: vertical;
  min-height: 90px;
  padding: 10px 11px;
}

#countInput {
  padding: 6px 8px;
}

.input-options {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.option-group {
  display: flex;
  align-items: center;
  gap: 7px;
}

.check-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #4b5563;
}

#searchBtn {
  border: none;
  border-radius: 10px;
  background: #111827;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 12px;
  cursor: pointer;
}

#searchBtn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.table-panel {
  background: #fff;
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 10px 0 0;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 14px 10px;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.view-switch {
  display: inline-flex;
  border: 1px solid var(--line-dark);
  border-radius: 999px;
  padding: 2px;
  background: #f9fafb;
}

.view-btn {
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #6b7280;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.view-btn.active {
  background: #111827;
  color: #fff;
}

.table-meta {
  color: #6b7280;
  font-size: 12px;
  font-weight: 600;
}

.network-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
}

.network-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2563eb;
  animation: network-pulse 1.2s ease-in-out infinite;
}

@keyframes network-pulse {
  0% {
    transform: scale(0.85);
    opacity: 0.5;
  }
  70% {
    transform: scale(1.2);
    opacity: 1;
  }
  100% {
    transform: scale(0.85);
    opacity: 0.5;
  }
}

.table-wrap {
  min-height: 0;
  overflow: auto;
  position: relative;
}

.result-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.result-table th,
.result-table td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid #f0f2f5;
  padding: 10px 9px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

.result-table th {
  position: sticky;
  top: 0;
  background: #fafbfc;
  font-size: 12px;
  color: #4b5563;
  z-index: 2;
}

.result-table tr:hover td {
  background: #fcfcfd;
}

.name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 180px;
}

.name-text,
.company-cell,
.title-cell {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.name-text {
  font-weight: 600;
}

.pill {
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}

.pill-match-full {
  background: var(--tag-green-bg);
  color: var(--tag-green);
}

.pill-match-partial {
  background: var(--tag-amber-bg);
  color: var(--tag-amber);
}

.pill-match-low {
  background: var(--tag-gray-bg);
  color: var(--tag-gray);
}

.social-link {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #0a66c2;
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.social-link.empty {
  background: #d1d5db;
  color: #4b5563;
}

.account-links {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.email-chip {
  border: 1px solid var(--line-dark);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  color: #4b5563;
}

.email-chip.pending {
  background: #f8fafc;
  color: #6b7280;
}

.email-fetch-btn {
  border: 1px solid var(--line-dark);
  border-radius: 999px;
  background: #fff;
  color: #4b5563;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 11px;
  cursor: pointer;
}

.email-fetch-btn:hover {
  background: #f9fafb;
}

.country-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.action-cell {
  display: inline-flex;
  gap: 6px;
}

.action-icon {
  width: 22px;
  height: 22px;
  border: 1px solid var(--line-dark);
  border-radius: 50%;
  color: #6b7280;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.table-empty {
  text-align: center;
  color: #6b7280;
  padding: 36px 10px;
}

.loading-mask {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.78);
  display: grid;
  place-items: center;
  font-weight: 600;
  color: #111827;
  z-index: 3;
}

.hidden {
  display: none;
}

@media (max-width: 1280px) {
  .workspace-content {
    grid-template-columns: 320px 1fr;
  }
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .workspace-content {
    grid-template-columns: 1fr;
  }

  .chat-panel {
    border-right: none;
    border-bottom: 1px solid var(--line-dark);
  }
}
