:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #1a1d23;
  --muted: #5c6570;
  --line: #e2e5ea;
  --ok: #1f7a4c;
  --bad: #b42318;
  --accent: #1f4e79;
  --accent-soft: #e8eef5;
  --radius: 10px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.brand {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand span {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.95rem;
  margin-left: 8px;
}

.meta {
  color: var(--muted);
  font-size: 0.875rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.logout-link {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.logout-link:hover {
  color: var(--accent);
  border-color: #b7c9dc;
  text-decoration: none;
}

.current-agent {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid #b7c9dc;
  color: var(--ink);
  max-width: min(420px, 70vw);
}

.current-agent-label {
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: none;
  white-space: nowrap;
}

.current-agent-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.925rem;
}

th,
td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  background: #f8f9fb;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: none;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: #fafbfc;
}

.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.85rem;
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-ok {
  color: var(--ok);
}

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

.error {
  color: var(--bad);
  font-size: 0.85rem;
  max-width: 280px;
  white-space: normal;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.metric .label {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.metric .value {
  font-size: 1.45rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.section {
  margin-top: 28px;
}

.section h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
}

.crumb {
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.muted {
  color: var(--muted);
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
}

.pill-archived {
  background: #f3f3f3;
  color: var(--muted);
}

.title-cell {
  white-space: normal;
  max-width: 320px;
}

.section-hint {
  margin-left: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin: 0 0 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}

.filter-field select {
  min-width: 160px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.filter-btn {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.filter-btn:active {
  transform: translateY(1px);
}

.filter-reset {
  font-size: 0.875rem;
  padding: 8px 4px;
}

.filter-count {
  margin-left: auto;
  font-size: 0.85rem;
  align-self: center;
}

.conv-row {
  cursor: pointer;
}

.conv-row:hover td {
  background: var(--accent-soft);
}

.conv-row.is-open td {
  background: #f0f4f9;
}

.expand-cell {
  color: var(--muted);
  width: 2rem;
}

.expand-icon {
  display: inline-block;
  transition: transform 0.12s ease;
}

.conv-row.is-open .expand-icon {
  transform: rotate(90deg);
}

.conv-detail td {
  background: #f7f8fa;
  white-space: normal;
  padding: 0;
  border-bottom: 1px solid var(--line);
}

.conv-detail:hover td {
  background: #f7f8fa;
}

.user-questions {
  padding: 12px 16px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-placeholder {
  margin: 0;
}

.user-q {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.user-q-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.user-q-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.925rem;
  line-height: 1.5;
}

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-shell {
  width: min(400px, calc(100% - 32px));
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px 24px 24px;
  box-shadow: 0 8px 24px rgba(26, 29, 35, 0.06);
}

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

.login-title {
  font-size: 1.4rem;
  font-weight: 700;
}

.login-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.95rem;
}

.login-error {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fdecec;
  color: var(--bad);
  font-size: 0.9rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.login-field input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

.login-field input:focus {
  outline: 2px solid #b7c9dc;
  outline-offset: 1px;
}

.login-btn {
  margin-top: 4px;
  padding: 11px 14px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.login-btn:active {
  transform: translateY(1px);
}
