.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  width: fit-content;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 8px 20px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}

.tab-btn:hover { color: var(--text); background: var(--bg); }
.tab-btn.active {
  background: var(--primary);
  color: #fff;
}

.panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel.active { display: block; }

.toolbar {
  display: flex;
  align-items: center;
}

.panel > .toolbar {
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.list-count {
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.toolbar-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  justify-content: flex-end;
}

.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--border); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803d; }

.btn-info { background: var(--primary); color: #fff; }
.btn-info:hover:not(:disabled) { background: var(--primary-hover); }

.btn-sm {
  padding: 4px 12px;
  font-size: 0.8125rem;
}

.btn-qa-added {
  background: var(--success);
  color: #fff;
  border: 1px solid var(--success);
  cursor: not-allowed;
}

.btn.loading::after {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 8px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

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

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

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: var(--bg);
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

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

#wechat-table-body tr.wechat-context-anchor td {
  background: #eff6ff;
  box-shadow: inset 0 1px 0 rgba(37, 99, 235, 0.32), inset 0 -1px 0 rgba(37, 99, 235, 0.32);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

#wechat-table-body tr.wechat-context-anchor td:first-child {
  box-shadow: inset 3px 0 0 var(--primary), inset 0 1px 0 rgba(37, 99, 235, 0.32), inset 0 -1px 0 rgba(37, 99, 235, 0.32);
}

.cell-text {
  max-width: 560px;
  word-break: break-word;
}

.status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-pending { background: #f1f5f9; color: var(--muted); }
.status-running { background: #dbeafe; color: var(--primary); }
.status-done { background: #dcfce7; color: var(--success); }
.status-failed { background: #fee2e2; color: var(--danger); }

.rating {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.rating-unrated { background: #f1f5f9; color: var(--muted); }
.rating-good { background: #dcfce7; color: var(--success); }
.rating-medium { background: #fef9c3; color: #ca8a04; }
.rating-bad { background: #fee2e2; color: var(--danger); }

.need-reply-no { color: var(--muted); }
.need-reply-yes { color: var(--danger); font-weight: 500; }

.qa-added-yes { color: var(--success); font-weight: 500; }
.qa-added-no { color: var(--muted); }

.content-type-text { color: var(--primary); }
.content-type-image { color: var(--danger); font-weight: 500; }
.content-type-voice { color: #ca8a04; }
.content-type-video { color: var(--success); }
.content-type-file { color: #9333ea; }
.content-type-other { color: var(--muted); }

.empty, .loading-row {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px !important;
}

.loading-indicator {
  text-align: center;
  color: var(--muted);
  padding: 16px;
  font-size: 0.875rem;
}

td.actions {
  display: table-cell;
  white-space: nowrap;
  width: 1%;
}

td.actions .btn + .btn {
  margin-left: 8px;
}

dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  max-width: 760px;
  width: calc(100% - 32px);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.18);
  margin: auto;
  position: fixed;
  inset: 0;
  height: fit-content;
  max-height: calc(100vh - 48px);
  overflow: hidden;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.4);
}

#issue-wechat-relation-dialog {
  max-width: 1400px;
}

#issue-wechat-new-dialog {
  max-width: 1120px;
}

#issue-wechat-relation-dialog .dialog-body,
#issue-wechat-new-dialog .dialog-body {
  max-height: 85vh;
  min-height: 480px;
}

#qa-new-dialog[open] {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 24px);
  max-height: calc(100vh - 24px);
}

#qa-new-dialog .dialog-body {
  flex: 1;
  max-height: none;
  min-height: 0;
}

.dialog-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  font-size: 1.0625rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dialog-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-height: 70vh;
  overflow-y: auto;
}

.dialog-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.toolbar-wechat {
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
}

.toolbar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.filter-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-item label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
}

.date-shortcuts {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-bottom: 1px;
  flex-shrink: 0;
}

.date-shortcut-btn {
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.date-shortcut-btn:hover,
.date-shortcut-btn:focus-visible {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.18);
  outline: none;
}

.date-input,
.filter-item input[type="date"] {
  width: 160px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text);
}

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

input[type="date"]::-webkit-datetime-edit-fields-wrapper {
  padding: 0;
}

input[type="date"]::-webkit-datetime-edit-text,
input[type="date"]::-webkit-datetime-edit-month-field,
input[type="date"]::-webkit-datetime-edit-day-field,
input[type="date"]::-webkit-datetime-edit-year-field {
  color: var(--text);
}

.filter-item input[type="text"] {
  width: 100%;
  min-width: 240px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}

.date-input:focus,
.filter-item input[type="date"]:focus,
.filter-item input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.filter-item select,
.toolbar-select {
  min-width: 140px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}

.filter-item select:focus,
.toolbar-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.filter-item-grow {
  flex: 1;
  min-width: 200px;
}

#wechat-list .filter-item-search {
  flex: 0 0 auto;
}

#wechat-list .filter-item-search input[type="text"] {
  width: 280px;
  min-width: 120px;
}

.filter-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

#wechat-page-info,
#wechat-user-page-info,
#issue-wechat-page-info {
  font-size: 0.875rem;
  color: var(--muted);
}

.dialog-body .toolbar {
  border-bottom: none;
  padding: 0;
  gap: 8px;
}

.dialog-body .toolbar input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--surface);
  line-height: 1.5;
}

.dialog-body .toolbar input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
