:root {
  --bg: #f5f7fb;
  --bg-elev: #ffffff;
  --bg-soft: #f2f4f8;
  --line: #dbe2ec;
  --line-strong: #c8d2e1;
  --text: #102030;
  --muted: #5a6b80;
  --heading: #0d1a2b;
  --accent: #0d6efd;
  --accent-soft: #e7f1ff;
  --good: #0b8f57;
  --good-soft: #e8f8f0;
  --bad: #c53d4a;
  --bad-soft: #ffeef1;
  --neutral: #7a8798;
  --shadow-sm: 0 1px 2px rgba(10, 30, 60, 0.08);
  --shadow-md: 0 8px 22px rgba(10, 25, 55, 0.08);
  --radius-md: 12px;
  --radius-lg: 18px;
  --font-ui: "Manrope", "Segoe UI", sans-serif;
  --font-display: "Sora", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--text);
  background: radial-gradient(1200px 600px at 15% -10%, #e8f2ff 0%, transparent 70%),
    radial-gradient(1000px 520px at 95% -25%, #eafaf5 0%, transparent 68%),
    var(--bg);
  line-height: 1.4;
  overflow-x: hidden;
}

body.auth-open {
  overflow: hidden;
}

.backdrop-grid {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(15, 65, 130, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 65, 130, 0.03) 1px, transparent 1px);
  background-size: 34px 34px;
  pointer-events: none;
  z-index: -2;
}

.backdrop-glow {
  position: fixed;
  width: 420px;
  height: 420px;
  border-radius: 999px;
  filter: blur(68px);
  pointer-events: none;
  z-index: -1;
  opacity: 0.65;
}

.glow-a {
  top: -180px;
  left: -120px;
  background: rgba(13, 110, 253, 0.22);
}

.glow-b {
  right: -130px;
  top: -150px;
  background: rgba(27, 169, 118, 0.2);
}

.topbar {
  width: min(1320px, calc(100% - 40px));
  margin: 22px auto 12px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  animation: fade-slide 0.55s ease both;
}

.brand {
  max-width: 760px;
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid #b9d2ff;
  background: #f0f6ff;
  color: #0f4fa8;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.brand h1 {
  margin: 10px 0 8px;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 2.7vw, 2.35rem);
  color: var(--heading);
}

.brand p {
  margin: 0;
  color: var(--muted);
  max-width: 620px;
}

.topbar-meta {
  display: grid;
  gap: 9px;
  min-width: 220px;
}

.topbar-meta .btn {
  justify-self: end;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow-sm);
  color: var(--muted);
  font-size: 0.84rem;
}

.label {
  font-weight: 700;
  color: #38516f;
}

.workspace {
  width: min(1320px, calc(100% - 40px));
  margin: 0 auto 28px;
  display: grid;
  gap: 12px;
}

.tab-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 4px;
  border: 1px solid #d7e2f0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-sm);
}

.tab-button {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  background: transparent;
  color: #35597f;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.tab-button:hover {
  background: #f0f6ff;
}

.tab-button.active {
  background: #e8f2ff;
  border-color: #b8d4ff;
  color: #114783;
}

.tab-panel {
  min-width: 0;
}

.card {
  background: color-mix(in srgb, var(--bg-elev) 95%, #f5fbff 5%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  animation: fade-slide 0.55s ease both;
}

.launch-card {
  padding: 14px;
  max-width: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 10px 12px;
  align-items: start;
}

.launch-card .card-head {
  grid-column: 1 / -1;
  margin-bottom: 2px;
}

.form-grid.launch-form {
  grid-column: 1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.launch-card .job-panel {
  grid-column: 2;
  margin-top: 0;
}

.launch-form .field {
  gap: 3px;
}

.launch-form .field span {
  font-size: 0.68rem;
}

.launch-form .input {
  padding: 7px 9px;
  font-size: 0.84rem;
}

.launch-form .textarea {
  min-height: 50px;
}

.launch-form .toggle {
  font-size: 0.8rem;
}

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

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

.field-span-4 {
  grid-column: span 4;
}

.actions.actions-wide {
  grid-column: 1 / -1;
  margin-top: 0;
}

.results-card {
  padding: 16px;
}

.chart-card {
  padding: 16px;
}

.card-head {
  margin-bottom: 14px;
}

.card-head-inline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.card-head h2 {
  margin: 0;
  font-size: 1.18rem;
  color: var(--heading);
}

.muted {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

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

.field {
  display: grid;
  gap: 5px;
}

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

.field span {
  font-size: 0.76rem;
  font-weight: 700;
  color: #314761;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.input:focus {
  outline: none;
  border-color: #7eb2ff;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.14);
}

.textarea {
  resize: vertical;
  min-height: 74px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: #294765;
  font-weight: 600;
}

.toggle input {
  width: 15px;
  height: 15px;
}

.actions {
  grid-column: span 2;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

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

.btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 16px rgba(13, 110, 253, 0.25);
}

.btn.soft {
  background: #eef5ff;
  color: #16417c;
  border-color: #cde0ff;
}

.btn.ghost {
  background: #fff;
  color: #2a4c6f;
  border-color: var(--line);
}

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

.btn.active {
  background: #0f4fa8;
  border-color: #0f4fa8;
  color: #fff;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.65;
  transform: none;
}

.job-panel {
  margin-top: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
}

.job-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #dce7f6;
  overflow: hidden;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #0d6efd, #2f86ff);
  transition: width 0.25s ease;
}

.job-meta {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.76rem;
  color: var(--muted);
}

.job-link {
  margin-top: 8px;
  display: inline-block;
  font-size: 0.82rem;
  color: #1454b1;
  font-weight: 700;
  text-decoration: none;
}

.job-link:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) repeat(5, auto);
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(9, 23, 43, 0.48);
  backdrop-filter: blur(10px);
}

