:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #172033;
  --muted: #697386;
  --line: #e5e9f0;
  --accent: #176b5b;
  --accent-soft: #e7f3ef;
  --accent-strong: #105347;
  --danger: #b42318;
  --shadow: 0 12px 34px rgba(31, 42, 55, 0.07);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.app-shell { min-height: 100vh; }
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 15%, rgba(23, 107, 91, .1), transparent 30%),
    radial-gradient(circle at 85% 80%, rgba(23, 107, 91, .07), transparent 34%),
    var(--bg);
}
.login-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, .96);
  padding: 30px;
  box-shadow: 0 24px 70px rgba(23, 32, 51, .12);
}
.login-brand { display: flex; align-items: center; gap: 12px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.login-brand strong, .login-brand small { display: block; }
.login-brand strong { font-size: 15px; }
.login-brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.login-copy { padding: 27px 0 20px; }
.login-copy h1 { margin: 0; font-size: 28px; letter-spacing: -.04em; }
.login-copy > p:last-child { margin: 9px 0 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.login-form { display: grid; gap: 15px; }
.login-form label { display: grid; gap: 7px; color: #344054; font-size: 12px; font-weight: 750; }
.login-form input { width: 100%; height: 46px; border: 1px solid var(--line); border-radius: 11px; outline: 0; background: white; color: var(--text); padding: 0 13px; font-size: 13px; font-weight: 500; }
.login-form input:focus { border-color: #83aea3; box-shadow: 0 0 0 3px rgba(23, 107, 91, .1); }
.login-error { min-height: 18px; margin: -3px 0 0; color: transparent; font-size: 11px; }
.login-error.visible { color: var(--danger); }
.login-button { width: 100%; min-height: 46px; }
.login-role-hint { display: grid; gap: 7px; margin-top: 22px; border-radius: 12px; background: var(--surface-soft); padding: 12px 14px; color: var(--muted); font-size: 11px; }
.login-role-hint span::before { content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 8px; border-radius: 50%; background: #83aea3; vertical-align: 1px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  box-shadow: 0 7px 18px rgba(23, 107, 91, 0.2);
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: .02em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.source-chip {
  border: 1px solid #cfe2dc;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
}
.account-area { display: flex; align-items: center; gap: 9px; }
.role-chip { display: flex; align-items: center; gap: 7px; border: 1px solid #cfe2dc; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); padding: 7px 11px; font-size: 11px; font-weight: 750; }
.role-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.role-chip.followup { border-color: #d8def0; background: #eef1fa; color: #41507d; }
.role-chip.followup i { background: #6574a6; }
.role-chip small { padding-left: 6px; border-left: 1px solid currentColor; opacity: .65; font-size: 10px; font-weight: 600; }
.logout-button { border: 1px solid var(--line); border-radius: 9px; background: white; color: #667085; padding: 7px 10px; font-size: 11px; font-weight: 700; }
.logout-button:hover { background: #f3f5f7; color: var(--text); }

.workspace { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 46px 0 72px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.eyebrow { margin: 0 0 8px !important; color: var(--accent) !important; font-size: 12px !important; font-weight: 800; letter-spacing: .12em; }
.page-heading h1 { margin: 0; font-size: clamp(28px, 4vw, 40px); letter-spacing: -.04em; line-height: 1.1; }
.page-heading p { margin: 12px 0 0; color: var(--muted); font-size: 14px; }
.summary-group { display: flex; gap: 12px; }
.summary-card {
  min-width: 156px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  padding: 15px 18px;
  box-shadow: var(--shadow);
}
.summary-card.emphasis { border-color: #cfe2dc; background: var(--accent-soft); box-shadow: none; }
.summary-card span { color: var(--muted); font-size: 12px; }
.summary-card strong { display: block; margin-top: 3px; color: var(--accent); font-size: 26px; }

.toolbar { margin-top: 34px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.search-field {
  width: min(390px, 100%);
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  padding: 0 14px;
  color: #8a94a6;
  box-shadow: 0 3px 12px rgba(31, 42, 55, .035);
}
.search-field:focus-within { border-color: #83aea3; box-shadow: 0 0 0 3px rgba(23, 107, 91, .1); }
.search-field input { width: 100%; height: 44px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13px; }
.search-field input::placeholder { color: #99a1af; }
.clear-search { display: grid; width: 24px; height: 24px; place-items: center; flex: 0 0 auto; border: 0; border-radius: 50%; background: #eef1f5; color: var(--muted); font-size: 17px; line-height: 1; }
.tabs { display: flex; gap: 5px; border-radius: 12px; background: #e9edf2; padding: 4px; }
.tab { border: 0; border-radius: 9px; background: transparent; padding: 8px 13px; color: var(--muted); font-size: 12px; font-weight: 700; }
.tab span { margin-left: 3px; opacity: .7; }
.tab.active { background: white; color: var(--text); box-shadow: 0 2px 7px rgba(31, 42, 55, .08); }
.scope-chip { border: 1px solid var(--line); border-radius: 999px; background: var(--surface-soft); color: #667085; padding: 8px 12px; font-size: 11px; font-weight: 700; }

.customer-panel { margin-top: 16px; overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.table-head, .customer-row { display: grid; grid-template-columns: 1.2fr 1fr 150px; align-items: center; gap: 24px; }
.table-head { min-height: 42px; padding: 0 24px; border-bottom: 1px solid var(--line); background: var(--surface-soft); color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .06em; }
.customer-row { min-height: 78px; padding: 13px 24px; border-bottom: 1px solid var(--line); }
.customer-row:last-child { border-bottom: 0; }
.customer-name { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar { display: grid; width: 40px; height: 40px; flex: 0 0 auto; place-items: center; border-radius: 12px; background: #eef1f5; color: #596275; font-size: 14px; font-weight: 800; }
.customer-copy { min-width: 0; }
.customer-name strong, .customer-name small { display: block; }
.customer-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.customer-name small { margin-top: 3px; color: #8a94a6; font-size: 11px; }
.phone-cell { display: flex; align-items: center; gap: 10px; }
.phone { width: max-content; color: #344054; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; text-decoration: none; }
.phone:hover { color: var(--accent); }
.copy-button { border: 0; border-radius: 7px; background: transparent; color: #8993a4; padding: 5px 7px; font-size: 10px; }
.copy-button:hover { background: #eef1f5; color: var(--text); }
.detail-button { display: inline-flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid #cfe2dc; border-radius: 10px; background: var(--accent-soft); color: var(--accent-strong); padding: 9px 12px; font-size: 12px; font-weight: 750; }
.detail-button:hover { background: #dcece7; }

.customer-list.is-loading { opacity: .62; }
.skeleton-row { min-height: 78px; }
.skeleton { display: block; height: 14px; border-radius: 999px; background: linear-gradient(90deg, #eef1f5 25%, #f8fafc 48%, #eef1f5 72%); background-size: 230% 100%; animation: shimmer 1.4s infinite linear; }
.customer-skeleton { width: 46%; height: 36px; border-radius: 11px; }
.phone-skeleton { width: 56%; }
.button-skeleton { width: 100%; height: 34px; border-radius: 9px; }
@keyframes shimmer { to { background-position: -230% 0; } }

.state-panel { min-height: 310px; display: flex; align-items: center; justify-content: center; flex-direction: column; padding: 44px 20px; text-align: center; }
.state-icon { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 14px; background: #fff1e9; color: #b54708; font-size: 21px; font-weight: 800; }
.state-icon.success { background: var(--accent-soft); color: var(--accent); }
.state-panel h2 { margin: 15px 0 5px; font-size: 17px; }
.state-panel p { margin: 0; color: var(--muted); font-size: 13px; }
.state-panel button { margin-top: 18px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--text); padding: 9px 14px; font-size: 12px; font-weight: 700; }
.panel-foot { padding: 15px 24px; border-top: 1px solid var(--line); background: var(--surface-soft); color: var(--muted); text-align: center; font-size: 11px; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 16px; text-align: left; }
.pagination > div { display: flex; align-items: center; gap: 10px; }
.pagination button { border: 1px solid var(--line); border-radius: 8px; background: white; color: #475467; padding: 6px 10px; font-size: 11px; font-weight: 650; }
.pagination button:disabled { cursor: not-allowed; opacity: .45; }

.modal-backdrop { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: rgba(19, 29, 45, .5); backdrop-filter: blur(5px); animation: fade-in .16s ease-out; }
.modal-card { width: min(520px, 100%); max-height: min(720px, calc(100vh - 32px)); overflow: auto; border: 1px solid rgba(255,255,255,.45); border-radius: 22px; background: white; box-shadow: 0 28px 80px rgba(13, 29, 37, .24); animation: modal-in .2s ease-out; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 24px 24px 20px; }
.modal-header p { margin: 0 0 5px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.modal-header h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.modal-close { display: grid; width: 34px; height: 34px; place-items: center; border: 0; border-radius: 10px; background: #eef1f5; color: #667085; font-size: 21px; line-height: 1; }
.modal-customer { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 13px; margin: 0 24px 22px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-soft); padding: 13px; }
.avatar.large { width: 44px; height: 44px; }
.modal-customer div span, .modal-customer div a { display: block; }
.modal-customer div span { margin-bottom: 3px; color: var(--muted); font-size: 10px; }
.modal-customer div a { width: max-content; color: var(--text); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 14px; font-weight: 700; text-decoration: none; }
.modal-customer > button { border: 0; border-radius: 8px; background: var(--accent-soft); color: var(--accent-strong); padding: 7px 9px; font-size: 10px; font-weight: 700; }
.modal-card form, .processed-detail { padding: 0 24px 24px; }
.note-label { display: block; margin-bottom: 8px; color: #344054; font-size: 12px; font-weight: 750; }
.note-label span { margin-left: 4px; color: var(--danger); font-size: 10px; }
.quick-note-block { margin-bottom: 12px; border-radius: 12px; background: var(--surface-soft); padding: 11px 12px; }
.quick-note-label { display: flex; align-items: baseline; gap: 7px; margin-bottom: 8px; color: #475467; font-size: 11px; font-weight: 750; }
.quick-note-label span { color: #98a2b3; font-size: 10px; font-weight: 500; }
.quick-note-buttons { display: flex; flex-wrap: wrap; gap: 7px; }
.quick-note-button { border: 1px solid #d7e5e1; border-radius: 999px; background: white; color: var(--accent-strong); padding: 7px 10px; font-size: 11px; font-weight: 700; transition: background .15s ease, border-color .15s ease, transform .15s ease; }
.quick-note-button:hover { border-color: #9fc2b9; background: var(--accent-soft); transform: translateY(-1px); }
.quick-note-button.selected { border-color: #78a99c; background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(23,107,91,.08); }
.quick-note-button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.modal-card textarea { width: 100%; min-height: 150px; resize: vertical; border: 1px solid var(--line); border-radius: 13px; outline: 0; background: white; color: var(--text); padding: 13px 14px; font: inherit; font-size: 13px; line-height: 1.7; }
.modal-card textarea:focus { border-color: #83aea3; box-shadow: 0 0 0 3px rgba(23, 107, 91, .1); }
.modal-card textarea::placeholder { color: #a1a8b5; }
.note-meta { min-height: 30px; display: flex; justify-content: space-between; gap: 16px; padding-top: 7px; color: #8a94a6; font-size: 10px; }
.form-error { color: var(--danger); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.modal-actions.single { margin-top: 20px; }
.secondary-button, .primary-button { border-radius: 10px; padding: 10px 15px; font-size: 12px; font-weight: 750; }
.secondary-button { border: 1px solid var(--line); background: white; color: #475467; }
.primary-button { border: 1px solid var(--accent); background: var(--accent); color: white; box-shadow: 0 7px 16px rgba(23,107,91,.18); }
.primary-button:disabled, .secondary-button:disabled, .modal-close:disabled { cursor: not-allowed; opacity: .55; }
.detail-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.detail-label span { color: #344054; font-size: 12px; font-weight: 750; }
.detail-label small { color: #8a94a6; font-size: 10px; }
.processed-detail > p { min-height: 112px; margin: 0; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); padding: 14px; color: #344054; font-size: 13px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 50; max-width: min(420px, calc(100% - 32px)); transform: translate(-50%, 14px); border-radius: 12px; background: #172033; color: white; padding: 11px 15px; box-shadow: 0 12px 30px rgba(13,29,37,.22); font-size: 12px; opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; }
.toast.visible { transform: translate(-50%, 0); opacity: 1; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(23, 107, 91, .25); outline-offset: 2px; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.985); } }

@media (max-width: 720px) {
  .topbar { height: 64px; }
  .source-chip { display: none; }
  .role-chip small { display: none; }
  .login-card { padding: 24px; }
  .workspace { width: min(100% - 24px, 1120px); padding-top: 30px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .summary-group { display: grid; grid-template-columns: 1fr 1fr; }
  .summary-card { min-width: 0; display: flex; align-items: flex-start; flex-direction: column; }
  .summary-card strong { margin: 0; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .tabs { width: 100%; }
  .scope-chip { width: max-content; }
  .tab { flex: 1; }
  .table-head { display: none; }
  .customer-row { grid-template-columns: 1fr auto; gap: 8px 16px; padding: 16px; }
  .customer-name { grid-row: span 2; }
  .phone-cell { justify-content: flex-end; }
  .copy-button { display: none; }
  .phone { font-size: 12px; }
  .detail-button { justify-content: center; }
  .pagination { align-items: stretch; flex-direction: column; text-align: center; }
  .pagination > div { justify-content: center; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal-card { width: 100%; max-height: 92vh; border-radius: 22px 22px 0 0; }
  .modal-customer { grid-template-columns: auto 1fr; }
  .modal-customer > button { grid-column: 1 / -1; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
