html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

.ia-app-body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top right, rgba(37, 99, 168, 0.08), transparent 30rem),
    #f5f7fa;
  color: #1f2933;
}

.ia-app-nav {
  border-bottom: 1px solid #d9e1ea;
  background: rgba(255, 255, 255, 0.94);
}

.ia-app-nav-content {
  width: min(100% - 32px, 1180px);
  min-height: 54px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #5f6b7a;
  font-size: 0.9rem;
}

.ia-app-brand {
  color: #172b4d;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
}

.ia-app-main {
  padding: 24px;
}

.ia-app-embedded .ia-app-main {
  padding: 18px;
}

.ia-shell {
  max-width: 1180px;
  margin: 0 auto;
}

.ia-app-embedded .ia-shell {
  max-width: 1440px;
}

.ia-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.ia-header h1 {
  font-size: 1.65rem;
  margin: 0;
  color: #172b4d;
}

.ia-header p {
  margin: 4px 0 0;
  color: #5f6b7a;
}

.ia-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ia-eyebrow {
  color: #2563a8;
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 3px;
  text-transform: uppercase;
}

.ia-session-summary {
  border-right: 1px solid #d9e1ea;
  display: grid;
  line-height: 1.2;
  padding-right: 12px;
  text-align: right;
}

.ia-session-summary strong {
  color: #202b36;
  font-size: 0.84rem;
}

.ia-session-summary span {
  color: #6b7280;
  font-size: 0.72rem;
}

.ia-status {
  border: 1px solid #b8d8c2;
  border-radius: 999px;
  color: #25633a;
  background: #edf8f0;
  font-size: 0.8rem;
  line-height: 1;
  padding: 7px 10px;
}

.ia-panel {
  border: 1px solid #d9e1ea;
  border-radius: 12px;
  background: #fff;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(23, 43, 77, 0.04);
}

.ia-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.ia-panel-heading h2 {
  font-size: 1rem;
  margin: 0;
}

.ia-panel-description {
  color: #5f6b7a;
  font-size: 0.875rem;
  margin: 6px 0 0;
  max-width: 720px;
}

.ia-session-loading {
  align-items: center;
  color: #5f6b7a;
  display: flex;
  gap: 10px;
  min-height: 72px;
}

.ia-login-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.ia-form-label-row {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 8px;
  min-height: 24px;
}

.ia-form-label-row .form-label {
  margin: 0;
}

.ia-field-origin {
  color: #2563a8;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.ia-conversation-layout {
  display: grid;
  gap: 16px;
}

.ia-welcome {
  align-items: center;
  background:
    linear-gradient(120deg, rgba(37, 99, 168, 0.08), rgba(255, 255, 255, 0.96) 54%);
  border: 1px solid #d9e4f0;
  border-radius: 14px;
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(220px, 0.65fr) minmax(420px, 1.35fr);
  padding: 22px;
}

.ia-welcome h2 {
  color: #172b4d;
  font-size: 1.35rem;
  margin: 0;
}

.ia-welcome p {
  color: #5f6b7a;
  margin: 6px 0 0;
}

