:root, [data-theme="dark"] {
  --bg: #0e1116;
  --panel: #161a21;
  --panel-2: #1d222b;
  --panel-3: #262c37;
  --hover: #1f2530;
  --active: #232c3a;
  --border: #272d38;
  --text: #e8ebf1;
  --muted: #8a94a6;
  --accent: #5b8bab;
  --accent-2: #6f9dbb;
  --accent-soft: rgba(91, 139, 171, .16);
  --danger: #f05252;
  --warn: #f59e0b;
  --ok: #22c55e;
  --bubble-in: #1d222b;
  --bubble-out: #1f4d45;
  --chat-bg: #0e1116;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --card-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --link: #7cb3d6;
  --read: #53bdeb;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #f2f4f7;
  --panel-3: #e8ebf0;
  --hover: #f2f4f7;
  --active: #eaf0f4;
  --border: #e4e7ec;
  --text: #101828;
  --muted: #667085;
  --accent: #3d5a6c;
  --accent-2: #4b7590;
  --accent-soft: rgba(61, 90, 108, .1);
  --danger: #d92d20;
  --warn: #dc6803;
  --ok: #16a34a;
  --bubble-in: #ffffff;
  --bubble-out: #dcefe6;
  --chat-bg: #eef0f3;
  --shadow: 0 12px 32px rgba(16, 24, 40, .14);
  --card-shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --link: #2f6f95;
  --read: #3a9fd6;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  user-select: none;
}
input, textarea, select, button { font: inherit; color: inherit; }
.text, .note-text, .quoted-text, input, textarea, .chat-head-sub, .crm-name, td { user-select: text; }
a { color: var(--link); cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.row.wrap { flex-wrap: wrap; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pre { white-space: pre-wrap; }
code.path { display: block; padding: 8px; background: var(--panel-2); border-radius: 6px; font-size: 12px; word-break: break-all; margin-bottom: 10px; user-select: text; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(134, 150, 160, .35); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

#app { display: flex; height: 100vh; position: relative; }

/* ------------------------------------------------------------ rail */
.rail {
  width: 72px; flex: none; background: var(--panel-2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 4px;
}
.rail-logo { width: 44px; height: 44px; margin-bottom: 10px; }
.rail-btn {
  position: relative; width: 62px; padding: 7px 0 5px; border: 0; border-radius: 10px; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted);
}
.rail-btn:hover { background: var(--hover); color: var(--text); }
.rail-btn.active { background: var(--active); color: var(--text); }
.rail-btn.active::before { content: ""; position: absolute; left: -5px; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--accent); }
.rail-icon { font-size: 20px; line-height: 1; }
.rail-label { font-size: 10.5px; }
.nav-badge {
  position: absolute; top: 2px; right: 8px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent);
  color: #fff; font-size: 11px; font-weight: 600; display: grid; place-items: center;
}
.rail-status { padding: 10px; }
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.status-dot.ok { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .2); }
.status-dot.warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(245, 158, 11, .2); }
.status-dot.bad { background: var(--danger); box-shadow: 0 0 0 3px rgba(239, 68, 68, .2); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.view { display: none; flex: 1; min-height: 0; }
.view.active { display: flex; }
.view-page.active { display: block; overflow: auto; padding: 22px 28px; }
.view-board.active { display: flex; flex-direction: column; padding: 16px 20px 0; }

/* ---------------------------------------------------------- buttons */
.btn {
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text); padding: 7px 14px; border-radius: 8px;
  cursor: pointer; white-space: nowrap; transition: background .12s;
}
.btn:hover { background: var(--panel-3); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: rgba(239, 68, 68, .12); }
.icon-btn {
  border: 0; background: transparent; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; color: var(--muted);
  font-size: 18px; display: grid; place-items: center; flex: none;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.small { width: 28px; height: 28px; font-size: 14px; }
.icon-btn:disabled { opacity: .35; cursor: default; }

.input {
  width: 100%; background: var(--panel-2); border: 1px solid transparent; border-radius: 8px; padding: 8px 11px; outline: none;
}
.input:focus { border-color: var(--accent); }
.input-sm { padding: 6px 9px; font-size: 13px; }
.select-sm { width: auto; padding: 5px 8px; font-size: 12.5px; }
textarea.input { resize: vertical; }
[data-theme="light"] .input { background: #fff; border-color: var(--border); }
[data-theme="light"] .input:focus { border-color: var(--accent); }
.search { padding-left: 12px; }
.check { display: flex; align-items: center; gap: 6px; cursor: pointer; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 0; background: var(--panel-2); color: var(--muted); padding: 5px 12px; border-radius: 16px; cursor: pointer; font-size: 13px;
}
.chip:hover { color: var(--text); }
.chip.active { background: rgba(75, 117, 144, .25); color: var(--accent-2); }
[data-theme="light"] .chip.active { color: var(--accent); }

/* ------------------------------------------------------------ inbox */
.view-inbox { background: var(--panel); }
.chatlist { width: 380px; flex: none; display: flex; flex-direction: column; border-right: 1px solid var(--border); background: var(--panel); }
.chatlist-head { padding: 12px 14px 8px; display: flex; flex-direction: column; gap: 9px; border-bottom: 1px solid var(--border); }
.chatlist-head h2 { margin: 0; font-size: 21px; flex: 1; }
.filter-selects { display: flex; gap: 6px; }
.filter-selects select { flex: 1; min-width: 0; }
.chatlist-items { flex: 1; overflow-y: auto; }
.list-empty { padding: 30px 20px; text-align: center; color: var(--muted); }
.list-section { padding: 12px 16px 6px; color: var(--accent); font-size: 13px; text-transform: uppercase; }
.chat-row {
  display: flex; gap: 12px; padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); position: relative; align-items: center;
}
.chat-row::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--stage, transparent); }
.chat-row:hover { background: var(--hover); }
.chat-row.active { background: var(--active); }
.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-top, .chat-bottom { display: flex; align-items: center; gap: 8px; }
.chat-name { flex: 1; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { font-size: 12px; color: var(--muted); flex: none; }
.chat-row.unread .chat-time { color: var(--accent-2); }
.chat-row.unread .chat-name { font-weight: 600; }
.chat-preview { flex: 1; color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-meta { display: flex; gap: 5px; align-items: center; margin-top: 3px; flex-wrap: wrap; }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent-2); color: #111b21;
  font-size: 12px; font-weight: 600; display: grid; place-items: center; flex: none;
}
.search-hit mark { background: rgba(0, 168, 132, .35); color: inherit; border-radius: 2px; }

