:root {
  color-scheme: light;
  --bg: #f4efe6;
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --ink: #1a2b3d;
  --muted: #708090;
  --line: #ded8cc;
  --brand: #ff6b35;
  --brand-strong: #e95722;
  --navy: #1a2b3d;
  --navy-soft: #eef1f2;
  --green: #087662;
  --attention: #b75f23;
  --ok: rgba(8, 118, 98, 0.1);
  --orange-soft: rgba(255, 107, 53, 0.1);
  --shadow: 0 22px 60px rgba(26, 43, 61, 0.11);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 74% 6%, rgba(255, 107, 53, 0.12), transparent 28rem),
    linear-gradient(180deg, #ffffff 0, var(--bg) 280px, #ffffff 100%),
    var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

.appShell {
  width: min(1320px, calc(100vw - 56px));
  margin: 0 auto;
  padding: 30px 0 56px;
}

.appHeader,
.briefBand,
.chatPanel,
.evidencePanel,
.reviewPanel {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.appHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 24px 30px;
  border-radius: 10px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1.06;
  letter-spacing: 0;
  font-family: Fraunces, Georgia, serif;
  font-weight: 800;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
  font-weight: 850;
}

.statusText,
.hint {
  color: var(--muted);
  font-size: 13px;
}

.statusText {
  margin-top: 9px;
}

.progressTrace {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  max-width: 720px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 107, 53, 0.28);
  border-radius: 8px;
  background: rgba(255, 107, 53, 0.08);
  color: var(--ink);
}

.progressPulse {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--brand);
  box-shadow: 0 0 0 0 rgba(255, 107, 53, 0.46);
  animation: progressPulse 1.3s ease-out infinite;
}

.progressTrace.complete .progressPulse {
  background: var(--green);
  animation: none;
  box-shadow: 0 0 0 4px rgba(8, 118, 98, 0.12);
}

.progressTrace.failed .progressPulse {
  background: #b42318;
  animation: none;
  box-shadow: 0 0 0 4px rgba(180, 35, 24, 0.12);
}

.progressLabel {
  margin: 0 0 2px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.progressText {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 760;
  line-height: 1.35;
}

@keyframes progressPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 107, 53, 0.46);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(255, 107, 53, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 107, 53, 0);
  }
}

.headerActions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.statusPill,
.docType {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--ok);
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.statusPill.subtle {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.inlineToggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--navy);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

button:disabled {
  cursor: progress;
  opacity: 0.66;
}

.primaryButton {
  width: 210px;
  min-height: 56px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 12px 26px rgba(255, 107, 53, 0.24);
}

.primaryButton:hover,
.secondaryButton:hover {
  background: var(--brand-strong);
}

.secondaryButton {
  min-height: 42px;
  padding: 0 16px;
  background: var(--brand);
  color: #fff;
}

.briefBand {
  display: grid;
  grid-template-columns: minmax(280px, 0.68fr) minmax(560px, 1.32fr);
  gap: 24px;
  margin-top: 18px;
  padding: 28px 30px;
  border-radius: 10px;
  align-items: start;
}

.briefCopy p:last-child {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.5;
  max-width: 56ch;
}

.metricsGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr)) minmax(220px, 1.4fr);
  gap: 12px;
  align-items: start;
}

.metric,
.vendorSummary {
  min-height: 108px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 14px;
}

