:root {
  color-scheme: light;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background: #f6f8fb;
  color: #172033;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-alt: #f9fbfd;
  --line: #d9e1ec;
  --line-strong: #bac7d8;
  --text: #172033;
  --muted: #647086;
  --blue: #1665d8;
  --blue-dark: #0c4aa8;
  --teal: #008c95;
  --green: #16824a;
  --red: #c83332;
  --amber: #b5690d;
  --shadow: 0 10px 30px rgba(20, 42, 77, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  height: 62px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border: 1px solid #a9dbe0;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--teal);
  background: #eefbfc;
  flex: 0 0 auto;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.2;
  margin: 0;
  font-weight: 720;
  letter-spacing: 0;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill {
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #f7fafc;
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--amber);
}

.status-dot.ok {
  background: var(--green);
}

.layout {
  display: grid;
  grid-template-columns: 292px minmax(520px, 1fr) 390px;
  gap: 14px;
  padding: 14px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.panel-header h2,
.section-title h2 {
  font-size: 14px;
  line-height: 1.2;
  margin: 0;
  font-weight: 720;
}

.panel-header p,
.section-title p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.panel-body {
  padding: 14px;
}

.sidebar {
  position: sticky;
  top: 76px;
}

.env-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.tab {
  height: 36px;
  border: 1px solid var(--line);
  background: #f9fbfd;
  color: var(--muted);
  border-radius: 8px;
  font-size: 13px;
}

.tab.active {
  background: #eaf3ff;
  border-color: #9ec6fa;
  color: var(--blue-dark);
  font-weight: 700;
}

.model-list {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.model-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
  padding: 10px;
  color: var(--text);
}

.model-item.active {
  border-color: #7abec5;
  background: #f0fbfc;
}

.model-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
}

.model-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

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

.btn {
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 650;
}

.btn.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.btn.teal {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.btn.danger {
  background: #fff5f5;
  border-color: #f2b7b7;
  color: var(--red);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  padding: 0 6px;
}

.main {
  display: grid;
  gap: 14px;
}

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

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

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

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.input,
.select,
.textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  min-height: 38px;
  padding: 8px 10px;
  outline: none;
  font-size: 13px;
}

.textarea {
  min-height: 86px;
  resize: vertical;
  line-height: 1.5;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: #66b6d9;
  box-shadow: 0 0 0 3px rgba(0, 140, 149, 0.12);
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

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

.action-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-alt);
  display: grid;
  gap: 10px;
  min-height: 132px;
}

.action-card h3 {
  margin: 0;
  font-size: 13px;
}

.action-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.rightbar {
  position: sticky;
  top: 76px;
  display: grid;
  gap: 14px;
}

.json-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0e1726;
  color: #d8e7ff;
  padding: 12px;
  min-height: 124px;
  overflow: auto;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.result-cell {
  border: 1px solid var(--line);
  background: var(--surface-alt);
  border-radius: 8px;
  padding: 10px;
}

.result-cell span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 5px;
}

.result-cell strong {
  font-size: 13px;
}

.history-wrap {
  grid-column: 1 / -1;
}

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

.table-shell {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
  font-size: 12px;
}

th,
td {
  padding: 10px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: #4d5b70;
  background: #f4f7fb;
  font-weight: 720;
  position: sticky;
  top: 0;
}

td {
  color: #253148;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 7px;
  background: #eef3f8;
  color: #4b5c72;
  font-weight: 700;
  white-space: nowrap;
}

.badge.ok {
  background: #eaf7f0;
  color: var(--green);
}

.badge.warn {
  background: #fff6e7;
  color: var(--amber);
}

.badge.fail {
  background: #fff0f0;
  color: var(--red);
}

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

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.notice {
  border: 1px solid #c9e6ea;
  background: #f0fbfc;
  color: #1e5d65;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.55;
}

.offline {
  border-color: #efd49a;
  background: #fff8e8;
  color: #75510e;
}

.hide {
  display: none !important;
}

@media (max-width: 1280px) {
  .layout {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .rightbar {
    position: static;
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 900px) {
  .topbar {
    height: auto;
    min-height: 62px;
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 14px;
    gap: 10px;
  }

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

  .sidebar,
  .rightbar {
    position: static;
  }

  .rightbar,
  .split,
  .form-grid,
  .form-grid.three,
  .action-row {
    grid-template-columns: 1fr;
  }
}
