/* This file is for your main application CSS */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-muted: #eef1f4;
  --text: #161a1f;
  --muted: #64707d;
  --line: #d9dee5;
  --accent: #2f6fed;
  --ok: #16803c;
  --warn: #996400;
  --bad: #b42318;
  --running: #265fbc;
  --shadow: 0 12px 32px rgba(22, 26, 31, 0.08);
}

body {
  background: var(--bg);
  color: var(--text);
}

.app-nav {
  display: flex;
  gap: 16px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.app-nav a {
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}

.app-nav form {
  margin: 0;
}

.app-nav button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.dashboard-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.dashboard-header,
.panel-heading,
.header-actions,
.status-grid,
.queue-strip,
.role-list,
.score-list,
.model-row {
  display: flex;
  align-items: center;
}

.dashboard-header {
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.dashboard-header h1 {
  font-size: 30px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: 0;
}

.topic-description {
  max-width: 820px;
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.55;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.button.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}

.button:disabled,
.button[disabled],
.button.secondary:disabled,
.button.secondary[disabled] {
  border-color: var(--line);
  background: var(--surface-muted);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.65;
  box-shadow: none;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  min-height: 84px;
  padding: 16px;
  gap: 10px;
}

.metric p,
.queue-strip span,
.role-list span,
.score-list span,
.model-row span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong,
.queue-strip strong,
.role-list strong,
.score-list strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
  line-height: 1.1;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--muted);
  flex: 0 0 auto;
}

.status-dot.ok,
.pill.ok,
.pill.done {
  background: #e7f6ec;
  color: var(--ok);
}

.status-dot.degraded,
.pill.degraded,
.pill.incomplete,
.status-dot.queued,
.pill.queued,
.pill.pending {
  background: #fff4db;
  color: var(--warn);
}

.status-dot.failed,
.pill.failed,
.pill.error {
  background: #fee4e2;
  color: var(--bad);
}

.status-dot.running,
.pill.running,
.pill.sampling {
  background: #e8f0ff;
  color: var(--running);
}

