:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-2: #f9f9f9;
  --panel: #ffffff;
  --ink: #000000;
  --text: #111111;
  --muted: #6e6e80;
  --line: #000000;
  --line-light: #e5e5e5;
  --accent: #000000;
  --accent-strong: #000000;
  --danger: #111111;
  --warn: #111111;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}

body:not(.is-authenticated) {
  display: block;
}

body:not(.is-authenticated) .sidebar,
body:not(.is-authenticated) .shell {
  display: none;
}

body.is-authenticated .login-page {
  display: none;
}

[hidden],
.test-hidden {
  display: none !important;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background: #fff;
}

.login-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  padding: 32px;
  background: #fff;
}

.login-mark {
  margin-bottom: 20px;
}

.login-copy {
  margin: 12px 0 24px;
  color: var(--muted);
  font-size: 14px;
}

.login-form button {
  min-height: 42px;
}

.login-error {
  min-height: 20px;
  margin-top: 12px;
  color: #111;
  font-size: 13px;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--text);
  min-height: 34px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  border-color: #9aa4b2;
}

button:disabled {
  cursor: default;
  opacity: 0.58;
}

.sidebar {
  min-height: 100vh;
  padding: 24px 16px;
  border-right: 1px solid var(--line);
  background: #fff;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 60px;
  padding: 0 8px 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 0;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.brand span,
.eyebrow,
.meta {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  min-height: 40px;
  padding: 0 12px;
}

.nav-item.active {
  background: #000;
  color: #fff;
  font-weight: 700;
}

.shell {
  padding: 0 24px 28px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  min-height: 64px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.notification-wrap {
  position: relative;
  margin-left: auto;
}

.notification-button {
  min-width: 58px;
}

.notification-button span {
  font-weight: 700;
}

.notification-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 15;
  width: min(360px, calc(100vw - 40px));
  max-height: 360px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
}

.notification-menu[hidden] {
  display: none;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 16px;
}

.top-user-panel {
  display: flex;
  align-items: center;
  gap: 12px;
}

.token-form,
.inline-form {
  display: flex;
  gap: 8px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 16px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0;
}

.metric {
  padding: 14px;
}

.metric strong {
  display: block;
  font-size: 24px;
  margin-top: 6px;
}

.panel {
  padding: 16px;
  min-width: 0;
}

.panel.narrow {
  max-width: 720px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head.subhead {
  margin: 16px 0 10px;
}

.small-input {
  max-width: 160px;
}

.button-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.plugin-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.field-card {
  display: grid;
  gap: 6px;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.field-card span {
  color: var(--muted);
  font-size: 12px;
}

.field-card strong {
  word-break: break-all;
}

.followup-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(420px, 1.8fr) minmax(280px, 0.95fr);
  gap: 16px;
  align-items: start;
}

.list {
  display: grid;
  gap: 8px;
}

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

.row-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
}

.row p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.action-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.action-strip:empty {
  display: none;
}

.followup-reminder {
  margin-bottom: 12px;
}

.followup-contact {
  margin-bottom: 12px;
}

.followup-filter {
  margin-bottom: 12px;
}

.knowledge-filter {
  margin-bottom: 12px;
}

.lead-filter {
  margin-bottom: 12px;
}

.sourcing-filter {
  margin-bottom: 12px;
}

.event-filter {
  margin-bottom: 12px;
}

.task-filter {
  margin-bottom: 12px;
}

.auth-filter {
  margin: 12px 0;
}

.followup-filter select {
  min-width: 110px;
}

.queue-check {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 4px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  background: #eef2f6;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.badge.good {
  background: #dcfce7;
  color: #166534;
}

.badge.warn {
  background: #fef3c7;
  color: var(--warn);
}

.badge.bad {
  background: #fee4e2;
  color: var(--danger);
}

.stack-form {
  display: grid;
  gap: 10px;
}

.checkline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.checkline input {
  width: auto;
}

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

.reply-box {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.reply-box textarea {
  min-height: 96px;
  border: 0;
  padding: 4px;
  resize: vertical;
}

.reply-box textarea:focus {
  outline: none;
}

.reply-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.notice {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.notice-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  margin-top: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
}

.attachment-chip strong {
  flex: 0 0 auto;
  color: var(--text);
  font-size: 11px;
}

.attachment-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-chip button {
  min-height: auto;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  padding: 0;
  line-height: 18px;
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.attachment-link {
  min-height: auto;
  max-width: 100%;
}

.send-form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.stack-form button,
.token-form button,
.inline-form button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

.token-form.secondary button {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.secondary-button {
  background: #fff !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
  font-weight: 700;
}

.reply-ai-button {
  min-width: 118px;
}

.reply-ai-button:active {
  transform: translateY(1px);
}

.compact .row {
  padding: 8px 10px;
}

.scroll-list {
  max-height: 360px;
  overflow: auto;
  padding-right: 2px;
}

.markdown-box {
  white-space: pre-wrap;
  line-height: 1.55;
  color: var(--text);
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  font-size: 13px;
}

.markdown-render {
  white-space: pre-wrap;
}

.markdown-render h1,
.markdown-render h2 {
  margin: 0 0 10px;
}

.markdown-render h1 {
  font-size: 20px;
}

.markdown-render h2 {
  margin-top: 16px;
  font-size: 15px;
}

.markdown-render p {
  margin: 6px 0;
}

.markdown-render ul {
  margin: 6px 0 10px;
  padding-left: 18px;
}

.markdown-render li {
  margin: 4px 0;
}

.markdown-render a {
  color: var(--accent-strong);
  font-weight: 700;
}

.markdown-list {
  padding-left: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: start center;
  overflow: auto;
  padding: 24px;
  background: rgba(15, 23, 42, 0.38);
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(760px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.cookie-import-card {
  width: min(640px, 100%);
}

.cookie-import-hint {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted, #6b7280);
  white-space: pre-line;
}

.cookie-import-card textarea {
  width: 100%;
  box-sizing: border-box;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  resize: vertical;
}

.modal-body {
  max-height: 460px;
  overflow: auto;
}

.quick-material-options {
  min-width: 0;
  display: grid;
  gap: 10px;
  margin: 12px 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.quick-material-attachments {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.attachment-choice {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
}

.attachment-choice input {
  flex: 0 0 auto;
  width: auto;
}

.draft {
  margin: 12px 0 0;
  padding: 12px;
  border-radius: 6px;
  background: #f8fafc;
  border: 1px solid var(--line);
  white-space: pre-wrap;
  color: var(--text);
}

#toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #111827;
  color: #fff;
  opacity: 0;
  transform: translateY(8px);
  transition: 0.18s ease;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    position: static;
  }

  nav,
  .metric-grid,
  .split,
  .plugin-control-grid,
  .followup-grid,
  .topbar {
    grid-template-columns: 1fr;
    display: grid;
  }

  .token-form,
  .inline-form {
    flex-direction: column;
  }
}

:root {
  --bg-2: #f9f9f9;
  --ink: #000000;
  --sidebar: 260px;
}

.sprite {
  display: none;
}

body.is-authenticated {
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  padding: 24px 16px;
}

.brand {
  gap: 12px;
  margin-bottom: 8px;
}

.brand strong {
  display: block;
  font-weight: 600;
}

.brand span,
.user-chip small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

nav {
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  font-weight: 400;
}

.nav-item svg,
.top-actions svg,
.small-button svg,
.composer svg,
.search-box svg,
.primary-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex: 0 0 auto;
}

.nav-item.active {
  font-weight: 600;
}

.shell {
  padding: 0 24px 28px;
}

.topbar {
  margin-bottom: 0;
}

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

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--panel);
}

.notify-button {
  position: relative;
  min-width: 38px;
}

.notify-button span {
  position: absolute;
  right: -7px;
  top: -7px;
  min-width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--ink);
  color: var(--bg);
  font-size: 11px;
  line-height: 1;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-chip strong {
  display: block;
  color: var(--ink);
  font-weight: 600;
}

.avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.view {
  padding-top: 20px;
}

.view.active {
  display: block;
}

.view-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.view-head h2 {
  margin: 0;
  font-size: 20px;
  line-height: 28px;
}

.view-head.action-head {
  justify-content: flex-end;
  margin-bottom: 10px;
  padding-bottom: 0;
  border-bottom: 0;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--ink);
  color: var(--bg);
  font-weight: 700;
  white-space: nowrap;
}

.date-range-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.date-range-bar input,
.date-range-bar button {
  width: auto;
  min-width: 136px;
  min-height: 32px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.date-range-bar button {
  min-width: 68px;
  padding: 0 12px;
}

#sourcingMetrics.metric-grid {
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric-card {
  min-height: 78px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.metric-card span {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.metric-card strong {
  display: block;
  margin: 8px 0 3px;
  color: var(--ink);
  font-size: 24px;
  line-height: 30px;
  font-weight: 600;
}

.metric-card small {
  color: var(--muted);
}

.pool-switch {
  display: inline-flex;
  padding: 4px;
  margin: 2px 0 12px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.pool-switch button {
  min-height: 28px;
  padding: 0 12px;
  border: 0;
  color: var(--muted);
  background: transparent;
}

.pool-switch button.active {
  color: var(--bg);
  background: var(--ink);
}

.sourcing-layout {
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(380px, 1.05fr);
  gap: 12px;
  height: min(620px, calc(100vh - 258px));
  min-height: 500px;
  margin-bottom: 12px;
}

.queue-panel,
.detail-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.queue-panel .panel-head,
.detail-panel .panel-head {
  flex: 0 0 auto;
}

.diting-console-card {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 60px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  --diting-active-index: 0;
  --diting-progress-cells: 1;
}

.diting-motion-rail {
  min-width: 0;
}

.diting-rail-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  height: 22px;
  border: 1px solid var(--line);
  background: #fff;
  overflow: hidden;
}

.diting-rail-track::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0 auto 0 0;
  width: calc((100% / 7) * var(--diting-progress-cells));
  background: #111;
  opacity: 0.06;
}

.diting-rail-track::after {
  content: "";
  position: absolute;
  z-index: 4;
  top: -1px;
  bottom: -1px;
  left: calc((100% / 7) * var(--diting-active-index) + (100% / 14) - 1px);
  width: 2px;
  background: #111;
}

.diting-rail-track i {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  border-right: 1px solid var(--line);
}

.diting-rail-track em {
  position: relative;
  z-index: 2;
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: #fff;
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  white-space: nowrap;
}

.diting-rail-track i:last-of-type {
  border-right: 0;
}

.diting-rail-track i.done {
  background: #111;
  opacity: 0.11;
}

.diting-rail-track i.active {
  background: #111;
}

.diting-rail-track i.active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 5px;
  height: 5px;
  border: 1px solid #fff;
  background: #111;
  transform: translateX(-50%);
}

.diting-rail-track i.active.labeled::after {
  display: none;
}

.diting-console-card.state-action .diting-rail-track i.active {
  background: #fff;
  box-shadow: inset 0 0 0 2px #111;
}

.diting-console-card.state-action .diting-rail-track em {
  color: #111;
}

.diting-console-card.state-action .diting-rail-track i.active::after {
  border-color: #111;
  background: #111;
}

.diting-rail-track b {
  position: absolute;
  z-index: 3;
  top: -1px;
  bottom: -1px;
  left: -18%;
  width: 12%;
  background: #111;
  opacity: 0.12;
  transform: skewX(-12deg);
  animation: diting-rail-scan 2.8s cubic-bezier(0.45, 0, 0.2, 1) infinite;
}

.diting-console-card.mode-standby .diting-rail-track::after,
.diting-console-card.mode-standby .diting-rail-track b {
  display: none;
  animation: none;
}

.diting-console-card.mode-standby .diting-rail-track::before {
  width: 0;
}

.diting-mini-lanes {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.diting-mini-lanes span {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
  overflow: hidden;
}

.diting-mini-lanes i {
  position: relative;
  z-index: 1;
  width: 6px;
  height: 6px;
  border: 1px solid var(--line);
  background: #fff;
}

.diting-mini-lanes span::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  background: #111;
  opacity: 0.1;
  transform: scaleX(0.18);
  transform-origin: left;
}

.diting-mini-lanes span.active i {
  background: #111;
}

.diting-mini-lanes span.active::after {
  opacity: 0.35;
}

@keyframes diting-rail-scan {
  0% {
    left: -14%;
    opacity: 0;
  }
  12% {
    opacity: 0.12;
  }
  88% {
    opacity: 0.12;
  }
  100% {
    left: 104%;
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .diting-rail-track b {
    animation: none;
  }
}

#sourcingList,
#leadDetail,
#cardList,
#cardDetailBlock {
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

#sourcingList {
  flex: 1 1 auto;
}

.stack-list {
  display: grid;
  gap: 8px;
}

.stack-row {
  width: 100%;
  padding: 10px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel);
}

#sourcingList .stack-row {
  display: grid;
  gap: 6px;
  min-height: 96px;
  max-height: 118px;
  overflow: hidden;
  align-content: start;
}

#sourcingList .stack-row .row-title {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  justify-content: space-between;
  min-width: 0;
}

