* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: #0f1115;
  color: #e6e8eb;
  min-height: 100vh;
}

/* ===== Dashboard admin ===== */
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px; border-bottom: 1px solid #1f232b;
  position: sticky; top: 0; background: #0f1115; z-index: 10;
}
h1 { margin: 0; font-size: 18px; letter-spacing: 0.5px; }
h2 { margin: 0; font-size: 13px; color: #9aa4b2; text-transform: uppercase; letter-spacing: 1px; }
.status { display: flex; gap: 12px; align-items: center; font-size: 13px; }
.link-btn { color: #7aa7ff; text-decoration: none; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }
.badge { padding: 3px 8px; border-radius: 10px; background: #1f232b; font-size: 11px; }
.badge.ok { background: #14432a; color: #7ee2a8; }
.badge.ko { background: #4a1a1f; color: #f08080; }

.panel {
  margin: 16px 24px; background: #161a22; border: 1px solid #1f232b;
  border-radius: 8px; overflow: hidden;
}
.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid #1f232b; gap: 8px;
}
.panel-header select, .panel-header button, header button {
  background: #1f232b; color: #e6e8eb; border: 1px solid #2a2f3a;
  padding: 4px 10px; border-radius: 4px; font-size: 12px; cursor: pointer;
}
.panel-header button:hover, header button:hover { background: #2a2f3a; }
.subtle { opacity: 0.6; }
.tiny { background: transparent !important; border: none !important; color: #f08080 !important; font-size: 16px; cursor: pointer; }

.logs {
  margin: 0; padding: 12px 16px; height: 260px; overflow-y: auto;
  font-family: "SF Mono", Menlo, monospace; font-size: 12px;
  background: #0b0d12; color: #b7c1ce; white-space: pre-wrap; word-break: break-word;
}

.directives { list-style: none; margin: 0; padding: 8px 16px; }
.directives li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #1f232b; font-size: 14px; }
.directives li:last-child { border-bottom: none; }

.stats { padding: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat { background: #0b0d12; border: 1px solid #1f232b; border-radius: 6px; padding: 14px; text-align: center; }
.stat .num { font-size: 22px; font-weight: 600; color: #7ee2a8; }
.stat .lbl { font-size: 11px; color: #9aa4b2; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }
.last-lead { margin-top: 12px; font-size: 13px; color: #9aa4b2; padding: 8px 12px; background: #0b0d12; border-radius: 6px; }

.chat { height: 400px; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.45; }
.msg-text { white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: #2b5fdb; color: white; }
.msg.assistant { align-self: flex-start; background: #1f232b; color: #e6e8eb; }
.msg.pending { opacity: 0.5; }
.tool-calls { margin-top: 8px; font-size: 12px; }
.tool-calls summary { cursor: pointer; color: #9aa4b2; }
.tool-calls pre { background: #0b0d12; padding: 8px; border-radius: 4px; overflow-x: auto; font-size: 11px; max-height: 200px; overflow-y: auto; }

.chat-input {
  display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid #1f232b; background: #0f1115;
}
.chat-input textarea {
  flex: 1; background: #1f232b; color: #e6e8eb; border: 1px solid #2a2f3a;
  border-radius: 8px; padding: 10px 12px; font-size: 14px; resize: none; font-family: inherit;
}
.chat-input textarea:focus { outline: none; border-color: #2b5fdb; }
.chat-input button {
  width: 42px; height: 42px; border-radius: 50%; border: none;
  background: #2b5fdb; color: white; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.chat-input button:hover { background: #3b6fee; }

/* ===== Login ===== */
.center-screen { display: flex; align-items: center; justify-content: center; }
.login-card {
  background: #161a22; border: 1px solid #1f232b; border-radius: 12px;
  padding: 32px; width: 320px; display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { text-align: center; }
.login-card .muted { color: #9aa4b2; text-align: center; margin: 0; font-size: 13px; }
.login-card input {
  background: #0b0d12; color: #e6e8eb; border: 1px solid #2a2f3a;
  border-radius: 8px; padding: 10px 12px; font-size: 14px;
}
.login-card input:focus { outline: none; border-color: #2b5fdb; }
.login-card button {
  background: #2b5fdb; color: white; border: none; border-radius: 8px;
  padding: 10px; font-size: 14px; cursor: pointer;
}
.login-card button:hover { background: #3b6fee; }
.error { color: #f08080; font-size: 12px; min-height: 14px; text-align: center; }

/* ===== Chatbot public ===== */
.chatbot-body { background: #f5f7fa; color: #1a1e26; }
.chatbot-wrap {
  max-width: 640px; margin: 0 auto; min-height: 100vh;
  display: flex; flex-direction: column; background: white;
  box-shadow: 0 0 40px rgba(0,0,0,0.05);
}
.chatbot-header {
  padding: 16px 20px; border-bottom: 1px solid #e5e8ec;
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, #2d8f3f 0%, #4ab05c 100%); color: white;
  position: sticky; top: 0; z-index: 5;
}
.chatbot-header .brand { display: flex; align-items: center; gap: 12px; }
.chatbot-header .logo {
  width: 40px; height: 40px; border-radius: 50%;
  background: white; color: #2d8f3f;
  font-weight: 700; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
}
.chatbot-header .name { font-weight: 600; font-size: 15px; }
.chatbot-header .sub { font-size: 12px; opacity: 0.9; }

.chatbot-messages {
  flex: 1; overflow-y: auto; padding: 20px;
  display: flex; flex-direction: column; gap: 10px;
  background: #f5f7fa;
}
.bubble {
  max-width: 80%; padding: 10px 14px; border-radius: 16px; font-size: 15px; line-height: 1.45;
  white-space: pre-wrap; word-wrap: break-word;
}
.bubble.user { align-self: flex-end; background: #2d8f3f; color: white; border-bottom-right-radius: 4px; }
.bubble.assistant { align-self: flex-start; background: white; color: #1a1e26; border: 1px solid #e5e8ec; border-bottom-left-radius: 4px; }
.bubble.pending { opacity: 0.6; }

.chatbot-input {
  display: flex; gap: 8px; padding: 12px 16px;
  border-top: 1px solid #e5e8ec; background: white;
  position: sticky; bottom: 0;
}
.chatbot-input textarea {
  flex: 1; background: #f5f7fa; color: #1a1e26; border: 1px solid #e5e8ec;
  border-radius: 20px; padding: 10px 16px; font-size: 15px; resize: none;
  font-family: inherit; max-height: 120px;
}
.chatbot-input textarea:focus { outline: none; border-color: #2d8f3f; }
.chatbot-input button {
  width: 40px; height: 40px; border-radius: 50%; border: none; flex-shrink: 0;
  background: #2d8f3f; color: white; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.chatbot-input button:hover { background: #247030; }
