:root {
  color-scheme: light;
  font-family:
    Söhne,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  --bg-page: #fff;
  --bg-muted: #f7f7f8;
  --bg-user: #f4f4f4;
  --border: #e3e3e3;
  --text: #0d0d0d;
  --text-muted: #6e6e80;
  --accent: #10a37f;
  --thread-width: 48rem;
  background: var(--bg-page);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg-page);
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  width: 100%;
  min-height: 100vh;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.chat-panel {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: calc(100vh - 52px);
  background: var(--bg-page);
}

.answer-mode {
  margin: 10px 0 0;
  padding: 4px 10px;
  width: fit-content;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.answer-mode.analytics {
  background: #dbeafe;
  color: #1d4ed8;
}

.answer-mode.rag {
  background: #dcfce7;
  color: #166534;
}

@media (max-width: 960px) {
  .chat-panel {
    min-height: auto;
  }
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: rgb(255 255 255 / 92%);
  backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(var(--thread-width), calc(100% - 32px));
  margin: 0 auto;
  padding: 12px 0;
}

.header-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
}

.eyebrow {
  margin: 0 0 4px;
  color: #6b7280;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.login-card h1 {
  font-size: 24px;
}

.hidden {
  display: none !important;
}

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

.user-label {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
}

.ghost-button {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--bg-page);
  color: var(--text);
  font-size: 13px;
  transition: background 0.15s ease;
}

.ghost-button:hover {
  background: var(--bg-muted);
}

.login-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 18px 40px rgb(15 23 42 / 8%);
}

.login-copy {
  margin: 0 0 20px;
  color: #6b7280;
  font-size: 14px;
  line-height: 1.6;
}

.login-form {
  display: grid;
  gap: 14px;
}

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

.login-form input {
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 10px 12px;
}

.login-form button {
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  background: #111827;
  color: #fff;
}

.login-error {
  margin: 0;
  color: #b91c1c;
  font-size: 13px;
}

.upload-shell {
  width: min(760px, 100%);
  min-height: 100vh;
  margin: 0 auto;
}

.upload-panel {
  padding: 24px;
}

.upload-copy {
  margin: 0 0 20px;
  color: #6b7280;
  line-height: 1.7;
}

.status-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 24px;
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #fff;
}

.status-card div {
  display: grid;
  gap: 4px;
}

.status-card dt {
  color: #6b7280;
  font-size: 12px;
}

.status-card dd {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.upload-form {
  display: grid;
  gap: 14px;
  margin-bottom: 20px;
}

.file-label {
  display: grid;
  gap: 8px;
  color: #374151;
  font-size: 14px;
}

.upload-form button {
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  background: #111827;
  color: #fff;
}

.upload-message {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
}

.upload-message.error {
  color: #b91c1c;
}

.zip-format {
  margin: 0;
  padding: 14px;
  border-radius: 10px;
  background: #f3f4f6;
  color: #374151;
  font-size: 13px;
  line-height: 1.5;
}

.thread {
  display: grid;
  align-content: start;
  gap: 0;
  overflow-y: auto;
  padding: 24px 16px 180px;
}

.message {
  width: 100%;
  padding: 20px 0;
}

.message-inner {
  display: flex;
  gap: 16px;
  width: min(var(--thread-width), 100%);
  margin: 0 auto;
  align-items: flex-start;
}

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

.assistant-avatar {
  display: block;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  overflow: hidden;
  background: #000;
}

.assistant-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bubble {
  min-width: 0;
  flex: 1;
  color: var(--text);
  font-size: 16px;
  line-height: 1.7;
}

.user-bubble {
  flex: 0 1 auto;
  max-width: min(85%, 36rem);
  padding: 10px 16px;
  border-radius: 24px;
  background: var(--bg-user);
}

.user-message .message-text {
  white-space: pre-wrap;
}

.welcome-message .bubble {
  padding-top: 2px;
}

.welcome-heading {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.welcome-copy {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.6;
}

.chat-progress {
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid #ececf1;
  border-radius: 16px;
  background: var(--bg-muted);
}

.chat-progress-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
}

.chat-progress-step {
  padding: 4px 10px;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #fff;
  color: #6b7280;
  font-size: 11px;
  font-weight: 700;
}

.chat-progress-step.is-active {
  border-color: #2563eb;
  background: #dbeafe;
  color: #1d4ed8;
}

.chat-progress-step.is-done {
  border-color: #86efac;
  background: #dcfce7;
  color: #166534;
}

.chat-progress-message {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: #1f2937;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
}

.chat-progress-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #bfdbfe;
  border-top-color: #2563eb;
  border-radius: 999px;
  animation: chat-progress-spin 0.8s linear infinite;
  flex-shrink: 0;
}

