/* ===== Identidade JSG ===== */
@font-face { font-family: 'Neue Haas'; src: url('assets/fonts/NeueHaasDisplayRoman.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Neue Haas'; src: url('assets/fonts/NeueHaasDisplayMediu.ttf') format('truetype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Neue Haas'; src: url('assets/fonts/NeueHaasDisplayBold.ttf') format('truetype'); font-weight: 700; font-display: swap; }

:root {
  --red: #E53346;
  --red-deep: #C9283A;
  --red-soft: #FDEDEF;
  --ink: #1E1E1E;
  --ink-2: #4A4A4A;
  --muted: #8A8A8A;
  --line: #EDEDED;
  --line-2: #E2E2E2;
  --surface: #FFFFFF;
  --canvas: #F7F7F7;
  --gray: #C8C8C8;
  --green: #22A06B;
  --radius: 20px;
  --pill: 999px;
  --shadow: 0 1px 2px rgba(30, 30, 30, .04), 0 8px 24px rgba(30, 30, 30, .06);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --track: 0.02em;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Neue Haas', 'Helvetica Neue', Arial, sans-serif;
  color: var(--ink);
  background: var(--surface);
  letter-spacing: var(--track);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
::selection { background: var(--red-soft); color: var(--red-deep); }
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: #E4E4E4; border-radius: 10px; border: 3px solid var(--surface); }

.boot { position: fixed; inset: 0; display: grid; place-items: center; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--red);
  animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Componentes ===== */
.icons { display: flex; justify-content: center; margin-bottom: 28px; }
.icons--left { justify-content: flex-start; }
.icons span {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  background: var(--red); margin-left: -8px;
}
.icons span:first-child { margin-left: 0; }
.icons span:nth-child(2) { background: var(--gray); }
.icons svg { width: 26px; height: 26px; stroke-width: 2.2; }

.cta {
  display: inline-flex; align-items: center; justify-content: center; gap: 14px;
  height: 52px; padding: 0 26px; border-radius: var(--pill);
  background: var(--red); color: #fff; font-weight: 700; font-size: 16px;
  transition: background .2s var(--ease), transform .15s var(--ease);
}
.cta:hover { background: var(--red-deep); }
.cta:active { transform: scale(.98); }
.cta .arrow { color: var(--ink); stroke-width: 3; }
.cta[disabled] { opacity: .45; pointer-events: none; }
.cta--block { width: 100%; }
.ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 52px; padding: 0 24px; border-radius: var(--pill);
  border: 1.5px solid var(--line-2); font-weight: 500;
  transition: border-color .2s, color .2s;
}
.ghost:hover { border-color: var(--ink); }
.ghost.is-done { border-color: var(--green); color: var(--green); }
.ghost--sm { height: 40px; padding: 0 18px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); transition: background .2s; }
.icon-btn:hover { background: var(--canvas); color: var(--ink); }
#pushBtn { color: var(--red); background: var(--red-soft); }
.link { color: var(--muted); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }

.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field span { font-size: 13px; color: var(--muted); }
.field input, .field textarea {
  border: 1.5px solid transparent; outline: 0; background: var(--canvas); border-radius: 14px; padding: 13px 16px; width: 100%;
  transition: border-color .2s;
}
.field input:focus, .field textarea:focus { border-color: var(--ink); background: var(--surface); }
.field textarea { min-height: 150px; resize: vertical; line-height: 1.5; font-size: 16px; }

/* ===== Login ===== */
.login { min-height: 100%; display: grid; place-items: center; padding: 32px 20px; }
.login__card { width: 100%; max-width: 400px; text-align: center; }
.login__logo { height: 44px; margin-bottom: 48px; }
.login .icons span { width: 56px; height: 56px; }
.login__title { font-size: 40px; line-height: 1.05; font-weight: 400; margin: 0 0 32px; }
.login__title strong { color: var(--red); font-weight: 700; }
.login__form { text-align: left; }
.login__form .cta { margin-top: 10px; }
.login__error { color: var(--red-deep); background: var(--red-soft); padding: 10px 14px; border-radius: 12px; font-size: 14px; margin: 4px 0 0; }
.login .link { margin-top: 20px; }

/* ===== Topo ===== */
.shell { height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: relative; height: 72px; flex: none; display: flex; align-items: center; gap: 40px;
  padding: 0 28px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.topbar__logo { height: 40px; }
.nav { display: flex; gap: 4px; background: var(--canvas); padding: 4px; border-radius: var(--pill); }
.nav__item {
  padding: 9px 20px; border-radius: var(--pill); font-weight: 500; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 8px; transition: background .2s var(--ease), color .2s var(--ease);
}
.nav__item:hover { color: var(--ink); }
.nav__item.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.nav__badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--pill); background: var(--red); color: #fff;
  font-size: 12px; font-weight: 700; display: inline-grid; place-items: center;
}
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.sync {
  display: inline-flex; align-items: center; gap: 10px; padding: 9px 16px; border-radius: var(--pill);
  border: 1px solid var(--line-2); font-size: 14px; color: var(--ink-2); white-space: nowrap;
}
.sync__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gray); position: relative; }
.sync.is-ok .sync__dot { background: var(--green); }
.sync.is-ok .sync__dot::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--green);
  opacity: 0; animation: ping 2.4s var(--ease) infinite;
}
.sync.is-error .sync__dot { background: var(--red); }
.sync.is-error { color: var(--red-deep); border-color: #F5C2C8; }
@keyframes ping { 0% { transform: scale(.6); opacity: .7; } 100% { transform: scale(1.6); opacity: 0; } }
.menu {
  position: absolute; right: 20px; top: 66px; z-index: 30; width: 300px;
  background: var(--surface); border-radius: 20px; padding: 20px; box-shadow: 0 18px 50px rgba(30, 30, 30, .16);
  animation: fade .2s var(--ease);
}
.menu__email { font-size: 13px; color: var(--muted); margin: 0 0 14px; word-break: break-all; }

/* ===== Estrutura ===== */
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 360px 1fr; }

