* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: #0b141a;
  color: #111b21;
}

input,
button {
  font: inherit;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: #25d366;
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  opacity: 0.94;
}

.row {
  display: flex;
  gap: 10px;
}

.hidden {
  display: none !important;
}

.muted {
  color: #667781;
  margin: 8px 0 0;
}

.error {
  color: #c1121f;
  margin: 8px 4px 0;
  min-height: 1.2em;
}

.messages {
  overflow-y: auto;
  border-radius: 12px;
  background: #efeae2;
  padding: 12px;
}

.chat-image {
  display: block;
  max-width: min(320px, 80vw);
  width: auto;
  height: auto;
  border-radius: 10px;
  margin-bottom: 8px;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.message {
  margin-bottom: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  max-width: 76%;
  line-height: 1.35;
  word-break: break-word;
}

.message.user {
  background: #fff;
}

.message.owner {
  background: #d9fdd3;
  margin-left: auto;
}

.user-messages .message.user {
  background: #d9fdd3;
  margin-left: auto;
}

.user-messages .message.owner {
  background: #fff;
  margin-right: auto;
}

.meta {
  margin-top: 4px;
  font-size: 0.75rem;
  color: #667781;
}

.message a {
  color: #0b57d0;
}

.user-app {
  max-width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  display: block;
}

.message.image-only {
  width: fit-content;
  max-width: calc(min(320px, 80vw) + 22px);
}

.user-card {
  width: 100vw;
  height: 100vh;
  max-width: none;
  background: #fff;
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
  display: grid;
  grid-template-rows: auto 1fr;
}

.user-header {
  padding: 14px 16px;
  background: #f0f2f5;
  border-bottom: 1px solid #d1d7db;
  font-weight: 700;
  color: #1f2c33;
}

.user-body {
  padding: 16px;
}

.user-body input {
  flex: 1;
  border: 1px solid #cbd5dc;
  border-radius: 10px;
  padding: 10px 12px;
}

.attach-icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 1.1rem;
  line-height: 34px;
  text-align: center;
  background: transparent;
  color: #334155;
  border: 0;
  border-radius: 999px;
}

.message-input-wrap {
  flex: 1;
  position: relative;
}

.message-input-wrap #message-input {
  width: 100%;
  padding-left: 44px;
}

.message-input-wrap .attach-icon-btn {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
}

.phone-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  border: 1px solid #cbd5dc;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.phone-prefix {
  padding: 10px 12px;
  color: #475569;
  background: #f8fafc;
  border-right: 1px solid #e2e8f0;
  font-weight: 700;
}

.phone-wrap input {
  border: 0 !important;
  border-radius: 0 !important;
}

.phone-wrap input:focus {
  outline: none;
}

.user-messages {
  flex: 1;
  min-height: 0;
  margin: 10px 0;
}

#chat-step {
  height: calc(100vh - 56px);
  display: grid;
  grid-template-rows: auto 1fr auto auto;
}

#message-form {
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.image-preview-wrap {
  margin-bottom: 8px;
  display: inline-block;
  position: relative;
  justify-self: start;
  width: fit-content;
  max-width: 100%;
}

.image-preview-wrap img {
  max-height: 84px;
  width: auto;
  height: auto;
  border-radius: 10px;
  border: 1px solid #dce4ea;
  display: block;
}

.image-remove-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 999px;
  border: 1px solid #d1d7db;
  background: #fff;
  color: #1f2937;
  padding: 0;
  line-height: 22px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
}

.pending-note {
  margin: 8px 0;
  padding: 9px 10px;
  border-radius: 10px;
  background: #fff3cd;
  color: #7a5500;
}

.owner-app {
  max-width: 1220px;
  height: calc(100vh - 24px);
  margin: 0 auto;
  padding: 12px;
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 0;
  overflow: hidden;
}

