/* P3-SSO: login providers block */
.sso-buttons { margin-top: 14px; }
.sso-divider { display: flex; align-items: center; gap: 10px; color: rgba(120,120,140,0.7); font-size: 12px; margin: 14px 0 10px; }
.sso-divider::before, .sso-divider::after { content: ""; flex: 1; height: 1px; background: rgba(255,255,255,0.08); }
.sso-btn { width: 100%; padding: 10px 14px; border-radius: 10px; border: 1px solid rgba(0,0,0,0.12); background: rgba(0,0,0,0.02); color: inherit; cursor: pointer; font-size: 14px; transition: background 0.15s; }
.sso-btn:hover { background: rgba(0,0,0,0.05); }
.sso-feishu { border-color: #00b9b1; }
.sso-feishu:hover { background: rgba(0, 185, 177, 0.12); }

:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --danger: #dc2626;
  --shadow: 0 10px 30px rgba(17, 24, 39, 0.08);
  --radius: 14px;
  --font-ui: "Inter", "PingFang SC", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-reading: "Source Han Sans SC", "PingFang SC", "Noto Sans CJK SC", var(--font-ui);
  font-family: var(--font-ui);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #0b1120;
  color: var(--text);
  font-family: var(--font-reading);
  letter-spacing: 0.01em;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

.bg-stars {
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  position: fixed;
  z-index: 0;
}

.star-layer {
  inset: -40%;
  position: absolute;
}

.layer-a {
  animation: stars-drift-a 170s linear infinite;
  background-image:
    radial-gradient(1.2px 1.2px at 14% 22%, rgba(255, 255, 255, 0.85) 40%, transparent 100%),
    radial-gradient(1px 1px at 33% 68%, rgba(191, 219, 254, 0.75) 40%, transparent 100%),
    radial-gradient(1.4px 1.4px at 72% 31%, rgba(255, 255, 255, 0.9) 40%, transparent 100%),
    radial-gradient(1px 1px at 84% 78%, rgba(226, 232, 240, 0.7) 40%, transparent 100%),
    radial-gradient(1.1px 1.1px at 57% 52%, rgba(186, 230, 253, 0.7) 40%, transparent 100%),
    radial-gradient(1px 1px at 9% 88%, rgba(255, 255, 255, 0.8) 40%, transparent 100%);
  background-repeat: repeat;
  background-size: 540px 540px;
  opacity: 0.55;
}

.layer-b {
  animation: stars-drift-b 220s linear infinite;
  background-image:
    radial-gradient(1.6px 1.6px at 21% 43%, rgba(255, 255, 255, 0.6) 45%, transparent 100%),
    radial-gradient(1.3px 1.3px at 48% 17%, rgba(196, 181, 253, 0.48) 45%, transparent 100%),
    radial-gradient(1.8px 1.8px at 67% 63%, rgba(191, 219, 254, 0.5) 45%, transparent 100%),
    radial-gradient(1.5px 1.5px at 89% 24%, rgba(255, 255, 255, 0.45) 45%, transparent 100%);
  background-repeat: repeat;
  background-size: 760px 760px;
  opacity: 0.32;
}

.layer-c {
  animation: stars-drift-c 280s linear infinite;
  background-image:
    radial-gradient(120px 70px at 24% 28%, rgba(37, 99, 235, 0.14), transparent 78%),
    radial-gradient(180px 110px at 74% 58%, rgba(147, 197, 253, 0.09), transparent 82%),
    radial-gradient(140px 90px at 49% 82%, rgba(56, 189, 248, 0.08), transparent 80%);
  background-repeat: repeat;
  background-size: 900px 900px;
  opacity: 0.95;
}

@keyframes stars-drift-a {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(-240px, -180px, 0);
  }
}

@keyframes stars-drift-b {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(190px, -230px, 0);
  }
}

@keyframes stars-drift-c {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(-120px, 140px, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .layer-a,
  .layer-b,
  .layer-c {
    animation: none;
  }
}

#loginView,
#appView {
  position: relative;
  z-index: 1;
}

