* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0a0a0a;
  color: #f2f2f2;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
header {
  padding: 14px 20px;
  background: #0a0a0a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #262626;
}
header h1 {
  font-size: 18px; margin: 0; display: flex; align-items: center; gap: 10px;
  letter-spacing: 0.3px; text-transform: uppercase; font-weight: 800;
}
header h1 .brand-accent { color: #f2740c; }
.dot-cluster { display: inline-flex; gap: 3px; }
.dot-cluster span { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-cluster .d1 { background: #2a6df0; }
.dot-cluster .d2 { background: #e8344a; }
.dot-cluster .d3 { background: #f2740c; }
header nav { display: flex; align-items: center; gap: 8px; }
header nav a {
  color: #d4d4d4; text-decoration: none; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px;
  border: 1px solid #333; border-radius: 999px; padding: 7px 14px;
}
header nav a:hover { border-color: #f2740c; color: #f2740c; }
.nav-btn {
  background: none;
  border: 1px solid #333;
  color: #d4d4d4;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  cursor: pointer;
}
.nav-btn:hover { border-color: #f2740c; color: #f2740c; }
#chat-view, #stats-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.view-hidden { display: none !important; }
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg { max-width: 85%; padding: 11px 16px; border-radius: 14px; white-space: pre-wrap; line-height: 1.45; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, #f2740c, #d9600a); color: #0a0a0a; font-weight: 500; }
.msg.assistant { align-self: flex-start; background: #161616; border: 1px solid #2a2a2a; }
.msg.system { align-self: center; color: #8a8a8a; font-size: 13px; background: none; border: 1px dashed #333; }

.stats-wrap { padding: 24px; overflow-y: auto; }
.stats-wrap h2 { margin-top: 0; font-size: 18px; text-transform: uppercase; letter-spacing: 0.4px; }
.stats-summary { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.stat-box {
  background: #141414; border: 1px solid #2a2a2a; border-radius: 10px;
  padding: 16px 22px; min-width: 130px; text-align: center;
  border-top: 2px solid #f2740c;
}
.stat-value { font-size: 24px; font-weight: 800; color: #f2740c; }
.stat-label { font-size: 11px; color: #8a8a8a; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.4px; }
#stats-table { width: 100%; border-collapse: collapse; font-size: 13px; }
#stats-table th, #stats-table td { padding: 10px; border-bottom: 1px solid #262626; text-align: left; }
#stats-table th { color: #8a8a8a; font-weight: 500; text-transform: uppercase; font-size: 11px; letter-spacing: 0.4px; }
.stats-note { font-size: 12px; color: #666; margin-top: 16px; }
form#chat-form {
  display: flex;
  padding: 14px;
  gap: 10px;
  background: #0f0f0f;
  border-top: 1px solid #262626;
}
#chat-input {
  flex: 1;
  padding: 13px 16px;
  border-radius: 999px;
  border: 1px solid #333;
  background: #161616;
  color: #f2f2f2;
  font-size: 15px;
}
#chat-input:focus { outline: none; border-color: #f2740c; }
#chat-form button {
  background: linear-gradient(135deg, #f2740c, #d9600a);
  color: #0a0a0a;
  font-weight: 700;
  border: none;
  border-radius: 999px;
  padding: 0 22px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  cursor: pointer;
}
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75);
  display: none; align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #141414; border: 1px solid #262626; padding: 24px; border-radius: 14px; width: 90%; max-width: 420px;
}
.modal h2 { margin-top: 0; font-size: 15px; text-transform: uppercase; letter-spacing: 0.4px; }
.modal input, .modal select {
  width: 100%; padding: 11px; margin: 8px 0; border-radius: 8px; border: 1px solid #333;
  background: #0a0a0a; color: #f2f2f2;
}
.modal input:focus, .modal select:focus { outline: none; border-color: #f2740c; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.modal button { padding: 9px 16px; border-radius: 999px; border: none; cursor: pointer; font-size: 13px; text-transform: uppercase; letter-spacing: 0.3px; }
.modal .save { background: linear-gradient(135deg, #f2740c, #d9600a); color: #0a0a0a; font-weight: 700; }
.modal .cancel { background: #262626; color: #f2f2f2; }
.login-wrap { height: 100vh; display: flex; align-items: center; justify-content: center; background: #0a0a0a; }
.login-box { background: #141414; border: 1px solid #262626; padding: 32px; border-radius: 16px; width: 90%; max-width: 360px; text-align: center; }
.login-box h1 { font-size: 20px; margin-top: 0; text-transform: uppercase; letter-spacing: 0.4px; font-weight: 800; }
.login-box h1 .brand-accent { color: #f2740c; }
.login-box input {
  width: 100%; padding: 13px; margin: 14px 0 6px; border-radius: 999px; border: 1px solid #333;
  background: #0a0a0a; color: #f2f2f2; font-size: 15px; text-align: center;
}
.login-box input:focus { outline: none; border-color: #f2740c; }
.login-box button {
  width: 100%; padding: 13px; border-radius: 999px; border: none;
  background: linear-gradient(135deg, #f2740c, #d9600a); color: #0a0a0a; font-size: 14px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; cursor: pointer; margin-top: 6px;
}
.error { color: #e8344a; font-size: 13px; min-height: 18px; }