.auth-dialog {
  width: min(440px, 100%);
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 48px rgba(10, 24, 51, 0.18);
}

.auth-dialog__head h2 {
  margin: 12px 0 8px;
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--heading);
}

.auth-dialog__head p {
  margin: 0 0 14px;
  color: var(--muted);
}

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

.auth-message {
  min-height: 20px;
}

.run-cell__meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.model-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.model-badge.api {
  color: #0f4fa8;
  background: #e8f2ff;
  border: 1px solid #bfd6ff;
}

.model-badge.local {
  color: #0b8f57;
  background: #e8f8f0;
  border: 1px solid #b7e7cd;
}

.item-row {
  cursor: pointer;
}

.item-details-row td {
  padding: 0;
  background: #fbfdff;
}

.item-detail-panel {
  padding: 14px;
  display: grid;
  gap: 12px;
}

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

.item-detail-block {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.item-detail-block strong {
  color: var(--heading);
}

.item-detail-block pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: inherit;
  color: var(--text);
}

.item-detail-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.rerank-impact-table th:last-child,
.rerank-impact-table td:last-child {
  min-width: 92px;
}

.delta-chip {
  font-weight: 700;
  color: var(--neutral);
}

.delta-chip.positive {
  color: var(--good);
}

.delta-chip.negative {
  color: var(--bad);
}

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

.legend-item {
  display: inline-flex;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.74rem;
  font-weight: 700;
}

.legend-item.good {
  color: var(--good);
  border-color: #a9e2c8;
  background: var(--good-soft);
}

.legend-item.bad {
  color: var(--bad);
  border-color: #f2b8c0;
  background: var(--bad-soft);
}

.legend-item.neutral {
  color: var(--neutral);
  border-color: #d5dce6;
  background: #f3f6fa;
}

.legend-item.best {
  color: #0b8f57;
  border-color: #98d5ba;
  background: #e6f7ef;
}

.legend-item.second {
  color: #a85a00;
  border-color: #ffd09a;
  background: #fff4e6;
}

.legend-item.base {
  color: #1f4f8f;
  border-color: #c6daff;
  background: #edf4ff;
}

.scatter-shell {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 6px;
  min-height: 460px;
}

.score-chart {
  width: 100%;
  height: auto;
  display: block;
}

.chart-hint {
  margin-top: 10px;
}

.chart-plot-bg {
  fill: #fbfdff;
}

.chart-grid-line {
  stroke: #e6edf7;
  stroke-width: 1;
}

.chart-axis-line {
  stroke: #9fb3cc;
  stroke-width: 1.4;
}

.chart-axis-title {
  fill: #1f4f8f;
  font-size: 14px;
  font-weight: 700;
}

.chart-axis-text {
  fill: #627891;
  font-size: 12px;
}

.chart-point {
  stroke: #fff;
  stroke-width: 2;
  cursor: pointer;
  transition: opacity 0.16s ease;
}

.chart-point.regular {
  fill: #1e6ad9;
  opacity: 0.82;
}

.chart-point.best {
  fill: #0b8f57;
  opacity: 0.96;
}

.chart-point.second {
  fill: #ff8f1f;
  opacity: 0.94;
}

.chart-point:hover,
.chart-point:focus-visible {
  opacity: 1;
  stroke: #0f2f52;
  outline: none;
}

