:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #f0f3f6;
  --text: #17202a;
  --muted: #697586;
  --line: #dde3ea;
  --brand: #0f766e;
  --brand-strong: #115e59;
  --brand-soft: #d9f4ef;
  --danger: #b42318;
  --shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 390px) 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 22px;
}

.brand,
.topbar,
.section-heading,
.dialog-header,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  justify-content: flex-start;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 28px;
}

h3 {
  font-size: 15px;
}

.brand p,
#lead-meta,
.eyebrow,
.details-list dt,
.activity-list,
.lead-card p,
.metrics span {
  color: var(--muted);
}

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

.metrics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-soft);
}

.metrics strong,
.metrics span {
  display: block;
}

.metrics strong {
  font-size: 22px;
}

.toolbar {
  display: grid;
  gap: 10px;
}

.search {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  outline: none;
  padding: 11px 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.primary-button,
.ghost-button,
.text-button,
.icon-button,
.quick-replies button {
  border: 0;
  border-radius: 8px;
  padding: 11px 14px;
  font-weight: 700;
}

.primary-button {
  background: var(--brand);
  color: white;
}

.primary-button:hover {
  background: var(--brand-strong);
}

.ghost-button,
.quick-replies button {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
}

.text-button,
.icon-button {
  background: transparent;
  color: var(--brand);
}

.stage-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.public-links {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.public-links a {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--brand-strong);
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.public-links a:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.stage-tabs button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--muted);
  padding: 8px 12px;
}

.stage-tabs button.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-weight: 800;
}

.lead-list {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.lead-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 14px;
  text-align: left;
}

.lead-card.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.lead-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.lead-card strong {
  display: block;
  margin-bottom: 4px;
}

.badge {
  align-self: flex-start;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 24px;
}

.topbar {
  min-height: 82px;
  margin-bottom: 20px;
}

.eyebrow {
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-actions select {
  min-width: 170px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 20px;
  min-height: 0;
  flex: 1;
}

.chat-panel,
.details-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.chat-panel {
  display: grid;
  grid-template-rows: minmax(280px, 1fr) auto auto;
  min-height: 0;
}

.chat-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  padding: 20px;
}

.message {
  max-width: min(76%, 620px);
  border-radius: 8px;
  padding: 11px 13px;
  line-height: 1.45;
}

.message.inbound {
  align-self: flex-start;
  background: var(--panel-soft);
}

.message.outbound {
  align-self: flex-end;
  background: var(--brand);
  color: white;
}

.message time {
  display: block;
  margin-top: 6px;
  opacity: 0.68;
  font-size: 12px;
}

.message p {
  margin: 0;
}

.message-media {
  display: block;
  width: min(260px, 100%);
  max-height: 320px;
  margin-bottom: 8px;
  border-radius: 8px;
  object-fit: cover;
}

.quick-replies,
.composer {
  display: flex;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 12px;
}

.quick-replies {
  flex-wrap: wrap;
}

.composer input {
  flex: 1;
}

.composer #media-input {
  max-width: 260px;
}

.details-panel {
  display: grid;
  align-content: start;
  gap: 22px;
  padding: 20px;
  overflow: auto;
}

.details-list {
  display: grid;
  gap: 12px;
  margin: 14px 0 0;
}

.details-list div {
  display: grid;
  gap: 4px;
}

.details-list dt {
  font-size: 12px;
}

.details-list dd {
  margin: 0;
  font-weight: 700;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tag {
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 800;
}

.section-caption {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.model-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
  max-height: 390px;
  overflow: auto;
  padding-right: 4px;
}

.model-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 8px;
  color: var(--text);
  text-align: left;
}

.model-card:hover {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.model-card img {
  width: 100%;
  aspect-ratio: 1 / 1.18;
  border-radius: 6px;
  object-fit: cover;
  background: var(--panel-soft);
}

.model-card span {
  font-size: 12px;
  font-weight: 800;
}

textarea {
  margin-top: 10px;
  resize: vertical;
}

.activity-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  font-size: 14px;
}

.activity {
  border-left: 3px solid var(--brand);
  padding-left: 10px;
}

dialog {
  width: min(460px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.44);
}

.legal-page {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 70px;
}

.legal-page h1 {
  margin: 12px 0 8px;
  font-size: 34px;
}

.legal-page h2 {
  margin-bottom: 8px;
  font-size: 20px;
}

.legal-page section {
  margin-top: 26px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.legal-page p {
  color: var(--muted);
  line-height: 1.7;
}

.back-link {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--brand-strong);
  padding: 10px 12px;
  font-weight: 800;
  text-decoration: none;
}

#lead-form {
  display: grid;
  gap: 14px;
  padding: 20px;
}

#lead-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  display: grid;
  min-height: 220px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 980px) {
  .app-shell,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .lead-list {
    max-height: 360px;
  }

  .topbar,
  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .sidebar,
  .workspace {
    padding: 16px;
  }

  h2 {
    font-size: 23px;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .composer {
    flex-direction: column;
  }

  .composer #media-input {
    max-width: none;
  }

  .message {
    max-width: 92%;
  }
}
