:root {
  --primary: 211.4 85.2% 47.8%;
  --primary-foreground: 0 0% 100%;
  --secondary: 220 56% 96%;
  --background: 228 45% 98%;
  --foreground: 222 24% 15%;
  --muted: 225 44% 97%;
  --muted-foreground: 223.6 4.5% 47.6%;
  --card: 0 0% 100%;
  --border: 220 32% 92%;
  --success: 151 56% 39%;
  --success-soft: 148 52% 95%;
  --warning: 38 88% 46%;
  --warning-soft: 42 100% 95%;
  --danger: 0 72% 51%;
  --danger-soft: 0 86% 97%;
  --surface-shadow: 0 8px 24px hsl(222 24% 15% / 0.07);
  --focus-shadow: 0 0 0 3px hsl(var(--primary) / 0.14);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  min-width: 320px;
  background: hsl(var(--background));
}

body {
  margin: 0;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  font-family: "Public Sans", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: none;
  box-shadow: var(--focus-shadow);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 64px;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--card) / 0.94);
  backdrop-filter: blur(14px);
}

.topbar-inner,
.shell {
  width: min(1440px, 100%);
  margin-inline: auto;
  padding-inline: 20px;
}

.topbar-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand,
.topbar-actions,
.toolbar-controls,
.status-cell,
.timeline,
.model-name,
.modal-kicker {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.1);
}

.brand-icon svg,
.icon-button svg {
  width: 18px;
  height: 18px;
}

.brand strong,
.brand span {
  display: block;
  line-height: 1.25;
}

.brand strong {
  font-size: 15px;
  font-weight: 700;
}

.brand span {
  margin-top: 2px;
  color: hsl(var(--muted-foreground));
  font: 11px/1.2 "JetBrains Mono", monospace;
}

.topbar-actions {
  gap: 12px;
}

.sync-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: hsl(var(--muted-foreground));
  font-size: 12px;
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: hsl(var(--warning));
}

.sync-state.is-ready .sync-dot {
  background: hsl(var(--success));
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  color: hsl(var(--foreground));
  background: hsl(var(--card));
  cursor: pointer;
  transition: background-color 180ms ease-out, border-color 180ms ease-out, transform 180ms ease-out;
}

.icon-button:hover {
  border-color: hsl(var(--primary) / 0.25);
  background: hsl(var(--secondary));
}

.icon-button:active,
.model-button:active,
.modal-backdrop:active {
  transform: scale(0.96);
}

.icon-button.is-loading svg {
  animation: spin 800ms linear infinite;
}

.shell {
  padding-top: 32px;
  padding-bottom: 48px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.page-heading h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
  font-weight: 700;
}

.page-heading p {
  max-width: 65ch;
  margin: 7px 0 0;
  color: hsl(var(--muted-foreground));
  font-size: 14px;
}

.heading-time {
  flex: 0 0 auto;
  text-align: right;
}

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

.heading-time span {
  color: hsl(var(--muted-foreground));
  font-size: 11px;
}

.heading-time strong {
  margin-top: 2px;
  font: 500 12px/1.4 "JetBrains Mono", monospace;
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 28px;
  border-block: 1px solid hsl(var(--border));
  background: hsl(var(--card) / 0.55);
}

.summary-item {
  min-width: 0;
  padding: 18px 22px;
  border-right: 1px solid hsl(var(--border));
}

.summary-item:last-child {
  border-right: 0;
}

.summary-item span,
.summary-item strong {
  display: block;
}

.summary-item span {
  color: hsl(var(--muted-foreground));
  font-size: 12px;
}

.summary-item strong {
  margin-top: 3px;
  font: 600 25px/1.25 "JetBrains Mono", monospace;
  font-variant-numeric: tabular-nums;
}

.summary-healthy strong {
  color: hsl(var(--success));
}

.summary-down strong {
  color: hsl(var(--danger));
}

.toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.toolbar-title h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
  font-weight: 650;
}

.toolbar-title span {
  display: block;
  margin-top: 3px;
  color: hsl(var(--muted-foreground));
  font-size: 12px;
}

.toolbar-controls {
  gap: 10px;
}

.search-control,
.select-control {
  position: relative;
  display: block;
}

.search-control svg,
.select-control svg {
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  color: hsl(var(--muted-foreground));
  transform: translateY(-50%);
  pointer-events: none;
}

.search-control svg {
  left: 12px;
}

.select-control svg {
  right: 11px;
}

.search-control input,
.select-control select {
  height: 42px;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  color: hsl(var(--foreground));
  background: hsl(var(--card));
  box-shadow: inset 0 1px 2px hsl(var(--foreground) / 0.04);
  transition: border-color 180ms ease-out, box-shadow 180ms ease-out;
}

