:root {
  --xl-brand: #132C52;
  --xl-brand-dark: #0C1E3A;
  --xl-brand-deep: #1A3A6B;
  --xl-brand-light: #EEF3F9;
  --xl-brand-soft: #DBEAFE;
  --xl-brand-border: #93C5FD;
  --bg-page: #F8FAFC;
  --bg-card: #FFFFFF;
  --border: #CBD5E1;
  --border-soft: #E1DFDD;
  --text: #0F172A;
  --text-body: #242424;
  --text-muted: #605E5C;
  --danger: #B91C1C;
  --danger-bg: #FEF2F2;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(12, 30, 58, 0.10);
  --sidebar-w: 276px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-page);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

svg {
  display: block;
  flex-shrink: 0;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

/* Shell Layout */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  gap: 12px;
  z-index: 30;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px;
}

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

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--xl-brand), var(--xl-brand-deep));
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text strong {
  font-size: 15px;
  color: var(--xl-brand-dark);
}

.brand-text small {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 40px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--xl-brand);
  color: #FFFFFF;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-body);
  cursor: pointer;
  text-align: left;
  font-weight: 500;
}

.nav-item.active {
  background: var(--xl-brand-light);
  color: var(--xl-brand);
  font-weight: 600;
}

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--xl-brand-soft);
  color: var(--xl-brand-dark);
  font-weight: 600;
}

.history-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--border-soft);
  padding-top: 10px;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 0 8px;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-empty {
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-body);
  font-size: 13px;
}

.history-item.active {
  background: var(--xl-brand-light);
  color: var(--xl-brand-dark);
  font-weight: 600;
}

.history-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-del {
  width: 24px;
  height: 24px;
  padding: 0;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.6;
}

.sidebar-footer {
  border-top: 1px solid var(--border-soft);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-action {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  cursor: pointer;
  text-align: left;
}

.footer-action-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  flex: 1;
  min-width: 0;
}

.footer-action-text strong {
  font-size: 13px;
  color: var(--text);
}

.footer-action-text small {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #CBD5E1;
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--xl-brand-deep);
  box-shadow: 0 0 0 3px var(--xl-brand-soft);
}

.account-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-account {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #FFFFFF;
  cursor: pointer;
  font-weight: 500;
  color: var(--xl-brand-dark);
}

.quota-pill {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  background: var(--xl-brand-light);
  border-radius: 6px;
  padding: 4px 8px;
}

/* Main Area */
.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar {
  height: 56px;
  flex-shrink: 0;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-soft);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--xl-brand-dark);
}

.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: #FFFFFF;
  color: var(--text);
  cursor: pointer;
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--xl-brand-dark);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.pill-btn.primary-soft {
  background: var(--xl-brand-light);
  border-color: var(--xl-brand-border);
  color: var(--xl-brand);
}

/* Views */
.view {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.view.active {
  display: flex;
}

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 16px;
}

.welcome-hero {
  max-width: 820px;
  margin: 28px auto 12px;
  text-align: center;
}

.hero-badge {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--xl-brand-light);
  border: 1px solid var(--xl-brand-border);
  color: var(--xl-brand);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 14px;
}

.welcome-hero h1 {
  margin: 0 0 10px;
  font-size: 28px;
  line-height: 1.28;
  color: var(--xl-brand-dark);
  letter-spacing: -0.02em;
}

.hero-sub {
  margin: 0 auto 24px;
  max-width: 620px;
  color: var(--text-muted);
  font-size: 14.5px;
}

.quick-prompts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  text-align: left;
}

.prompt-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.prompt-card strong {
  color: var(--xl-brand);
  font-size: 13px;
}

.prompt-card span {
  color: var(--text-body);
  font-size: 13.5px;
}

/* Thread */
.thread-container {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 16px;
}

.msg-user {
  align-self: flex-end;
  max-width: 82%;
  background: var(--xl-brand);
  color: #FFFFFF;
  padding: 12px 16px;
  border-radius: 16px 16px 4px 16px;
  font-size: 14.5px;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-assistant {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.status-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--xl-brand);
  background: var(--xl-brand-light);
  border: 1px solid var(--xl-brand-soft);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--xl-brand-border);
  border-top-color: var(--xl-brand);
  border-radius: 999px;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

