:root {
  --bg: #080b12;
  --panel: #101622;
  --panel2: #151d2c;
  --line: #263247;
  --text: #edf2fb;
  --muted: #8490a5;
  --blue: #6d8cff;
  --green: #35d39a;
  --orange: #f5b95f;
  --red: #ff7181;
  --purple: #b193ff;
  --shadow: 0 20px 60px #0008;
  --sans: Inter, system-ui, 'Microsoft YaHei', sans-serif;
  --mono: 'SFMono-Regular', Consolas, monospace
}

* {
  box-sizing: border-box
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(80% 100% at 100% 0, #19274a 0, transparent 55%), var(--bg);
  color: var(--text);
  font: 13px/1.45 var(--sans)
}

body {
  min-height: 100vh
}

button,
input,
textarea {
  font: inherit
}

button {
  cursor: pointer
}

.hidden {
  display: none !important
}

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

.small {
  font-size: 11px
}

.eyebrow {
  margin: 0;
  color: var(--blue);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(135deg, #6f8dff, #ad88ff);
  font-weight: 800;
  color: #fff
}

.auth-wrap {
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px
}

.auth-card {
  width: min(390px, 100%);
  padding: 34px;
  background: #111825eF;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow)
}

.auth-card h1 {
  margin: 12px 0 6px;
  font-size: 28px
}

.auth-card .brand-mark {
  margin-bottom: 18px
}

.field {
  display: block;
  margin: 15px 0;
  color: var(--muted);
  font-size: 12px
}

.field input,
.field textarea,
.search {
  display: block;
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel2);
  color: var(--text);
  padding: 10px 11px;
  outline: 0
}

.field input:focus,
.field textarea:focus,
.search:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px #6d8cff22
}

.error {
  min-height: 18px;
  color: var(--red);
  font-size: 12px
}

.btn {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #172033;
  color: var(--text);
  padding: 8px 12px;
  white-space: nowrap
}

.btn:hover {
  border-color: #6d8cff88;
  background: #1d2a45
}

.btn.primary {
  border-color: transparent;
  background: linear-gradient(135deg, #6586ff, #8069df);
  color: white
}

.btn.wide {
  width: 100%;
  margin-top: 5px;
  padding: 11px
}

.btn.small {
  padding: 5px 9px;
  font-size: 12px
}

.app {
  height: 100vh;
  min-height: 0;
  display: flex;
  flex-direction: column
}

.workspace {
  overflow: auto;
  min-height: 0
}

.btn:disabled {
  cursor: not-allowed;
  opacity: .45
}

.bad {
  color: var(--red)
}

.secret-visible {
  overflow-wrap: anywhere;
  user-select: all
}

select,
input[type=number] {
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px
}

input[type=checkbox] {
  accent-color: var(--blue)
}

.snapshot-details {
  margin: 12px 0;
  color: var(--muted)
}

.snapshot-details summary {
  cursor: pointer;
  color: var(--blue)
}

.topbar {
  height: 60px;
  flex: 0 0 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid #202a3c;
  background: #0c111bd9;
  backdrop-filter: blur(16px)
}

.brand,
.header-actions,
.heading-actions,
.filter-tabs,
.batchbar,
.title-row,
.card-actions,
.key-actions,
.modal-actions,
.drawer-head,
.summary {
  display: flex;
  align-items: center
}

.brand {
  gap: 10px
}

.brand strong {
  display: block;
  font-size: 14px
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 1px
}

.header-actions {
  gap: 10px
}

.connection {
  font-size: 11px;
  color: var(--muted)
}

.connection i,
.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 5px
}

.workspace {
  width: calc(100% - 32px);
  margin: 0 auto;
  padding: 25px 0 10px;
  flex: 1
}

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

.page-heading h1 {
  font-size: 25px;
  margin: 5px 0 0
}

.heading-actions {
  gap: 8px
}

.count {
  color: var(--muted);
  font-size: 11px
}

.summary-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 13px
}

.summary {
  justify-content: space-between;
  padding: 12px 15px;
  border: 1px solid var(--line);
  background: #111927b8;
  border-radius: 10px
}

.summary span {
  color: var(--muted);
  font-size: 11px
}

.summary strong {
  font: 700 20px var(--mono)
}

.summary .date {
  font-size: 13px
}

.ok {
  color: var(--green)
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px
}

