@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700;800;900&family=Geist+Mono:wght@400;500&display=swap');

* { box-sizing: border-box; }

:root {
  --primary: #0F5F4C;
  --primary-deep: #0A4537;
  --primary-soft: #E8F0EC;
  --accent: #F5C26B;
  --accent-deep: #E2A538;
  --gold: #FFC200;

  --ink: #0F1410;
  --ink-2: #2A322D;
  --ink-3: #5A645E;
  --ink-4: #8A938D;

  --paper: #FAF8F4;
  --paper-2: #F2EFE8;
  --paper-3: #E9E5DC;
  --line: rgba(15, 20, 16, 0.08);
  --line-2: rgba(15, 20, 16, 0.14);

  --ok: #1F7A56;
  --warn: #B8742B;
  --bad: #9A3A2E;

  --c-novo: #0F5F4C;
  --c-contatado: #B8742B;
  --c-fechado: #1F7A56;
  --c-descartado: #8A938D;

  --shadow-1: 0 1px 2px rgba(15,20,16,0.04), 0 4px 12px rgba(15,20,16,0.04);
  --shadow-2: 0 8px 24px rgba(15,20,16,0.12);
  --shadow-3: 0 24px 60px rgba(0,0,0,0.18);

  --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, monospace;
}

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--paper-2);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select { font-family: inherit; }

/* ============ Login ============ */
.login-wrap {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-deep) 100%);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--paper); border-radius: 18px;
  padding: 28px 24px; box-shadow: var(--shadow-3);
}
.login-card h1 { font-size: 22px; margin: 0 0 4px; font-weight: 800; letter-spacing: -0.01em; }
.login-card p { color: var(--ink-3); margin: 0 0 20px; font-size: 14px; }
.login-card label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.login-card input[type="password"] {
  width: 100%; border: 1.5px solid var(--line-2); border-radius: 12px;
  padding: 12px 14px; font-size: 16px; background: var(--paper);
}
.login-card input[type="password"]:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
.login-card button {
  width: 100%; margin-top: 16px;
  background: var(--primary); color: white; border: 0; border-radius: 12px;
  padding: 14px; font-size: 15px; font-weight: 700; cursor: pointer;
}
.login-card button:disabled { opacity: 0.5; cursor: not-allowed; }
.login-error { color: var(--bad); font-size: 13px; margin-top: 8px; }

/* ============ Shell + topbar ============ */
.shell { min-height: 100dvh; }

.topbar {
  background: white; border-bottom: 1px solid var(--line);
  padding: 10px 16px; display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 30;
}
.brand {
  font-weight: 800; font-size: 15px; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap;
}
.brand-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 95, 76, 0.15);
}
.brand small { color: var(--ink-4); font-weight: 500; margin-left: 2px; }

.search {
  flex: 1; max-width: 480px;
  display: flex; align-items: center; gap: 8px;
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px;
  color: var(--ink-3);
}
.search:focus-within { border-color: var(--primary); background: white; }
.search svg { flex-shrink: 0; }
.search input {
  flex: 1; border: 0; background: transparent;
  font-size: 14px; outline: none; color: var(--ink);
}
.search input::-webkit-search-cancel-button { display: none; }
.search-clear {
  background: transparent; border: 0; color: var(--ink-4);
  cursor: pointer; font-size: 18px; line-height: 1; padding: 0 4px;
}
.search-clear:hover { color: var(--ink); }

.topbar-actions { display: flex; gap: 6px; }
.ghost {
  background: transparent; border: 1px solid var(--line-2);
  border-radius: 10px; padding: 8px 12px; font-size: 13px; cursor: pointer;
  color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px;
  transition: background 0.15s;
}
.ghost:hover { background: var(--paper-2); }
.ghost:disabled { opacity: 0.5; cursor: wait; }

/* ============ Stats ============ */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  padding: 14px 16px 0;
}
.stat {
  background: white; border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 2px;
  box-shadow: var(--shadow-1);
}
.stat-num {
  font-size: 28px; font-weight: 800; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; line-height: 1;
}
.stat-lbl {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-4); font-weight: 600; margin-top: 6px;
}
.stat[data-tone="novo"] { border-top: 3px solid var(--c-novo); }
.stat[data-tone="contatado"] { border-top: 3px solid var(--c-contatado); }
.stat[data-tone="fechado"] { border-top: 3px solid var(--c-fechado); }
.stat[data-tone="descartado"] { border-top: 3px solid var(--c-descartado); }

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat-num { font-size: 22px; }
}

