html, body {
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
  background: #eef2f5;
  color: #1f2937;
  height: 100%;
}

body {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.muted {
  color: #6b7280;
}

.small {
  font-size: 12px;
}

.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 10px 32px rgba(0,0,0,.08);
  padding: 28px;
}

.form-row {
  margin-top: 14px;
}

.form-row label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
}

input, textarea, select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #d8dde3;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
}

textarea {
  resize: none;
  min-height: 72px;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
}

.btn-primary {
  background: #3390ec;
  color: #fff;
}

.btn-light {
  background: #f3f4f6;
  color: #111827;
}

.message {
  margin-top: 14px;
  min-height: 18px;
  font-size: 14px;
}

.layout {
  display: flex;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 360px;
  min-width: 320px;
  max-width: 420px;
  background: #fff;
  border-right: 1px solid #dde3e8;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-top {
  padding: 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  border-bottom: 1px solid #eef2f5;
}

.brand {
  font-size: 18px;
  font-weight: 700;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tabs {
  display: flex;
  padding: 12px 16px 8px;
  gap: 8px;
}

.tab {
  flex: 1;
  background: #f3f4f6;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

.tab.is-active {
  background: #dbeafe;
  color: #1d4ed8;
}

.search-wrap {
  padding: 0 16px 12px;
}

.pane {
  display: none;
  overflow: auto;
  padding: 0 8px 12px;
  flex: 1;
}

.pane.is-active {
  display: block;
}

.list-item {
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  margin: 6px 8px;
  border: 1px solid #eef2f5;
  cursor: pointer;
}

.list-item:hover {
  background: #f8fafc;
}

.list-item.is-active {
  border-color: #93c5fd;
  background: #eff6ff;
}

.item-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.item-sub {
  font-size: 13px;
  color: #6b7280;
}

.chat-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  padding: 24px;
  text-align: center;
}

.placeholder-title {
  font-size: 22px;
  font-weight: 700;
}

.chat-wrap {
  min-height: 100vh;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.chat-head {
  background: #fff;
  border-bottom: 1px solid #dde3e8;
  padding: 16px 20px;
  flex: 0 0 auto;
}

.chat-head-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.chat-title {
  font-size: 18px;
  font-weight: 700;
}

.btn-back {
  white-space: nowrap;
}

.messages-box {
  flex: 1 1 auto;
  min-height: 0;
  padding: 24px 20px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background:
    radial-gradient(circle at top left, rgba(13, 110, 253, 0.04), transparent 26%),
    linear-gradient(180deg, #f8fafc 0%, #eef3f8 100%);
}

.messages-empty {
  align-self: center;
  margin: auto 0;
  background: rgba(255,255,255,0.88);
  border: 1px solid #dbe4ef;
  border-radius: 16px;
  padding: 12px 16px;
  backdrop-filter: blur(6px);
}

.msg {
  width: 100%;
  display: flex;
}

.msg.in {
  justify-content: flex-start;
}

.msg.out {
  justify-content: flex-end;
}

.msg-bubble {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  width: auto;
  max-width: min(560px, 72%);
  min-width: 96px;
  padding: 12px 14px 10px;
  border-radius: 18px;
  box-sizing: border-box;
  line-height: 1.45;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.msg.in .msg-bubble {
  background: #ffffff;
  border: 1px solid #dbe4ef;
  color: #0f172a;
  border-top-left-radius: 8px;
}

.msg.out .msg-bubble {
  background: linear-gradient(135deg, #0d6efd 0%, #228be6 100%);
  border: 1px solid rgba(13, 110, 253, 0.22);
  color: #ffffff;
  border-top-right-radius: 8px;
}

.msg-text {
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-meta {
  margin-top: 8px;
  align-self: flex-end;
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.01em;
  text-align: right;
}

.msg.in .msg-meta {
  color: #64748b;
}

.msg.out .msg-meta {
  color: rgba(255,255,255,0.86);
}

.composer {
  background: rgba(255,255,255,0.96);
  border-top: 1px solid #dbe4ef;
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex: 0 0 auto;
  backdrop-filter: blur(10px);
}

.composer textarea {
  flex: 1;
  min-height: 52px;
  max-height: 180px;
  border: 1px solid #cfd8e3;
  border-radius: 16px;
  padding: 14px 16px;
  background: #ffffff;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

.composer textarea:focus {
  outline: none;
  border-color: #0d6efd;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.12);
}

.composer-send {
  flex: 0 0 auto;
  min-width: 120px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, #0d6efd 0%, #228be6 100%);
  box-shadow: 0 10px 24px rgba(13, 110, 253, 0.22);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 40;
}

.modal-card {
  background: #fff;
  width: 100%;
  max-width: 720px;
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
  padding: 18px;
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.modal-card--wide {
  max-width: 980px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-subhead {
  margin-top: 18px;
  margin-bottom: 10px;
  font-weight: 700;
}

.profile-box {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.profile-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}

.sessions-box {
  display: grid;
  gap: 10px;
}

.session-row {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 10px 12px;
}

.admin-create {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1.2fr 1.4fr 160px 140px;
  gap: 10px;
}

.admin-users-box {
  margin-top: 14px;
}

.admin-row {
  display: grid;
  grid-template-columns: 1.2fr 1.4fr 110px 110px 160px 140px 260px;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid #eef2f5;
  padding: 10px 0;
  font-size: 14px;
}

.admin-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 1100px) {
  .admin-row {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 12px 0;
  }

  .admin-create {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 900px) {
  .sidebar {
    width: 320px;
    min-width: 280px;
  }

  .msg-bubble {
    max-width: 82%;
  }
}

@media (max-width: 720px) {
  .layout {
    position: relative;
  }

  .sidebar {
    width: 100%;
    min-width: 0;
    max-width: none;
    border-right: 0;
  }

  .chat-area {
    position: absolute;
    inset: 0;
    background: #eef2f5;
    transform: translateX(100%);
    transition: transform .2s ease;
  }

  .layout.mobile-chat-open .chat-area {
    transform: translateX(0);
  }

  .layout.mobile-chat-open .sidebar {
    visibility: hidden;
  }

  .btn-back {
    display: inline-flex !important;
  }

  .chat-wrap,
  .layout,
  .chat-area {
    min-height: 100vh;
    height: 100vh;
  }

  .composer {
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }

  .top-actions {
    gap: 6px;
  }

  .top-actions .btn {
    padding: 8px 10px;
    font-size: 13px;
  }

  .admin-create {
    grid-template-columns: 1fr;
  }

  .modal {
    padding: 12px;
  }

  .modal-card {
    max-height: calc(100vh - 24px);
  }
}

@media (max-width: 480px) {
  .sidebar-top {
    padding: 12px;
  }

  .tabs {
    padding: 10px 12px 8px;
  }

  .search-wrap {
    padding: 0 12px 10px;
  }

  .chat-head {
    padding: 12px 14px;
  }

  .messages-box {
    padding: 12px;
  }

  .composer {
    padding: 10px 12px;
    gap: 8px;
  }

  .msg-bubble {
    max-width: 90%;
    min-width: 0;
    padding: 10px 12px 9px;
  }

  .composer-send {
    min-width: 98px;
    height: 48px;
    border-radius: 14px;
  }

  .placeholder-title {
    font-size: 20px;
  }
}


.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: #f3f4f6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0;
}

.icon-btn:hover {
  background: #e5e7eb;
}

@media (max-width: 480px) {
  .icon-btn {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
}


.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: #f3f4f6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0;
}

.icon-btn:hover {
  background: #e5e7eb;
}

.icon-btn .bi {
  font-size: 18px;
  line-height: 1;
}

@media (max-width: 480px) {
  .icon-btn {
    width: 36px;
    height: 36px;
  }

  .icon-btn .bi {
    font-size: 16px;
  }
}


.item-sub--presence {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.presence-dot {
  width: 10px;
  height: 10px;
  min-width: 10px;
  border-radius: 50%;
  display: inline-block;
}

.presence-dot.is-online {
  background: #0d6efd;
}

.presence-dot.is-offline {
  background: #9ca3af;
}


.list-item__row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.list-item__meta {
  min-width: 0;
  flex: 1;
}

.avatar {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  line-height: 1;
  user-select: none;
}

.avatar--list {
  width: 42px;
  height: 42px;
  min-width: 42px;
  font-size: 15px;
}

.avatar--chat {
  width: 44px;
  height: 44px;
  min-width: 44px;
  font-size: 16px;
}

.chat-head-meta {
  min-width: 0;
}

.avatar-color-0 { background: linear-gradient(135deg, #5b8def, #7b61ff); }
.avatar-color-1 { background: linear-gradient(135deg, #12b886, #2f9e44); }
.avatar-color-2 { background: linear-gradient(135deg, #f76707, #f59f00); }
.avatar-color-3 { background: linear-gradient(135deg, #e64980, #be4bdb); }
.avatar-color-4 { background: linear-gradient(135deg, #228be6, #15aabf); }
.avatar-color-5 { background: linear-gradient(135deg, #7950f2, #4c6ef5); }
.avatar-color-6 { background: linear-gradient(135deg, #fa5252, #f06595); }
.avatar-color-7 { background: linear-gradient(135deg, #40c057, #12b886); }

@media (max-width: 480px) {
  .avatar--list {
    width: 38px;
    height: 38px;
    min-width: 38px;
    font-size: 14px;
  }

  .avatar--chat {
    width: 40px;
    height: 40px;
    min-width: 40px;
    font-size: 14px;
  }

  .list-item__row {
    gap: 10px;
  }
}

.msg-day-divider {
  display: flex;
  justify-content: center;
  margin: 4px 0 2px;
}

.msg-day-divider__label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.88);
  border: 1px solid #dbe4ef;
  color: #64748b;
  font-size: 12px;
  line-height: 1;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
  backdrop-filter: blur(6px);
}

.composer-attach {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  flex: 0 0 auto;
}

.composer-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-draft {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px 12px;
  border: 1px solid #dbe4ef;
  border-radius: 16px;
  background: rgba(255,255,255,0.96);
}

.file-draft__icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #eef4ff;
  color: #0d6efd;
  font-size: 18px;
}

.file-draft__meta {
  min-width: 0;
  flex: 1 1 auto;
}

.file-draft__name {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-draft__sub {
  margin-top: 2px;
  font-size: 12px;
  color: #64748b;
}

.file-draft__remove {
  border: 0;
  background: transparent;
  color: #64748b;
  width: 32px;
  height: 32px;
  border-radius: 10px;
}

.file-draft__remove:hover {
  background: #f1f5f9;
}

.msg-meta-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.msg-delete-btn {
  border: 0;
  background: transparent;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  color: inherit;
  opacity: 0.7;
}

.msg-delete-btn:hover {
  opacity: 1;
  background: rgba(255,255,255,0.14);
}

.msg.in .msg-delete-btn:hover {
  background: #eef2f7;
}

.msg-attachment {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 8px;
  text-align: left;
}

.msg.in .msg-attachment {
  background: #f8fafc;
}

.msg.out .msg-attachment {
  background: rgba(255,255,255,0.16);
}

.msg-attachment__icon {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.msg.in .msg-attachment__icon {
  background: #eaf1fb;
  color: #0d6efd;
}

.msg.out .msg-attachment__icon {
  background: rgba(255,255,255,0.18);
  color: #ffffff;
}

.msg-attachment__meta {
  min-width: 0;
  flex: 1 1 auto;
}

.msg-attachment__name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-attachment__sub {
  margin-top: 2px;
  font-size: 12px;
  opacity: 0.86;
}

@media (max-width: 640px) {
  .composer {
    align-items: stretch;
  }

  .composer-send,
  .composer-attach {
    height: 48px;
    min-width: 48px;
  }
}

.list-item__topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.dialog-unread-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #0d6efd;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  flex: 0 0 auto;
}
