:root {
  --bg: #f4f7fb;
  --bg-soft: #eef4f8;
  --surface: #ffffff;
  --surface-2: #f8fbfd;
  --surface-3: #edf4f7;
  --text: #17212b;
  --muted: #657386;
  --line: #dde7ee;
  --line-strong: #c6d5df;
  --brand: #16a085;
  --brand-strong: #0f766e;
  --brand-soft: rgba(22, 160, 133, 0.12);
  --blue: #2563eb;
  --orange: #f59e0b;
  --red: #dc2626;
  --shadow: 0 16px 38px rgba(26, 45, 62, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 78% 8%, rgba(22, 160, 133, 0.14), transparent 260px),
    linear-gradient(180deg, #f8fbfd 0%, var(--bg) 320px);
}

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

code,
pre {
  font-family: Consolas, "SFMono-Regular", monospace;
}

.admin-shell {
  min-height: 100vh;
  width: 100%;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 16px 12px;
  color: var(--text);
  background:
    linear-gradient(180deg, #ffffff 0%, #f7fbfd 100%);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 8px 0 24px rgba(26, 45, 62, 0.04);
}

.brand-block {
  order: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 6px 6px 14px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), #7dd3c7);
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(22, 160, 133, 0.22);
}

.brand-block h1 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-block p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  order: 2;
  display: grid;
  gap: 6px;
  align-items: stretch;
}

.sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 42px;
  padding: 0 14px 0 36px;
  border-radius: 8px;
  color: #425466;
  font-size: 14px;
  font-weight: 700;
}

.sidebar-link::before {
  content: "";
  position: absolute;
  left: 15px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #b7c6d0;
}

.sidebar-link:hover,
.sidebar-link.active {
  color: var(--brand-strong);
  background: var(--brand-soft);
}

.sidebar-link:hover::before,
.sidebar-link.active::before {
  background: var(--brand);
}

.sidebar-user {
  order: 3;
  margin-top: auto;
  padding: 12px;
  min-height: 58px;
  display: grid;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

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

.sidebar-user strong {
  color: var(--text);
  font-size: 14px;
}

.sidebar-footer {
  order: 4;
  display: flex;
  justify-content: stretch;
}

.ghost-link {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #425466;
  background: #ffffff;
}

.ghost-link:hover {
  color: var(--red);
  border-color: rgba(220, 38, 38, 0.25);
  background: rgba(220, 38, 38, 0.05);
}

.content-shell {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 18px;
}

.page-top,
.hero-top {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  min-height: 132px;
  margin-bottom: 14px;
  padding: 26px 28px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(239, 249, 246, 0.98) 55%, rgba(232, 242, 255, 0.96) 100%);
  box-shadow: var(--shadow);
}

.hero-top::before {
  content: "";
  position: absolute;
  right: 36px;
  top: 24px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(22, 160, 133, 0.20) 0 30%, transparent 32%),
    conic-gradient(from 90deg, rgba(22, 160, 133, 0.28), rgba(37, 99, 235, 0.18), rgba(22, 160, 133, 0.28));
  opacity: 0.68;
}

.hero-top::after {
  content: "";
  position: absolute;
  right: 94px;
  bottom: 22px;
  width: 170px;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(22, 160, 133, 0.42), transparent);
  transform: rotate(-12deg);
}

.hero-top > * {
  position: relative;
  z-index: 1;
}

.page-top h2,
.hero-top h2 {
  margin: 4px 0 8px;
  color: var(--text);
  font-size: 30px;
  line-height: 1.18;
  letter-spacing: -0.03em;
}

.page-top p,
.hero-top p {
  margin: 0;
  max-width: 660px;
  color: var(--muted);
  font-size: 14px;
}

.eyebrow,
.hero-top .eyebrow {
  display: inline-block;
  color: var(--brand-strong);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.content-area,
.stack-layout {
  display: grid;
  gap: 14px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
}

.compact-grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 220px));
}

.metric-panel {
  min-height: 112px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-panel span {
  display: block;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
}

.metric-panel strong {
  color: var(--text);
  font-size: 32px;
  line-height: 1;
}

.accent-blue {
  border-color: rgba(37, 99, 235, 0.18);
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.08), #ffffff 58%);
}

