:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #dbe3ef;
  --accent: #b91c1c;
  --accent-soft: #fff1f2;
  --dark: #111827;
  --brand-gold: #f59e0b;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", "Noto Sans SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 480px at -10% -20%, rgba(56, 189, 248, 0.17), transparent 60%),
    radial-gradient(1000px 420px at 110% 120%, rgba(251, 113, 133, 0.16), transparent 58%),
    linear-gradient(160deg, #f8fafc 0%, #f1f5f9 42%, #fff7ed 100%);
  min-height: 100vh;
}

.login-body {
  display: grid;
  place-items: center;
}

.login-shell {
  position: relative;
  z-index: 1;
  width: min(560px, 92vw);
}

.login-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
}

.login-brand {
  margin-bottom: 2px;
}

.login-card h2 {
  margin: 6px 0 0;
}

.login-card label {
  font-size: 13px;
  color: #334155;
  display: grid;
  gap: 6px;
}

.bg-shape {
  position: fixed;
  border-radius: 999px;
  filter: blur(78px);
  z-index: 0;
  pointer-events: none;
}

.bg-1 {
  width: 320px;
  height: 320px;
  top: 40px;
  right: 70px;
  background: rgba(250, 204, 21, 0.2);
}

.bg-2 {
  width: 360px;
  height: 360px;
  bottom: 40px;
  left: 80px;
  background: rgba(239, 68, 68, 0.16);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1480px, 96vw);
  margin: 18px auto;
}

.topbar {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(140deg, #dc2626, #ef4444 55%, #fb7185);
  color: #fff;
  font-weight: 800;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 20px rgba(220, 38, 38, 0.32);
}

.brand h1 {
  margin: 0;
  font-size: 21px;
  letter-spacing: 0.2px;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

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

.auth-user-tag {
  font-size: 12px;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #f8fafc;
  padding: 5px 10px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-dark {
  color: #fff;
  background: var(--dark);
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.18);
}

.btn-dark:hover:not(:disabled) {
  background: #0b1220;
}

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

.btn-amber {
  border-color: rgba(245, 158, 11, 0.35);
  color: #92400e;
  background: linear-gradient(180deg, #fffbeb, #fef3c7);
}

.content-grid {
  display: grid;
  grid-template-columns: 480px 1fr;
  gap: 14px;
  margin-top: 14px;
}

.left-panel,
.right-panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.left-panel {
  max-height: calc(100vh - 130px);
  overflow: auto;
}

.session-box {
  font-size: 13px;
  color: #334155;
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  padding: 10px;
}

.stage-track {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
}

.workflow-box {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  background: #ffffffd9;
}

.workflow-title {
  font-size: 13px;
  color: #334155;
  font-weight: 600;
  margin-bottom: 8px;
}

.track-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  background: #fff;
}

.track-item.active {
  border-color: #fda4af;
  background: var(--accent-soft);
  color: #9f1239;
  font-weight: 700;
}

.stage-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 10px;
  background: linear-gradient(180deg, #ffffff, #fcfdff);
}

.stage-card[disabled] {
  opacity: 0.55;
}

.stage-card h3 {
  margin: 0 0 10px;
  font-size: 15px;
  color: #111827;
}

.customer-hidden {
  display: none !important;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.form-grid label {
  font-size: 12px;
  color: #334155;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

input,
textarea,
select {
  border: 1px solid #d7e0ec;
  border-radius: 8px;
  padding: 8px 9px;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
  background: #fff;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #f43f5e;
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.12);
}

textarea {
  min-height: 84px;
  resize: vertical;
}

.upload-box {
  margin-top: 10px;
  padding: 9px;
  border: 1px dashed #cfd8e5;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  background: #f8fbff;
}

.row-actions {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.radio-group {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.radio-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px;
  font-size: 12px;
  background: #fff;
}

.history-list {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.history-btn {
  text-align: left;
  border: 1px solid #d7e0ec;
  border-radius: 9px;
  background: #fff;
  padding: 8px 9px;
  font-size: 12px;
  color: #0f172a;
  cursor: pointer;
}

.history-btn:hover {
  border-color: #fda4af;
  background: #fff7f8;
}

.right-panel {
  position: relative;
  max-height: calc(100vh - 130px);
  overflow: auto;
  isolation: isolate;
}

.right-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.28)),
    url("/static/expert-team-bg.png") center center / cover no-repeat;
  opacity: 0.6;
  pointer-events: none;
  z-index: 0;
}

.right-panel > * {
  position: relative;
  z-index: 1;
}

.output-box {
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 14px;
  padding: 16px;
  backdrop-filter: blur(2px);
}

.output-box h2 {
  margin-top: 0;
  font-size: 23px;
  letter-spacing: 0.1px;
}

.output-box h3 {
  margin-top: 18px;
  margin-bottom: 8px;
}

.output-box {
  line-height: 1.78;
  white-space: pre-wrap;
  color: #0f172a;
}

.chat-thread {
  display: grid;
  gap: 10px;
}

.chat-item {
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  background: #fff;
}

.chat-item.user {
  border-color: #fecaca;
  background: #fff7f7;
}

.chat-item.assistant {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.chat-role {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
  color: #334155;
}

.thinking {
  background: linear-gradient(180deg, #fff7ed, #ffedd5);
  border: 1px solid #fdba74;
  color: #9a3412;
  border-radius: 12px;
  padding: 9px 11px;
  margin-bottom: 10px;
  font-size: 13px;
}

.thinking span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #ea580c;
  margin-right: 3px;
  animation: pulse 1.1s infinite ease-in-out;
}

.thinking span:nth-child(2) {
  animation-delay: 0.15s;
}

.thinking span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes pulse {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.3;
  }
  50% {
    transform: translateY(-2px);
    opacity: 1;
  }
}

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

.auth-modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.56);
  display: grid;
  place-items: center;
  z-index: 1000;
}

