:root {
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #d9e1ea;
  --line-strong: #c6d2df;
  --text: #16202a;
  --muted: #64748b;
  --primary: #1769aa;
  --primary-strong: #0f4f83;
  --green: #157347;
  --amber: #b54708;
  --red: #b42318;
  --blue: #175cd3;
  --gray: #475467;
  --shadow: 0 16px 40px rgba(15, 23, 42, .08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 78% 18%, rgba(241, 169, 79, .20), transparent 30%),
    radial-gradient(circle at 18% 82%, rgba(22, 117, 170, .16), transparent 34%),
    linear-gradient(135deg, rgba(23, 105, 170, .12), rgba(21, 115, 71, .08)),
    var(--bg);
}

.auth-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(15, 37, 55, .045) 1px, transparent 1px),
    linear-gradient(0deg, rgba(15, 37, 55, .035) 1px, transparent 1px);
  background-size: 38px 38px;
  opacity: .45;
}

.auth-bg-orbit {
  position: absolute;
  width: min(720px, 90vw);
  height: min(720px, 90vw);
  border-radius: 50%;
  pointer-events: none;
  animation: orbitTurn 28s linear infinite;
  opacity: .98;
}

.auth-bg-orbit::before,
.auth-bg-orbit::after {
  content: "";
  position: absolute;
  inset: 16%;
  border: 1px solid rgba(23, 105, 170, .12);
  border-radius: 50%;
}

.auth-bg-orbit::after {
  inset: 27%;
  border-color: rgba(21, 115, 71, .12);
}

.orbit-image {
  position: absolute;
  width: 86px;
  height: 86px;
  object-fit: cover;
  border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, .92);
  box-shadow: 0 18px 36px rgba(15, 37, 55, .18);
  animation: orbitImagePulse 9s ease-in-out infinite;
}

.orbit-one {
  left: 50%;
  top: 8%;
  animation-delay: 0s;
}

.orbit-two {
  right: 9%;
  bottom: 21%;
  animation-delay: 3s;
}

.orbit-three {
  left: 10%;
  bottom: 24%;
  animation-delay: 6s;
}

@keyframes orbitTurn {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes orbitImagePulse {
  0%,
  100% {
    opacity: .28;
    transform: scale(.88) rotate(-10deg);
  }
  28%,
  58% {
    opacity: .96;
    transform: scale(1) rotate(0deg);
  }
  72% {
    opacity: .45;
    transform: scale(.92) rotate(8deg);
  }
}

.auth-layout {
  width: min(420px, 100%);
  display: grid;
  grid-template-columns: minmax(320px, 420px);
  align-items: stretch;
  position: relative;
  z-index: 2;
}

.auth-panel {
  background: rgba(255, 255, 255, .88);
  border: 1px solid var(--line);
  border-radius: 8px;
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  padding: 28px;
  min-height: 470px;
  display: grid;
  align-content: center;
  position: relative;
  z-index: 2;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  margin-bottom: 18px;
}

.brand-mark.small {
  width: 34px;
  height: 34px;
  margin: 0;
}

.auth-panel h1 {
  margin: 0;
  font-size: 24px;
}

.auth-panel p {
  margin: 8px 0 20px;
  color: var(--muted);
}

.auth-form,
.settings-form {
  display: grid;
  gap: 14px;
}

.settings-form.inline {
  grid-template-columns: repeat(2, minmax(180px, 1fr)) auto;
  align-items: end;
  padding: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

input,
select {
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 11px;
  background: #fff;
  color: var(--text);
  min-width: 0;
}

input:focus,
select:focus {
  outline: 2px solid rgba(23, 105, 170, .18);
  border-color: var(--primary);
}

.primary-btn,
.ghost-btn {
  border: 1px solid transparent;
  border-radius: 6px;
  height: 38px;
  padding: 0 14px;
  font-weight: 700;
}

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

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

.primary-btn.compact,
.ghost-btn.compact {
  height: 34px;
}

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

.text-btn {
  border: 0;
  background: transparent;
  color: var(--primary);
  min-height: 30px;
  padding: 0;
  font-weight: 700;
  text-align: center;
}

.text-btn:hover {
  color: var(--primary-strong);
}

.form-error {
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
}

.form-note {
  color: var(--muted);
  padding: 0 16px 16px;
}

.user-list {
  display: grid;
  gap: 8px;
  padding: 0 16px 16px;
}

.user-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
}

.user-row span {
  color: var(--muted);
}

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

.sidebar {
  background: #0f2537;
  color: #dbeafe;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.workspace-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.workspace-title strong,
.workspace-title span {
  display: block;
}

.workspace-title span {
  color: #9fb3c8;
  font-size: 12px;
  margin-top: 3px;
}

.nav-list {
  display: grid;
  gap: 6px;
  margin-top: 18px;
}

.nav-item {
  border: 0;
  border-radius: 6px;
  min-height: 42px;
  background: transparent;
  color: #c6d7e8;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  text-align: left;
}

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

.nav-icon {
  width: 22px;
  text-align: center;
  font-size: 16px;
}

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

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

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

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.sync-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
}

.view {
  display: none;
}

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

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 12px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 88px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  font-size: 28px;
  margin-top: 8px;
}

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

