*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #F0F2F5;
  --surface:   #FFFFFF;
  --border:    #E4E7EC;
  --text:      #101828;
  --muted:     #667085;
  --accent:    #25D366;

  --c1: #2563EB;
  --c2: #D97706;
  --c3: #7C3AED;
  --c4: #EA580C;
  --c5: #059669;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(16,24,40,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal-box {
  background: var(--surface);
  border-radius: 16px;
  padding: 40px 48px;
  text-align: center;
  width: 340px;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
}
.modal-icon { margin-bottom: 16px; }
.modal-box h2 { font-size: 1.2rem; font-weight: 600; margin-bottom: 8px; }
.modal-box p  { font-size: .875rem; color: var(--muted); line-height: 1.5; }
#qr-img { width: 220px; height: 220px; margin: 20px auto 0; border-radius: 8px; display: block; }

.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 20px auto 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress-bar {
  height: 4px; background: var(--border);
  border-radius: 4px; margin-top: 20px; overflow: hidden;
}
.progress-bar #modal-progress-inner {
  height: 100%; background: var(--accent);
  transition: width .3s ease;
  border-radius: 4px;
}

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-title { font-weight: 700; font-size: 1rem; letter-spacing: -.02em; }
.topbar-right { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); }

.topbar-search {
  position: relative;
  display: flex; align-items: center;
}
.search-icon {
  position: absolute; left: 10px;
  color: var(--muted); pointer-events: none;
}
.search-input {
  width: 260px;
  padding: 7px 12px 7px 32px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
  font-family: inherit; font-size: .82rem;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,211,102,.15);
  background: var(--surface);
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #D1D5DB; }
.status-dot.online { background: var(--accent); box-shadow: 0 0 0 3px rgba(37,211,102,.2); }

/* ── Board ───────────────────────────────────────────────── */
.board {
  display: flex;
  gap: 12px;
  padding: 72px 16px 16px;
  height: 100vh;
  overflow-x: auto;
  overflow-y: hidden;
}
.board::-webkit-scrollbar { height: 6px; }
.board::-webkit-scrollbar-track { background: transparent; }
.board::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Column ──────────────────────────────────────────────── */
.column {
  flex: 0 0 240px;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.column-header {
  padding: 12px 14px;
  border-bottom: 2px solid;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.column-header-left { display: flex; align-items: center; gap: 8px; }
.col-dot { width: 10px; height: 10px; border-radius: 50%; }
.column-title { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text); }
.column-count {
  font-size: .72rem; font-weight: 600;
  background: var(--bg); border-radius: 20px;
  padding: 1px 8px; color: var(--muted);
}
.column-cards {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex; flex-direction: column; gap: 6px;
  min-height: 80px;
}
.column-cards::-webkit-scrollbar { width: 4px; }
.column-cards::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.column.drag-over .column-cards {
  background: rgba(37,211,102,.06);
  border-radius: 8px;
}

/* ── Card ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  cursor: grab;
  transition: box-shadow .15s, transform .15s;
  user-select: none;
}
.card:hover    { box-shadow: 0 4px 16px rgba(0,0,0,.08); transform: translateY(-1px); }
.card.dragging { opacity: .45; cursor: grabbing; }

.card-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.card-identity { min-width: 0; }
.card-name  { font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-phone { font-size: .74rem; color: var(--muted); }

.card-last-msg {
  font-size: .78rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 6px;
}
.card-footer { display: flex; justify-content: flex-end; }
.card-time   { font-size: .7rem; color: #9CA3AF; }

.card.unread {
  border-color: #25D366;
  box-shadow: 0 0 0 1.5px #25D36640;
}
.card.unread .card-name { color: var(--text); font-weight: 700; }

.unread-badge {
  margin-left: auto;
  background: #25D366;
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 7px;
  flex-shrink: 0;
}

.card-last-msg.unread-text {
  color: var(--text);
  font-weight: 500;
}

/* ── Side panel ──────────────────────────────────────────── */
.panel {
  position: fixed; top: 0; right: -420px; width: 400px; height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 150;
  transition: right .25s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
.panel.open { right: 0; }

.panel-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.25);
  z-index: 149;
}

