.ib-clients-app {
  background: #f4f6fa;
}

body[data-layout-page="ib-clients"] [hidden] {
  display: none !important;
}

.ib-clients-page {
  min-height: calc(100vh - var(--app-chrome-height, 131px));
  padding: 24px 24px 64px;
}

.ib-clients-shell {
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
}

.ib-clients-heading {
  margin-bottom: 18px;
  padding: 0 2px;
}

.ib-clients-heading h1 {
  margin: 0;
  color: #0f172a;
  font-size: 28px;
  line-height: 1.18;
  font-weight: 900;
  letter-spacing: 0;
}

.ib-clients-heading p {
  max-width: 720px;
  margin: 8px 0 0;
  color: #64748b;
  font-size: 13px;
  line-height: 1.6;
  font-weight: 700;
}

.ib-client-filter,
.ib-client-table-card {
  border: 1px solid #dce6f4;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.05);
}

.ib-client-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.ib-metric-card {
  min-width: 0;
  min-height: 104px;
  display: grid;
  align-content: center;
  gap: 11px;
  padding: 16px 18px;
  border: 1px solid #dbe7f8;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.045);
}

.ib-metric-heading {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ib-metric-heading > span:last-child {
  min-width: 0;
  color: #64748b;
  font-size: 12px;
  line-height: 1.3;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.ib-metric-icon {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.ib-metric-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.ib-metric-card strong {
  display: block;
  overflow: hidden;
  color: #0f172a;
  font-size: clamp(26px, 2vw, 30px);
  line-height: 1;
  font-weight: 950;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ib-metric-card.tone-blue {
  border-color: #d7e6fb;
  background: #f8fbff;
}

.ib-metric-card.tone-blue .ib-metric-icon {
  background: #eef5ff;
  color: var(--blue);
}

.ib-metric-card.tone-sky {
  border-color: #cfe3ff;
  background: #f3f8ff;
}

.ib-metric-card.tone-sky .ib-metric-icon {
  background: #dbeafe;
  color: var(--blue-ink);
}

.ib-metric-card.tone-violet {
  border-color: #ddd0ff;
  background: #f7f4ff;
}

.ib-metric-card.tone-violet .ib-metric-icon {
  background: #ede3ff;
  color: #7c3aed;
}

.ib-metric-card.tone-green {
  border-color: #b9f2cb;
  background: #f0fff6;
}

.ib-metric-card.tone-green .ib-metric-icon {
  background: #d5fbe4;
  color: #059669;
}

.ib-metric-card.tone-green strong {
  color: #059669;
  font-size: clamp(26px, 2vw, 30px);
  white-space: nowrap;
}

.ib-client-filter {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
  gap: 16px 14px;
  padding: 20px;
}

.ib-filter-heading {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 2px;
}

.ib-filter-heading h2,
.ib-table-heading h2 {
  margin: 0;
  color: var(--text-strong, #0f172a);
  font-size: 16px;
  line-height: 1.35;
  font-weight: 900;
}

.ib-filter-heading p,
.ib-table-heading p {
  margin: 5px 0 0;
  color: var(--text-soft, #64748b);
  font-size: 12px;
  line-height: 1.5;
  font-weight: 700;
}

.ib-client-filter label {
  min-width: 0;
  display: grid;
  gap: 8px;
  color: #0f172a;
  font-size: 12px;
  font-weight: 850;
}

.ib-client-filter label > span {
  color: #64748b;
  font-size: 12px;
  line-height: 1.2;
  font-weight: 850;
}

.ib-client-filter input,
.ib-client-filter select {
  width: 100%;
  height: 46px;
  min-width: 0;
  border: 1px solid #d8e1ef;
  border-radius: 10px;
  background: #fff;
  color: #0f172a;
  font: inherit;
  font-size: 13px;
  font-weight: 850;
}

.ib-client-filter input,
.ib-client-filter select {
  padding: 0 12px;
}

.ib-client-filter .ib-date-range {
  width: 100%;
  height: 46px;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  border: 1px solid #d8e1ef;
  border-radius: 10px;
  background: #fff;
}

.ib-client-filter .ib-date-range input {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 13px;
}

.ib-date-range i {
  color: #94a3b8;
  font-style: normal;
}

.ib-client-filter .ib-filter-check {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #64748b;
  font-size: 12px;
  font-weight: 850;
}

.ib-client-filter .ib-filter-check input {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--blue);
}

.ib-client-filter input::placeholder {
  color: #a8b2c3;
}

.ib-search-field {
  height: auto;
  display: grid !important;
  gap: 8px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.ib-search-control {
  width: 100%;
  height: 46px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid #d8e1ef;
  border-radius: 10px;
  background: #fff;
}

.ib-search-control svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  color: #64748b;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.ib-search-control input {
  height: 100%;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 0;
}

.ib-filter-actions,
.ib-table-tools,
.ib-footer-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ib-filter-actions {
  grid-column: 3 / -1;
  align-self: stretch;
  align-items: stretch;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.ib-primary-action,
.ib-secondary-action,
.ib-icon-action {
  width: auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
}

.ib-primary-action,
.ib-secondary-action {
  height: 42px;
  gap: 8px;
  padding: 0 15px;
}

.ib-primary-action {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #fff;
  box-shadow: 0 10px 20px rgba(var(--blue-rgb), 0.17);
}

.ib-secondary-action {
  border: 1px solid #bfdbfe;
  background: #fff;
  color: var(--blue-ink);
}

.ib-icon-action {
  width: 38px;
  height: 38px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--blue-ink);
}

.ib-primary-action svg,
.ib-secondary-action svg,
.ib-icon-action svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.ib-client-filter .ib-primary-action,
.ib-client-filter .ib-secondary-action {
  height: 46px;
  border-radius: 10px;
  padding: 0 15px;
}

.ib-client-table-card {
  margin-top: 20px;
  overflow: hidden;
}

.ib-client-table-toolbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #edf1f7;
  background: #fbfdff;
}

.ib-table-heading {
  min-width: 0;
}

.ib-client-table-wrap {
  overflow: auto;
}

.ib-client-table {
  width: 100%;
  /* 基线列数是 15 列，1120px 会把注册时间和最近跟进压成两行，
     所以下限抬到能一行放完所有列的宽度，横向滚动交给 .ib-client-table-wrap。 */
  min-width: 1880px;
  border-collapse: collapse;
  color: #0f172a;
}

.ib-client-table th,
.ib-client-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #edf1f7;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.ib-client-table th {
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  font-weight: 900;
}

.ib-client-tags {
  max-width: 240px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ib-client-tag {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--blue-ink);
  font-size: 10px;
  font-weight: 900;
}

.ib-client-tag.green {
  border-color: #bbf7d0;
  background: #ecfdf5;
  color: #047857;
}

.ib-client-tag.amber {
  border-color: #fde68a;
  background: #fffbeb;
  color: #b45309;
}

.ib-client-tag.purple {
  border-color: #ddd6fe;
  background: #f5f3ff;
  color: #7c3aed;
}

.ib-client-tag.red {
  border-color: #fecaca;
  background: #fff1f2;
  color: #dc2626;
}

.ib-client-tag.slate {
  border-color: #e2e8f0;
  background: #f8fafc;
  color: #64748b;
}

.ib-client-tag-empty {
  color: #94a3b8;
}

:root[data-theme="dark"] .ib-client-tag {
  border-color: rgba(96, 165, 250, 0.32);
  background: rgba(96, 165, 250, 0.14);
  color: #93c5fd;
}

:root[data-theme="dark"] .ib-client-tag.green {
  border-color: rgba(52, 211, 153, 0.28);
  background: rgba(52, 211, 153, 0.12);
  color: #6ee7b7;
}

.ib-client-table td {
  background: #fff;
  font-size: 13px;
  line-height: 1.45;
}

.ib-client-table tbody tr:hover td {
  background: #fbfdff;
}

.ib-client-table th.actions-column,
.ib-client-table td.actions-cell {
  position: sticky;
  right: 0;
  min-width: 92px;
  width: 92px;
  background: #fff;
  box-shadow: -10px 0 18px rgba(15, 23, 42, 0.06);
}

.ib-client-table th.actions-column {
  z-index: 6;
  background: #f8fafc;
}

.ib-client-table td.actions-cell {
  z-index: 4;
}

.ib-client-name,
.ib-client-contact,
.ib-client-money,
.ib-client-date {
  display: grid;
  gap: 5px;
  line-height: 1.35;
}

.ib-client-name strong,
.ib-client-contact strong,
.ib-client-money strong,
.ib-client-date strong {
  max-width: 150px;
  overflow: hidden;
  color: #0f172a;
  font-weight: 950;
  text-overflow: ellipsis;
}

.ib-client-name small,
.ib-client-contact small,
.ib-client-money small,
.ib-client-date small,
.ib-client-table td small {
  display: block;
  max-width: 150px;
  overflow: hidden;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
}

/* ---------- 基线列：邮箱 / 金额 / 计数 / 时间 / 备注 ---------- */
.ib-client-email,
.ib-client-time,
.ib-client-remark {
  display: block;
  overflow: hidden;
  color: #0f172a;
  font-weight: 800;
  text-overflow: ellipsis;
}

.ib-client-time {
  color: #475569;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.ib-client-remark {
  max-width: 160px;
}

.ib-client-empty {
  color: #94a3b8;
  font-weight: 800;
}

/* 金额与计数列右对齐并锁等宽数字，扫一列的时候个位能对齐 */
.ib-client-table th.is-numeric,
.ib-client-table td.is-numeric {
  text-align: right;
}

.ib-client-amount {
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.ib-chip {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

/* 状态点跟文字同色：已创建/未创建 在一列里靠颜色先被看见，文字只是确认 */
.ib-chip::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.ib-chip.green {
  background: #ecfdf5;
  color: #047857;
}

.ib-chip.amber {
  background: #fffbeb;
  color: #b45309;
}

.ib-chip.slate {
  background: #f1f5f9;
  color: #64748b;
}

.ib-chip.blue {
  background: #eff6ff;
  color: var(--blue-ink);
}

.ib-row-action {
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: var(--blue-ink);
  font-size: 11px;
  font-weight: 900;
}

.ib-empty-state {
  padding: 42px 20px;
  color: #64748b;
  font-weight: 850;
  text-align: center;
}

.ib-table-footer {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 16px;
}

.ib-footer-left {
  color: #64748b;
  font-size: 12px;
  font-weight: 850;
}

.ib-page-size {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ib-page-size select {
  height: 32px;
  padding: 0 10px;
  border: 1px solid #d8e1ef;
  border-radius: 8px;
  background: #fff;
  color: #0f172a;
  font-weight: 850;
}

.ib-pager {
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid #d8e1ef;
  border-radius: 10px;
}

.ib-pager button {
  min-width: 36px;
  height: 32px;
  border: 0;
  border-left: 1px solid #d8e1ef;
  background: #fff;
  color: #64748b;
  font-weight: 900;
}

.ib-pager button:first-child {
  border-left: 0;
}

.ib-pager button.active {
  background: var(--blue);
  color: #fff;
}

.ib-pager button:disabled {
  color: #cbd5e1;
}

.ib-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  justify-content: flex-end;
  background: rgba(15, 23, 42, 0.36);
}

.ib-client-drawer {
  width: min(520px, 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #fff;
  box-shadow: -20px 0 60px rgba(15, 23, 42, 0.2);
}

.ib-client-drawer header,
.ib-client-drawer footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 22px;
  border-bottom: 1px solid #edf1f7;
}

.ib-client-drawer footer {
  justify-content: flex-end;
  border-top: 1px solid #edf1f7;
  border-bottom: 0;
}

.ib-client-drawer header span {
  color: #64748b;
  font-size: 12px;
  font-weight: 850;
}

.ib-client-drawer h2 {
  margin: 5px 0 0;
  color: #0f172a;
  font-size: 24px;
  font-weight: 950;
}

.ib-drawer-body {
  flex: 1;
  overflow: auto;
  display: grid;
  gap: 16px;
  align-content: start;
  padding: 20px 22px;
  background: #f8fafc;
}

.ib-drawer-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.ib-drawer-summary div,
.ib-client-fields {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
}

.ib-drawer-summary div {
  padding: 14px;
}

.ib-drawer-summary span {
  display: block;
  color: #64748b;
  font-size: 12px;
  font-weight: 850;
}

.ib-drawer-summary strong {
  display: block;
  margin-top: 8px;
  color: #0f172a;
  font-size: 18px;
  font-weight: 950;
}

.ib-client-fields {
  margin: 0;
  overflow: hidden;
}

.ib-client-fields div {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  border-top: 1px solid #edf1f7;
}

.ib-client-fields div:first-child {
  border-top: 0;
}

.ib-client-fields dt {
  color: #64748b;
  font-size: 12px;
  font-weight: 850;
}

.ib-client-fields dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: #0f172a;
  font-weight: 850;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 90;
  max-width: min(360px, calc(100vw - 44px));
  padding: 13px 16px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #0f172a;
  color: #fff;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.22);
  font-size: 13px;
  font-weight: 850;
  transform: translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

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

@media (max-width: 1180px) {
  .ib-client-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

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

  .ib-search-field {
    grid-column: 1 / -1;
  }

  .ib-client-filter .ib-date-filter {
    grid-column: 1 / -1;
  }

  .ib-filter-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .ib-clients-page {
    padding: 18px 14px 44px;
  }

  .ib-clients-heading {
    margin-bottom: 18px;
    padding: 0 2px;
  }

  .ib-clients-heading h1 {
    font-size: 24px;
  }

  .ib-clients-heading p {
    margin-top: 6px;
    font-size: 12px;
  }

  .ib-client-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
  }

  .ib-client-filter {
    grid-template-columns: 1fr;
  }

  .ib-metric-card {
    min-height: 96px;
    gap: 9px;
    padding: 13px 14px;
  }

  .ib-metric-heading {
    gap: 8px;
  }

  .ib-metric-heading > span:last-child {
    font-size: 11px;
  }

  .ib-metric-icon {
    width: 28px;
    height: 28px;
    border-radius: 9px;
  }

  .ib-metric-icon svg {
    width: 17px;
    height: 17px;
  }

  .ib-metric-card strong {
    font-size: 24px;
  }

  .ib-metric-card.tone-green strong {
    font-size: 22px;
  }

  .ib-client-filter {
    align-items: stretch;
    gap: 14px;
    padding: 16px;
  }

  .ib-filter-heading {
    padding-bottom: 2px;
  }

  .ib-client-table-toolbar,
  .ib-table-footer,
  .ib-footer-left {
    align-items: stretch;
    flex-direction: column;
  }

  .ib-filter-actions {
    flex-direction: row;
  }

  .ib-filter-actions .ib-primary-action,
  .ib-filter-actions .ib-secondary-action {
    flex: 1;
  }

  .ib-filter-actions .ib-primary-action,
  .ib-filter-actions .ib-secondary-action,
  .ib-table-tools .ib-secondary-action,
  .ib-page-size,
  .ib-page-size select {
    width: 100%;
  }

  .ib-client-table {
    min-width: 0;
  }

  .ib-client-table-card {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .ib-client-table-toolbar,
  .ib-table-footer {
    border: 1px solid var(--border, #dce6f4);
    border-radius: 14px;
    background: var(--surface-raised, #fff);
    box-shadow: var(--shadow-soft, 0 10px 24px rgba(15, 23, 42, 0.045));
  }

  .ib-client-table-toolbar {
    min-height: 0;
    margin-bottom: 10px;
    padding: 14px;
  }

  .ib-table-tools {
    width: 100%;
    flex-wrap: nowrap;
  }

  .ib-table-tools .ib-secondary-action {
    flex: 1;
  }

  .ib-client-table thead {
    display: none;
  }

  .ib-client-table,
  .ib-client-table tbody,
  .ib-client-table tr,
  .ib-client-table td {
    display: block;
    width: 100%;
  }

  .ib-client-table tbody {
    display: grid;
    gap: 10px;
  }

  .ib-client-table tr {
    overflow: hidden;
    border: 1px solid var(--border, #dce6f4);
    border-radius: 14px;
    background: var(--surface-raised, #fff);
    box-shadow: var(--shadow-soft, 0 10px 24px rgba(15, 23, 42, 0.045));
  }

  .ib-client-table td {
    min-height: 48px;
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid #edf1f7;
    white-space: normal;
  }

  .ib-client-table td:last-child {
    border-bottom: 0;
  }

  .ib-client-table td::before {
    content: attr(data-label);
    /* 卡片流里 td 变成「列名 + 值」两格栅格，右对齐的数字列别把列名也甩到右边 */
    text-align: left;
    color: var(--muted, #64748b);
    font-size: 12px;
    font-weight: 950;
  }

  /* 卡片流里 td 是两格栅格，行内块默认会被拉满右格：徽标和标签组收回自身宽度 */
  .ib-client-table td > .ib-chip,
  .ib-client-table td > .ib-client-tags {
    justify-self: start;
  }

  .ib-client-table td.actions-cell {
    position: static;
    width: auto;
    min-width: 0;
    box-shadow: none;
  }

  .ib-client-table td.actions-cell .ib-row-action {
    width: 100%;
    height: 36px;
  }

  :root[data-theme="dark"] body[data-layout-page="ib-clients"] .ib-client-table-card {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
  }

  :root[data-theme="dark"] body[data-layout-page="ib-clients"] .ib-client-table td.actions-cell {
    box-shadow: none;
  }

  .ib-table-footer {
    margin-top: 10px;
    padding: 14px;
  }

  .ib-pager {
    align-self: flex-end;
  }

  .ib-drawer-summary,
  .ib-client-fields div {
    grid-template-columns: 1fr;
  }

  .ib-client-drawer footer {
    align-items: stretch;
    flex-direction: column;
  }

  .ib-client-drawer footer .ib-primary-action,
  .ib-client-drawer footer .ib-secondary-action {
    width: 100%;
  }
}
