:root {
  color-scheme: light;
  --bg: #f3f6f5;
  --surface: #ffffff;
  --surface-2: #edf2f0;
  --ink: #17211e;
  --muted: #64716d;
  --border: #d9e1de;
  --border-strong: #bcc9c4;
  --accent: #087f68;
  --accent-hover: #066854;
  --accent-soft: #dff3ed;
  --warning-soft: #fff2cc;
  --warning-ink: #745200;
  --danger: #b42318;
  --focus: #2563eb;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --text-xs: 12px;
  --text-sm: 14px;
  --text-md: 16px;
  --text-lg: 20px;
  --text-xl: 28px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --shadow-panel: 0 16px 40px rgba(23, 33, 30, 0.09);
  --dur-fast: 140ms;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent);
  outline-offset: 2px;
}

.login-body {
  background: #e9efec;
}

.login-layout {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px 20px;
}

.login-panel {
  width: min(100%, 400px);
  border-top: 4px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-panel);
  padding: 36px;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-link {
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: inline-grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--accent);
}

.brand-mark::before,
.brand-mark span {
  position: absolute;
  width: 14px;
  height: 4px;
  border-radius: 1px;
  background: #fff;
  content: "";
}

.brand-mark span {
  transform: rotate(90deg);
}

.brand-name {
  font-size: var(--text-md);
  font-weight: 700;
}

.login-heading {
  margin: 52px 0 28px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 700;
}

h1,
h2,
p {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: var(--text-xl);
  line-height: 1.25;
}

.login-form {
  display: grid;
  gap: 20px;
}

.field-group,
.filter-search,
.filter-select {
  display: grid;
  gap: 7px;
}

