[hidden] { display: none !important; }
.admin-main { max-width: 1800px; }
.admin-logo { max-width: 48vw; object-fit: contain; }
.admin-logo-lg { max-width: 85vw; object-fit: contain; }
.chat-beta {
  display: inline-flex; padding: .25rem .625rem; border: 1px solid #f472b6;
  border-radius: .5rem; background: #be185d; color: #fff; font-size: .75rem; font-weight: 600;
}
.chat-flow-dialog {
  position: fixed; width: min(46rem, calc(100% - 2rem)); max-width: none; max-height: calc(100% - 2rem);
  padding: 2rem; border: 1px solid var(--admin-line); border-radius: .75rem;
  background: #f4f9fa; color: var(--admin-ink);
}
.chat-flow-dialog::backdrop { background: rgb(16 36 58 / 60%); }
.chat-flow-close { position: absolute; top: 1rem; right: 1rem; }
.chat-flow-header { text-align: center; }
.chat-flow-header h2 { margin: .75rem 0 2.5rem; font-size: 1.5rem; font-weight: 700; }
.chat-flow-header h2::after { content: ""; display: block; width: 4.5rem; height: 3px; margin: .625rem auto 0; background: var(--admin-teal); }
.chat-flow-diagram { position: relative; margin-right: 2.5rem; }
.chat-flow-steps { display: grid; gap: 1.25rem; padding: 0; margin: 0; list-style: none; }
.chat-flow-steps li {
  position: relative; display: flex; gap: .75rem; align-items: flex-start; padding: 1rem;
  border: 1px solid #b1c7ce; border-radius: .75rem; background: #fff;
  box-shadow: 0 2px 5px rgb(16 36 58 / 10%);
}
.chat-flow-steps li:not(:last-child)::after {
  content: ""; position: absolute; z-index: 1; bottom: -1rem; left: 50%; transform: translateX(-50%);
  border-left: .625rem solid transparent; border-right: .625rem solid transparent; border-top: 1.1rem solid var(--admin-teal);
}
.chat-flow-number {
  display: grid; flex: 0 0 1.75rem; width: 1.75rem; height: 1.75rem; place-items: center;
  border-radius: 50%; background: #bcebed; font-size: .625rem; font-weight: 700;
}
.chat-flow-steps h3 { margin: .2rem 0 .75rem; font-size: .875rem; font-weight: 700; }
.chat-flow-steps p { margin: 0; font-size: .8125rem; }
.chat-flow-refine {
  position: absolute; top: 2.5rem; right: -2rem; bottom: 2.5rem; width: 2rem;
  border-top: 2px dashed #eaa326; border-right: 2px dashed #eaa326; border-bottom: 2px dashed #eaa326;
}
.chat-flow-refine::before {
  content: ""; position: absolute; top: -.625rem; left: 0; border-top: .55rem solid transparent;
  border-bottom: .55rem solid transparent; border-right: 1rem solid #eaa326;
}
.chat-flow-refine span {
  position: absolute; top: 50%; right: -.9rem; transform: translateY(-50%);
  writing-mode: vertical-rl; rotate: 180deg; background: #f4f9fa; color: #9c6100; font-size: .625rem; font-weight: 700;
}
.chat-history { display: flex; flex-direction: column; gap: .75rem; margin-top: 1rem; }
.chat-history:empty { display: none; }
.chat-message {
  align-self: flex-start; max-width: 90%; padding: .75rem 1rem; border: 1px solid var(--admin-line);
  border-radius: .875rem; background: var(--admin-paper); color: var(--admin-ink); font-size: .875rem;
}
.chat-message-user { align-self: flex-end; background: var(--admin-teal); border-color: var(--admin-teal); color: #fff; }
.chat-message-role { margin-bottom: .25rem; font-size: .75rem; font-weight: 600; opacity: .8; }
.chat-message-content { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-message-loading { display: flex; flex-direction: column; align-items: flex-start; gap: .375rem; }
.chat-thinking-line { display: flex; align-items: center; gap: .5rem; }
.chat-thinking-stage { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .75rem; }
.chat-composer { width: 100%; }
.chat-input-shell {
  display: flex; align-items: flex-end; gap: .75rem; padding: .5rem;
  background: var(--admin-paper); border: 1px solid var(--admin-line); border-radius: .75rem;
}
.chat-composer textarea {
  min-width: 0; width: 100%; min-height: 3.5rem; max-height: 10rem; resize: vertical;
  border: 0; padding: .5rem; background: transparent; color: var(--admin-ink); font: inherit; font-size: .875rem;
}
.chat-send { flex-shrink: 0; padding: .5rem; }
.chat-composer textarea:focus { outline: 0; }
.chat-input-shell:focus-within { border-color: var(--admin-teal); box-shadow: 0 0 0 .2rem rgb(8 126 139 / 15%); }
.chat-mode-tabs { display: flex; }
.chat-mode-tab {
  flex: 1; min-width: 0; padding: .5rem .75rem; border: 1px solid var(--admin-line);
  border-bottom: 0; border-radius: .75rem .75rem 0 0; background: #e9eef4; color: var(--admin-muted); font-size: .8125rem;
}
.chat-mode-tab + .chat-mode-tab { margin-left: -1px; }
.chat-mode-tab[aria-selected="true"] { background: var(--admin-teal-light); color: var(--admin-teal); font-weight: 600; }
.chat-mode-tabs:not([hidden]) + .chat-input-shell { border-top-left-radius: 0; border-top-right-radius: 0; }
#chat-form[aria-busy="true"] .chat-composer { display: none; }
.chat-result-actions { display: flex; flex-direction: column; align-items: flex-end; max-width: 100%; margin-left: auto; }
.chat-result-heading { flex: 1; min-width: 0; }
.chat-result-heading details { min-width: 0; }
.chat-result-heading details[open] { flex-basis: 100%; }
#chat-results [data-feedback-vote].is-selected { color: #fff; background: var(--admin-teal); }
.chat-export-menu { position: relative; }
.chat-export-menu summary { list-style: none; }
.chat-export-menu summary::-webkit-details-marker { display: none; }
.chat-export-options {
  position: absolute; right: 0; z-index: 10; display: flex; flex-direction: column;
  min-width: 11rem; padding: .5rem; border: 1px solid var(--admin-line); border-radius: .35rem;
  background: #fff; box-shadow: 0 3px 14px rgb(16 36 58 / 10%);
}
.chat-export-options button { text-align: left; }
#chat-export-status { box-sizing: border-box; width: 20rem; max-width: 100%; padding: 1rem; background: var(--admin-teal-light); overflow-wrap: anywhere; font-size: .875rem; }
.chat-feedback-fields { display: flex; flex-direction: column; gap: .5rem; }
.chat-feedback-fields input { flex: 1; min-width: 0; }
.chat-feedback-fields input, .chat-feedback-fields button { min-height: 2.75rem; }
#chat-report { width: 100%; height: 70vh; min-height: 360px; border: 0; margin-top: 8px; background: transparent; }
[data-result-sql] { overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
[data-result-table] { overflow-x: auto; }
@keyframes sync-loader-pulse { 50% { opacity: .4; box-shadow: 0 0 8px rgb(8 126 139 / 40%); } }
.sync-loader-icon {
  box-sizing: border-box; display: inline-block; width: 1.5rem; height: 1.5rem; border: 2px solid var(--admin-teal);
  border-radius: 50%; animation: sync-loader-pulse 2s ease-in-out infinite;
}
.sync-loader-icon-sm { width: .875rem; height: .875rem; border-width: 1.5px; }
@media (min-width: 992px) {
  .chat-composer { width: 50%; }
  .chat-feedback-fields { flex-direction: row; align-items: center; }
}
@media (max-width: 380px) {
  .admin-main { padding-inline: .5rem; } .card-body { padding: .75rem; }
  .chat-flow-dialog { padding: 1.5rem .75rem; }
}
@media (prefers-reduced-motion: reduce) { .sync-loader-icon { animation: none; } }
