:root {
  --bg: #f4efe7;
  --paper: rgba(255, 252, 246, 0.9);
  --ink: #18230f;
  --muted: #5c6757;
  --line: rgba(24, 35, 15, 0.12);
  --accent: #1f6f5f;
  --accent-strong: #11473c;
  --danger: #9f3a2d;
  --ok: #1d7a43;
  --warn: #a45d19;
  --shadow: 0 18px 60px rgba(31, 44, 17, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(31, 111, 95, 0.14), transparent 36%),
    radial-gradient(circle at top right, rgba(164, 93, 25, 0.14), transparent 30%),
    linear-gradient(180deg, #f7f2ea 0%, #f1ebe2 100%);
  min-height: 100vh;
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 0;
}

.hero {
  padding: 20px 4px 28px;
}

.hero-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

.auth-user {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.eyebrow {
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.04;
}

.hero-copy {
  max-width: 760px;
  margin: 16px 0 0;
  font-size: 16px;
  line-height: 1.75;
  color: var(--muted);
}

.top-nav {
  margin-top: 22px;
}

.panel {
  margin-top: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--paper);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.auth-panel {
  width: min(520px, 100%);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 20px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}

.auth-error {
  margin: 0;
  color: var(--danger);
  font-size: 14px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-header h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.panel-header p {
  margin: 0;
  color: var(--muted);
}

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

.history-actions {
  align-items: center;
}

.panel-select {
  min-width: 136px;
  width: auto;
  padding-right: 36px;
}

.segmented-control {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: rgba(24, 35, 15, 0.06);
}

.segment-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 10px 14px;
  text-decoration: none;
}

.segment-button.active {
  background: #fffdf9;
  color: var(--ink);
  box-shadow: 0 2px 12px rgba(24, 35, 15, 0.08);
}

.monitor-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.monitor-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}

.monitor-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

button {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background-color 160ms ease;
}

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

button:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

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

.ghost-button {
  background: rgba(24, 35, 15, 0.06);
  color: var(--ink);
}

.danger-button {
  background: rgba(159, 58, 45, 0.1);
  color: var(--danger);
}

.batch-input,
input,
select {
  width: 100%;
  border: 1px solid rgba(24, 35, 15, 0.14);
  background: #fffdf9;
  color: var(--ink);
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 14px;
}

input[type="checkbox"] {
  width: auto;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 22px) calc(50% - 2px),
    calc(100% - 16px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

select:disabled {
  opacity: 0.7;
  cursor: wait;
}

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

.api-key-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}

.model-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.test-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  min-width: 220px;
}

.test-options label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  white-space: nowrap;
}

.test-options input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.mini-button {
  padding: 10px 14px;
  white-space: nowrap;
}

.batch-input {
  min-height: 140px;
  resize: vertical;
  line-height: 1.6;
}

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

.table-wrap table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}

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

thead th {
  border-top: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.channel-table #channel-body td:nth-child(1),
.channel-table thead th:nth-child(1) {
  min-width: 44px;
}

.channel-table #channel-body td:nth-child(2),
.channel-table thead th:nth-child(2) {
  min-width: 120px;
}

.channel-table #channel-body td:nth-child(3),
.channel-table thead th:nth-child(3) {
  min-width: 120px;
}

.channel-table #channel-body td:nth-child(4),
.channel-table thead th:nth-child(4) {
  min-width: 140px;
}

.channel-table #channel-body td:nth-child(5),
.channel-table thead th:nth-child(5) {
  min-width: 280px;
}

.channel-table #channel-body td:nth-child(6),
.channel-table thead th:nth-child(6) {
  min-width: 260px;
}

.channel-table #channel-body td:nth-child(7),
.channel-table thead th:nth-child(7) {
  min-width: 260px;
}

.channel-table #channel-body td:nth-child(8),
.channel-table thead th:nth-child(8) {
  min-width: 260px;
}

.channel-table #channel-body td:nth-child(9),
.channel-table thead th:nth-child(9) {
  min-width: 220px;
}

.channel-table #channel-body td:nth-child(10),
.channel-table thead th:nth-child(10) {
  min-width: 92px;
}

tbody tr {
  animation: fade-in 240ms ease;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
}

.group-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(31, 111, 95, 0.1);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.ok {
  color: var(--ok);
  background: rgba(29, 122, 67, 0.12);
}

.status-pill.warn {
  color: var(--warn);
  background: rgba(164, 93, 25, 0.12);
}

.status-pill.bad {
  color: var(--danger);
  background: rgba(159, 58, 45, 0.12);
}

.status-pill.unsupported {
  color: var(--ink);
  background: rgba(24, 35, 15, 0.08);
}

.status-pill.skipped {
  color: var(--muted);
  background: rgba(24, 35, 15, 0.06);
}

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

.summary-card {
  padding: 18px;
  border-radius: 18px;
  background: rgba(24, 35, 15, 0.05);
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.summary-card strong {
  font-size: 30px;
}

.summary-card.ok {
  background: rgba(29, 122, 67, 0.12);
}

.summary-card.warn {
  background: rgba(159, 58, 45, 0.12);
}

.history-group {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 253, 249, 0.72);
  padding: 16px;
  margin-bottom: 14px;
}

.history-group-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--accent-strong);
}

