* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f3f4f6;
  color: #111827;
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  background: #111827;
  color: white;
  padding: 18px;
  overflow-y: auto;
}

.brand {
  margin-bottom: 20px;
}

.brand-with-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-logo {
  width: 54px;
  height: 54px;
  object-fit: contain;
  border-radius: 16px;
  background: #ffffff;
  padding: 5px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.brand h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
}

.brand p {
  margin: 4px 0 0;
  color: #9ca3af;
  font-size: 13px;
}

.user-box {
  margin-bottom: 16px;
}

.user-box label,
.modal-content label {
  display: block;
  font-size: 12px;
  margin-bottom: 6px;
  color: #6b7280;
}

.user-box select,
.modal-content input,
.modal-content select,
.modal-content textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
}

.thread-header {
  margin: 18px 0 10px;
  color: #9ca3af;
  font-size: 13px;
  text-transform: uppercase;
}

.thread-item {
  padding: 12px;
  margin-bottom: 8px;
  background: #1f2937;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.2s;
}

.thread-item:hover,
.thread-item.active {
  background: #374151;
}

.thread-item h4 {
  margin: 0 0 6px;
  font-size: 14px;
}

.thread-item p {
  margin: 0;
  color: #d1d5db;
  font-size: 12px;
}

.muted {
  color: #9ca3af;
  font-size: 13px;
}

/* Chat area */
.chat-area {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
}

.chat-header {
  padding: 18px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-header h3 {
  margin: 0;
}

.chat-header p {
  margin: 4px 0 0;
  color: #6b7280;
  font-size: 13px;
}

.badge {
  background: #e0f2fe;
  color: #0369a1;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: #f9fafb;
}

.empty-state {
  color: #6b7280;
  text-align: center;
  margin-top: 60px;
}

.message {
  max-width: 70%;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: white;
  border: 1px solid #e5e7eb;
}

.message.mine {
  margin-left: auto;
  background: #dbeafe;
  border-color: #bfdbfe;
}

.message .meta {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 6px;
}

.message .text {
  font-size: 14px;
  line-height: 1.4;
}

.message-box {
  display: flex;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid #e5e7eb;
}

.message-box input {
  flex: 1;
  padding: 12px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
}

.message-box button,
.primary-btn,
.secondary-btn {
  padding: 10px 14px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}

.message-box button,
.primary-btn {
  background: #2563eb;
  color: white;
}

.secondary-btn {
  background: #e5e7eb;
  color: #111827;
}

/* Details panel */
.details-panel {
  padding: 18px;
  background: #f9fafb;
  overflow-y: auto;
}

.detail-card {
  background: white;
  border: 1px solid #e5e7eb;
  padding: 12px;
  border-radius: 12px;
  margin-bottom: 12px;
}

.detail-card label {
  display: block;
  color: #6b7280;
  font-size: 12px;
  margin-bottom: 4px;
}

.detail-card p {
  margin: 0;
  font-weight: bold;
}

.warning-box {
  background: #fef3c7;
  color: #92400e;
  padding: 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  width: 420px;
  max-width: 92%;
  padding: 20px;
  border-radius: 16px;
}

.modal-content h3 {
  margin-top: 0;
}

.modal-content label {
  margin-top: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

/* Responsive */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .details-panel {
    height: auto;
  }

  .chat-area {
    min-height: 70vh;
  }
}