.chart-point-rank {
  fill: #21466f;
  font-size: 11px;
  font-weight: 700;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

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

thead th {
  text-align: left;
  white-space: nowrap;
  font-weight: 700;
  color: #38516f;
  padding: 10px 11px;
  background: #f7fbff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr {
  border-bottom: 1px solid #edf2f9;
  transition: background-color 0.16s ease;
  cursor: pointer;
}

tbody tr:hover {
  background: #f8fbff;
}

tbody td {
  white-space: nowrap;
  padding: 9px 11px;
  vertical-align: top;
}

.details-row td {
  padding: 0;
  background: transparent;
  border-bottom: none;
  overflow-x: hidden;
}

.metric-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 700;
}

.metric-chip.good {
  color: var(--good);
  background: var(--good-soft);
  border-color: #b4e7cf;
}

.metric-chip.bad {
  color: var(--bad);
  background: var(--bad-soft);
  border-color: #f6c2c9;
}

.metric-chip.neutral {
  color: var(--neutral);
  background: #f3f6fa;
  border-color: #dde5ef;
}

.metric-max {
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.2);
}

.details-panel {
  background: #fcfdff;
  border-top: 1px solid var(--line);
  padding: 14px;
  width: 100%;
  min-width: 0;
  max-height: 70vh;
  overflow-x: hidden;
  overflow-y: auto;
}

.details-panel .table-wrap {
  max-width: 100%;
}

.details-panel thead th {
  position: static;
  white-space: normal;
}

