:root {
  --bg: #eef4f8;
  --panel: #ffffff;
  --ink: #152033;
  --muted: #667085;
  --line: #d8dee9;
  --line-soft: #edf1f6;
  --soft: #f8fafc;
  --green: #15805d;
  --green-soft: #e9f7f1;
  --red: #d92d20;
  --red-soft: #fff1f0;
  --amber: #f07818;
  --amber-soft: #fff5eb;
  --blue: #1f6feb;
  --code: #0f172a;
  --shadow: 0 22px 60px rgba(20, 34, 55, 0.08);
  --shadow-soft: 0 12px 28px rgba(20, 34, 55, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  background:
    radial-gradient(circle at 18% 10%, rgba(21, 128, 93, 0.08), transparent 28%),
    linear-gradient(130deg, #f7fbff 0%, #eef4fb 54%, #eef9f5 100%);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
}

button,
select,
input,
textarea {
  font: inherit;
}

button,
a {
  border-radius: 8px;
}

button {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  padding: 8px 12px;
}

button:hover,
a:hover {
  border-color: var(--green);
}

a {
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 8px 12px;
  text-decoration: none;
}

h1,
h2,
h3,
p {
  margin: 0;
}

[hidden] {
  display: none !important;
}

.qa-shell {
  min-height: 100vh;
}

.qa-topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(210, 220, 234, 0.76);
  display: flex;
  gap: 16px;
  height: 56px;
  justify-content: space-between;
  padding: 0 16px;
}

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

.brand-mark {
  align-items: center;
  background: var(--green);
  border-radius: 8px;
  color: #fff;
  display: inline-flex;
  font-size: 15px;
  font-weight: 900;
  height: 28px;
  justify-content: center;
  width: 28px;
}

.qa-topbar h1 {
  font-size: 22px;
  letter-spacing: 0;
}

.top-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.api-copy {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.api-status {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  gap: 6px;
}

.api-status::before {
  background: var(--muted);
  border-radius: 50%;
  content: "";
  height: 8px;
  width: 8px;
}

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

.api-status.ok::before {
  background: var(--green);
}

.api-status.fail {
  color: var(--red);
}

.api-status.fail::before {
  background: var(--red);
}

.qa-board {
  display: grid;
  gap: 12px;
  grid-template-columns: 360px minmax(0, 1fr) 330px;
  height: calc(100vh - 80px);
  padding: 14px;
}

.session-panel,
.center-panel,
.report-panel {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(210, 220, 234, 0.9);
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
}

.session-panel,
.report-panel {
  min-height: 0;
  overflow: auto;
  padding: 14px;
}

.panel-title {
  margin-bottom: 12px;
}

.panel-title h2 {
  font-size: 18px;
  letter-spacing: 0;
}

.history-search-row {
  display: grid;
}

.batch-sync-panel {
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
}

.batch-sync-panel label {
  display: grid;
  gap: 4px;
}

.batch-sync-panel span,
.batch-sync-panel small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.batch-sync-panel button {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.batch-sync-panel button:disabled {
  cursor: wait;
  opacity: 0.68;
}

input,
select,
textarea {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  padding: 10px 12px;
  width: 100%;
}

.session-filter-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
  margin-top: 10px;
}

.session-filter-grid select,
.session-filter-grid button,
.session-actions-row button {
  min-height: 40px;
}

.session-filter-grid select:first-child {
  grid-column: 1 / -1;
}

.session-filter-grid button {
  grid-column: 1 / -1;
}

.session-actions-row {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 10px;
}

button.danger {
  background: #fff5f5;
  border-color: #ffd1cc;
  color: var(--red);
}

.batch-sync-panel button.danger {
  background: #fff5f5;
  border-color: #ffd1cc;
  color: var(--red);
}

textarea {
  line-height: 1.5;
  resize: vertical;
}

.session-count-line {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  justify-content: space-between;
  margin: 14px 0 10px;
}

.run-list,
.case-list,
.model-picks {
  display: grid;
  gap: 10px;
}

.run-item {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 253, 0.92));
  border: 1px solid rgba(210, 220, 234, 0.95);
  border-radius: 16px;
  color: var(--ink);
  display: grid;
  gap: 8px;
  padding: 0;
  text-align: left;
  width: 100%;
  box-shadow: 0 8px 22px rgba(20, 34, 55, 0.045);
  overflow: hidden;
}