/* cabeçalho fixo */
.panel-header {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-avatar { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .9rem; font-weight: 700; color: #fff; flex-shrink: 0; }
.panel-info   { flex: 1; min-width: 0; }
.panel-name-row { display: flex; align-items: center; gap: 6px; }
.panel-name   { font-size: .95rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-phone  { font-size: .8rem; color: var(--muted); }
.panel-close  { margin-left: auto; flex-shrink: 0; }

/* fase + notas (rola se crescer demais) */
.panel-top {
  flex-shrink: 0;
  overflow-y: auto;
  max-height: 260px;
  border-bottom: 1px solid var(--border);
}
.panel-top::-webkit-scrollbar { width: 4px; }
.panel-top::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.panel-phase { padding: 14px 16px 10px; border-bottom: 1px solid var(--border); }
.panel-notes { padding: 12px 16px 14px; }

.field-label {
  display: block; font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin-bottom: 8px;
}

.phase-select {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font-family: inherit; font-size: .875rem;
  cursor: pointer; outline: none;
  transition: border-color .15s;
}
.phase-select:focus { border-color: #6366F1; box-shadow: 0 0 0 3px rgba(99,102,241,.15); }

textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: .875rem; color: var(--text);
  resize: vertical; outline: none;
  transition: border-color .15s;
}
textarea:focus { border-color: #6366F1; box-shadow: 0 0 0 3px rgba(99,102,241,.15); }

.btn-save {
  margin-top: 8px; width: 100%;
  padding: 9px; border-radius: 8px;
  background: var(--accent); color: #fff;
  border: none; font-family: inherit; font-size: .875rem; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.btn-save:hover { background: #1DB954; }

.btn-delete {
  width: 100%; padding: 9px; border-radius: 8px;
  background: transparent; color: #EF4444;
  border: 1px solid #FECACA;
  font-family: inherit; font-size: .875rem; font-weight: 600;
  cursor: pointer; transition: background .15s, border-color .15s;
}
.btn-delete:hover { background: #FEF2F2; border-color: #EF4444; }

.btn-icon {
  background: transparent; border: none; cursor: pointer;
  color: var(--muted); border-radius: 6px;
  padding: 4px; display: flex; align-items: center; justify-content: center;
  transition: color .15s, background .15s;
}
.btn-icon:hover { color: var(--text); background: var(--bg); }

/* ── Área de conversa ────────────────────────────────────── */
.panel-chat-area {
  flex: 1;
  display: flex; flex-direction: column;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  min-height: 180px;
}

.panel-chat-header {
  padding: 10px 16px 4px;
  flex-shrink: 0;
}

.messages-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.messages-list::-webkit-scrollbar { width: 4px; }
.messages-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.msg-bubble {
  max-width: 85%; padding: 8px 12px;
  border-radius: 12px; font-size: .82rem; line-height: 1.4;
  word-break: break-word;
}
.msg-bubble.received { background: var(--bg); color: var(--text); align-self: flex-start; border-bottom-left-radius: 3px; }
.msg-bubble.sent     { background: #DCF8C6; color: #111; align-self: flex-end; border-bottom-right-radius: 3px; }
.msg-time { font-size: .65rem; color: var(--muted); margin-top: 3px; opacity: .8; }

.empty-msgs { font-size: .82rem; color: var(--muted); text-align: center; padding: 20px 0; }

/* input de envio */
.chat-input-row {
  flex-shrink: 0;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.chat-input {
  flex: 1;
  resize: none;
  max-height: 100px;
  overflow-y: auto;
  padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 20px;
  font-family: inherit; font-size: .875rem; color: var(--text);
  outline: none; line-height: 1.4;
  transition: border-color .15s;
}
.chat-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,211,102,.15); }

.btn-send {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--accent); color: #fff;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .1s;
}
.btn-send:hover   { background: #1DB954; }
.btn-send:active  { transform: scale(.92); }
.btn-send:disabled { background: var(--border); cursor: not-allowed; }

/* zona de perigo */
.panel-danger { flex-shrink: 0; padding: 12px 16px; }

/* ── Botão anexar ────────────────────────────────────────── */
.btn-attach {
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: transparent; color: var(--muted);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color .15s, background .15s;
}
.btn-attach:hover { color: var(--text); background: var(--bg); }

/* ── Preview de arquivo selecionado ──────────────────────── */
.file-preview {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  font-size: .82rem;
}
.preview-thumb {
  width: 42px; height: 42px;
  object-fit: cover; border-radius: 6px; flex-shrink: 0;
}
.preview-file-icon { font-size: 1.4rem; flex-shrink: 0; }
.preview-filename {
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}
.btn-clear-file {
  flex-shrink: 0;
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 1.1rem; line-height: 1;
  padding: 2px 5px; border-radius: 4px;
  transition: color .15s, background .15s;
}
.btn-clear-file:hover { color: #EF4444; background: #FEF2F2; }

/* ── Mídia nas bolhas de mensagem ────────────────────────── */
.msg-img {
  max-width: 100%; border-radius: 8px; display: block; cursor: pointer;
}
.msg-caption { margin-top: 4px; }
.msg-file {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 0;
  color: inherit; text-decoration: none; font-size: .82rem;
}
.msg-file:hover { text-decoration: underline; }

/* ── Bot badges (cards) ──────────────────────────────────── */
.bot-badge {
  display: inline-flex; align-items: center;
  font-size: .68rem; font-weight: 600;
  padding: 2px 7px; border-radius: 99px;
  letter-spacing: .02em; white-space: nowrap;
}
.bot-active  { background: #DCFCE7; color: #15803D; }
.bot-handoff { background: #FEF3C7; color: #92400E; }

/* ── Bot status bar (panel) ──────────────────────────────── */
.bot-status-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  font-size: .82rem;
  border-bottom: 1px solid var(--border);
}
.bot-bar-active  { background: #F0FDF4; }
.bot-bar-handoff { background: #FFFBEB; }
.bot-bar-text { flex: 1; color: var(--text); }
.btn-assume {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: .78rem; font-weight: 600;
  cursor: pointer; color: var(--text);
  transition: background .15s, border-color .15s;
}
.btn-assume:hover { background: var(--bg); border-color: #94A3B8; }

/* ── Tab nav ─────────────────────────────────────────────── */
.tab-nav {
  display: flex; gap: 4px;
  background: var(--bg); border-radius: 8px;
  padding: 3px;
}
.tab-btn {
  padding: 5px 18px; border-radius: 6px; border: none;
  font-family: inherit; font-size: .82rem; font-weight: 600;
  cursor: pointer; color: var(--muted); background: transparent;
  transition: background .15s, color .15s;
}
.tab-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.tab-btn:hover:not(.active) { color: var(--text); }

/* ── Reports view ────────────────────────────────────────── */
.reports-view {
  padding: 72px 24px 24px;
  height: 100vh;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 20px;
}
.reports-view::-webkit-scrollbar { width: 6px; }
.reports-view::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.reports-filters {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface); border-radius: 12px;
  padding: 12px 16px; border: 1px solid var(--border);
}
.filter-btn {
  padding: 5px 14px; border-radius: 6px;
  border: 1px solid var(--border);
  font-family: inherit; font-size: .8rem; font-weight: 500;
  cursor: pointer; color: var(--muted); background: var(--surface);
  transition: all .15s;
}
.filter-btn.active {
  background: var(--text); color: #fff; border-color: var(--text);
}
.filter-btn:hover:not(.active) { border-color: #94A3B8; color: var(--text); }

.custom-range {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.custom-range input[type="date"] {
  padding: 5px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-family: inherit; font-size: .82rem; color: var(--text);
  outline: none; background: var(--surface);
}

.report-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.report-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px 20px;
}
.report-card.accent-green { border-top: 3px solid #059669; }
.report-card.accent-blue  { border-top: 3px solid #2563EB; }
.report-card-label {
  font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin-bottom: 8px;
}
.report-card-value {
  font-size: 1.8rem; font-weight: 700; color: var(--text);
  line-height: 1; margin-bottom: 6px;
}
.report-card-sub { font-size: .78rem; color: var(--muted); }

.report-table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
}
.report-table-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.report-section-title {
  font-size: .9rem; font-weight: 600; color: var(--text);
}
.report-table {
  width: 100%; border-collapse: collapse;
  font-size: .85rem;
}
.report-table th {
  padding: 10px 18px; text-align: left;
  font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.report-table td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.report-table tr:last-child td { border-bottom: none; }
.report-table tbody tr:hover { background: var(--bg); }

.r-empty {
  text-align: center; padding: 32px;
  font-size: .875rem; color: var(--muted);
}

/* ── Registrar Pedido ────────────────────────────────────── */
.panel-pedido-action {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.btn-pedido-action {
  width: 100%; padding: 10px;
  border-radius: 8px;
  background: #059669; color: #fff;
  border: none; font-family: inherit; font-size: .875rem; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 7px;
  transition: background .15s;
}
.btn-pedido-action:hover { background: #047857; }

/* ── Utilities ───────────────────────────────────────────── */
.hidden { display: none !important; }