.details-panel tbody td {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.detail-section {
  margin-bottom: 14px;
}

.detail-section h3 {
  margin: 0 0 8px;
  color: #1e4a80;
  letter-spacing: 0.05em;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.detail-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.detail-card {
  background: #f6faff;
  border: 1px solid #dbe9f8;
  border-radius: 10px;
  padding: 9px;
}

.detail-card span {
  display: block;
  font-size: 0.74rem;
  color: var(--muted);
}

.detail-card strong {
  color: #102e4f;
}

.metrics-columns {
  display: grid;
  grid-template-columns: 1fr 1.3fr 1fr;
  gap: 10px;
  align-items: start;
}

.metric-block-wide {
  grid-column: 2 / 3;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

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

.metric-card.good {
  border-color: #afdfc7;
  background: var(--good-soft);
}

.metric-card.bad {
  border-color: #f3c0c8;
  background: var(--bad-soft);
}

.metric-card.neutral {
  border-color: #dce4ee;
  background: #f8fbff;
}

.metric-card span {
  font-size: 0.72rem;
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin-top: 2px;
  color: #163a61;
}

.text-expander {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  background: #fff;
  color: #1f3a56;
  text-align: left;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.text-expander:hover,
.text-expander:focus-visible {
  border-color: #84b8ff;
  outline: none;
  background: #f4f9ff;
}

pre {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
  color: #1b3553;
  max-height: 280px;
  overflow: auto;
  font-size: 0.78rem;
  line-height: 1.4;
}

.details-panel pre {
  max-width: 100%;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.config-snapshot-toggle {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 10px;
  margin-bottom: 8px;
  background: #fff;
  color: #2a4c6f;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.config-snapshot-toggle:hover,
.config-snapshot-toggle:focus-visible {
  border-color: #84b8ff;
  outline: none;
  background: #f4f9ff;
}

.details-panel .config-snapshot-pre {
  max-height: none;
  overflow: visible;
}

.details-panel .config-snapshot-pre.collapsed {
  display: none;
}

.modal-shell {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(7, 24, 46, 0.25);
  backdrop-filter: blur(3px);
  z-index: 2000;
}

.modal-shell.visible {
  display: flex;
}

.modal-dialog {
  width: min(960px, 92vw);
  max-height: 82vh;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 24px 56px rgba(5, 23, 46, 0.2);
  overflow: hidden;
}

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

.modal-title {
  margin: 0;
  font-size: 0.9rem;
  color: #1d4f8a;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.modal-close {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  background: #fff;
}

.modal-body {
  padding: 10px 12px;
}

.modal-body pre {
  max-height: 68vh;
  white-space: pre-wrap;
  word-break: break-word;
}

body.modal-open {
  overflow: hidden;
}

.metrics-popover {
  position: absolute;
  display: none;
  flex-direction: column;
  min-width: 250px;
  max-width: 420px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 20px 40px rgba(8, 28, 50, 0.15);
  z-index: 1800;
  overflow: hidden;
}

.metrics-popover.visible {
  display: flex;
}

.metrics-popover__header {
  padding: 8px 10px;
  background: #f7fbff;
  border-bottom: 1px solid var(--line);
  color: #2a4f7a;
  font-size: 0.78rem;
  font-weight: 700;
}

.metrics-popover__meta {
  padding: 6px 10px 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.metrics-popover__body {
  border: none;
  border-radius: 0;
  max-height: 280px;
  background: #fff;
}

.compare-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
  padding-bottom: 10px;
}

.compare-tab {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  background: #fff;
  color: #35597f;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.compare-tab.active {
  border-color: #9bc4ff;
  background: #eaf3ff;
  color: #134888;
}

.compare-content.hidden {
  display: none;
}

.config-diff.same {
  color: var(--muted);
}

.config-diff.different {
  color: #184f93;
  font-weight: 700;
}

.details-panel .config-diff {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.details-panel.compare-panel {
  max-height: none;
  overflow: visible;
}

.details-panel.compare-panel .table-wrap {
  overflow: visible;
}

.details-panel.compare-panel table {
  width: 100%;
  table-layout: fixed;
}

.details-panel.compare-panel thead th,
.details-panel.compare-panel tbody td {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  vertical-align: top;
}

.details-panel.compare-panel .metric-chip {
  min-width: 0;
  width: 100%;
  padding: 2px 4px;
  font-size: 0.68rem;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 3px 9px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-chip.good {
  color: var(--good);
  background: var(--good-soft);
  border-color: #b4e7cf;
}

.status-chip.bad {
  color: var(--bad);
  background: var(--bad-soft);
  border-color: #f6c2c9;
}

.status-chip.neutral {
  color: var(--neutral);
  background: #f0f4f8;
  border-color: #dbe2ec;
}

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

  .launch-card {
    grid-template-columns: 1fr;
  }

  .form-grid.launch-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .launch-card .job-panel {
    grid-column: 1;
    margin-top: 4px;
  }

  .launch-form .field-span-3 {
    grid-column: span 2;
  }
}

@media (max-width: 980px) {
  .card-head-inline {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .metric-block-wide {
    grid-column: span 2;
  }

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

  .item-detail-grid {
    grid-template-columns: 1fr;
  }

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

  .launch-form .field-span-2,
  .launch-form .field-span-3,
  .launch-form .field-span-4 {
    grid-column: span 2;
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-meta .btn {
    justify-self: stretch;
  }

  .tab-nav {
    grid-template-columns: 1fr;
    display: grid;
  }

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

  .field-wide,
  .actions,
  .actions-wide,
  .field-span-2,
  .field-span-3,
  .field-span-4 {
    grid-column: span 1;
  }

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

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

  .metric-block-wide {
    grid-column: span 1;
  }

  .launch-card {
    max-width: none;
    padding: 12px;
    gap: 8px;
  }

  .launch-form .field span {
    font-size: 0.7rem;
  }

  .launch-form .input {
    font-size: 0.86rem;
  }

  .scatter-shell {
    min-height: 320px;
    padding: 4px;
  }
}

/* LLM Perf */

.llm-perf-launch-card {
  grid-template-columns: minmax(0, 1fr) 320px;
}

.llm-perf-run-selector {
  display: flex;
  gap: 8px;
  align-items: center;
}

.llm-perf-run-selector .input {
  min-width: 260px;
}

.llm-perf-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.llm-perf-chart-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
}

.llm-perf-chart-card h3 {
  margin: 0 0 8px;
  font-size: 0.88rem;
  color: #1e4a80;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.lp-chart {
  width: 100%;
  height: auto;
  display: block;
}

.lp-grid-line {
  stroke: #e6edf7;
  stroke-width: 1;
}

.lp-axis-line {
  stroke: #9fb3cc;
  stroke-width: 1.4;
}

.lp-axis-text {
  fill: #627891;
  font-size: 11px;
}

.lp-axis-title {
  fill: #1f4f8f;
  font-size: 12px;
  font-weight: 700;
}

.lp-line {
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lp-marker {
  stroke: #fff;
  stroke-width: 1.8;
}

.lp-legend-text {
  fill: #38516f;
  font-size: 11px;
  font-weight: 600;
}

.llm-perf-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.llm-perf-summary .metric-card strong {
  font-size: 1.05rem;
}

@media (max-width: 1080px) {
  .llm-perf-launch-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .llm-perf-charts-grid {
    grid-template-columns: 1fr;
  }

  .llm-perf-run-selector {
    flex-direction: column;
    align-items: stretch;
  }

  .llm-perf-run-selector .input {
    min-width: 0;
  }
}

/* ── Datasets & Models tabs ──────────────────────────────── */
#datasets-table td,
#models-table td {
  vertical-align: middle;
  font-size: 0.9rem;
}

#models-table td:nth-child(2) {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.82rem;
  color: var(--muted);
}

#models-table td:nth-child(4) {
  font-size: 0.8rem;
  color: var(--muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#add-model-panel form {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  animation: fade-slide 0.15s ease;
}

.toolbar select#dataset-filter {
  min-width: 140px;
}

@keyframes fade-slide {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