.hidden {
  display: none !important;
}

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

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

.eyebrow {
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 10px;
}

button {
  background: var(--primary);
  border: 0;
  border-radius: 10px;
  color: white;
  cursor: pointer;
  font-weight: 600;
  padding: 10px 14px;
}

button.secondary {
  background: var(--primary-soft);
  color: var(--primary);
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

input,
select,
textarea {
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  padding: 10px 12px;
  width: 100%;
}

label {
  color: #374151;
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-top: 12px;
}

.auth-view {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  box-shadow: var(--shadow);
  max-width: 420px;
  padding: 28px;
  width: 100%;
}

.auth-card h1 {
  margin: 8px 0 6px;
}

.auth-form button {
  margin-top: 16px;
  width: 100%;
}

.auth-hint {
  font-size: 12px;
  margin-top: 14px;
}

.app-view {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  width: 100%;
}

.app-header {
  align-items: center;
  background: rgba(248, 250, 252, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.85);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 14px 20px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand strong {
  display: block;
  font-size: 18px;
}

.header-actions {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  gap: 8px;
}

.header-chip {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-sizing: border-box;
  color: var(--text);
  display: inline-flex;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  gap: 8px;
  justify-content: center;
  line-height: 1;
  min-height: 36px;
  padding: 0 14px;
  white-space: nowrap;
}

button.header-chip {
  cursor: pointer;
  font: inherit;
}

button.header-chip:hover {
  background: #f8fbff;
  border-color: #bfdbfe;
}

.header-chip-accent {
  background: var(--primary);
  border-color: transparent;
  color: #fff;
}

button.header-chip-accent:hover {
  background: #1d4ed8;
  border-color: transparent;
  color: #fff;
}

.header-chip-quota {
  background: var(--primary-soft);
  border-color: #bfdbfe;
  color: var(--primary);
  cursor: default;
  padding: 0 12px;
}

.quota-pill {
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  white-space: nowrap;
}

.user-menu {
  position: relative;
}

.user-menu-trigger {
  padding: 0 10px 0 4px;
}

.user-menu-trigger:hover {
  background: #f8fbff;
  border-color: #bfdbfe;
}

.avatar {
  align-items: center;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-radius: 50%;
  color: white;
  display: inline-flex;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  height: 28px;
  justify-content: center;
  width: 28px;
}

.user-menu-text {
  display: grid;
  gap: 1px;
  line-height: 1.15;
  text-align: left;
}

.user-menu-text small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.chevron {
  color: var(--muted);
  flex-shrink: 0;
  font-size: 11px;
  margin-left: 2px;
}

.dropdown {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  min-width: 180px;
  padding: 6px;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 30;
}

.dropdown-item {
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  display: block;
  font-weight: 500;
  padding: 10px 12px;
  text-align: left;
  width: 100%;
}

.dropdown-item:hover {
  background: #f3f4f6;
}

.dropdown-item.danger {
  color: var(--danger);
}

.dropdown-divider {
  border-top: 1px solid var(--border);
  margin: 6px 0;
}

.app-body {
  align-items: stretch;
  box-sizing: border-box;
  display: grid;
  flex: 1 1 auto;
  gap: 12px;
  grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
  margin: 0;
  max-width: none;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  padding: 12px 14px 14px;
  width: 100%;
}

.app-body > .sidebar,
.app-body > .main.panel {
  min-width: 0;
}

.app-body.sidebar-collapsed {
  grid-template-columns: minmax(0, 1fr);
}

.app-body.sidebar-collapsed .sidebar {
  display: none;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
  max-height: 100%;
  max-width: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  padding: 14px;
}

.sidebar-block {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: hidden;
}

.sidebar-block .row {
  flex-shrink: 0;
}

.sidebar-block h2 {
  font-size: 15px;
  margin: 0 0 8px;
}

.row {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.usage-box {
  display: grid;
  gap: 8px;
}

.conversation-list {
  align-content: flex-start;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-color: rgba(148, 163, 184, 0.65) rgba(15, 23, 42, 0.25);
  scrollbar-width: thin;
}

.conversation-list::-webkit-scrollbar {
  width: 7px;
}

.conversation-list::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.18);
  border-radius: 999px;
}

.conversation-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.62);
  border-radius: 999px;
}

