:root {
  --app-bg: #d9dbd5;
  --wa-green: #075e54;
  --wa-green-2: #128c7e;
  --wa-light: #dcf8c6;
  --panel: #f0f2f5;
  --chat-bg: #efeae2;
  --ink: #111b21;
  --muted: #667781;
  --line: #d1d7db;
  --white: #ffffff;
  --police: #163b63;
  --red: #b8322a;
  --shadow: 0 18px 55px rgba(17, 27, 33, 0.2);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(var(--wa-green) 0 128px, var(--app-bg) 128px 100%);
  overflow: hidden;
}

button,
input {
  font: inherit;
}

a {
  color: var(--wa-green-2);
  font-weight: 700;
}

.app-shell {
  width: min(1220px, calc(100% - 28px));
  height: min(900px, calc(100dvh - 36px));
  min-height: min(640px, calc(100dvh - 36px));
  margin: 18px auto;
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  overflow: hidden;
  background: var(--white);
  border: 1px solid rgba(17, 27, 33, 0.12);
  box-shadow: var(--shadow);
}

.contacts-panel {
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--white);
  display: flex;
  flex-direction: column;
}

.contacts-top,
.chat-header {
  min-height: 64px;
  padding: 10px 16px;
  background: var(--panel);
  display: flex;
  align-items: center;
  gap: 12px;
}

.contacts-top img {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: var(--white);
}

.contacts-top strong,
.chat-identity strong {
  display: block;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.2;
}

.contacts-top span,
.chat-identity div span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.2;
}

.search-pill {
  margin: 10px 12px;
  min-height: 38px;
  padding: 10px 14px;
  color: var(--muted);
  background: var(--panel);
  border-radius: 8px;
  font-size: 0.92rem;
}

.contact-list {
  display: grid;
}

.contact-card {
  min-width: 0;
  min-height: 76px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: center;
  border-top: 1px solid #eef0f1;
  background: var(--white);
  cursor: pointer;
}

.contact-card.active {
  background: #e9edef;
}

.contact-card:focus-visible {
  outline: 3px solid rgba(18, 140, 126, 0.28);
  outline-offset: -3px;
}

.contact-card strong {
  display: block;
  color: var(--ink);
  font-size: 0.96rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  flex: 0 0 44px;
}

.brand-avatar,
.verify-avatar {
  background: var(--police);
}

.police-avatar,
.hint-avatar {
  background: var(--red);
}

.contact-card .avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  padding: 0;
  color: #fff;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.contact-card .verify-avatar {
  background: #163b63;
}

.contact-card .hint-avatar {
  background: #b8322a;
}

.chat-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--chat-bg);
  overflow: hidden;
}

.chat-header {
  justify-content: space-between;
  border-bottom: 1px solid rgba(17, 27, 33, 0.08);
}

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

[data-contact-avatar] {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 22px;
  font-weight: 950;
  line-height: 1;
  text-align: center;
}

[data-contact-avatar].hint-avatar {
  background: #b8322a;
  font-size: 24px;
}

[data-contact-avatar].verify-avatar {
  background: #163b63;
  font-size: 21px;
}

.chat-identity div {
  min-width: 0;
}

.chat-identity strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ghost-button {
  min-height: 36px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.ghost-button:hover {
  background: rgba(17, 27, 33, 0.08);
}

.lead-gate {
  width: min(430px, calc(100% - 30px));
  margin: auto;
  padding: 22px;
  max-height: calc(100dvh - 112px);
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--white);
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(17, 27, 33, 0.12);
}

.eyebrow {
  display: block;
  margin-bottom: 8px;
  color: var(--wa-green);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

h2,
p {
  margin-top: 0;
}

.lead-gate h2 {
  margin-bottom: 10px;
  font-size: 1.45rem;
}

.lead-gate p {
  color: var(--muted);
  line-height: 1.55;
}

form {
  display: grid;
  gap: 13px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 750;
}

input[type="text"],
input[type="email"],
select {
  font-size: 16px;
}

input[type="text"],
input[type="email"] {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

input:focus {
  border-color: var(--wa-green-2);
  box-shadow: 0 0 0 3px rgba(18, 140, 126, 0.16);
}

.check-row {
  grid-template-columns: 18px 1fr;
  align-items: start;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.42;
}

.check-row input {
  margin-top: 3px;
}

.primary-button,
.composer button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--wa-green);
  font-weight: 850;
  cursor: pointer;
}