.sources-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.source-card {
  flex: 0 0 210px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: var(--bg-page);
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.source-top {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.source-idx {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--xl-brand);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.source-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--xl-brand-dark);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.answer-body {
  color: var(--text-body);
  font-size: 14.5px;
  line-height: 1.68;
  word-break: break-word;
}

.answer-body h2, .answer-body h3, .answer-body h4 {
  color: var(--xl-brand-dark);
  margin: 14px 0 6px;
  line-height: 1.35;
}

.answer-body p {
  margin: 0 0 10px;
}

.answer-body ul, .answer-body ol {
  margin: 6px 0 12px;
  padding-left: 22px;
}

.answer-body li {
  margin-bottom: 4px;
}

.answer-body pre {
  background: #0C1E3A;
  color: #F8FAFC;
  padding: 12px 14px;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
}

.answer-body code {
  background: var(--xl-brand-light);
  color: var(--xl-brand-dark);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
}

.answer-body pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.cite-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  margin: 0 1px;
  border-radius: 4px;
  background: var(--xl-brand-soft);
  color: var(--xl-brand-dark);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  vertical-align: middle;
}

.meta-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
  font-size: 12px;
  color: var(--text-muted);
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg-page);
  border: 1px solid var(--border-soft);
}

.meta-chip.brand {
  background: var(--xl-brand-light);
  border-color: var(--xl-brand-border);
  color: var(--xl-brand);
  font-weight: 600;
}

.meta-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mini-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--border-soft);
  background: #FFFFFF;
  color: var(--text-body);
  font-size: 12px;
  cursor: pointer;
}

.followups-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 6px;
}

.followups-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.followup-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: var(--bg-page);
  color: var(--xl-brand-dark);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}

/* Composer */
.composer-wrap {
  flex-shrink: 0;
  padding: 10px 20px 14px;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0) 0%, var(--bg-page) 22%);
}

.composer-box {
  max-width: 860px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
}

.composer-box:focus-within {
  border-color: var(--xl-brand);
  box-shadow: 0 0 0 3px rgba(19, 44, 82, 0.08);
}

.attached-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.img-thumb {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.img-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.img-thumb button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  padding: 0;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  background: rgba(12, 30, 58, 0.85);
  color: #FFFFFF;
  cursor: pointer;
}

#chatInput {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-size: 14.5px;
  line-height: 1.5;
  max-height: 160px;
}

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
}

.composer-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.mode-group {
  display: inline-flex;
  background: var(--bg-page);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 2px;
}

.mode-btn {
  border: none;
  background: transparent;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
}

.mode-btn.active {
  background: var(--xl-brand);
  color: #FFFFFF;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--bg-page);
  font-size: 12px;
  color: var(--text-body);
  cursor: pointer;
  user-select: none;
}

.toggle-chip input {
  accent-color: var(--xl-brand);
  margin: 0;
}

.icon-chip {
  width: 30px;
  height: 30px;
  padding: 0;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--bg-page);
  color: var(--xl-brand);
  cursor: pointer;
}

.send-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: none;
  background: var(--xl-brand);
  color: #FFFFFF;
  cursor: pointer;
  flex-shrink: 0;
}

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

.composer-hint {
  max-width: 860px;
  margin: 6px auto 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Secondary Pages */
.page-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
}

.page-header h2 {
  margin: 0 0 4px;
  font-size: 21px;
  color: var(--xl-brand-dark);
}

.page-header p {
  margin: 0;
  color: var(--text-muted);
}

.search-inline {
  display: flex;
  gap: 8px;
}

.search-inline input {
  height: 38px;
  min-width: 240px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #FFFFFF;
}

.community-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.comm-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}

.comm-card h4 {
  margin: 0;
  font-size: 15px;
  color: var(--xl-brand-dark);
  cursor: pointer;
}

.comm-preview {
  font-size: 13px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.comm-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
}

/* Cards & Forms */
.kb-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.card h3, .card h4 {
  margin: 0 0 8px;
  color: var(--xl-brand-dark);
}

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

.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-body);
}