.panel-head {
  min-height: 56px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
}

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

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

.toolbar input {
  width: 260px;
}

.module-grid,
.connector-grid,
.flow-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 12px;
  padding: 16px;
}

.module,
.connector,
.flow-step {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-2);
}

.module h3,
.connector h3,
.flow-step h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.module p,
.flow-step p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.module-head,
.connector-head,
.flow-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 8px;
}

.connector form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.connector-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.risk-list {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.risk {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: var(--surface-2);
}

.risk strong {
  color: var(--text);
}

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

table {
  width: 100%;
  min-width: 1320px;
  border-collapse: collapse;
  table-layout: fixed;
}

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

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

tbody tr:hover {
  background: #fbfdff;
}

.table-foot {
  padding: 12px 16px;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  margin: 0 4px 5px 0;
}

.badge.ok {
  color: var(--green);
  background: #ecfdf3;
  border-color: #abefc6;
}

.badge.warn {
  color: var(--amber);
  background: #fffaeb;
  border-color: #fedf89;
}

.badge.bad {
  color: var(--red);
  background: #fef3f2;
  border-color: #fecdca;
}

.badge.info {
  color: var(--blue);
  background: #eff8ff;
  border-color: #b2ddff;
}

.badge.hold {
  color: var(--gray);
  background: #f2f4f7;
  border-color: #d0d5dd;
}

.mini-list {
  display: grid;
  gap: 7px;
  margin-top: 4px;
}

.mini-row {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.mono {
  font-family: Consolas, "Courier New", monospace;
}

.ai-layout {
  display: grid;
  grid-template-columns: minmax(280px, 520px) 1fr;
  gap: 16px;
  padding: 16px;
}

.status-stack {
  display: grid;
  align-content: start;
  gap: 10px;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  background: var(--surface-2);
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  border: 0;
  border-radius: 999px;
  background: #cbd5e1;
  padding: 0;
}

.switch::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: #fff;
  transition: transform .18s ease;
}

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

.switch.on::after {
  transform: translateX(18px);
}

@media (max-width: 1180px) {
  .auth-layout {
    grid-template-columns: minmax(320px, 420px);
  }

  .auth-bg-orbit {
    width: min(620px, 92vw);
    height: min(620px, 92vw);
  }

  .metric-grid,
  .module-grid,
  .connector-grid,
  .flow-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}

@media (max-width: 820px) {
  .auth-shell {
    padding: 18px;
  }

  .auth-layout {
    grid-template-columns: 1fr;
  }

  .auth-panel {
    min-height: auto;
  }

  .auth-bg-orbit {
    width: 460px;
    height: 460px;
    opacity: .52;
  }

  .orbit-image {
    width: 64px;
    height: 64px;
    border-width: 4px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

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

  .nav-list {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

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

  .metric-grid,
  .module-grid,
  .connector-grid,
  .flow-grid,
  .ai-layout,
  .settings-form.inline,
  .risk {
    grid-template-columns: 1fr;
  }

  .toolbar input {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-bg-orbit,
  .orbit-image {
    animation: none;
  }

  .orbit-image {
    opacity: .72;
  }
}
