html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
  background: #f5f7f8;
  color: #1f2933;
  font-family: Arial, Helvetica, sans-serif;
}

.login-shell {
  display: grid;
  min-height: 70vh;
  place-items: center;
}

.login-panel {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid #dde3e8;
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 14px 35px rgba(30, 41, 59, 0.08);
}

.login-panel h1,
.portal-header h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
}

.login-panel p {
  margin: 8px 0 24px;
  color: #64748b;
}

.login-hint {
  margin-top: 14px;
  color: #64748b;
  font-size: 0.85rem;
  text-align: center;
}

.portal-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.account-picker {
  display: grid;
  gap: 6px;
  min-width: 240px;
}

.inbox-shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  height: calc(100vh - 210px);
  min-height: 460px;
  overflow: hidden;
  background: #fff;
  border: 1px solid #d7dee5;
  border-radius: 8px;
}

.conversation-panel {
  display: flex;
  min-height: 0;
  min-width: 0;
  flex-direction: column;
  border-right: 1px solid #d7dee5;
  background: #fbfcfd;
}

.conversation-panel-title {
  padding: 14px 16px;
  border-bottom: 1px solid #d7dee5;
  font-weight: 700;
}

.conversation-list {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  overflow-y: auto;
}

.conversation-item {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 14px;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid #edf1f5;
}

.conversation-item:hover,
.conversation-item.active {
  background: #eef6ff;
  color: inherit;
}

.conversation-avatar {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  background: #dbeafe;
  color: #1d4ed8;
  font-weight: 700;
}

.conversation-content {
  min-width: 0;
}

.conversation-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.conversation-title,
.conversation-subtitle,
.conversation-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-title {
  font-weight: 700;
}

.conversation-topline time,
.conversation-subtitle,
.conversation-preview,
.conversation-empty {
  color: #64748b;
  font-size: 0.84rem;
}

.conversation-preview {
  margin-top: 4px;
}

.conversation-empty {
  padding: 18px 16px;
}

.chat-panel {
  display: flex;
  min-height: 0;
  min-width: 0;
  flex-direction: column;
  background: #f8fafc;
}

.chat-header {
  padding: 14px 18px;
  border-bottom: 1px solid #d7dee5;
  background: #fff;
}

.chat-title {
  font-weight: 700;
}

.chat-subtitle {
  color: #64748b;
  font-size: 0.86rem;
}

.chat-placeholder {
  display: grid;
  min-height: 360px;
  place-items: center;
  color: #64748b;
}

.message-list {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 16px 18px 36px;
}

.message-bubble {
  width: min(680px, 92%);
  border: 1px solid #d7dee5;
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff;
}

.message-bubble.inbound {
  align-self: flex-start;
  border-left: 4px solid #0f766e;
}

.message-bubble.outbound {
  align-self: flex-end;
  border-right: 4px solid #2563eb;
  background: #eef6ff;
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: #64748b;
  font-size: 0.78rem;
  margin-bottom: 8px;
}

.message-body {
  white-space: normal;
  line-height: 1.8;
}

.message-media {
  display: block;
  max-width: min(360px, 100%);
  max-height: 360px;
  border-radius: 6px;
  margin-top: 10px;
  object-fit: contain;
  background: #e5e7eb;
}

.modal-media {
  display: block;
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  background: #eef2f6;
  border-radius: 6px;
}

.media-link {
  display: inline-block;
  margin-top: 10px;
}

.empty-state {
  background: #fff;
  border: 1px dashed #b6c2cf;
  border-radius: 8px;
  padding: 28px;
  margin: 16px 18px;
  color: #64748b;
  text-align: center;
}

@media (max-width: 640px) {
  .portal-header {
    align-items: stretch;
    flex-direction: column;
  }

  .account-picker {
    min-width: 0;
  }

  .inbox-shell {
    grid-template-columns: 1fr;
    height: calc(100vh - 220px);
    min-height: 520px;
  }

  .conversation-panel {
    border-right: 0;
    border-bottom: 1px solid #d7dee5;
  }

  .conversation-list {
    flex: 0 0 220px;
  }

  .message-bubble {
    width: 100%;
  }
}