.filter-tabs {
  gap: 4px;
  flex-wrap: wrap
}

.filter-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 6px
}

.filter-tab.active {
  color: #fff;
  background: #283653
}

.search {
  max-width: 250px;
  margin: 0 0 0 auto;
  padding: 8px 11px
}

.batchbar {
  gap: 9px;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  color: var(--muted)
}

.batchbar .sync-status {
  margin-left: auto;
  font-size: 11px
}

.check {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-size: 12px
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 15px 0
}

.endpoint-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: linear-gradient(145deg, #121b2a, #0f1520);
  padding: 14px;
  transition: .15s
}

.endpoint-card:hover {
  border-color: #50689b
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 8px
}

.title-row {
  gap: 8px;
  min-width: 0
}

.card-title {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.status-pill {
  font-size: 10px;
  padding: 3px 6px;
  border-radius: 5px;
  white-space: nowrap
}

.status-pill i {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 4px
}

.status-pill.healthy {
  color: var(--green);
  background: #35d39a18
}

.status-pill.partial {
  color: var(--orange);
  background: #f5b95f18
}

.status-pill.failed {
  color: var(--red);
  background: #ff718118
}

.status-pill.running {
  color: var(--blue);
  background: #6d8cff18
}

.status-pill.untested {
  color: var(--muted);
  background: #8490a518
}

.card-url {
  margin: 4px 0 12px;
  color: var(--muted);
  font: 11px var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.key-line {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 0;
  border-top: 1px solid #233047
}

.key-mask {
  font: 11px var(--mono);
  color: #c0c9db;
  flex: 1;
  overflow: hidden
}

.mini-btn {
  border: 0;
  color: var(--muted);
  background: transparent;
  padding: 3px 5px;
  font-size: 11px
}

.mini-btn:hover {
  color: var(--text)
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 12px 0
}

.metric {
  padding: 8px;
  background: #0c131f;
  border-radius: 6px
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 10px
}

.metric b {
  font: 700 14px var(--mono)
}

.metric em {
  font-size: 10px;
  color: var(--muted);
  font-style: normal
}

.card-actions {
  gap: 7px;
  margin-top: auto;
  padding-top: 10px
}

.card-actions .btn {
  flex: 1
}

.run-progress {
  height: 4px;
  background: #263247;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 10px
}

.run-progress i {
  display: block;
  height: 100%;
  background: var(--blue);
  transition: width .3s
}

.empty-card {
  grid-column: 1/-1;
  text-align: center;
  color: var(--muted);
  padding: 60px;
  border: 1px dashed var(--line);
  border-radius: 11px
}

footer {
  display: flex;
  justify-content: space-between;
  color: #657187;
  font-size: 10px;
  padding: 12px 28px
}

.overlay {
  position: fixed;
  inset: 0;
  background: #02040aaa;
  z-index: 10
}

.drawer {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: min(620px, 100%);
  background: #101722;
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column
}

.drawer-head {
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line)
}

.drawer-head h2 {
  margin: 5px 0 0
}

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  padding: 4px
}

.drawer-tabs {
  display: flex;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  gap: 18px;
  flex-shrink: 0;
  overflow-x: auto;
  white-space: nowrap
}

.drawer-tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 12px 0;
  border-bottom: 2px solid transparent
}

.drawer-tabs button.active {
  color: var(--text);
  border-color: var(--blue)
}

.drawer-body {
  overflow: auto;
  padding: 20px 24px
}

.drawer-section {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 13px;
  margin-bottom: 12px
}

.drawer-section h3 {
  font-size: 13px;
  margin: 0 0 10px
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px
}

.model-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  background: var(--panel2);
  border-radius: 6px;
  font: 11px var(--mono)
}

.run-row {
  padding: 11px 0;
  border-bottom: 1px solid var(--line)
}

.run-row:last-child {
  border: 0
}

.run-row strong {
  display: block
}

.run-row small {
  color: var(--muted)
}

dialog {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #111a29;
  color: var(--text);
  width: min(480px, calc(100% - 28px));
  padding: 0;
  box-shadow: var(--shadow)
}

dialog::backdrop {
  background: #02040acc
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line)
}

dialog form {
  padding-bottom: 20px
}

.modal-head h2 {
  margin: 5px 0 0
}

.modal-head~.field,
.modal-head~.muted,
.modal-head~.check,
.modal-head~.error {
  margin-left: 22px;
  margin-right: 22px
}

