* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }
.error { color: #e74c3c; margin-top: 8px; font-size: 14px; }

/* Login */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, #075e54 0%, #128c7e 100%);
}

.login-box {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  width: 360px;
  text-align: center;
}

.login-box h1 {
  color: #075e54;
  margin-bottom: 4px;
}

.login-box p {
  color: #667781;
  margin-bottom: 24px;
  font-size: 14px;
}

.login-box input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  outline: none;
}

.login-box input:focus {
  border-color: #075e54;
}

.login-box button {
  width: 100%;
  padding: 12px;
  background: #075e54;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  font-weight: 500;
}

.login-box button:hover {
  background: #064e46;
}

/* Header */
.header {
  background: #075e54;
  color: white;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header h1 { font-size: 18px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.btn-small {
  background: rgba(255,255,255,0.2);
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.btn-small:hover { background: rgba(255,255,255,0.3); }

/* Inbox layout */
.inbox-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.inbox-container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Contacts panel */
.contacts-panel {
  width: 360px;
  min-width: 360px;
  border-right: 1px solid #e0e0e0;
  background: white;
  display: flex;
  flex-direction: column;
}

.search-box {
  padding: 10px;
  background: #f0f2f5;
}

.search-box input {
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: white;
  font-size: 14px;
  outline: none;
}

.contacts-list {
  flex: 1;
  overflow-y: auto;
}

.contact-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f0f2f5;
  transition: background 0.15s;
}

.contact-item:hover { background: #f5f6f6; }
.contact-item.active { background: #f0f2f5; }

.contact-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #dfe5e7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
  margin-right: 12px;
  flex-shrink: 0;
}

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

.contact-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.contact-name {
  font-weight: 500;
  font-size: 15px;
  color: #111b21;
}

.contact-time {
  font-size: 12px;
  color: #667781;
  flex-shrink: 0;
}

.contact-preview {
  font-size: 13px;
  color: #667781;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
}

.unread-badge {
  background: #25d366;
  color: white;
  border-radius: 50%;
  min-width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  margin-left: 4px;
}

/* Chat panel */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #efeae2;
}

.chat-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #667781;
  font-size: 15px;
  background: #f0f2f5;
}

.chat-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  background: #f0f2f5;
  padding: 12px 16px;
  border-bottom: 1px solid #e0e0e0;
}

.chat-contact-name {
  font-weight: 600;
  font-size: 15px;
  color: #111b21;
}

.chat-contact-phone {
  font-size: 12px;
  color: #667781;
  margin-left: 8px;
}

/* Messages */
.messages-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 60px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-bubble {
  max-width: 65%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.4;
  position: relative;
  word-wrap: break-word;
}

.message-bubble.incoming {
  background: white;
  align-self: flex-start;
  border-top-left-radius: 0;
}

.message-bubble.outgoing {
  background: #d9fdd3;
  align-self: flex-end;
  border-top-right-radius: 0;
}

.message-time {
  font-size: 11px;
  color: #667781;
  text-align: right;
  margin-top: 2px;
}

.message-status {
  font-size: 11px;
  margin-left: 4px;
}

/* Chat input */
.chat-input {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  background: #f0f2f5;
}

.chat-input textarea {
  flex: 1;
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 100px;
}

.chat-input button {
  background: #075e54;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  align-self: flex-end;
}

.chat-input button:hover { background: #064e46; }

/* Date separator */
.date-separator {
  text-align: center;
  margin: 12px 0;
}

.date-separator span {
  background: #e1f3fb;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  color: #54656f;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  border-radius: 12px;
  padding: 24px;
  width: 480px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h2 {
  font-size: 18px;
  color: #075e54;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #667781;
}

.modal-content label {
  display: block;
  font-size: 13px;
  color: #667781;
  margin-bottom: 4px;
  margin-top: 12px;
}

.modal-content input[type="text"],
.modal-content input[type="file"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}

.modal-content input[type="text"]:focus {
  border-color: #075e54;
}

.modal-content button[type="submit"] {
  width: 100%;
  padding: 12px;
  background: #075e54;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  font-weight: 500;
  margin-top: 20px;
}

.modal-content button[type="submit"]:hover {
  background: #064e46;
}

.modal-content button[type="submit"]:disabled {
  background: #a0a0a0;
  cursor: not-allowed;
}

.csv-preview {
  background: #f0f2f5;
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 8px;
  font-size: 13px;
  color: #333;
  max-height: 120px;
  overflow-y: auto;
}

.progress-bar {
  background: #e0e0e0;
  border-radius: 6px;
  height: 8px;
  margin: 16px 0 8px;
  overflow: hidden;
}

.progress-fill {
  background: #25d366;
  height: 100%;
  width: 0%;
  transition: width 0.3s;
  border-radius: 6px;
}

.bulk-progress p {
  font-size: 13px;
  color: #667781;
  text-align: center;
}

.bulk-results {
  margin-top: 16px;
  font-size: 13px;
}

.bulk-results .result-summary {
  padding: 12px;
  border-radius: 8px;
  background: #f0f2f5;
  margin-bottom: 8px;
  font-weight: 500;
}

.bulk-results .result-detail {
  max-height: 150px;
  overflow-y: auto;
}

.bulk-results .result-item {
  padding: 4px 0;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #f0f2f5;
}

.result-item .status-sent { color: #25d366; }
.result-item .status-failed { color: #e74c3c; }

/* Responsive */
@media (max-width: 768px) {
  .contacts-panel {
    width: 100%;
    min-width: unset;
  }
  .chat-panel.has-chat .chat-placeholder { display: none; }
  .messages-list { padding: 16px 12px; }
  .message-bubble { max-width: 85%; }
}
