:root {
  /* Epicor Kinetic palette */
  --bg: #f8f9fa;
  --surface: #ffffff;
  --surface-hover: #f0f0f0;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-muted: #5a5a5a;
  --accent: #0078d4;
  --accent-teal: #005578;
  --accent-hover: #106ebe;
  --success: #107c10;
  --error: #d13438;
  --radius: 4px;
  --font-sans: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --font-mono: 'Consolas', 'Cascadia Code', monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
}

/* Header - Epicor style */
.header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.logo-icon {
  font-size: 1.5rem;
  color: var(--accent-teal);
}

.logo h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text);
}

.logo-badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  font-weight: 500;
}

.header-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.header-content {
  position: relative;
}

.header-buttons {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-btn,
.catalog-toggle,
.conversation-toggle,
.filter-logic-toggle,
.admin-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2rem;
  margin: 0;
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  box-sizing: border-box;
  text-decoration: none;
  -webkit-appearance: none;
  appearance: none;
}

.header-btn:hover,
.catalog-toggle:hover,
.conversation-toggle:hover,
.filter-logic-toggle:hover,
.admin-link:hover {
  color: var(--accent);
  background: var(--surface-hover);
}

/* Fly-out */
.catalog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 100;
}

.catalog-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.catalog-flyout {
  position: fixed;
  top: 0;
  right: 0;
  width: 500px;
  max-width: 95vw;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -2px 0 12px rgba(0, 0, 0, 0.1);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 101;
  display: flex;
  flex-direction: column;
}

.catalog-flyout.is-open {
  transform: translateX(0);
}

.catalog-flyout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.catalog-flyout-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.catalog-close {
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s;
}

.catalog-close:hover {
  color: var(--text);
}

.conversation-flyout-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.conversation-info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.conversation-info-btn:hover {
  color: var(--accent-teal);
  border-color: var(--accent-teal);
  background: rgba(0, 85, 120, 0.06);
}

.conversation-info-panel {
  padding: 1rem 1.5rem;
  margin: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.5;
}
.conversation-info-panel p {
  margin: 0 0 0.5rem;
}
.conversation-info-panel p:last-child {
  margin-bottom: 0;
}

.conversation-flyout .conversation-clear {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.conversation-flyout .conversation-clear:hover {
  color: var(--error);
  border-color: var(--error);
}

.conv-fav-btn {
  margin-left: 0.25rem;
  padding: 0 0.25rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  transition: color 0.2s;
}
.conv-fav-btn:hover {
  color: var(--accent-teal);
}

.favorite-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.favorite-item:last-child {
  margin-bottom: 0;
}
.favorite-q {
  flex: 1;
  font-size: 0.9rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.favorite-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}
.favorite-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s;
}
.favorite-copy:hover {
  color: var(--accent-teal);
}
.favorite-copy svg {
  display: block;
}
.favorite-ask {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  background: var(--accent-teal);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
}
.favorite-ask:hover {
  background: #004060;
}
.favorite-remove {
  padding: 0 0.35rem;
  font-size: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s;
}
.favorite-remove:hover {
  color: var(--error);
}

.catalog-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
}