.metric {
  align-self: start;
  color: var(--ink);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.metric strong {
  display: block;
  margin-top: 14px;
  font-size: 38px;
  line-height: 0.9;
  letter-spacing: 0;
  font-family: Fraunces, Georgia, serif;
}

.primaryMetric {
  background: var(--orange-soft);
  border-color: rgba(255, 107, 53, 0.34);
}

.attention strong {
  color: var(--attention);
}

.metricButton {
  display: block;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.metricButton:hover {
  border-color: var(--brand);
  background: #fff7f1;
  transform: translateY(-1px);
}

.vendorSummary {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.vendorSummary p {
  color: var(--ink);
  font-weight: 850;
  margin-bottom: 8px;
}

.vendorSummary div {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.vendorSummary span {
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 5px 9px;
}

.vendorSummary small {
  display: block;
  margin-top: 9px;
}

.vendorSummary a {
  color: var(--brand-strong);
  text-decoration: none;
  font-weight: 800;
}

.workbench {
  display: block;
  margin-top: 24px;
}

.chatPanel,
.evidencePanel,
.reviewPanel {
  border-radius: 8px;
  padding: 28px 30px;
}

.chatPanel {
  min-height: 760px;
  display: flex;
  flex-direction: column;
}

.evidencePanel {
  position: fixed;
  z-index: 40;
  top: 24px;
  right: 24px;
  bottom: 24px;
  width: min(560px, calc(100vw - 48px));
  min-height: 0;
  transform: translateX(calc(100% + 36px));
  transition: transform 180ms ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.evidencePanel.open {
  transform: translateX(0);
}

.evidenceBackdrop {
  position: fixed;
  z-index: 35;
  inset: 0;
  background: rgba(26, 43, 61, 0.24);
  backdrop-filter: blur(2px);
}

.drawerOpen {
  overflow: hidden;
}

.sectionHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.chatHeaderActions,
.evidenceHeaderActions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.ghostButton {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  font-size: 13px;
}

.ghostButton:hover {
  color: var(--brand-strong);
  background: var(--orange-soft);
  border-color: rgba(255, 107, 53, 0.36);
}

textarea {
  flex: 1;
  min-height: 86px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 17px 18px;
  font-size: 17px;
  line-height: 1.45;
  outline: none;
}

textarea:focus,
input[type="search"]:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.16);
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 14px;
}

.suggestions button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  font-size: 13px;
}

.suggestions button:hover {
  color: var(--brand-strong);
  background: var(--orange-soft);
  border-color: rgba(255, 107, 53, 0.36);
}

.composer {
  display: flex;
  align-items: stretch;
  gap: 12px;
  margin-top: 14px;
}

.fileContextBar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  min-height: 38px;
}

.fileChips {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

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

.fileChip {
  display: inline-flex;
  align-items: center;
  max-width: min(460px, 100%);
  min-height: 32px;
  border: 1px solid rgba(255, 107, 53, 0.32);
  border-radius: 999px;
  background: #fff7f1;
  color: var(--navy);
  padding: 0 4px 0 11px;
  font-size: 12px;
  font-weight: 850;
}

.fileChip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fileChip button {
  width: 24px;
  height: 24px;
  min-height: 24px;
  margin-left: 4px;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  line-height: 1;
}

.fileChip button:hover {
  background: rgba(255, 107, 53, 0.14);
  color: var(--brand-strong);
}

.filePicker {
  position: absolute;
  z-index: 25;
  left: 0;
  bottom: calc(100% + 8px);
  width: min(620px, calc(100vw - 96px));
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 22px 60px rgba(26, 43, 61, 0.16);
  padding: 12px;
}

.filePickerHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.filePickerHeader strong {
  color: var(--navy);
  font-size: 13px;
}

.smallIconButton {
  width: 30px;
  height: 30px;
  min-height: 30px;
  font-size: 19px;
}

.filePicker input[type="search"] {
  width: 100%;
}

.fileResults {
  display: grid;
  gap: 7px;
  max-height: 300px;
  overflow: auto;
  margin-top: 10px;
}

.fileResult {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  padding: 9px 10px;
  text-align: left;
}

.fileResult strong,
.fileResult span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fileResult strong {
  font-size: 13px;
}

.fileResult span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.fileResult:hover,
.fileResult.selected {
  border-color: rgba(255, 107, 53, 0.42);
  background: #fff7f1;
}

.chatLog {
  margin-top: 0;
  flex: 1;
  min-height: 500px;
  max-height: min(860px, calc(100vh - 260px));
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fffdf8, #faf7ef);
  padding: 16px;
}

.message {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  max-width: 100%;
}

.userMessage {
  justify-self: end;
}

.assistantMessage {
  justify-self: start;
  width: 100%;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--navy);
  color: #fff;
  font-size: 12px;
  font-weight: 850;
}

.userMessage .avatar {
  background: var(--brand);
}

.message > div:last-child {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 13px 15px;
  min-width: 0;
}

.userMessage > div:last-child {
  background: #fff7f1;
  border-color: rgba(255, 107, 53, 0.32);
}

.messageLabel {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  margin-bottom: 6px;
}

.chatMeta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.answerText {
  color: #213039;
  font-size: 16px;
  line-height: 1.65;
  min-width: 0;
}

.answerText p + p,
.answerText p + ul,
.answerText p + ol,
.answerText p + .answerTableWrap,
.answerText .answerTableWrap + p,
.answerText ul + p,
.answerText ol + p {
  margin-top: 15px;
}

.answerText strong {
  color: #0f2c32;
}

.answerText ul,
.answerText ol {
  margin: 10px 0 0;
  padding-left: 22px;
}

.answerText li + li {
  margin-top: 6px;
}

.inlineCitation {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border: 0;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--orange-soft);
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 850;
  vertical-align: 0.08em;
  cursor: pointer;
}

