:root {
  --bg: #0b0f14;
  --bg-soft: #0f151c;
  --panel: #121a23;
  --panel-2: #16202b;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #e8edf4;
  --muted: #93a1b5;
  --muted-2: #8494a9;
  --accent: #4cc2ff;
  --green: #1f9d61;
  --green-strong: #178a54;
  --amber: #d99a2b;
  --red: #e05a5a;
  --radius: 16px;
  --shadow: 0 18px 40px -28px rgba(0, 0, 0, 0.9);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

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

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

a {
  color: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.brand {
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 17px;
  white-space: nowrap;
}

.brand-tag {
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  vertical-align: 2px;
}

/* ------------------------------- Login ------------------------------- */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(900px 480px at 50% -10%, rgba(76, 194, 255, 0.1), transparent 65%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin-top: 18px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-copy {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.login-card label {
  display: block;
  margin-top: 20px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.login-card input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: #0a1017;
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.login-card .btn.block {
  margin-top: 14px;
}

.login-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(76, 194, 255, 0.18);
}

.login-hint {
  margin-top: 12px;
  font-size: 11px;
  color: var(--muted-2);
  text-align: center;
}

.form-error {
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid rgba(224, 90, 90, 0.35);
  background: rgba(224, 90, 90, 0.1);
  color: #ffb4b4;
  font-size: 12px;
  line-height: 1.45;
}

/* ------------------------------- Topbar ------------------------------ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 15, 20, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.sync-label {
  display: none;
  font-size: 11px;
  color: var(--muted-2);
  white-space: nowrap;
}

.wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 16px 56px;
}

/* ------------------------------- Buttons ----------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 13px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--panel-2);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn:hover {
  background: #1b2632;
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn.block {
  width: 100%;
  height: 44px;
  font-size: 13.5px;
}

.btn.primary {
  background: var(--green);
  border-color: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.btn.primary:hover {
  background: var(--green-strong);
}

.btn.ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--muted);
}

.btn.ghost:hover {
  background: var(--panel-2);
  color: var(--text);
}

.btn.soft {
  background: rgba(76, 194, 255, 0.1);
  border-color: rgba(76, 194, 255, 0.25);
  color: #9bdcff;
}

.btn.soft:hover {
  background: rgba(76, 194, 255, 0.16);
}

.btn.followup {
  background: rgba(217, 154, 43, 0.14);
  border-color: rgba(217, 154, 43, 0.38);
  color: #f0c377;
}

.btn.followup:hover {
  background: rgba(217, 154, 43, 0.22);
}

.btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

/* ------------------------------- Summary ----------------------------- */
.summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.summary-card {
  min-width: 0;
  padding: 12px 13px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.summary-card .label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.summary-card .value {
  margin-top: 4px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.summary-card .sub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}

.summary-card.alert {
  border-color: rgba(224, 90, 90, 0.45);
  background: rgba(224, 90, 90, 0.08);
}

.summary-card.alert .value {
  color: #ff8f8f;
}

.summary-card.good .value {
  color: #6fe0a6;
}

/* ------------------------------- Toolbar ----------------------------- */
.toolbar {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.tab .count {
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
  color: var(--muted-2);
}

.tab:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.tab[aria-selected="true"] {
  background: rgba(76, 194, 255, 0.12);
  border-color: rgba(76, 194, 255, 0.42);
  color: #eaf6ff;
}

.tab[aria-selected="true"] .count {
  color: var(--accent);
}

.search-box input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.search-box input:focus {
  border-color: var(--line-strong);
}

.state-line {
  margin-top: 22px;
  color: var(--muted-2);
  font-size: 13px;
  text-align: center;
}

/* ------------------------------- Leads ------------------------------- */
.leads {
  margin-top: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 15px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card-head h3 {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.card-head .place {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.score {
  flex: 0 0 auto;
  min-width: 38px;
  padding: 4px 8px;
  border-radius: 9px;
  background: rgba(76, 194, 255, 0.1);
  border: 1px solid rgba(76, 194, 255, 0.22);
  color: #9bdcff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.score-max {
  font-size: 9px;
  font-weight: 600;
  color: rgba(155, 220, 255, 0.65);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.chip {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.chip.rating {
  color: #f0c377;
  border-color: rgba(217, 154, 43, 0.3);
}

.chip.status-novo {
  color: #9bdcff;
  border-color: rgba(76, 194, 255, 0.3);
}

.chip.status-enviado {
  color: #f0c377;
  border-color: rgba(217, 154, 43, 0.3);
}

.chip.status-respondeu {
  color: #c7b3ff;
  border-color: rgba(160, 130, 255, 0.35);
}

.chip.status-pago_49,
.chip.status-ativo_133 {
  color: #6fe0a6;
  border-color: rgba(31, 157, 97, 0.45);
}

.chip.status-descartado {
  color: var(--muted-2);
}

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 11.5px;
  color: var(--muted);
}

.metrics strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.reasons {
  font-size: 11.5px;
  color: var(--muted-2);
  overflow-wrap: anywhere;
}

.preview-line {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-width: 0;
  font-size: 11.5px;
  color: var(--muted-2);
}

.preview-line a {
  color: #9bdcff;
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

.preview-line a:hover {
  color: #c7ecff;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.actions .btn {
  flex: 1 1 160px;
}

.quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.quick .btn {
  height: 32px;
  padding: 0 10px;
  font-size: 11.5px;
  flex: 0 1 auto;
  white-space: normal;
  line-height: 1.2;
  text-align: center;
}

input::placeholder {
  color: #7d8ca1;
  opacity: 1;
}

.status-select {
  height: 32px;
  padding: 0 8px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 11.5px;
  font-weight: 600;
}

.email-preview {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
  padding: 8px 10px;
}

.email-preview summary {
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

.email-preview pre {
  margin: 8px 0 0;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: "Geist", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.55;
  color: #cdd7e4;
}

/* ------------------------------- Toast ------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 60;
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: #1b2632;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: 0 16px 40px -18px rgba(0, 0, 0, 0.9);
  text-align: center;
  pointer-events: none;
}

.toast.error {
  border-color: rgba(224, 90, 90, 0.5);
  background: #3a1c1f;
  color: #ffb4b4;
}

/* ------------------------------ Responsive --------------------------- */
@media (min-width: 560px) {
  .summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sync-label {
    display: inline;
  }

  .toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .tabs {
    flex: 1 1 auto;
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .search-box {
    flex: 0 0 260px;
  }

  .search-box input {
    font-size: 14px;
  }
}

@media (min-width: 820px) {
  .summary {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .leads {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1180px) {
  .leads {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