label {
  color: #34413d;
  font-size: var(--text-xs);
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 11px;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

input:hover,
select:hover {
  border-color: #93a49e;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.primary-button {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  padding: 10px 18px;
  transition: background var(--dur-fast);
}

.primary-button:hover {
  background: var(--accent-hover);
}

.secondary-button {
  min-height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  padding: 9px 16px;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}

.secondary-button:hover {
  border-color: #93a49e;
  background: var(--surface-2);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.form-error {
  margin-bottom: 18px;
  border-left: 3px solid var(--danger);
  background: #fff0ee;
  color: #8f1d14;
  padding: 10px 12px;
}

.app-header {
  min-height: 58px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-inner {
  display: flex;
  width: min(100% - 40px, 1280px);
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  margin: 0 auto;
}

.account-area {
  display: flex;
  align-items: center;
  gap: 18px;
}

.account-name {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 0;
}

.text-button:hover {
  color: var(--ink);
}

.workspace {
  width: min(100% - 40px, 1280px);
  margin: 0 auto;
  padding: 32px 0 48px;
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.result-count {
  margin: 0;
  color: var(--muted);
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.8fr) minmax(150px, 1fr) minmax(150px, 1fr) auto;
  align-items: end;
  gap: 12px;
  border-top: 1px solid var(--border);
  padding: 18px 0;
}

.filter-actions {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 14px;
}

.compact-button {
  min-height: 42px;
}

.secondary-link {
  color: var(--muted);
  text-decoration: none;
}

.secondary-link:hover {
  color: var(--ink);
}

.customer-table-shell {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.table-scroll {
  overflow-x: auto;
}

.customer-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  table-layout: fixed;
}

.customer-table th,
.customer-table td {
  border-bottom: 1px solid var(--border);
  padding: 13px 16px;
  text-align: left;
  vertical-align: middle;
}

.customer-table th {
  background: var(--surface-2);
  color: #53615c;
  font-size: var(--text-xs);
  font-weight: 700;
}

.customer-table th:nth-child(1) { width: 29%; }
.customer-table th:nth-child(2) { width: 22%; }
.customer-table th:nth-child(3) { width: 23%; }
.customer-table th:nth-child(4) { width: 12%; }
.customer-table th:nth-child(5) { width: 14%; }

.customer-table tbody tr:last-child td {
  border-bottom: 0;
}

.customer-table tbody tr:hover {
  background: #f8fbfa;
}

.customer-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.customer-avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-fallback {
  display: grid;
  place-items: center;
  background: #dfe9e5;
  color: #31554b;
  font-weight: 750;
}

.customer-primary {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.customer-name {
  overflow: hidden;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-name:hover {
  color: var(--accent);
}

.customer-meta,
.relation-item small,
.muted-text {
  overflow: hidden;
  color: var(--muted);
  font-size: var(--text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.relation-list,
.relation-item {
  display: grid;
  min-width: 0;
}

.relation-list {
  gap: 6px;
}

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

.tag-chip {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border: 1px solid #ead58f;
  border-radius: 999px;
  background: var(--warning-soft);
  color: var(--warning-ink);
  font-size: var(--text-xs);
  padding: 2px 8px;
}

.mono-data {
  color: #4c5b56;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.empty-state {
  display: grid;
  min-height: 280px;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: 32px;
  text-align: center;
}

.empty-state h2 {
  margin: 0;
  font-size: var(--text-lg);
}

.pagination {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

.pagination a {
  text-decoration: none;
}

.pagination [aria-disabled="true"] {
  color: #a3ada9;
}

.page-indicator {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.detail-workspace {
  padding-top: 22px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: var(--text-xs);
}

.breadcrumb a {
  color: var(--muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--ink);
}

.notice-banner {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: #195a4b;
  margin-bottom: 20px;
  padding: 10px 14px;
}

.notice-banner small {
  font-family: var(--font-mono);
}

.notice-warning {
  border-left-color: #c98a00;
  background: var(--warning-soft);
  color: var(--warning-ink);
}

.detail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding: 4px 0 24px;
}

.detail-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 14px;
}

.detail-avatar {
  display: grid;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  place-items: center;
  border-radius: 50%;
  object-fit: cover;
}

.detail-meta {
  margin: 4px 0 0;
  color: var(--muted);
}

.detail-tag-summary {
  display: grid;
  min-width: min(100%, 390px);
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.summary-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
}

.local-tag-chip {
  border-color: #a9c8e9;
  background: #eaf4ff;
  color: #184f80;
}

.customer-profile {
  display: grid;
  grid-template-columns: minmax(180px, 0.3fr) minmax(0, 1fr);
  gap: 32px;
  border-top: 1px solid var(--border);
  padding: 22px 0;
}

.profile-heading h2 {
  margin: 0;
  font-size: var(--text-lg);
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px 24px;
  margin: 0;
}

.profile-grid > div {
  min-width: 0;
}

.profile-grid dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
}

.profile-grid dd {
  margin: 0;
  color: var(--ink);
}

.profile-identifier {
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.customer-profile + .detail-toolbar {
  border-top: 0;
}

.detail-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(180px, 1fr) auto;
  align-items: end;
  gap: 24px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}

.relation-switcher {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto;
  align-items: end;
  gap: 8px;
}

.sync-state {
  display: grid;
  align-content: end;
  gap: 2px;
  min-height: 42px;
}

.sync-state .summary-label {
  margin: 0;
}

.sync-state small {
  color: var(--muted);
  font-size: var(--text-xs);
}

.detail-actions,
.recommendation-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.detail-actions form,
.recommendation-actions form {
  margin: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.conversation-section,
.analysis-section {
  min-width: 0;
  padding: 26px;
}

.analysis-section {
  border-left: 1px solid var(--border);
}

.section-heading {
  display: flex;
  min-height: 48px;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-heading h2 {
  margin: 0;
  font-size: var(--text-lg);
}

.section-count,
.analysis-mode,
.analysis-date {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.message-list {
  display: grid;
  gap: 12px;
}

.message-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  scroll-margin-top: 20px;
}

.message-origin {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: #e2e8e5;
  color: #53615c;
  font-size: var(--text-xs);
  font-weight: 750;
}

.customer-message .message-origin {
  background: #e8eef8;
  color: #355a86;
}

.employee-message .message-origin {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.message-content {
  max-width: min(100%, 620px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fbfcfc;
  padding: 11px 13px;
}

.employee-message .message-content {
  border-color: #b9dbd1;
  background: #f1faf7;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: var(--text-xs);
}

.message-meta strong {
  color: var(--ink);
}

.message-meta time {
  font-family: var(--font-mono);
}

.message-content p {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

.media-placeholder {
  color: var(--muted);
  font-size: var(--text-xs);
}

.section-empty {
  display: grid;
  min-height: 260px;
  place-content: center;
  justify-items: center;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.section-empty h3 {
  margin: 0;
  color: var(--ink);
  font-size: var(--text-md);
}

.section-empty p {
  margin: 6px 0 0;
}

.analysis-summary {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
}

.analysis-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.scenario-badge {
  color: var(--accent-hover);
  font-weight: 750;
}

.analysis-summary p {
  margin: 10px 0 0;
}

.judgement-list {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--border);
  margin-top: 20px;
  padding-top: 18px;
}

.judgement-row {
  display: grid;
  gap: 4px;
}

.judgement-row > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.judgement-row p,
.next-action p,
.local-only-note {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-xs);
}

.next-action,
.evidence-links,
.recommendation-section {
  border-top: 1px solid var(--border);
  margin-top: 18px;
  padding-top: 18px;
}

.evidence-links > div {
  display: grid;
  gap: 8px;
}

.evidence-message {
  border-left: 3px solid var(--accent);
  padding: 8px 10px;
  background: var(--surface-muted);
}

.evidence-message-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: var(--text-xs);
}

.evidence-message-meta time {
  color: var(--text-muted);
}

.evidence-message p {
  margin: 5px 0 0;
}

.recommendation-section {
  display: grid;
  gap: 14px;
}

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

.recommendation-row {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.recommendation-row:last-child {
  border-bottom: 0;
}

.recommendation-row > div:first-child {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.recommendation-row small {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

@media (max-width: 760px) {
  .header-inner,
  .workspace {
    width: min(100% - 24px, 1280px);
  }

  .workspace {
    padding-top: 24px;
  }

  .page-heading {
    align-items: start;
  }

  .filters {
    grid-template-columns: 1fr 1fr;
  }

  .filter-search {
    grid-column: 1 / -1;
  }

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

  .customer-table {
    min-width: 600px;
  }

  .optional-column {
    display: none;
  }

  .customer-table th:nth-child(1) { width: 42%; }
  .customer-table th:nth-child(2) { width: 28%; }
  .customer-table th:nth-child(3) { width: 30%; }

  .login-panel {
    padding: 28px 24px;
  }

  .pagination {
    justify-content: center;
  }

  .detail-heading {
    align-items: start;
    flex-direction: column;
  }

  .detail-tag-summary {
    width: 100%;
    min-width: 0;
  }

  .customer-profile {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .profile-grid {
    grid-template-columns: 1fr 1fr;
  }

  .detail-toolbar {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .relation-switcher {
    grid-template-columns: 1fr auto;
  }

  .detail-actions {
    justify-content: stretch;
  }

  .detail-actions form {
    flex: 1;
  }

  .detail-actions button {
    width: 100%;
  }

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

  .conversation-section,
  .analysis-section {
    padding: 22px 16px;
  }

  .analysis-section {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .message-meta,
  .analysis-title-row,
  .recommendation-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .message-meta {
    display: flex;
  }

  .recommendation-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
