body.inbox-shell {
  margin: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  font-family: Inter, system-ui, sans-serif;
  background: #eef3f9;
  color: #122033;
}

.inbox-login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-card {
  width: min(420px, calc(100vw - 32px));
  background: #fff;
  border: 1px solid #d8e2f0;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: #5d728c;
}

.login-card h1,
.inbox-header h1,
.conversation-header h2 {
  margin: 0;
}

.login-form,
.conversation-form {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.login-form label,
.conversation-form label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

input,
button {
  font: inherit;
}

input[type="text"],
input[type="password"],
input[type="search"] {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #c9d6e5;
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  background: #2563eb;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.login-error {
  min-height: 20px;
  margin: 12px 0 0;
  color: #b42318;
  font-size: 14px;
}

.inbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  background: #fff;
  border-bottom: 1px solid #d8e2f0;
}

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

.mobile-back-btn {
  display: none;
  background: #e8f0ff;
  color: #1d4ed8;
  padding: 10px 12px;
  white-space: nowrap;
}

.inbox-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.conversation-list-pane,
.conversation-pane {
  min-width: 0;
  min-height: 0;
}

.conversation-list-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-right: 1px solid #d8e2f0;
  background: #f8fbff;
  overflow: hidden;
}

.list-toolbar {
  padding: 16px;
  border-bottom: 1px solid #d8e2f0;
  background: #f8fbff;
  position: relative;
  z-index: 1;
}

.conversation-list {
  display: grid;
  min-height: 0;
  overflow: auto;
}

.conversation-row {
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid #e4ebf5;
  background: transparent;
  text-align: left;
  color: inherit;
}

.conversation-row.active {
  background: #e8f0ff;
}

.conversation-row.highlight {
  background: #fff6d8;
  box-shadow: inset 4px 0 0 #d97706;
  animation: conversationPulse 1.2s ease 3;
}

.conversation-row.active.highlight {
  background: #fef3c7;
}

.conversation-row strong,
.conversation-row small {
  display: block;
}

.conversation-row small {
  color: #60758e;
}

.channel-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.channel-badge.whatsapp {
  background: #dcfce7;
  color: #166534;
}

.channel-badge.web {
  background: #dbeafe;
  color: #1d4ed8;
}

.conversation-pane {
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #fff;
  min-height: 0;
  overflow: hidden;
}

.conversation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid #d8e2f0;
  background: #fff;
  position: relative;
  z-index: 1;
}

.customer-active-btn {
  border-color: #15803d;
  color: #166534;
  background: #f0fdf4;
}

.customer-active-btn.active {
  color: #fff;
  background: #15803d;
  border-color: #15803d;
}

.conversation-header > div:first-of-type {
  min-width: 0;
}

#conversationMeta,
#inboxSubtitle {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.conversation-messages {
  padding: 20px;
  display: grid;
  gap: 12px;
  align-content: start;
  min-height: 0;
  overflow: auto;
}

.message {
  max-width: min(720px, 90%);
  padding: 12px 14px;
  border-radius: 8px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.message.user {
  justify-self: end;
  background: #e8f0ff;
}

.message.assistant {
  justify-self: start;
  background: #f4f6f8;
}

.message.human {
  justify-self: start;
  background: #fff1d6;
}

.message-meta {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: #60758e;
}

.conversation-form {
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 16px 20px 20px;
  border-top: 1px solid #d8e2f0;
  background: #fff;
  position: relative;
  z-index: 1;
}

.conversation-form input {
  min-width: 0;
}

.inbox-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #122033;
  color: #fff;
  opacity: 0;
  transform: translateY(8px);
  transition: 0.2s ease;
}

.inbox-toast.show {
  opacity: 1;
  transform: translateY(0);
}

@keyframes conversationPulse {
  0% {
    background: #fde68a;
  }
  100% {
    background: #fff6d8;
  }
}

@media (max-width: 960px) {
  body.inbox-shell {
    height: 100dvh;
  }

  .inbox-header {
    padding: 14px 16px;
    gap: 12px;
    align-items: flex-start;
    flex-direction: column;
  }

  .inbox-header h1 {
    font-size: 1.75rem;
  }

  .inbox-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .inbox-actions button {
    flex: 1 1 0;
    min-width: 0;
  }

  .inbox-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
  }

  .conversation-list-pane {
    border-right: 0;
  }

  body.mobile-view .conversation-list-pane,
  body.mobile-view .conversation-pane {
    grid-column: 1;
    grid-row: 1;
  }

  body.mobile-view .conversation-pane {
    display: none;
  }

  body.mobile-view.mobile-show-conversation .conversation-list-pane {
    display: none;
  }

  body.mobile-view.mobile-show-conversation .conversation-pane {
    display: grid;
  }

  .mobile-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .conversation-header {
    grid-template-columns: auto minmax(0, 1fr);
    display: grid;
    align-items: start;
    padding: 12px 14px;
    gap: 12px;
  }

  .conversation-header .inbox-actions {
    grid-column: 1 / -1;
  }

  .conversation-messages {
    padding: 14px;
  }

  .message {
    max-width: 94%;
  }

  .conversation-form {
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    gap: 10px;
  }

  .conversation-form input {
    min-height: 44px;
  }

  .conversation-form button {
    min-height: 44px;
  }
}