/* ============ Filtros (chips) ============ */
.filters {
  padding: 12px 16px;
  display: flex; gap: 16px; flex-wrap: wrap;
}
.chips { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chips-lbl { font-size: 11px; color: var(--ink-4); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin-right: 2px; }
.chip {
  background: white; border: 1px solid var(--line-2);
  border-radius: 999px; padding: 6px 12px; font-size: 12.5px;
  cursor: pointer; color: var(--ink-2); white-space: nowrap;
  transition: all 0.12s;
}
.chip:hover { background: var(--paper-2); }
.chip-active { background: var(--ink); color: white; border-color: var(--ink); }

/* ============ Tabs (mobile) ============ */
.tabs {
  display: flex; gap: 4px;
  padding: 4px; margin: 8px 16px 12px;
  background: white; border: 1px solid var(--line); border-radius: 12px;
  overflow-x: auto;
}
.tab {
  flex: 1;
  background: transparent; border: 0;
  border-radius: 8px; padding: 8px 10px;
  font-size: 12.5px; font-weight: 600; cursor: pointer;
  color: var(--ink-3); white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.tab-active { background: var(--ink); color: white; }
.tab-count {
  background: rgba(0,0,0,0.08); padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-variant-numeric: tabular-nums;
}
.tab-active .tab-count { background: rgba(255,255,255,0.2); }

/* ============ Kanban ============ */
.kanban {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px; padding: 4px 16px 80px;
  align-items: start;
}
.kanban-mobile { grid-template-columns: 1fr; padding-top: 0; }

.col {
  background: var(--paper-3); border-radius: 14px;
  padding: 10px; min-height: 280px;
  transition: background 0.15s, outline 0.15s;
  outline: 2px dashed transparent; outline-offset: -6px;
}
.col.is-over { background: var(--primary-soft); outline-color: var(--primary); }

.col-head {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px 12px;
  font-size: 12.5px; font-weight: 700;
  color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.05em;
}
.col-head::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
}
.col-head[data-status="novo"]::before { background: var(--c-novo); }
.col-head[data-status="contatado"]::before { background: var(--c-contatado); }
.col-head[data-status="fechado"]::before { background: var(--c-fechado); }
.col-head[data-status="descartado"]::before { background: var(--c-descartado); }
.col-title { flex: 1; }
.col-count {
  background: white; color: var(--ink-2);
  padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-variant-numeric: tabular-nums;
  font-weight: 700; letter-spacing: 0;
}
.col-body {
  display: flex; flex-direction: column; gap: 8px;
}
.col-empty {
  text-align: center; color: var(--ink-4); font-size: 12px;
  padding: 28px 8px; opacity: 0.6; font-style: italic;
}

/* ============ Card ============ */
.card {
  background: white; border-radius: 10px;
  padding: 10px 12px; cursor: grab;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.12s;
  position: relative;
}
.card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
  border-color: var(--line-2);
}
.card:active { cursor: grabbing; }
.card.is-dragging { opacity: 0.4; transform: scale(0.98) rotate(-1deg); }

.card[data-variant="positive"] { border-left: 3px solid var(--ok); }
.card[data-variant="technical"] { border-left: 3px solid var(--warn); }
.card[data-variant="expired"] { border-left: 3px solid var(--bad); }