.conversation {
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  flex: 0 0 auto;
  padding: 8px 9px;
  transition: background 120ms ease, border-color 120ms ease;
}

.conversation:hover {
  background: rgba(239, 246, 255, 0.72);
  border-color: #bfdbfe;
}

.main {
  display: flex;
  flex: 1;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  padding: 10px 12px;
}

.main-nav {
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  margin: -4px 0 14px;
  padding-bottom: 12px;
}

.main-nav-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  padding: 8px 16px;
}

.main-nav-btn.active {
  background: var(--primary-soft);
  border-color: #93c5fd;
  color: var(--primary);
}

.main-view {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.admin-main {
  overflow: auto;
}

.admin-page-header h2 {
  font-size: 22px;
  margin: 0 0 6px;
}

.admin-layout {
  align-items: start;
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(280px, 340px) 1fr;
  margin-top: 12px;
}

.admin-form-card,
.admin-list-card {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.admin-form-card h3,
.admin-list-card h3 {
  font-size: 15px;
  margin: 0 0 12px;
}

.admin-user-list {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  max-height: none;
}

.chat-toolbar {
  align-items: end;
  display: grid;
  flex-shrink: 0;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 auto;
  max-width: min(760px, 100%);
  padding: 0 12px;
  width: 100%;
}

.chat-toolbar > label {
  margin: 0;
  min-width: 0;
}

@media (max-width: 1280px) {
  .app-body:not(.sidebar-collapsed) .chat-toolbar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .chat-toolbar {
    grid-template-columns: 1fr;
  }
}

.quick-downloads {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  color: #1e40af;
  font-size: 13px;
  margin: 0 auto;
  max-width: min(760px, 100%);
  padding: 10px 12px;
  width: 100%;
}

.quick-download-link {
  color: #1d4ed8;
  font-weight: 600;
  text-decoration: none;
}

.quick-download-link:hover {
  text-decoration: underline;
}

.auto-badge {
  align-items: center;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 10px;
  box-sizing: border-box;
  color: #047857;
  display: flex;
  font-size: 12px;
  font-weight: 700;
  justify-content: center;
  margin-top: 4px;
  min-height: 42px;
  padding: 0 12px;
  width: 100%;
}

.model-label {
  font-size: 12px;
  margin: 0;
}

.model-label select {
  margin-top: 4px;
  max-width: 100%;
  min-height: 42px;
  min-width: 0;
  width: 100%;
}

.toggle-label {
  align-items: center;
  color: #475569;
  display: inline-flex;
  font-size: 12px;
  font-weight: 600;
  gap: 6px;
  margin: 0;
  white-space: nowrap;
}

.toggle-label input {
  margin: 0;
  width: auto;
}

.toggle-label select {
  min-width: 126px;
  padding: 6px 10px;
  width: auto;
}

.messages {
  background: transparent;
  border: none;
  box-shadow: none;
  display: flex;
  flex: 1 1 0%;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px 0 12px;
}

.message-row {
  width: 100%;
}

.message-inner {
  margin: 0 auto;
  max-width: min(760px, 100%);
  padding: 0 12px;
  width: 100%;
}

.message-row.user .message-inner {
  display: flex;
  justify-content: flex-end;
}

.message-row.user .message-bubble {
  background: #edf3fe;
  border-radius: 16px;
  color: #111827;
  max-width: 100%;
  padding: 10px 14px;
}

.message-row.user .message-body {
  font-size: 14px;
  line-height: 1.55;
}

.message-row.assistant .message-body {
  background: transparent;
  border: none;
  color: #111827;
  font-size: 14px;
  line-height: 1.62;
  padding: 0;
}

.message-row .message-role {
  display: none;
}

.message-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.58;
}

.message-thinking {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 10px;
  margin-bottom: 8px;
  padding: 8px 10px;
}

.message-thinking-summary {
  background: #f8fafc;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  margin-bottom: 8px;
  padding: 8px 10px;
}

.message-thinking-summary h4 {
  color: #1d4ed8;
  font-size: 11px;
  letter-spacing: 0.04em;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.message-thinking-summary p {
  color: #334155;
  font-size: 12px;
  line-height: 1.45;
  margin: 2px 0;
}

.message-thinking summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: #0369a1;
}

.thinking-list {
  margin: 10px 0 0;
  padding-left: 1.25rem;
  font-size: 13px;
  line-height: 1.5;
  color: #334155;
}

.message-body .answer-h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 10px 0 6px;
  white-space: normal;
}

