.chat-panel {
  position: fixed; right: 0; bottom: 0; z-index: 150;
  width: 380px; max-width: 95vw;
  background: #fff;
  box-shadow: -4px 0 16px rgba(0,0,0,0.12);
  display: flex; flex-direction: column;
  border-top-left-radius: 12px;
  transition: transform 0.25s ease;
}

.chat-panel.collapsed { transform: translateY(calc(100% - 44px)); }

.chat-toggle {
  padding: 12px 16px;
  background: #1a365d; color: #fff;
  border-top-left-radius: 12px;
  cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600;
  user-select: none;
}
.chat-toggle-icon { font-size: 16px; }
.chat-panel:not(.collapsed) .chat-toggle { border-top-left-radius: 12px; }

.chat-body {
  display: flex; flex-direction: column;
  height: 500px; max-height: 70vh;
}

.chat-header {
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
  display: flex; justify-content: space-between; align-items: center;
}
.chat-header h3 { margin: 0; font-size: 13px; color: #4a5568; }
.chat-header .btn { padding: 4px 10px; font-size: 12px; }

.chat-messages {
  flex: 1; padding: 14px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
}

.chat-message {
  padding: 10px 12px; border-radius: 8px;
  font-size: 13px; line-height: 1.5;
  max-width: 85%;
  white-space: pre-wrap; word-wrap: break-word;
}
.chat-message-user {
  background: #3182ce; color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}
.chat-message-assistant {
  background: #edf2f7; color: #2d3748;
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}
.chat-message em { color: #718096; }
.chat-message strong { color: #1a365d; }

.chat-proposal {
  background: #fefcbf; border-left: 4px solid #d69e2e;
  padding: 12px 14px; border-radius: 6px;
  align-self: flex-start; max-width: 95%;
  font-size: 13px;
}
.chat-proposal-title {
  font-weight: 600; color: #744210; margin-bottom: 6px; font-size: 12px;
}
.chat-proposal-desc { color: #2d3748; margin-bottom: 10px; }
.chat-proposal-actions { display: flex; gap: 6px; }
.chat-proposal-actions .btn { padding: 6px 12px; font-size: 12px; }

.chat-form {
  padding: 10px 12px;
  border-top: 1px solid #e2e8f0;
  display: flex; gap: 8px;
}
.chat-form input {
  flex: 1; padding: 9px 12px;
  border: 1px solid #cbd5e0; border-radius: 6px;
  font-size: 13px;
}
.chat-form .btn { padding: 9px 14px; font-size: 13px; }

.chat-loading {
  align-self: flex-start; color: #718096; font-size: 12px;
  font-style: italic;
}

.flex-header { font-weight: 600; color: #1a365d; margin-bottom: 4px; font-size: 13px; }
.flex-sub { color: #718096; font-size: 11px; }
.flex-table { width: 100%; margin-top: 10px; border-collapse: collapse; font-size: 12px; }
.flex-table th {
  text-align: left; padding: 6px 8px; background: #edf2f7;
  color: #4a5568; font-size: 11px; text-transform: uppercase;
}
.flex-table td { padding: 8px; border-bottom: 1px solid #edf2f7; vertical-align: top; }
.flex-table tr.flex-best { background: #f0fff4; }
.flex-table tr.flex-best .flex-total { color: #22543d; font-weight: 700; }
.flex-table .flex-total { font-weight: 600; color: #1a365d; text-align: right; }
.chat-message a { color: #3182ce; text-decoration: underline; word-break: break-all; }
.chat-message-user a { color: #bee3f8; }

@media (max-width: 700px) {
  .chat-panel { width: 100vw; right: 0; left: 0; }
}
