.customer-page {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.customer-directory {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}

.customer-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  border-radius: 12px 12px 0 0;
  background: #faf9fd;
}

.customer-toolbar-start {
  display: flex;
  flex: 1 1 330px;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.customer-search {
  display: flex;
  flex: 0 1 256px;
  align-items: center;
  gap: 7px;
  min-width: 120px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid #e2deec;
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: text;
}

.customer-search:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px #8268e72a;
}

.customer-search input {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 6px 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.customer-search input::placeholder { color: var(--muted); }

.customer-search svg,
.customer-button svg,
.customer-contact-icon svg {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
}

.customer-toolbar-end {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-inline-start: auto;
}

#customer-result-count {
  flex: none;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.customer-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid #e4dfef;
  border-radius: 8px;
  background: var(--surface);
  color: var(--label);
  font-size: 13px;
  font-weight: 630;
  line-height: 1.4;
  white-space: nowrap;
}

.customer-button:hover { border-color: #d6c8f3; background: #faf8ff; color: var(--accent); }
.customer-button[aria-expanded="true"] { border-color: #ded2f9; background: var(--lavender); color: #5338ba; }
.customer-button.customer-button--primary { border-color: transparent; background: var(--accent); color: #fff; }
.customer-button.customer-button--primary:hover { background: #5034b9; }
.customer-button:disabled { opacity: .55; cursor: default; }

.customer-filters,
.customer-filter-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px 10px;
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
}

.customer-filter-field { flex: 0 1 134px; min-width: 105px; }
.customer-filter-actions { display: flex; gap: 6px; margin-inline-start: auto; }
.customer-filter-summary { padding-block: 8px; gap: 6px; background: #faf8ff; }
.customer-filter-summary:empty { display: none; }

.customer-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  padding: 2px 8px;
  border: 1px solid #e1d8f8;
  border-radius: 6px;
  background: var(--lavender);
  color: #543a98;
  font-size: 12px;
}

.customer-filter-chip:hover { background: #e8dffd; }

.customer-table-shell {
  position: relative;
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border-radius: 0 0 12px 12px;
}

.customer-table-shell:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.customer-table {
  width: 100%;
  min-width: 1000px;
  border-spacing: 0;
  color: var(--ink);
  font-size: 13px;
  text-align: start;
}

.customer-table th,
.customer-table td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  text-align: start;
}

.customer-table th {
  padding-block: 9px;
  background: #f6f4fa;
  color: var(--label);
  font-size: 12px;
  font-weight: 660;
  white-space: nowrap;
}

.customer-table :is(th, td):first-child {
  position: sticky;
  z-index: 1;
  left: 0;
  width: 15%;
  padding-left: 13px;
  border-inline-end: 1px solid var(--line);
  box-shadow: 3px 0 6px #30214805;
}

.customer-table td:first-child { background: var(--surface); }
.customer-table td + td { border-inline-start: 1px solid #f1eff6; }
.customer-table td:first-child + td { border-inline-start: 0; }
.customer-table th:nth-child(2) { width: 9%; }
.customer-table th:nth-child(3) { width: 8.5%; }
.customer-table th:nth-child(4) { width: 8.5%; }
.customer-table th:nth-child(5) { width: 10%; }
.customer-table th:nth-child(6) { width: 22%; }
.customer-table th:nth-child(7) { width: 7.5%; }
.customer-table th:nth-child(8) { width: 9%; }
.customer-table th:nth-child(9) { width: 10.5%; }

.customer-table tbody tr:last-child td { border-bottom: 0; }
.customer-table tbody tr:hover td,
.customer-table tbody tr:focus-within td { background: #faf8ff; }

.customer-table :is(.customer-cell-number, .customer-cell-date) {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.customer-table .customer-cell-date { color: var(--muted); }
.customer-table .customer-cell-number { text-align: end; }
.customer-table :is(th, td):nth-child(7) { text-align: center; }

.customer-name-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: start;
  font-weight: 660;
}

.customer-name-button:hover { color: var(--accent); }
.customer-name-copy { overflow-wrap: anywhere; }

.customer-avatar,
.customer-detail-avatar {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 34px;
  aspect-ratio: 1;
  border: 1px solid #e7e0fa;
  border-radius: 50%;
  background: var(--lavender);
  color: #6247a5;
  font-size: 13px;
  font-weight: 690;
}

.customer-contacts { display: flex; align-items: center; gap: 7px; }
.customer-contact-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #a5a0b3;
}

.customer-contact-icon.is-available { color: #694cc4; }

.customer-status,
.customer-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding: 2px 7px;
  border-radius: 5px;
  background: #f1eef6;
  color: var(--label);
  font-size: 12px;
  font-weight: 625;
  white-space: nowrap;
}

.customer-status:is([data-status="待跟进"], [data-status="new"]) { background: #f0edf6; color: #615775; }
.customer-status:is([data-status="沟通中"], [data-status="following"]) { background: #eee8fb; color: #6542a7; }
.customer-status:is([data-status="已成交"], [data-status="booked"]) { background: #e8f4ed; color: #2d6d49; }
.customer-status:is([data-status="长期合作"], [data-status="partner"]) { background: #e9effb; color: #3a5c9b; }

.customer-trip-chips { display: grid; justify-items: start; gap: 4px; }

.customer-trip-chip {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 7px;
  max-width: 100%;
  padding: 4px 7px;
  border: 1px solid #e8dff9;
  border-radius: 6px;
  background: #f7f3fe;
  color: #5a4192;
  text-align: start;
  line-height: 1.5;
}

.customer-trip-chip:hover { border-color: #d8c8f2; background: #f0e8fd; }
.customer-trip-chip strong { font-size: 12px; font-weight: 650; overflow-wrap: anywhere; }
.customer-trip-chip small { color: #706487; font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.customer-history-link {
  min-width: 24px;
  padding: 2px 5px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #6042a6;
  font-weight: 650;
}

.customer-history-link:hover { border-color: #e3d8fa; background: var(--lavender); }
.customer-cell-empty { color: #827b92; }
.customer-empty { padding: 25px 12px; color: var(--muted); text-align: center; font-size: 13px; }
.customer-empty p + .customer-button { margin-top: 8px; }
.customer-feedback { padding: 8px 13px; border-top: 1px solid var(--line); color: var(--label); font-size: 12px; }
.customer-feedback:empty { display: none; }

.customer-dialog {
  width: min(500px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 14px 55px #2e224f25;
}

.customer-dialog::backdrop { background: #2f244331; }

.customer-form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px 17px;
  border-bottom: 1px solid var(--line);
}

.customer-form-header h2 { font-size: 18px; }
.customer-form-body { display: grid; gap: 12px; padding: 13px 17px 17px; }
.customer-form-hint,
.customer-preview-hint { color: var(--muted); font-size: 12px; }

.customer-form-fields,
.customer-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px 12px;
}

.customer-form-fields > label,
.customer-form-grid > label,
.customer-inline-form > label,
.customer-filter-field {
  display: grid;
  align-content: start;
  gap: 4px;
  color: var(--label);
  font-size: 13px;
  font-weight: 620;
}

.customer-form-fields .customer-field-wide,
.customer-form-grid .customer-field-wide { grid-column: 1 / -1; }

:where(.customer-filters, .customer-dialog) :is(input, select, textarea) {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid #e5dfef;
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 450;
}

:where(.customer-filters, .customer-dialog) :is(input, select, textarea):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.customer-dialog textarea { resize: vertical; }
.customer-form-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.customer-form-actions .customer-preview-hint { margin-inline-end: auto; }
.customer-form-error { color: #9c2849; font-size: 13px; }
.customer-edit-section { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; }
.customer-edit-section summary { cursor: pointer; color: var(--label); font-weight: 650; }
.customer-edit-section > [data-customer-add] { margin-top: 7px; }
.customer-edit-item { display: grid; justify-items: start; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.customer-edit-item .customer-form-fields { width: 100%; }
.customer-edit-item-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.customer-button.customer-button--add { color: #fff; background: #2162d9; border-color: #2162d9; }
.customer-button.customer-button--add:hover:not(:disabled) { color: #fff; background: #174eae; border-color: #174eae; }
.customer-button.customer-button--danger { color: #9c2849; background: #fff5f7; border-color: #efd0db; }
.customer-button.customer-button--danger:hover { color: #8d2041; background: #fbe9ee; }
.customer-detail-actions { display: flex; flex: none; align-items: center; gap: 6px; }
.customer-detail-actions .customer-button { min-height: 32px; padding: 4px 9px; }

#customer-detail-dialog {
  --drawer-available: calc(100% - 2 * var(--workspace-inset));
  position: fixed;
  inset: var(--workspace-inset) var(--workspace-inset) var(--workspace-inset) auto;
  width: min(600px, var(--drawer-available));
  height: var(--drawer-available);
  max-width: none;
  max-height: none;
  margin: 0;
  overflow: hidden;
  border-radius: var(--workspace-radius);
}

#customer-detail-dialog[open] { display: flex; flex-direction: column; }

.customer-detail-header { flex: none; padding: 18px 21px 0; border-bottom: 1px solid var(--line); }
.customer-detail-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.customer-detail-identity { display: flex; align-items: center; gap: 11px; min-width: 0; }
.customer-detail-avatar { width: 42px; font-size: 17px; }
.customer-detail-identity h2 { font-size: 22px; font-weight: 690; overflow-wrap: anywhere; letter-spacing: -.02em; }
.customer-detail-badges { display: flex; flex-wrap: wrap; gap: 5px; margin: 9px 0 12px; }

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

.customer-detail-stats > div {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid #eee8f6;
  border-radius: 8px;
  background: #f8f5fc;
}

.customer-detail-stats dt,
.customer-detail-fields dt { color: var(--muted); font-size: 12px; }

.customer-detail-stats dd {
  margin: 1px 0 0;
  color: var(--ink);
  font-size: clamp(15px, 3.4vw, 19px);
  font-weight: 670;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.customer-detail-tabs { display: flex; gap: 6px; }

.customer-detail-tabs button {
  flex: 1 1 0;
  min-height: 42px;
  padding: 6px 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 620;
  white-space: nowrap;
}

.customer-detail-tabs button:hover { color: var(--accent); }
.customer-detail-tabs button[aria-selected="true"] { border-bottom-color: var(--accent); color: #5338b2; }
.customer-detail-tabs button:focus-visible { outline-offset: -4px; }

.customer-detail-content {
  flex: 1 1 auto;
  min-height: 0;
  padding: 16px 21px 22px;
  overflow: auto;
  overscroll-behavior: contain;
}

.customer-detail-section + .customer-detail-section {
  margin-top: 15px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.customer-detail-content h3 { margin: 0; font-size: 15px; font-weight: 680; }

.customer-detail-fields {
  display: grid;
  gap: 7px;
  margin: 10px 0 0;
}

.customer-detail-fields > div { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 8px; align-items: baseline; }
.customer-detail-fields dd { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
.customer-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.customer-tags .customer-chip { background: var(--lavender); color: #6041a2; }

.customer-detail-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 7px; margin-bottom: 8px; }
.customer-trip-group + .customer-trip-group { margin-top: 13px; }
.customer-trip-group h4 { margin: 0 0 2px; color: var(--muted); font-size: 12px; font-weight: 650; }

.customer-trip-row,
.customer-notes-list > li {
  display: flex;
  align-items: start;
  gap: 9px;
  padding: 10px 3px;
  border-bottom: 1px solid var(--line);
}

.customer-trip-row:focus,
.customer-trip-row[data-highlight] {
  border-radius: 6px 6px 0 0;
  outline: 0;
  background: #f3edfe;
}

.customer-trip-icon {
  display: grid;
  flex: 0 0 32px;
  place-items: center;
  height: 32px;
  border-radius: 7px;
  background: #f1ebfb;
  color: #6649aa;
}

.customer-trip-icon { position: relative; }
.customer-trip-icon::before, .customer-trip-icon::after { position: absolute; content: ""; }
.customer-trip-icon::before {
  inset: 10px 8px 8px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
}
.customer-trip-icon::after { inset: 7px 13px auto; height: 4px; border: 1.5px solid currentColor; border-radius: 2px 2px 0 0; }
.customer-trip-copy { min-width: 0; flex: 1 1 auto; }
.customer-trip-copy h5 { margin: 0 0 2px; font-size: 13px; font-weight: 680; overflow-wrap: anywhere; }
.customer-trip-copy p { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.customer-trip-state { flex: none; align-self: center; }
.customer-trip-row[data-state="已预订"] .customer-trip-state { background: #eee9fa; color: #6542a7; }
.customer-trip-row[data-state="已完成"] .customer-trip-state { background: #e8f4ed; color: #2d6d49; }

.customer-notes-list > li { display: grid; gap: 2px; }
.customer-notes-list p { font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.customer-notes-list time { color: var(--muted); font-size: 12px; }

.customer-inline-form[data-form="note"] .customer-form-fields { grid-template-columns: minmax(0, 1fr); }

.customer-inline-form {
  display: grid;
  gap: 9px;
  margin: 0 0 12px;
  padding: 10px;
  border: 1px solid #eae3f5;
  border-radius: 9px;
  background: #faf7fe;
}

@media (max-width: 700px) {
  .customer-toolbar { padding: 9px; gap: 7px; }
  .customer-toolbar-start { flex-basis: 240px; }
  .customer-search { flex: 1 1 120px; min-width: 0; }
  .customer-toolbar-end { gap: 7px; }
  .customer-table :is(th, td):first-child { max-width: 136px; }
}

@media (max-width: 560px) {
  .customer-toolbar-start { flex-basis: 100%; }
  .customer-toolbar-end { flex: 1 1 100%; justify-content: space-between; }
  .customer-filters { padding-inline: 9px; }
  .customer-filter-field { flex: 1 1 100px; }
  .customer-detail-header, .customer-detail-content { padding-inline: 13px; }
}

@media (max-width: 370px) {
  .customer-form-fields, .customer-form-grid { grid-template-columns: minmax(0, 1fr); }
  .customer-detail-fields > div { grid-template-columns: 76px minmax(0, 1fr); }
}
