.page,
.detailPage {
  width: 100%;
  max-width: 100%;
  height: 100%;
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--primary-bg);
  color: var(--primary-text);
}

.page {
  padding: 2rem;
}

.header,
.detailTitleRow {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
}

.header {
  margin-bottom: 1.5rem;

  h1 {
    margin: 0.25rem 0 0.35rem;
    font-size: 2rem;
    line-height: 1.1;
    letter-spacing: -0.04em;
  }

  p {
    margin: 0;
    color: var(--secondary-text);
  }
}

.eyebrow {
  color: var(--primary-purple);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.totalBadge,
.status,
.exploited {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  border: 1px solid var(--border-default);
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  color: var(--secondary-text);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: capitalize;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0.9rem 1rem;
  background: #0e0e0e;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;

  span {
    color: var(--secondary-text);
    font-size: 0.78rem;
    font-weight: 600;
  }

  strong {
    font-size: 1.65rem;
    letter-spacing: -0.04em;
  }
}

.metricCritical strong { color: #ff5c5c; }
.metricHigh strong { color: #ff9f43; }

.tableCard {
  min-height: 360px;
  overflow: hidden;
  background: #0d0d0d;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
}

.toolbar {
  display: flex;
  gap: 0.75rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.search { max-width: 420px; }
.filter { width: 170px; }

.toolbar :global(.ant-input-affix-wrapper),
.toolbar :global(.ant-select-selector),
.chatComposer :global(.ant-input) {
  color: var(--primary-text) !important;
  background: var(--input-bg) !important;
  border-color: var(--border-default) !important;
}

.tableWrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;

  th {
    padding: 0.7rem 0.9rem;
    color: #777;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-align: left;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-subtle);
  }

  td {
    padding: 0.9rem;
    vertical-align: middle;
    color: #d7d7d7;
    font-size: 0.78rem;
    border-bottom: 1px solid var(--border-subtle);
  }

  th:nth-child(1) { width: 100px; }
  th:nth-child(2) { width: 29%; }
  th:nth-child(3) { width: 18%; }
  th:nth-child(4) { width: 70px; }
  th:nth-child(5) { width: 115px; }
  th:nth-child(6) { width: 95px; }
  th:nth-child(7) { width: 155px; }
  th:nth-child(8) { width: 34px; }

  tbody tr {
    cursor: pointer;
    transition: background var(--transition-fast);

    &:hover,
    &:focus-visible {
      outline: none;
      background: var(--surface-hover);
    }

    &:last-child td { border-bottom: 0; }
  }
}

.severity {
  display: inline-flex;
  justify-content: center;
  min-width: 68px;
  padding: 0.24rem 0.45rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.critical { color: #ff5c5c; background: rgba(255, 92, 92, 0.09); }
.high { color: #ff9f43; background: rgba(255, 159, 67, 0.09); }
.medium { color: #f5d76e; background: rgba(245, 215, 110, 0.08); }
.low { color: #58a6ff; background: rgba(88, 166, 255, 0.08); }
.info { color: #9b9b9b; background: rgba(155, 155, 155, 0.08); }

.findingTitle,
.findingContext,
.asset,
.assetMeta {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.findingTitle { color: var(--primary-text); margin-bottom: 0.25rem; }
.findingContext,
.assetMeta { color: #777; font-size: 0.7rem; }
.asset { color: #d7d7d7; font-family: "JetBrains Mono", monospace; margin-bottom: 0.2rem; }
.updated { color: #777 !important; font-size: 0.7rem !important; }
.openIcon { color: #555; }

.centerState,
.fullState {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  color: var(--secondary-text);
}

.fullState { height: 100%; }

.detailPage {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  container-type: inline-size;
}

.detailHeader {
  flex-shrink: 0;
  min-width: 0;
  padding: 1.2rem 1.5rem 1.3rem;
  background: #0d0d0d;
  border-bottom: 1px solid var(--border-subtle);
}

.backButton {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 1rem;
  padding: 0;
  color: var(--secondary-text);
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 0.75rem;

  &:hover { color: var(--primary-text); }
}

.detailTitleRow {
  min-width: 0;

  > div:first-child { flex: 1 1 auto; min-width: 0; }

  h1 {
    margin: 0.45rem 0 0.25rem;
    max-width: 820px;
    font-size: 1.65rem;
    line-height: 1.2;
    letter-spacing: -0.035em;
  }

  p {
    margin: 0;
    overflow-wrap: anywhere;
    color: var(--secondary-text);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.75rem;
  }
}

.detailBadges { display: flex; align-items: center; gap: 0.45rem; }
.exploited { color: #ff5c5c; border-color: rgba(255, 92, 92, 0.4); }

.scoreGrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(76px, 1fr));
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: 9px;

  div {
    padding: 0.7rem 0.85rem;
    border-right: 1px solid var(--border-subtle);
    &:last-child { border-right: 0; }
  }

  span,
  strong { display: block; }
  span { margin-bottom: 0.2rem; color: #666; font-size: 0.58rem; font-weight: 700; text-transform: uppercase; }
  strong { font-size: 0.85rem; white-space: nowrap; }
}

.detailBody {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 38%);
  width: 100%;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.findingDocument {
  min-width: 0;
  overflow-y: auto;
  padding: 1.5rem;
}

.detailSection {
  margin-bottom: 1rem;
  padding: 1.1rem 1.2rem;
  background: #0d0d0d;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;

  h2 {
    margin: 0 0 0.7rem;
    color: #888;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
}

.sectionContent { color: #d0d0d0; font-size: 0.86rem; line-height: 1.65; white-space: pre-wrap; }

.evidence {
  overflow-x: auto;
  padding: 0.85rem;
  color: #b7e4a8;
  background: #050705;
  border: 1px solid rgba(126, 231, 135, 0.14);
  border-radius: 7px;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.73rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.steps {
  margin: 0;
  padding-left: 1.25rem;
  li { margin-bottom: 0.55rem; padding-left: 0.35rem; }
}

.chatPanel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #080808;
  border-left: 1px solid var(--border-subtle);
}

.chatHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  min-width: 0;
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);

  > div { min-width: 0; }
  h2 { margin: 0.2rem 0 0; font-size: 0.95rem; line-height: 1.3; }
  > span { color: #666; font-size: 0.7rem; }
}

.chatMessages {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 1.25rem;

  &::-webkit-scrollbar { width: 8px; }
  &::-webkit-scrollbar-track { background: transparent; }
  &::-webkit-scrollbar-thumb {
    background: #343434;
    border: 2px solid #080808;
    border-radius: 999px;
  }
}

.chatEmpty {
  margin: 2rem auto;
  max-width: 310px;
  color: #666;
  font-size: 0.78rem;
  line-height: 1.55;
  text-align: center;
}

.chatMessage {
  flex: 0 0 auto;
  width: 100%;
  max-width: 720px;
  box-sizing: border-box;
  min-width: 0;
  margin-bottom: 0.85rem;
  padding: 0.9rem 1rem;
  border-radius: 9px;
  color: #d6d6d6;
  font-size: 0.8rem;
  line-height: 1.55;
}

.user {
  align-self: flex-end;
  width: fit-content;
  max-width: min(82%, 560px);
  margin-left: auto;
  padding: 0.75rem 0.9rem;
  background: rgba(142, 53, 255, 0.15);
  border: 1px solid rgba(142, 53, 255, 0.25);
}

.assistant {
  align-self: flex-start;
  margin-right: auto;
  background: #111;
  border: 1px solid var(--border-subtle);
}

.chatRole {
  display: block;
  margin-bottom: 0.35rem;
  color: #777;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.chatMarkdown {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;

  > :first-child { margin-top: 0; }
  > :last-child { margin-bottom: 0; }

  p { margin: 0 0 0.7rem; }
  ol,
  ul {
    margin: 0.45rem 0 0.8rem;
    padding-left: 1.35rem;
  }
  li {
    margin: 0.35rem 0;
    padding-left: 0.15rem;
  }
  li > p { margin: 0; }
  pre {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0.7rem 0;
    padding: 0.75rem 0.85rem;
    overflow-x: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: #090909;
    border: 1px solid var(--border-subtle);
    border-radius: 7px;
  }
  code {
    color: #c8a6ff;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.92em;
    white-space: break-spaces;
    overflow-wrap: anywhere;
  }
  blockquote {
    margin: 0.7rem 0;
    padding-left: 0.8rem;
    color: var(--secondary-text);
    border-left: 2px solid var(--primary-purple);
  }
}

.thinking { display: flex; align-items: center; gap: 0.5rem; color: #888; }

.chatComposer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.65rem;
  width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
  min-width: 0;
  // Keep the global feedback launcher from covering the send action.
  padding: 0.85rem 5rem 0.85rem 0.85rem;
  border-top: 1px solid var(--border-subtle);

  :global(.ant-input-textarea-affix-wrapper),
  :global(textarea) {
    color: var(--primary-text) !important;
    background: #101010 !important;
    border-color: var(--border-default) !important;
  }

  :global(.ant-input-textarea-affix-wrapper) { min-width: 0; }
  :global(textarea) { resize: none; }

  :global(.ant-btn-primary) {
    background: var(--filled-purple);
  }

  :global(.ant-btn-primary:disabled) {
    color: rgba(255, 255, 255, 0.38);
    background: rgba(142, 53, 255, 0.32);
    border-color: rgba(142, 53, 255, 0.4);
  }
}

.sendButton {
  min-width: 82px;
  height: 40px !important;
  padding-inline: 1rem;
  border-radius: 8px;
}

@container (max-width: 1020px) {
  .detailBody {
    grid-template-columns: minmax(0, 1fr);
    overflow-y: auto;
  }

  .findingDocument { overflow: visible; }

  .chatPanel {
    height: min(720px, 76dvh);
    min-height: 540px;
    border-top: 1px solid var(--border-subtle);
    border-left: 0;
  }

  .chatMessage { max-width: 820px; }
}

@media (max-width: 1100px) {
  .page { padding: 1.25rem; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .header,
  .detailTitleRow,
  .toolbar { flex-direction: column; }
  .search,
  .filter { width: 100%; max-width: none; }
  .scoreGrid { width: 100%; }
  .chatMessages { padding: 0.85rem; }
  .chatComposer { padding: 0.75rem 4.5rem 0.75rem 0.75rem; }
  .sendButton { min-width: 52px; padding-inline: 0.8rem; }
}
