:root {
  --admin-bg: var(--bg);
  --admin-bg-elevated: color-mix(in srgb, var(--bg) 86%, var(--toolbar-bg) 14%);
  --admin-bg-panel: color-mix(in srgb, var(--bg) 78%, var(--toolbar-bg) 22%);
  --admin-bg-panel-strong: color-mix(in srgb, var(--bg) 68%, var(--toolbar-bg) 32%);
  --admin-bg-soft: color-mix(in srgb, var(--bg) 84%, var(--input-bg) 16%);
  --admin-ink: var(--text);
  --admin-muted: var(--text-muted);
  --admin-subtle: var(--text-dim);
  --admin-border: color-mix(in srgb, var(--border) 80%, transparent 20%);
  --admin-border-strong: color-mix(in srgb, var(--border) 100%, var(--text-faint2) 20%);
  --admin-accent: var(--accent);
  --admin-accent-strong: var(--btn-primary);
  --admin-accent-soft: var(--accent-subtle);
  --admin-card-shadow: 0 18px 50px color-mix(in srgb, var(--bg) 72%, transparent 28%);
  --admin-surface-glow: color-mix(in srgb, var(--link) 18%, transparent 82%);
  --admin-good: var(--badge-info-text);
  --admin-good-bg: var(--badge-info-bg);
  --admin-warn: var(--badge-warn-text);
  --admin-warn-bg: var(--badge-warn-bg);
  --admin-bad: var(--badge-error-text);
  --admin-bad-bg: var(--badge-error-bg);
  color-scheme: dark;
}

[data-theme-schema="light"] {
  color-scheme: light;
}

[data-theme-schema="dark"] {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--admin-ink);
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--admin-accent) 14%, transparent 86%), transparent 26%),
    radial-gradient(circle at top right, color-mix(in srgb, var(--link) 12%, transparent 88%), transparent 22%),
    linear-gradient(180deg, color-mix(in srgb, var(--admin-bg) 94%, #000 6%) 0%, var(--admin-bg) 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

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

button,
input,
select,
textarea,
code {
  color: inherit;
}

select,
input,
textarea {
  outline: none;
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px 1fr;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--toolbar-bg) 58%, transparent 42%) 0, color-mix(in srgb, var(--toolbar-bg) 12%, transparent 88%) 300px, transparent 300px),
    radial-gradient(circle at 24% 12%, var(--admin-surface-glow), transparent 24%);
}

.admin-sidebar {
  position: sticky;
  top: 0;
  min-height: 100vh;
  padding: 28px 22px;
  border-right: 1px solid var(--admin-border);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--toolbar-bg) 82%, transparent 18%), color-mix(in srgb, var(--bg) 88%, transparent 12%));
  backdrop-filter: blur(18px);
}

.admin-brand {
  display: grid;
  gap: 12px;
  margin-bottom: 28px;
}

.admin-brand-mark {
  width: 76px;
  height: 76px;
  padding: 6px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  box-shadow: 0 14px 34px color-mix(in srgb, var(--admin-accent) 24%, transparent 76%);
  border: 1px solid color-mix(in srgb, var(--admin-border) 72%, transparent 28%);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--toolbar-bg) 80%, transparent 20%), color-mix(in srgb, var(--admin-bg-panel) 88%, transparent 12%));
}

.admin-brand-mark-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 18px;
}

.admin-brand h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0.02em;
}

.admin-brand p,
.admin-sidebar-note,
.page-hero p,
.muted {
  margin: 0;
  color: var(--admin-muted);
}

.admin-nav {
  display: grid;
  gap: 10px;
}

.admin-nav-link {
  padding: 13px 14px;
  border: 1px solid transparent;
  border-radius: 16px;
  color: var(--admin-muted);
  transition: 160ms ease;
}

.admin-nav-link.router-link-active {
  background: color-mix(in srgb, var(--toolbar-bg) 78%, var(--admin-accent) 22%);
  border-color: color-mix(in srgb, var(--admin-accent) 36%, var(--admin-border) 64%);
  color: var(--admin-ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--admin-accent) 12%, transparent 88%);
}

.admin-nav-link:hover {
  background: color-mix(in srgb, var(--toolbar-bg) 60%, transparent 40%);
  color: var(--admin-ink);
}