.ia-shortcuts {
  display: grid;
  gap: 9px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ia-shortcut {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #d7e1ec;
  border-radius: 10px;
  color: #344054;
  display: grid;
  gap: 3px;
  min-height: 74px;
  padding: 11px 12px;
  text-align: left;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.ia-shortcut:hover,
.ia-shortcut:focus-visible {
  border-color: #76a7da;
  box-shadow: 0 6px 16px rgba(37, 99, 168, 0.1);
  outline: 0;
  transform: translateY(-1px);
}

.ia-shortcut strong {
  color: #244e78;
  font-size: 0.83rem;
}

.ia-shortcut span {
  color: #667085;
  font-size: 0.72rem;
  line-height: 1.35;
}

.ia-conversation-panel {
  background: #fff;
  border: 1px solid #d9e1ea;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(23, 43, 77, 0.05);
  min-width: 0;
  overflow: clip;
}

.ia-conversation-feed {
  display: grid;
  gap: 24px;
  min-height: 250px;
  padding: 24px;
}

.ia-turn-current,
.ia-turn-archived {
  display: grid;
  gap: 14px;
}

.ia-turn-archived {
  border-bottom: 1px solid #e7edf3;
  padding-bottom: 24px;
}

.ia-message {
  align-items: flex-start;
  display: flex;
  gap: 10px;
  min-width: 0;
}

.ia-message-user {
  justify-content: flex-end;
}

.ia-message-avatar {
  align-items: center;
  background: #e8f1fb;
  border: 1px solid #c9ddf2;
  border-radius: 50%;
  color: #2563a8;
  display: flex;
  flex: 0 0 32px;
  font-size: 0.68rem;
  font-weight: 800;
  height: 32px;
  justify-content: center;
}

.ia-message-bubble {
  background: #f7f9fc;
  border: 1px solid #e1e7ef;
  border-radius: 4px 13px 13px;
  max-width: min(88%, 980px);
  min-width: 0;
  padding: 12px 14px;
}

.ia-message-user .ia-message-bubble {
  background: #2563a8;
  border-color: #2563a8;
  border-radius: 13px 13px 4px 13px;
  color: #fff;
  max-width: min(75%, 760px);
  white-space: pre-wrap;
}

.ia-message-intro .ia-message-bubble {
  color: #475467;
}

.ia-answer-content {
  background: #fff;
  width: min(92%, 1040px);
}

.ia-answer-toolbar {
  align-items: center;
  border-bottom: 1px solid #e7edf3;
  color: #667085;
  display: flex;
  font-size: 0.72rem;
  font-weight: 700;
  justify-content: space-between;
  margin: -3px 0 12px;
  padding-bottom: 8px;
  text-transform: uppercase;
}

.ia-answer-toolbar-actions {
  align-items: center;
  display: flex;
  gap: 6px;
}

.ia-query-progress {
  align-items: center;
  background: #f5f9fe;
  border: 1px solid #d6e5f5;
  border-radius: 9px;
  color: #315b86;
  display: flex;
  gap: 11px;
  padding: 11px 12px;
}

.ia-query-progress > div:last-child {
  display: grid;
  gap: 1px;
}

.ia-query-progress strong {
  font-size: 0.82rem;
}

.ia-query-progress span {
  color: #667b91;
  font-size: 0.74rem;
}

.ia-query-context {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.ia-context-chip {
  background: #edf3fa;
  border: 1px solid #d6e2ef;
  border-radius: 999px;
  color: #3d5e80;
  font-size: 0.7rem;
  padding: 4px 8px;
}

.ia-context-chip-warning {
  background: #fff6df;
  border-color: #efd28a;
  color: #765408;
}

.ia-composer {
  align-items: end;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid #dfe6ee;
  bottom: 0;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 14px;
  position: sticky;
  z-index: 4;
}

.ia-composer textarea {
  max-height: 160px;
  min-height: 52px;
  resize: vertical;
}

.ia-composer-actions {
  display: flex;
  gap: 8px;
}

.ia-data-details {
  border: 1px solid #dfe6ee;
  border-radius: 9px;
  margin-top: 14px;
  overflow: hidden;
}

.ia-data-details summary {
  align-items: center;
  background: #f8fafc;
  color: #344054;
  cursor: pointer;
  display: flex;
  font-size: 0.82rem;
  font-weight: 650;
  justify-content: space-between;
  list-style: none;
  padding: 10px 12px;
}

.ia-data-details summary::-webkit-details-marker {
  display: none;
}

.ia-data-details summary::before {
  color: #2563a8;
  content: "›";
  font-size: 1.15rem;
  margin-right: 7px;
  transition: transform 120ms ease;
}

.ia-data-details[open] summary::before {
  transform: rotate(90deg);
}

.ia-data-details summary span {
  flex: 1;
}

.ia-data-details summary small {
  color: #7a8699;
  font-weight: 500;
}

.ia-data-details > :not(summary) {
  padding: 12px;
}

.ia-chart-snapshot {
  display: block;
  height: auto;
  max-width: 100%;
}

.ia-history-panel {
  grid-column: 1 / -1;
}

.ia-response-text {
  min-height: 0;
  white-space: pre-wrap;
  color: #1f2933;
}

.ia-response-blocks {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.ia-metrics-block h3,
.ia-chart-block h3,
.ia-structured-table h3,
.ia-sources h3 {
  color: #344054;
  font-size: 0.82rem;
  font-weight: 700;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.ia-chart-block {
  border: 1px solid #e1e7ef;
  border-radius: 10px;
  background: #fbfcfe;
  padding: 12px;
}

.ia-chart-canvas {
  height: clamp(260px, 35vh, 390px);
  position: relative;
}

.ia-metrics-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.ia-metric {
  background: #f7f9fc;
  border: 1px solid #e1e7ef;
  border-radius: 9px;
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 10px;
}

.ia-metric span {
  color: #667085;
  font-size: 0.72rem;
}

.ia-metric strong {
  color: #172b4d;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.ia-inline-alert {
  background: #eef6ff;
  border: 1px solid #c9dff6;
  border-radius: 8px;
  color: #244e78;
  display: grid;
  font-size: 0.82rem;
  gap: 3px;
  padding: 10px 12px;
}

.ia-inline-alert-warning {
  background: #fff8e7;
  border-color: #f1d58b;
  color: #714f05;
}

.ia-empty-response {
  color: #8492a6;
}

.ia-consultas {
  color: #5f6b7a;
  font-size: 0.875rem;
  margin-top: 12px;
}

.ia-sources {
  border-top: 1px solid #e7edf3;
  margin-top: 14px;
  padding-top: 12px;
}

.ia-sources-list {
  display: grid;
  gap: 7px;
}

.ia-source-item {
  align-items: start;
  display: grid;
  gap: 2px;
}

.ia-source-identification {
  align-items: center;
  display: flex;
  gap: 7px;
  min-width: 0;
}

.ia-source-identification a,
.ia-source-identification > span:last-child {
  color: #344054;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ia-source-identification a {
  color: #2563a8;
}

.ia-source-type {
  background: #edf3fa;
  border-radius: 999px;
  color: #315b86;
  flex: 0 0 auto;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  text-transform: uppercase;
}

.ia-source-meta {
  color: #7a8699;
  font-size: 0.7rem;
  padding-left: 2px;
}

.ia-suggested-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}

.ia-feedback {
  align-items: center;
  border-top: 1px solid #e7edf3;
  color: #667085;
  display: flex;
  font-size: 0.78rem;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
  padding-top: 10px;
}

.ia-feedback > div {
  display: flex;
  gap: 5px;
}

.ia-feedback-comment {
  background: #f8fafc;
  border: 1px solid #dfe6ee;
  border-radius: 9px;
  display: grid;
  gap: 7px;
  margin-top: 9px;
  padding: 10px;
}

.ia-feedback-comment label {
  color: #475467;
  font-size: 0.78rem;
  font-weight: 600;
}

.ia-feedback-comment label span {
  color: #7a8699;
  font-weight: 400;
}

.ia-feedback-comment > div {
  display: flex;
  gap: 7px;
  justify-content: flex-end;
}

.ia-feedback-registered {
  color: #25633a;
  font-weight: 600;
}

.ia-structured-tables {
  display: grid;
  gap: 18px;
}

.ia-structured-table + .ia-structured-table {
  border-top: 1px solid #e7edf3;
  padding-top: 16px;
}

.ia-structured-table-heading {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 8px;
}

.ia-structured-table-heading h3 {
  margin: 0;
}

.ia-structured-table-heading span {
  color: #6b7280;
  font-size: 0.75rem;
}

.ia-structured-table table {
  margin-bottom: 0;
}

.ia-table-group-row td {
  background: #edf3f8;
  border-top: 1px solid #d8e2eb;
  color: #29435c;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.015em;
  padding-bottom: 0.48rem;
  padding-top: 0.48rem;
}

.ia-table-group-level-2 td {
  background: #f5f8fb;
  border-top-color: #e2e9f0;
  color: #496277;
  font-size: 0.75rem;
  padding-left: 1.25rem;
}

.ia-cell-number {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.ia-empty {
  color: #6b7280;
  font-size: 0.92rem;
  padding: 6px 0;
}

.ia-history-list {
  display: grid;
  gap: 14px;
}

.ia-history-current {
  border: 1px solid #d9e1ea;
  border-radius: 8px;
  background: #fbfcfe;
  padding: 14px;
}

.ia-history-previous-title {
  color: #202b36;
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 2px;
}

.ia-history-group {
  border-top: 1px solid #e7edf3;
  padding-top: 12px;
}

.ia-history-group:first-child {
  border-top: 0;
  padding-top: 0;
}

.ia-history-group-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.ia-history-title {
  font-weight: 600;
  color: #202b36;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ia-history-date {
  color: #6b7280;
  font-size: 0.78rem;
  white-space: nowrap;
}

.ia-history-message {
  border-top: 1px solid #e7edf3;
  padding: 12px 0 0;
  margin-top: 12px;
}

.ia-history-message-meta,
.ia-history-consultas {
  color: #6b7280;
  font-size: 0.78rem;
}

.ia-history-label {
  color: #475467;
  font-size: 0.76rem;
  font-weight: 600;
  margin-top: 8px;
  text-transform: uppercase;
}

.ia-history-question-full,
.ia-history-answer-preview {
  color: #1f2933;
  white-space: pre-wrap;
  word-break: break-word;
}

.ia-history-answer-preview {
  color: #344054;
}

.ia-history-consultas,
.ia-history-message-actions {
  margin-top: 8px;
}

.ia-history-detail {
  margin-top: 8px;
}

.ia-history-detail summary {
  color: #2563a8;
  cursor: pointer;
  font-weight: 600;
  width: fit-content;
}

.ia-history-detail summary:hover,
.ia-history-detail summary:focus {
  color: #174d85;
}

.ia-history-full-answer {
  border: 1px solid #e7edf3;
  border-radius: 6px;
  background: #fff;
  color: #1f2933;
  margin-top: 8px;
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

.ia-history-table {
  margin-top: 10px;
}

.ia-history-table table {
  margin-bottom: 0;
}

@media (max-width: 760px) {
  .ia-app-main,
  .ia-app-embedded .ia-app-main {
    padding: 12px;
  }

  .ia-login-form,
  .ia-welcome,
  .ia-shortcuts,
  .ia-composer {
    grid-template-columns: 1fr;
  }

  .ia-welcome {
    padding: 16px;
  }

  .ia-shortcuts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ia-conversation-feed {
    padding: 16px 12px;
  }

  .ia-message-bubble,
  .ia-answer-content,
  .ia-message-user .ia-message-bubble {
    max-width: calc(100% - 6px);
    width: auto;
  }

  .ia-answer-content {
    width: calc(100% - 42px);
  }

  .ia-composer-actions {
    justify-content: flex-end;
  }

  .ia-header {
    flex-direction: column;
  }

  .ia-header-actions {
    justify-content: flex-start;
  }

  .ia-session-summary {
    border-right: 0;
    padding-right: 0;
    text-align: left;
    width: 100%;
  }

  .ia-chart-canvas {
    height: 280px;
  }

  .ia-history-group-header {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

@media (max-width: 480px) {
  .ia-shortcuts {
    grid-template-columns: 1fr;
  }

  .ia-composer-actions .btn {
    flex: 1;
  }
}