.search-control input {
  width: 260px;
  padding: 0 12px 0 37px;
}

.select-control select {
  min-width: 136px;
  padding: 0 36px 0 12px;
  appearance: none;
  cursor: pointer;
}

.search-control input::placeholder {
  color: hsl(var(--muted-foreground));
}

.search-control input:focus,
.select-control select:focus {
  border-color: hsl(var(--primary) / 0.45);
}

.notice {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid hsl(var(--danger) / 0.22);
  border-radius: 8px;
  color: hsl(var(--danger));
  background: hsl(var(--danger-soft));
  font-size: 13px;
}

.notice svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.table-frame {
  position: relative;
  min-height: 220px;
  overflow: hidden;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--card));
  box-shadow: var(--surface-shadow);
}

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

table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 14px 16px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted) / 0.72);
  font-size: 11px;
  font-weight: 600;
}

th:nth-child(1) { width: 23%; }
th:nth-child(2) { width: 11%; }
th:nth-child(3) { width: 13%; }
th:nth-child(4) { width: 15%; }
th:nth-child(5) { width: 13%; }
th:nth-child(6) { width: 16%; }
th:nth-child(7) { width: 9%; }

tbody tr {
  border-top: 1px solid hsl(var(--border));
  transition: background-color 140ms ease-out;
}

tbody tr:hover {
  background: hsl(var(--muted) / 0.42);
}

td {
  font-size: 13px;
}

.group-cell {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.platform-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.1);
  font: 600 12px/1 "JetBrains Mono", monospace;
  text-transform: uppercase;
}

.group-copy {
  min-width: 0;
}

.group-name {
  display: block;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-meta {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: hsl(var(--muted-foreground));
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-cell {
  gap: 7px;
  white-space: nowrap;
}

.status-dot,
.timeline-dot {
  flex: 0 0 auto;
  border-radius: 50%;
}

.status-dot {
  width: 8px;
  height: 8px;
}

.status-healthy { background: hsl(var(--success)); }
.status-degraded { background: hsl(var(--warning)); }
.status-down { background: hsl(var(--danger)); }
.status-pending,
.status-unconfigured { background: hsl(var(--muted-foreground) / 0.55); }

.status-text {
  font-weight: 550;
}

.metric-value {
  font: 500 13px/1.3 "JetBrains Mono", monospace;
  font-variant-numeric: tabular-nums;
}

.metric-subtext,
.last-message {
  display: block;
  margin-top: 3px;
  color: hsl(var(--muted-foreground));
  font-size: 11px;
}

.last-message {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline {
  width: 100%;
  gap: 3px;
}

.timeline-dot {
  width: 6px;
  height: 18px;
  border-radius: 3px;
  background: hsl(var(--border));
}

.timeline-dot.status-healthy { background: hsl(var(--success) / 0.85); }
.timeline-dot.status-degraded { background: hsl(var(--warning) / 0.9); }
.timeline-dot.status-down { background: hsl(var(--danger) / 0.85); }
.timeline-dot.status-unconfigured { background: hsl(var(--muted-foreground) / 0.35); }

.action-heading,
.action-cell {
  text-align: right;
}

.model-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  color: hsl(var(--foreground));
  background: hsl(var(--card));
  cursor: pointer;
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
  transition: color 180ms ease-out, background-color 180ms ease-out, border-color 180ms ease-out, transform 180ms ease-out;
}

.model-button svg {
  width: 15px;
  height: 15px;
}

.model-button:hover {
  border-color: hsl(var(--primary) / 0.3);
  color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.06);
}

.loading-state,
.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: hsl(var(--card));
  color: hsl(var(--muted-foreground));
  font-size: 13px;
}

.empty-state {
  flex-direction: column;
  gap: 6px;
  text-align: center;
}

.empty-state strong {
  color: hsl(var(--foreground));
  font-size: 14px;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 4px;
  border-radius: 8px;
  background: hsl(var(--secondary));
}

.empty-icon svg {
  width: 20px;
  height: 20px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid hsl(var(--border));
  border-top-color: hsl(var(--primary));
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-layer[hidden],
[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: hsl(var(--foreground) / 0.34);
  backdrop-filter: blur(4px);
  cursor: default;
}

.modal-panel {
  position: relative;
  width: min(1080px, 100%);
  max-height: min(780px, calc(100dvh - 40px));
  overflow: hidden;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--card));
  box-shadow: 0 24px 64px hsl(var(--foreground) / 0.2);
  animation: modal-in 220ms var(--ease-out) both;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid hsl(var(--border));
}

.modal-kicker {
  gap: 6px;
  color: hsl(var(--primary));
  font-size: 11px;
  font-weight: 650;
}