.modal-actions {
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px 0;
  border-top: 1px solid var(--line);
  margin-top: 15px
}

.required {
  color: var(--red)
}

.toast {
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translate(-50%, 15px);
  background: #263654;
  color: #fff;
  padding: 10px 16px;
  border-radius: 7px;
  opacity: 0;
  pointer-events: none;
  transition: .2s;
  z-index: 20
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0)
}

@media(max-width:1600px) {
  .cards {
    grid-template-columns: repeat(3, minmax(0, 1fr))
  }

  .summary-row {
    grid-template-columns: repeat(5, 1fr)
  }
}

@media(max-width:900px) {
  .workspace {
    width: calc(100% - 30px)
  }

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

  .summary-row {
    grid-template-columns: repeat(3, 1fr)
  }

  .summary:nth-child(n+4) {
    display: none
  }

  .header-actions .connection {
    display: none
  }
}

@media(max-width:600px) {
  .topbar {
    padding: 0 15px
  }

  .brand small,
  .user-badge {
    display: none
  }

  .workspace {
    width: calc(100% - 20px);
    padding-top: 17px
  }

  .page-heading {
    align-items: flex-start;
    gap: 12px;
    flex-direction: column
  }

  .heading-actions {
    width: 100%
  }

  .heading-actions .btn {
    flex: 1
  }

  .summary-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px
  }

  .summary {
    padding: 9px
  }

  .summary strong {
    font-size: 16px
  }

  .toolbar {
    display: block
  }

  .filter-tabs {
    margin-bottom: 8px
  }

  .search {
    max-width: none
  }

  .batchbar {
    overflow: auto
  }

  .cards {
    grid-template-columns: 1fr;
    padding-top: 10px
  }

  footer {
    padding: 10px
  }

  .drawer-body {
    padding: 15px
  }

  .drawer-head {
    padding: 16px
  }

  .drawer-tabs {
    padding: 0 16px
  }

  .model-grid {
    grid-template-columns: 1fr
  }
}

.endpoint-table-wrap { width: 100%; overflow-x: auto; margin: 12px 0; border: 1px solid var(--line); border-radius: 9px; }
.endpoint-table, .model-table { width: 100%; border-collapse: collapse; text-align: left; }
.endpoint-table { table-layout: fixed; min-width: 1050px; }
.endpoint-table th, .endpoint-table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.endpoint-table thead th { color: var(--muted); font-size: 11px; background: #151f30; position: sticky; top: 0; z-index: 1; }
.col-name { width: 16%; } .col-url { width: 20%; } .col-key { width: 24%; } .col-count { width: 6%; } .col-status { width: 16%; } .col-actions { width: 18%; }
.endpoint-row { background: #101824; cursor: pointer; }
.endpoint-row:hover, .endpoint-row[aria-expanded=true] { background: #162238; }
.endpoint-row .title-row { align-items: center; gap: 5px; overflow-wrap: anywhere; }
.endpoint-url, .api-key { overflow-wrap: anywhere; font: 12px/1.5 var(--mono); }
.api-key { display: block; white-space: pre-wrap; user-select: all; color: #d6e2ff; }
.endpoint-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.expand-toggle { font-size: 17px; padding: 2px; }
.model-expansion > td { padding: 0; background: #0b121d; }
.model-panel { padding: 12px 18px 16px; }
.model-panel-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.model-panel-heading .btn { margin-left: auto; }
.model-table-scroll { max-height: 360px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.model-table { min-width: 760px; font-size: 12px; }
.model-table th, .model-table td { padding: 7px 10px; }
.model-table thead th { position: sticky; top: 0; background: #192335; z-index: 1; }
.model-table tbody tr:last-child td { border-bottom: 0; }
.model-choice { display: flex; align-items: center; gap: 7px; overflow-wrap: anywhere; }
.capability { border-radius: 4px; padding: 3px 6px; white-space: nowrap; font-size: 11px; }
.capability.confirmed, .test-status.success { color: var(--green); }
.capability.confirmed { background: #35d39a18; }
.capability.inferred, .test-status.timeout { color: var(--orange); }
.capability.inferred { background: #f5b95f18; }
.capability.unknown, .test-status.untested { color: var(--muted); }
.test-status.failed { color: var(--red); }
.model-grid { max-height: 360px; overflow: auto; }
