:root {
  --bg: #f5f6fa; --surface: #ffffff; --surface-2: #f7f9fc; --line: #e3e8f0; --line-2: #d5dbe6;
  --text: #1c2333; --muted: #5b6478; --faint: #8a93a6;
  --brand: #1e2a63; --brand-ink: #ffffff; --brand-soft: #e8ebf7;
  --accent: #2ccbf2; --accent-ink: #0a7597; --accent-soft: #eafaff;
  --out-bg: #e6f7fc; --out-edge: #c5ebf7;
  --note-bg: #fff6d6; --note-edge: #f1dc8c; --note-ink: #4f4100; --note-label: #8a6d00;
  --col-bg: #f1f4f9; --danger: #c2255c; --danger-soft: #fde8ee; --ok: #2f7d4f; --ok-soft: #e9f6ee;
  --shadow: 0 1px 2px rgba(16, 23, 58, .06); --shadow-lg: 0 16px 40px rgba(16, 23, 58, .18);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e121d; --surface: #151a28; --surface-2: #121724; --line: #222a3d; --line-2: #2c354c;
    --text: #e6e9f2; --muted: #98a1b6; --faint: #6b7590;
    --brand: #26356e; --brand-ink: #ffffff; --brand-soft: #222a4a;
    --accent: #2ccbf2; --accent-ink: #6fd9f5; --accent-soft: #10303b;
    --out-bg: #12313d; --out-edge: #1d4a5a;
    --note-bg: #3a3110; --note-edge: #5c4d16; --note-ink: #f3e2a0; --note-label: #e0c35a;
    --col-bg: #121724; --danger: #ff6b98; --danger-soft: #3c1526; --ok: #6fd39a; --ok-soft: #12301f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e121d; --surface: #151a28; --surface-2: #121724; --line: #222a3d; --line-2: #2c354c;
  --text: #e6e9f2; --muted: #98a1b6; --faint: #6b7590;
  --brand: #26356e; --brand-ink: #ffffff; --brand-soft: #222a4a;
  --accent: #2ccbf2; --accent-ink: #6fd9f5; --accent-soft: #10303b;
  --out-bg: #12313d; --out-edge: #1d4a5a;
  --note-bg: #3a3110; --note-edge: #5c4d16; --note-ink: #f3e2a0; --note-label: #e0c35a;
  --col-bg: #121724; --danger: #ff6b98; --danger-soft: #3c1526; --ok: #6fd39a; --ok-soft: #12301f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.4 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg { flex: none; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: var(--brand); }
.login-box { width: 100%; max-width: 380px; background: var(--surface); border-radius: 18px; padding: 26px 22px 20px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 14px; }
.login-marca { display: flex; gap: 12px; align-items: center; margin-bottom: 6px; }
.login-marca b { display: block; font-size: 18px; }
.login-marca small { color: var(--muted); font-size: 13px; }
.login label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); }
.login input { height: 46px; border: 1px solid var(--line-2); border-radius: 11px; padding: 0 14px; background: var(--surface); font-size: 16px; color: var(--text); }
.login input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.login-erro { margin: 0; background: var(--danger-soft); color: var(--danger); border-radius: 10px; padding: 9px 12px; font-size: 14px; }
.login-dica { margin: 2px 0 0; text-align: center; color: var(--faint); font-size: 12.5px; }
.btn-pri { height: 48px; border: 0; border-radius: 12px; background: var(--brand); color: var(--brand-ink); font-weight: 700; font-size: 16px; }
.btn-pri:disabled { opacity: .6; cursor: wait; }