/* ===== Lista ===== */
.sidebar { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.sidebar__head { padding: 24px 20px 12px; display: grid; gap: 14px; }
.sidebar__title { margin: 0; font-size: 26px; font-weight: 700; display: flex; align-items: baseline; gap: 8px; }
.sidebar__title span { font-size: 15px; font-weight: 400; color: var(--muted); }
.segment { display: flex; flex-wrap: wrap; gap: 6px; }
.segment button {
  padding: 7px 14px; border-radius: var(--pill); font-size: 13px; font-weight: 500;
  border: 1px solid var(--line-2); color: var(--ink-2); transition: all .2s var(--ease);
}
.segment button:hover { border-color: var(--gray); color: var(--ink); }
.segment button.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.segment button .n { opacity: .55; margin-left: 4px; }
.search { display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 44px; border-radius: 14px; background: var(--canvas); color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 16px; }
.search input::placeholder { color: var(--muted); }

.lead-list { list-style: none; margin: 0; padding: 4px 12px 24px; overflow-y: auto; flex: 1; }
.lead {
  position: relative; display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center;
  padding: 14px 12px; border-radius: 16px; cursor: pointer; transition: background .2s var(--ease);
}
.lead:hover { background: var(--canvas); }
.lead.is-selected { background: var(--red-soft); }
.lead.is-selected::before { content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 3px; background: var(--red); }
.lead.is-fresh { animation: arrive .9s var(--ease); }
@keyframes arrive {
  0% { transform: translateY(-12px); opacity: 0; box-shadow: 0 0 0 0 rgba(229, 51, 70, .4); }
  60% { transform: none; opacity: 1; box-shadow: 0 0 0 8px rgba(229, 51, 70, 0); }
}
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 15px; background: var(--canvas); color: var(--ink-2); }
.lead.is-novo .avatar { background: var(--red); color: #fff; }
.lead__text { min-width: 0; }
.lead__name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead__meta { font-size: 13px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead__side { display: grid; justify-items: end; gap: 6px; }
.lead__time { font-size: 12px; color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 4px 10px; border-radius: var(--pill); white-space: nowrap; }
.status--novo { background: var(--red); color: #fff; }
.status--atendimento { border: 1px solid var(--red); color: var(--red); padding: 3px 9px; }
.status--contatado { background: var(--canvas); color: var(--ink-2); }
.status--contatado svg { width: 12px; height: 12px; stroke-width: 3; }
.list-empty { padding: 40px 16px; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.5; }

/* ===== Centro ===== */
.center { overflow-y: auto; min-height: 0; position: relative; }
.center__inner { max-width: 760px; margin: 0 auto; padding: 44px 48px 64px; animation: fade .35s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.back { display: none; align-items: center; gap: 4px; font-weight: 500; color: var(--ink-2); margin: -8px 0 18px -6px; padding: 6px; }

.empty { min-height: 100%; display: grid; place-items: center; text-align: center; padding: 48px 24px; }
.empty h1 { font-size: 44px; line-height: 1.04; margin: 0; font-weight: 700; color: var(--red); }
.empty p { font-size: 20px; margin: 18px 0 0; }

.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--red); background: var(--red-soft); padding: 7px 14px; border-radius: var(--pill); }
.headline { font-size: 52px; line-height: 1.02; margin: 18px 0 0; font-weight: 400; overflow-wrap: anywhere; }
.headline strong { font-weight: 700; color: var(--red); }
.subline { font-size: 18px; color: var(--ink-2); margin: 14px 0 0; line-height: 1.4; }

.contact { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.chip {
  display: inline-flex; align-items: center; gap: 10px; height: 48px; padding: 0 18px; border-radius: var(--pill);
  border: 1.5px solid var(--line-2); font-size: 16px; font-weight: 500; max-width: 100%; transition: border-color .2s;
}
.chip:hover { border-color: var(--ink); }
.chip--icon { width: 48px; padding: 0; justify-content: center; }
.chip__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .copy-ico { color: var(--muted); width: 16px; height: 16px; }
.chip.is-done { border-color: var(--green); }
.chip.is-done .copy-ico { color: var(--green); }

.status-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 18px; }
.status-row .label { font-size: 14px; color: var(--muted); margin-right: 4px; }
.status-opt { padding: 8px 16px; border-radius: var(--pill); border: 1.5px solid var(--line-2); font-size: 14px; font-weight: 500; color: var(--ink-2); transition: all .2s var(--ease); }
.status-opt:hover { border-color: var(--gray); }
.status-opt.is-active { border-color: var(--red); background: var(--red); color: #fff; }

.section { margin-top: 44px; }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section__title { font-size: 24px; margin: 0; font-weight: 700; }
.section__hint { font-size: 14px; color: var(--muted); }

.tpl-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tpl-tab { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: var(--pill); border: 1.5px solid var(--line-2); font-weight: 500; color: var(--ink-2); transition: all .2s var(--ease); }
.tpl-tab:hover { border-color: var(--gray); color: var(--ink); }
.tpl-tab.is-active { border-color: var(--ink); background: var(--ink); color: #fff; }
.tpl-tab .tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: var(--pill); background: var(--red); color: #fff; }
.message { border-radius: var(--radius); background: var(--canvas); padding: 4px; transition: box-shadow .2s; }
.message:focus-within { box-shadow: 0 0 0 2px var(--ink) inset; }
.message textarea { display: block; width: 100%; min-height: 190px; resize: none; overflow: hidden; border: 0; outline: 0; background: transparent; padding: 20px 22px; font-size: 17px; line-height: 1.5; }
.message__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

.answers { display: grid; gap: 10px; }
.answer { display: grid; grid-template-columns: 22px 1fr; gap: 6px 10px; align-items: start; padding: 16px 20px; border: 1.5px solid var(--line); border-radius: 18px; }
.answer .chev { color: var(--red); stroke-width: 3; width: 16px; height: 16px; margin-top: 2px; }
.answer__q { font-size: 13px; color: var(--muted); }
.answer__a { grid-column: 2; font-size: 18px; font-weight: 500; overflow-wrap: anywhere; }
.answers--empty { color: var(--muted); font-size: 15px; }
.meta-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; margin: 0; }
.meta-grid div { background: var(--surface); padding: 14px 18px; }
.meta-grid dt { font-size: 12px; color: var(--muted); }
.meta-grid dd { margin: 4px 0 0; font-size: 14px; word-break: break-word; }

.dock { display: none; }

/* Editor */
.editor-intro { margin-bottom: 36px; }
.editor-intro .headline { font-size: 46px; }
.tpl-card { border: 1.5px solid var(--line); border-radius: 24px; padding: 24px; margin-bottom: 18px; transition: border-color .2s; }
.tpl-card:focus-within { border-color: var(--ink); }
.tpl-card__head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.tpl-num { width: 36px; height: 36px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.tpl-card:nth-of-type(3) .tpl-num { background: var(--gray); }
.tpl-name { flex: 1; min-width: 0; font-size: 22px; font-weight: 700; border: 0; outline: 0; padding: 4px 0; background: transparent; }
.vars { display: flex; flex-wrap: wrap; gap: 6px; }
.var { font-size: 12px; padding: 5px 10px; border-radius: var(--pill); border: 1px dashed var(--gray); color: var(--ink-2); }
.var:hover { border-color: var(--red); color: var(--red); }
.editor-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.is-readonly .field input, .is-readonly .field textarea, .is-readonly .tpl-name { cursor: default; }
.is-readonly .field input:focus, .is-readonly .field textarea:focus { border-color: transparent; background: var(--canvas); }

/* Avisos */
.toasts { position: fixed; left: 24px; bottom: 24px; display: grid; gap: 10px; z-index: 50; }
.toast {
  display: flex; align-items: center; gap: 14px; width: 320px; padding: 14px 16px 14px 14px; border-radius: 18px;
  background: var(--ink); color: #fff; box-shadow: 0 18px 40px rgba(30, 30, 30, .25); cursor: pointer; animation: toastIn .45s var(--ease);
}
.toast > div { min-width: 0; }
.toast.is-out { animation: toastOut .3s var(--ease) forwards; }
.toast__ico { width: 40px; height: 40px; border-radius: 50%; background: var(--red); display: grid; place-items: center; flex: none; }
.toast__title { font-weight: 700; }
.toast__body { font-size: 13px; opacity: .7; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast--plain { width: auto; max-width: 420px; padding: 12px 18px; line-height: 1.4; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px); } }

/* ===== Computador: detalhe e editor na horizontal ===== */
@media (min-width: 1280px) {
  .center__inner.detail, .center__inner.editor { max-width: 1320px; padding: 40px 56px 64px; }
  .detail {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 0 56px; align-items: start;
  }
  .detail__head {
    grid-column: 1 / -1; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px 48px;
    flex-wrap: wrap; padding-bottom: 32px; border-bottom: 1px solid var(--line);
  }
  .detail__title { min-width: 0; }
  .detail__actions { display: grid; justify-items: end; gap: 14px; }
  .detail__actions .contact { margin-top: 0; justify-content: flex-end; }
  .detail__actions .status-row { margin-top: 0; }
  .detail__main { grid-column: 2; grid-row: 2; position: sticky; top: 0; margin-top: 0; padding-top: 36px; }
  .detail__side { grid-column: 1; grid-row: 2; }
  .detail__side > .section:first-child { margin-top: 36px; }
  .detail__side .answers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail__side .answer__a { font-size: 17px; }

  .editor-intro { display: grid; grid-template-columns: auto 1fr; align-items: end; gap: 8px 48px; }
  .editor-intro .icons { grid-row: span 2; margin: 0; }
  .editor-intro .headline { margin: 0; }
  .editor-intro .subline { grid-column: 2; max-width: 720px; margin-top: 4px; }
  .tpl-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: start; }
  .tpl-grid .tpl-card { margin-bottom: 0; display: flex; flex-direction: column; }
  .tpl-grid .field textarea { min-height: 260px; }
  .editor-actions { margin-top: 24px; }
}

/* ===== Tablet ===== */
@media (max-width: 1180px) {
  .topbar { gap: 20px; }
  .layout { grid-template-columns: 320px 1fr; }
  .center__inner { padding: 36px 32px 56px; }
  .headline { font-size: 42px; }
}

/* ===== Celular ===== */
@media (max-width: 860px) {
  .topbar { height: 60px; padding: 0 12px 0 16px; gap: 12px; }
  .topbar__logo { height: 32px; }
  .nav { order: 3; position: fixed; left: 16px; right: 16px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 20; justify-content: center; box-shadow: 0 10px 30px rgba(30, 30, 30, .14); background: var(--surface); }
  .nav__item { flex: 1; justify-content: center; }
  .sync { padding: 7px 12px; font-size: 13px; }
  .menu { right: 12px; top: 56px; width: calc(100vw - 24px); }

  .layout { display: block; position: relative; overflow: hidden; }
  .sidebar { position: absolute; inset: 0; border: 0; }
  .sidebar__head { padding: 20px 16px 10px; }
  .lead-list { padding: 4px 8px 110px; }
  .center {
    position: absolute; inset: 0; background: var(--surface); z-index: 10;
    transform: translateX(100%); transition: transform .3s var(--ease); visibility: hidden;
  }
  body.show-detail .center { transform: none; visibility: visible; }
  body.show-detail .nav { display: none; }
  body.view-editor .nav { display: flex; }

  .center__inner { padding: 22px 20px 120px; }
  .back { display: inline-flex; }
  body.view-editor .back { display: none; }
  .headline { font-size: 36px; }
  .editor-intro .headline { font-size: 34px; }
  .subline { font-size: 16px; }
  .empty h1 { font-size: 34px; }
  .icons span { width: 52px; height: 52px; }
  .icons svg { width: 22px; height: 22px; }
  .contact { margin-top: 22px; }
  .section { margin-top: 36px; }
  .section__hint { display: none; }
  .message textarea { font-size: 16px; padding: 16px 18px; }
  .message__actions .cta { display: none; }
  .message__actions .ghost { width: 100%; }
  .meta-grid { grid-template-columns: 1fr; }
  .dock {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--surface) 70%, rgba(255, 255, 255, 0));
  }
  .dock .cta { height: 56px; font-size: 17px; }
  .toasts { left: 12px; right: 12px; bottom: calc(86px + env(safe-area-inset-bottom)); }
  .toast { width: 100%; }
}
@media (max-width: 520px) {
  .sync span:last-child { display: none; }
  .sync { padding: 10px; }
}
