:root {
  --pri: #14275c;        /* azul escuro FC */
  --pri-2: #1e3a8a;
  --pri-3: #2b4fb3;
  --pri-soft: #e9eefb;
  --pri-soft-2: #d6e0f7;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f4f6fb;
  --white: #fff;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #b91c1c;
  --chat-bg: #eef1f7;
  --bubble-in: #ffffff;
  --bubble-out: #dce6fb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { font-size: 14px; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* ---------- login ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 10% -10%, #2b4fb3 0%, transparent 60%), linear-gradient(160deg, #0d1b45, #14275c 55%, #1e3a8a); }
.login-card { width: 100%; max-width: 380px; background: var(--white); border-radius: 18px; padding: 32px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--pri); color: #fff; display: grid; place-items: center; font-weight: 800; letter-spacing: .5px; }
.brand h1 { font-size: 20px; margin: 0; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.input, .select, .textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--pri-3); box-shadow: 0 0 0 3px rgba(43, 79, 179, .15); }
.textarea { resize: vertical; min-height: 80px; }
.btn { border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 600; background: var(--pri); color: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background .15s, opacity .15s; }
.btn:hover { background: var(--pri-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--pri); border: 1px solid var(--pri-soft-2); }
.btn.ghost:hover { background: var(--pri-soft); }
.btn.light { background: var(--pri-soft); color: var(--pri); }
.btn.light:hover { background: var(--pri-soft-2); }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 4px 0 10px; }
.demo-note { margin-top: 16px; padding: 10px 12px; border-radius: 10px; background: var(--pri-soft); color: var(--pri); font-size: 12.5px; line-height: 1.45; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 72px 360px 1fr; height: 100vh; height: 100dvh; }
.rail { background: var(--pri); color: #c7d2f0; display: flex; flex-direction: column; align-items: center; padding: 12px 0; gap: 4px; }
.rail .logo { width: 42px; height: 42px; border-radius: 12px; background: #fff; color: var(--pri); font-weight: 800; display: grid; place-items: center; margin-bottom: 14px; font-size: 15px; }
.rail-btn { position: relative; width: 58px; padding: 8px 0 6px; border: 0; background: transparent; color: inherit; border-radius: 10px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; }
.rail-btn svg { width: 22px; height: 22px; }
.rail-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.rail-btn.active { background: rgba(255,255,255,.14); color: #fff; }
.rail-btn .dot { position: absolute; top: 4px; right: 10px; min-width: 18px; height: 18px; border-radius: 9px; background: #ef4444; color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }
.rail .spacer { flex: 1; }
.rail .me { width: 38px; height: 38px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); color: #fff; font-weight: 700; display: grid; place-items: center; background: transparent; }
.wa-pill { font-size: 9.5px; padding: 2px 6px; border-radius: 6px; margin-bottom: 8px; font-weight: 700; letter-spacing: .3px; }
.wa-pill.on { background: #16a34a; color: #fff; }
.wa-pill.off { background: #ef4444; color: #fff; }

/* ---------- lista ---------- */
.list { background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.list-head { padding: 14px 14px 8px; border-bottom: 1px solid var(--line); }
.list-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.list-title h2 { margin: 0; font-size: 17px; }
.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.search .input { padding-left: 32px; background: var(--bg); border-color: transparent; }
.tabs { display: flex; gap: 4px; margin-top: 10px; }
.tab { flex: 1; border: 0; background: transparent; padding: 8px 4px; border-radius: 8px; font-weight: 600; color: var(--muted); font-size: 13px; display: inline-flex; justify-content: center; align-items: center; gap: 6px; }
.tab:hover { background: var(--bg); }
.tab.active { background: var(--pri-soft); color: var(--pri); }
.count { background: var(--line); color: var(--ink-2); border-radius: 10px; padding: 0 7px; font-size: 11.5px; line-height: 18px; }
.tab.active .count { background: var(--pri); color: #fff; }
.count.alert { background: #ef4444; color: #fff; }
.filters { display: flex; gap: 6px; margin-top: 8px; }
.filters .select { padding: 6px 8px; font-size: 12.5px; border-radius: 8px; }
.items { flex: 1; overflow-y: auto; }
.item { display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid #f1f5f9; cursor: pointer; align-items: center; }
.item:hover { background: #f8fafc; }
.item.active { background: var(--pri-soft); }
.avatar { width: 42px; height: 42px; flex: none; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px; }
.item-main { flex: 1; min-width: 0; }
.item-row { display: flex; align-items: center; gap: 6px; }
.item-name { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-time { font-size: 11.5px; color: var(--muted); flex: none; }
.item-time.unread { color: var(--pri-3); font-weight: 700; }
.item-prev { color: var(--muted); font-size: 13px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.badge { min-width: 20px; height: 20px; border-radius: 10px; background: var(--pri-3); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 6px; flex: none; }
.tag { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 6px; color: #fff; flex: none; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag.queue { background: #fef3c7; color: #92400e; }
.tag.done { background: #e2e8f0; color: var(--ink-2); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.list-foot { padding: 10px 14px; border-top: 1px solid var(--line); }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; min-width: 0; background: var(--chat-bg); }
.chat-empty { flex: 1; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 20px; }
.chat-empty .big { width: 72px; height: 72px; border-radius: 20px; background: #fff; display: grid; place-items: center; margin: 0 auto 14px; box-shadow: var(--shadow); color: var(--pri); }
.chat-head { background: #fff; border-bottom: 1px solid var(--line); padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.chat-head .back { display: none; border: 0; background: transparent; padding: 4px; }
.chat-head .who { flex: 1; min-width: 0; cursor: pointer; }
.chat-head .who b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .who small { color: var(--muted); }
.chat-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.msgs { flex: 1; overflow-y: auto; padding: 16px 6%; display: flex; flex-direction: column; gap: 4px; }
.day { align-self: center; background: #fff; color: var(--muted); font-size: 11.5px; padding: 4px 10px; border-radius: 8px; margin: 10px 0 6px; box-shadow: 0 1px 1px rgba(0,0,0,.04); }
.sys { align-self: center; background: #fff8e6; color: #7c5300; font-size: 12px; padding: 4px 10px; border-radius: 8px; margin: 4px 0; text-align: center; max-width: 85%; }
.bubble { max-width: min(560px, 78%); padding: 7px 10px 5px; border-radius: 10px; box-shadow: 0 1px 1px rgba(0,0,0,.06); position: relative; word-wrap: break-word; white-space: pre-wrap; line-height: 1.38; }
.bubble.in { align-self: flex-start; background: var(--bubble-in); border-top-left-radius: 3px; }
.bubble.out { align-self: flex-end; background: var(--bubble-out); border-top-right-radius: 3px; }
.bubble .by { font-size: 11.5px; font-weight: 700; margin-bottom: 2px; }
.bubble .meta { font-size: 10.5px; color: var(--muted); text-align: right; margin-top: 2px; }
.bubble img.media { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; margin-bottom: 4px; cursor: zoom-in; }
.bubble img.sticker { max-width: 140px; }
.bubble video { max-width: 100%; max-height: 320px; border-radius: 8px; }
.bubble audio { width: 260px; max-width: 100%; }
.bubble a { color: var(--pri-3); }
.doc { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.6); border: 1px solid var(--line); padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--ink) !important; margin-bottom: 4px; }
.doc svg { width: 28px; height: 28px; color: var(--pri); flex: none; }
.composer { background: #fff; border-top: 1px solid var(--line); padding: 10px 12px; display: flex; gap: 8px; align-items: flex-end; position: relative; }
.composer textarea { flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; resize: none; max-height: 160px; min-height: 42px; outline: none; background: var(--bg); line-height: 1.35; }
.composer textarea:focus { background: #fff; border-color: var(--pri-3); }
.icon-btn { width: 42px; height: 42px; flex: none; border-radius: 12px; border: 0; background: var(--pri-soft); color: var(--pri); display: grid; place-items: center; }
.icon-btn:hover { background: var(--pri-soft-2); }
.icon-btn.send { background: var(--pri); color: #fff; }
.icon-btn.send:hover { background: var(--pri-2); }
.icon-btn svg { width: 20px; height: 20px; }
.notice { background: #fff; border-top: 1px solid var(--line); padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--ink-2); }
.qr-pop { position: absolute; left: 12px; right: 12px; bottom: 64px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; z-index: 5; }
.qr-pop .qr-item { padding: 9px 12px; border-bottom: 1px solid #f1f5f9; cursor: pointer; }
.qr-pop .qr-item:hover, .qr-pop .qr-item.sel { background: var(--pri-soft); }
.qr-pop .qr-item b { color: var(--pri); margin-right: 6px; }
.qr-pop .qr-item span { color: var(--muted); }

/* ---------- páginas ---------- */
.page { grid-column: 2 / 4; overflow-y: auto; padding: 24px 28px 40px; }
.page h2 { margin: 0 0 4px; font-size: 22px; }
.page .sub { color: var(--muted); margin: 0 0 20px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: 0 1px 2px rgba(15,23,42,.03); margin-bottom: 16px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi small { color: var(--muted); font-weight: 600; font-size: 12px; }
.kpi b { display: block; font-size: 26px; margin-top: 4px; color: var(--pri); }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid #f1f5f9; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.person { display: flex; align-items: center; gap: 8px; }
.swatch { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar i { display: block; width: 100%; max-width: 38px; background: var(--pri-3); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar span { font-size: 10.5px; color: var(--muted); }
.bar em { font-style: normal; font-size: 11px; font-weight: 700; color: var(--ink-2); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.pill { font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 20px; }
.pill.on { background: #dcfce7; color: var(--ok); }
.pill.off { background: #fee2e2; color: var(--danger); }
.pill.wait { background: #fef3c7; color: var(--warn); }
.pill.role { background: var(--pri-soft); color: var(--pri); }
.wa-box { display: grid; grid-template-columns: 300px 1fr; gap: 24px; align-items: start; }
.wa-box img { width: 280px; height: 280px; border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: #fff; }
.wa-box ol { margin: 0; padding-left: 20px; line-height: 1.8; color: var(--ink-2); }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--pri); }
.help { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

/* ---------- modal / toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 440px; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); max-height: 90vh; overflow-y: auto; }
.modal h3 { margin: 0 0 14px; font-size: 17px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.pick { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; }
.pick button { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: #fff; text-align: left; }
.pick button:hover { background: var(--pri-soft); border-color: var(--pri-soft-2); }
.colors { display: flex; gap: 6px; flex-wrap: wrap; }
.colors label { cursor: pointer; }
.colors input { display: none; }
.colors span { display: block; width: 26px; height: 26px; border-radius: 50%; border: 3px solid transparent; }
.colors input:checked + span { border-color: var(--ink); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 60; box-shadow: var(--shadow); font-size: 13.5px; max-width: 90vw; }
.toast.err { background: var(--danger); }
.menu { position: fixed; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 40; min-width: 200px; padding: 6px; }
.menu .head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu .head small { color: var(--muted); }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 10px; border-radius: 8px; }
.menu button:hover { background: var(--bg); }
.demo-bar { position: fixed; right: 16px; bottom: 16px; z-index: 30; }

/* ---------- celular ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr 60px; }
  .rail { order: 2; flex-direction: row; justify-content: space-around; padding: 4px 6px; gap: 0; }
  .rail .logo, .rail .spacer, .wa-pill { display: none; }
  .rail-btn { width: auto; flex: 1; }
  .list, .chat, .page { grid-row: 1; grid-column: 1; }
  .app.in-chat .list { display: none; }
  .app:not(.in-chat) .chat { display: none; }
  .chat-head .back { display: block; }
  .msgs { padding: 12px; }
  .page { padding: 16px; }
  .wa-box { grid-template-columns: 1fr; }
  .chat-actions .btn span.t { display: none; }
}