.owner-left {
  background: #111b21;
  color: #e9edef;
  border-top-left-radius: 12px;
  border-bottom-left-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.owner-left-header {
  padding: 14px 16px;
  font-size: 1.15rem;
  font-weight: 700;
  background: #1f2c33;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.owner-search-wrap {
  padding: 10px;
}

.owner-search-wrap input {
  width: 100%;
  border: 1px solid #2a3942;
  background: #202c33;
  color: #e9edef;
  border-radius: 10px;
  padding: 10px 12px;
}

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

.label-filter-wrap {
  padding: 8px 10px 10px;
  border-bottom: 1px solid #1f2c33;
}

.compact-filter {
  display: grid;
  gap: 8px;
}

.ghost-btn {
  background: #202c33;
  color: #9eb1bc;
  border: 1px solid #2a3942;
  border-radius: 8px;
  padding: 8px 10px;
  text-align: left;
  font-size: 0.82rem;
}

.label-filter-title {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #9eb1bc;
}

.label-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.label-chip {
  border: 0;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.7rem;
  color: #fff;
  background: #64748b;
  white-space: nowrap;
}

.label-chip.inactive {
  opacity: 0.4;
}

.label-chip.selected {
  outline: 2px solid #fff;
}

.conversation-item {
  padding: 12px 14px;
  border-bottom: 1px solid #1f2c33;
  cursor: pointer;
}

.conversation-item.active {
  background: #2a3942;
}

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

.conversation-title {
  font-weight: 700;
  color: #f1f5f8;
}

.conversation-subtitle {
  margin-top: 4px;
  color: #9eb1bc;
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-labels {
  margin-top: 5px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.conversation-labels .mini-label {
  border-radius: 999px;
  font-size: 0.64rem;
  padding: 2px 7px;
  color: #fff;
}

.conversation-labels .mini-label-dot {
  width: 10px;
  height: 10px;
  padding: 0;
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.badges {
  display: inline-flex;
  gap: 6px;
}

.badge {
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge.pending {
  background: #f59e0b;
  color: #111;
}

.badge.unread {
  background: #25d366;
  color: #fff;
}

.owner-right {
  background: #efeae2;
  border-top-right-radius: 12px;
  border-bottom-right-radius: 12px;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto auto;
  min-height: 0;
  overflow: hidden;
}

.owner-right-header {
  background: #f0f2f5;
  border-bottom: 1px solid #d1d7db;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.owner-right-header p {
  margin: 0;
  font-size: 1.1rem;
}

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

.pending-banner {
  background: #fff3cd;
  color: #7a5500;
  border-bottom: 1px solid #f1d58a;
  padding: 8px 16px;
  font-size: 0.9rem;
}

.application-details {
  background: #f8fafb;
  border-bottom: 1px solid #d1d7db;
  padding: 0 16px;
}

.application-details summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 0;
  font-weight: 700;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.application-details summary::-webkit-details-marker {
  display: none;
}

.application-details summary::after {
  content: "▾";
  font-size: 0.9rem;
  color: #64748b;
  transition: transform 0.15s ease;
}

.application-details[open] summary::after {
  transform: rotate(180deg);
}

.application-data {
  padding: 2px 0 12px;
  display: grid;
  gap: 8px;
}

.application-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 10px;
  border-bottom: 1px solid #e7edf1;
  padding-bottom: 6px;
}

.application-row strong {
  color: #64748b;
  font-size: 0.82rem;
}

.contact-tools {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 10px 16px;
  background: #f0f2f5;
  border-bottom: 1px solid #d1d7db;
}

.contact-tools input {
  width: 100%;
  border: 1px solid #cbd5dc;
  border-radius: 10px;
  padding: 10px 12px;
}

.approve-btn {
  background: #2563eb;
}

.delete-btn {
  background: #dc2626;
}

.subtle-delete {
  background: #475569;
}

.label-manager {
  padding: 8px 16px;
  background: #f8fafb;
  border-bottom: 1px solid #d1d7db;
  min-height: 58px;
  max-height: 58px;
  display: flex;
  align-items: center;
}

.label-assign-wrap {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.label-assign-wrap .label-filter-title {
  margin: 0;
  white-space: nowrap;
}

.label-assign-wrap .label-chip-list {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  padding-bottom: 2px;
  min-width: 0;
}

.label-assign-wrap .label-chip {
  cursor: pointer;
  flex: 0 0 auto;
}

.label-assign-wrap .label-chip.unassigned {
  opacity: 0.35;
}

.owner-messages {
  margin: 12px 16px;
  min-height: 300px;
}

.owner-send {
  padding: 10px 16px 6px;
}

.owner-send input {
  flex: 1;
  border: 1px solid #cbd5dc;
  border-radius: 10px;
  padding: 10px 12px;
}

@media (max-width: 980px) {
  .owner-app {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 10px;
    height: auto;
    overflow: visible;
  }

  .owner-left,
  .owner-right {
    border-radius: 12px;
  }

  .owner-right {
    min-height: 72vh;
  }

  .contact-tools {
    grid-template-columns: 1fr;
  }
}

.apps-page {
  max-width: 100%;
  min-height: 100vh;
  background: #f8fafb;
  color: #111b21;
  padding: 16px;
}

.apps-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.apps-header h1 {
  margin: 0;
  font-size: 1.4rem;
}

.apps-link {
  text-decoration: none;
  color: #fff;
  background: #2563eb;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 700;
}

.owner-apps-link {
  background: #334155;
}

.apps-toolbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  margin-bottom: 12px;
}

.apps-toolbar input {
  border: 1px solid #cbd5dc;
  border-radius: 8px;
  padding: 10px 12px;
}

.apps-table-wrap {
  overflow: auto;
  background: #fff;
  border: 1px solid #dce4ea;
  border-radius: 10px;
}

.apps-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1100px;
}

.apps-table th,
.apps-table td {
  border-bottom: 1px solid #eef3f6;
  padding: 10px;
  text-align: left;
  font-size: 0.86rem;
  vertical-align: top;
}

.apps-table th {
  background: #f5f8fa;
  position: sticky;
  top: 0;
  z-index: 1;
}

.apps-footer {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.apps-pagination {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 900px) {
  .apps-toolbar {
    grid-template-columns: 1fr;
  }

  .apps-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}
