:root {
  --sx-bg: #f6f8fc;
  --sx-bg-glow-a: rgba(56, 189, 248, 0.14);
  --sx-bg-glow-b: rgba(45, 212, 191, 0.12);
  --sx-surface: rgba(255, 255, 255, 0.86);
  --sx-surface-solid: #ffffff;
  --sx-text: #0f172a;
  --sx-muted: #5b6476;
  --sx-line: #dbe2ee;
  --sx-line-strong: #c8d3e6;
  --sx-accent: #2563eb;
  --sx-accent-strong: #1d4ed8;
  --sx-accent-teal: #0f766e;
  --sx-danger: #b91c1c;
  --sx-ok: #0f766e;
  --sx-warn: #c26a09;
  --sx-radius-xl: 24px;
  --sx-radius-lg: 18px;
  --sx-radius-md: 14px;
  --sx-shadow-lg: 0 20px 52px rgba(15, 23, 42, 0.1);
  --sx-shadow-md: 0 12px 30px rgba(15, 23, 42, 0.07);
  --sx-ease: 220ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

body.saas-ui {
  color: var(--sx-text);
  font-family: "IBM Plex Sans", "Source Han Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(1000px 520px at -8% -12%, var(--sx-bg-glow-a), transparent 72%),
    radial-gradient(880px 440px at 112% -5%, var(--sx-bg-glow-b), transparent 72%),
    var(--sx-bg);
}

body.saas-ui .page {
  width: min(1380px, 94vw);
  margin: 28px auto 36px;
}

body.saas-ui #site-topbar-root {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

/* Tailwind-style utility classes (local, CSP-friendly) */
.tw-flex { display: flex; }
.tw-grid { display: grid; }
.tw-items-center { align-items: center; }
.tw-items-start { align-items: flex-start; }
.tw-justify-between { justify-content: space-between; }
.tw-justify-center { justify-content: center; }
.tw-gap-1 { gap: 0.25rem; }
.tw-gap-2 { gap: 0.5rem; }
.tw-gap-3 { gap: 0.75rem; }
.tw-gap-4 { gap: 1rem; }
.tw-w-full { width: 100%; }
.tw-min-w-0 { min-width: 0; }
.tw-wrap { flex-wrap: wrap; }
.tw-inline-flex { display: inline-flex; }
.tw-text-sm { font-size: 0.875rem; }
.tw-text-xs { font-size: 0.75rem; }
.tw-font-medium { font-weight: 500; }
.tw-font-semibold { font-weight: 600; }
.tw-font-bold { font-weight: 700; }
.tw-transition { transition: all var(--sx-ease); }
.tw-leading-tight { line-height: 1.25; }
.tw-leading-relaxed { line-height: 1.62; }
.tw-uppercase { text-transform: uppercase; }
.tw-tracking { letter-spacing: 0.04em; }

.shell-intro {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(147, 197, 253, 0.46);
  border-radius: var(--sx-radius-xl);
  padding: clamp(22px, 3vw, 34px) clamp(18px, 2.4vw, 28px);
  color: #eaf1ff;
  background:
    linear-gradient(132deg, #0f1f45 0%, #1e3a8a 45%, #0f766e 100%);
  box-shadow: var(--sx-shadow-lg);
  text-align: center;
  animation: saas-fade-up 460ms ease-out both;
}

.shell-intro::before,
.shell-intro::after {
  content: "";
  position: absolute;
  pointer-events: none;
  border-radius: 999px;
}

.shell-intro::before {
  width: 300px;
  height: 300px;
  right: -110px;
  top: -150px;
  background: radial-gradient(circle, rgba(125, 211, 252, 0.32) 0%, rgba(125, 211, 252, 0) 70%);
}

.shell-intro::after {
  width: 240px;
  height: 240px;
  left: -100px;
  bottom: -130px;
  background: radial-gradient(circle, rgba(45, 212, 191, 0.3) 0%, rgba(45, 212, 191, 0) 70%);
}

.shell-intro h1 {
  margin: 0;
  font-size: clamp(1.4rem, 2.7vw, 2.24rem);
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.shell-intro p {
  margin: 12px auto 0;
  max-width: 980px;
  color: rgba(224, 231, 255, 0.92);
  font-size: 0.96rem;
  line-height: 1.7;
}

.shell-topbar {
  display: grid;
  grid-template-columns: max-content 1fr max-content;
  align-items: center;
  gap: 12px 14px;
  padding: 12px 14px;
  border-radius: var(--sx-radius-lg);
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: var(--sx-surface);
  backdrop-filter: blur(8px);
  box-shadow: var(--sx-shadow-md);
  animation: saas-fade-up 520ms ease-out both;
}

.shell-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--sx-text);
}

.shell-brand-badge {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.84rem;
  color: #fff;
  background: linear-gradient(135deg, var(--sx-accent), var(--sx-accent-teal));
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.28);
}

