/* Zapdrop — painel (desktop-first, responsivo) */
:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r-sm: 8px; --r: 12px; --r-lg: 16px;
  --sidebar: 240px;
  --accent: #8a2be2; --accent-2: #a855f7; --accent-ink: #fff; --accent-soft: rgba(138, 43, 226, .12);
  --ok: #16a34a; --ok-soft: rgba(22, 163, 74, .12);
  --warn: #d97706; --warn-soft: rgba(217, 119, 6, .14);
  --bad: #dc2626; --bad-soft: rgba(220, 38, 38, .12);
  --hot: #ea580c; --hot-soft: rgba(234, 88, 12, .14);
}
:root[data-theme="light"] {
  --bg: #f5f6fa; --bg-2: #eef0f6; --card: #ffffff; --ink: #141824; --ink-2: #4a5165; --muted: #7b8297;
  --line: #e4e7ef; --line-2: #d7dbe6; --side: #ffffff; --hover: #f1f2f8; --chat: #f1f2f8; --bubble-in: #ffffff; --bubble-out: #efe3ff;
  --shadow: 0 1px 2px rgba(20, 24, 36, .05), 0 4px 16px rgba(20, 24, 36, .05);
}
:root[data-theme="dark"] {
  --bg: #0d0b13; --bg-2: #15121e; --card: #181522; --ink: #eceef5; --ink-2: #b4b9c9; --muted: #8189a0;
  --line: #27223a; --line-2: #332c49; --side: #0a0810; --hover: #1f1a2d; --chat: #100d18; --bubble-in: #211c30; --bubble-out: #3a1f66;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  --accent-soft: rgba(168, 85, 247, .16);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-2); text-decoration: none; }
button { font: inherit; color: inherit; }
.hide { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.brand-mark.light { display: none; }
:root[data-theme="light"] .brand-mark.dark { display: none; }
:root[data-theme="light"] .brand-mark.light { display: block; filter: none; }
.brand-mark { width: 34px; height: 34px; object-fit: contain; filter: drop-shadow(0 0 10px rgba(168, 85, 247, .45)); }
.brand-name { font-family: "Lexend", var(--font); font-weight: 700; font-size: 21px; letter-spacing: -.01em; }
.nav { padding: 6px 10px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: var(--hover); color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--accent-2); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .badge { margin-left: auto; }
.side-foot { padding: 12px; border-top: 1px solid var(--line); }
.conn { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 28px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 10; }
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.topbar .spacer { flex: 1; }
.page { padding: 24px 28px 48px; max-width: 1400px; width: 100%; }
.btn.menu-btn { display: none; }

/* ---------- Componentes ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow); }
.card h2 { font-size: 15px; margin: 0 0 14px; font-weight: 700; }
.card h2 .muted { font-weight: 500; }
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-21 { grid-template-columns: 2fr 1fr; }

.kpi .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.kpi .value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.meter { height: 6px; border-radius: 99px; background: var(--bg-2); margin-top: 10px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; background: var(--accent); color: var(--accent-ink); padding: 9px 14px; border-radius: var(--r-sm); font-weight: 600; cursor: pointer; white-space: nowrap; transition: filter .15s; }
.btn:not(.ghost):not(.bad) { background-image: linear-gradient(135deg, #a347ff, #6d28d9); box-shadow: 0 4px 14px rgba(138, 43, 226, .28); }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: var(--card); color: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { background: var(--hover); filter: none; }
.btn.bad { background: var(--bad-soft); color: var(--bad); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.icon { padding: 8px; }
.btn svg { width: 16px; height: 16px; }

label.f { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 12px 0 6px; }
input, textarea, select { width: 100%; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: var(--r-sm); font: inherit; background: var(--card); color: var(--ink); outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 96px; resize: vertical; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--bg-2); color: var(--ink-2); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.hot { background: var(--hot-soft); color: var(--hot); }
.pill.acc { background: var(--accent-soft); color: var(--accent-2); }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--hot); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }

table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr:hover { background: var(--hover); }
.t-wrap { overflow-x: auto; margin: -4px -8px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; color: var(--muted); font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--accent-2); border-color: var(--accent); }

/* ---------- Gráficos ---------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 230px; padding-top: 8px; overflow: hidden; }
.bars .col { min-width: 0; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .pair { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.bars .b1, .bars .b2 { width: 42%; max-width: 14px; border-radius: 4px 4px 2px 2px; min-height: 2px; }
.bars .b1 { background: var(--accent); }
.bars .b2 { background: var(--hot); }
.bars .lbl { font-size: 10px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.funnel .fr { display: grid; grid-template-columns: 120px 1fr 44px; gap: 10px; align-items: center; margin-bottom: 9px; font-size: 13px; }
.funnel .track { height: 10px; background: var(--bg-2); border-radius: 99px; overflow: hidden; }
.funnel .track i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.funnel .n { text-align: right; font-weight: 700; }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 12px; min-height: calc(100vh - 210px); }
.kcol { background: var(--bg-2); border-radius: var(--r-lg); padding: 10px; display: flex; flex-direction: column; min-height: 200px; border: 1px solid transparent; }
.kcol.drop { border-color: var(--accent); background: var(--accent-soft); }
.khead { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; font-weight: 700; font-size: 13px; }
.khead .count { margin-left: auto; color: var(--muted); font-weight: 600; }
.kbar { width: 4px; height: 14px; border-radius: 2px; }
.kcards { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.kcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 11px 12px; cursor: grab; box-shadow: var(--shadow); }
.kcard:hover { border-color: var(--line-2); }
.kcard.dragging { opacity: .5; }
.kcard .t1 { font-weight: 600; }
.kcard .t2 { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kcard .t3 { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* ---------- Conversas ---------- */
.inbox { display: grid; grid-template-columns: 340px 1fr; height: calc(100vh - 64px - 48px); background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); }
.inbox-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.inbox-list .head { padding: 12px; border-bottom: 1px solid var(--line); }
.inbox-items { overflow-y: auto; flex: 1; }
.ii { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.ii:hover { background: var(--hover); }
.ii.on { background: var(--accent-soft); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-2); display: grid; place-items: center; font-weight: 700; flex: none; }
.chat-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.chat-body { flex: 1; overflow-y: auto; padding: 18px; background: var(--chat); display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: min(560px, 78%); padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; box-shadow: var(--shadow); }
.msg.in { background: var(--bubble-in); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.out { background: var(--bubble-out); align-self: flex-end; border-bottom-right-radius: 4px; }
.msg .meta { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; text-align: right; }
.chat-foot { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-empty { flex: 1; display: grid; place-items: center; color: var(--muted); }

/* ---------- Drawer / modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8, 10, 16, .5); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100%); background: var(--card); border-left: 1px solid var(--line); z-index: 41; display: flex; flex-direction: column; box-shadow: -10px 0 40px rgba(0, 0, 0, .2); }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.step { border: 1px solid var(--line); border-radius: var(--r); padding: 14px; background: var(--bg-2); position: relative; }
.step-n { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.bubble-preview { background: var(--bubble-out); padding: 8px 12px; border-radius: 12px; margin-top: 6px; white-space: pre-wrap; }

.qr { text-align: center; padding: 12px; }
.qr img { width: 260px; max-width: 100%; background: #fff; padding: 10px; border-radius: 12px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .2s; pointer-events: none; z-index: 60; font-weight: 500; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

.theme-btn svg { width: 18px; height: 18px; }

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-21, .g-3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 10px 0 40px rgba(0, 0, 0, .3); }
  .btn.menu-btn { display: inline-flex; }
  .bars { gap: 3px; }
  .bars .col:nth-child(odd) .lbl { visibility: hidden; }
  .legend { flex-wrap: wrap; gap: 8px; }
  .funnel .fr { grid-template-columns: 96px 1fr 36px; }
  .topbar { padding: 0 14px; }
  .page { padding: 16px 14px 40px; }
  .g-2 { grid-template-columns: 1fr; }
  .inbox { grid-template-columns: 1fr; height: calc(100vh - 64px - 32px); }
  .inbox.has-chat .inbox-list { display: none; }
  .inbox:not(.has-chat) .chat-pane { display: none; }
  .kanban { grid-auto-columns: 82%; }
  .hide-m { display: none !important; }
}
@media (min-width: 861px) { .only-m { display: none !important; } }