.status-dot.ok,
.status-dot.degraded,
.status-dot.failed,
.status-dot.running,
.status-dot.queued {
  color: transparent;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.span-2 {
  grid-column: span 2;
}

.span-3 {
  grid-column: 1 / -1;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-heading h2 {
  margin-top: 2px;
  font-size: 18px;
  font-weight: 700;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

button.pill {
  cursor: pointer;
}

.queue-strip,
.role-list,
.score-list {
  gap: 12px;
}

.queue-strip > div,
.role-list > div,
.score-list > div {
  flex: 1 1 0;
  min-width: 0;
  padding: 12px;
  border-radius: 6px;
  background: var(--surface-muted);
}

.role-list,
.score-list {
  flex-direction: column;
}

.role-list > div,
.score-list > div {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.current-round h3 {
  margin: 14px 0 8px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
}

.live-agent-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.live-agent-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.live-agent-row strong,
.live-agent-row span {
  display: block;
}

.live-agent-row span {
  color: var(--muted);
  font-size: 13px;
}

.live-agent-error {
  grid-column: 1 / -1;
  color: var(--bad);
  font-size: 13px;
}

.live-clear-countdown {
  color: var(--muted);
  font-size: 13px;
}

.current-round p,
.empty-state {
  color: var(--muted);
  font-size: 14px;
}

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

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.topic-cell {
  max-width: 520px;
}

.topic-cell a,
.topic-cell span {
  display: block;
}

.topic-cell span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

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

.model-row {
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.model-row strong,
.model-row span {
  display: block;
}

.model-row strong {
  font-size: 14px;
}

.option-list,
.sample-grid,
.error-list,
.topic-form,
.queued-topic-list {
  display: grid;
  gap: 10px;
}

.queued-topic-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.queued-topic-row strong,
.queued-topic-row span {
  display: block;
}

.queued-topic-row strong {
  font-size: 14px;
  line-height: 1.35;
}

.queued-topic-row div > span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.topic-form label,
.topic-form label span {
  display: block;
}

.topic-form label span {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.topic-form input,
.topic-form textarea,
.topic-form select {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}

.topic-form input:disabled,
.topic-form textarea:disabled,
.topic-form select:disabled {
  border-color: var(--line);
  background: var(--surface-muted);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.75;
}

.topic-form input:disabled::placeholder,
.topic-form textarea:disabled::placeholder {
  color: color-mix(in srgb, var(--muted) 70%, white);
}

.topic-form textarea {
  min-height: 92px;
}

.topic-options-form,
.topic-form-footer {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.topic-form-footer {
  grid-template-columns: minmax(140px, 220px) auto;
  align-items: end;
}

.topic-form-footer .button {
  width: fit-content;
}

.form-errors {
  display: grid;
  gap: 6px;
}

.form-errors p {
  padding: 8px 10px;
  border-radius: 6px;
  background: #fee4e2;
  color: var(--bad);
  font-size: 13px;
}

.tick-error {
  margin-top: 10px;
}

.option-row,
.sample-agent,
.sample-row {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.option-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) minmax(130px, auto);
  align-items: center;
  min-height: 44px;
  overflow: hidden;
}

.option-row.winner {
  border-color: var(--ok);
  box-shadow: inset 3px 0 0 var(--ok);
}

.option-row strong {
  display: grid;
  height: 100%;
  place-items: center;
  background: var(--surface-muted);
}

.option-row > span {
  padding: 10px 12px;
  min-width: 0;
}

.option-points {
  display: grid;
  justify-items: end;
  gap: 4px;
  padding: 8px 10px;
  border-left: 1px solid var(--line);
}

.option-points b {
  font-size: 13px;
}

.compact table {
  min-width: 420px;
}

.matrix-wrap {
  max-height: 520px;
}

.matrix-table {
  min-width: 720px;
}

.matrix-table th:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
}

.matrix-table td,
.matrix-table th {
  text-align: right;
  white-space: nowrap;
}

.matrix-table th:first-child {
  text-align: left;
}

.embedding-plot {
  display: grid;
  gap: 12px;
}

.embedding-plot svg {
  width: 100%;
  height: auto;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.embedding-axis {
  stroke: var(--line);
  stroke-width: 1;
}

.embedding-point {
  stroke: #fff;
  stroke-width: 2;
}

.embedding-point-label {
  fill: #fff;
  font-size: 11px;
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
}

.embedding-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.embedding-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.embedding-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

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

.sample-agent {
  overflow: hidden;
}

.sample-agent-heading {
  padding: 12px;
  background: var(--surface-muted);
}

.sample-agent-heading strong,
.sample-agent-heading span {
  display: block;
}

.sample-agent-heading span,
.sample-row p,
.error-list p {
  color: var(--muted);
  font-size: 13px;
}

.sample-row {
  margin: 10px;
  padding: 10px;
}

.sample-row p {
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.sample-row > div {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.sample-index {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 24px;
  border-radius: 4px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.sample-toggle {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.error-list p {
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--surface-muted);
  overflow-wrap: anywhere;
}

.text-link {
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}

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

.setting-value {
  overflow-wrap: anywhere;
}

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

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

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-bottom: 14px;
}

.search-form input {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}

.filter-summary {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 14px;
}

.pagination-bar span {
  color: var(--muted);
  font-size: 14px;
}

.disabled-link {
  pointer-events: none;
  opacity: 0.55;
}

@media (max-width: 980px) {
  .status-grid,
  .dashboard-grid,
  .model-grid,
  .sample-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .span-3 {
    grid-column: auto;
  }
}

@media (max-width: 720px) {
  .dashboard-shell {
    padding: 18px;
  }

  .dashboard-header,
  .queue-strip,
  .pagination-bar,
  .search-form,
  .topic-options-form,
  .topic-form-footer {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

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

  .button,
  .topic-form-footer .button {
    width: 100%;
  }

  .option-row {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .option-points {
    grid-column: 1 / -1;
    justify-items: start;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}