.history-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.history-group-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.history-rate-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  flex: 0 0 auto;
}

.history-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(220, 122, 32, 0.22);
  background: linear-gradient(135deg, rgba(255, 247, 237, 0.98), rgba(255, 227, 184, 0.98));
  color: #b85b00;
  box-shadow: 0 8px 18px rgba(220, 122, 32, 0.14);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.history-link-button:hover {
  transform: translateY(-1px);
  border-color: rgba(220, 122, 32, 0.34);
  background: linear-gradient(135deg, rgba(255, 241, 222, 1), rgba(255, 214, 145, 1));
  box-shadow: 0 12px 22px rgba(220, 122, 32, 0.2);
}

.history-link-button:active {
  transform: translateY(0);
}

.history-group-body {
  display: grid;
  gap: 12px;
}

.history-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 999px;
  background: rgba(24, 35, 15, 0.06);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.history-toggle input {
  width: auto;
  margin: 0;
}

.endpoint {
  max-width: 320px;
  word-break: break-all;
  color: var(--muted);
  font-size: 13px;
}

.models {
  max-width: 260px;
  word-break: break-word;
  font-size: 13px;
}

.message {
  max-width: 360px;
  word-break: break-word;
}

.history-board {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.history-row {
  display: grid;
  grid-template-columns: minmax(220px, 340px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(24, 35, 15, 0.08);
}

.history-row.ok {
  background: rgba(29, 122, 67, 0.08);
}

.history-row.warn {
  background: rgba(164, 93, 25, 0.08);
}

.history-row.bad {
  background: rgba(159, 58, 45, 0.08);
}

.history-meta {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  min-width: 0;
}

.history-meta > div {
  min-width: 0;
}

.history-rate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 6px 10px;
  border-radius: 999px;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}

.history-rate.ok {
  background: var(--ok);
}

.history-rate.warn {
  background: var(--warn);
}

.history-rate.bad {
  background: var(--danger);
}

.history-name {
  font-size: 16px;
  font-weight: 700;
}

.history-sub,
.history-foot {
  color: var(--muted);
  font-size: 13px;
}

.history-sub {
  white-space: normal;
  line-height: 1.5;
  word-break: break-word;
}

.history-track-wrap {
  min-width: 0;
}

.history-track {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  overflow: hidden;
  padding-inline: 4px 10px;
}

.history-bar {
  width: 6px;
  height: 18px;
  border-radius: 999px;
  flex: 0 0 auto;
  background: rgba(24, 35, 15, 0.12);
  position: relative;
}

.history-bar.ok {
  background: #43cf72;
}

.history-bar.warn {
  background: #e0a03b;
}

.history-bar.bad {
  background: #d7263d;
}

.history-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

@media (max-width: 1100px) {
  .history-row {
    grid-template-columns: 1fr;
  }
}

.history-empty {
  padding: 32px 18px;
  border-radius: 18px;
  background: rgba(24, 35, 15, 0.04);
  color: var(--muted);
  text-align: center;
}

.history-tooltip {
  position: fixed;
  z-index: 20;
  min-width: 140px;
  max-width: 240px;
  max-height: calc(100vh - 28px);
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(9, 14, 24, 0.96);
  color: #fff;
  box-shadow: 0 18px 48px rgba(9, 14, 24, 0.28);
  pointer-events: none;
  font-size: 13px;
  line-height: 1.5;
  overflow-y: auto;
}

.run-card {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(24, 35, 15, 0.08);
}

.run-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.run-card-meta {
  color: var(--muted);
  font-size: 13px;
}

.run-card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.run-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.run-item-name {
  min-width: 0;
  word-break: break-word;
}

.run-item-meta {
  color: var(--muted);
  font-size: 13px;
}

.detail-row td {
  padding-top: 0;
}

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

.check-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.45);
  overflow: hidden;
}