.admin-theme-card,
.panel,
.card,
.stat-card,
.editor-card {
  border-radius: 24px;
  border: 1px solid var(--admin-border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--admin-bg-panel) 92%, transparent 8%), color-mix(in srgb, var(--admin-bg-panel-strong) 96%, transparent 4%));
  backdrop-filter: blur(18px);
  box-shadow: var(--admin-card-shadow);
}

.admin-theme-card {
  margin-top: 18px;
  padding: 16px;
  display: grid;
  gap: 14px;
}

.admin-theme-card-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.admin-theme-card-header strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.admin-theme-card-header p {
  color: var(--admin-muted);
  font-size: 12px;
  line-height: 1.5;
}

.theme-mode-pill,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: color-mix(in srgb, var(--toolbar-bg) 72%, transparent 28%);
  color: var(--admin-subtle);
  border: 1px solid var(--admin-border);
}

.theme-select-field,
.field,
.field-full {
  display: grid;
  gap: 7px;
}

.theme-select-field span,
.field label,
.field-full label {
  font-size: 13px;
  color: var(--admin-subtle);
  font-weight: 700;
}

.theme-select-field select,
.field input,
.field textarea,
.field select,
.field-full input,
.field-full textarea,
.field-full select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--admin-border);
  background: color-mix(in srgb, var(--input-bg) 88%, transparent 12%);
  padding: 11px 12px;
  color: var(--admin-ink);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.theme-select-field select:focus,
.field input:focus,
.field textarea:focus,
.field select:focus,
.field-full input:focus,
.field-full textarea:focus,
.field-full select:focus {
  border-color: color-mix(in srgb, var(--admin-accent) 55%, var(--admin-border) 45%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--admin-accent-soft) 72%, transparent 28%);
}

.theme-preview-card {
  overflow: hidden;
  border: 1px solid var(--admin-border);
  border-radius: 18px;
}

.theme-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
}

.theme-preview-body {
  padding: 14px 12px;
  display: grid;
  gap: 12px;
}

.theme-preview-muted {
  color: var(--admin-muted);
  font-weight: 500;
}

.theme-preview-chip {
  width: fit-content;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.theme-preview-lines {
  display: grid;
  gap: 8px;
}

.theme-preview-lines span {
  height: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, currentColor 14%, transparent 86%);
}

.theme-preview-lines span:last-child {
  width: 72%;
}

.admin-sidebar-note {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--admin-border);
  line-height: 1.6;
}

.admin-main {
  padding: 28px;
  overflow-y: auto;
  height: 100vh;
}

.page {
  display: grid;
  gap: 22px;
}

.page-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-radius: 20px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--admin-bg-panel) 92%, transparent 8%), color-mix(in srgb, var(--admin-bg-panel-strong) 96%, transparent 4%));
  border: 1px solid var(--admin-border);
  box-shadow: var(--admin-card-shadow);
  backdrop-filter: blur(18px);
}

.page-hero h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0.02em;
}

.hero-actions,
.panel-actions,
.inline-actions,
.status-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.grid-2,
.grid-3,
.stat-grid,
.panel-grid {
  display: grid;
  gap: 18px;
}

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

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

.panel,
.editor-card {
  padding: 22px;
}

.card,
.stat-card {
  padding: 18px;
}

.panel h3,
.editor-card h3,
.card h3 {
  margin: 0 0 10px;
}

.stat-card strong {
  display: block;
  margin-top: 12px;
  font-size: 34px;
}

.split-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.stack,
.list,
.table-list {
  display: grid;
}

.stack {
  gap: 12px;
}

.list,
.table-list {
  gap: 14px;
}

.record,
.tool-block {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--admin-border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--admin-bg-soft) 86%, transparent 14%), color-mix(in srgb, var(--admin-bg-panel) 94%, transparent 6%));
}

.record h4 {
  margin: 0 0 8px;
  font-size: 18px;
}

.record-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--admin-muted);
  font-size: 13px;
}

.badge.running,
.badge.success {
  background: var(--admin-good-bg);
  color: var(--admin-good);
  border-color: transparent;
}

.badge.starting {
  background: var(--admin-warn-bg);
  color: var(--admin-warn);
  border-color: transparent;
}