.message-body .answer-list {
  margin: 0 0 8px;
  padding-left: 1.1rem;
  white-space: normal;
}

.waterfall-body {
  position: relative;
}

.waterfall-body::after {
  animation: blink-caret 1s step-end infinite;
  color: #2563eb;
  content: "▋";
  margin-left: 2px;
}

.stream-phase {
  font-size: 12px;
  margin-bottom: 8px;
}

.stream-progress-sticky {
  align-items: center;
  backdrop-filter: blur(3px);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #dbeafe;
  border-radius: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  padding: 6px 8px;
  position: sticky;
  top: -4px;
  z-index: 5;
}

.stream-progress-bar-wrap {
  background: #e2e8f0;
  border-radius: 999px;
  height: 6px;
  margin-left: auto;
  min-width: 160px;
  overflow: hidden;
  width: 24%;
}

.stream-progress-bar {
  background: linear-gradient(90deg, #2563eb, #16a34a);
  height: 100%;
  transition: width 160ms ease;
}

.stream-phase-badge {
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  text-transform: uppercase;
}

.stream-phase-badge.running {
  background: #dbeafe;
  color: #1d4ed8;
}

.stream-phase-badge.completed {
  background: #dcfce7;
  color: #15803d;
}

.stream-phase-badge.failed {
  background: #fee2e2;
  color: #b91c1c;
}

.stream-phase-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.stream-phase-item {
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  color: #475569;
  font-size: 11px;
  padding: 2px 8px;
}

.stream-phase-item.running {
  border-color: #93c5fd;
  color: #1d4ed8;
}

.stream-phase-item.completed {
  border-color: #86efac;
  color: #15803d;
}

.stream-live-body {
  color: #475569;
  font-size: 12.5px;
  line-height: 1.5;
  max-height: 260px;
  overflow: auto;
}

@keyframes blink-caret {
  0%,
  100% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
}

.workflow-timeline {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  margin-bottom: 8px;
  padding: 0;
}

.workflow-timeline[open] {
  padding: 8px 10px 6px;
}

.workflow-title {
  color: #475569;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  list-style: none;
  margin-bottom: 0;
  text-transform: none;
}

.workflow-title::-webkit-details-marker {
  display: none;
}

.workflow-steps {
  margin-top: 6px;
}

.workflow-step {
  display: grid;
  gap: 8px;
  grid-template-columns: 12px 1fr;
  padding: 4px 0;
  position: relative;
}

.workflow-step:not(:last-child)::after {
  background: #cbd5e1;
  content: "";
  height: calc(100% - 10px);
  left: 5px;
  position: absolute;
  top: 18px;
  width: 2px;
}

.workflow-dot {
  background: #94a3b8;
  border-radius: 50%;
  height: 10px;
  margin-top: 3px;
  width: 10px;
  z-index: 1;
}

.workflow-step.completed .workflow-dot {
  background: #16a34a;
}

.workflow-step.running .workflow-dot {
  background: #2563eb;
}

.workflow-step.failed .workflow-dot {
  background: #dc2626;
}

.workflow-step strong {
  font-size: 12px;
  line-height: 1.35;
}

.workflow-step p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  margin: 2px 0;
}