.shell-brand-name {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.shell-brand-sub {
  font-size: 0.72rem;
  color: var(--sx-muted);
  margin-top: 2px;
}

.shell-menu {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.shell-menu-link {
  text-decoration: none;
  color: #334155;
  background: rgba(248, 250, 252, 0.84);
  border: 1px solid var(--sx-line);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.82rem;
  line-height: 1.2;
  transition: all var(--sx-ease);
}

.shell-menu-link:hover {
  transform: translateY(-1px);
  border-color: #bfdbfe;
  color: #1d4ed8;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.12);
}

.shell-menu-link.is-active {
  border-color: transparent;
  color: #eef2ff;
  background: linear-gradient(135deg, #1e3a8a, #2563eb 55%, #0f766e);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.24);
}

.shell-menu-link.is-placeholder {
  opacity: 0.62;
  cursor: default;
  border-style: dashed;
}

.shell-menu-link.shell-menu-admin-only {
  display: none;
}

.shell-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.shell-user-chip {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.34);
  color: #334155;
  background: rgba(248, 250, 252, 0.92);
  font-size: 0.77rem;
  line-height: 1.2;
  padding: 7px 11px;
}

.shell-tool-btn {
  border: 0;
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 0.84rem;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--sx-ease);
}

.shell-tool-btn:hover {
  transform: translateY(-1px);
}

.shell-tool-btn-primary {
  color: #eef2ff;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  box-shadow: 0 9px 20px rgba(37, 99, 235, 0.22);
}

.shell-tool-btn-secondary {
  color: #0f172a;
  background: #eef2f7;
}

body.saas-ui .hero {
  border-radius: var(--sx-radius-xl);
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: var(--sx-shadow-lg);
  animation: saas-fade-up 420ms ease-out both;
}

body.saas-ui .hero p {
  font-size: 0.94rem;
}

body.saas-ui .panel,
body.saas-ui .dash-panel,
body.saas-ui .card,
body.saas-ui .pool-card,
body.saas-ui .picked-card,
body.saas-ui .chat-panel,
body.saas-ui .modal-card,
body.saas-ui .drawer-panel,
body.saas-ui .table-shell,
body.saas-ui .metric,
body.saas-ui .mini-metric,
body.saas-ui .overview-item,
body.saas-ui .option-item,
body.saas-ui .school-option-item,
body.saas-ui .picked-mini-item,
body.saas-ui .history-item,
body.saas-ui .progress-card,
body.saas-ui .quick-item,
body.saas-ui .alert-item,
body.saas-ui .result-card,
body.saas-ui .status-chip,
body.saas-ui .role-chip,
body.saas-ui .table-wrap {
  border-color: rgba(148, 163, 184, 0.26);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
  transition: transform var(--sx-ease), box-shadow var(--sx-ease), border-color var(--sx-ease);
}

body.saas-ui .panel:hover,
body.saas-ui .dash-panel:hover,
body.saas-ui .card:hover,
body.saas-ui .pool-card:hover,
body.saas-ui .picked-card:hover,
body.saas-ui .chat-panel:hover {
  border-color: rgba(96, 165, 250, 0.44);
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.12);
}

body.saas-ui .btn,
body.saas-ui .go,
body.saas-ui .progress-action,
body.saas-ui .hero-link,
body.saas-ui .btn-inline,
body.saas-ui .method-btn,
body.saas-ui .tab-btn {
  transition: transform var(--sx-ease), box-shadow var(--sx-ease), opacity var(--sx-ease), border-color var(--sx-ease), background-color var(--sx-ease), color var(--sx-ease);
}

body.saas-ui .btn:hover,
body.saas-ui .go:hover,
body.saas-ui .progress-action:hover,
body.saas-ui .hero-link:hover,
body.saas-ui .btn-inline:hover,
body.saas-ui .method-btn:hover,
body.saas-ui .tab-btn:hover {
  transform: translateY(-1px);
}

body.saas-ui .btn:active,
body.saas-ui .go:active,
body.saas-ui .progress-action:active,
body.saas-ui .hero-link:active,
body.saas-ui .btn-inline:active {
  transform: translateY(0);
}