.run-item-main {
  background: transparent;
  border: 0;
  border-radius: 0;
  color: inherit;
  display: grid;
  gap: 8px;
  padding: 14px 14px 10px;
  text-align: left;
  width: 100%;
}

.run-item.active {
  border-color: var(--green);
  box-shadow: inset 4px 0 0 var(--green), var(--shadow-soft);
}

.run-item.archived {
  opacity: 0.62;
}

.run-item-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.run-item strong {
  font-size: 15px;
}

.run-item-head b {
  background: var(--red-soft);
  border: 1px solid #ffc7c2;
  border-radius: 999px;
  color: var(--red);
  font-size: 12px;
  padding: 3px 8px;
}

.run-item-head b.ok {
  background: var(--green-soft);
  border-color: #b9ead6;
  color: var(--green);
}

.run-item-actions {
  align-items: center;
  background: rgba(244, 247, 251, 0.7);
  border-top: 1px solid var(--line-soft);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 8px 10px;
}

.run-item-actions button {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.run-item i {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.run-item span,
.run-item em,
.run-item small {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.35;
}

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

.run-field-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.run-field-grid span {
  background: rgba(248, 250, 252, 0.82);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 6px 7px;
}

.run-field-grid b {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.run-user-preview {
  color: var(--ink) !important;
  font-weight: 800;
}

.center-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  overflow: hidden;
}

.run-overview {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-height: 88px;
  padding: 14px 18px;
}

.title-line {
  align-items: center;
  display: flex;
  gap: 10px;
}

.run-overview h2 {
  font-size: 22px;
}

.run-overview p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.run-submeta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 16px;
  margin-top: 8px;
}

.run-status {
  border-radius: 999px;
  font-size: 12px;
  padding: 4px 8px;
}

.run-status.ok {
  background: var(--green-soft);
  color: var(--green);
}

.run-status.guarded,
.run-status.issue {
  background: var(--amber-soft);
  color: var(--amber);
}

.run-status.fallback,
.run-status.blocked {
  background: var(--red-soft);
  color: var(--red);
}

.model-picks.compact {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.model-pick {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  gap: 2px;
  min-width: 120px;
  max-width: 190px;
  padding: 8px 11px;
  text-align: left;
}

.model-pick strong {
  color: var(--ink);
  font-size: 13px;
}

.model-pick span {
  font-size: 11px;
}

.model-pick.active {
  background: var(--green-soft);
  border-color: var(--green);
  color: var(--green);
}

.chat-card {
  min-height: 0;
  overflow: hidden;
}

.chat-day-separator {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 14px;
  padding: 16px 28px 4px;
}

.chat-day-separator::before,
.chat-day-separator::after {
  background: var(--line);
  content: "";
  flex: 1;
  height: 1px;
}

.chat-replay {
  align-content: start;
  display: grid;
  gap: 0;
  height: 100%;
  max-height: none;
  min-height: 0;
  overflow: auto;
  padding: 8px 24px 20px;
}

.conversation-turn {
  align-content: start;
  align-items: start;
  border-left: 2px dashed var(--line);
  display: grid;
  gap: 8px;
  padding: 10px 0 16px 28px;
  position: relative;
}

.conversation-turn::before {
  align-items: center;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  content: attr(data-round);
  display: flex;
  font-size: 12px;
  font-weight: 800;
  height: 28px;
  justify-content: center;
  left: -15px;
  position: absolute;
  top: 10px;
  width: 28px;
}

.conversation-turn.has-issue {
  border-left-color: var(--amber);
}

.conversation-turn.has-issue::before {
  background: var(--amber-soft);
  border-color: var(--amber);
  color: var(--amber);
}

.conversation-turn.focused-round {
  background: #fffaf4;
  border-left-color: var(--amber);
  border-radius: 0 10px 10px 0;
}

.conversation-turn-head {
  display: none;
}

.chat-bubble {
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 5px;
  max-width: min(520px, 72%);
  min-width: 120px;
  padding: 9px 12px;
  width: fit-content;
}

.chat-bubble.user {
  background: #e8f4ef;
  border-color: #cbe7dc;
  justify-self: end;
}

.chat-bubble.assistant {
  background: var(--soft);
  justify-self: start;
}

.chat-bubble span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chat-bubble p {
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-media {
  border-radius: 8px;
  max-width: min(320px, 100%);
}

.chat-media.image img,
.chat-media.video {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  max-height: 220px;
  max-width: 100%;
  object-fit: contain;
}

.chat-media.voice {
  background: rgba(13, 148, 136, 0.08);
  border: 1px solid rgba(13, 148, 136, 0.18);
  color: #0f766e;
  font-size: 13px;
  font-weight: 800;
  padding: 8px 10px;
}

.chat-media-link {
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.turn-insights {
  align-self: start;
  background: rgba(248, 250, 252, 0.92);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  display: grid;
  gap: 7px 10px;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  justify-self: start;
  margin: 4px 0 2px;
  max-width: min(880px, 100%);
  padding: 8px 10px;
  width: 100%;
}

.turn-insights > span {
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
  grid-column: 1 / -1;
  letter-spacing: 0;
  line-height: 1.2;
}

.turn-insights div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.turn-insights b {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.turn-insights em {
  color: var(--ink);
  font-size: 11px;
  font-style: normal;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.turn-insights.muted {
  grid-template-columns: max-content 1fr;
}

.turn-insights.muted b {
  color: var(--muted);
  font-size: 12px;
}

.turn-insights.muted em {
  color: var(--muted);
}

.timeline-toolbar {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  min-height: 64px;
  padding: 10px 16px;
}

.legend-row,
.jump-tools {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  gap: 12px;
}

.legend-row strong {
  color: var(--ink);
}

.legend-ok,
.legend-issue {
  display: inline-block;
  height: 8px;
  margin-right: 5px;
  width: 8px;
}

.legend-ok {
  background: #b7e2d2;
}

.legend-issue {
  background: var(--amber);
}

.jump-tools input {
  width: 210px;
}

.report-panel {
  display: grid;
  gap: 12px;
  grid-auto-rows: max-content;
}

.report-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.report-block h3 {
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  padding: 12px;
}

.report-metrics {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 12px;
}

.report-metrics article {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  min-height: 72px;
  padding: 10px;
  text-align: center;
}

.report-metrics span,
.kv-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.report-metrics strong {
  font-size: 22px;
}

.report-metrics .metric-ok strong,
.report-metrics .severity-none strong,
.report-metrics .severity-low strong {
  color: var(--green);
}

.report-metrics .metric-warn strong,
.report-metrics .severity-medium strong {
  color: var(--amber);
}

.report-metrics .metric-danger strong,
.report-metrics .severity-high strong {
  color: var(--red);
}

.issue-bars,
.issue-rounds,
.kv-grid {
  display: grid;
  gap: 10px;
  padding: 12px;
}

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

.report-card {
  align-items: start;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  min-height: 82px;
  padding: 10px;
  text-align: left;
}

.report-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.report-card strong {
  font-size: 24px;
  line-height: 1;
}

.report-card em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  line-height: 1.35;
}

.report-card.good strong {
  color: var(--green);
}

.report-card.warn strong {
  color: var(--amber);
}

.report-card.bad strong {
  color: var(--red);
}

.report-note,
.final-report-summary {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  font-size: 12px;
  gap: 6px;
  grid-column: 1 / -1;
  line-height: 1.4;
  padding: 10px;
}

.final-report {
  padding: 12px;
}

.final-report-summary strong {
  color: var(--ink);
  font-size: 15px;
}

.final-report-summary button {
  margin-top: 4px;
  width: 100%;
}

.issue-bar {
  display: grid;
  gap: 6px;
}

.issue-bar-row {
  align-items: center;
  display: flex;
  font-size: 12px;
  justify-content: space-between;
}

.issue-bar-track {
  background: #e9edf3;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.issue-bar-fill {
  background: linear-gradient(90deg, var(--amber), #f04438);
  height: 100%;
}

.issue-round {
  background: transparent;
  border-bottom: 1px solid var(--line-soft);
  border-left: 0;
  border-radius: 0;
  border-right: 0;
  border-top: 0;
  color: inherit;
  display: grid;
  gap: 4px;
  padding-bottom: 8px;
  text-align: left;
  width: 100%;
}

.issue-round:last-child {
  border-bottom: 0;
}

.issue-round:hover {
  background: var(--amber-soft);
  border-color: var(--line-soft);
}

.issue-round strong {
  font-size: 13px;
}

.issue-round span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.kv-row {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 9px 10px;
}

.kv-row strong {
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}

#copyReport {
  width: 100%;
}

.report-modal {
  inset: 0;
  position: fixed;
  z-index: 20;
}

.report-modal-backdrop {
  background: rgb(15 23 42 / 0.42);
  inset: 0;
  position: absolute;
}

.report-modal-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 24px 80px rgb(15 23 42 / 0.24);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  left: 50%;
  max-height: min(760px, calc(100vh - 48px));
  max-width: min(760px, calc(100vw - 32px));
  overflow: hidden;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 760px;
}

.report-modal-panel header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 14px 16px;
}

.report-modal-panel h2 {
  font-size: 18px;
}

.report-modal-body {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding: 14px;
}

.sync-modal-panel {
  max-width: min(520px, calc(100vw - 32px));
  width: 520px;
}

.sync-modal-body {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.sync-quick-ranges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sync-quick-ranges span {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  flex: 0 0 100%;
  font-size: 12px;
  font-weight: 800;
}

.sync-quick-ranges button {
  background: #fff;
  border-color: var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 12px;
  min-height: 34px;
  padding: 0 12px;
}

.sync-quick-ranges button:hover {
  border-color: var(--green);
  color: var(--green);
}

.sync-form-slot {
  display: grid;
  gap: 10px;
}

.sync-form-slot label {
  display: grid;
  gap: 6px;
}

.sync-form-slot span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

#syncModalStart {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  min-height: 42px;
}

#syncModalStart:disabled {
  cursor: wait;
  opacity: 0.68;
}

.sync-progress-card {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.sync-progress-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.sync-progress-head strong {
  font-size: 14px;
}

.sync-progress-head span {
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
}

.sync-progress-track {
  background: #e5eaf0;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.sync-progress-track i {
  background: linear-gradient(90deg, var(--green), #43c59e);
  display: block;
  height: 100%;
  transition: width 0.2s ease;
  width: 0;
}

.sync-progress-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.modal-evidence {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 12px;
}

.modal-evidence h3 {
  font-size: 14px;
}

.modal-evidence p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.modal-evidence strong {
  color: var(--ink);
}

.modal-evidence button {
  justify-self: start;
  margin-top: 2px;
}

.modal-raw {
  background: var(--soft);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 9px;
}

.modal-raw span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

pre,
code {
  background: var(--code);
  color: #e5e7eb;
  font-size: 12px;
  line-height: 1.5;
  margin: 0;
  max-height: 420px;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
}

.empty,
.monitor-empty,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.58);
}

.run-loading {
  display: grid;
  gap: 8px;
}

.run-loading strong::before {
  animation: spin 0.8s linear infinite;
  border: 2px solid rgba(24, 137, 98, 0.16);
  border-top-color: var(--green);
  border-radius: 999px;
  content: "";
  display: inline-block;
  height: 14px;
  margin-right: 8px;
  vertical-align: -2px;
  width: 14px;
}

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

.error-empty {
  display: grid;
  gap: 10px;
  color: var(--red);
}

.error-empty span {
  color: var(--muted);
}

@media (max-width: 1280px) {
  .qa-board {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .report-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .qa-topbar,
  .top-actions,
  .run-overview,
  .timeline-toolbar {
    align-items: flex-start;
    flex-direction: column;
    height: auto;
  }

  .qa-board,
  .report-metrics,
  .turn-insights {
    grid-template-columns: 1fr;
  }

  .qa-board {
    height: auto;
  }

  .session-panel,
  .report-panel {
    max-height: none;
  }
}