.badge.error,
.badge.failed {
  background: var(--admin-bad-bg);
  color: var(--admin-bad);
  border-color: transparent;
}

.btn {
  padding: 11px 16px;
  border: 1px solid var(--admin-border-strong);
  border-radius: 14px;
  background: color-mix(in srgb, var(--btn-bg) 88%, transparent 12%);
  color: var(--admin-ink);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--admin-accent) 28%, var(--admin-border) 72%);
  background: color-mix(in srgb, var(--btn-hover) 88%, transparent 12%);
}

.btn.primary {
  background: linear-gradient(135deg, var(--btn-primary) 0%, color-mix(in srgb, var(--btn-primary-hover) 72%, white 28%) 100%);
  border-color: transparent;
  box-shadow: 0 14px 28px color-mix(in srgb, var(--btn-primary) 24%, transparent 76%);
  color: var(--btn-primary-text);
}

.btn.ghost {
  background: transparent;
}

.btn.warn {
  color: var(--btn-primary-text);
  background: color-mix(in srgb, var(--badge-error-text) 72%, #550000 28%);
  border-color: transparent;
}

.btn.danger {
  color: var(--btn-primary-text);
  background: linear-gradient(135deg, #dc2626, #991b1b);
  border-color: color-mix(in srgb, #ef4444 55%, transparent 45%);
  box-shadow: 0 12px 24px color-mix(in srgb, #dc2626 18%, transparent 82%);
}

.btn.danger:hover {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  border-color: color-mix(in srgb, #f87171 62%, transparent 38%);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

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

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

.field textarea,
.field-full textarea {
  min-height: 110px;
  resize: vertical;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
}

.field-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
}

.field-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--admin-accent);
}

.key-value {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px;
  color: var(--admin-subtle);
  font-size: 14px;
}

.mono {
  font-family: Consolas, "SFMono-Regular", monospace;
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--admin-border-strong);
  border-radius: 18px;
  color: var(--admin-muted);
  background: color-mix(in srgb, var(--admin-bg-soft) 64%, transparent 36%);
}

.connection-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
  background: color-mix(in srgb, var(--bg) 38%, transparent 62%);
  backdrop-filter: blur(10px);
}

.connection-picker-dialog {
  width: min(560px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 22px;
  border-radius: 24px;
  border: 1px solid var(--admin-border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--admin-bg-panel) 94%, transparent 6%), color-mix(in srgb, var(--admin-bg-panel-strong) 98%, transparent 2%));
  box-shadow: var(--admin-card-shadow);
}

.connection-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.connection-picker-header h3 {
  margin: 0;
}

code {
  font-family: Consolas, "SFMono-Regular", monospace;
  color: color-mix(in srgb, var(--admin-ink) 86%, var(--admin-accent) 14%);
}

@media (max-width: 1180px) {
  .admin-shell {
    grid-template-columns: 240px minmax(0, 1fr);
    background:
      linear-gradient(90deg, color-mix(in srgb, var(--toolbar-bg) 52%, transparent 48%) 0, color-mix(in srgb, var(--toolbar-bg) 10%, transparent 90%) 240px, transparent 240px),
      radial-gradient(circle at 24% 10%, var(--admin-surface-glow), transparent 24%);
  }

  .admin-sidebar {
    padding: 22px 16px;
  }

  .admin-brand h1 {
    font-size: 26px;
  }

  .admin-main {
    min-width: 0;
    padding: 22px;
  }
}

@media (max-width: 900px) {
  .admin-shell {
    grid-template-columns: 1fr;
    background:
      linear-gradient(180deg, color-mix(in srgb, var(--toolbar-bg) 48%, transparent 52%) 0, transparent 220px),
      radial-gradient(circle at 24% 8%, var(--admin-surface-glow), transparent 22%);
  }

  .admin-sidebar {
    position: static;
    min-height: auto;
    padding: 20px 16px;
    border-right: none;
    border-bottom: 1px solid var(--admin-border);
  }

  .admin-brand {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 14px;
    row-gap: 0;
  }

  .admin-brand h1 {
    font-size: 24px;
  }

  .admin-nav {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .admin-main {
    height: auto;
    min-height: 0;
    overflow: visible;
    padding: 18px 16px 24px;
  }

  .page-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding: 18px;
  }

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