.modal-kicker svg {
  width: 15px;
  height: 15px;
}

.modal-header h2 {
  margin: 5px 0 0;
  font-size: 20px;
  line-height: 1.3;
}

.modal-header p {
  margin: 4px 0 0;
  color: hsl(var(--muted-foreground));
  font-size: 12px;
}

.image-price-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 10px 20px;
  border-bottom: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted) / 0.58);
  font-size: 12px;
}

.image-price-strip strong {
  margin-left: 5px;
  color: hsl(var(--foreground));
  font-family: "JetBrains Mono", monospace;
}

.modal-body {
  max-height: calc(min(780px, 100dvh - 40px) - 104px);
  overflow: auto;
}

.price-table {
  width: 100%;
  min-width: 920px;
  table-layout: auto;
}

.price-table th {
  position: sticky;
  top: 0;
  z-index: 10;
}

.price-table th,
.price-table td {
  padding: 12px 14px;
}

.price-table th:first-child {
  width: 30%;
}

.model-name {
  gap: 8px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
}

.model-name.is-probe::after {
  content: "测试模型";
  padding: 2px 6px;
  border-radius: 999px;
  color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.09);
  font-family: "Public Sans", sans-serif;
  font-size: 10px;
  white-space: nowrap;
}

.price-value {
  font: 500 12px/1.4 "JetBrains Mono", monospace;
  white-space: nowrap;
}

.price-empty {
  color: hsl(var(--muted-foreground) / 0.65);
}

.modal-loading,
.modal-empty {
  display: grid;
  place-items: center;
  min-height: 220px;
  color: hsl(var(--muted-foreground));
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: min(380px, calc(100vw - 40px));
  padding: 11px 14px;
  border: 1px solid hsl(var(--danger) / 0.22);
  border-radius: 8px;
  color: hsl(var(--danger));
  background: hsl(var(--danger-soft));
  box-shadow: var(--surface-shadow);
  font-size: 13px;
}

.toast svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

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

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(5px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@media (max-width: 760px) {
  .topbar-inner,
  .shell {
    padding-inline: 14px;
  }

  .sync-state {
    display: none;
  }

  .shell {
    padding-top: 22px;
    padding-bottom: 32px;
  }

  .page-heading {
    display: block;
    margin-bottom: 18px;
  }

  .page-heading h1 {
    font-size: 23px;
  }

  .heading-time {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    text-align: left;
  }

  .heading-time strong {
    margin-top: 0;
  }

  .summary-band {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 22px;
  }

  .summary-item {
    padding: 14px;
  }

  .summary-item:nth-child(2) {
    border-right: 0;
  }

  .summary-item:nth-child(-n + 2) {
    border-bottom: 1px solid hsl(var(--border));
  }

  .toolbar {
    display: block;
  }

  .toolbar-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 132px;
    margin-top: 12px;
  }

  .search-control input,
  .select-control select {
    width: 100%;
    min-width: 0;
  }

  .table-frame {
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .table-scroll {
    overflow: visible;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 10px;
    padding: 15px;
    border: 1px solid hsl(var(--border));
    border-radius: 8px;
    background: hsl(var(--card));
    box-shadow: 0 4px 14px hsl(var(--foreground) / 0.045);
  }

  tbody tr:hover {
    background: hsl(var(--card));
  }

  td {
    padding: 0;
  }

  td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: hsl(var(--muted-foreground));
    font-size: 10px;
  }

  td:first-child,
  td:nth-child(6),
  td:nth-child(7) {
    grid-column: 1 / -1;
  }

  td:first-child::before,
  td:nth-child(7)::before {
    display: none;
  }

  .group-cell {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .platform-icon {
    width: 38px;
    height: 38px;
  }

  .group-name {
    white-space: normal;
  }

  .last-message {
    max-width: none;
  }

  .timeline {
    overflow: hidden;
  }

  .timeline-dot {
    flex: 1 1 6px;
    min-width: 4px;
  }

  .model-button {
    width: 100%;
    min-height: 44px;
  }

  .loading-state,
  .empty-state {
    min-height: 220px;
    border: 1px solid hsl(var(--border));
    border-radius: 8px;
  }

  .modal-layer {
    align-items: end;
    padding: 0;
  }

  .modal-panel {
    width: 100%;
    max-height: 90dvh;
    border-radius: 8px 8px 0 0;
  }

  .modal-header {
    padding: 16px;
  }

  .modal-body {
    max-height: calc(90dvh - 105px);
  }

  .image-price-strip {
    padding-inline: 16px;
  }
}

@media (hover: hover) and (pointer: fine) {
  .icon-button:hover,
  .model-button:hover {
    transform: translateY(-1px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