.marca { width: 36px; height: 36px; border-radius: 10px; background: var(--brand); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.marca svg { width: 20px; height: 20px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.login .marca { width: 44px; height: 44px; border-radius: 12px; }
.login .marca svg { stroke: var(--accent); }

/* ---------- moldura ---------- */
.app { height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; }
.top { height: 58px; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: relative; z-index: 5; }
.cli { min-width: 0; display: flex; align-items: baseline; gap: 6px; white-space: nowrap; overflow: hidden; }
.cli b { font-size: 16.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.cli span { color: var(--muted); font-size: 14.5px; }
.cli span::before { content: "· "; }
.sp { flex: 1; }
.abas-top { display: none; background: var(--col-bg); border-radius: 10px; padding: 4px; margin-left: 10px; }
.abas-top button { border: 0; background: none; padding: 6px 15px; border-radius: 7px; font-weight: 600; font-size: 14.5px; color: var(--muted); }
.abas-top button[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.conta-sel, .quadro-sel { height: 34px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 0 8px; max-width: 200px; }
.usuario { position: relative; }
.avatar-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 13.5px; }
:root[data-theme="dark"] .avatar-btn { color: #c9d1ff; }
.menu { position: absolute; right: 0; top: 44px; width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; display: flex; flex-direction: column; }
.menu-nome { padding: 8px 10px 10px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-nome b { display: block; color: var(--text); font-size: 14.5px; }
.menu a, .menu button { text-align: left; padding: 9px 10px; border-radius: 8px; border: 0; background: none; color: var(--text); text-decoration: none; font-size: 14.5px; }
.menu a:hover, .menu button:hover { background: var(--col-bg); }

main { position: relative; min-height: 0; overflow: hidden; }
.view { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0; }

.abas-baixo { display: flex; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.abas-baixo button { flex: 1; border: 0; background: none; height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; font-weight: 600; color: var(--faint); position: relative; }
.abas-baixo svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.abas-baixo button[aria-current="page"] { color: var(--brand); }
:root[data-theme="dark"] .abas-baixo button[aria-current="page"] { color: var(--accent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .abas-baixo button[aria-current="page"] { color: var(--accent); } }
.abas-baixo i, .badge { font-style: normal; min-width: 18px; height: 18px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; }
.abas-baixo i { position: absolute; top: 7px; left: calc(50% + 6px); }

@media (min-width: 900px) {
  .abas-top { display: flex; }
  .abas-baixo { display: none; }
  .cli span { display: none; }
}

.vazio { margin: auto; padding: 32px 20px; text-align: center; color: var(--muted); max-width: 420px; }
.aviso-topo { margin: 10px 16px 0; padding: 9px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 14px; }

/* ---------- agenda ---------- */
#agendaFrame { flex: 1; width: 100%; border: 0; background: var(--bg); }

/* ---------- funil ---------- */
.funil-topo { display: flex; align-items: center; gap: 10px; padding: 12px 16px 0; min-height: 46px; }
.funil-legenda { color: var(--muted); font-size: 13.5px; }
.cols { flex: 1; min-height: 0; display: flex; gap: 12px; overflow-x: auto; padding: 12px 16px 16px; scroll-snap-type: x mandatory; scroll-padding: 0 16px; }
.col { flex: 0 0 86vw; max-width: 330px; background: var(--col-bg); border-radius: 14px; display: flex; flex-direction: column; min-height: 0; scroll-snap-align: start; }
.colh { display: flex; align-items: center; gap: 9px; padding: 13px 14px 10px; font-weight: 700; font-size: 15px; }
.colh .pt { width: 10px; height: 10px; border-radius: 50%; background: var(--faint); }
.colh .n { font-style: normal; background: var(--line); color: var(--muted); border-radius: 999px; font-size: 12.5px; padding: 1px 9px; margin-left: auto; }
.col-cards { flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 10px; display: flex; flex-direction: column; gap: 10px; }
.col-vazia { color: var(--faint); font-size: 13px; text-align: center; padding: 14px 6px; }
.card { text-align: left; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; box-shadow: var(--shadow); display: block; }
.card:hover { border-color: var(--accent); }
.card[disabled] { cursor: default; }
.card[disabled]:hover { border-color: var(--line); }
.card .r1 { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.card .r1 span:first-of-type { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .r2 { font-size: 13.5px; color: var(--muted); margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.card .r3 { font-size: 12.5px; margin-top: 7px; color: var(--accent-ink); font-weight: 650; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.card .r3 .atras { color: var(--danger); }
.pri { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--danger); background: var(--danger-soft); border-radius: 999px; padding: 2px 8px; flex: none; }
.etq { font-size: 11px; font-weight: 650; color: var(--muted); background: var(--col-bg); border-radius: 999px; padding: 1px 8px; }
.ic { width: 20px; height: 20px; display: inline-flex; }
.ic svg { width: 100%; height: 100%; }
@media (min-width: 900px) { .col { flex-basis: 290px; } .cols { scroll-snap-type: none; } }

/* ---------- conversas ---------- */
#v-conversas { flex-direction: row; }
.clist { width: 100%; display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.filtros { display: flex; gap: 6px; padding: 12px 12px 8px; overflow-x: auto; scrollbar-width: none; flex: none; }
.filtros button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.filtros button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.busca { margin: 0 12px 8px; height: 38px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--surface-2); flex: none; }
.lista { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 8px; }
.ti { width: 100%; text-align: left; display: flex; gap: 11px; padding: 11px 10px; border-radius: 12px; border: 0; background: none; align-items: flex-start; }
.ti:hover { background: var(--surface-2); }
.ti[aria-current="true"] { background: var(--accent-soft); }
.av { width: 42px; height: 42px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 14.5px; display: flex; align-items: center; justify-content: center; flex: none; }
:root[data-theme="dark"] .av { color: #c9d1ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .av, :root:not([data-theme="light"]) .avatar-btn { color: #c9d1ff; } }
.ti-c { flex: 1; min-width: 0; }
.ti-l1 { display: flex; align-items: center; gap: 7px; }
.ti-l1 b { font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ti-l1 .ic { width: 17px; height: 17px; }
.ti-l1 time { margin-left: auto; font-size: 12px; color: var(--faint); flex: none; }
.ti-l2 { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.ti-l2 span { flex: 1; min-width: 0; font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ti-l3 { font-size: 12.5px; font-weight: 650; margin-top: 3px; }
.st-ia { color: var(--accent-ink); }
.st-equipe { color: var(--brand); }
:root[data-theme="dark"] .st-equipe { color: #c9d1ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .st-equipe { color: #c9d1ff; } }
.st-fila { color: var(--danger); }
.st-resolvida, .st-adiada { color: var(--faint); }
.mais { display: block; margin: 8px auto 4px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 16px; font-size: 13.5px; color: var(--muted); }

.conv { position: absolute; inset: 0; background: var(--surface-2); display: flex; flex-direction: column; min-height: 0; transform: translateX(100%); transition: transform .22s ease; z-index: 3; }
#v-conversas.aberta .conv { transform: none; }
.chead { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--line); min-height: 62px; flex: none; }
.voltar { width: 36px; height: 36px; border-radius: 50%; border: 0; background: none; display: inline-flex; align-items: center; justify-content: center; margin-left: -6px; }
.voltar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.chead-c { flex: 1; min-width: 0; }
.chead-c b { display: flex; align-items: center; gap: 7px; font-size: 16px; }
.chead-c b span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chead-c b .ic { width: 18px; height: 18px; }
.chead-c small { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.selo { font-size: 12.5px; font-weight: 650; border-radius: 999px; padding: 5px 11px; white-space: nowrap; flex: none; }
.selo.st-ia { background: var(--accent-soft); }
.selo.st-equipe { background: var(--brand); color: var(--brand-ink); }
.selo.st-fila { background: var(--danger-soft); }
.selo.st-resolvida, .selo.st-adiada { background: var(--col-bg); }
.msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 14px 20px; display: flex; flex-direction: column; gap: 8px; }
.dia { align-self: center; font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 3px 10px; margin: 8px 0 2px; }
.tb { max-width: min(78%, 560px); padding: 8px 12px 6px; border-radius: 14px; font-size: 15px; line-height: 1.42; white-space: pre-wrap; overflow-wrap: anywhere; }
.tb small { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 1px; }
.tb time { display: block; text-align: right; font-size: 11px; color: var(--faint); margin-top: 2px; }
.tb.in { background: var(--surface); border: 1px solid var(--line); align-self: flex-start; border-top-left-radius: 4px; }
.tb.out { background: var(--out-bg); border: 1px solid var(--out-edge); align-self: flex-end; border-top-right-radius: 4px; }
.tb.nota { align-self: stretch; max-width: none; background: var(--note-bg); border: 1px solid var(--note-edge); color: var(--note-ink); }
.tb.nota small { color: var(--note-label); letter-spacing: .02em; }
.tb a { color: var(--accent-ink); }
.ativ { align-self: center; font-size: 12px; color: var(--faint); text-align: center; max-width: 90%; }
.anexo-img { display: block; max-width: 100%; max-height: 300px; border-radius: 10px; margin: 4px 0; }
.anexo-aud { display: block; width: 260px; max-width: 100%; margin: 4px 0; }
.anexo-arq { display: inline-flex; gap: 6px; align-items: center; margin: 4px 0; font-weight: 600; }
.cpe { flex: none; padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--muted); }
.cpe a { margin-left: auto; flex: none; text-decoration: none; background: var(--brand); color: var(--brand-ink); border-radius: 10px; padding: 8px 13px; font-weight: 650; font-size: 13.5px; }
.carregando { margin: auto; color: var(--faint); font-size: 14px; }

@media (min-width: 900px) {
  .clist { width: 340px; flex: none; border-right: 1px solid var(--line); }
  .conv { position: relative; inset: auto; flex: 1; transform: none; transition: none; }
  .voltar { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