.workflow-step small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.artifact-preview {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 8px 0 12px;
  overflow: hidden;
}

.artifact-preview img {
  display: block;
  max-height: 360px;
  object-fit: contain;
  width: 100%;
}

.artifact-preview iframe {
  border: 0;
  height: 420px;
  width: 100%;
}

.composer {
  flex-shrink: 0;
  margin: 0;
  margin-top: 0;
  max-width: none;
  width: 100%;
}

.composer.drag-over {
  background: #f8fbff;
  border: 1px dashed var(--primary);
  border-radius: 12px;
  padding: 8px;
}

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

.composer-tools .secondary {
  font-size: 12px;
  padding: 8px 12px;
}

.composer-hint {
  font-size: 12px;
  line-height: 1.4;
}

.composer-row {
  align-items: stretch;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
}

#prompt {
  min-height: 72px;
  resize: none;
}

.progress {
  background: #e5e7eb;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.progress-bar {
  background: linear-gradient(90deg, #2563eb, #10b981);
  height: 100%;
}

.progress.warn .progress-bar {
  background: linear-gradient(90deg, #f59e0b, #ef4444);
}

.usage-item {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  padding: 10px;
}

.usage-detail {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  display: grid;
  gap: 6px;
  margin-top: 8px;
  padding: 10px;
}

.usage-detail strong {
  color: #111827;
  font-size: 12px;
}

.usage-detail span {
  color: #6b7280;
  font-size: 12px;
}

.line-items {
  border-top: 1px dashed #d1d5db;
  display: grid;
  gap: 3px;
  margin-top: 4px;
  padding-top: 6px;
}

.line-items span {
  color: #64748b;
  font-size: 11px;
}

.admin-user-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13px;
  padding: 14px;
}

.usage-metric {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.modal-backdrop {
  align-items: center;
  background: rgba(17, 24, 39, 0.45);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: fixed;
  z-index: 50;
}

.modal {
  box-shadow: var(--shadow);
  max-width: 440px;
  padding: 0;
  width: 100%;
}

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

.modal-header h3 {
  margin: 0;
}

.modal-body {
  padding: 16px 18px 20px;
}

.icon-btn {
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  padding: 0 6px;
}

.stack-form button {
  margin-top: 14px;
  width: 100%;
}

.profile-dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

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

.profile-dl dd {
  font-weight: 600;
  margin: 0;
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.attachment-chip {
  align-items: center;
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  color: var(--primary);
  display: inline-flex;
  font-size: 12px;
  gap: 6px;
  padding: 6px 10px;
}

.chip-remove {
  background: transparent;
  border: 0;
  color: var(--primary);
  padding: 0;
}

.message-attachments {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}

.file-card {
  align-items: center;
  background: #f8fafc;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  padding: 6px 8px;
}

.file-card-main {
  min-width: 0;
}

.file-card-title {
  color: #0f172a;
  display: block;
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-card-meta {
  color: #64748b;
  font-size: 12px;
}

.file-card-actions {
  display: inline-flex;
  gap: 6px;
}

.file-card-actions button,
.file-card-actions a {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  text-decoration: none;
}

.file-card-actions button:hover,
.file-card-actions a:hover {
  background: #dbeafe;
}

.checkbox-label {
  align-items: center;
  display: flex;
  gap: 8px;
}

.checkbox-label input {
  margin: 0;
  width: auto;
}

.analytics-grid {
  display: grid;
  gap: 18px;
}

.analytics-card {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.analytics-card h3 {
  font-size: 16px;
  margin: 0 0 12px;
}

.month-filter {
  font-size: 13px;
  margin: 0;
}

.month-filter input {
  margin-top: 4px;
  width: auto;
}

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

.data-table {
  border-collapse: collapse;
  font-size: 13px;
  width: 100%;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

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

.activity-toolbar {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.activity-toolbar label {
  margin: 0;
  min-width: 200px;
}

.activity-list {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
}

.activity-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.activity-item summary {
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
}

.activity-body {
  font-size: 13px;
  margin-top: 10px;
}

.activity-body p {
  margin: 8px 0 0;
}

.evaluate-result {
  font-size: 13px;
}

.evaluate-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.evaluate-score {
  font-size: 18px;
}

.evaluate-dims {
  margin: 10px 0;
  padding-left: 18px;
}

.toast-stack {
  bottom: 20px;
  display: grid;
  gap: 8px;
  pointer-events: none;
  position: fixed;
  right: 20px;
  width: min(360px, calc(100vw - 24px));
  z-index: 100;
}

.toast {
  background: #111827;
  border-radius: 10px;
  box-shadow: var(--shadow);
  color: #fff;
  font-size: 13px;
  opacity: 0.96;
  padding: 10px 12px;
}

.toast.error {
  background: #b91c1c;
}

/* ---- Minimal SaaS Chat Layout (DeepSeek-like) ---- */
body.theme-business .layer-a {
  opacity: 0.42;
}

body.theme-business .layer-b {
  opacity: 0.26;
}

body.theme-business .layer-c {
  opacity: 0.52;
}

.app-body {
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 16px;
  max-width: none;
  padding: 12px 14px 14px;
}

.main.panel {
  background: rgba(255, 255, 255, 0.26);
  backdrop-filter: blur(10px);
  border: 0;
  box-shadow: none;
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.sidebar.panel {
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  box-shadow: none;
  padding: 10px;
}

.sidebar-block h2 {
  color: #6b7280;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.conversation {
  background: rgba(248, 250, 252, 0.74);
  border: 1px solid rgba(226, 232, 240, 0.78);
  border-radius: 10px;
  flex: 0 0 auto;
  line-height: 1.12;
  padding: 8px 9px;
}

.conversation strong {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.12;
}

.conversation-title {
  display: block;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation small {
  color: #94a3b8;
  font-size: 10.5px;
  line-height: 1.05;
}

.conversation-meta {
  display: block;
}

.conversation.active {
  background: inherit;
  border-color: inherit;
}

.conversation:hover {
  background: rgba(248, 250, 252, 0.92);
  border-color: rgba(226, 232, 240, 0.95);
}

#chatView {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

#chatView > .chat-toolbar,
#chatView > .quick-downloads,
#chatView > .attachment-list,
#chatView > .upload-progress,
#chatView > .composer,
#chatView > #chatError {
  flex-shrink: 0;
}

#chatView.is-empty {
  gap: 14px;
  justify-content: flex-start;
  overflow-y: auto;
  padding-top: 2px;
}

.chat-empty-state {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 6px;
  justify-content: flex-start;
  margin: 0;
  max-width: none;
  padding: 4px 0 0;
  text-align: center;
  width: 100%;
}

.chat-empty-state h2 {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
}

.chat-empty-state .muted {
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}

.empty-mode-pills {
  display: inline-flex;
  gap: 8px;
}

.pill {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  color: #475569;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
}

.pill.active {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #3730a3;
}

.pill:hover {
  background: #eef2ff;
}

#chatView.is-empty .chat-toolbar,
#chatView.is-empty .composer {
  flex: 0 0 auto;
  flex-shrink: 0;
  margin: 0 auto;
  max-width: min(760px, 100%);
  width: 100%;
}

#chatView.is-empty .composer {
  margin-top: 0;
}

#chatView.is-empty .messages {
  display: none;
}

.messages {
  background: transparent;
  backdrop-filter: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  flex: 1 1 0%;
  gap: 18px;
  margin: 0;
  max-width: none;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px 0 12px;
  width: 100%;
}

.composer {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.05);
  flex-shrink: 0;
  margin: 0 auto;
  max-width: min(760px, 100%);
  padding: 10px;
  width: 100%;
}

#sendBtn {
  align-self: end;
  border-radius: 999px;
  height: 38px;
  margin-bottom: 2px;
  padding: 0;
  width: 38px;
}

#sendBtn::before {
  content: "↑";
  font-size: 16px;
  font-weight: 700;
}

#sendBtn {
  font-size: 0;
}