.check-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  list-style: none;
  padding: 14px 16px;
}

.check-summary::-webkit-details-marker {
  display: none;
}

.check-title {
  font-weight: 700;
}

.check-meta {
  color: var(--muted);
  font-size: 13px;
}

.check-body {
  padding: 0 16px 16px;
}

.check-block + .check-block {
  margin-top: 14px;
}

.check-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

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

.check-copy-button {
  flex: 0 0 auto;
}

.check-body pre {
  margin: 0;
  padding: 14px;
  border-radius: 14px;
  background: #fffdf9;
  border: 1px solid rgba(24, 35, 15, 0.1);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  max-height: 320px;
  overflow-y: auto;
}

.empty-row td {
  color: var(--muted);
}

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

@media (max-width: 780px) {
  .page {
    width: min(100% - 20px, 100%);
    padding-top: 20px;
  }

  .hero-copy {
    font-size: 14px;
    line-height: 1.65;
  }

  .panel {
    padding: 18px;
    border-radius: 20px;
  }

  .panel-header {
    flex-direction: column;
  }

  .panel-header h2 {
    font-size: 20px;
  }

  .actions,
  .history-actions,
  .hero-toolbar {
    width: 100%;
  }

  .actions > * ,
  .history-actions > * {
    width: 100%;
  }

  .model-picker,
  .api-key-wrap {
    flex-direction: column;
    align-items: stretch;
  }

  .model-picker > *,
  .api-key-wrap > * {
    width: 100%;
  }

  .monitor-controls {
    align-items: flex-start;
  }

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

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

  .history-row {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 14px;
  }

  .history-meta {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .history-rate-stack {
    width: 100%;
    align-items: flex-start;
  }

  .history-sub {
    white-space: normal;
  }

  .history-rate {
    min-width: 58px;
    padding: 5px 9px;
    font-size: 12px;
  }

  .history-group-head {
    flex-direction: column;
    align-items: stretch;
  }

  .history-item-delete {
    width: 100%;
    justify-content: center;
  }

  .history-foot {
    justify-content: flex-start;
    gap: 8px 12px;
  }

  .history-foot span {
    display: inline-flex;
    align-items: center;
  }

  th,
  td {
    min-width: 140px;
  }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 520px) {
  .page {
    width: min(100% - 16px, 100%);
    padding-top: 16px;
  }

  .hero {
    padding: 10px 2px 20px;
  }

  .panel {
    padding: 16px;
    border-radius: 18px;
  }

  .panel-select,
  .actions > *,
  .history-actions > * {
    width: 100%;
    min-width: 0;
  }

  .history-group {
    padding: 12px;
    border-radius: 18px;
  }

  .history-name {
    font-size: 15px;
  }

  .history-sub,
  .history-foot {
    font-size: 12px;
  }

  .history-track {
    gap: 4px;
    padding-inline: 6px 14px;
  }

  .history-bar {
    width: 7px;
    height: 18px;
  }

  .history-bar::before {
    content: "";
    position: absolute;
    inset: -8px -4px;
  }

  .history-tooltip {
    min-width: 0;
    max-width: min(220px, calc(100vw - 20px));
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.45;
  }
}
