*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #1663d8;
  --indigo: #4f46e5;
  --cyan: #16a3c7;
  --green: #16a34a;
  --amber: #c47a00;
  --ink: #102033;
  --muted: #627086;
  --line: #dce5ee;
  --panel: rgba(255,255,255,.95);
  --shadow: 0 22px 50px rgba(12,43,58,.11);
  --shadow-soft: 0 12px 28px rgba(12,43,58,.07);
}

body {
  min-height: 100vh;
  color: var(--ink);
  font-family: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;
  background:
    radial-gradient(circle at 84% 8%, rgba(79,70,229,.12), transparent 28%),
    linear-gradient(180deg,#f8fbfd 0%,#edf4f8 68%,#e7f0f5 100%);
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 24px;
  border-bottom: 1px solid rgba(220,229,238,.85);
  background: rgba(255,255,255,.9);
  box-shadow: 0 10px 28px rgba(12,43,58,.05);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: #fff;
  background: linear-gradient(145deg,#0f69df,#103da8);
  box-shadow: 0 12px 24px rgba(22,99,216,.24);
  font-size: 12px;
  font-weight: 800;
}

.brand-title { display: grid; line-height: 1.15; min-width: 150px; }
.brand-title strong { font-size: 15px; color: #0f2636; }
.brand-title span { margin-top: 2px; font-size: 11px; font-weight: 600; color: var(--muted); }

.app-menu {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f5f8fb;
}

.app-menu a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 8px;
  color: #526276;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.app-menu a:hover { color: var(--ink); background: #fff; }
.app-menu a.active { color: var(--blue); background: #fff; box-shadow: 0 8px 18px rgba(12,43,58,.08); }
.topbar-spacer { flex: 1; }
.topbar-user { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #374151; }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(145deg,#4f46e5,#16a3c7);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(12,43,58,.14);
}

.page-shell { max-width: 1480px; margin: 0 auto; padding: 22px; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--indigo);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.page-head h1 {
  color: #0d2b3a;
  font-size: clamp(30px,4vw,46px);
  line-height: 1.05;
  margin-bottom: 8px;
}

.page-head p {
  max-width: 770px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.security-card {
  min-width: 310px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  background: #f0fdf4;
  box-shadow: var(--shadow-soft);
}

.security-card i {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: #fff;
  background: var(--green);
}

.security-card strong,
.security-card span { display: block; }
.security-card strong { font-size: 14px; color: #0d2b3a; }
.security-card span { margin-top: 2px; color: var(--muted); font-size: 12px; }

.bot-grid {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(420px, 1fr) minmax(320px, 380px);
  gap: 16px;
  align-items: stretch;
}

.source-panel,
.chat-panel,
.rag-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head,
.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2,
.chat-head h2 { color: #0d2b3a; font-size: 18px; line-height: 1.2; }
.chat-head span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }

.badge,
.mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #ecebff;
  color: var(--indigo);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.source-list {
  display: grid;
  gap: 9px;
  padding: 14px 18px 0;
}

.source {
  width: 100%;
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  gap: 10px;
  border: 1px solid #dce5ee;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 10px;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.source i {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--indigo);
  background: #ecebff;
}

.source strong,
.source small { display: block; }
.source strong { color: #0d2b3a; font-size: 13px; }
.source small { margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.source.active { border-color: var(--indigo); background: #f5f4ff; }

.upload-card {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 14px 18px 0;
  padding: 13px;
  border: 1px dashed #b9b5f4;
  border-radius: 10px;
  background: #fafaff;
}

.upload-card i { color: var(--indigo); font-size: 18px; }
.upload-card strong,
.upload-card span { display: block; }
.upload-card strong { font-size: 13px; color: #0d2b3a; }
.upload-card span { margin-top: 2px; color: var(--muted); font-size: 12px; }

.index-health {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 14px 18px 18px;
}

.index-health div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid #dce5ee;
  border-radius: 8px;
  background: #f8fbfd;
}

.index-health strong { font-size: 12px; color: #0d2b3a; }
.index-health span { font-size: 12px; color: var(--muted); font-weight: 700; }

.chat-panel {
  display: grid;
  grid-template-rows: auto auto minmax(390px, 1fr) auto;
  min-height: 720px;
}

.examples {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #f8fbfd;
}

.question-chip {
  border: 1px solid #dce5ee;
  border-radius: 999px;
  background: #fff;
  color: #43556b;
  padding: 7px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.question-chip:hover { border-color: var(--indigo); color: var(--indigo); }

.messages {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 18px;
  overflow-y: auto;
}

.message { display: flex; }
.message.user { justify-content: flex-end; }
.bubble {
  max-width: 82%;
  padding: 13px 14px;
  border-radius: 10px;
  border: 1px solid #dce5ee;
  background: #fff;
  box-shadow: 0 8px 18px rgba(12,43,58,.04);
}

.message.user .bubble { color: #fff; background: linear-gradient(145deg,#4f46e5,#1663d8); border-color: transparent; }
.bubble strong { display: block; margin-bottom: 5px; font-size: 13px; }
.bubble p { color: inherit; font-size: 13px; line-height: 1.55; }
.message.assistant .bubble p { color: #415163; }

.citations {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.citation {
  border: 1px solid #b9b5f4;
  border-radius: 999px;
  background: #f5f4ff;
  color: var(--indigo);
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 800;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
  background: #f8fbfd;
}

textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid #d4e1ec;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  line-height: 1.45;
  padding: 10px 11px;
  resize: vertical;
  outline: none;
}

textarea:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }

.btn {
  min-height: 48px;
  border: 0;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.btn.primary { color: #fff; background: linear-gradient(145deg,#4f46e5,#1663d8); box-shadow: 0 10px 20px rgba(79,70,229,.18); }

.pipeline {
  display: grid;
  gap: 9px;
  padding: 14px 18px 0;
}

.pipe-step {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
  align-items: start;
  padding: 11px;
  border: 1px solid #dce5ee;
  border-radius: 10px;
  background: #fff;
}

.pipe-step > span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--indigo);
  background: #ecebff;
}

.pipe-step strong,
.pipe-step small { display: block; }
.pipe-step strong { color: #0d2b3a; font-size: 13px; }
.pipe-step small { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.pipe-step.done { border-color: #bbf7d0; background: #f4fdf7; }
.pipe-step.done > span { color: #fff; background: var(--green); }
.pipe-step.active { border-color: #b9b5f4; background: #f5f4ff; }

.evidence-card,
.guardrails {
  margin: 14px 18px 0;
  border: 1px solid #dce5ee;
  border-radius: 10px;
  background: #f8fbfd;
}

.evidence-card { padding: 13px; }
.evidence-head { display: flex; align-items: center; gap: 8px; color: var(--indigo); margin-bottom: 8px; }
.evidence-head strong { font-size: 13px; color: #0d2b3a; }
.evidence-card p { color: #415163; font-size: 13px; line-height: 1.45; }

.guardrails {
  display: grid;
  gap: 8px;
  padding: 12px;
  margin-bottom: 18px;
}

.guardrails div {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #31516b;
  font-size: 12px;
  font-weight: 800;
}

.guardrails i { color: var(--green); width: 18px; text-align: center; }

@media (max-width: 1180px) {
  .bot-grid { grid-template-columns: 1fr 1fr; }
  .chat-panel { grid-column: 1 / -1; order: 3; }
  .rag-panel { order: 2; }
}

@media (max-width: 880px) {
  .topbar { flex-wrap: wrap; padding: 12px; }
  .brand-title { min-width: 0; }
  .app-menu { order: 3; width: 100%; overflow-x: auto; }
  .page-shell { padding: 16px; }
  .page-head { display: grid; align-items: start; }
  .security-card { min-width: 0; width: 100%; }
  .bot-grid { grid-template-columns: 1fr; }
  .chat-panel { min-height: 620px; }
}

@media (max-width: 560px) {
  .topbar-user span { display: none; }
  .page-head h1 { font-size: 31px; }
  .page-head p { font-size: 14px; }
  .composer { grid-template-columns: 1fr; }
  .bubble { max-width: 92%; }
  .panel-head, .chat-head { align-items: flex-start; flex-direction: column; }
}
