* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f4f6f8;
  color: #1c1f24;
  display: flex;
  flex-direction: column;
}
header {
  background: #1c2733;
  color: #fff;
  padding: 10px 16px;
  border-bottom: 3px solid #16a34a;
}
header h1 { margin: 0; font-size: 1.15rem; }
.header-row { display: flex; justify-content: space-between; align-items: center; max-width: 1200px; margin: 0 auto; }
.muted { color: #c8d1dc; }
.badges { display: flex; gap: 6px; }
.badge { padding: 3px 8px; border-radius: 999px; font-size: 0.75rem; }
.badge-on { background: #14532d; color: #d1fae5; }
.badge-off { background: #3a3a3a; color: #cbd5e1; }

.chat-shell {
  flex: 1;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
  min-height: 0;
}
.chat-side, .chat-main {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.chat-side { padding: 12px; overflow: auto; }
.chat-side summary { font-weight: 600; cursor: pointer; color: #166534; }
.actions-col { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.ghost {
  background: transparent; color: #166534; border: 1px solid #86efac;
  padding: 6px 10px; border-radius: 6px; cursor: pointer;
}
.example-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.example {
  text-align: left; border: 1px solid #e2e8f0; background: #f8fafc;
  border-radius: 6px; padding: 6px 8px; font-size: 0.82rem; cursor: pointer;
}
.example:hover { background: #ecfdf5; border-color: #86efac; }

.chat-main { display: flex; flex-direction: column; min-height: 0; }
.chat-history {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.composer { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid #e2e8f0; }
.composer input { flex: 1; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 1rem; }
.composer button {
  background: #16a34a; color: #fff; border: none;
  padding: 10px 18px; border-radius: 6px; cursor: pointer;
}
.composer button:disabled { background: #9ca3af; }

.bubble {
  max-width: 92%; padding: 10px 14px; border-radius: 14px;
  font-size: 0.95rem; white-space: pre-wrap; word-break: break-word;
}
.bubble.user { align-self: flex-end; background: #16a34a; color: #fff; border-bottom-right-radius: 4px; }
.bubble.bot { align-self: flex-start; background: #f1f5f9; color: #0f172a; border-bottom-left-radius: 4px; width: 100%; }
.bubble.bot.error { background: #fef2f2; border: 1px solid #fecaca; color: #7f1d1d; }
.bubble.bot .meta { display: block; font-size: 0.72rem; color: #64748b; margin-top: 6px; font-family: monospace; }

.disambiguation { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.disambig-label { font-size: 0.82rem; color: #334155; font-weight: 600; }
.disambig-btn {
  text-align: left; border: 1px solid #cbd5e1; background: #fff;
  border-radius: 8px; padding: 8px 10px; font-size: 0.82rem; cursor: pointer;
}
.disambig-btn:hover { background: #ecfdf5; border-color: #86efac; }

.fld-missing { color: #dc2626; font-weight: 600; }
.bubble.bot .answer-html hr { border: none; border-top: 1px solid #e2e8f0; margin: 10px 0; }

.action-buttons { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.action-btn {
  border: 1px solid #cbd5e1; background: #fff; border-radius: 8px;
  padding: 8px 12px; font-size: 0.82rem; cursor: pointer;
}
.action-btn:hover { background: #f1f5f9; }
.action-primary { background: #16a34a; color: #fff; border-color: #16a34a; }
.action-primary:hover { background: #15803d; }
.action-danger { color: #b91c1c; border-color: #fecaca; }
.action-danger:hover { background: #fef2f2; }
.action-secondary { background: #f8fafc; }
.action-hint { font-style: italic; color: #475569; }

.loader { display: inline-block; width: 14px; height: 14px; border: 2px solid #cbd5e1; border-top-color: #16a34a; border-radius: 50%; animation: spin 0.8s linear infinite; margin-right: 6px; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

.debug-block { margin-top: 8px; font-size: 0.72rem; }
.debug-block pre { background: #0f172a; color: #e2e8f0; padding: 8px; border-radius: 6px; overflow: auto; max-height: 200px; }
.debug-block.hidden { display: none; }

.table-wrap { margin-top: 10px; overflow-x: auto; max-width: 100%; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.table-wrap th, .table-wrap td { border: 1px solid #e2e8f0; padding: 6px 8px; text-align: left; }
.table-wrap th { background: #f1f5f9; font-weight: 600; }
.table-wrap tr:nth-child(even) { background: #f8fafc; }

@media (max-width: 800px) {
  .chat-shell { grid-template-columns: 1fr; }
  .chat-side { display: none; }
}