.catalog-item {
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.catalog-item:last-child {
  margin-bottom: 0;
}

.catalog-item-name {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-teal);
  margin: 0 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.catalog-item-info {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.15rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.catalog-item-info:hover {
  color: var(--accent);
  background: var(--surface-hover);
}

.catalog-item-columns {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.catalog-columns-title {
  margin: 0 0 0.35rem;
  font-weight: 600;
  color: var(--text);
}

.catalog-columns-list {
  margin: 0;
  padding-left: 1.25rem;
  max-height: 200px;
  overflow-y: auto;
}

.catalog-columns-empty,
.catalog-columns-error {
  margin: 0;
  font-style: italic;
}

.catalog-item-desc {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.catalog-empty {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.filter-logic-list .filter-logic-item {
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.filter-logic-list .filter-logic-item:last-child {
  margin-bottom: 0;
}

.filter-logic-list .filter-logic-category {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-teal);
  margin: 0 0 0.5rem;
}

.filter-logic-list .filter-logic-examples {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.validation-content {
  padding: 1rem;
}
.validation-question {
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--surface);
  border-radius: var(--radius);
  border-left: 3px solid var(--accent-teal);
}
.validation-output-type {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.validation-items {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.validation-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 0.9rem;
}
.validation-label {
  font-weight: 600;
  color: var(--text-muted);
  min-width: 6rem;
}
.validation-value {
  color: var(--text);
}

.validation-section {
  margin-bottom: 1.25rem;
}
.validation-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 0 0 0.5rem;
}
.validation-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.9rem;
}
.validation-list li {
  padding: 0.35rem 0.75rem;
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 0.25rem;
}
.validation-baq-id {
  font-weight: 600;
  color: var(--accent-teal);
}
.validation-section-warn .validation-section-title {
  color: var(--warning, #b8860b);
}
.validation-section-tip .validation-note {
  font-size: 0.9rem;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem;
  background: rgba(0, 150, 136, 0.08);
  border-radius: var(--radius);
  border-left: 3px solid var(--accent-teal);
  margin: 0;
}
.validation-note {
  font-size: 0.9rem;
  margin: 0;
}
.validation-note-muted {
  color: var(--text-muted);
  font-size: 0.8rem;
}
.validation-status {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
}
.validation-empty {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 0;
}

.filter-logic-list .filter-logic-examples li {
  margin-bottom: 0.2rem;
}

/* Ask form */
.ask-section {
  margin-bottom: 2rem;
}

.ask-form {
  width: 100%;
}

/* BAQ dropdown and column pills */
.baq-select-row {
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.baq-select-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}
.baq-select {
  font-size: 0.9rem;
  padding: 0.35rem 2rem 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  max-width: 320px;
}
.baq-select:focus {
  outline: none;
  border-color: var(--accent-teal);
}
.column-pills-wrap {
  margin-bottom: 0.75rem;
  padding: 0.5rem 0;
}
.column-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.column-pill {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.column-pill:hover {
  background: var(--surface-hover);
  border-color: var(--accent-teal);
}
.column-pills-more {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  background: transparent;
  border: none;
  color: var(--accent-teal);
  cursor: pointer;
  text-decoration: underline;
}
.column-pills-more:hover {
  color: var(--accent-hover);
}

/* @ column picker popover - only visible when BAQ selected and user types @ */
.at-column-popover[hidden] {
  display: none !important;
}
.at-column-popover {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 100;
  max-height: 240px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.at-column-filter {
  padding: 0.5rem 0.75rem;
  border: none;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  width: 100%;
}
.at-column-filter:focus {
  outline: none;
}
.at-column-list {
  overflow-y: auto;
  max-height: 180px;
}
.at-column-item {
  padding: 0.4rem 0.75rem;
  font-size: 0.875rem;
  cursor: pointer;
}
.at-column-item:hover,
.at-column-item.selected {
  background: var(--surface-hover);
}

.input-group {
  display: flex;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group:focus-within {
  border-color: var(--accent-teal);
  box-shadow: 0 0 0 2px rgba(0, 85, 120, 0.15);
}

.question-input-wrapper {
  position: relative;
  flex: 1;
  display: flex;
}

.question-clear-x {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 1;
  width: 0rem;
  height: 0rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 2px;
  transition: color 0.2s, background 0.2s;
}

.question-clear-x:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.06);
}

.question-clear-x.hidden {
  visibility: hidden;
  pointer-events: none;
}

.question-validate-btn {
  position: absolute;
  bottom: 0.5rem;
  left: 0.5rem;
  z-index: 1;
  width: 0rem;
  height: 0rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 2px;
  transition: color 0.2s, background 0.2s;
}

.question-validate-btn:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.06);
}

.question-validate-btn.hidden {
  visibility: hidden;
  pointer-events: none;
}

.question-validate-btn svg {
  flex: 0 0 auto;
}

.input-group textarea {
  flex: 1;
  min-height: 3rem;
  padding: 0.75rem 1rem 2rem 2.25rem;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  resize: none;
}

.input-group textarea::placeholder {
  color: var(--text-muted);
}

.input-group textarea:focus {
  outline: none;
}

.btn-submit {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--accent-teal);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-submit:hover:not(:disabled) {
  background: #004060;
}

.btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-clear {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.btn-clear:hover {
  color: var(--text);
  border-color: var(--text-muted);
  background: var(--surface);
}

.btn-icon {
  font-size: 1.1rem;
}

.hint {
  margin: 0.5rem 0 0 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.hint-try {
  margin-top: 0.25rem;
  font-style: italic;
}

/* Results */
.conversation-section {
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.conversation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.conversation-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
}

.conversation-clear {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.conversation-clear:hover {
  color: var(--error);
  border-color: var(--error);
}

.conversation-list,
.conversation-list-inner {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.conversation-item {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.conversation-item:last-child {
  border-bottom: none;
}

.conversation-q {
  color: var(--text);
  margin-bottom: 0.25rem;
}

.conversation-a {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.conv-label {
  font-weight: 600;
  color: var(--accent);
  margin-right: 0.25rem;
}

.conv-baq {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.results-section,
.error-section {
  margin-bottom: 2rem;
}

.result-card,
.error-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.result-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.result-baq {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.result-status {
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.result-feedback {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-right: 0.5rem;
}
.result-feedback .feedback-btn {
  background: none;
  border: none;
  padding: 0.2rem;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.7;
  border-radius: 2px;
}
.result-feedback .feedback-btn:hover {
  opacity: 1;
}
.result-feedback .feedback-btn:disabled {
  cursor: default;
  opacity: 0.5;
}
.result-feedback .feedback-thanks {
  font-size: 0.75rem;
  color: var(--success);
}
.feedback-followup {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
}
.feedback-followup-label {
  color: var(--text-muted);
  margin-right: 0.15rem;
}
/* Pills for "What made this helpful?" (thumbs up) - reuse column-pill styling, scoped to override any parent button resets */
.feedback-followup-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}
.result-feedback .feedback-followup-pills .column-pill,
.result-feedback .feedback-followup-pills .feedback-pill {
  font-size: 0.8rem;
  padding: 0.25rem 0.55rem;
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 999px !important;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.result-feedback .feedback-followup-pills .column-pill:hover,
.result-feedback .feedback-followup-pills .feedback-pill:hover {
  background: var(--surface-hover, rgba(0, 0, 0, 0.03)) !important;
  border-color: var(--accent-teal) !important;
}
.result-feedback .feedback-followup-pills .column-pill.feedback-skip,
.result-feedback .feedback-followup-pills .feedback-pill.feedback-skip {
  opacity: 0.7;
}
.feedback-followup-btn {
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  color: var(--text);
  white-space: nowrap;
}
.feedback-followup-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.feedback-followup-btn.feedback-skip {
  opacity: 0.7;
}

.result-confidence {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.result-status.success {
  background: rgba(16, 124, 16, 0.15);
  color: var(--success);
}

.result-status.error {
  background: rgba(209, 52, 56, 0.15);
  color: var(--error);
}

.clarification-links {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.clarification-links .clarification-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.clarification-links .clarification-link:hover {
  text-decoration: underline;
  color: var(--accent-hover);
}

.clarification-rephrase {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.clarification-rephrase-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.clarification-rephrase-link:hover {
  text-decoration: underline;
  color: var(--accent-hover);
}

.clarification-freetext {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.clarification-freetext label {
  flex: 0 0 100%;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.clarification-freetext-input {
  flex: 1 1 12rem;
  min-width: 10rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.95rem;
}
.clarification-freetext-btn {
  padding: 0.4rem 0.8rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
}
.clarification-freetext-btn:hover {
  background: var(--accent-hover);
}

.result-status.clarification {
  background: rgba(0, 120, 212, 0.15);
  color: var(--accent);
}

.result-cache-icon {
  font-size: 1.1rem;
  margin-left: 0.25rem;
  opacity: 1;
  flex-shrink: 0;
  display: inline-block;
}
.result-cache-icon[hidden] {
  display: none !important;
}

.result-body {
  color: var(--text);
  word-break: break-word;
}

.result-body:not(.markdown) {
  white-space: pre-wrap;
}

.result-body.markdown {
  line-height: 1.7;
}

.result-body.markdown p {
  margin: 0 0 0.75rem;
}

.result-body.markdown p:last-child {
  margin-bottom: 0;
}

.result-body.markdown strong {
  font-weight: 600;
  color: var(--accent-teal);
}

.result-body.markdown table,
.result-body .ai-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.9rem;
  display: table;
}

.result-body.markdown th,
.result-body.markdown td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border: 1px solid var(--border);
}

.result-body.markdown th {
  background: var(--surface-hover);
  font-weight: 600;
  color: var(--text);
}

.result-body.markdown tr:nth-child(even) td {
  background: rgba(0, 0, 0, 0.02);
}

.result-summary {
  margin-bottom: 1rem;
}

.result-stats {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.result-stats-title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.stat-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.stat-column {
  font-family: var(--font-mono);
  color: var(--text-muted);
  min-width: 140px;
}

.stat-values {
  color: var(--text);
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.85em;
}

.result-summary p:last-child,
.result-table-wrap {
  margin-bottom: 0;
}

.result-table-title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.result-table-wrap {
  overflow-x: auto;
  margin-top: 1rem;
}

.result-table-wrap table {
  margin: 0;
  table-layout: auto;
  min-width: max-content;
}

.result-table-wrap th,
.result-table-wrap td {
  white-space: nowrap;
  padding: 0.5rem 0.75rem;
  text-align: left;
  border: 1px solid var(--border);
  min-width: 4rem;
}

.result-table-wrap th {
  background: var(--surface-hover);
  font-weight: 600;
  color: var(--text);
}

.result-table-wrap tbody tr:nth-child(even) td {
  background: rgba(0, 0, 0, 0.02);
}

.result-truncation-note {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.result-expand-link {
  color: var(--accent);
  text-decoration: none;
  margin-left: 0.5rem;
}

.result-expand-link:hover {
  text-decoration: underline;
  color: var(--accent-hover);
}

.result-body .mermaid {
  display: flex;
  justify-content: center;
  margin: 1.5rem 0;
  min-height: 200px;
}

.result-body .mermaid svg {
  max-width: 100%;
  height: auto;
}

.result-body .mermaid-error {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.result-chart-wrap {
  margin-top: 1.5rem;
  max-width: 100%;
  position: relative;
  height: 300px;
}

.chart-error {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0.5rem 0 0;
}

.result-chart-wrap canvas {
  max-height: 300px;
}

/* Bedrock prompts (dev and prod) */
.bedrock-debug {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: linear-gradient(135deg, var(--surface) 0%, color-mix(in srgb, var(--surface) 90%, var(--bg)) 100%);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.bedrock-debug summary {
  cursor: pointer;
  list-style: none;
}

.bedrock-debug summary::-webkit-details-marker {
  display: none;
}

.bedrock-debug-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.95rem;
}

.bedrock-debug-summary-icon {
  display: inline-block;
  font-size: 0.65rem;
  transition: transform 0.2s ease;
  color: var(--text-muted);
}

.bedrock-debug[open] .bedrock-debug-summary-icon {
  transform: rotate(90deg);
}

.bedrock-debug-performance {
  margin-top: 0.75rem;
  margin-bottom: 1rem;
  padding: 1rem 1.25rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.bedrock-debug-performance h5 {
  margin: 0 0 0.5rem 0;
  font-size: 0.95rem;
  color: var(--text);
}
.bedrock-debug-performance .perf-steps {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.85rem;
}
.bedrock-debug-performance .perf-steps li {
  margin-bottom: 0.35rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
}
.bedrock-debug-performance .perf-label {
  flex: 1;
  min-width: 0;
}
.bedrock-debug-performance .perf-duration {
  flex-shrink: 0;
  font-family: var(--font-mono);
  color: var(--accent);
}
.bedrock-debug-performance .perf-note {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.bedrock-debug-performance .perf-skipped {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}
.bedrock-debug-performance .perf-total {
  margin: 0.75rem 0 0 0;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

.bedrock-debug-intro {
  margin-top: 0.75rem;
  padding: 0.5rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.bedrock-debug-items {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: relative;
}

.bedrock-debug-items::before {
  content: "";
  position: absolute;
  left: calc(1.75rem - 1px);
  top: 1.75rem;
  bottom: 1rem;
  width: 2px;
  background: linear-gradient(to bottom, var(--accent) 0%, var(--border) 100%);
  opacity: 0.35;
  border-radius: 1px;
  z-index: 0;
}

.bedrock-debug-item {
  position: relative;
  z-index: 1;
  padding: 1rem 1.25rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.bedrock-debug-item-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.bedrock-debug-num {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 50%;
}

.bedrock-debug-item h5 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.bedrock-debug-tip {
  margin: 0 0 0.75rem;
  padding-left: 2.25rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  font-style: italic;
}

.bedrock-debug-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.15rem 0.45rem;
  font-size: 0.62rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: color-mix(in srgb, var(--text-muted) 12%, transparent);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.bedrock-debug-logic .bedrock-debug-num {
  color: var(--text-muted);
  background: color-mix(in srgb, var(--text-muted) 10%, transparent);
  border-color: var(--border);
}

.bedrock-debug-logic .bedrock-debug-prompt {
  border-left: 3px solid var(--text-muted);
}

.bedrock-debug-sections {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.bedrock-debug-section {
  margin: 0;
}

.bedrock-debug-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.bedrock-debug-prompt,
.bedrock-debug-response {
  margin: 0;
  padding: 0.65rem 0.85rem;
  background: var(--surface);
  border-radius: 6px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--text-muted);
  border: 1px solid transparent;
}

.bedrock-debug-prompt {
  border-left: 3px solid color-mix(in srgb, var(--accent) 60%, transparent);
}

.bedrock-debug-response {
  border-left: 3px solid var(--success);
}

.error-card p {
  margin: 0;
  color: var(--error);
}

/* Footer */
.footer {
  margin-top: auto;
  padding-top: 2rem;
  padding-bottom: 5px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer p {
  margin: 0;
}

/* Epicor embed-only: full-screen overlay when app must be opened from Epicor */
.embed-block-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.embed-block-overlay[hidden] {
  display: none !important;
}

.embed-block-message {
  max-width: 400px;
  padding: 2rem;
  text-align: center;
}

.embed-block-message h2 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  color: var(--text);
}

.embed-block-message p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.6;
}