.auth-panel {
  width: min(420px, 92vw);
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.24);
  display: grid;
  gap: 8px;
}

.auth-panel h3 {
  margin: 0 0 2px;
}

.auth-panel label {
  font-size: 12px;
  color: #334155;
  display: grid;
  gap: 4px;
}

.auth-error {
  color: #b91c1c;
  font-size: 12px;
  min-height: 18px;
}

@media (max-width: 1180px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .left-panel,
  .right-panel {
    max-height: none;
  }
}

.admin-grid {
  grid-template-columns: 360px 1fr;
}

.admin-table-wrap {
  margin-top: 10px;
  border: 1px solid #dbe3ef;
  border-radius: 10px;
  overflow: auto;
  max-height: calc(100vh - 260px);
  background: #fff;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid #edf2f7;
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 1;
}

.admin-table .content-cell {
  min-width: 280px;
  max-width: 420px;
  white-space: normal;
  word-break: break-word;
}

.three-d-grid {
  display: grid;
  grid-template-columns: 520px 1fr;
  gap: 14px;
  margin-top: 14px;
}

.mode-group {
  display: grid;
  gap: 8px;
}

.mode-pill {
  border: 1px solid #dbe3ef;
  border-radius: 10px;
  background: #fff;
  color: #0f172a;
  font-size: 13px;
  padding: 9px 12px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
}

.mode-pill:hover {
  transform: translateY(-1px);
}

.mode-pill.active {
  border-color: #fb7185;
  background: #fff1f2;
  color: #9f1239;
  font-weight: 700;
}

.prompt-output pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.72;
}

#promptEditor {
  min-height: 220px;
}

.industry-extra {
  margin-top: 10px;
  border-top: 1px dashed #dbe3ef;
  padding-top: 10px;
}

.image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.image-card {
  border: 1px solid #dbe3ef;
  border-radius: 12px;
  padding: 8px;
  background: #fff;
}

.image-card img {
  width: 100%;
  border-radius: 8px;
  display: block;
}

.image-card a {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
}

@media (max-width: 1180px) {
  .three-d-grid {
    grid-template-columns: 1fr;
  }
}
