@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=Fraunces:opsz,wght@9..144,600&display=swap");

:root {
  --bg: #f6f5ef;
  --ink: #102a27;
  --ink-soft: #2d4a46;
  --brand: #114b46;
  --brand-2: #2f7a72;
  --accent: #d95f87;
  --lime: #9bcf3c;
  --line: #d7d8ce;
  --card: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  background: radial-gradient(circle at 10% 10%, #ffffff 0%, var(--bg) 45%),
    linear-gradient(120deg, #eef3e5 0%, #f7f0ea 100%);
  color: var(--ink);
}

.hero {
  padding: 2.4rem 1.2rem 1.2rem;
  text-align: center;
}

.eyebrow {
  margin: 0;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--brand-2);
}

h1 {
  font-family: "Fraunces", serif;
  margin: 0.4rem 0;
  font-size: clamp(1.9rem, 4vw, 2.8rem);
}

.subtitle {
  margin: 0 auto;
  max-width: 860px;
  color: var(--ink-soft);
}

.hero-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.7rem;
  justify-content: center;
  flex-wrap: wrap;
}

.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 1100px) {
  .layout {
    grid-template-columns: 440px 1fr;
    align-items: start;
  }

  .layout > .card:first-child {
    position: sticky;
    top: 1rem;
  }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 6px 30px rgba(25, 52, 48, 0.08);
  padding: 1rem;
}

h2 {
  margin-top: 0;
  margin-bottom: 0.7rem;
  font-size: 1.1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

.full-width {
  grid-column: 1 / -1;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.34rem;
  font-size: 0.86rem;
  color: var(--ink-soft);
}

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

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.56rem 0.62rem;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

.btn {
  border-radius: 999px;
  padding: 0.56rem 0.95rem;
  border: 0;
  cursor: pointer;
  font-weight: 600;
}

.btn-primary {
  background: linear-gradient(120deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
}

.btn-secondary {
  background: #e9eee8;
  color: var(--ink);
}

.table-header {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  align-items: center;
  flex-wrap: wrap;
}

.filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  max-height: 68vh;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1180px;
  table-layout: fixed;
}

th,
td {
  padding: 0.62rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.84rem;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #fff;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.col-actions,
.cell-actions {
  left: 0;
  width: 168px;
  min-width: 168px;
}

th.col-actions,
td.cell-actions {
  position: sticky;
  left: 0;
  z-index: 4;
  background: #fff;
  box-shadow: 1px 0 0 var(--line);
}

td.cell-actions {
  z-index: 2;
}

.cell-name { width: 170px; }
.cell-phone { width: 92px; }
.col-email,
.cell-email { width: 150px; }
.cell-method { width: 84px; }
.cell-pipeline { width: 78px; }
.col-response,
.cell-response { width: 250px; }
.cell-next { width: 126px; }
.cell-date { width: 76px; }
.cell-count { width: 54px; text-align: center; }
.cell-owner { width: 96px; }
.cell-type { width: 92px; }

.cell-email,
.cell-response small,
.cell-next {
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-email {
  white-space: nowrap;
}

.cell-response small {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.35;
}

.status-pill {
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  display: inline-block;
}

.status-nuevo {
  background: #f3f3f0;
}

.status-intento_1_enviado {
  background: #edf4fb;
}

.status-intento_2_enviado {
  background: #e3ecfb;
}

.status-conversacion_abierta {
  background: #ddf4e8;
}

.status-interesado {
  background: #d8edf9;
}

.status-propuesta_enviada {
  background: #e9e6fb;
}

.status-en_negociacion {
  background: #f9efdc;
}

.status-ganado {
  background: #dff2d3;
}

.status-perdido {
  background: #f8dfdf;
}

.status-en_nurture {
  background: #f5f1dc;
}

.action-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.28rem;
}

.mini {
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0.24rem 0.38rem;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.1;
}

.mini.history-btn {
  grid-column: 1 / -1;
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.mini.danger-btn {
  color: #991b1b;
}

.mini.sms-sent {
  background: #059669;
  color: #fff;
  border-color: #059669;
}

.mini.sms-btn { font-weight: 600; }
.mini.sms-1 { border-color: #059669; color: #059669; }
.mini.sms-2 { border-color: #d97706; color: #d97706; }
.mini.sms-3 { border-color: #dc2626; color: #dc2626; }
.mini.wa-btn { border-color: #25d366; color: #25d366; font-weight: 600; }

.history-panel {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-left: 6px solid var(--brand);
  border-radius: 14px;
  padding: 1rem;
  background: #fff;
}

.history-panel h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.history-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0 0 0.75rem;
  font-size: 0.84rem;
  color: var(--ink-soft);
}

.history-meta strong {
  color: var(--ink);
  font-size: 1rem;
}

.active-contact-label {
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  padding: 0.18rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.history-note {
  margin: -0.25rem 0 0.9rem;
  font-size: 0.84rem;
  color: var(--ink-soft);
}

.history-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.history-list-wrap {
  margin-top: 0.8rem;
  overflow-x: auto;
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.inline-help {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.pipeline-stats {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.stat-pill {
  background: #f3f3f0;
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.stat-pill.stat-ok { background: #d1fae5; color: #065f46; }
.stat-pill.stat-warn { background: #fee2e2; color: #991b1b; }

tr.overdue td {
  background: #fff5f5;
}

tr.selected-contact td {
  background: #ecfdf5;
}

tr.selected-contact td.cell-actions {
  box-shadow: inset 4px 0 0 var(--brand), 1px 0 0 var(--line);
}

tr.overdue .cell-next,
tr.overdue .cell-date {
  color: #dc2626;
  font-weight: 600;
}

.sms-banner {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 2px solid var(--brand);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(17, 75, 70, 0.18);
  padding: 1rem 1.4rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  z-index: 9999;
  max-width: 92vw;
  animation: banner-in 0.2s ease;
}

@keyframes banner-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.sms-banner-text {
  font-size: 0.95rem;
  color: var(--ink);
}

.sms-banner-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