#sourcingList .stack-row .row-title strong {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#sourcingList .stack-row .badge {
  flex: 0 0 auto;
}

#sourcingList .stack-row p {
  min-width: 0;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 20px;
  overflow: hidden;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

#sourcingList .stack-row p:first-of-type {
  -webkit-line-clamp: 1;
}

.selectable:hover {
  background: #f9f9f9;
}

.selectable.active {
  border-color: var(--ink);
  background: #f2f2f2;
}

.row,
.modal-card,
.markdown-box,
.reply-box,
.notice,
.draft,
.attachment-chip,
.quick-material-options,
.attachment-choice {
  border-radius: 0;
}

.badge {
  border-radius: 0;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--muted);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.lead-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.detail-block {
  display: grid;
  gap: 10px;
}

.evidence-card {
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--bg-2);
}

.evidence-card h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.evidence-card p {
  margin: 0;
}

.lead-detail-line {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.lead-detail-line > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.lead-detail-line strong {
  font-size: 13px;
}

.lead-detail-line span {
  color: var(--muted);
  font-size: 12px;
}

.lead-detail-line-body {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 22px;
  overflow-wrap: anywhere;
}

.lead-detail-line-body p,
.lead-detail-line-body ul {
  margin: 0;
}

.lead-detail-line-body p + p,
.lead-detail-line-body ul + p,
.lead-detail-line-body p + ul {
  margin-top: 6px;
}

.lead-detail-line-body ul {
  padding-left: 18px;
}

.lead-link {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.lead-evidence-chain {
  display: grid;
  gap: 10px;
}

.lead-evidence-chain .lead-detail-line {
  background: var(--bg-2);
}

.score-box {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.score-box strong {
  grid-column: 1 / -1;
  font-size: 18px;
  line-height: 24px;
}

.score-box span {
  padding: 6px;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  line-height: 16px;
  text-align: center;
}

.social-score {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.score-reasons {
  grid-column: 1 / -1;
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.score-reasons li {
  font-size: 12px;
  line-height: 18px;
  padding: 2px 6px;
  border-radius: 4px;
}

.score-reasons .score-good {
  color: var(--good, #15803d);
  background: color-mix(in srgb, var(--good, #15803d) 8%, transparent);
}

.score-reasons .score-missing {
  color: var(--warn, #b45309);
  background: color-mix(in srgb, var(--warn, #b45309) 8%, transparent);
}

.score-reasons .score-risk {
  color: var(--bad, #b91c1c);
  background: color-mix(in srgb, var(--bad, #b91c1c) 8%, transparent);
}

.lead-toolbar {
  min-width: 160px;
}

.diting-button {
  min-width: 168px;
}

.diting-button.searching svg {
  animation: diting-pulse 900ms linear infinite;
}

.diting-button.active-search {
  background: var(--ink);
  color: var(--bg);
}

.diting-button.active-search:hover {
  background: #fff;
  color: var(--ink);
}

@keyframes diting-pulse {
  0% { transform: scale(1); opacity: 0.65; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 0.65; }
}

.module-tabs,
.segmented {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.module-tabs button,
.segmented button {
  min-height: 28px;
  padding: 0 12px;
  border: 0;
  color: var(--muted);
  background: transparent;
}

.module-tabs button.active,
.segmented button.active {
  color: var(--bg);
  background: var(--ink);
}

.module-tabs.small-tabs {
  width: 100%;
  margin: 0 0 12px;
}

.module-tabs.small-tabs button {
  flex: 1 1 auto;
}

.search-box {
  height: 38px;
  min-width: 310px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
}

.search-box.slim {
  min-width: 0;
  width: 100%;
  margin-bottom: 12px;
}

.search-box svg,
.primary-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex: 0 0 auto;
}

.search-box input {
  min-height: unset;
  padding: 0;
  border: 0;
  background: transparent;
}

.material-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px;
  height: min(780px, calc(100vh - 210px));
  min-height: 620px;
}

.material-create-panel,
.material-list-panel {
  min-height: 0;
  overflow: auto;
}

.material-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 12px;
}

.material-list {
  display: grid;
  gap: 8px;
}

.material-row {
  width: 100%;
  display: grid;
  gap: 8px;
  padding: 12px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel);
}

.material-row:hover {
  background: #f2f2f2;
}

.material-row p {
  margin: 0;
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.upload-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--bg-2);
}

.upload-box p {
  margin: 0;
}

.material-upload-preview {
  min-height: 34px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.followup-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 320px;
  gap: 16px;
  height: min(820px, calc(100vh - 250px));
  min-height: 560px;
}

.thread-list, .chat-panel, .ai-rail { min-width: 0; }

.thread-list {
  height: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  overflow: auto;
}

.thread-button {
  width: 100%;
  min-height: 74px;
  padding: 12px;
  margin-bottom: 8px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.thread-button.active {
  border-color: var(--ink);
  background: #f2f2f2;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  height: 100%;
  min-height: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
}

.thread-header {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.permission-banner {
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  line-height: 20px;
}

.message-timeline {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 18px;
  overflow: auto;
}

.message {
  max-width: 76%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--bg-2);
}

.message.outbound {
  align-self: flex-end;
  color: var(--bg);
  border-color: var(--ink);
  background: var(--ink);
}

.message.internal {
  max-width: 86%;
  border-style: dashed;
  background: #ffffff;
  color: var(--muted);
}

.message .meta {
  display: block;
  margin-bottom: 6px;
  color: inherit;
  opacity: 0.72;
  font-size: 11px;
}

.message-body {
  white-space: pre-wrap;
  word-break: break-word;
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.composer {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
}

.composer-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 120px auto;
  gap: 8px;
  align-items: stretch;
}

.composer-tools {
  display: flex;
  gap: 6px;
}

.composer .composer-tools button,
.composer .attachment-chip {
  color: var(--text);
  background: var(--panel);
  border-color: var(--line);
}

.attachment-menu-wrap {
  position: relative;
}

.composer .plus-button {
  width: 42px;
  padding: 0;
}

.composer .plus-button svg {
  width: 20px;
  height: 20px;
}

.attachment-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 5;
  width: 188px;
  padding: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

.attachment-menu::after {
  content: "";
  position: absolute;
  left: 14px;
  bottom: -6px;
  width: 10px;
  height: 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  transform: rotate(45deg);
}

.attachment-menu button {
  width: 100%;
  justify-content: flex-start;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--text);
}

.attachment-menu button:hover {
  background: #f2f2f2;
}

.attachment-menu svg {
  width: 17px;
  height: 17px;
}

.composer .bot-button {
  width: 42px;
  padding: 0;
  position: relative;
  color: var(--bg);
  background: var(--ink);
  border-color: var(--ink);
}

.composer .bot-button svg {
  width: 19px;
  height: 19px;
}

.composer .bot-button::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid transparent;
  pointer-events: none;
}

.composer .bot-button:hover::after,
.composer .bot-button.thinking::after {
  border-color: var(--bg);
}

.composer .bot-button.thinking svg {
  animation: botThinking 760ms ease-in-out infinite;
}

@keyframes botThinking {
  0%, 100% { transform: translateY(0); opacity: 1; }
  50% { transform: translateY(-2px); opacity: 0.65; }
}

.composer textarea {
  min-height: 42px;
  max-height: 96px;
  resize: none;
}

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

.attachment-chip {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  font-size: 12px;
}

.attachment-chip svg {
  width: 15px;
  height: 15px;
}

.attachment-chip span {
  color: var(--muted);
}

.plugin-action-bar,
.readonly-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
}

.readonly-bar {
  color: var(--muted);
  font-size: 13px;
}

.compact-panel { margin-bottom: 16px; }

.ai-rail {
  display: grid;
  grid-template-rows: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 16px;
  height: 100%;
  overflow: hidden;
}

.ai-rail .compact-panel {
  min-height: 0;
  margin-bottom: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.ai-rail .quick-panel {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.quick-reply-controls {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.quick-reply-controls input {
  min-height: 34px;
  font-size: 13px;
}

.quick-filter-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid var(--line);
}

.quick-filter-tabs button {
  min-height: 30px;
  padding: 0 6px;
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
}

.quick-filter-tabs button:last-child {
  border-right: 0;
}

.quick-filter-tabs button.active {
  background: var(--ink);
  color: var(--bg);
}

.quick-reply-list {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
  max-width: 100%;
}

.quick-reply-item {
  width: 100%;
  min-width: 0;
  display: grid;
  gap: 6px;
  padding: 10px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
}

.quick-reply-item:hover {
  background: #f2f2f2;
}

.quick-reply-item span,
.quick-reply-item small {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
  overflow-wrap: anywhere;
}

.quick-reply-item strong {
  min-width: 0;
  display: block;
  color: var(--text);
  white-space: normal;
  line-height: 20px;
}

.quick-reply-item span {
  display: block;
  overflow: visible;
}

.quick-reply-item small {
  display: block;
  overflow: visible;
}

.followup-profile {
  height: 100%;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  font-size: 13px;
  line-height: 22px;
  white-space: normal;
}

.followup-profile h1,
.quick-material-copy h1 {
  margin: 0 0 12px;
  font-size: 16px;
  line-height: 24px;
}

.followup-profile h2,
.quick-material-copy h2 {
  margin: 16px 0 6px;
  font-size: 13px;
  line-height: 20px;
}

.followup-profile p,
.quick-material-copy p {
  margin: 4px 0;
  color: var(--text);
  font-size: 13px;
  line-height: 22px;
}

.quick-material-dialog-body {
  display: grid;
  gap: 14px;
  max-height: min(560px, calc(100vh - 260px));
  overflow: auto;
}

.quick-material-view {
  display: grid;
  gap: 14px;
}

.quick-material-copy {
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--bg-2);
}

.quick-material-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.quick-material-file {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

.quick-material-image img {
  width: 100%;
  height: 180px;
  display: block;
  object-fit: cover;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}

.quick-material-image figcaption,
.quick-material-pdf a,
.quick-material-link {
  min-width: 0;
  padding: 10px;
  font-size: 13px;
  line-height: 20px;
  overflow-wrap: anywhere;
}

.quick-material-pdf {
  display: grid;
  grid-template-rows: 220px auto;
}

.quick-material-pdf iframe {
  width: 100%;
  height: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}

.quick-material-pdf a {
  display: block;
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.quick-material-link {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.button-link {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

.quick-material-link span,
.attachment-choice span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.attachment-choice {
  align-items: flex-start;
}

.attachment-choice strong {
  flex: 1 1 auto;
  min-width: 0;
  display: block;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.settings-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 16px;
  min-height: min(760px, calc(100vh - 210px));
}

.settings-nav {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--bg-2);
}

.settings-nav button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
}

.settings-nav button.active,
.settings-nav button:hover {
  border-color: var(--line);
  background: var(--panel);
}

.settings-content {
  min-height: 0;
  overflow: auto;
}

.settings-panel {
  display: none;
}

.settings-panel.active {
  display: block;
}

.settings-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.settings-section-head h3 {
  margin: 0;
}

.settings-note {
  max-width: 860px;
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.6;
}

.settings-subsection {
  margin-bottom: 18px;
}

.settings-subhead {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.settings-subhead h4 {
  margin: 0;
  font-size: 15px;
}

.settings-subhead span {
  color: var(--muted);
  font-size: 12px;
}

.settings-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.settings-form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

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

.settings-form-grid button {
  align-self: end;
}

.settings-filter {
  margin-bottom: 10px;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.preset-card {
  min-height: 74px;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  text-align: left;
}

.preset-card:hover {
  background: var(--bg-2);
}

.preset-card strong,
.preset-card span {
  display: block;
}

.preset-card strong {
  margin-bottom: 6px;
}

.preset-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.authorization-platform-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 12px;
}

.authorization-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.authorization-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.authorization-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 16px;
}

.authorization-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.authorization-meta {
  font-size: 12px;
}

.authorization-hint {
  font-size: 12px;
  color: #6b7280;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 8px 10px;
  line-height: 1.5;
}
.authorization-hint strong {
  color: #155e75;
}

.authorization-card .row-actions {
  justify-content: flex-start;
  margin-top: 0;
}

.authorization-card .button-link.primary-button {
  background: var(--ink);
  color: var(--bg);
  font-weight: 700;
}

.browser-login-card {
  width: min(1500px, calc(100vw - 48px));
  max-width: none;
  max-height: calc(100vh - 48px);
}

.browser-login-body {
  display: grid;
  gap: 12px;
}

.browser-login-card .modal-body {
  max-height: none;
  overflow: visible;
}

.browser-login-actions {
  justify-content: flex-start;
  margin: 0;
}

.browser-login-status {
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.browser-login-status.good {
  color: var(--text);
  font-weight: 700;
}

.browser-login-status.warn {
  color: #8a5a00;
}

.browser-login-status.bad {
  color: var(--danger);
}

.browser-login-body p {
  margin: 0;
  line-height: 1.6;
}

.browser-login-url {
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--muted);
  overflow-wrap: anywhere;
}

.browser-login-frame-wrap {
  min-height: 680px;
  border: 1px solid var(--line);
  background: #111;
  overflow: hidden;
}

.browser-login-frame-wrap iframe {
  display: block;
  width: 100%;
  height: min(78vh, 900px);
  min-height: 680px;
  border: 0;
  background: #111;
}

.settings-list {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.settings-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.settings-row .row-actions {
  justify-content: flex-end;
  margin-top: 0;
}

.plugin-settings-layout .settings-content {
  padding: 16px;
}

@media (max-width: 1180px) {
  :root {
    --sidebar: 220px;
  }

  .followup-layout {
    grid-template-columns: 280px minmax(0, 1fr);
    height: auto;
    min-height: 0;
  }

  .chat-panel {
    height: min(720px, calc(100vh - 260px));
    min-height: 0;
  }

  .ai-rail {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: none;
    height: auto;
    overflow: visible;
  }
}

@media (max-width: 900px) {
  body.is-authenticated {
    grid-template-columns: 1fr;
  }

  .sourcing-layout,
  #sourcingMetrics.metric-grid,
  .lead-detail-grid,
  .material-layout,
  .followup-layout,
  .settings-layout,
  .preset-grid,
  .authorization-platform-grid,
  .settings-form-grid,
  .settings-row {
    grid-template-columns: 1fr;
    height: auto;
  }

  .settings-subhead {
    align-items: start;
    flex-direction: column;
  }

  .chat-panel {
    height: 640px;
  }

  .ai-rail {
    height: auto;
    overflow: visible;
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }
}

/* ============= 名片中心 ============= */

#cards .module-tabs { margin-right: auto; }

/* 数据表格 */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 4px;
}
.data-table th,
.data-table td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}
.data-table th {
  background: var(--bg-2);
  font-weight: 600;
  font-size: 11px;
  white-space: nowrap;
}
.data-table tr:nth-child(even) {
  background: var(--bg-2);
}

/* 验证时间线 */
.card-timeline {
  display: grid;
  gap: 6px;
  font-size: 12px;
}
.timeline-row {
  display: grid;
  grid-template-columns: 130px 1fr auto 40px;
  gap: 8px;
  align-items: start;
  padding: 4px 0;
  border-bottom: 1px solid var(--line-light);
}
.timeline-time {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.timeline-event {
  color: var(--text);
  line-height: 1.4;
}
.timeline-source {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.timeline-conf {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

/* 名片详情评分框 */
.card-detail-grid .score-box {
  margin-bottom: 8px;
}

.empty-panel {
  padding: 48px 24px;
  border: 1px solid var(--line);
  text-align: center;
}
.empty-panel p { color: var(--muted); margin-bottom: 16px; }

/* 名片行 */
#cardList .stack-row {
  display: grid;
  gap: 6px;
  min-height: 78px;
  max-height: 96px;
  overflow: hidden;
  align-content: start;
}
#cardList .stack-row .row-title {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  justify-content: space-between;
  min-width: 0;
}
#cardList .stack-row .row-title strong {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
#cardList .stack-row .badge { flex: 0 0 auto; }
#cardList .stack-row p {
  min-width: 0;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 20px;
  overflow: hidden;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* 名片详情 */
.card-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

/* 导入模态框 */
.import-drop {
  padding: 32px;
  border: 2px dashed var(--line);
  text-align: center;
  background: var(--bg-2);
}
.import-drop .link {
  text-decoration: underline;
  cursor: pointer;
}
.import-file-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}
.import-file-list .row {
  padding: 8px;
}
.import-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}
.import-log {
  max-height: 200px;
  overflow: auto;
  font-size: 12px;
  background: var(--bg-2);
  padding: 8px;
  border: 1px solid var(--line);
}
.import-log .row {
  padding: 6px;
  margin-bottom: 0;
}
.import-done-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
  flex-wrap: wrap;
}
.progress-track {
  height: 8px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  overflow: hidden;
}
.progress-thumb {
  height: 100%;
  background: var(--ink);
  width: 0;
  transition: width .3s ease;
}

@media (max-width: 900px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  body.is-authenticated {
    display: block;
    min-height: 100vh;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 12;
    min-height: 0;
    padding: 8px 10px 6px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    min-height: 0;
    margin: 0 0 6px;
    padding: 0 2px;
    border-bottom: 0;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
  }

  nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 2px 0 4px;
    -webkit-overflow-scrolling: touch;
  }

  .nav-item {
    flex: 0 0 auto;
    width: auto;
    min-width: 82px;
    min-height: 38px;
    justify-content: center;
    gap: 6px;
    padding: 0 10px;
    border: 1px solid var(--line);
    white-space: nowrap;
  }

  .nav-item svg {
    width: 16px;
    height: 16px;
  }

  .shell {
    padding: 0 12px calc(24px + env(safe-area-inset-bottom));
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    min-height: 0;
    gap: 10px;
    padding: 12px 0;
    margin-bottom: 0;
  }

  .topbar h1 {
    font-size: 22px;
    line-height: 30px;
  }

  .top-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
    margin-left: 0;
  }

  .notification-wrap {
    margin-left: 0;
  }

  .notification-menu {
    left: 0;
    right: auto;
    width: min(360px, calc(100vw - 24px));
    max-height: 70vh;
  }

  .user-chip {
    min-width: 0;
    flex: 1 1 160px;
  }

  .user-chip > div {
    min-width: 0;
  }

  .user-chip strong,
  .user-chip small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  button,
  input,
  select,
  textarea {
    min-width: 0;
  }

  button {
    min-height: 38px;
  }

  .view {
    padding-top: 12px;
  }

  .view.active {
    display: block;
  }

  .view-head,
  .panel-head,
  .settings-section-head,
  .settings-subhead,
  .authorization-card-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .view-head.action-head {
    justify-content: stretch;
  }

  .view-head.action-head .primary-button,
  .diting-button,
  #importCardsBtn {
    width: 100%;
  }

  .panel {
    padding: 12px;
  }

  .metric-grid,
  #sourcingMetrics.metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .date-range-bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .date-range-bar input,
  .date-range-bar button {
    width: 100%;
    min-width: 0;
  }

  .pool-switch,
  .module-tabs,
  .segmented {
    width: 100%;
    overflow-x: auto;
  }

  .pool-switch button,
  .module-tabs button,
  .segmented button {
    flex: 1 0 auto;
  }

  .sourcing-layout,
  .material-layout,
  .settings-layout,
  .plugin-settings-layout,
  .followup-layout {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    min-height: 0;
  }

  .queue-panel,
  .detail-panel,
  .material-create-panel,
  .material-list-panel,
  .settings-content {
    min-height: 0;
    overflow: visible;
  }

  #sourcingList,
  #leadDetail,
  #cardList,
  #cardDetailBlock {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  #sourcingList .stack-row,
  #cardList .stack-row {
    max-height: none;
  }

  .diting-console-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    min-height: 76px;
    padding: 12px;
  }

  .diting-mini-lanes {
    justify-content: flex-start;
  }

  #sourcingList .stack-row .row-title,
  #cardList .stack-row .row-title,
  .row-title {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  #sourcingList .stack-row .row-title strong,
  #cardList .stack-row .row-title strong {
    white-space: normal;
  }

  .lead-detail-grid,
  .card-detail-grid,
  .settings-form-grid,
  .authorization-platform-grid,
  .quick-material-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .score-box {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .score-box strong {
    grid-column: 1 / -1;
  }

  .material-toolbar,
  .composer-main,
  .settings-row,
  .timeline-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 8px;
    -webkit-overflow-scrolling: touch;
  }

  .settings-nav button {
    flex: 0 0 auto;
    min-width: 112px;
    text-align: center;
    white-space: nowrap;
  }

  .preset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-strip {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .action-strip .module-tabs {
    margin-bottom: 0;
  }

  .small-input {
    max-width: none;
  }

  .row-actions,
  .browser-login-actions,
  .import-actions,
  .import-done-actions {
    width: 100%;
    justify-content: stretch;
  }

  .row-actions > *,
  .browser-login-actions > *,
  .import-actions > *,
  .import-done-actions > * {
    flex: 1 1 auto;
  }

  .data-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
  }

  .modal {
    place-items: stretch;
    padding: 10px;
  }

  .modal-card,
  .modal-card.wide,
  .browser-login-card {
    width: 100%;
    max-height: calc(100vh - 20px);
    padding: 12px;
  }

  .modal-body {
    max-height: calc(100vh - 190px);
  }

  .browser-login-card .modal-body {
    max-height: none;
  }

  .browser-login-frame-wrap {
    min-height: 62vh;
  }

  .browser-login-frame-wrap iframe {
    height: 62vh;
    min-height: 62vh;
  }

  .quick-material-dialog-body {
    max-height: calc(100vh - 280px);
  }

  #wechatExportText {
    min-height: 55vh;
  }

  #toast {
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    max-width: none;
  }
}

@media (max-width: 520px) {
  .login-page {
    padding: 16px;
  }

  .login-card {
    padding: 22px;
  }

  .brand span {
    display: none;
  }

  .nav-item {
    min-width: 72px;
    padding: 0 8px;
    font-size: 13px;
  }

  .nav-item svg {
    display: none;
  }

  .top-actions .icon-button {
    width: 36px;
    height: 36px;
  }

  .metric-grid,
  #sourcingMetrics.metric-grid,
  .preset-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .date-range-bar {
    grid-template-columns: minmax(0, 1fr);
  }

  .panel-head > * {
    min-width: 0;
  }

  .browser-login-frame-wrap,
  .browser-login-frame-wrap iframe {
    min-height: 58vh;
    height: 58vh;
  }
}