.accent-orange {
  border-color: rgba(245, 158, 11, 0.2);
  background:
    linear-gradient(180deg, rgba(245, 158, 11, 0.10), #ffffff 58%);
}

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

.wide-form-grid {
  grid-template-columns: minmax(360px, 500px) minmax(0, 1fr);
}

.card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.form-card {
  align-self: start;
}

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

.section-head h3,
.detail-card h3 {
  margin: 2px 0 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.25;
}

.shortcut-list {
  display: grid;
  gap: 10px;
}

.shortcut-card {
  display: block;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.shortcut-card:hover {
  border-color: rgba(22, 160, 133, 0.32);
  background: #f0fbf8;
}

.shortcut-card strong {
  display: block;
  margin-bottom: 5px;
  color: var(--text);
}

.shortcut-card span {
  color: var(--muted);
  font-size: 13px;
}

.stack-form,
.narrow-form {
  display: grid;
  gap: 12px;
}

.inline-form,
.compact-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.inline-form input,
.inline-form select {
  flex: 1 1 220px;
}

label,
.label-title {
  display: block;
  color: #344458;
  font-size: 13px;
  font-weight: 800;
}

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

input,
select,
textarea {
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(22, 160, 133, 0.13);
}

textarea {
  resize: vertical;
}

button,
.link-btn,
.primary-btn,
.secondary-btn,
.danger-btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
}

.primary-btn {
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(22, 160, 133, 0.18);
}

.primary-btn:hover {
  background: var(--brand-strong);
}

.secondary-btn {
  background: #e8eef3;
  color: #26384a;
}

.secondary-btn:hover {
  background: #dce6ed;
}

.danger-btn {
  background: rgba(220, 38, 38, 0.09);
  color: var(--red);
}

.link-btn {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.flash {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
}

.flash.success {
  background: rgba(22, 160, 133, 0.10);
  color: var(--brand-strong);
}

.flash.error {
  background: rgba(220, 38, 38, 0.10);
  color: var(--red);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

.data-table th {
  color: #526475;
  background: #f4f8fb;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.data-table tbody tr:hover {
  background: #f7fbfd;
}

.data-table tbody tr td:first-child {
  font-weight: 700;
}

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

.tag-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.tag-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid rgba(22, 160, 133, 0.22);
  border-radius: 999px;
  background: rgba(22, 160, 133, 0.09);
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.switch-form {
  margin: 0;
}

.switch-control {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.switch-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  opacity: 0;
}

.switch-track {
  position: relative;
  width: 52px;
  height: 28px;
  border-radius: 999px;
  background: #cbd6df;
  transition: background 0.18s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(26, 45, 62, 0.18);
  transition: transform 0.18s ease;
}

.switch-control input:checked + .switch-track {
  background: var(--brand);
}

.switch-control input:checked + .switch-track::after {
  transform: translateX(24px);
}

.muted,
.empty,
.hint-box {
  color: var(--muted);
}

.checkbox-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding: 10px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.checkbox-item input {
  width: auto;
  margin: 0;
}

.detail-card {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 14px;
  margin: 12px 0;
}

.detail-grid p {
  margin: 0;
  display: grid;
  gap: 3px;
}

.detail-grid strong {
  color: #526475;
  font-size: 12px;
  text-transform: uppercase;
}

.api-rule-grid,
.api-example-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.rule-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.rule-card strong {
  display: block;
  margin-bottom: 5px;
  color: var(--text);
}

.rule-card p,
.api-description {
  margin: 0;
  color: var(--muted);
}

.api-head {
  align-items: center;
}

.api-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.method-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 8px;
  background: var(--blue);
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
}

.api-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 12px 0;
}

.meta-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.code-panel {
  overflow: hidden;
  border: 1px solid #d6e2ea;
  border-radius: 8px;
  background: #0f172a;
}

.code-title {
  padding: 9px 12px;
  color: #dce8f2;
  background: #182235;
  border-bottom: 1px solid #27344b;
  font-size: 13px;
}

.code-panel pre {
  margin: 0;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #e7eef7;
  font-size: 13px;
  overflow-x: auto;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 18%, rgba(22, 160, 133, 0.16), transparent 260px),
    radial-gradient(circle at 82% 14%, rgba(37, 99, 235, 0.12), transparent 260px),
    var(--bg);
}

.login-card {
  width: min(460px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.login-card h1 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.login-card .muted {
  margin-bottom: 18px;
}

.hint-box {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

@media (max-width: 1180px) {
  .dashboard-grid,
  .panel-grid,
  .wide-form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .admin-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .content-shell {
    padding: 14px;
  }

  .page-top,
  .hero-top {
    flex-direction: column;
    align-items: flex-start;
  }
}
