:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-alt: #eef2f5;
  --border: #d7dee5;
  --text: #17212b;
  --muted: #667482;
  --accent: #146b5a;
  --accent-strong: #0d5144;
  --blue: #2563a8;
  --orange: #b35d13;
  --red: #b42318;
  --shadow: 0 8px 24px rgba(23, 33, 43, 0.07);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code,
pre,
.mono {
  font-family: "Cascadia Mono", Consolas, monospace;
}

.topbar {
  background: #17212b;
  color: #fff;
  border-bottom: 1px solid #0c141b;
}

.topbar-inner {
  max-width: 1480px;
  margin: 0 auto;
  min-height: 58px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.nav a {
  color: #c7d1da;
  padding: 8px 10px;
  border-radius: 6px;
  text-decoration: none;
}

.nav a:hover,
.nav a.active {
  color: #fff;
  background: #2a3946;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #c7d1da;
}

.top-actions form {
  margin: 0;
}

.connection-bar {
  background: #e9eef2;
  border-bottom: 1px solid #cfd8e0;
}

.connection-inner {
  max-width: 1480px;
  margin: 0 auto;
  min-height: 50px;
  padding: 8px 24px;
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
}

.connection-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.connection-label {
  color: #53616e;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.connection-item code {
  color: #16212c;
  background: #fff;
  border: 1px solid #cbd5dd;
  border-radius: 5px;
  padding: 5px 8px;
  overflow-wrap: anywhere;
}

.model-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.page {
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px;
}

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

.page-head h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.2;
}

.page-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}

.panel-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
}

.panel-body {
  padding: 16px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
}

.stat-value {
  font-size: 25px;
  font-weight: 700;
  line-height: 1;
}

.stat-note {
  color: var(--muted);
  margin-top: 9px;
  font-size: 12px;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 18px;
}

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

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.form-row.span-3 {
  grid-column: span 3;
}

label {
  color: #3b4855;
  font-size: 12px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid #bec9d3;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(20, 107, 90, 0.15);
}

.button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 7px 13px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.button:hover {
  background: var(--accent-strong);
}

.button.secondary {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

.button.secondary:hover {
  background: var(--surface-alt);
}

.button.compact {
  min-height: 28px;
  padding: 3px 9px;
  font-size: 12px;
}

.button.danger {
  background: #fff;
  border-color: #e6b5af;
  color: var(--red);
}

.button.danger:hover {
  background: #fff1ef;
}

.button.link {
  border: 0;
  background: transparent;
  color: #c7d1da;
  padding: 6px 2px;
}

.button.link:hover {
  color: #fff;
  background: transparent;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

th,
td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid #e5eaee;
  vertical-align: middle;
}

th {
  color: #576572;
  background: #f8fafb;
  font-size: 12px;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.row-actions form {
  margin: 0;
}

.token-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 99px;
  padding: 3px 8px;
  background: #e9eef2;
  color: #40505f;
  font-size: 12px;
  font-weight: 600;
}

.badge.ok {
  background: #e4f4ee;
  color: #146b5a;
}

.badge.warn {
  background: #fff1de;
  color: #8a470d;
}

.badge.error {
  background: #fde8e5;
  color: #a91c11;
}

.notice {
  border: 1px solid #a9cfc5;
  background: #e9f6f2;
  color: #0b5b4c;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.notice.error {
  border-color: #e7aaa3;
  background: #fff0ee;
  color: #8f1b12;
}

.secret-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid #e1b96e;
  background: #fff8e8;
  border-radius: 6px;
  margin-bottom: 14px;
}

.secret-box code {
  flex: 1;
  overflow-wrap: anywhere;
  user-select: all;
}

.bar {
  height: 8px;
  min-width: 80px;
  background: #e5eaee;
  border-radius: 4px;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  min-width: 2px;
  background: var(--accent);
}

.filters {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.filters .form-row {
  min-width: 170px;
}

.pagination {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 0 0 6px;
  font-size: 22px;
}

.login-panel > p {
  margin: 0 0 22px;
  color: var(--muted);
}

.login-panel .button {
  width: 100%;
  margin-top: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.detail-grid > div {
  padding: 10px 12px;
  border-bottom: 1px solid #e5eaee;
  min-width: 0;
}

.detail-grid > div:nth-child(odd) {
  background: #f8fafb;
  color: #53616e;
  font-weight: 600;
}

.code-preview {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #111923;
  color: #e6edf3;
  padding: 16px;
  border-radius: 8px;
  max-height: 520px;
  overflow: auto;
}

@media (max-width: 1080px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .form-row.span-2,
  .form-row.span-3 {
    grid-column: span 1;
  }
}

@media (max-width: 720px) {
  .topbar-inner {
    padding: 10px 14px;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
  }

  .connection-inner {
    padding: 9px 14px;
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .connection-item {
    width: 100%;
    flex-wrap: wrap;
  }

  .nav {
    order: 3;
    flex: 0 0 100%;
    width: 100%;
    min-width: 100%;
    overflow-x: auto;
  }

  .page {
    padding: 14px;
  }

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

  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .detail-grid > div:nth-child(odd) {
    border-bottom: 0;
  }
}
