:root {
  --navy: #0b1f3a; --navy-2: #12294a; --navy-3: #1c3760;
  --teal: #0f9f90; --teal-2: #0c857a; --teal-soft: #e3f5f2;
  --bg: #f4f6f9; --surface: #ffffff; --line: #e2e7ee; --line-2: #cfd7e2;
  --text: #16233a; --muted: #5d6b80; --faint: #8a96a8;
  --red: #c2413b; --red-soft: #fbeceb; --amber: #b7791f; --amber-soft: #fdf3e1; --blue-soft: #e8f0fb;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 35, 58, .06), 0 2px 8px rgba(16, 35, 58, .05);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; --head: 'Plus Jakarta Sans', var(--font);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--teal-2); }
h1, h2, h3 { font-family: var(--head); margin: 0; letter-spacing: -.01em; }

/* Layout */
.shell { display: grid; grid-template-columns: 232px 1fr; height: 100vh; }
.side { background: var(--navy); color: #c9d4e3; display: flex; flex-direction: column; padding: 18px 12px; gap: 2px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; font-family: var(--head); font-weight: 700; font-size: 16px; }
.brand small { display: block; font: 500 11px var(--font); color: #8fa3bf; letter-spacing: .02em; }
.side .sec { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7e92ae; padding: 14px 10px 6px; }
.side a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: #c9d4e3; text-decoration: none; font-weight: 500; }
.side a:hover { background: var(--navy-2); color: #fff; }
.side a.on { background: var(--navy-3); color: #fff; box-shadow: inset 3px 0 0 var(--teal); }
.side a .count { margin-left: auto; background: var(--teal); color: #fff; font-size: 11px; border-radius: 99px; padding: 0 7px; }
.side .me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--navy-3); font-size: 13px; }
.side .me button { background: none; border: 0; color: #8fa3bf; padding: 0; cursor: pointer; text-decoration: underline; }
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.top { display: flex; align-items: center; gap: 12px; padding: 16px 24px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.top h1 { font-size: 20px; margin-right: auto; }
.content { flex: 1; overflow: auto; padding: 20px 24px; }

/* Controls */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: var(--surface); padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--teal); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-2); }
.btn.danger { color: var(--red); border-color: #efc9c6; }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=tel], select, textarea {
  width: 100%; border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; background: #fff; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.top input[type=search] { width: 240px; }
.top select { width: auto; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--blue-soft); color: #264a7a; white-space: nowrap; }
.tag.teal { background: var(--teal-soft); color: var(--teal-2); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.gray { background: #eef1f5; color: var(--muted); }
.muted { color: var(--muted); }
.empty { color: var(--faint); text-align: center; padding: 28px 12px; font-size: 13px; }

/* Pipeline tabs */
.ptabs { display: flex; gap: 4px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; }
.ptabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.ptabs a.on { color: var(--text); border-color: var(--teal); }

/* Kanban */
.board { display: flex; gap: 14px; align-items: flex-start; min-height: 100%; }
.col { flex: 0 0 272px; background: #eaeef3; border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 190px); }
.col.won .col-h { box-shadow: inset 0 3px 0 var(--teal); }
.col.lost .col-h { box-shadow: inset 0 3px 0 var(--red); }
.col-h { display: flex; align-items: center; gap: 8px; padding: 11px 12px 9px; font-weight: 600; border-radius: var(--radius) var(--radius) 0 0; }
.col-h .n { margin-left: auto; font-size: 12px; color: var(--muted); background: #fff; border-radius: 99px; padding: 0 8px; }
.col-body { padding: 4px 8px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.col.drop { outline: 2px dashed var(--teal); outline-offset: -2px; }
.card { background: var(--surface); border-radius: 8px; padding: 10px 11px; box-shadow: var(--shadow); cursor: pointer; border: 1px solid transparent; }
.card:hover { border-color: var(--teal); }
.card.dragging { opacity: .45; }
.card .t { font-weight: 600; margin-bottom: 2px; overflow-wrap: anywhere; }
.card .s { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.card .meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.card .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 12px; color: var(--faint); }

/* Drawer */
.drawer-bg { position: fixed; inset: 0; background: rgba(11, 31, 58, .32); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); background: var(--bg); z-index: 21; display: flex; flex-direction: column; box-shadow: -8px 0 30px rgba(11, 31, 58, .18); }
.drawer-h { background: var(--surface); padding: 16px 20px 0; border-bottom: 1px solid var(--line); }
.drawer-h .row1 { display: flex; align-items: flex-start; gap: 10px; }
.drawer-h h2 { font-size: 19px; flex: 1; overflow-wrap: anywhere; }
.drawer-h .row2 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0 12px; }
.drawer-h .row2 select { width: auto; }
.x { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); padding: 2px 6px; }
.tabs { display: flex; gap: 2px; }
.tabs button { border: 0; background: none; padding: 9px 12px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; }
.tabs button.on { color: var(--text); border-color: var(--teal); }
.drawer-b { flex: 1; overflow-y: auto; padding: 18px 20px 30px; display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.panel h3 { font-size: 14px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.callout { border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.callout.warn { background: var(--amber-soft); color: #7a4f10; }
.callout.bad { background: var(--red-soft); color: #8a2b26; }
.callout.info { background: var(--teal-soft); color: #0b5e56; }
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.li:first-child { border-top: 0; }
.li .grow { flex: 1; min-width: 0; }
.li .when { font-size: 12px; color: var(--faint); white-space: nowrap; }
.li.done .grow { text-decoration: line-through; color: var(--faint); }
.timeline .li .grow { font-size: 13px; }
.timeline .ic { width: 22px; text-align: center; }
.note-form { display: flex; gap: 8px; }
.pre { white-space: pre-wrap; font-size: 13px; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.wa { background: #e7f7ef; border-color: #cdebdc; }

/* Tables */
table.t { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; background: #f8fafc; padding: 9px 12px; border-bottom: 1px solid var(--line); }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #f8fafc; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(11, 31, 58, .4); z-index: 40; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 12px; width: min(560px, 100%); max-height: 90vh; overflow-y: auto; padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal h2 { font-size: 18px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--navy); padding: 16px; }
.login form { background: #fff; padding: 30px 28px; border-radius: 14px; width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login h1 { font-size: 22px; }
.err { color: var(--red); font-size: 13px; min-height: 18px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; max-width: 90vw; }
#toast.show { opacity: 1; }
#toast.bad { background: var(--red); }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { flex-direction: row; overflow-x: auto; padding: 8px; align-items: center; }
  .side .sec, .side .me, .brand small { display: none; }
  .brand { padding: 0 8px; }
  .top { padding: 12px 16px; }
  .top input[type=search] { width: 100%; }
  .content { padding: 14px 16px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .col { flex-basis: 250px; }
}

/* Conversas */
.chips { display: flex; gap: 6px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; }
.chips button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: #fff; border-radius: 99px; padding: 4px 11px; cursor: pointer; font-weight: 500; white-space: nowrap; font-size: 13px; }
.chips button.on { border-color: var(--teal); background: var(--teal-soft); color: var(--teal-2); }
.chips button i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.chips button b { background: var(--teal); color: #fff; border-radius: 99px; padding: 0 6px; font-size: 11px; }
.chips .off { color: var(--faint); font-size: 10px; }
.ch { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; color: var(--c); background: color-mix(in srgb, var(--c) 12%, white); white-space: nowrap; }
.inbox { flex: 1; display: grid; grid-template-columns: 330px 1fr; min-height: 0; }
.ilist { border-right: 1px solid var(--line); overflow-y: auto; background: var(--surface); }
.iitem { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 11px 14px; cursor: pointer; }
.iitem:hover { background: #f8fafc; }
.iitem.on { background: var(--teal-soft); box-shadow: inset 3px 0 0 var(--teal); }
.iitem .r1 { display: flex; justify-content: space-between; gap: 8px; }
.iitem .r1 b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.iitem.unread .r1 b { font-weight: 700; }
.iitem .when { font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.iitem .r2 { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 12.5px; color: var(--muted); }
.iitem .snip { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iitem .count { background: var(--teal); color: #fff; font-size: 11px; border-radius: 99px; padding: 0 7px; }
.iitem .r3 { font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.ithread { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.thead { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.thead select { width: auto; }
.tbody { flex: 1; display: grid; grid-template-columns: 1fr 250px; min-height: 0; }
.msgs { overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 72%; padding: 8px 12px; border-radius: 12px; overflow-wrap: anywhere; font-size: 13.5px; }
.msg.in { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; background: #d9f2ee; border-bottom-right-radius: 4px; }
.msg.auto { align-self: flex-end; background: #eef1f5; color: var(--muted); border: 1px dashed var(--line-2); font-size: 12.5px; }
.msg small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.msg .subj { font-weight: 600; margin-bottom: 4px; }
.msg .meta { font-size: 10.5px; color: var(--faint); text-align: right; margin-top: 3px; }
.msg .meta .bad { color: var(--red); font-weight: 600; }
.tside { border-left: 1px solid var(--line); padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.tside .panel { padding: 12px; }
.reply { display: flex; gap: 8px; padding: 12px 16px; background: var(--surface); border-top: 1px solid var(--line); align-items: flex-end; flex-wrap: wrap; }
.reply textarea { flex: 1; resize: vertical; min-width: 200px; }
.reply input { flex-basis: 100%; }
@media (max-width: 1100px) { .tbody { grid-template-columns: 1fr; } .tside { display: none; } }
@media (max-width: 860px) { .inbox { grid-template-columns: 1fr; } .ithread { display: none; } .inbox.has-open .ilist { display: none; } .inbox.has-open .ithread { display: flex; } }
.thead .back { display: none; }
@media (max-width: 860px) { .thead .back { display: inline-flex; } }

.msg .txt { white-space: pre-wrap; }

/* Plataformas no menu */
.side a.soon { opacity: .55; cursor: default; }
.side a.soon:hover { background: none; color: #c9d4e3; }
.side .soon-tag { margin-left: auto; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; border: 1px solid #3a5378; border-radius: 99px; padding: 0 6px; }
/* Abas de funis no CRM */
.chips.funnels a { display: inline-flex; align-items: center; border: 1px solid var(--line-2); background: #fff; border-radius: 99px; padding: 4px 13px; font-weight: 600; font-size: 13px; color: var(--text); text-decoration: none; white-space: nowrap; }
.chips.funnels a.on { border-color: var(--teal); background: var(--teal-soft); color: var(--teal-2); }
/* Barra funil + etapas */
.stagebar { background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 16px 10px; display: flex; flex-direction: column; gap: 8px; }
.drawer-h .stagebar { padding: 10px 0 4px; border-bottom: 0; }
.sb-pipes { display: flex; gap: 4px; flex-wrap: wrap; }
.sb-pipes button { border: 0; background: none; padding: 3px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--faint); cursor: pointer; }
.sb-pipes button:hover { color: var(--text); background: var(--bg); }
.sb-pipes button.on { color: var(--text); background: var(--bg); }
.sb-pipes button.cur { color: var(--teal-2); }
.sb-pipes button.cur::before { content: "● "; font-size: 9px; vertical-align: 1px; }
.sb-steps { display: flex; overflow-x: auto; scrollbar-width: thin; }
.sb-steps button { flex: 1 0 auto; position: relative; border: 0; background: #e9edf2; color: var(--muted); font-size: 12px; font-weight: 600; padding: 7px 14px 7px 20px; cursor: pointer; white-space: nowrap;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%); margin-right: -6px; }
.sb-steps button:first-child { clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%); border-radius: 6px 0 0 6px; padding-left: 14px; }
.sb-steps button:hover { background: #dce3eb; color: var(--text); }
.sb-steps button.done { background: #cdeae6; color: var(--teal-2); }
.sb-steps button.on { background: var(--teal); color: #fff; }
.sb-steps button.won.on { background: #2f9e5a; }
.sb-steps button.lost.on { background: var(--red); }

/* Arquivos do card */
.files { display: flex; flex-direction: column; gap: 6px; }
.files .file { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); text-decoration: none; color: var(--text); font-weight: 600; font-size: 13px; }
.files .file:hover { border-color: var(--teal); color: var(--teal-2); }
.files .file small { color: var(--faint); font-weight: 400; white-space: nowrap; }
.tside .files .file { flex-direction: column; align-items: flex-start; gap: 2px; }