.avatar {
  border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 600; overflow: hidden; position: relative;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.stage-pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 11px; font-size: 12px; white-space: nowrap;
  background: color-mix(in srgb, var(--c) 22%, transparent); color: color-mix(in srgb, var(--c) 70%, var(--text));
}
.stage-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.stage-pill.small { font-size: 11px; padding: 1px 7px; }
.tag-dots { display: inline-flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.tag-chip {
  display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11.5px; border: 1px solid color-mix(in srgb, var(--c) 60%, transparent);
  color: color-mix(in srgb, var(--c) 75%, var(--text)); background: color-mix(in srgb, var(--c) 12%, transparent); white-space: nowrap;
}
.tag-chip.toggle { cursor: pointer; opacity: .55; background: transparent; padding: 3px 10px; font-size: 12.5px; }
.tag-chip.toggle.on { opacity: 1; background: color-mix(in srgb, var(--c) 22%, transparent); }
.tag-more { font-size: 11px; color: var(--muted); }
.task-flag { font-size: 11.5px; color: var(--muted); }
.task-flag.late { color: var(--danger); font-weight: 600; }

/* ------------------------------------------------------------ chat view */
.chatview { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--chat-bg); }
.chat-pane { display: flex; flex-direction: column; flex: 1; min-height: 0; position: relative; }
.chat-pane.dropping::after {
  content: "Solte os arquivos para enviar"; position: absolute; inset: 10px; border: 3px dashed var(--accent); border-radius: 14px;
  display: grid; place-items: center; font-size: 20px; background: rgba(0, 0, 0, .55); color: #fff; z-index: 20;
}
.chat-head { display: flex; align-items: center; gap: 12px; padding: 9px 16px; background: var(--panel-2); border-left: 1px solid var(--border); min-height: 60px; }
.chat-head-info { flex: 1; min-width: 0; cursor: pointer; }
.chat-head-name { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head-sub { font-size: 12.5px; color: var(--muted); }
.stage-btn {
  border: 1px solid color-mix(in srgb, var(--c, var(--muted)) 55%, transparent); background: color-mix(in srgb, var(--c, transparent) 16%, transparent);
  color: var(--text); padding: 6px 12px; border-radius: 16px; cursor: pointer; white-space: nowrap; font-size: 13px;
}
.stage-btn.unset { border-style: dashed; color: var(--muted); --c: var(--muted); background: transparent; }
.chat-head .stage-btn { flex: 0 1 auto; min-width: 0; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.chat-head .icon-btn { flex: none; }
.chat-head-info { min-width: 90px; }
.stage-btn.wide { width: 100%; text-align: left; border-radius: 8px; }
.messages-wrap { flex: 1; min-height: 0; position: relative; }
.messages { position: absolute; inset: 0; overflow-y: auto; padding: 12px 6% 18px; display: flex; flex-direction: column; gap: 2px; }
.older-bar { text-align: center; padding: 8px; }
.day-sep { text-align: center; margin: 10px 0 6px; }
.day-sep span { background: var(--panel-2); color: var(--muted); font-size: 12px; padding: 5px 12px; border-radius: 8px; box-shadow: 0 1px 1px rgba(0,0,0,.15); }
.sys-msg { text-align: center; margin: 6px 0; }
.sys-msg span { background: var(--panel-2); color: var(--muted); font-size: 12.5px; padding: 5px 12px; border-radius: 8px; display: inline-block; }
.msg { display: flex; margin: 1px 0; }
.msg.out { justify-content: flex-end; }
.msg.flash .bubble { animation: flash 1.4s; }
@keyframes flash { 0%, 60% { filter: brightness(1.5); } 100% { filter: none; } }
.bubble {
  max-width: min(65%, 560px); padding: 6px 8px 6px 9px; border-radius: 8px; position: relative; background: var(--bubble-in);
  box-shadow: 0 1px .5px rgba(11, 20, 26, .13); margin-bottom: 2px;
}
.msg.out .bubble { background: var(--bubble-out); }
.bubble.sticker { background: transparent; box-shadow: none; }
.bubble-body { display: flex; flex-direction: column; gap: 4px; min-width: 70px; }
.sender { font-size: 12.5px; font-weight: 600; }
.text { line-height: 1.4; word-wrap: break-word; overflow-wrap: anywhere; font-size: 14.2px; }
.text code { background: rgba(0,0,0,.2); padding: 1px 4px; border-radius: 4px; font-family: Consolas, monospace; }
.meta { align-self: flex-end; display: flex; gap: 4px; align-items: center; font-size: 11px; color: var(--muted); margin-top: -2px; }
.msg.out .meta { color: color-mix(in srgb, var(--text) 60%, transparent); }
.edited { font-style: italic; }
.tick { font-size: 11px; letter-spacing: -3px; margin-right: 3px; }
.tick-read { color: var(--read); }
.tick-error { color: var(--danger); letter-spacing: 0; }
.deleted { font-style: italic; color: var(--muted); }
.msg-menu-btn {
  position: absolute; top: 2px; right: 4px; border: 0; background: inherit; color: var(--muted); border-radius: 50%;
  width: 22px; height: 22px; cursor: pointer; opacity: 0; z-index: 2; font-size: 12px;
}
.bubble:hover .msg-menu-btn { opacity: 1; }
.quoted {
  background: rgba(0, 0, 0, .18); border-left: 4px solid var(--accent-2); border-radius: 6px; padding: 5px 9px; cursor: pointer; font-size: 13px;
}
[data-theme="light"] .quoted { background: rgba(0, 0, 0, .05); }
.quoted-who { color: var(--accent-2); font-weight: 600; font-size: 12.5px; }
.quoted-text { color: var(--muted); white-space: pre-wrap; max-height: 60px; overflow: hidden; }
.reactions {
  position: absolute; bottom: -14px; right: 10px; background: var(--panel-2); border-radius: 12px; padding: 1px 6px; font-size: 13px;
  box-shadow: 0 1px 3px rgba(0,0,0,.3); display: flex; gap: 3px;
}
.msg:has(.reactions) { margin-bottom: 14px; }
.reactions small { font-size: 10px; color: var(--muted); margin-left: 1px; }
.media-img { max-width: 100%; max-height: 340px; border-radius: 6px; display: block; cursor: zoom-in; object-fit: cover; min-width: 120px; }
.media-img.blur { filter: blur(3px); cursor: default; max-height: 240px; }
.sticker-img { width: 150px; height: 150px; object-fit: contain; }
.media-video { max-width: 100%; max-height: 340px; border-radius: 6px; }
.media-placeholder { position: relative; min-width: 220px; min-height: 90px; display: grid; place-items: center; background: rgba(0,0,0,.2); border-radius: 6px; overflow: hidden; }
.media-placeholder .dl-btn { position: absolute; }
.media-icon { font-size: 34px; padding: 8px; }
.media-icon.small { font-size: 22px; padding: 2px; }
.audio { display: flex; align-items: center; gap: 8px; min-width: 260px; }
.audio audio { height: 36px; flex: 1; }
.doc { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.15); padding: 9px; border-radius: 6px; min-width: 260px; }
.doc-icon { font-size: 30px; }
.doc-info { flex: 1; min-width: 0; }
.doc-name { font-weight: 500; word-break: break-all; }
.doc-actions { display: flex; flex-direction: column; gap: 4px; }
.location { display: flex; gap: 10px; align-items: center; text-decoration: none; color: var(--text); }
.location img { width: 90px; height: 90px; border-radius: 6px; object-fit: cover; }
.contact-card { display: flex; flex-direction: column; gap: 6px; min-width: 220px; }
.contact-item { display: flex; gap: 8px; align-items: center; }
.contact-item > div { flex: 1; }
.poll ul { margin: 6px 0 0; padding-left: 18px; }
.new-msgs-btn {
  position: absolute; right: 24px; bottom: 14px; border: 0; background: var(--panel-2); color: var(--accent-2); padding: 8px 14px;
  border-radius: 18px; box-shadow: var(--shadow); cursor: pointer; z-index: 5;
}



.composer { background: var(--panel-2); padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; }
.composer-bar { display: flex; align-items: flex-end; gap: 4px; }
.composer-input-wrap { flex: 1; position: relative; }
.composer-input {
  width: 100%; resize: none; border: 0; outline: none; border-radius: 10px; padding: 10px 14px; background: var(--panel-3); max-height: 180px;
  line-height: 1.35; font-size: 14.5px;
}
[data-theme="light"] .composer-input { background: #fff; }
.send-btn { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 18px; cursor: pointer; flex: none; }
.send-btn:hover { background: var(--accent-2); }
.reply-bar { display: flex; gap: 8px; align-items: center; }
.reply-bar .quoted { flex: 1; }
.offline-banner { background: rgba(245, 158, 11, .15); color: var(--warn); padding: 6px 10px; border-radius: 6px; font-size: 12.5px; }
.quick-suggest {
  position: absolute; bottom: calc(100% + 6px); left: 0; right: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); overflow: hidden; z-index: 30;
}
.quick-item { padding: 8px 12px; display: flex; gap: 10px; cursor: pointer; align-items: baseline; }
.quick-item span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick-item.active, .quick-item:hover { background: var(--hover); }
.recording-bar { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
.rec-timer { font-variant-numeric: tabular-nums; flex: 1; }
@keyframes pulse { 50% { opacity: .3; } }
.emoji-pop { display: grid !important; grid-template-columns: repeat(8, 36px); padding: 6px; }
.emoji { border: 0; background: transparent; font-size: 22px; cursor: pointer; border-radius: 6px; height: 36px; }
.emoji:hover { background: var(--hover); }
.send-previews { display: flex; flex-wrap: wrap; gap: 8px; }
.send-preview { width: 110px; text-align: center; }
.send-preview img { width: 110px; height: 90px; object-fit: cover; border-radius: 6px; }

/* ------------------------------------------------------------ CRM panel */
.crm-panel:empty { display: none; }
.crm-panel { width: 340px; flex: none; background: var(--panel); border-left: 1px solid var(--border); overflow-y: auto; }
.crm-top { padding: 18px 16px 6px; }
.crm-id { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; margin-bottom: 14px; }
.crm-name { font-size: 18px; font-weight: 600; margin-top: 6px; }
.crm-block { margin-bottom: 14px; }
.crm-label, .crm-field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.crm-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.crm-fields .crm-field:first-child { grid-column: 1 / -1; }
.tag-select { display: flex; gap: 5px; flex-wrap: wrap; }
.crm-section { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.crm-section:empty { display: none; }
.crm-section-head { display: flex; align-items: center; justify-content: space-between; }
.crm-section-head h4 { margin: 0; font-size: 14px; }
.task { display: flex; align-items: flex-start; gap: 8px; padding: 7px 8px; border-radius: 8px; background: var(--panel-2); }
.task input { margin-top: 3px; accent-color: var(--accent); }
.task-main { flex: 1; min-width: 0; cursor: pointer; }
.task-title { word-wrap: break-word; }
.task-sub { font-size: 12px; color: var(--muted); }
.task.late .task-sub { color: var(--danger); }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.note { background: var(--panel-2); border-radius: 8px; padding: 8px 10px; border-left: 3px solid var(--warn); }
.note-text { white-space: pre-wrap; word-wrap: break-word; }
.note-foot { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: var(--muted); }
.activity { display: flex; flex-direction: column; font-size: 13px; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.participants { max-height: 260px; overflow-y: auto; }
.participant { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }

/* ------------------------------------------------------------ board */
.board-head { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.board-head > .row { justify-content: flex-end; }
.board-head .search { max-width: 280px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 9px 16px; cursor: pointer; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; font-size: 15px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab.add { font-size: 18px; }
.board-cols { flex: 1; min-height: 0; display: flex; gap: 12px; overflow-x: auto; padding-bottom: 14px; }
.col {
  width: 290px; flex: none; background: var(--panel); border-radius: 12px; display: flex; flex-direction: column; min-height: 0;
  border-top: 4px solid var(--c); transition: box-shadow .1s;
}
.col.drop { box-shadow: 0 0 0 2px var(--c) inset; background: color-mix(in srgb, var(--c) 8%, var(--panel)); }
.col-head { padding: 10px 12px 6px; }
.col-title { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.col-title .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.col-title .count { margin-left: auto; font-weight: 400; color: var(--muted); background: var(--panel-2); border-radius: 10px; padding: 0 8px; font-size: 12px; }
.col-total { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.col-cards { flex: 1; overflow-y: auto; padding: 4px 8px; display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.col-add { border: 0; background: transparent; color: var(--muted); padding: 9px; cursor: pointer; border-radius: 0 0 12px 12px; }
.col-add:hover { background: var(--hover); color: var(--text); }
.card {
  background: var(--panel-2); border-radius: 10px; padding: 9px 10px; cursor: grab; display: flex; flex-direction: column; gap: 6px;
  border: 1px solid transparent;
}
.card:hover { border-color: var(--border); background: var(--panel-3); }
.card.dragging { opacity: .4; }
.card.unread { border-left: 3px solid var(--accent-2); }
.card-top { display: flex; gap: 8px; align-items: center; }
.card-name { flex: 1; min-width: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-preview { color: var(--muted); font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.money { color: #22c55e; font-weight: 600; font-size: 12.5px; }
.picker-list { max-height: 380px; overflow-y: auto; display: flex; flex-direction: column; }
.picker-item { display: flex; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.picker-item > div:last-child { min-width: 0; }
.picker-item:hover { background: var(--hover); }

/* ------------------------------------------------------------ pages */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 22px; }
.page-head .search { width: 240px; }
.table-wrap { background: var(--panel); border-radius: 12px; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--panel-2); }
.table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--hover); }
.task-groups { display: grid; gap: 18px; max-width: 820px; }
.task-group { display: flex; flex-direction: column; gap: 6px; }
.task-group h3 { margin: 0 0 4px; font-size: 15px; color: var(--muted); }
.task-group .task { background: var(--panel); padding: 10px 12px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border-radius: 12px; padding: 16px; }
.stat.clickable { cursor: pointer; }
.stat.clickable:hover { background: var(--panel-2); }
.stat-value { font-size: clamp(19px, 2vw, 28px); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-label { color: var(--muted); }
.panel { background: var(--panel); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 10px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.panel-head h3 { margin: 0; font-size: 16px; }
.funnel-row { display: grid; grid-template-columns: 170px 1fr 150px; align-items: center; gap: 12px; }
.funnel-bar { background: var(--panel-2); height: 14px; border-radius: 7px; overflow: hidden; }
.funnel-bar > div { height: 100%; border-radius: 7px; min-width: 2px; }
.funnel-n { text-align: right; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; align-items: start; }
.settings-grid .panel { margin: 0; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 6px 0; cursor: pointer; }
.switch { appearance: none; width: 40px; height: 22px; border-radius: 11px; background: var(--panel-3); position: relative; cursor: pointer; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { left: 21px; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.stage-dots { display: flex; gap: 3px; flex: 1; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot.big { width: 14px; height: 14px; }
.conn-info { display: flex; gap: 12px; align-items: center; }
.legacy { background: var(--panel-2); border-radius: 8px; padding: 10px 12px; }
.legacy p { margin: 0 0 8px; }
.palette { display: flex; gap: 4px; flex-wrap: wrap; }
.swatch { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch.on { border-color: var(--text); }
.stage-editor { display: flex; flex-direction: column; gap: 6px; }
.stage-edit-row { display: flex; align-items: center; gap: 8px; }
.stage-edit-row .palette { flex: none; max-width: 190px; }
.icon-input { width: 64px; text-align: center; font-size: 18px; }

/* ------------------------------------------------------------ modais */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); display: grid; place-items: center; z-index: 100; }
.modal { background: var(--panel); border-radius: 14px; width: min(480px, 92vw); max-height: 88vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal-wide { width: min(760px, 94vw); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 6px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 8px 18px; overflow-y: auto; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px 16px; }
.modal-actions .btn-danger { margin-right: auto; }
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12.5px; color: var(--muted); }

.popup-menu {
  position: fixed; z-index: 200; background: var(--panel); border-radius: 10px; box-shadow: var(--shadow); padding: 6px 0; min-width: 190px;
  max-height: 70vh; overflow-y: auto; border: 1px solid var(--border);
}
.popup-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; text-align: left; padding: 8px 16px; cursor: pointer; white-space: pre; }
.popup-item:hover:not(:disabled) { background: var(--hover); }
.popup-item.active { color: var(--accent-2); font-weight: 600; }
.popup-item.danger { color: var(--danger); }
.popup-item.popup-header { color: var(--muted); font-size: 12px; cursor: default; padding-top: 10px; text-transform: uppercase; }
.popup-icon { width: 18px; text-align: center; }
.popup-sep { height: 1px; background: var(--border); margin: 5px 0; }

#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 300; align-items: center; }
.toast { background: var(--panel-3); color: var(--text); padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow); max-width: 560px; transition: opacity .3s; }
.toast-error { background: #7f1d1d; color: #fff; }
.toast-success { background: #065f46; color: #fff; }
.toast.out { opacity: 0; }

.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px; color: var(--muted); gap: 6px; }
.empty-icon { font-size: 56px; }
.empty h3 { margin: 6px 0 0; color: var(--text); font-size: 22px; font-weight: 400; }
.empty p { max-width: 420px; }

/* ------------------------------------------------------------ conexão */
.connect-overlay { position: absolute; inset: 0; background: var(--bg); z-index: 50; display: grid; place-items: center; }
#app > .connect-overlay { left: 72px; }
.connect-card {
  background: var(--panel); border-radius: 16px; padding: 40px 48px; display: flex; gap: 48px; align-items: center; max-width: 960px; margin: 20px;
  box-shadow: var(--shadow);
}
.connect-text h1 { font-weight: 300; font-size: 28px; margin: 0 0 18px; }
.connect-text ol { padding-left: 20px; line-height: 2.1; font-size: 15.5px; }
.connect-qr { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.qr { width: 264px; height: 264px; background: #fff; border-radius: 10px; padding: 8px; }
.qr-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.alert { background: rgba(239, 68, 68, .14); color: #fca5a5; padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; }
[data-theme="light"] .alert { color: #b91c1c; }
.alert.info { background: rgba(83, 189, 235, .14); color: var(--link); }
.banner-wrap { flex: none; }
.banner { display: flex; align-items: center; gap: 10px; padding: 7px 16px; font-size: 13px; }
.banner.warn { background: rgba(245, 158, 11, .16); color: var(--warn); }
.banner.info { background: rgba(83, 189, 235, .14); color: var(--link); }
.spinner { width: 34px; height: 34px; border: 3px solid var(--panel-3); border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; }
.spinner.small { width: 14px; height: 14px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.fatal { color: var(--danger); padding: 20px; }

@media (max-width: 1280px) {
  .crm-panel { width: 300px; }
  .chatlist { width: 330px; }
}
@media (max-width: 1100px) {
  .crm-panel:not(.hidden) { position: absolute; right: 0; top: 0; bottom: 0; z-index: 40; box-shadow: var(--shadow); }
  .rail-label { display: none; }
}

.connect-tabs { margin-bottom: 14px; }
.connect-error:empty { display: none; }
.pairing { width: 280px; display: flex; flex-direction: column; gap: 10px; }
.pairing-code {
  font-size: 34px; font-weight: 700; letter-spacing: 4px; text-align: center; padding: 18px 10px; border-radius: 12px;
  background: var(--panel-2); font-family: Consolas, monospace; user-select: text;
}

.diag { display: flex; flex-direction: column; gap: 10px; min-width: 380px; }
.diag-step { padding: 8px 10px; border-radius: 8px; background: var(--panel-2); border-left: 4px solid var(--muted); }
.diag-step.ok { border-left-color: #22c55e; }
.diag-step.bad { border-left-color: var(--danger); }

/* tipos de contato e filtros */
.chip-count { margin-left: 6px; background: var(--accent-2); color: #111b21; border-radius: 9px; padding: 0 6px; font-size: 11px; font-weight: 600; }
.chip-edit { font-weight: 600; }
.type-icon { font-size: 13px; }
.waiting { font-size: 11.5px; color: var(--warn); }
.waiting.late { color: var(--danger); font-weight: 600; }
.classify-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 16px; font-size: 13px;
  background: color-mix(in srgb, var(--warn) 12%, var(--panel-2)); border-left: 1px solid var(--border);
}
.classify-bar > span { color: var(--muted); margin-right: 4px; }

/* casos */
.mono { font-family: Consolas, "Cascadia Mono", monospace; letter-spacing: .2px; }
.bad-text { color: var(--danger); font-weight: 600; }
.case-card {
  background: var(--panel-2); border-radius: 8px; padding: 8px 10px; cursor: pointer; border-left: 4px solid var(--c, var(--muted));
  display: flex; flex-direction: column; gap: 3px;
}
.case-card:hover { background: var(--panel-3); }
.case-card.closed { opacity: .6; }
.case-card-title { font-weight: 600; }
.case-card-foot { display: flex; gap: 10px; flex-wrap: wrap; }
.closed-cases summary { cursor: pointer; padding: 4px 0; }
.closed-cases .case-card { margin-top: 6px; }
.modal-case { width: min(1180px, 96vw); height: 92vh; max-height: 92vh; }
.modal-case .modal-body { flex: 1; }
.case { display: flex; flex-direction: column; gap: 12px; }
.case-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.case-client { display: flex; align-items: center; gap: 10px; cursor: pointer; flex: 1; min-width: 200px; }
.case-client:hover b { text-decoration: underline; }
.case-return { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; padding: 8px 12px; border-radius: 8px; background: var(--panel-2); }
.case-return.late { background: rgba(239, 68, 68, .12); color: var(--danger); }
.case-content { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.case-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.case-grid .wide { grid-column: 1 / -1; }
.fee-types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fee-type { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; border: 2px solid var(--border); cursor: pointer; }
.fee-type.on { border-color: var(--accent); background: rgba(0, 168, 132, .08); }
.fee-type input { margin-top: 3px; accent-color: var(--accent); }
.fee-summary { display: flex; gap: 22px; align-items: flex-end; flex-wrap: wrap; padding: 12px 14px; background: var(--panel-2); border-radius: 10px; }
.fee-summary b { font-size: 18px; }
.progress { flex: 1; min-width: 140px; height: 10px; background: var(--panel-3); border-radius: 5px; overflow: hidden; align-self: center; }
.progress > div { height: 100%; background: #22c55e; }
.status-pill { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status-pill.ok { background: rgba(34, 197, 94, .18); color: #16a34a; }
.status-pill.bad { background: rgba(239, 68, 68, .16); color: var(--danger); }
.status-pill.warn { background: rgba(245, 158, 11, .18); color: #d97706; }
.status-pill.muted { background: var(--panel-3); color: var(--muted); }
.table.compact td, .table.compact th { padding: 6px 8px; }
.table td.num { text-align: right; white-space: nowrap; }
.table td.actions { white-space: nowrap; text-align: right; }
.table td.actions .btn { margin-left: 4px; }
.table tr.pay-overdue td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.btn-ok { background: rgba(34, 197, 94, .15); border-color: rgba(34, 197, 94, .5); }
.btn-ok:hover { background: rgba(34, 197, 94, .3); }
.doc-list { display: flex; flex-direction: column; gap: 6px; }
.doc-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--panel-2); border-radius: 8px; }
.doc-row .doc-icon { font-size: 22px; }
.task-list { display: flex; flex-direction: column; gap: 6px; }
.card-case { font-size: 12.5px; font-weight: 600; color: var(--accent-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-theme="light"] .card-case { color: var(--accent); }
.card.closed { opacity: .55; }
.stat-bad .stat-value { color: var(--danger); }
.stat-ok .stat-value { color: #22c55e; }
.finance-bar { margin-bottom: 12px; }
.picker-list.short { max-height: 200px; border: 1px solid var(--border); border-radius: 8px; }
.picker-item.active { background: rgba(0, 168, 132, .16); }
.fee-late { font-size: 11.5px; color: var(--danger); font-weight: 600; }
.table td.actions > * { display: inline-flex; vertical-align: middle; }

/* agenda */
.view-agenda.active { display: flex; }
.agenda { display: flex; flex: 1; min-height: 0; }
.agenda-side { width: 250px; flex: none; padding: 14px; display: flex; flex-direction: column; gap: 14px; border-right: 1px solid var(--border); background: var(--panel); overflow-y: auto; }
.btn.wide { width: 100%; }
.gcard { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 10px; background: var(--panel-2); border-left: 4px solid var(--muted); }
.gcard.ok { border-left-color: #22c55e; }
.gcard.bad { border-left-color: var(--danger); background: rgba(239, 68, 68, .1); }
.gcard p { margin: 0; }
.gcard .field.small > span { font-size: 11.5px; }
.cal-legend { display: flex; flex-direction: column; gap: 6px; }
.cal-item { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; min-width: 0; }
.cal-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.cal-kinds { margin-top: 6px; line-height: 1.6; }
.agenda-body { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--panel); }
.agenda-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.agenda-title { margin: 0 0 0 6px; font-size: 18px; font-weight: 500; }
.segmented { display: inline-flex; background: var(--panel-2); border-radius: 8px; padding: 2px; gap: 2px; }
.segmented.wrap { flex-wrap: wrap; }
.seg { border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.seg.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.2); font-weight: 600; }
.seg:disabled { opacity: .4; cursor: default; }
.agenda-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tg { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.tg-head, .tg-allday, .tg-body { display: grid; }
.tg-head { border-bottom: 1px solid var(--border); padding-right: 8px; }
.tg-day { text-align: center; padding: 6px 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; }
.tg-day span { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.tg-day b { font-size: 20px; font-weight: 500; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; }
.tg-day.today b { background: var(--accent); color: #fff; }
.tg-allday { border-bottom: 1px solid var(--border); padding-right: 8px; min-height: 26px; }
.tg-allday > div:first-child { display: flex; align-items: center; justify-content: flex-end; padding-right: 6px; }
.tg-allday-cell { border-left: 1px solid var(--border); padding: 2px; display: flex; flex-direction: column; gap: 2px; }
.tg-scroll { flex: 1; overflow-y: auto; }
.tg-body { position: relative; }
.tg-hours .tg-hour { height: 48px; font-size: 11px; color: var(--muted); text-align: right; padding-right: 6px; transform: translateY(-7px); }
.tg-col { position: relative; border-left: 1px solid var(--border); height: calc(48px * 24);
  background-image: repeating-linear-gradient(to bottom, var(--border) 0 1px, transparent 1px 48px); cursor: cell; }
.tg-col.today { background-color: color-mix(in srgb, var(--accent) 5%, transparent); }
.tg-event {
  position: absolute; border-radius: 6px; padding: 3px 6px; font-size: 12px; overflow: hidden; cursor: pointer; z-index: 1;
  background: color-mix(in srgb, var(--c) 28%, var(--panel)); border-left: 3px solid var(--c); color: var(--text); line-height: 1.25;
}
.tg-event:hover { filter: brightness(1.08); z-index: 2; box-shadow: var(--shadow); }
.tg-event b { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-event.crm { border-style: dashed; }
.tg-event.done, .ev-chip.done { opacity: .55; text-decoration: line-through; }
.tg-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 3; }
.tg-now::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.ev-chip {
  font-size: 11.5px; padding: 1px 6px; border-radius: 4px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: color-mix(in srgb, var(--c) 28%, var(--panel)); border-left: 3px solid var(--c);
}
.mo { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.mo-head { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--border); }
.mo-head div { text-align: center; font-size: 11px; color: var(--muted); text-transform: uppercase; padding: 6px 0; }
.mo-grid { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: repeat(6, 1fr); min-height: 0; }
.mo-cell { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 3px; display: flex; flex-direction: column; gap: 2px; overflow: hidden; min-height: 0; }
.mo-cell.other { background: var(--panel-2); opacity: .7; }
.mo-date { font-size: 12px; align-self: center; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; cursor: pointer; }
.mo-cell.today .mo-date { background: var(--accent); color: #fff; font-weight: 600; }
.mo-more { font-size: 11px; color: var(--muted); cursor: pointer; padding-left: 4px; }

/* modo discreto: embaça valores e prévias; passar o mouse mostra */
body.discreet .chat-preview,
body.discreet .card-preview,
body.discreet .search-hit .chat-preview,
body.discreet .money,
body.discreet .money-total,
body.discreet .fee-late,
body.discreet .fee-summary b,
body.discreet .view-page:not(.view-today) .stat-value,
body.discreet .col-total,
body.discreet .table td.num,
body.discreet .case-card-foot,
body.discreet .card-foot .bad-text,
body.discreet .funnel-n,
body.discreet .panel-head .money,
body.discreet .crm-field input[type="number"],
body.discreet .case-grid input[type="number"],
body.discreet-msgs .bubble-body,
body.discreet-msgs .reply-bar .quoted {
  filter: blur(6px);
  transition: filter .15s;
}
body.discreet .chat-row:hover .chat-preview,
body.discreet .card:hover .card-preview,
body.discreet .money:hover,
body.discreet .money-total:hover,
body.discreet .fee-late:hover,
body.discreet .fee-summary b:hover,
body.discreet .view-page .stat:hover .stat-value,
body.discreet .col-head:hover .col-total,
body.discreet .table tr:hover td.num,
body.discreet .case-card:hover .case-card-foot,
body.discreet .card:hover .card-foot .bad-text,
body.discreet .funnel-row:hover .funnel-n,
body.discreet .panel-head:hover .money,
body.discreet .crm-field input[type="number"]:hover,
body.discreet .crm-field input[type="number"]:focus,
body.discreet .case-grid input[type="number"]:hover,
body.discreet .case-grid input[type="number"]:focus,
body.discreet-msgs .bubble:hover .bubble-body,
body.discreet-msgs .reply-bar .quoted:hover {
  filter: none;
}
.rail-btn.on { background: rgba(0, 168, 132, .18); color: var(--accent-2); }
.rail-btn.on .rail-icon { filter: drop-shadow(0 0 4px var(--accent)); }

/* visualizador de imagens (tela cheia, acima da janela e abaixo das caixas de diálogo) */
.iv-overlay { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, .9); display: flex; flex-direction: column; user-select: none; }
.iv-stage { flex: 1; position: relative; overflow: hidden; display: grid; place-items: center; cursor: zoom-in; touch-action: none; }
.iv-stage.zoomed { cursor: grab; }
.iv-stage.zoomed:active { cursor: grabbing; }
.iv-img { max-width: 94vw; max-height: calc(100vh - 80px); transform-origin: center center; transition: transform .08s ease-out; will-change: transform; }
.iv-bar { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px; background: rgba(0, 0, 0, .6); color: #fff; flex-wrap: wrap; }
.iv-extra { display: flex; gap: 6px; margin: 0 10px; padding: 0 10px; border-left: 1px solid rgba(255, 255, 255, .2); border-right: 1px solid rgba(255, 255, 255, .2); }
.iv-btn { background: rgba(255, 255, 255, .12); color: #fff; border: 0; border-radius: 8px; min-width: 36px; height: 34px; padding: 0 10px; font-size: 17px; cursor: pointer; }
.iv-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .25); }
.iv-btn:disabled { opacity: .3; cursor: default; }
.iv-zoom { min-width: 52px; text-align: center; font-variant-numeric: tabular-nums; font-size: 13px; }
.iv-counter { font-size: 13px; opacity: .8; margin-right: 8px; }
.iv-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 64px; font-size: 34px; z-index: 1; }
.iv-prev { left: 12px; }
.iv-next { right: 12px; }

/* ------------------------------------------------------------ login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100%; padding: 24px 16px; background: var(--bg); box-sizing: border-box; }
body.login-body { overflow-y: auto; }
.login-switch { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 13px; padding: 4px; align-self: center; }

.login-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 28px 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.login-logo { display: block; width: 100%; max-width: 300px; margin: 0 auto 4px; border-radius: 10px; background: #fff; padding: 10px 14px; }
.login-card h1 { font-size: 20px; margin: 0; text-align: center; }
.login-card p { margin: 0; text-align: center; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.login-card .input { height: 44px; font-size: 16px; }
.login-card .btn { height: 46px; font-size: 16px; justify-content: center; }
.login-error { color: var(--danger); min-height: 20px; text-align: center; font-size: 14px; }
.team-presence { font-size: 12px; color: var(--accent-2); padding-top: 2px; }
.login-card label.toggle-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.login-card label.toggle-row input[type=radio] { width: 20px; height: 20px; flex: none; }

/* sugestão de palavras ao digitar */
.word-suggest { position: absolute; bottom: calc(100% + 4px); left: 6px; display: flex; gap: 6px; align-items: center; z-index: 25; }
.word-chip { border: 1px solid var(--border); background: var(--panel); color: var(--text); border-radius: 14px; padding: 3px 12px; font-size: 13.5px; cursor: pointer; box-shadow: var(--shadow); }
.word-chip.first { border-color: var(--accent, #00a884); font-weight: 600; }
.word-chip:hover { background: var(--panel-3); }
.word-hint { font-size: 11px; opacity: .6; }
.word-fixed { border: 1px solid var(--border); background: var(--panel); border-radius: 14px; padding: 3px 12px; font-size: 13px; box-shadow: var(--shadow); color: var(--accent); }

/* ---------- Hoje (Meu dia / Minha semana) ---------- */
.view-today { max-width: 1280px; }
.stat.clickable { cursor: pointer; }
.stat.clickable:hover { outline: 1px solid var(--accent); }
.stat-warn .stat-value { color: #f59e0b; }
.today-alert { background: color-mix(in srgb, var(--danger) 14%, var(--panel)); border-left: 4px solid var(--danger); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-weight: 500; }
.today-alert.ok { background: color-mix(in srgb, #22c55e 12%, var(--panel)); border-left-color: #22c55e; }
.today-grid { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(0, 2fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .today-grid { grid-template-columns: 1fr; } }
.today-title { margin: 0 0 10px; font-size: 16px; }
.today-group .task-row { margin: 0; }
.agenda-row { display: flex; gap: 10px; align-items: stretch; padding: 8px 6px; border-radius: 8px; cursor: pointer; }
.agenda-row:hover { background: var(--panel-2); }
.agenda-row.done { opacity: .55; }
.agenda-row.done .agenda-title { text-decoration: line-through; }
.agenda-time { width: 62px; flex-shrink: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.agenda-bar { width: 4px; border-radius: 2px; background: var(--c); flex-shrink: 0; }
.agenda-title { font-weight: 500; }
.kind-tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--panel-2); margin-bottom: 2px; }
.kind-prazo { background: color-mix(in srgb, var(--danger) 20%, var(--panel)); }
.kind-audiencia { background: color-mix(in srgb, var(--accent) 25%, var(--panel)); }
.action-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-top: 1px solid var(--border); }
.action-row:first-of-type { border-top: 0; }
.action-main { min-width: 0; cursor: pointer; }
.action-who { font-weight: 600; }
.action-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 13px; }
.bad-text { color: var(--danger); }
.today-week-sum { margin-bottom: 12px; }
.week-cols { display: grid; grid-template-columns: repeat(var(--n), minmax(140px, 1fr)); gap: 10px; overflow-x: auto; }
.week-col { background: var(--panel); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 180px; }
.week-col.today { outline: 2px solid var(--accent); }
.week-col.past { opacity: .7; }
.week-head { display: flex; flex-direction: column; text-transform: capitalize; }
.week-ev { background: var(--panel-2); border-left: 3px solid var(--c); border-radius: 6px; padding: 6px 8px; cursor: pointer; }
.week-ev.done { opacity: .5; }
.week-ev-title { font-size: 13px; font-weight: 500; }
.week-empty { text-align: center; margin-top: 12px; }
.day-close { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--panel); border-radius: 12px; padding: 14px 18px; margin-top: 16px; }

/* tela de entrada em janelas baixas (notebook com zoom do Windows) */
@media (max-height: 820px) {
  .login-page { align-items: flex-start; padding: 12px 16px; }
  .login-card { padding: 18px 22px; gap: 9px; }
  .login-logo { max-width: 220px; padding: 6px 10px; }
  .login-card .input { height: 38px; }
  .login-card .btn { height: 40px; }
  .login-error { min-height: 0; }
}
/* ---------- Documentos (OneDrive) ---------- */
.docs-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; min-width: 0; }
.crumb { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 2px 4px; border-radius: 4px; font-weight: 500; }
.crumb:hover { background: var(--panel-2); }
.doc-main { min-width: 0; cursor: default; }
.doc-row .doc-main[onclick], .doc-row:has(.btn:only-of-type) .doc-main { cursor: pointer; }
.docs-empty { background: var(--panel-2); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.docs-empty p { margin: 0; }
.folder-preview { background: var(--panel); border: 1px dashed var(--border); border-radius: 8px; padding: 6px 10px; word-break: break-all; }
.case-folder { margin-bottom: 6px; }
.tpl-list { max-height: 55vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.tpl-area { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 4px 0; }
.tpl-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 1px solid var(--border); background: var(--panel); color: var(--text); border-radius: 8px; padding: 8px 10px; cursor: pointer; margin-bottom: 4px; }
.tpl-item:hover { border-color: var(--accent); }
.docs-search { flex: 1; height: 44px; font-size: 15px; }
.docs-results { margin-top: 12px; display: flex; flex-direction: column; gap: 4px; }
.docs-hint { padding: 8px 2px; }
.search-hit { background: var(--panel); border-radius: 10px; padding: 10px 12px; }
.snippet { color: var(--muted); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
mark { background: color-mix(in srgb, #f59e0b 35%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
.placeholder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 14px; }
.placeholder-grid code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
.crm-docdata summary { cursor: pointer; list-style: none; }
.crm-docdata summary::before { content: '▸ '; }
.crm-docdata[open] summary::before { content: '▾ '; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.doc-list { display: flex; flex-direction: column; gap: 2px; }
.doc-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; }
.doc-row:hover { background: var(--panel-2); }
.doc-row .doc-icon { font-size: 22px; flex: none; }
.doc-row .btn { flex: none; }
.crumb { text-align: left; }

/* WhatsApp é um módulo: QR e faixa de conexão só aparecem no Atendimento */
body:not([data-view="inbox"]) .connect-overlay,
body:not([data-view="inbox"]) .banner-wrap { display: none !important; }

/* ---------- Jurídico (clientes, processos) ---------- */
.legal-tools { margin-bottom: 12px; gap: 8px; }
.legal-search { flex: 1; height: 42px; font-size: 15px; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--panel-2); }
.back-btn { margin-bottom: 10px; }
.client-head { flex-direction: row; align-items: center; gap: 16px; }
.client-head h2 { margin: 0; font-size: 22px; }
.client-avatar { background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 21px; border-radius: 50%; flex: none; }
.client-body { margin-top: 12px; }
.client-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.client-form .field.wide { grid-column: 1 / -1; }
.case-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.case-cards .case-card { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.activity-row { padding: 4px 0; border-top: 1px solid var(--border); }
.case-wa { color: var(--accent); }

/* ---------- Ficha do processo: fluxo, documentos, andamentos ---------- */
.case-next, .case-resp { display: flex; flex-direction: column; line-height: 1.2; padding: 4px 10px; border-left: 1px solid var(--border); }
.case-next { cursor: pointer; }
.case-next b { color: var(--accent); }
.flow-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 900px) { .flow-wrap { grid-template-columns: 1fr; } }
.flow-wrap .panel { margin: 0; }
.flow { display: flex; flex-direction: column; gap: 2px; }
.flow-step { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; }
.flow-step.next { background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.flow-step.done b, .flow-step.na b { color: var(--muted); font-weight: 500; }
.flow-icon { font-size: 18px; width: 24px; text-align: center; }
.check-row { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-top: 1px solid var(--border); font-size: 14px; }
.check-row.recebido span.grow { color: var(--muted); text-decoration: line-through; }
.timeline { display: flex; flex-direction: column; gap: 0; border-left: 2px solid var(--border); margin-left: 8px; }
.tl-item { display: flex; gap: 12px; padding: 8px 10px; position: relative; }
.tl-item::before { content: ''; position: absolute; left: -7px; top: 14px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.tl-item.src-datajud::before, .tl-item.src-djen::before { background: #f59e0b; }
.tl-date { width: 86px; flex: none; font-weight: 600; font-variant-numeric: tabular-nums; }
.tl-text { white-space: pre-wrap; }
.parties { margin: 6px 0 0; }

/* ---------- Intimações ---------- */
.oab-list { display: flex; flex-direction: column; gap: 4px; }
.oab-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-top: 1px solid var(--border); }
.oab-row.off { opacity: .55; }
.intim-tools { margin: 4px 0 12px; align-items: center; }
.intim-list { display: flex; flex-direction: column; gap: 10px; }
.intim { margin: 0; gap: 6px; border-left: 4px solid var(--border); }
.intim-nova { border-left-color: #f59e0b; }
.intim-prazo { border-left-color: #22c55e; }
.intim-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.intim-date { font-weight: 700; font-variant-numeric: tabular-nums; }
.intim-text { white-space: pre-wrap; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.intim-text.open { display: block; -webkit-line-clamp: unset; max-height: 40vh; overflow-y: auto; background: var(--panel-2); padding: 8px 10px; border-radius: 8px; }
.unknown-procs summary { cursor: pointer; }
.unknown-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-top: 1px solid var(--border); }
.datajud-row { align-items: center; }

/* ---------- Gráficos (paleta validada para os dois temas) ---------- */
:root, [data-theme="dark"] { --viz-1: #3987e5; --viz-2: #d95926; }
[data-theme="light"] { --viz-1: #2a78d6; --viz-2: #eb6834; }
.viz { position: relative; }
.viz-toggle { position: absolute; right: 0; top: -30px; }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 2px 4px; text-decoration: underline; }
.viz-plot { position: relative; width: 100%; min-height: 240px; }
.viz-svg { display: block; }
.viz-grid { stroke: var(--border); stroke-width: 1; }
.viz-base { stroke: var(--muted); stroke-width: 1; opacity: .5; }
.viz-axis { fill: var(--muted); font-size: 11px; }
.viz-mark { transition: opacity .1s; }
.viz-plot:has(.viz-mark.hover) .viz-mark:not(.hover) { opacity: .45; }
.viz-hit { cursor: default; outline: none; }
.viz-hit:focus-visible { stroke: var(--accent); stroke-width: 1; }
.viz-tip { position: absolute; pointer-events: none; opacity: 0; background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow);
  border-radius: 8px; padding: 6px 10px; font-size: 12.5px; z-index: 5; min-width: 130px; transition: opacity .08s; }
.viz-tip.on { opacity: 1; }
.viz-tip-title { color: var(--muted); margin-bottom: 2px; }
.viz-tip-row { display: flex; align-items: center; gap: 6px; }
.viz-key { width: 10px; height: 2px; border-radius: 1px; flex: none; }
.viz-legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.viz-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.viz-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.viz-bars { display: flex; flex-direction: column; gap: 6px; }
.viz-bar-row { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; align-items: center; gap: 8px; font-size: 13px; outline: none; }
.viz-bar-row:hover .viz-bar, .viz-bar-row:focus-visible .viz-bar { filter: brightness(1.12); }
.viz-bar-label { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viz-bar-track { height: 14px; display: block; }
.viz-bar { display: block; height: 14px; border-radius: 0 4px 4px 0; min-width: 2px; }
.viz-bar-value { font-variant-numeric: tabular-nums; font-size: 12.5px; }

/* ---------- Financeiro: painel ---------- */
.fin-alerts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.fin-alert { text-align: left; border: 0; border-left: 4px solid var(--warn); background: color-mix(in srgb, var(--warn) 12%, var(--panel)); color: var(--text);
  border-radius: 8px; padding: 9px 12px; cursor: pointer; font-size: 14px; }
.fin-alert.bad { border-left-color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--panel)); }
.fin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.fin-grid .panel { margin: 0; }
.fin-wide { grid-column: 1 / -1; }
@media (max-width: 900px) { .fin-grid { grid-template-columns: 1fr; } }
.fin-line { display: flex; align-items: center; gap: 6px; padding: 5px 0; border-top: 1px solid var(--border); font-size: 13.5px; }
.fin-line:first-of-type { border-top: 0; }
.fin-dir { font-weight: 700; width: 16px; text-align: center; }
.fin-dir.in { color: #16a34a; }
.fin-dir.out { color: var(--danger); }
.cash-month { margin: 0 8px; text-transform: capitalize; min-width: 180px; text-align: center; }
.receipt-frame { width: 100%; height: 62vh; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.case-costs { margin-top: 14px; }
body.discreet .viz-axis, body.discreet .viz-tip b, body.discreet .viz-bar-value, body.discreet .fin-line b { filter: blur(6px); }
.money.plain { color: inherit; font-size: inherit; font-weight: inherit; }
.finance-body .stat-value { font-size: clamp(17px, 1.55vw, 24px); overflow: visible; text-overflow: clip; }


/* =================================================================
   Visual 2026 — interface moderna: cartões leves com borda, ícones de
   traço, tipografia mais firme, foco visível e menos cor decorativa.
   (fica no fim do arquivo para valer sobre as regras antigas)
   ================================================================= */
.ico { display: inline-block; vertical-align: -3px; flex: none; }
h2, h3 { letter-spacing: -0.01em; }
.page-head h2 { font-size: 24px; font-weight: 650; }
.view-page.active { padding: 26px 32px 40px; }

/* menu lateral */
.rail { width: 78px; background: var(--panel); border-right: 1px solid var(--border); gap: 2px; padding: 14px 0; }
.rail-logo { width: 40px; height: 40px; margin-bottom: 14px; border-radius: 10px; }
.rail-btn { width: 66px; padding: 8px 0 6px; border-radius: 10px; gap: 4px; color: var(--muted); }
.rail-btn:hover { background: var(--hover); color: var(--text); }
.rail-btn.active { background: var(--accent-soft); color: var(--accent); }
[data-theme="dark"] .rail-btn.active, :root:not([data-theme="light"]) .rail-btn.active { color: var(--accent-2); }
.rail-btn.active::before { display: none; }
.rail-btn.on { color: var(--accent); }
.rail-icon { font-size: 0; line-height: 0; }
.rail-label { font-size: 11px; font-weight: 500; letter-spacing: .01em; }
.nav-badge { top: 3px; right: 10px; background: var(--danger); box-shadow: 0 0 0 2px var(--panel); }

/* cartões */
.panel, .stat { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--card-shadow); }
.panel { padding: 18px 20px; }
.panel-head h3 { font-size: 15px; font-weight: 600; }
.stats { gap: 14px; }
.stat { padding: 16px 18px; }
.stat-value { font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat.clickable:hover { outline: none; border-color: var(--accent); }

/* botões e campos */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px; background: var(--panel);
  border: 1px solid var(--border); font-weight: 500; box-shadow: var(--card-shadow); }
.btn:hover { background: var(--panel-2); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-ok { color: var(--ok); }
.btn:focus-visible, .icon-btn:focus-visible, .seg:focus-visible, .chip:focus-visible, .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-btn { border-radius: 8px; }
.icon-btn .ico { width: 18px; height: 18px; }
.icon-btn.small .ico { width: 16px; height: 16px; }
.input, [data-theme="light"] .input { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; }
.input:focus, [data-theme="light"] .input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.segmented { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.seg { border-radius: 7px; font-weight: 500; padding: 6px 12px; }
.seg.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(16, 24, 40, .12); }
.chip { background: var(--panel); border: 1px solid var(--border); color: var(--muted); font-weight: 500; }
.chip.active, [data-theme="light"] .chip.active { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.tabs { gap: 2px; }
.tab { font-weight: 500; font-size: 14px; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* tabelas */
.table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: transparent; }
.table td, .table th { border-bottom: 1px solid var(--border); }
.table tbody tr:hover td { background: var(--hover); }
.table-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: var(--card-shadow); }
.status-pill { font-weight: 600; letter-spacing: .01em; }

/* janelas */
.modal { border: 1px solid var(--border); border-radius: 14px; }
.modal-head h3 { font-size: 16px; font-weight: 600; }
.toast { border-radius: 10px; }

/* listas e linhas */
.action-row, .fin-line, .check-row, .oab-row, .unknown-row { border-top-color: var(--border); }
.case-card { border-radius: 10px; }
.doc-row .ico-folder { color: var(--accent); }
.doc-row .ico-pdf { color: #d92d20; }
.doc-row .ico-doc { color: #2f6fd6; }
.doc-row .ico-sheet { color: #16a34a; }
.doc-row .ico-slides { color: #dc6803; }
.flow-icon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--panel-2); color: var(--muted); }
.flow-step.done .flow-icon { background: rgba(34, 197, 94, .14); color: var(--ok); }
.flow-step.next .flow-icon { background: var(--accent-soft); color: var(--accent); }
.fin-alert .ico, .today-alert .ico { vertical-align: -3px; margin-right: 6px; }
.today-alert { border-radius: 10px; }
.empty-icon { font-size: 0; width: 64px; height: 64px; border-radius: 16px; background: var(--panel-2); display: grid; place-items: center; color: var(--muted); margin-bottom: 4px; }
.empty-icon .ico { width: 28px; height: 28px; }
.empty h3 { font-size: 18px; font-weight: 600; }

/* ícones de traço nos itens do cadastro (funis, tipos, filtros) e no texto */
.ico.inline { vertical-align: -2px; margin-right: 4px; flex: none; }
.with-ico, .stage-btn, .stage-pill, .tag-chip, .chip, .board-head .tab, .classify-bar .btn, .type-icon { display: inline-flex; align-items: center; gap: 5px; }
.popup-icon { display: inline-flex; align-items: center; justify-content: center; width: 18px; }
.popup-header .popup-icon { color: var(--muted); }
.icon-picker { display: flex; flex-wrap: wrap; gap: 4px; max-width: 100%; }
.icon-pick { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text-2, var(--muted)); cursor: pointer; padding: 0; }
.icon-pick:hover { border-color: var(--accent); color: var(--text); }
.icon-pick.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.media-icon .ico, .doc-icon .ico { color: var(--muted); }
.team-presence, .chat-name, .wait-flag, .fee-late, .task-flag { display: inline-flex; align-items: center; gap: 3px; }

/* ---------------------------------------------------------- Comercial */
.view-commercial.active { display: flex; flex-direction: column; padding: 16px 20px 0; min-height: 0; }
.view-commercial .page-head { margin-bottom: 10px; }
.view-commercial .comm-stats { margin-bottom: 10px; }
.view-commercial .legal-tools { margin-bottom: 10px; }
.comm-body { flex: 1; min-height: 0; overflow: auto; padding-bottom: 16px; }
.comm-body.board-cols { overflow-x: auto; overflow-y: hidden; }
.comm-body.board-cols .col { min-width: 250px; }
.atend-switch { margin-left: 4px; }
.chatlist-head .atend-switch { margin: 2px 0 8px; align-self: flex-start; }
.lead-card .card-name { flex: 1; }
.lead-sheet { display: flex; flex-direction: column; gap: 12px; }
.lead-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lead-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; }
@media (max-width: 760px) { .lead-cols { grid-template-columns: 1fr; } }
.lead-dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; font-size: 13.5px; }
.lead-dl dt { color: var(--muted); }
.lead-dl dd { margin: 0; }
.lead-desc { white-space: pre-wrap; margin: 10px 0 0; font-size: 13.5px; }
.lead-foot { align-items: center; gap: 8px; }
.att-list { display: flex; flex-direction: column; gap: 2px; max-height: 420px; overflow: auto; }
.att-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.att-item:last-child { border-bottom: 0; }
.att-ico { flex: none; width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); }
.att-summary { white-space: pre-wrap; margin: 2px 0; }
.lead-link:empty { display: none; }
.lead-link { margin-bottom: 8px; }
.lead-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; background: var(--accent-soft); color: var(--text); }
.lead-chip > .ico { color: var(--accent); }
.lead-chip:hover { border-color: var(--accent); }
.btn.wide { width: 100%; justify-content: center; }

/* ---------------------------------------------------------- Relatórios */
.report-period { margin-top: 2px; }
.report-body > .panel { margin-bottom: 14px; }
.report-body .fin-grid { margin-top: 14px; }
.table-wrap { overflow-x: auto; }
.print-only { display: none; }
@media print {
  .rail, .no-print, .banner-wrap, .connect-overlay, .toast-wrap, .viz-toggle { display: none !important; }
  .print-only { display: block; margin: 0 0 10px; }
  body, .main, .view-page.active { background: #fff !important; overflow: visible !important; height: auto !important; }
  .view-page.active { padding: 0 !important; }
  .panel, .stat { box-shadow: none !important; break-inside: avoid; }
  body.discreet .money, body.discreet td.num { filter: none !important; }
}
.panel.has-csv .viz-toggle { right: 62px; }
.sig-preview { max-height: 64px; max-width: 220px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px; }
.cert-box { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; justify-content: space-between; }

/* ---------------------------------------------------------- celular */
.mobile-back { display: none; }
@media (max-width: 760px) {
  #app { height: 100dvh; }
  /* menu embaixo, só com os ícones */
  .rail { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; height: calc(58px + env(safe-area-inset-bottom));
    padding: 4px 4px env(safe-area-inset-bottom); flex-direction: row; justify-content: space-around; align-items: center;
    border-right: 0; border-top: 1px solid var(--border); z-index: 60; gap: 0; }
  .rail-logo, .rail .grow, .rail-status, .rail-btn[title^="Modo discreto"] { display: none; }
  .rail-btn { width: auto; flex: 1; max-width: 64px; padding: 6px 0; }
  .rail-label { display: none; }
  .main { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
  #app > .connect-overlay { left: 0; bottom: 58px; }
  .view-page.active { padding: 14px 12px 24px; }
  .view-commercial.active, .view-board.active { padding: 10px 10px 0; }
  .page-head { flex-wrap: wrap; gap: 10px; }
  .page-head h2 { font-size: 22px; }
  .page-head .row, .row.wrap { flex-wrap: wrap; }
  .segmented { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .seg { white-space: nowrap; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .tab { white-space: nowrap; }
  /* números em duas colunas, mais baixos */
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat .stat-value { font-size: 20px; }
  .stat .muted.small { font-size: 11.5px; }
  .finance-body .stat-value { font-size: 17px; }
  /* tabelas rolam de lado em vez de estourar a tela */
  .view-page .table, .modal .table { display: block; overflow-x: auto; white-space: nowrap; }
  .legal-tools { flex-wrap: wrap; }
  /* Atendimento: lista OU conversa, a ficha por cima */
  .view-inbox .chatlist { width: 100%; border-right: 0; }
  .view-inbox .chatview { display: none; }
  body.chat-open .view-inbox .chatlist { display: none; }
  body.chat-open .view-inbox .chatview { display: flex; }
  .crm-panel:not(.hidden) { position: fixed; inset: 0 0 calc(58px + env(safe-area-inset-bottom)) 0; width: auto; z-index: 55; }
  .mobile-back { display: inline-flex; margin-left: -6px; }
  /* topo da conversa: só voltar, foto, nome e a ficha (tipo e casos ficam na ficha ☰) */
  .chat-head { gap: 8px; padding: 8px 8px; }
  .chat-head .stage-btn, .chat-head .icon-btn[title="Marcar como não lida"] { display: none; }
  .chat-head-info { min-width: 0; flex: 1; }
  .chat-head-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* caixa de texto ocupa o espaço; respostas rápidas pelo "/" */
  .composer-bar { gap: 2px; padding-left: 4px; padding-right: 4px; }
  .composer-input-wrap { min-width: 0; }
  .composer-bar .icon-btn.quick { display: none; }
  /* janelas ocupam quase a tela toda */
  .overlay { place-items: end center; }
  .modal, .modal.modal-wide { width: 100vw; max-width: 100vw; max-height: 92dvh; border-radius: 16px 16px 0 0; }
  .modal-actions { flex-wrap: wrap; }
  #toasts { bottom: calc(66px + env(safe-area-inset-bottom)); left: 8px; right: 8px; transform: none; }
  .toast { max-width: none; }
  .board-cols .col { min-width: 82vw; }
  .panel-head { flex-wrap: wrap; gap: 6px; }
  .panel { padding-left: 14px; padding-right: 14px; }
  .viz-plot { overflow: hidden; }
}
