:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #172033;
  --muted: #657083;
  --line: #dfe5ee;
  --teal: #00a6a6;
  --teal-dark: #087d80;
  --amber: #b7791f;
  --red: #c2413b;
  --green: #17824f;
  --ink: #111827;
  --sidebar: #18202f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  font: 14px/1.45 Arial, "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef2f6;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 12px 32px rgba(23, 32, 51, 0.08);
}

.brand-row,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  color: #fff;
  background: var(--teal-dark);
  font-weight: 700;
}

.brand-row h1 {
  margin: 0;
  font-size: 24px;
}

.brand-row p,
.sidebar-brand small,
#sub-title {
  margin: 0;
  color: var(--muted);
}

.form-stack,
.form-grid,
.api-form {
  display: grid;
  gap: 16px;
}

.form-stack {
  margin-top: 28px;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: #394255;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfd7e3;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 40px;
  padding: 8px 11px;
}

textarea {
  resize: vertical;
  padding: 10px 11px;
  font-family: Consolas, "Courier New", monospace;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 166, 166, 0.14);
}

.primary-btn,
.ghost-btn,
.link-btn {
  min-height: 36px;
  border-radius: 6px;
  padding: 8px 14px;
  border: 1px solid transparent;
  white-space: nowrap;
}

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

.primary-btn:hover {
  background: #06696b;
}

.ghost-btn {
  color: var(--text);
  background: #fff;
  border-color: var(--line);
}

.ghost-btn:hover {
  border-color: #b8c4d3;
  background: #f8fafc;
}

.ghost-btn.danger {
  color: var(--red);
}

.link-btn {
  padding: 0;
  min-height: auto;
  color: var(--teal-dark);
  background: transparent;
}

.error-text {
  min-height: 20px;
  color: var(--red);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
}

.sidebar {
  background: var(--sidebar);
  color: #e9edf5;
  padding: 20px 16px;
}

.sidebar-brand {
  min-height: 56px;
  margin-bottom: 24px;
}

.sidebar-brand .brand-mark {
  background: #0d8e91;
}

.side-nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border: 0;
  border-radius: 6px;
  color: #c9d3e2;
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.main-area {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar h2 {
  margin: 0 0 4px;
  font-size: 22px;
}

.top-actions,
.button-group,
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  top: 20px;
  right: 24px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid #b8d7c6;
  border-radius: 8px;
  color: #0f5132;
  background: #e9f7ef;
  box-shadow: 0 12px 28px rgba(23, 32, 51, 0.12);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  min-height: 124px;
  padding: 16px;
  display: grid;
  align-content: space-between;
  gap: 10px;
}

.metric span,
.status-pill {
  color: var(--muted);
}

.metric strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 18px;
}

.panel {
  padding: 18px;
  margin-bottom: 16px;
}

.panel-head {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h3 {
  margin: 0;
  font-size: 17px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #edf2f7;
  font-size: 12px;
}

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

.form-grid.compact {
  max-width: 920px;
}

.wide {
  grid-column: 1 / -1;
}

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

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  color: #394255;
  background: #f8fafc;
  font-weight: 700;
}

.method-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 150px;
  gap: 10px;
  align-items: center;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
}

.checkline input {
  width: 16px;
  min-height: auto;
}

.checkline span {
  margin: 0;
}

.json-box {
  min-height: 120px;
  margin: 14px 0 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid #d8e0eb;
  border-radius: 8px;
  background: #111827;
  color: #e5e7eb;
  font: 13px/1.5 Consolas, "Courier New", monospace;
}

.timeline,
.log-list {
  display: grid;
  gap: 10px;
}

.timeline-item,
.log-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
}

.timeline-item strong,
.log-item strong {
  display: block;
  margin-bottom: 4px;
}

.timeline-item code,
.log-item code {
  display: block;
  overflow-wrap: anywhere;
  color: var(--muted);
}

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

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

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

  .metric-grid,
  .split-grid,
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .main-area {
    padding: 16px;
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-grid,
  .split-grid,
  .form-grid,
  .form-row,
  .method-row,
  .side-nav {
    grid-template-columns: 1fr;
  }
}