@media (max-width: 900px) {
  .app-body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: none;
  }

  .main {
    max-height: none;
  }

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

  .admin-user-list {
    grid-template-columns: 1fr;
  }
}

/* ---- UI stabilization: readable content + sidebar-only starfield ---- */
body.theme-business .app-body {
  background: rgba(248, 250, 252, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.8);
}

body.theme-business .main.panel {
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid rgba(226, 232, 240, 0.72);
  border-radius: 14px;
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

body.theme-business .main.panel::before,
body.theme-business .main.panel::after {
  content: "";
  inset: -20%;
  pointer-events: none;
  position: absolute;
  z-index: 0;
}

body.theme-business .main.panel::before {
  animation: content-stars-drift 84s linear infinite, sidebar-stars-twinkle 5.6s ease-in-out infinite;
  background-image:
    radial-gradient(1.6px 1.6px at 12% 18%, rgba(56, 189, 248, 0.72) 45%, transparent 100%),
    radial-gradient(1.4px 1.4px at 26% 62%, rgba(99, 102, 241, 0.62) 45%, transparent 100%),
    radial-gradient(1.8px 1.8px at 54% 24%, rgba(14, 165, 233, 0.66) 45%, transparent 100%),
    radial-gradient(1.3px 1.3px at 73% 72%, rgba(168, 85, 247, 0.58) 45%, transparent 100%),
    radial-gradient(1.5px 1.5px at 88% 41%, rgba(59, 130, 246, 0.64) 45%, transparent 100%),
    radial-gradient(1.2px 1.2px at 38% 44%, rgba(45, 212, 191, 0.52) 45%, transparent 100%);
  background-repeat: repeat;
  background-size: 280px 280px;
  opacity: 0.88;
}

body.theme-business .main.panel::after {
  animation: content-nebula-drift 120s linear infinite;
  background-image:
    radial-gradient(120px 70px at 22% 28%, rgba(14, 165, 233, 0.1), transparent 82%),
    radial-gradient(140px 88px at 66% 64%, rgba(99, 102, 241, 0.1), transparent 84%),
    radial-gradient(110px 74px at 84% 32%, rgba(167, 139, 250, 0.08), transparent 82%);
  background-repeat: repeat;
  background-size: 620px 620px;
  opacity: 0.8;
}

body.theme-business .main.panel > * {
  position: relative;
  z-index: 1;
}

body.theme-business .messages {
  background: transparent;
  border: none;
}

body.theme-business .composer {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(226, 232, 240, 0.92);
}

body.theme-business .message-body,
body.theme-business .chat-empty-state h2,
body.theme-business .model-label,
body.theme-business .toggle-label {
  color: #111827;
}

body.theme-business .muted {
  color: #6b7280;
}

/* Sidebar-only starfield (test version) */
body.theme-business .sidebar.panel {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.88), rgba(30, 41, 59, 0.85));
  border: 1px solid rgba(100, 116, 139, 0.45);
  overflow: hidden;
  position: relative;
}

