:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --col: #eceef2;
  --line: #dfe2e8;
  --text: #16181d;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --wa: #1fa855;
  --call: #2563eb;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --panel: #181b21;
    --col: #14171c;
    --line: #2a2f38;
    --text: #e8eaee;
    --muted: #8b93a1;
    --accent: #4f8cff;
    --wa: #25c264;
    --call: #4f8cff;
    --danger: #f05252;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

/* botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); cursor: pointer; text-decoration: none; color: var(--text);
  font-weight: 500; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.icon { width: 36px; padding: 0; }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.call { background: var(--call); border-color: var(--call); color: #fff; }
.btn:disabled { opacity: .55; cursor: default; }

/* login */
.login { flex: 1; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px; display: grid; gap: 14px; box-shadow: var(--shadow);
}
.login-card .btn { height: 42px; }
.error { color: var(--danger); margin: 0; }

/* topo */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.logo {
  width: 30px; height: 30px; border-radius: 8px; background: var(--text); color: var(--bg);
  display: grid; place-items: center; font-weight: 700;
}
.top {
  display: flex; align-items: center; gap: 16px; padding: 12px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.search {
  flex: 1; min-width: 180px; max-width: 420px; display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
.search svg { color: var(--muted); }
.search input { border: 0; background: none; outline: none; width: 100%; }
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* quadro */
.board {
  flex: 1; display: flex; gap: 12px; padding: 16px; overflow-x: auto; overflow-y: hidden;
  align-items: stretch; scroll-snap-type: x proximity;
}
.column {
  flex: 0 0 290px; display: flex; flex-direction: column; background: var(--col);
  border-radius: 12px; max-height: 100%; scroll-snap-align: start; border: 1px solid transparent;
}
.column.over { border-color: var(--accent); }
.col-head { padding: 12px 12px 8px; display: flex; align-items: center; gap: 8px; }
.col-head .dot { width: 10px; height: 10px; border-radius: 50%; }
.col-head .name { font-weight: 600; }
.col-head .count { margin-left: auto; color: var(--muted); font-size: 12px; background: var(--panel); padding: 1px 8px; border-radius: 99px; }
.col-sum { padding: 0 12px 8px; color: var(--muted); font-size: 12px; min-height: 8px; }
.col-body { flex: 1; overflow-y: auto; padding: 0 8px 8px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.col-add { margin: 0 8px 8px; background: none; border: 1px dashed var(--line); color: var(--muted); border-radius: 8px; height: 34px; cursor: pointer; }
.col-add:hover { color: var(--text); border-color: var(--muted); }

.card {
  background: var(--panel); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow);
  cursor: pointer; border: 1px solid transparent; display: grid; gap: 6px;
}
.card:hover { border-color: var(--line); }
.card.dragging { opacity: .4; }
.card .c-name { font-weight: 600; overflow-wrap: anywhere; }
.card .c-meta { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.card .c-tag { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--bg); color: var(--muted); }
.card .c-actions { display: flex; gap: 6px; margin-top: 2px; }
.card .c-actions .btn { height: 30px; padding: 0 10px; font-size: 13px; flex: 1; }
.card .c-actions svg { width: 15px; height: 15px; }
.placeholder { height: 4px; background: var(--accent); border-radius: 4px; }

/* gaveta do lead */
.drawer {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .35); display: flex; justify-content: flex-end; z-index: 20;
}
.drawer-panel {
  width: 100%; max-width: 480px; height: 100%; background: var(--panel); display: flex; flex-direction: column;
  box-shadow: -8px 0 24px rgba(0, 0, 0, .15);
}
.d-head { padding: 16px; border-bottom: 1px solid var(--line); display: grid; gap: 12px; }
.d-title { display: flex; align-items: flex-start; gap: 8px; }
.d-title h2 { margin: 0; font-size: 18px; flex: 1; overflow-wrap: anywhere; }
.d-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.d-actions .btn { flex: 1; }
.d-body { flex: 1; overflow-y: auto; padding: 16px; display: grid; gap: 18px; align-content: start; }
.section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
input, select, textarea {
  height: 38px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: var(--bg);
  color: var(--text); font-size: 14px; width: 100%; min-width: 0;
}
textarea { height: auto; min-height: 70px; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.answers { display: grid; gap: 8px; }
.answer { background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.answer .q { font-size: 12px; color: var(--muted); }
.timeline { display: grid; gap: 8px; }
.tl { display: grid; grid-template-columns: 8px 1fr; gap: 10px; align-items: start; }
.tl .b { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-top: 6px; }
.tl.note .b { background: var(--accent); }
.tl.call .b { background: var(--wa); }
.tl.error .b { background: var(--danger); }
.tl .t { white-space: pre-wrap; overflow-wrap: anywhere; }
.tl.system .t, .tl.call .t { color: var(--muted); }
.tl .w { font-size: 11px; color: var(--muted); display: flex; gap: 8px; }
.tl .w button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; font-size: 11px; text-decoration: underline; }
.note-form { display: grid; gap: 8px; }
.note-form .btn { justify-self: end; }
.row { display: flex; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.warn { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); padding: 8px 10px; border-radius: 8px; font-size: 13px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); display: grid; place-items: center; z-index: 30; padding: 16px; }
.modal-panel {
  width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--panel);
  border-radius: 14px; padding: 20px; display: grid; gap: 16px;
}
.modal-panel h2 { margin: 0; font-size: 18px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 8px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--text); border-color: var(--accent); font-weight: 600; }
.stage-row { display: grid; grid-template-columns: auto 40px 1fr auto auto auto; gap: 6px; align-items: center; }
.stage-row input[type=color] { padding: 2px; height: 36px; width: 40px; }
.stage-row .btn { height: 36px; }
.copy { display: flex; gap: 6px; }
.copy input { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.help { font-size: 13px; color: var(--muted); margin: 0; }
.ok-badge { color: var(--wa); font-weight: 600; }

/* aviso */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; z-index: 40; max-width: calc(100vw - 32px); box-shadow: var(--shadow);
}
.toast.err { background: var(--danger); color: #fff; }

.empty { color: var(--muted); font-size: 12px; text-align: center; padding: 12px 4px; }

@media (max-width: 640px) {
  .top { gap: 10px; }
  .brand { font-size: 15px; }
  .search { order: 3; max-width: none; flex-basis: 100%; }
  #stats { display: none; }
  .board { padding: 12px; scroll-snap-type: x mandatory; }
  .column { flex-basis: calc(100vw - 48px); }
  .grid2 { grid-template-columns: 1fr; }
}
