:root {
  --bg-main: #090d16;
  --bg-card: #131b2e;
  --bg-card-hover: #1b2640;
  --border-color: rgba(255, 255, 255, 0.08);
  --accent-blue: #3b82f6;
  --accent-gold: #eab308;
  --accent-green: #10b981;
  --accent-pink: #ec4899;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Auth Modal Overlay */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 13, 22, 0.96);
  backdrop-filter: blur(20px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: #111827;
  border: 1px solid rgba(59, 130, 246, 0.35);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 35px -5px rgba(59, 130, 246, 0.25);
  border-radius: 16px;
  padding: 2.5rem 2.25rem;
  text-align: center;
}

.auth-logo {
  display: inline-block;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #fff;
  font-weight: 800;
  font-size: 1.3rem;
  padding: 0.5rem 1.25rem;
  border-radius: 12px;
  letter-spacing: 1px;
  margin-bottom: 1.25rem;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.auth-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.35rem;
}

.auth-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 0.4rem;
  letter-spacing: 0.5px;
}

.auth-input-wrap {
  position: relative;
}

.auth-input {
  width: 100%;
  background: #090d16;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  color: #fff;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.auth-toggle-pwd {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
}

.auth-remember {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: #94a3b8;
  cursor: pointer;
}

.auth-remember input {
  accent-color: var(--accent-blue);
}

.btn-auth-submit {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.85rem;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.btn-auth-submit:hover {
  opacity: 0.92;
}

.btn-auth-submit:active {
  transform: scale(0.99);
}

.auth-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  padding: 0.65rem 0.85rem;
  border-radius: 6px;
  font-size: 0.82rem;
  display: none;
  margin-bottom: 1rem;
  text-align: center;
}

/* Header */
.app-header {
  height: 56px;
  background: rgba(19, 27, 46, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 50;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-badge {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  border: 1px solid var(--border-color);
}

.dot-green {
  width: 8px;
  height: 8px;
  background: var(--accent-green);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-green);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid rgba(234, 179, 8, 0.3);
  color: #fbbf24;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.btn-logout {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* Layout */
.main-container {
  display: flex;
  flex: 1;
  height: calc(100vh - 56px);
  overflow: hidden;
}

/* Left Sidebar (Rooms & Agents) */
.sidebar-left {
  width: 290px;
  background: #0d1322;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.section-label {
  padding: 0.85rem 1rem 0.4rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #64748b;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-add-room {
  background: none;
  border: none;
  color: var(--accent-blue);
  cursor: pointer;
  font-size: 1.1rem;
}

.room-item {
  padding: 0.75rem 1rem;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.room-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.room-item.active {
  background: rgba(59, 130, 246, 0.1);
  border-left-color: var(--accent-blue);
}

.room-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-desc {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Agent List */
.agent-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  transition: background 0.15s;
}

.agent-item:hover {
  background: rgba(255, 255, 255, 0.02);
}

.agent-avatar {
  font-size: 1.25rem;
}

.agent-info {
  flex: 1;
  min-width: 0;
}

.agent-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #cbd5e1;
}

.agent-role {
  font-size: 0.7rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Chat Center */
.chat-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  position: relative;
  overflow: hidden;
}

.chat-header {
  padding: 0.8rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  background: rgba(13, 19, 34, 0.6);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.active-room-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
}

.active-room-topic {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.message-stream {
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.msg-row {
  display: flex;
  gap: 0.85rem;
  max-width: 900px;
}

.msg-row.user-msg {
  flex-direction: row-reverse;
  align-self: flex-end;
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  border: 1px solid var(--border-color);
}

.msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.85rem 1.1rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #e2e8f0;
}

.user-msg .msg-bubble {
  background: #1e293b;
  border-color: rgba(234, 179, 8, 0.25);
}

.msg-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.sender-name {
  font-weight: 700;
  font-size: 0.82rem;
}

.sender-role {
  font-size: 0.7rem;
  color: #64748b;
}

.msg-time {
  font-size: 0.7rem;
  color: #475569;
  margin-left: auto;
}

.msg-body p {
  margin-bottom: 0.4rem;
}

.msg-body p:last-child {
  margin-bottom: 0;
}

.msg-body code {
  background: rgba(0, 0, 0, 0.4);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
  color: #38bdf8;
}

/* Typing Indicator */
.typing-box {
  padding: 0.5rem 1.25rem;
  font-size: 0.78rem;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 30px;
}

/* Input Area */
.input-area {
  padding: 1rem 1.25rem;
  background: #0d1322;
  border-top: 1px solid var(--border-color);
}

.quick-prompts {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  margin-bottom: 0.6rem;
  padding-bottom: 0.3rem;
}

.prompt-pill {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: #94a3b8;
  padding: 0.3rem 0.65rem;
  border-radius: 14px;
  font-size: 0.75rem;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s;
}

.prompt-pill:hover {
  background: rgba(59, 130, 246, 0.15);
  color: #fff;
  border-color: rgba(59, 130, 246, 0.4);
}

.input-form {
  display: flex;
  gap: 0.6rem;
}

.chat-input {
  flex: 1;
  background: #131b2e;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: #fff;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input:focus {
  border-color: var(--accent-blue);
}

.btn-send {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-send:hover {
  opacity: 0.9;
}

/* Right Sidebar (Consensus & Qdrant Search) */
.sidebar-right {
  width: 340px;
  background: #0d1322;
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 1rem;
  gap: 1.25rem;
}

/* Consensus Card */
.consensus-card {
  background: var(--bg-card);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 12px;
  padding: 1.1rem;
}

.consensus-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.consensus-tag {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.consensus-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f1f5f9;
  margin-bottom: 0.5rem;
}

.consensus-summary {
  font-size: 0.8rem;
  color: #94a3b8;
  line-height: 1.4;
  margin-bottom: 0.85rem;
}

.action-item {
  background: rgba(0, 0, 0, 0.25);
  border-left: 2px solid var(--accent-green);
  padding: 0.5rem 0.65rem;
  border-radius: 4px;
  margin-bottom: 0.4rem;
  font-size: 0.78rem;
}

.action-owner {
  font-weight: 700;
  color: #34d399;
}

.btn-approve {
  width: 100%;
  margin-top: 0.85rem;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.7rem;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-approve.executed {
  background: #1e293b;
  border: 1px solid #10b981;
  color: #10b981;
  cursor: default;
}

/* Qdrant Memory Inspector */
.memory-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.1rem;
}

.memory-header {
  font-size: 0.85rem;
  font-weight: 700;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.search-input {
  width: 100%;
  background: #090d16;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  font-size: 0.8rem;
  color: #fff;
  outline: none;
  margin-bottom: 0.75rem;
}

.memory-hits {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.hit-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.5rem;
  font-size: 0.75rem;
  color: #94a3b8;
}

.hit-tag {
  color: #38bdf8;
  font-weight: 600;
}

/* Mobile Responsiveness */
.mobile-tabs {
  display: none;
}

@media (max-width: 900px) {
  .sidebar-left {
    display: none;
  }
  .sidebar-right {
    display: none;
  }
  .mobile-tabs {
    display: flex;
    background: #0d1322;
    border-top: 1px solid var(--border-color);
    height: 48px;
  }
  .tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
  }
  .tab-btn.active {
    color: #38bdf8;
    border-top: 2px solid #38bdf8;
  }
}