body.theme-business .sidebar.panel::before,
body.theme-business .sidebar.panel::after {
  content: "";
  inset: -25%;
  pointer-events: none;
  position: absolute;
}

body.theme-business .sidebar.panel::before {
  animation: sidebar-stars-pan 42s linear infinite, sidebar-stars-twinkle 4.2s ease-in-out infinite;
  background-image:
    radial-gradient(1.3px 1.3px at 12% 17%, rgba(255, 255, 255, 0.96) 45%, transparent 100%),
    radial-gradient(1.1px 1.1px at 18% 33%, rgba(255, 255, 255, 0.92) 45%, transparent 100%),
    radial-gradient(1px 1px at 27% 63%, rgba(191, 219, 254, 0.86) 45%, transparent 100%),
    radial-gradient(1.45px 1.45px at 51% 23%, rgba(255, 255, 255, 0.95) 45%, transparent 100%),
    radial-gradient(1.2px 1.2px at 68% 31%, rgba(186, 230, 253, 0.86) 45%, transparent 100%),
    radial-gradient(1px 1px at 77% 56%, rgba(255, 255, 255, 0.9) 45%, transparent 100%),
    radial-gradient(1.35px 1.35px at 84% 79%, rgba(255, 255, 255, 0.94) 45%, transparent 100%);
  background-repeat: repeat;
  background-size: 260px 260px;
  mix-blend-mode: screen;
  opacity: 0.95;
}