.chat-progress-detail {
  margin: 8px 0 0;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.6;
}

.chat-progress-elapsed {
  margin: 8px 0 0;
  color: #9ca3af;
  font-size: 11px;
}

@keyframes chat-progress-spin {
  to {
    transform: rotate(360deg);
  }
}

.message-text {
  white-space: pre-wrap;
  line-height: 1.8;
}

.message-text p,
.bubble p {
  margin: 0;
}

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

.examples button {
  min-height: 72px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-page);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  text-align: left;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}

.examples button:hover {
  background: var(--bg-muted);
  border-color: #d0d0d5;
}

.composer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  padding: 0 16px 18px;
  background: linear-gradient(180deg, rgb(255 255 255 / 0) 0%, rgb(255 255 255 / 88%) 24%, #fff 48%);
}

.composer-inner {
  width: min(var(--thread-width), 100%);
  margin: 0 auto;
}

.composer-shell {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 10px 10px 16px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--bg-page);
  box-shadow:
    0 0 0 1px rgb(0 0 0 / 3%),
    0 4px 16px rgb(0 0 0 / 6%);
}

.composer textarea {
  width: 100%;
  max-height: 200px;
  min-height: 24px;
  resize: none;
  padding: 8px 0 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  line-height: 1.6;
  box-shadow: none;
}

.composer textarea:focus {
  outline: none;
}

.composer-send {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
}

.composer-send:hover:not(:disabled) {
  transform: scale(1.04);
}

.composer-send:disabled,
.composer-send.is-loading {
  cursor: wait;
  opacity: 0.35;
}

.composer-footnote {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.sources {
  margin-top: 16px;
  color: #353740;
}

.sources summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
}

.sources.empty {
  color: #6b7280;
  font-size: 14px;
}

.source-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.source-card {
  padding: 12px;
  border: 1px solid #ececf1;
  border-radius: 14px;
  background: #f7f7f8;
}

.source-card h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.meta {
  margin-bottom: 8px;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.5;
}

.quote {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: #353740;
  font-size: 13px;
  line-height: 1.6;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.accounts-shell {
  width: min(1100px, 100%);
  min-height: 100vh;
  margin: 0 auto;
}

.accounts-panel {
  padding: 24px;
}

.accounts-copy {
  margin: 0 0 20px;
  color: #6b7280;
  font-size: 14px;
  line-height: 1.6;
}

.tenant-account-groups {
  display: grid;
  gap: 20px;
}

.tenant-account-card {
  overflow: hidden;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #fff;
}

.tenant-account-card header {
  padding: 16px 18px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
}

.tenant-account-card h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.tenant-account-card header p {
  margin: 0;
  color: #6b7280;
  font-size: 12px;
}

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

.accounts-table th,
.accounts-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
  vertical-align: top;
}

.accounts-table th {
  background: #fcfcfd;
  color: #4b5563;
  font-size: 12px;
}

.accounts-table code {
  font-size: 12px;
}

@media (max-width: 720px) {
  .accounts-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    width: calc(100% - 24px);
  }

  .header-actions {
    flex-wrap: wrap;
  }

  .thread {
    padding-right: 12px;
    padding-left: 12px;
    padding-bottom: 200px;
  }

  .welcome-heading {
    font-size: 22px;
  }

  .examples {
    grid-template-columns: 1fr;
  }

  .user-bubble {
    max-width: 92%;
  }
}