.card-row {
  display: flex; align-items: baseline; gap: 8px;
}
.card-name {
  flex: 1; font-weight: 700; font-size: 14px;
  letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-time {
  font-size: 11px; color: var(--ink-4); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.card-phone {
  font-family: var(--font-mono); font-size: 12px;
  color: var(--ink-3); margin-top: 2px;
}
.card-tags {
  display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px;
}
.card-preview {
  margin-top: 6px; font-size: 11.5px; line-height: 1.4;
  color: var(--ink-3);
  display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============ Tags ============ */
.tag {
  display: inline-flex; align-items: center;
  font-size: 10.5px; padding: 2px 7px; border-radius: 5px; font-weight: 600;
  background: var(--paper-2); color: var(--ink-2);
  white-space: nowrap; letter-spacing: 0.01em;
}
.tag.variant-positive { background: #DCEFE5; color: var(--ok); }
.tag.variant-technical { background: #FDF3DE; color: var(--warn); }
.tag.variant-expired { background: #F2E1DD; color: var(--bad); }
.tag.status-novo { background: var(--primary-soft); color: var(--c-novo); }
.tag.status-contatado { background: #FDF3DE; color: var(--c-contatado); }
.tag.status-fechado { background: #DCEFE5; color: var(--c-fechado); }
.tag.status-descartado { background: var(--paper-3); color: var(--ink-3); }
.tag-utm { text-transform: lowercase; }

/* ============ Drawer ============ */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(15,20,16,0.45);
  z-index: 40; backdrop-filter: blur(2px);
  animation: fade 0.18s ease-out;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 440px; max-width: calc(100vw - 32px);
  background: white;
  z-index: 41;
  overflow-y: auto;
  box-shadow: var(--shadow-3);
  animation: slide-in 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
  display: flex; flex-direction: column; gap: 0;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-in { from { transform: translateX(100%); } to { transform: translateX(0); } }

.drawer-head {
  padding: 20px 22px 12px;
  display: flex; align-items: flex-start; gap: 12px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: white; z-index: 1;
}
.drawer-head > div:first-child { flex: 1; min-width: 0; }
.drawer-name {
  font-size: 19px; font-weight: 800; letter-spacing: -0.01em;
  word-break: break-word;
}
.drawer-phone {
  font-family: var(--font-mono); font-size: 13px;
  color: var(--ink-3); margin-top: 4px;
}
.drawer-close {
  background: var(--paper-2); border: 0; color: var(--ink-3);
  width: 32px; height: 32px; border-radius: 8px;
  font-size: 24px; cursor: pointer; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.drawer-close:hover { background: var(--paper-3); color: var(--ink); }

.drawer-tags {
  padding: 12px 22px;
  display: flex; gap: 6px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
}

.drawer-section {
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}
.drawer-section:last-child { border-bottom: 0; }
.section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-4); font-weight: 700; margin-bottom: 10px;
}

.btn {
  border: 1px solid var(--line-2); background: white;
  border-radius: 10px; padding: 9px 14px; font-size: 13px;
  cursor: pointer; color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; font-weight: 600;
}
.btn:hover { background: var(--paper-2); }
.btn.primary { background: #25D366; color: white; border-color: #25D366; }
.btn.primary:hover { background: #1DAB52; }
.btn.big {
  width: 100%; padding: 13px; font-size: 14.5px; border-radius: 12px;
  letter-spacing: -0.01em;
}

.status-picker {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px;
}
.pill {
  background: white; border: 1.5px solid var(--line-2);
  border-radius: 10px; padding: 9px 12px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--ink-2); transition: all 0.12s;
}
.pill:hover:not(:disabled) { background: var(--paper-2); }
.pill-active { background: var(--ink); color: white; border-color: var(--ink); cursor: default; }
.pill:disabled { opacity: 0.7; cursor: default; }
.pill.pill-novo:not(.pill-active):hover { border-color: var(--c-novo); color: var(--c-novo); }
.pill.pill-contatado:not(.pill-active):hover { border-color: var(--c-contatado); color: var(--c-contatado); }
.pill.pill-fechado:not(.pill-active):hover { border-color: var(--c-fechado); color: var(--c-fechado); }
.pill.pill-descartado:not(.pill-active):hover { border-color: var(--bad); color: var(--bad); }

.answers {
  background: var(--paper-2); border-radius: 10px; padding: 4px 12px;
}
.a-row {
  display: flex; justify-content: space-between; gap: 12px; padding: 8px 0;
}
.a-row + .a-row { border-top: 1px solid var(--line); }
.a-k { color: var(--ink-3); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.a-v { font-weight: 600; font-size: 13px; text-align: right; color: var(--ink); }

.meta-grid { display: flex; flex-direction: column; gap: 8px; }
.meta-grid > div { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.meta-k { color: var(--ink-4); font-size: 12px; }
.meta-v { font-weight: 600; }

/* ============ Misc ============ */
.empty {
  text-align: center; padding: 60px 20px; color: var(--ink-4);
}
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--line-2); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.6s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: white; padding: 10px 18px;
  border-radius: 12px; font-size: 13px; z-index: 60;
  font-weight: 600; box-shadow: var(--shadow-2);
  animation: toast-in 0.2s cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes toast-in {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* ============ Responsive ============ */
@media (max-width: 880px) {
  .topbar { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .brand { order: 1; }
  .topbar-actions { order: 2; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .stats { padding: 10px 12px 0; }
  .filters { padding: 8px 12px; gap: 10px; }
  .kanban, .tabs { padding-left: 12px; padding-right: 12px; }
  .drawer { width: 100%; max-width: 100%; }
}