body.theme-business .sidebar.panel::after {
  animation: sidebar-nebula-drift 64s linear infinite;
  background-image:
    radial-gradient(95px 60px at 22% 24%, rgba(56, 189, 248, 0.2), transparent 82%),
    radial-gradient(130px 88px at 74% 68%, rgba(99, 102, 241, 0.2), transparent 82%),
    radial-gradient(150px 96px at 46% 82%, rgba(59, 130, 246, 0.14), transparent 84%);
  background-repeat: repeat;
  background-size: 520px 520px;
  opacity: 0.88;
}

body.theme-business .sidebar.panel > * {
  position: relative;
  z-index: 1;
}

body.theme-business .conversation-list {
  scrollbar-color: rgba(148, 163, 184, 0.72) rgba(15, 23, 42, 0.35);
}

body.theme-business .sidebar-block h2 {
  color: #cbd5e1;
}

body.theme-business .conversation {
  background: rgba(15, 23, 42, 0.24);
  border: 1px solid rgba(148, 163, 184, 0.38);
  backdrop-filter: blur(2px);
}

body.theme-business .conversation-title {
  color: #e2e8f0;
}

body.theme-business .conversation-meta {
  color: #94a3b8;
}

body.theme-business .conversation:hover {
  background: rgba(30, 41, 59, 0.42);
  border-color: rgba(148, 163, 184, 0.52);
}

body.theme-business .conversation.active {
  background: rgba(15, 23, 42, 0.24);
  border-color: rgba(148, 163, 184, 0.38);
}

@keyframes sidebar-stars-pan {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(-180px, -120px, 0) scale(1.02);
  }
}

@keyframes sidebar-nebula-drift {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(120px, -160px, 0);
  }
}

@keyframes sidebar-stars-twinkle {
  0%,
  100% {
    opacity: 0.82;
    filter: brightness(1);
  }
  50% {
    opacity: 1;
    filter: brightness(1.24);
  }
}

@keyframes content-stars-drift {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(-120px, -90px, 0);
  }
}

@keyframes content-nebula-drift {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(100px, -120px, 0);
  }
}

/* Chat column layout (DeepSeek-like) */
body.theme-business .messages,
body.theme-business .composer {
  position: relative;
}

body.theme-business .composer {
  overflow: hidden;
}

body.theme-business .messages::before,
body.theme-business .composer::before {
  display: none !important;
}

body.theme-business .messages > *,
body.theme-business .composer > * {
  position: relative;
  z-index: 1;
}

@keyframes content-stars-local-a {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(-120px, -88px, 0) scale(1.03);
  }
}

@keyframes content-stars-local-b {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(-96px, -72px, 0) scale(1.02);
  }
}

/* Keep scrollbar visible in message history */
.messages {
  scrollbar-color: rgba(100, 116, 139, 0.55) rgba(241, 245, 249, 0.6);
  scrollbar-width: thin;
}

.messages::-webkit-scrollbar {
  width: 8px;
}

.messages::-webkit-scrollbar-track {
  background: rgba(241, 245, 249, 0.55);
  border-radius: 999px;
}

.messages::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.55);
  border-radius: 999px;
}