.lead-gate .primary-button {
  position: sticky;
  bottom: 0;
  box-shadow: 0 -8px 18px rgba(255, 255, 255, 0.88);
}

.primary-button:hover,
.composer button:hover {
  background: #064c44;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--red);
}

.chat-area {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-rows: 1fr auto;
}

.messages {
  min-height: 0;
  padding: 24px clamp(14px, 3vw, 54px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background:
    linear-gradient(rgba(239, 234, 226, 0.92), rgba(239, 234, 226, 0.92)),
    radial-gradient(circle at 20px 20px, rgba(17, 27, 33, 0.08) 1px, transparent 1px);
  background-size: auto, 28px 28px;
}

.message {
  position: relative;
  max-width: min(78%, 640px);
  padding: 9px 12px 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
  border-radius: 8px;
  color: var(--ink);
  box-shadow: 0 1px 1px rgba(17, 27, 33, 0.14);
}

.message.assistant {
  align-self: flex-start;
  background: var(--white);
  border-top-left-radius: 2px;
}

.message.user {
  align-self: flex-end;
  background: var(--wa-light);
  border-top-right-radius: 2px;
}

.message.pending {
  color: var(--muted);
  font-size: 1.25rem;
  letter-spacing: 2px;
}

.system-message {
  align-self: center;
  max-width: min(88%, 520px);
  margin: 6px 0;
  padding: 7px 12px;
  color: #54656f;
  background: #fff5c4;
  border-radius: 8px;
  font-size: 0.82rem;
  text-align: center;
  line-height: 1.35;
  box-shadow: 0 1px 1px rgba(17, 27, 33, 0.12);
}

.quick-replies {
  align-self: flex-start;
  width: min(88%, 640px);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 10px;
}

.quick-replies button {
  min-height: 38px;
  border: 1px solid rgba(22, 59, 99, 0.28);
  border-radius: 999px;
  padding: 8px 13px;
  color: var(--police);
  background: #ffffff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 1px 1px rgba(17, 27, 33, 0.1);
}

.quick-replies button:hover {
  background: #e8eef5;
}

.verification-desk {
  align-self: flex-start;
  width: min(92%, 900px);
  display: grid;
  gap: 12px;
  margin: 4px 0 12px;
  padding: 12px;
  border: 1px solid rgba(17, 27, 33, 0.12);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 1px 1px rgba(17, 27, 33, 0.12);
}

.verification-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.verification-photo-card {
  min-width: 0;
  display: grid;
  gap: 6px;
  padding: 7px;
  border: 1px solid rgba(17, 27, 33, 0.1);
  border-radius: 8px;
  background: #f8fafb;
}

.verification-photo-card label {
  display: grid;
  gap: 6px;
}

.verification-photo-card label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.verification-photo-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 150px;
  object-fit: cover;
  border-radius: 6px;
  background: #e9edef;
}

.verification-desk select {
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  font: inherit;
  font-size: 0.86rem;
}

.verification-result {
  min-height: 24px;
  margin: 0;
  color: var(--police);
  font-weight: 850;
  line-height: 1.45;
}

.verification-note {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 8px;
  background: #f8fafb;
  border: 1px solid rgba(17, 27, 33, 0.1);
}

.verification-note p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.verification-next {
  justify-self: start;
  padding-inline: 16px;
}

.verification-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.secondary-button {
  min-height: 46px;
  border: 1px solid rgba(17, 27, 33, 0.16);
  border-radius: 8px;
  padding: 0 16px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
}