body.saas-ui .btn,
body.saas-ui .go,
body.saas-ui .progress-action,
body.saas-ui .hero-link,
body.saas-ui .tab-btn,
body.saas-ui .method-btn {
  border-radius: 12px;
}

body.saas-ui .btn-primary,
body.saas-ui .go,
body.saas-ui .progress-action,
body.saas-ui .shell-tool-btn-primary,
body.saas-ui .hero-link,
body.saas-ui .tab-btn.active {
  color: #eff6ff;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 56%, #0f766e 100%);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
}

body.saas-ui .btn-secondary,
body.saas-ui .btn-ghost,
body.saas-ui .method-btn,
body.saas-ui .tab-btn {
  background: #f3f6fb;
  border: 1px solid var(--sx-line);
  color: #334155;
}

body.saas-ui .field input,
body.saas-ui .field select,
body.saas-ui .field textarea,
body.saas-ui .selector-input,
body.saas-ui .pool-search-input,
body.saas-ui input[type="text"],
body.saas-ui input[type="number"],
body.saas-ui input[type="password"],
body.saas-ui input[type="tel"],
body.saas-ui textarea,
body.saas-ui select {
  border-color: rgba(148, 163, 184, 0.38);
  background: rgba(248, 250, 252, 0.85);
  color: #0f172a;
  transition: border-color var(--sx-ease), box-shadow var(--sx-ease), background-color var(--sx-ease);
}

body.saas-ui .field input:focus,
body.saas-ui .field select:focus,
body.saas-ui .field textarea:focus,
body.saas-ui .selector-input:focus,
body.saas-ui .pool-search-input:focus,
body.saas-ui input[type="text"]:focus,
body.saas-ui input[type="number"]:focus,
body.saas-ui input[type="password"]:focus,
body.saas-ui input[type="tel"]:focus,
body.saas-ui textarea:focus,
body.saas-ui select:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.78);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.13);
  background: #ffffff;
}

body.saas-ui .status,
body.saas-ui .meta,
body.saas-ui .k,
body.saas-ui .note,
body.saas-ui .empty {
  color: var(--sx-muted);
}

body.saas-ui .status.error {
  color: var(--sx-danger);
}

body.saas-ui .status.ok {
  color: var(--sx-ok);
}

body.saas-ui table {
  border-collapse: collapse;
}

body.saas-ui th,
body.saas-ui td {
  border-color: rgba(148, 163, 184, 0.3);
}

body.saas-ui tr {
  transition: background-color var(--sx-ease);
}

body.saas-ui tr:hover {
  background-color: rgba(59, 130, 246, 0.06);
}

body.saas-ui .tier-chip,
body.saas-ui .chip,
body.saas-ui .tag,
body.saas-ui .status-badge {
  border-color: rgba(148, 163, 184, 0.32);
  background: rgba(248, 250, 252, 0.88);
}

body.saas-ui .main,
body.saas-ui .layout,
body.saas-ui .dashboard-grid,
body.saas-ui .main-grid {
  gap: 14px;
}

body.saas-ui .home-shell-status .status {
  font-size: 0.88rem;
}

body.saas-ui .chat-log {
  scroll-behavior: smooth;
}

body.saas-ui .msg {
  border-color: rgba(148, 163, 184, 0.28);
}

body.saas-ui .msg.assistant {
  background: rgba(241, 245, 255, 0.92);
}

body.saas-ui .msg.user {
  background: rgba(239, 246, 255, 0.96);
}

body.saas-ui .card h3,
body.saas-ui .panel-title,
body.saas-ui .title,
body.saas-ui .hero h1 {
  letter-spacing: 0.01em;
}

body.saas-ui .card p,
body.saas-ui .hero p,
body.saas-ui .progress-desc,
body.saas-ui .note {
  line-height: 1.7;
}

body.saas-ui.saas-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

body.saas-ui.saas-login .card {
  border-radius: 24px;
  box-shadow: 0 28px 56px rgba(15, 23, 42, 0.14);
  border: 1px solid rgba(148, 163, 184, 0.3);
}

body.saas-ui.saas-login .head {
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
}

@keyframes saas-fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1240px) {
  .shell-topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .shell-menu {
    justify-content: flex-start;
  }

  .shell-tools {
    justify-content: flex-start;
  }
}

@media (max-width: 980px) {
  body.saas-ui .page {
    margin-top: 20px;
  }

  .shell-intro {
    padding: 20px 16px;
  }

  .shell-intro p {
    font-size: 0.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
