:root {
  --green: #147d63;
  --green-dark: #0d604c;
  --green-light: #e5f4ef;
  --ink: #17231f;
  --muted: #78847f;
  --line: #e7ece9;
  --page: #f5f7f6;
  --white: #fff;
  --shadow: 0 16px 50px rgba(26, 50, 40, .12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 5vw;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}

.brand, .top-actions, .card-top, .card-bottom, .column-header,
.conversation-header, .conversation-identity {
  display: flex;
  align-items: center;
}

.brand { gap: 11px; }
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--green);
  font-weight: 800;
}
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 2px; }
.top-actions { gap: 20px; }
.online { color: #68756f; font-size: 13px; }
.online i {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: #2da977;
}
.logout { color: var(--muted); text-decoration: none; font-size: 13px; }

.workspace { max-width: 1440px; margin: 0 auto; padding: 38px 5vw 60px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 26px; }
.eyebrow { color: var(--green); font-size: 10px; letter-spacing: .15em; font-weight: 800; margin: 0 0 8px; }
h1 { margin: 0; font-size: clamp(25px, 3vw, 34px); letter-spacing: -.04em; }
.subheading { color: var(--muted); margin: 9px 0 0; font-size: 14px; }

.primary-button, .secondary-button {
  border: 0;
  border-radius: 10px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 700;
  transition: .15s ease;
}
.primary-button { color: #fff; background: var(--green); }
.primary-button:hover { background: var(--green-dark); }
.primary-button:disabled { opacity: .65; cursor: wait; }
.secondary-button { color: var(--ink); background: white; border: 1px solid var(--line); }
.secondary-button:hover { border-color: #bccbc4; }

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(230px, 1fr));
  gap: 16px;
  align-items: start;
  overflow-x: auto;
  padding-bottom: 12px;
}
.column {
  min-height: 260px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #eef2f0;
}
.column-header { justify-content: space-between; margin-bottom: 14px; }
.column-header > div { display: flex; align-items: center; gap: 9px; }
.column-header h2 { font-size: 13px; margin: 0; }
.column-count {
  display: grid;
  place-items: center;
  height: 22px;
  min-width: 22px;
  padding: 0 6px;
  background: white;
  color: var(--muted);
  border-radius: 7px;
  font-size: 11px;
}
.column-dot { width: 9px; height: 9px; border-radius: 50%; background: #9ca9a3; }
.dot-em-conversa { background: #4b9ee8; }
.dot-proposta { background: #e8a43c; }
.dot-fechado { background: #28a779; }
.column-cards { min-height: 190px; display: grid; align-content: start; gap: 10px; }
.column-empty { padding: 24px 8px; text-align: center; color: #a0aaa5; font-size: 12px; }

.lead-card {
  padding: 13px;
  border-radius: 12px;
  background: var(--white);
  border: 1px solid #e8eeeb;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(25, 50, 40, .025);
}
.lead-card:hover { border-color: #b8d9cc; box-shadow: 0 6px 18px rgba(25, 50, 40, .07); }
.lead-card.dragging { opacity: .45; }
.card-top { gap: 9px; }
.contact-avatar {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: var(--green-dark);
  background: var(--green-light);
  font-weight: 800;
}
.contact-avatar.small { width: 34px; height: 34px; border-radius: 11px; font-size: 13px; }
.lead-identity { min-width: 0; flex: 1; }
.lead-identity strong, .lead-identity span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-identity strong { font-size: 12px; }
.lead-identity span { color: var(--muted); font-size: 11px; margin-top: 4px; }
.unread {
  display: grid;
  place-items: center;
  height: 21px;
  min-width: 21px;
  padding: 0 5px;
  border-radius: 99px;
  color: white;
  background: var(--green);
  font-size: 10px;
  font-weight: 700;
}
.last-message {
  margin: 13px 0;
  color: #64716b;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-bottom { justify-content: space-between; color: #9aa49f; font-size: 10px; }
.loading, .empty-state { padding: 30px; text-align: center; color: var(--muted); font-size: 13px; }

.notice {
  margin: 0 0 15px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
}
.notice.success { background: #e5f4ef; color: #17684f; }
.notice.error { background: #fff0ee; color: #a63b31; }

.overlay {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 31, 26, .46);
}
.hidden { display: none !important; }
.conversation {
  width: min(760px, 100%);
  height: min(780px, 92vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: white;
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.conversation-header {
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}
.conversation-identity { min-width: 0; flex: 1; align-items: flex-start; flex-direction: column; gap: 4px; }
.conversation-identity strong { font-size: 14px; }
.conversation-identity span { color: var(--muted); font-size: 12px; }
.stage-picker { display: grid; gap: 4px; color: var(--muted); font-size: 10px; }
.stage-picker select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  color: var(--ink);
  background: white;
  font-size: 12px;
}
.icon-button {
  border: 0;
  background: transparent;
  color: #78847f;
  cursor: pointer;
  font-size: 26px;
  line-height: 1;
}
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
  background: #f7f9f8;
}
.message-row { display: flex; margin: 9px 0; }
.message-row.outgoing { justify-content: flex-end; }
.bubble { max-width: min(78%, 520px); padding: 10px 12px 7px; border-radius: 13px; background: white; box-shadow: 0 1px 3px #16251e0d; }
.outgoing .bubble { background: #dff4e9; }
.bubble p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.5; }
.bubble time { display: block; margin-top: 5px; color: #89968f; text-align: right; font-size: 9px; }
.composer { display: flex; gap: 10px; align-items: end; padding: 13px; border-top: 1px solid var(--line); }
.composer textarea {
  flex: 1;
  resize: vertical;
  min-height: 44px;
  max-height: 130px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
.composer textarea:focus, input:focus { border-color: #65ad91; outline: 2px solid #65ad9122; }

.new-contact-card, .login-card {
  position: relative;
  width: min(420px, 100%);
  display: grid;
  gap: 10px;
  padding: 28px;
  border-radius: 18px;
  background: white;
  box-shadow: var(--shadow);
}
.new-contact-card h2 { margin: 0 0 7px; }
.new-contact-card label, .login-card label { margin-top: 5px; font-size: 12px; font-weight: 700; }
.new-contact-card input, .login-card input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
}
.field-hint { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.modal-close { position: absolute; top: 15px; right: 17px; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(390px, 100%); }
.login-card .brand-mark { margin-bottom: 3px; }
.login-card h1 { font-size: 25px; }
.login-card > p { color: var(--muted); font-size: 13px; margin: 0 0 8px; }

@media (max-width: 900px) {
  .board { grid-template-columns: repeat(4, minmax(245px, 1fr)); }
}
@media (max-width: 600px) {
  .topbar { height: 64px; padding: 0 16px; }
  .top-actions { gap: 10px; }
  .online, .logout { display: none; }
  .top-actions .primary-button { padding: 9px 11px; font-size: 12px; }
  .workspace { padding: 27px 16px 40px; }
  .page-heading { align-items: flex-start; gap: 12px; }
  .page-heading .secondary-button { padding: 9px 11px; font-size: 12px; }
  .subheading { max-width: 270px; line-height: 1.5; }
  .overlay { padding: 0; }
  .conversation { width: 100%; height: 100dvh; border-radius: 0; }
  .conversation-header { padding: 12px; gap: 8px; }
  .stage-picker select { max-width: 105px; }
  .composer { padding: 10px; }
  .composer .primary-button { max-width: 145px; padding: 10px; font-size: 11px; }
  .new-contact-card { border-radius: 16px; }
}
