:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --ink: #1f1d1a;
  --muted: #6f6a62;
  --line: #e4e0d8;
  --accent: #8a6d3b;
  --accent-soft: #f1e9da;
  --mine: #efe6d4;
  --theirs: #ffffff;
  --danger: #a33a2c;
  --ok: #2f7d4f;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

/* Topo */
.top {
  height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.brand span { color: var(--accent); }
.top .spacer { flex: 1; }
.top select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--panel); }
.top .who { color: var(--muted); font-size: 14px; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 12px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.link { border: none; background: none; color: var(--accent); padding: 7px 4px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--danger); }
.status-dot.open { background: var(--ok); }

/* Layout principal */
.main { display: grid; grid-template-columns: 360px 1fr; height: calc(100% - 56px); }
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; gap: 4px; padding: 10px 12px 0; }
.tab { flex: 1; border: none; background: none; padding: 8px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.search { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; border-bottom: 1px solid var(--line); }
.search input[type=search] { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--bg); }
.search input[type=checkbox] { margin: 0; accent-color: var(--accent); }
.search label { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.list { overflow-y: auto; flex: 1; }
.item { display: block; width: 100%; text-align: left; border: none; background: none; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.item:hover { background: var(--bg); }
.item.active { background: var(--accent-soft); }
.item .row { display: flex; justify-content: space-between; gap: 8px; }
.item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .time { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.item .preview { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.badge { background: var(--accent); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; }
.empty { padding: 24px; color: var(--muted); text-align: center; }

/* Conversa */
.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-head { background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 16px; display: flex; align-items: center; gap: 10px; min-height: 56px; }
.chat-head .title { font-weight: 700; }
.chat-head .sub { font-size: 13px; color: var(--muted); }
.back { display: none; }
.messages { flex: 1; overflow-y: auto; padding: 16px 6%; display: flex; flex-direction: column; gap: 6px; }
.day { align-self: center; font-size: 12px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 2px 10px; margin: 8px 0; }
.bubble { max-width: 70%; padding: 7px 10px 5px; border-radius: var(--radius); background: var(--theirs); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; }
.composer[hidden] { display: none; }
.composer { display: flex; gap: 10px; align-items: flex-end; padding: 10px 16px; background: var(--panel); border-top: 1px solid var(--line); }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg); max-height: 160px; line-height: 1.35; }
.composer-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.composer-side label { font-size: 12px; color: var(--muted); display: flex; gap: 4px; align-items: center; }
.composer-side input { accent-color: var(--accent); margin: 0; }
.composer .error { margin: 0; }
.bubble.mine { align-self: flex-end; background: var(--mine); border-color: #e2d6bd; }
.bubble .sender { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.bubble .meta { font-size: 11px; color: var(--muted); text-align: right; margin-top: 3px; }
.bubble .tag { font-size: 12px; color: var(--muted); font-style: italic; }
.bubble img, .bubble video { max-width: 100%; border-radius: 6px; display: block; margin-top: 4px; }
.bubble audio { width: 260px; max-width: 100%; margin-top: 4px; }
.more { align-self: center; }
.placeholder { margin: auto; color: var(--muted); text-align: center; padding: 24px; }

/* Login e usuários */
.card { max-width: 380px; margin: 10vh auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.card h1 { margin: 0 0 4px; font-size: 22px; }
.card p { color: var(--muted); margin: 0 0 18px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-size: 14px; }
.field input, .field select { border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: var(--bg); }
.error { color: var(--danger); font-size: 14px; margin-bottom: 10px; }
.page { max-width: 900px; margin: 24px auto; padding: 0 16px; }
.page h2 { margin-top: 28px; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
th { background: var(--bg); font-weight: 600; }
.inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* Celular */
@media (max-width: 760px) {
  .main { grid-template-columns: 1fr; }
  .main.open .side { display: none; }
  .main:not(.open) .chat { display: none; }
  .back { display: inline-block; }
  .messages { padding: 12px; }
  .bubble { max-width: 88%; }
  .top { gap: 8px; padding: 0 10px; }
  .top select { flex: 1; min-width: 0; padding: 6px; }
  .top .spacer { display: none; }
  .top .btn { padding: 6px 8px; }
  .top .who { display: none; }
  .grid2 { grid-template-columns: 1fr; }
}

/* Navegação */
.nav { display: flex; gap: 4px; }
.nav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 8px; font-weight: 600; font-size: 14px; }
.nav a:hover { background: var(--bg); }
.nav a.current { color: var(--ink); background: var(--accent-soft); }

/* Painel do funil dentro da conversa */
.deal-panel[hidden] { display: none; }
.deal-panel { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.deal-panel label { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.deal-panel select, .deal-panel input { border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; background: var(--bg); font-size: 14px; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--ink); }
.deal-panel input { width: 120px; }
.deal-panel .saved { font-size: 12px; color: var(--ok); padding-bottom: 6px; }

/* Funil */
.funnel-page { display: flex; flex-direction: column; }
.board-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.board-tools input[type=search] { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: var(--bg); width: 240px; }
.board-tools label { font-size: 14px; display: flex; gap: 6px; align-items: center; }
.board-tools .hint { font-size: 12px; color: var(--muted); }
.board { flex: 1; display: flex; gap: 12px; padding: 14px 16px; overflow-x: auto; min-height: 0; align-items: flex-start; }
.col { flex: 0 0 260px; background: #ebe7df; border-radius: 12px; display: flex; flex-direction: column; max-height: 100%; }
.col.over { outline: 2px dashed var(--accent); }
.col-head { padding: 10px 12px 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.col-title { font-weight: 700; font-size: 14px; }
.col-count { background: var(--panel); border-radius: 10px; font-size: 12px; padding: 0 8px; color: var(--muted); }
.col-total { width: 100%; font-size: 12px; color: var(--muted); }
.col-body { overflow-y: auto; padding: 4px 8px 10px; display: flex; flex-direction: column; gap: 8px; }
.col-empty { color: var(--muted); text-align: center; padding: 10px; font-size: 13px; }
.col[data-stage=fechado] { background: #e3ece4; }
.col[data-stage=perdido] { background: #efe3e0; }
.deal { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; cursor: pointer; font-size: 13px; }
.deal:hover { border-color: var(--accent); }
.deal.dragging { opacity: .5; }
.deal-name { font-weight: 700; font-size: 14px; margin-bottom: 3px; overflow-wrap: anywhere; }
.deal-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--muted); font-size: 12px; }
.deal-meta .owner { color: var(--accent); font-weight: 600; }
.deal-meta .owner.none { color: var(--danger); font-weight: 400; }
.deal-info { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 5px; font-size: 12px; }
.deal-last { margin-top: 5px; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deal-lost { margin-top: 4px; font-size: 12px; color: var(--danger); }
.deal-since { margin-top: 5px; font-size: 11px; color: var(--muted); }
@media (max-width: 760px) {
  .nav a { padding: 6px; font-size: 13px; }
  .top .brand { display: none; }
  .top select { min-width: 96px; }
  .board { padding: 10px; }
  .col { flex-basis: 82vw; }
  .board-tools .hint { display: none; }
  .deal-panel input { width: 100px; }
}
