.netbill-chat-fab {
  position: fixed;
  z-index: 99998;
  right: 1rem;
  bottom: max(1rem, env(safe-area-inset-bottom, 1rem));
  width: 3.5rem;
  height: 3.5rem;
  border: none;
  border-radius: 9999px;
  background: hsl(195 85% 43%);
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.netbill-chat-fab:hover {
  filter: brightness(1.05);
}

.netbill-chat-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99998;
  background: rgba(0, 0, 0, 0.4);
}

.netbill-chat-backdrop-open {
  display: block;
}

.netbill-chat-panel {
  position: fixed;
  z-index: 99999;
  display: none;
  flex-direction: column;
  background: #fff;
  color: #111;
  border: 1px solid #e5e7eb;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  right: 1rem;
  bottom: 5rem;
  width: 20rem;
  height: 30rem;
  border-radius: 0.75rem;
}

.netbill-chat-panel-open {
  display: flex;
}

@media (max-width: 640px) {
  .netbill-chat-panel {
    inset: auto 0 0 0;
    width: 100%;
    height: min(85dvh, 520px);
    border-radius: 0.75rem 0.75rem 0 0;
    bottom: 0;
  }

  .netbill-chat-backdrop-open {
    display: block;
  }
}

.netbill-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
  flex-shrink: 0;
}

.netbill-chat-tabs {
  display: flex;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.netbill-chat-tab {
  flex: 1;
  border: none;
  background: #f9fafb;
  padding: 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
  color: #6b7280;
}

.netbill-chat-tab-active {
  background: #fff;
  color: hsl(195 85% 35%);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 hsl(195 85% 43%);
}

.netbill-chat-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.netbill-chat-view {
  flex: 1;
  min-height: 0;
  display: none;
  flex-direction: column;
  padding: 0.75rem;
  gap: 0.5rem;
  overflow-y: auto;
}

.netbill-chat-view:not([hidden]) {
  display: flex;
}

.netbill-chat-view[hidden] {
  display: none !important;
}

.netbill-chat-view-chat {
  padding: 0;
}

.netbill-chat-view-chat .netbill-chat-messages {
  padding: 0.75rem;
}

.netbill-chat-view-chat .netbill-chat-escalate,
.netbill-chat-view-chat .netbill-chat-input-row {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

.netbill-chat-escalate[hidden] {
  display: none !important;
}

.netbill-chat-login-step[hidden],
.netbill-chat-login-done[hidden],
.netbill-lead-coverage[hidden],
.netbill-lead-plan[hidden],
.netbill-lead-status[hidden],
.netbill-chat-auth-badge[hidden] {
  display: none !important;
}

.netbill-chat-auth-badge {
  margin: 0.5rem 0.75rem 0;
  padding: 0.35rem 0.5rem;
  background: rgba(14, 165, 233, 0.12);
  border-radius: 0.375rem;
  font-size: 0.75rem;
  color: hsl(195 85% 30%);
}

.netbill-chat-help {
  margin: 0;
  font-size: 0.8rem;
  color: #6b7280;
}

.netbill-chat-view input,
.netbill-chat-view textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  padding: 0.5rem 0.625rem;
  font-size: 0.875rem;
  box-sizing: border-box;
}

.netbill-chat-view button {
  border: none;
  border-radius: 0.375rem;
  background: hsl(195 85% 43%);
  color: #fff;
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem;
  cursor: pointer;
}

.netbill-chat-view button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.netbill-chat-logout {
  background: #6b7280 !important;
}

.netbill-lead-status-ok {
  color: #059669;
  font-size: 0.875rem;
}

.netbill-lead-status-err {
  color: #dc2626;
  font-size: 0.875rem;
}

.netbill-chat-link-btn {
  border: none;
  background: none;
  color: hsl(195 85% 35%);
  cursor: pointer;
  font-size: inherit;
  padding: 0;
  text-decoration: underline;
}

.netbill-chat-otp-hint {
  margin: 0;
  font-size: 0.8rem;
  color: #6b7280;
}

.netbill-chat-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.netbill-chat-close {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: #6b7280;
}

.netbill-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.netbill-chat-empty {
  margin: 0;
  color: #6b7280;
  font-size: 0.875rem;
}

.netbill-chat-msg {
  max-width: 90%;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.netbill-chat-msg-user {
  margin-left: auto;
  background: rgba(14, 165, 233, 0.15);
}

.netbill-chat-msg-assistant {
  background: #f3f4f6;
  color: #374151;
}

.netbill-chat-escalate {
  padding: 0 0.75rem 0.5rem;
  font-size: 0.75rem;
  color: #6b7280;
}

.netbill-chat-escalate a {
  color: hsl(195 85% 35%);
}

.netbill-chat-input-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid #e5e7eb;
}

.netbill-chat-input {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  padding: 0.5rem 0.625rem;
  font-size: 0.875rem;
}

.netbill-chat-send {
  border: none;
  border-radius: 0.375rem;
  background: hsl(195 85% 43%);
  color: #fff;
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem;
  cursor: pointer;
}

.netbill-chat-send:disabled,
.netbill-chat-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.netbill-chat-pending .netbill-chat-messages::after {
  content: '…';
  color: hsl(195 85% 43%);
  padding: 0.25rem 0.75rem;
}