.train-choice {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 10px;
  overflow: visible;
  border: 1px solid rgba(17, 27, 33, 0.16);
  border-radius: 12px;
  background: linear-gradient(#dfe7ec, #b7c5ce);
}

.train-choice label {
  position: relative;
  min-height: 118px;
  display: grid;
  place-items: center;
  padding: 44px 10px 28px;
  color: #14202a;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.92) 0 18%, transparent 18% 22%, rgba(255,255,255,0.92) 22% 40%, transparent 40% 44%, rgba(255,255,255,0.92) 44% 62%, transparent 62% 66%, rgba(255,255,255,0.92) 66% 84%, transparent 84%),
    linear-gradient(#c83932, #8f1f20);
  border: 2px solid #263643;
  border-radius: 16px 16px 8px 8px;
  cursor: pointer;
  text-align: center;
  font-weight: 900;
  box-shadow: inset 0 -10px 0 rgba(17, 27, 33, 0.18);
}

.train-choice label:last-child {
  border-right: 2px solid #263643;
}

.train-choice label:nth-child(2) {
  background:
    linear-gradient(90deg, rgba(255,255,255,0.92) 0 16%, transparent 16% 21%, rgba(255,255,255,0.92) 21% 37%, transparent 37% 42%, rgba(255,255,255,0.92) 42% 58%, transparent 58% 63%, rgba(255,255,255,0.92) 63% 79%, transparent 79%),
    linear-gradient(#d4a642, #8c5a19);
}

.train-choice label:nth-child(3) {
  background:
    linear-gradient(90deg, rgba(255,255,255,0.92) 0 18%, transparent 18% 22%, rgba(255,255,255,0.92) 22% 40%, transparent 40% 44%, rgba(255,255,255,0.92) 44% 62%, transparent 62% 66%, rgba(255,255,255,0.92) 66% 84%, transparent 84%),
    linear-gradient(#315f8d, #173454);
}

.train-choice label::before,
.train-choice label::after {
  content: "";
  position: absolute;
  bottom: -11px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #c9d1d7 0 22%, #263643 24% 100%);
  border: 2px solid #111b21;
}

.train-choice label::before {
  left: 22px;
}

.train-choice label::after {
  right: 22px;
}

.train-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.train-choice input:checked + span {
  color: #fff;
  background: rgba(17, 27, 33, 0.62);
}

.train-choice label:has(input:checked) {
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.86), inset 0 -10px 0 rgba(17, 27, 33, 0.18), 0 0 0 3px rgba(194, 147, 70, 0.52);
}

.train-choice span {
  position: relative;
  z-index: 1;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
}

.people-checklist {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.people-checklist label {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(17, 27, 33, 0.12);
  border-radius: 8px;
  background: #f8fafb;
  cursor: pointer;
}

.people-checklist input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.code-verification-field {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 850;
}

.code-verification-field input {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fffdf8;
  font: inherit;
}

.composer {
  min-height: 68px;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: 1fr 92px;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border-top: 1px solid rgba(17, 27, 33, 0.08);
}

.composer input {
  min-height: 46px;
  border-radius: 999px;
  border: 0;
  padding: 0 18px;
}

.composer input:disabled,
.composer button:disabled {
  opacity: 0.68;
  cursor: wait;
}

.composer button {
  border-radius: 999px;
}

.choice-composer {
  min-height: 56px;
  padding: 12px 16px;
  display: grid;
  place-items: center;
  color: #54656f;
  background: var(--panel);
  border-top: 1px solid rgba(17, 27, 33, 0.08);
  font-size: 0.88rem;
  font-weight: 800;
  text-align: center;
}

body[data-contact="fenix"] .chat-header {
  background: #e8eef5;
}

body[data-contact="fenix"] .composer button {
  background: var(--police);
}

body[data-contact="fenix"] .message.user {
  background: #d9e8f7;
}

.hidden {
  display: none !important;
}

@media (max-width: 820px) {
  body {
    background: var(--app-bg);
  }

  .app-shell {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    border: 0;
  }

  .contacts-panel {
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    display: block;
  }

  .contacts-top,
  .search-pill {
    display: none;
  }

  .contact-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .contact-card {
    min-height: 58px;
    padding: 8px 10px;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 8px;
    border-top: 0;
    border-right: 1px solid #eef0f1;
  }

  .contact-card:last-child {
    border-right: 0;
  }

  .contact-card strong {
    font-size: 0.86rem;
  }

  .contact-card p {
    margin-top: 2px;
    font-size: 0.74rem;
  }

  .avatar {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
    font-size: 0.82rem;
  }

  .contact-card .avatar {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    font-size: 0.82rem;
  }

  [data-contact-avatar] {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    font-size: 20px;
    line-height: 1;
  }

  [data-contact-avatar].hint-avatar {
    font-size: 22px;
  }

  [data-contact-avatar].verify-avatar {
    font-size: 19px;
  }

  .chat-panel {
    min-height: 0;
  }

  .lead-gate {
    margin: 12px auto;
    max-height: calc(100dvh - 138px);
  }

  .chat-header {
    min-height: 56px;
    padding: 8px 12px;
  }

  .message {
    max-width: min(92%, 620px);
  }

  .messages {
    padding: 16px 12px;
  }

  .quick-replies {
    width: 100%;
  }

  .verification-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .verification-desk {
    width: 100%;
  }

  .verification-photo-card {
    padding: 6px;
  }

  .verification-photo-card img {
    max-height: 112px;
  }

  .verification-photo-card label {
    font-size: 0.72rem;
  }

  .verification-desk select {
    min-height: 32px;
    padding: 5px 6px;
    font-size: 0.78rem;
  }

  .train-choice,
  .people-checklist {
    grid-template-columns: 1fr;
  }

  .train-choice label {
    min-height: 78px;
    border-right: 0;
    border-bottom: 2px solid #263643;
  }

  .train-choice label:last-child {
    border-bottom: 0;
  }
}

@media (max-width: 480px) {
  .contact-card {
    min-height: 54px;
    padding: 7px 8px;
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .avatar {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
    font-size: 0.76rem;
  }

  .contact-card .avatar {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    font-size: 0.76rem;
  }

  [data-contact-avatar] {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    font-size: 18px;
    line-height: 1;
  }

  [data-contact-avatar].hint-avatar {
    font-size: 20px;
  }

  [data-contact-avatar].verify-avatar {
    font-size: 17px;
  }

  .contact-card strong {
    font-size: 0.8rem;
  }

  .contact-card p {
    font-size: 0.68rem;
  }

  .chat-header {
    padding: 9px 10px;
  }

  .chat-identity {
    gap: 8px;
  }

  .chat-identity strong {
    font-size: 0.9rem;
  }

  .chat-identity div span {
    font-size: 0.74rem;
  }

  .ghost-button {
    min-height: 34px;
    padding: 0 8px;
    font-size: 0.78rem;
  }

  .lead-gate {
    width: min(100% - 20px, 430px);
    padding: 14px;
    max-height: calc(100dvh - 126px);
  }

  .lead-gate h2 {
    font-size: 1.22rem;
    margin-bottom: 7px;
  }

  .lead-gate p {
    margin-bottom: 8px;
    line-height: 1.35;
  }

  form {
    gap: 9px;
  }

  input[type="text"],
  input[type="email"],
  .primary-button {
    min-height: 42px;
  }

  .messages {
    padding: 14px 8px;
  }

  .message {
    max-width: 96%;
    font-size: 0.92rem;
  }

  .quick-replies button {
    min-height: 36px;
    padding: 7px 10px;
    font-size: 0.82rem;
  }

  .verification-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .verification-desk {
    width: 100%;
    padding: 8px;
  }

  .verification-photo-card {
    gap: 4px;
    padding: 5px;
  }

  .verification-photo-card img {
    max-height: 96px;
    border-radius: 5px;
  }

  .verification-photo-card label {
    gap: 3px;
    font-size: 0.66rem;
    line-height: 1.15;
  }

  .verification-desk select {
    min-height: 29px;
    padding: 4px 5px;
    font-size: 0.72rem;
  }

  .verification-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .verification-next,
  .verification-actions .primary-button,
  .secondary-button,
  .verification-desk > .primary-button {
    width: 100%;
    justify-self: stretch;
  }

  .train-choice {
    padding: 7px;
  }

  .train-choice label {
    min-height: 68px;
    padding: 28px 8px 22px;
    font-size: 0.84rem;
  }

  .train-choice label::before,
  .train-choice label::after {
    width: 17px;
    height: 17px;
    bottom: -9px;
  }

  .train-choice label::before {
    left: 16px;
  }

  .train-choice label::after {
    right: 16px;
  }

  .people-checklist {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .people-checklist label {
    min-height: 42px;
    padding: 8px;
    font-size: 0.84rem;
  }

  .code-verification-field input {
    min-height: 42px;
    font-size: 16px;
  }

  .composer {
    grid-template-columns: 1fr 76px;
    padding: 9px 10px;
  }
}