label input[type="text"],
label input[type="email"],
label input[type="password"],
label input[type="url"],
label input[type="number"],
label input[type="file"],
label select,
label textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #FFFFFF;
  font-weight: 400;
}

.switch-inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  cursor: pointer;
}

.switch-inline input {
  accent-color: var(--xl-brand);
}

.sub-heading {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--xl-brand);
  padding-top: 6px;
  border-top: 1px solid var(--border-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
}

.btn.primary {
  background: var(--xl-brand);
  color: #FFFFFF;
}

.btn.secondary {
  background: var(--xl-brand-light);
  border-color: var(--xl-brand-border);
  color: var(--xl-brand);
}

.btn.danger {
  background: var(--danger-bg);
  border-color: #FECACA;
  color: var(--danger);
}

.btn.full-width {
  width: 100%;
}

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

.form-actions.space-between {
  justify-content: space-between;
}

/* KB list & Stats */
.kb-list, .conn-list, .breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kb-row, .conn-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--bg-page);
}

.conn-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.conn-title-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--xl-brand-light);
  color: var(--xl-brand-dark);
}

.tag-navy {
  background: var(--xl-brand);
  color: #FFFFFF;
}

.tag-err {
  background: var(--danger-bg);
  color: var(--danger);
}

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

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px;
}

.stat-card small {
  color: var(--text-muted);
  font-size: 12px;
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
  color: var(--xl-brand-dark);
}

.opt-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text-body);
}

/* Modals (always centered) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 30, 58, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 100;
}

.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-sm { max-width: 440px; }
.modal-md { max-width: 640px; }
.modal-lg { max-width: 820px; }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
}

.modal-header h3 {
  margin: 0;
  font-size: 16.5px;
  color: var(--xl-brand-dark);
}

.modal-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 20px 0;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-page);
}

.modal-tabs.compact {
  padding: 0;
  background: transparent;
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 9px 14px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.tab-btn.active {
  color: var(--xl-brand);
  border-bottom-color: var(--xl-brand);
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.oauth-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.oauth-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  background: var(--bg-page);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.oauth-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.oauth-card p {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
  flex: 1;
}

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

.compact-select {
  height: 36px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  font-size: 12.5px;
}

.callback-note {
  font-size: 11.5px;
  color: var(--text-muted);
  word-break: break-all;
}

.callback-note code {
  background: var(--xl-brand-light);
  color: var(--xl-brand-dark);
  padding: 2px 5px;
  border-radius: 4px;
}

.pref-row {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--xl-brand-light);
}

.divider-or {
  text-align: center;
  margin: 14px 0;
  position: relative;
}

.divider-or::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: var(--border-soft);
}

.divider-or span {
  position: relative;
  background: #FFFFFF;
  padding: 0 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.profile-summary {
  padding: 14px;
  border-radius: 10px;
  background: var(--xl-brand-light);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Toast */
.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  background: var(--xl-brand-dark);
  color: #FFFFFF;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  max-width: 360px;
}

.toast.error {
  background: var(--danger);
}

.mobile-only {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

/* Hover only for fine pointer devices */
@media (hover: hover) and (pointer: fine) {
  .btn-new-chat:hover, .btn.primary:hover, .send-btn:hover {
    background: var(--xl-brand-deep);
  }
  .nav-item:hover:not(.active), .history-item:hover:not(.active) {
    background: var(--bg-page);
  }
  .history-del:hover {
    opacity: 1;
    color: var(--danger);
    background: var(--danger-bg);
  }
  .prompt-card:hover {
    border-color: var(--xl-brand-border);
    transform: translateY(-1px);
  }
  .source-card:hover, .followup-btn:hover {
    border-color: var(--xl-brand-border);
    background: var(--xl-brand-light);
  }
  .pill-btn:hover, .mini-btn:hover, .footer-action:hover, .btn-account:hover {
    border-color: var(--xl-brand-border);
  }
}

@media (max-width: 920px) {
  .mobile-only {
    display: inline-flex;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(12, 30, 58, 0.35);
    z-index: 25;
  }
  .quick-prompts, .kb-grid, .stats-grid, .oauth-cards, .form-grid {
    grid-template-columns: 1fr;
  }
  .welcome-hero h1 {
    font-size: 22px;
  }
}
