:root {
  color-scheme: light;
  --bg: #f9f8f9;
  --surface: #ffffff;
  --surface-soft: #fbfaff;
  --text: #231d33;
  --muted: #6b6679;
  --border: #e6e5e8;
  --accent: #6239c6;
  --accent-dark: #5130a3;
  --ok-bg: #e8f7ef;
  --ok-text: #1f6b46;
  --err-bg: #ffeceb;
  --err-text: #9f1e1b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top right, #efe9ff 0%, var(--bg) 48%);
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.header {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
}

.header-inner {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.title {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.header-links {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.header-link {
  text-decoration: none;
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
}

.main {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 14px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.status {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 10px 12px;
  font-size: 13px;
}

.status.success {
  border-color: #bbe3ca;
  background: var(--ok-bg);
  color: var(--ok-text);
}

.status.error {
  border-color: #ffcfc9;
  background: var(--err-bg);
  color: var(--err-text);
}

.filters {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  padding: 12px;
}

.filters-form {
  display: grid;
  grid-template-columns: 1.2fr 0.7fr 1.1fr 130px auto;
  gap: 8px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 9px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

input:focus,
select:focus {
  outline: 2px solid #8160d1;
  border-color: #8160d1;
}

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

.btn {
  border: 0;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

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

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.btn-soft {
  background: #ebe7f7;
  color: #413a53;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 12px;
  min-height: 520px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(35, 29, 51, 0.08);
  overflow: hidden;
  min-height: 0;
}

.panel-head {
  border-bottom: 1px solid var(--border);
  padding: 11px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-title {
  margin: 0;
  font-size: 14px;
}

.panel-subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.list-body {
  height: calc(100% - 66px);
  min-height: 420px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
}

.log-row {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
  padding: 10px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.log-row:hover {
  border-color: #cfc1f3;
  background: #faf8ff;
}

.log-row.active {
  border-color: #b59dea;
  background: #f3eeff;
}

.row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.conversation-id {
  font-size: 12px;
  font-weight: 800;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

.row-time {
  font-size: 11px;
  color: var(--muted);
}

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

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid #d9d0f3;
  background: #f2eeff;
  color: #4d3994;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
}

.chip.ok {
  border-color: #9ed3b6;
  background: #e9f8f0;
  color: #1d6b45;
}

.chip.err {
  border-color: #f0b8b5;
  background: #ffefee;
  color: #992522;
}

.preview {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: #3a3550;
}

.empty {
  border: 1px dashed var(--border);
  border-radius: 12px;
  text-align: center;
  color: var(--muted);
  padding: 16px;
  font-size: 13px;
}

.pager {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pager-info {
  color: var(--muted);
  font-size: 12px;
}

.detail-body {
  height: calc(100% - 66px);
  min-height: 420px;
  overflow: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.chat-preview {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, #f8f4ff 0%, #f6f2ff 100%);
  overflow: hidden;
}

.chat-preview-head {
  border-bottom: 1px solid #ddd3f2;
  padding: 9px 10px;
  background: #efe8ff;
}

.chat-preview-title {
  margin: 0;
  font-size: 13px;
}

.chat-preview-subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.chat-preview-body {
  padding: 10px;
}

.chat-turn {
  border: 1px dashed #d5caef;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.86);
  padding: 9px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.chat-turn + .chat-turn {
  margin-top: 8px;
}

.chat-turn-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.chat-turn-label {
  font-weight: 700;
}

.chat-row {
  display: flex;
}

.chat-row.user {
  justify-content: flex-end;
}

.chat-bubble {
  max-width: min(640px, 100%);
  border-radius: 12px;
  border: 1px solid #e0d8f3;
  background: #fff;
  padding: 9px 10px;
}

.chat-row.user .chat-bubble {
  border-color: #6239c6;
  background: #6239c6;
  color: #fff;
}

.chat-row.assistant .chat-bubble {
  color: #322f41;
}

.chat-bubble-text {
  font-size: 13px;
  line-height: 1.42;
  word-break: break-word;
}

.chat-bubble-text em {
  opacity: 0.85;
}

.chat-bubble-text a {
  color: inherit;
  text-decoration: underline;
}

.chat-bubble-text strong {
  font-weight: 800;
}

.chat-attachments {
  margin-top: 7px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid #ddd1f5;
  background: #f2ecff;
  color: #4b3a8f;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
}

.chat-row.user .attachment-chip {
  border-color: rgba(255, 255, 255, 0.48);
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.event-card {
  width: min(640px, 100%);
  border-radius: 11px;
  border: 1px solid #dfd4f3;
  background: #fff;
  padding: 9px 10px;
}

.event-card-title {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
}

.event-card-subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  color: #443f57;
  line-height: 1.4;
}

.cta-list {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cta-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid #d5c8f3;
  background: #f3eeff;
  color: #4a3792;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  padding: 4px 8px;
}

.cta-chip:hover {
  background: #ede6ff;
}

.event-card.cta {
  border-color: #bfe4cf;
  background: #f0fbf5;
}

.event-card.translation {
  border-color: #d5c8f3;
  background: #f4eeff;
}

.event-card.error {
  border-color: #f0b7b3;
  background: #ffefee;
}

.technical-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.summary-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 8px 9px;
}

.summary-key {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.summary-value {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.35;
  word-break: break-word;
}

details.json-block {
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
}

details.json-block > summary {
  list-style: none;
  cursor: pointer;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

details.json-block > summary::-webkit-details-marker {
  display: none;
}

.summary-title {
  font-size: 13px;
  font-weight: 700;
}

.summary-actions {
  display: inline-flex;
  gap: 6px;
}

.json-wrap {
  border-top: 1px solid var(--border);
  padding: 9px;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.45;
  color: #243555;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

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

  .list-body,
  .detail-body {
    min-height: 300px;
  }
}

@media (max-width: 860px) {
  .filters-form {
    grid-template-columns: 1fr;
  }

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

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}