.inlineCitation:hover {
  background: rgba(255, 107, 53, 0.18);
  color: var(--brand);
}

.answerTableWrap {
  width: 100%;
  margin-top: 14px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.answerTable {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.45;
}

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

.answerTable th {
  background: #fff7f1;
  color: var(--navy);
  font-weight: 850;
}

.answerTable tr:last-child td {
  border-bottom: 0;
}

.sourceList {
  margin-top: 16px;
  display: grid;
  gap: 10px;
  max-height: none;
  flex: 1;
  overflow: auto;
  padding-right: 3px;
}

.sourceItem {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 13px;
}

.webSource {
  border-color: #d8cfbf;
  background: #fffaf2;
}

.webNotice {
  border: 1px solid #d8cfbf;
  border-radius: 8px;
  background: #fffaf2;
  color: #76512f;
  padding: 11px 12px;
  font-size: 13px;
  font-weight: 750;
}

.sourceTopline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.sourceTopline a,
.sourceTopline button {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--navy);
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}

.sourceTopline span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.sourceItem p,
.emptyState {
  margin-top: 9px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.emptyState {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface-2);
}

.reviewPanel {
  margin-top: 24px;
}

.reviewControls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

input[type="search"] {
  width: min(380px, 42vw);
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 13px;
  outline: none;
}

.documentTable {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 10px;
  max-height: 430px;
  overflow: auto;
}

.docRow {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
  min-width: 0;
}

.docRow a {
  color: var(--brand-strong);
  font-weight: 850;
  text-decoration: none;
}

.docRow p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.docType {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
}

.docActions {
  display: grid;
  justify-items: end;
  gap: 8px;
  flex: 0 0 auto;
}

.docActions button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--navy);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.docActions button:hover {
  color: var(--brand-strong);
  background: var(--orange-soft);
  border-color: rgba(255, 107, 53, 0.36);
}

.sourceDialog {
  width: min(860px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 40px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 28px 90px rgba(23, 32, 39, 0.22);
  color: var(--ink);
}

.sourceDialog::backdrop {
  background: rgba(18, 28, 32, 0.35);
}

.dialogHeader,
.dialogActions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.dialogHeader h2 {
  word-break: break-word;
}

.iconButton {
  width: 38px;
  height: 38px;
  min-height: 38px;
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.dialogMeta {
  padding: 13px 20px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  border-bottom: 1px solid var(--line);
}

.dialogBody {
  max-height: 470px;
  overflow: auto;
  padding: 20px;
  white-space: pre-wrap;
  color: #203039;
  font: 14px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.dialogActions {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

.dialogActions a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  padding: 0 14px;
  text-decoration: none;
  font-weight: 850;
}

.issueList {
  display: grid;
  gap: 12px;
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, sans-serif;
  white-space: normal;
}

.issueList article {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 14px;
}

.issueList strong {
  display: block;
  color: var(--navy);
  margin-bottom: 6px;
}

.issueList p {
  color: var(--muted);
  margin-bottom: 10px;
}

.issueList a {
  color: var(--brand-strong);
  font-weight: 850;
  text-decoration: none;
}

@media (max-width: 1120px) {
  .briefBand,
  .workbench {
    display: block;
  }

  .metricsGrid,
  .chatPanel {
    margin-top: 16px;
  }

  .metricsGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .appShell {
    width: min(100vw - 24px, 720px);
    padding-top: 14px;
  }

  .appHeader,
  .composer,
  .sectionHeader,
  .reviewControls {
    display: block;
  }

  .headerActions,
  .reviewControls {
    margin-top: 16px;
  }

  .primaryButton,
  input[type="search"] {
    width: 100%;
    margin-top: 10px;
  }

  .message {
    max-width: 100%;
  }

  .chatMeta {
    display: block;
  }

  .metricsGrid,
  .documentTable {
    grid-template-columns: 1fr;
  }
}
