:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --text: #0f172a;
  --muted: #667085;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --sider: #0b1220;
  --sider-soft: rgba(255, 255, 255, 0.08);
  --shadow: 0 18px 60px rgba(15, 23, 42, 0.12);
}

body[data-theme-mode="dark"] {
  color-scheme: dark;
  --bg: #0f172a;
  --panel: #111827;
  --panel-2: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: #334155;
  --primary: #60a5fa;
  --primary-2: #93c5fd;
  --sider: #020617;
  --sider-soft: rgba(255, 255, 255, 0.1);
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

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

button {
  border: 0;
}

.initial-loader {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(140% 140% at 20% 20%, #162642 0%, #0c1528 40%, #060b16 100%);
}

.loader-card {
  min-width: 220px;
  padding: 20px 22px 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  color: #e5e7eb;
}

.loader-title {
  font-size: 16px;
  font-weight: 700;
}

.loader-dots {
  display: flex;
  gap: 8px;
}

.loader-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #82b5ff;
  animation: loader-bounce 1.1s ease-in-out infinite;
}

.loader-dots span:nth-child(2) {
  animation-delay: 0.14s;
}

.loader-dots span:nth-child(3) {
  animation-delay: 0.28s;
}

.loader-tip {
  color: rgba(229, 231, 235, 0.72);
  font-size: 13px;
}

@keyframes loader-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.6;
  }
  40% {
    transform: translateY(-7px);
    opacity: 1;
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: 0.18s ease;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

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

.btn.primary:hover:not(:disabled) {
  background: var(--primary-2);
  color: #fff;
}

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

.btn.link {
  border-color: transparent;
  background: transparent;
  color: var(--primary);
  padding-left: 4px;
  padding-right: 4px;
}

.btn.small {
  min-height: 28px;
  padding: 4px 9px;
  font-size: 12px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
}

.welcome-shell {
  min-height: 100vh;
  background: radial-gradient(circle at 20% 20%, #f3f6ff, #f5f7fb 38%, #eef2ff 65%),
    linear-gradient(120deg, #f6f9ff 0%, #f9fbff 35%, #eef4ff 100%);
  color: #0f172a;
  position: relative;
  overflow-x: hidden;
}

body[data-theme-mode="dark"] .welcome-shell {
  background: radial-gradient(circle at 20% 20%, #172554, #0f172a 48%, #020617 100%);
  color: #e5e7eb;
}

.welcome-topbar {
  position: absolute;
  top: 18px;
  right: 24px;
  z-index: 3;
}

.welcome-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 48px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 112px 28px 32px;
}

.welcome-hero {
  flex: 1;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.welcome-pill {
  width: fit-content;
  padding: 8px 14px;
  border-radius: 999px;
  color: #1d4ed8;
  background: rgba(40, 91, 255, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.16);
  font-weight: 700;
  font-size: 13px;
}

body[data-theme-mode="dark"] .welcome-pill {
  color: #bfdbfe;
  background: rgba(96, 165, 250, 0.14);
  border-color: rgba(147, 197, 253, 0.24);
}

.welcome-hero h1 {
  margin: 0;
  font-size: 40px;
  line-height: 1.2;
  letter-spacing: 0;
}

.welcome-lead {
  max-width: 620px;
  margin: 4px 0 0;
  font-size: 16px;
  line-height: 1.65;
  color: #42526b;
}

body[data-theme-mode="dark"] .welcome-lead,
body[data-theme-mode="dark"] .welcome-hint {
  color: #cbd5e1;
}

.welcome-tags,
.tag-row,
.actions,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.welcome-tags {
  margin-top: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  line-height: 1.2;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #dbeafe;
}

.tag.green {
  background: #ecfdf5;
  color: #047857;
  border-color: #d1fae5;
}

.tag.orange {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fed7aa;
}

.tag.red {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.tag.gray {
  background: #f1f5f9;
  color: #475569;
  border-color: #e2e8f0;
}

body[data-theme-mode="dark"] .tag {
  background: #172554;
  border-color: #1e40af;
  color: #bfdbfe;
}

body[data-theme-mode="dark"] .tag.green {
  background: #052e24;
  color: #a7f3d0;
  border-color: #065f46;
}

body[data-theme-mode="dark"] .tag.orange {
  background: #451a03;
  color: #fdba74;
  border-color: #9a3412;
}

body[data-theme-mode="dark"] .tag.red {
  background: #450a0a;
  color: #fecaca;
  border-color: #991b1b;
}

.welcome-bottom-cta {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.welcome-cta {
  height: 58px;
  padding: 0 40px;
  font-size: 18px;
  border-radius: 16px;
  box-shadow: 0 16px 50px rgba(37, 99, 235, 0.28);
}

.welcome-hint {
  color: #5f6b84;
  font-size: 13px;
}

.welcome-visuals {
  flex: 1;
  position: relative;
  min-height: 620px;
  width: 100%;
  cursor: pointer;
}

.visual-dots {
  position: absolute;
  inset: 32px;
  background-image: radial-gradient(#d6e0ff 1px, transparent 1px);
  background-size: 18px 18px;
  border-radius: 30px;
}

.visual-card {
  position: absolute;
  width: 74%;
  aspect-ratio: 4 / 7;
  top: 6%;
  left: 16%;
  border-radius: 24px;
  cursor: pointer;
  background-size: cover;
  background-position: center;
  box-shadow: 0 22px 66px rgba(15, 23, 42, 0.22);
  transform: rotate(-2deg);
}

.visual-card.secondary {
  width: 52%;
  top: 2%;
  left: -4%;
  transform: rotate(-9deg);
}

.visual-card.tertiary {
  width: 58%;
  top: 48%;
  right: -8%;
  left: auto;
  transform: rotate(9deg);
}

.visual-blur {
  position: absolute;
  inset: 6% 8%;
  background: radial-gradient(circle at 30% 40%, rgba(59, 130, 246, 0.14), transparent 46%),
    radial-gradient(circle at 78% 30%, rgba(59, 130, 246, 0.18), transparent 48%),
    radial-gradient(circle at 60% 82%, rgba(16, 185, 129, 0.18), transparent 48%);
  filter: blur(22px);
  border-radius: 30px;
  pointer-events: none;
}

.welcome-auth {
  max-width: 720px;
  margin: 0 auto 64px;
  padding: 24px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow);
}

body[data-theme-mode="dark"] .welcome-auth {
  background: rgba(15, 23, 42, 0.9);
}

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

.auth-title {
  font-size: 20px;
  font-weight: 700;
}

.auth-desc {
  color: var(--muted);
  margin-top: 4px;
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.tab {
  padding: 10px 12px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: var(--muted);
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 700;
}

.app-layout {
  height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  background: var(--bg);
}

.app-sider {
  height: 100vh;
  background: var(--sider);
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  overflow: hidden;
}

.sider-brand {
  font-size: 16px;
  font-weight: 700;
  padding: 4px 8px 14px;
}

.nav-scroll {
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
}

.nav-group-title {
  margin: 16px 8px 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.58);
}

.nav-link {
  display: flex;
  gap: 9px;
  align-items: center;
  color: #dbe4f0;
  padding: 10px 12px;
  border-radius: 8px;
  margin: 2px 4px;
  cursor: pointer;
}

.nav-link.active,
.nav-link:hover {
  background: var(--sider-soft);
  color: #fff;
}

.sider-footer {
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sider-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
}

.avatar {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #334155;
  color: #f8fafc;
  font-weight: 700;
}

.sider-name {
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
}

.sider-role {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
}

.app-main {
  min-width: 0;
  height: 100vh;
  overflow: auto;
  padding: 24px;
}

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

.page-title {
  font-size: 20px;
  font-weight: 700;
}

.page-desc {
  color: var(--muted);
  margin-top: 4px;
}

.panel,
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.panel {
  padding: 18px;
}

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

.card-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 14px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label,
.label {
  font-weight: 600;
  font-size: 13px;
}

.field small,
.help,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  outline: none;
}

.textarea {
  min-height: 88px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.switch input {
  appearance: none;
  width: 38px;
  height: 21px;
  border-radius: 999px;
  background: #cbd5e1;
  position: relative;
  transition: 0.18s ease;
}

.switch input::after {
  content: "";
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: 0.18s ease;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.22);
}

.switch input:checked {
  background: var(--primary);
}

.switch input:checked::after {
  transform: translateX(17px);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--panel-2);
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

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

.compact td,
.compact th {
  padding: 8px 10px;
}

.empty {
  padding: 42px 16px;
  text-align: center;
  color: var(--muted);
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.toolbar .input,
.toolbar .select {
  width: auto;
  min-width: 180px;
}

.modal-backdrop,
.preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.64);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 24px;
}

.modal {
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--panel);
  color: var(--text);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.modal.wide {
  width: min(980px, 100%);
}

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

.modal-foot {
  border-top: 1px solid var(--border);
  border-bottom: 0;
  justify-content: flex-end;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.modal-body {
  padding: 18px;
}

.drawer {
  width: min(760px, 100%);
  height: 100vh;
  margin-left: auto;
  background: var(--panel);
  overflow: auto;
}

.preview-img {
  max-width: calc(100vw - 96px);
  max-height: calc(100vh - 120px);
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px 42px;
  gap: 10px;
  align-items: end;
  margin-bottom: 8px;
}

.form-row.four {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 130px 42px;
}

.tree {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  max-height: 420px;
  overflow: auto;
  background: var(--panel-2);
}

.tree-node {
  margin: 6px 0;
}

.tree-children {
  margin-left: 22px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 3px 10px;
}

.step-actions {
  position: sticky;
  bottom: 0;
  padding: 14px 0 0;
  background: linear-gradient(to top, var(--bg), rgba(245, 247, 251, 0));
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

body[data-theme-mode="dark"] .step-actions {
  background: linear-gradient(to top, var(--bg), rgba(15, 23, 42, 0));
}

.progress-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--panel-2);
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: var(--primary);
  transition: width 0.2s ease;
}

.steps {
  display: grid;
  gap: 10px;
}

.step-line {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: var(--panel-2);
}

.step-line.done {
  border-color: #86efac;
}

.step-line.failed {
  border-color: #fca5a5;
}

#toast-root {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: grid;
  gap: 8px;
}

.toast {
  min-width: 220px;
  max-width: 360px;
  padding: 11px 13px;
  border-radius: 10px;
  color: #fff;
  background: #334155;
  box-shadow: var(--shadow);
  animation: toast-in 0.18s ease;
}

.toast.success {
  background: #059669;
}

.toast.error {
  background: #dc2626;
}

.toast.info {
  background: #2563eb;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hidden {
  display: none !important;
}

.nowrap {
  white-space: nowrap;
}

.pre {
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 920px) {
  .app-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .app-sider {
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    max-height: 55vh;
  }

  .app-main {
    height: auto;
    padding: 16px;
  }

  .welcome-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .welcome-visuals {
    min-height: 420px;
  }

  .grid.two,
  .grid.three {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 600px) {
  .welcome-hero h1 {
    font-size: 32px;
  }

  .page-head {
    flex-direction: column;
  }

  .toolbar .input,
  .toolbar .select {
    width: 100%;
  }

  .modal-backdrop {
    padding: 0;
  }

  .modal {
    min-height: 100vh;
    border-radius: 0;
  }
}
